[Code] wrap length
- BeebMaster
- Posts: 7379
- Joined: Sun Aug 02, 2009 5:59 pm
- Location: Lost in the BeebVault!
- Contact:
[Code] wrap length
Is it possible to set the line length for wraparound when using "code" tags?
Lines longer than the message width are displayed with a horizontal scroll bar, and it would look a lot better if they wrapped at the same point as the right-hand margin in the normal message text.
e.g. the end of my post here where I posted a one-liner which doesn't wrap.
Lines longer than the message width are displayed with a horizontal scroll bar, and it would look a lot better if they wrapped at the same point as the right-hand margin in the normal message text.
e.g. the end of my post here where I posted a one-liner which doesn't wrap.
Re: [Code] wrap length
no, code tags in phpBB don't wrap. There might be an option to allow it, but I've never been on a board that does it
Re: [Code] wrap length
It is possible, but it requires hacking the theme. IIRC older versions of phpBB did this automatically, but recent versions try to look more pretty by adding scrollbars.
Basically in styles/prosilver/theme/content.css in the section defining ".codebox code {"
* remove "max-height: 200px;" if you want to remove vertical scrolling and make the codebox as tall as possible.
* add "white-space: break-spaces;" and it will turn off horizontal scrolling and will word-wrap
Of course all hacks like this make phpBB upgrades harder, and the admins of this forum don't want to do things that'll make life harder (which I totally agree with).
And with the "select all" option people can easily cut'n'paste into their editor of choice, which is what I do if I want to look at longer code segments.
Rgds
Stephen
Stephen
Re: [Code] wrap length
You could make the line shorter:
Code: Select all
DIMosb 32:!osb=&1f001000:osb!4=0:osb!8=&200000:$(osb+11)="SYST":osb?15=13:A%=20:X%=osb MOD256:Y%=osb/256:CA.&FFF1
- IanJeffray
- Posts: 5962
- Joined: Sat Jun 06, 2020 3:50 pm
- Contact:
Re: [Code] wrap length
smaller still if you didn't call the buffer the gratuitously long "osb".Kweepa wrote: ↑Mon Mar 27, 2023 7:14 pm You could make the line shorter:Code: Select all
DIMosb 32:!osb=&1f001000:osb!4=0:osb!8=&200000:$(osb+11)="SYST":osb?15=13:A%=20:X%=osb MOD256:Y%=osb/256:CA.&FFF1
- TobyLobster
- Posts: 618
- Joined: Sat Aug 31, 2019 7:58 am
- Contact:
Re: [Code] wrap length
and:IanJeffray wrote: ↑Mon Mar 27, 2023 7:50 pmsmaller still if you didn't call the buffer the gratuitously long "osb".Kweepa wrote: ↑Mon Mar 27, 2023 7:14 pm You could make the line shorter:Code: Select all
DIMosb 32:!osb=&1f001000:osb!4=0:osb!8=&200000:$(osb+11)="SYST":osb?15=13:A%=20:X%=osb MOD256:Y%=osb/256:CA.&FFF1
Code: Select all
osb!8=2^21
Re: [Code] wrap length
Ah! I thought there'd be a shorter way to express that!
Edit: can we also do
Edit: do we need the MOD 256 here?
Edit: can we also do
Code: Select all
$(osb+11)="SYST"+CHR$13
Code: Select all
X%=osb MOD256
- BeebMaster
- Posts: 7379
- Joined: Sun Aug 02, 2009 5:59 pm
- Location: Lost in the BeebVault!
- Contact:
Re: [Code] wrap length
Well yes, but I still wanted the "short" version to be recognisable as a contraction of the program I posted in the same post.
Re: [Code] wrap length
Does this work I wonder...
𝙳𝙸𝙼𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝟹𝟸:!𝚘𝚜𝚋𝚕𝚘𝚌𝚔=0:𝚘𝚜𝚋𝚕𝚘𝚌𝚔!𝟺=0:$(𝚘𝚜𝚋𝚕𝚘𝚌𝚔+𝟽)=𝙲𝙷𝚁$0+𝙲𝙷𝚁$0+𝙲𝙷𝚁$0+𝙲𝙷𝚁$𝟹𝟸+"𝚂𝚈𝚂𝚃"+𝙲𝙷𝚁$𝟷𝟹:𝚘𝚜𝚋𝚕𝚘𝚌𝚔?𝟷=𝟷𝟼:𝚘𝚜𝚋𝚕𝚘𝚌𝚔?𝟹=𝟹𝟷:𝙰%=&𝟷𝟺:𝚇%=𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝙼𝙾𝙳𝟸𝟻𝟼:𝚈%=𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝙳𝙸𝚅𝟸𝟻𝟼:𝙲𝙰𝙻𝙻&𝙵𝙵𝙵𝟷
(using unicode's monospace characters)
𝙳𝙸𝙼𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝟹𝟸:!𝚘𝚜𝚋𝚕𝚘𝚌𝚔=0:𝚘𝚜𝚋𝚕𝚘𝚌𝚔!𝟺=0:$(𝚘𝚜𝚋𝚕𝚘𝚌𝚔+𝟽)=𝙲𝙷𝚁$0+𝙲𝙷𝚁$0+𝙲𝙷𝚁$0+𝙲𝙷𝚁$𝟹𝟸+"𝚂𝚈𝚂𝚃"+𝙲𝙷𝚁$𝟷𝟹:𝚘𝚜𝚋𝚕𝚘𝚌𝚔?𝟷=𝟷𝟼:𝚘𝚜𝚋𝚕𝚘𝚌𝚔?𝟹=𝟹𝟷:𝙰%=&𝟷𝟺:𝚇%=𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝙼𝙾𝙳𝟸𝟻𝟼:𝚈%=𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝙳𝙸𝚅𝟸𝟻𝟼:𝙲𝙰𝙻𝙻&𝙵𝙵𝙵𝟷
(using unicode's monospace characters)
Re: [Code] wrap length
"DIM X% 32" is a neat shortcut that I've seen jgh using.
Re: [Code] wrap length
78 characters if you don't mind the memory leak:
Having X% pointing to your control block is a useful technique as you can access it with X% indirections. I set up a global control block and initialise X%/Y% to point to it, and reinistialise X%/Y% at the start of any main loop if the program contains any calls that use X%/Y% themselves.
Eg:
10 REM > Demo
20 DIM ctrl% 31:X%=ctrl%:Y%=X%DIV256
30 blah blah
40 ON ERROR IF FNerr THEN PROCexit(ERR)
50 REPEAT:X%=ctrl%:Y%=X%DIV256
60 blah blah
70 UNTIL done:PROCexit(0)
80 :
90 DEFFNnetfs_op(A%,N%,A$):!X%=A%*256:X%?3=N%+LENA$:$(X%+N$)=A$:A%=&14:CALL&FFF1:ENDPROC
100 DEFPROCgbpb(A%,ch%,ad%,nm%,pt%):?X%=ch%:X%!1=ad%:X%!5=nm%:X%!9=pt%:CALL&FFD1:ENDPROC
110 DEFFNbyte(A%,X%,Y%)=((USR&FFF4)AND&FF00)DIV256
sorta thing.
I also program for A% and A$ to be "scratch" variables that can be used in any part of the program, knowing that if you call elsewhere they may have been trashed, so save having to save and restore them all the time.
Code: Select all
DIMX%32:Y%=X%DIV256:!X%=&1000:X%!3=31:X%!7=0:$(X%+10)="SYST":A%=&14:CALL&FFF1
Eg:
10 REM > Demo
20 DIM ctrl% 31:X%=ctrl%:Y%=X%DIV256
30 blah blah
40 ON ERROR IF FNerr THEN PROCexit(ERR)
50 REPEAT:X%=ctrl%:Y%=X%DIV256
60 blah blah
70 UNTIL done:PROCexit(0)
80 :
90 DEFFNnetfs_op(A%,N%,A$):!X%=A%*256:X%?3=N%+LENA$:$(X%+N$)=A$:A%=&14:CALL&FFF1:ENDPROC
100 DEFPROCgbpb(A%,ch%,ad%,nm%,pt%):?X%=ch%:X%!1=ad%:X%!5=nm%:X%!9=pt%:CALL&FFD1:ENDPROC
110 DEFFNbyte(A%,X%,Y%)=((USR&FFF4)AND&FF00)DIV256
sorta thing.
I also program for A% and A$ to be "scratch" variables that can be used in any part of the program, knowing that if you call elsewhere they may have been trashed, so save having to save and restore them all the time.
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_