[Code] wrap length

feedback, comments and suggestions pertaining to the stardot forum
Post Reply
User avatar
BeebMaster
Posts: 7379
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

[Code] wrap length

Post by BeebMaster »

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.
Image
User avatar
scruss
Posts: 653
Joined: Sun Jul 01, 2018 4:12 pm
Location: Toronto
Contact:

Re: [Code] wrap length

Post by scruss »

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
User avatar
sweh
Posts: 3314
Joined: Sat Mar 10, 2012 12:05 pm
Location: 07410 New Jersey
Contact:

Re: [Code] wrap length

Post by sweh »

scruss wrote: Mon Mar 27, 2023 2:08 am 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
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
Kweepa
Posts: 73
Joined: Mon Dec 16, 2013 11:45 pm
Contact:

Re: [Code] wrap length

Post by Kweepa »

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
:lol:
User avatar
IanJeffray
Posts: 5962
Joined: Sat Jun 06, 2020 3:50 pm
Contact:

Re: [Code] wrap length

Post by IanJeffray »

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
:lol:
smaller still if you didn't call the buffer the gratuitously long "osb".
User avatar
TobyLobster
Posts: 618
Joined: Sat Aug 31, 2019 7:58 am
Contact:

Re: [Code] wrap length

Post by TobyLobster »

IanJeffray wrote: Mon Mar 27, 2023 7:50 pm
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
:lol:
smaller still if you didn't call the buffer the gratuitously long "osb".
and:

Code: Select all

osb!8=2^21
User avatar
BigEd
Posts: 6261
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: [Code] wrap length

Post by BigEd »

Ah! I thought there'd be a shorter way to express that!

Edit: can we also do

Code: Select all

$(osb+11)="SYST"+CHR$13
Edit: do we need the MOD 256 here?

Code: Select all

X%=osb MOD256
User avatar
BeebMaster
Posts: 7379
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: [Code] wrap length

Post by BeebMaster »

Well yes, but I still wanted the "short" version to be recognisable as a contraction of the program I posted in the same post.
Image
User avatar
BigEd
Posts: 6261
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: [Code] wrap length

Post by BigEd »

Does this work I wonder...
𝙳𝙸𝙼𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝟹𝟸:!𝚘𝚜𝚋𝚕𝚘𝚌𝚔=0:𝚘𝚜𝚋𝚕𝚘𝚌𝚔!𝟺=0:$(𝚘𝚜𝚋𝚕𝚘𝚌𝚔+𝟽)=𝙲𝙷𝚁$0+𝙲𝙷𝚁$0+𝙲𝙷𝚁$0+𝙲𝙷𝚁$𝟹𝟸+"𝚂𝚈𝚂𝚃"+𝙲𝙷𝚁$𝟷𝟹:𝚘𝚜𝚋𝚕𝚘𝚌𝚔?𝟷=𝟷𝟼:𝚘𝚜𝚋𝚕𝚘𝚌𝚔?𝟹=𝟹𝟷:𝙰%=&𝟷𝟺:𝚇%=𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝙼𝙾𝙳𝟸𝟻𝟼:𝚈%=𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝙳𝙸𝚅𝟸𝟻𝟼:𝙲𝙰𝙻𝙻&𝙵𝙵𝙵𝟷
(using unicode's monospace characters)
gfoot
Posts: 987
Joined: Tue Apr 14, 2020 9:05 pm
Contact:

Re: [Code] wrap length

Post by gfoot »

BigEd wrote: Mon Mar 27, 2023 11:14 pm Does this work I wonder...
𝙳𝙸𝙼𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝟹𝟸:!𝚘𝚜𝚋𝚕𝚘𝚌𝚔=0:𝚘𝚜𝚋𝚕𝚘𝚌𝚔!𝟺=0:$(𝚘𝚜𝚋𝚕𝚘𝚌𝚔+𝟽)=𝙲𝙷𝚁$0+𝙲𝙷𝚁$0+𝙲𝙷𝚁$0+𝙲𝙷𝚁$𝟹𝟸+"𝚂𝚈𝚂𝚃"+𝙲𝙷𝚁$𝟷𝟹:𝚘𝚜𝚋𝚕𝚘𝚌𝚔?𝟷=𝟷𝟼:𝚘𝚜𝚋𝚕𝚘𝚌𝚔?𝟹=𝟹𝟷:𝙰%=&𝟷𝟺:𝚇%=𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝙼𝙾𝙳𝟸𝟻𝟼:𝚈%=𝚘𝚜𝚋𝚕𝚘𝚌𝚔 𝙳𝙸𝚅𝟸𝟻𝟼:𝙲𝙰𝙻𝙻&𝙵𝙵𝙵𝟷
(using unicode's monospace characters)
"DIM X% 32" is a neat shortcut that I've seen jgh using.
Kweepa
Posts: 73
Joined: Mon Dec 16, 2013 11:45 pm
Contact:

Re: [Code] wrap length

Post by Kweepa »

gfoot wrote: Tue Mar 28, 2023 12:18 am "DIM X% 32" is a neat shortcut that I've seen jgh using.
Ooh, clever
User avatar
jgharston
Posts: 5321
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: [Code] wrap length

Post by jgharston »

78 characters if you don't mind the memory leak:

Code: Select all

DIMX%32:Y%=X%DIV256:!X%=&1000:X%!3=31:X%!7=0:$(X%+10)="SYST":A%=&14:CALL&FFF1
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

$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
Post Reply

Return to “stardot FORUM”