From https://www.bbcbasic.co.uk/bbcwin/manua ... tml#cursor
"The shape of the text cursor can be controlled (to some degree) by using VDU 23 to set the start line and end line of the cursor 'block'; this affects its height and vertical position. The 'start line' and 'end line' are controlled by the following commands:
VDU 23,0,10,s,0;0;0; : REM Set start line
VDU 23,0,11,e,0;0;0; : REM Set end line"
Anyone who can clarify this..?
The shape of the text cursor
-
- Posts: 127
- Joined: Tue 07 May 2019, 16:47
The shape of the text cursor
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. C++ in 2021.
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: The shape of the text cursor
First of all, the figures you can use for the start and end appear to be limited by the total possible height of the chosen font, which for the standard font used in BB4W appears to be about 12.
Secondly there appears to be an anomaly here. Most of the VDU23 commands appear to need four sets of ; - see VDU23,1 or VDU23,0,10; Although these cursor controls work with a comma after the start and end figure, they appear to work just as well with a semi-colon in that position. It would be interesting to know the reason why and whether using a semi-colon will produce any errors.
The mini program below turns the cursor into a hyphen that appears opposite the middle of the ">" prompt - but if you set a larger font size, the hyphen shape will appear above the middle of the prompt.
Note that the only purpose of the INPUT commands is to cause a cursor to appear. Just press Return repeatedly.
Secondly there appears to be an anomaly here. Most of the VDU23 commands appear to need four sets of ; - see VDU23,1 or VDU23,0,10; Although these cursor controls work with a comma after the start and end figure, they appear to work just as well with a semi-colon in that position. It would be interesting to know the reason why and whether using a semi-colon will produce any errors.
The mini program below turns the cursor into a hyphen that appears opposite the middle of the ">" prompt - but if you set a larger font size, the hyphen shape will appear above the middle of the prompt.
Code: Select all
PRINT"This 1":INPUTa$
g%=GET
REM Sets the cursor to a solid block
VDU23,0,10;0;0;0;
PRINT"This 2":INPUTa$
g%=GET
REM Lowers the start and raises the end
VDU23,0,10,6,0;0;0;
VDU23,0,11,8,0;0;0;
PRINT"This 3":INPUTa$
Re: The shape of the text cursor
I strongly encourage people NOT to mess with the commas/semicolons in these commands: as I recall, it determines whether BB4W passes the underlying system call 4 or 2 byte numbers - if you pass blocks of the wrong size you are likely to mess up the memory block for the SYS call, with bizarre and hard-to-interpret consequences. The number of parameters, and their size, will reflect what the Windows API command expects. By all means experiment, but expect it to fail in odd ways!
I think Kendall is correct that the cursor is probably only variable within the limits of the current font.
Best wishes,
D
I think Kendall is correct that the cursor is probably only variable within the limits of the current font.
Best wishes,
D
-
- Posts: 127
- Joined: Tue 07 May 2019, 16:47
Re: The shape of the text cursor
Thanks, but I still struggle to change the cursor from overtype (line) vs insert (block) mode.
The manual like you uses VDU 23,0,10;0;0;0; to block mode, but I can't figure out to get the cursor back to a line.
The manual like you uses VDU 23,0,10;0;0;0; to block mode, but I can't figure out to get the cursor back to a line.
Code: Select all
rem An attempt to switch the cursor between insert and block mode.
mode 8
insert$ = chr$(134)
insert = true
repeat
key$ = inkey$(0)
case key$ of
when insert$
if insert then
vdu 23,0,10;0;0;0;
insert = false
else
vdu 23,??????
insert = true
endif
print insert
endcase
until false
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. C++ in 2021.
Re: The shape of the text cursor
Hi Ivan,
I think, after a bit of experimentation, that:
VDU 23,0,10,s,0;0;0; sets the top of the cursor s pixels down from the top of the character cell
VDU 23,0,11,e,0;0;0; sets the bottom of the cursor e pixels down from the top of the character cell, and
VDU 23,0,18,w,0;0;0; sets the width of the cursor to w pixels.
These limits do NOT appear to be bounded by the character cell, except that the start cannot be negative.
All cells within the block defined by these parameters will be black - as far as I can see there is no way (using this approach at least) that you could make your cursor "T" shaped, for example.
We can find the width and height of the character cell as @char.x% and @char.y%. In the code below I've renamed these for maybe a little extra clarity, but you could use them directly. The code sets up a few options, and shows them at input statements, and then loops through the possible options within this range, printing an "A" for reference. Putting "STEP 2" after each FOR loop will still give a decent idea, and is only 1/8th the time!
Hope that's useful!
D
I think, after a bit of experimentation, that:
VDU 23,0,10,s,0;0;0; sets the top of the cursor s pixels down from the top of the character cell
VDU 23,0,11,e,0;0;0; sets the bottom of the cursor e pixels down from the top of the character cell, and
VDU 23,0,18,w,0;0;0; sets the width of the cursor to w pixels.
These limits do NOT appear to be bounded by the character cell, except that the start cannot be negative.
All cells within the block defined by these parameters will be black - as far as I can see there is no way (using this approach at least) that you could make your cursor "T" shaped, for example.
We can find the width and height of the character cell as @char.x% and @char.y%. In the code below I've renamed these for maybe a little extra clarity, but you could use them directly. The code sets up a few options, and shows them at input statements, and then loops through the possible options within this range, printing an "A" for reference. Putting "STEP 2" after each FOR loop will still give a decent idea, and is only 1/8th the time!
Hope that's useful!
D
Code: Select all
cell_height% = @char.y%
cell_width% = @char.x%
PRINT cell_height%, cell_width%
VDU 23,0,10,0,0;0;0;
VDU 23,0,11,cell_height%,0;0;0;
VDU 23,0,18,cell_width%,0;0;0;
INPUT q$
VDU 23,0,10,cell_height%*1/3,0;0;0;
VDU 23,0,11,cell_height%*2/3,0;0;0;
VDU 23,0,18,cell_width%,0;0;0;
INPUT q$
VDU 23,0,10,4,0;0;0;
VDU 23,0,11,8,0;0;0;
VDU 23,0,18,4,0;0;0;
INPUT q$
VDU 23,0,10,cell_height%-2,0;0;0;
VDU 23,0,11,cell_height%,0;0;0;
VDU 23,0,18,1,0;0;0;
INPUT q$
VDU 23,0,10,cell_height%-2,0,0;0;0;
VDU 23,0,11,cell_height%,0;0;0;
VDU 23,0,18,0,0;0;0;
INPUT q$
FOR x%= 0 TO cell_height%-1
FOR y%=x%+1 TO cell_height%
FOR z%=1 TO cell_width%
VDU 23,0,10,x%,0,0;0;0;
VDU 23,0,11,y%,0;0;0;
VDU 23,0,18,z%,0;0;0;
PRINT "A";
WAIT 10
NEXT z%
NEXT y%
NEXT x%
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: The shape of the text cursor
David's recollection is correct: using ; passes a 4-byte number, using , passes a 2-byte number, which is why it is curious that in this instance the command appears - I stress "appears" - to accept either.
I realise now that the original questioner didn't really want to change the shape of the cursor, he wanted to restore the original flashing underline cursor after changing the cursor into a block (the over-write mode cursor). The answer is that I don't know. I can't find any documentation, either in the Help file or in the Wiki. Playing around with the various parameters of VDU23 doesn't throw up any obvious answers either.
Over to the experts ...
I realise now that the original questioner didn't really want to change the shape of the cursor, he wanted to restore the original flashing underline cursor after changing the cursor into a block (the over-write mode cursor). The answer is that I don't know. I can't find any documentation, either in the Help file or in the Wiki. Playing around with the various parameters of VDU23 doesn't throw up any obvious answers either.
Over to the experts ...
Re: The shape of the text cursor
The "Standard" cursor is a full-width line at the bottom of the character cell, so my final version:
VDU 23,0,10,cell_height%-2,0,0;0;0;
VDU 23,0,11,cell_height%,0;0;0;
VDU 23,0,18,0,0;0;0;
or the equivalent with VDU 23,0,10,cell_height%-1,0,0;0;0;
will do it.
Best wishes,
D
VDU 23,0,10,cell_height%-2,0,0;0;0;
VDU 23,0,11,cell_height%,0;0;0;
VDU 23,0,18,0,0;0;0;
or the equivalent with VDU 23,0,10,cell_height%-1,0,0;0;0;
will do it.
Best wishes,
D
-
- Posts: 127
- Joined: Tue 07 May 2019, 16:47
Re: The shape of the text cursor
This code seems to do the job:
Thanks
Code: Select all
if insert then
vdu 23,0,10,0,0;0;0;
vdu 23,0,11,cell_height%,0;0;0;
vdu 23,0,18,cell_width%,0;0;0;
insert = false
else
vdu 23,0,10,cell_height%-2,0,0;0;0;
vdu 23,0,11,cell_height%,0;0;0;
vdu 23,0,18,0,0;0;0;
insert = true
endif
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. C++ in 2021.
Re: The shape of the text cursor
Hi Ivan,
Don't forget that you can simply substitute @char.y% for cell_height% and @char.x% for cell_width%, throughout - no need to define some extra variables. I only did it to make more explicit what each one was.
Best wishes,
D
Don't forget that you can simply substitute @char.y% for cell_height% and @char.x% for cell_width%, throughout - no need to define some extra variables. I only did it to make more explicit what each one was.
Best wishes,
D
-
- Posts: 127
- Joined: Tue 07 May 2019, 16:47
Re: The shape of the text cursor
Hi DDRM,
As a person with strange dyslextic issues, I can't appriciate enough that you made the example as clear, as you did.
I often write extra lines to make my code clear and easy to read.
Regards,
Ivan
As a person with strange dyslextic issues, I can't appriciate enough that you made the example as clear, as you did.
I often write extra lines to make my code clear and easy to read.
Regards,
Ivan
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. C++ in 2021.