Commit af05965b authored by Ben Avison's avatar Ben Avison
Browse files

Optimisation to new WimpSymbol substitution code: in icons containing fonts...

Optimisation to new WimpSymbol substitution code: in icons containing fonts other than the desktop font, the substitution table is only calculated when a symbol character is encountered.

Embryonic cut-n-paste support introduced (currently in desktop builds only):
  * workspace is allocated and initialised;
  * extended Wimp_GetCaretPosition implemented;
  * pushfontstring adapted to allow insertion of arbitrary control sequences in
    font strings (to allow selected text to be plotted in inverted colours).
Inverted, unfilled text icons now work properly again in <256-colour modes.
Reworked NC error box code: see Doc.IconHigh.

Version 4.11. Tagged as 'Wimp-4_11'
parent f33646b8
IconHigh (and pointers) in Wimp error boxes
===========================================
Overview
--------
NC and STB builds of the Wimp feature support for the use of IconHigh to
navigate error boxes. This can also impact upon the pointer that is
used during error box display.
Spinner branch Wimps since v 3.97, and trunk Wimps v 4.01 - 4.10, have the
following functionality:
The pointer is always visible throughout error boxes: shape number 1,
programmed to ptr_default. IconHigh is activated for the duration, if and
only if the pointer shape number was 0 on entry to SWI Wimp_ReportError.
Unfortunately, if the hourglass is active on entry to the SWI, the pointer
shape is detected as 2 or 3 - even if smashing the hourglass would have
returned the pointer shape to 0; this leads to (a) IconHigh not being used
and (b) the pointer being incorrectly restored afterwards.
For comparison, the browser engages pointer shape 0 (invisible) whenever a
key is pressed, and shape 1 whenever the mouse is moved.
Changes
-------
The following behaviour will be implemented in NC / STB builds of the Wimp
in versions 4.11 onwards:
1) IconHigh will be active unconditionally during error box display.
2) SWI Hourglass_Smash will be called before the initial pointer shape
is recorded.
3) The pointer shape number will be preserved over opening of the error box.
4) Wimp_Extend 12 will be implemented: this will (a) set the pointer to
shape 0, and (b) flag that the Wimp should reprogram the pointer to
shape 1 the next time that the mouse state changes (position or buttons).
This will be called from IconHigh when it repositions the mouse
following an arrow key keypress; the fact that OS_Word 21,3 flushes the
mouse buffer means that the Wimp can guarantee that the next read from
the mouse buffer will contain the state to compare future reads against.
By placing the relevant code inside the "getmouseposn" routine,
multi-tasking IconHigh (eg on-screen keyboards) can automatically be
supported, as well as single-tasking IconHigh (in error boxes).
BAvison 09-Nov-1998
......@@ -47,7 +47,6 @@
Option Twitter, false ; Anti-twitter on redraws
Option TwitterOnlyMenus, false:LAND:Twitter ; Anti-twitter only menus
Option RegisterWIMPSymbolFont, true ; Register WIMPSymbol font
Option PreservePointerOnError, false ; Preserve mouse pointer state over errors
Option NKmessages1, false ; message queue optimisation (using lastpointer)
Option NKmessages2, true ; message queue optimisation
; (remove multiple memory change messages)
......@@ -77,6 +76,7 @@
Option ForceTwitter, false :LAND: Twitter ; Twitter needs-help windows & ignore interlace ModeFlags bit
Option HideIconBar, false ; icon bar is behind Wimp back window until brought to front
Option UTF8, true ; support for UTF-8 alphabet (Unicode)
Option CnP, true ; support for RISC OS selection model and Cut-and-Paste in writeable icons
Option RegisterMessages, false
Option RegisterTools2D, false
......
......@@ -5,8 +5,8 @@
GBLA Module_Version
GBLS Module_MinorVersion
GBLS Module_Date
Module_MajorVersion SETS "4.10"
Module_Version SETA 410
Module_MajorVersion SETS "4.11"
Module_Version SETA 411
Module_MinorVersion SETS ""
Module_Date SETS "29 Oct 1998"
Module_Date SETS "09 Nov 1998"
END
/* (4.10)
/* (4.11)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 4.10
#define Module_MajorVersion_CMHG 4.11
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 29 Oct 1998
#define Module_Date_CMHG 09 Nov 1998
#define Module_MajorVersion "4.10"
#define Module_Version 410
#define Module_MajorVersion "4.11"
#define Module_Version 411
#define Module_MinorVersion ""
#define Module_Date "29 Oct 1998"
#define Module_Date "09 Nov 1998"
......@@ -76,6 +76,9 @@ textop_painttext
MOV R2,R1
MOV R1,#is_deleted
MOV R9,#bignum
[ CnP
MOV R7, #nullptr
]
BL pushfontstring
LDR R9,last_fg_gcol
......@@ -189,6 +192,9 @@ textop_gettextwidth
MOV R2,R1
MOV R1,#is_deleted
[ CnP
MOV R7, #nullptr
]
BL pushfontstring
[ true
MOV R2,#0
......@@ -308,6 +314,10 @@ SWIWimp_Extend
]
TEQ R0,#11 ; In: R1 = pointer to block to fill with furniture dimensions
BEQ %FT11 ; [R1,#0] = window handle to use, or 0 for generic values
[ NCErrorBox
TEQ R0,#12
BEQ %FT12
]
B ExitWimp
[ ChildWindows
......@@ -364,9 +374,24 @@ SWIWimp_Extend
B ExitWimp
]
[ NCErrorBox
; Handle hiding of pointer for the duration of keyboard-driving of pointer
12 MOV R0, #106
MOV R1, #0
SWI XOS_Byte ; turn off pointer
MOV R0, #1
ADRL R14, ptrsuspendflag
STR R0, [R14]
B ExitWimp
]
extendjumptable
B getspriteaddr
[ CnP
B extendjumptable_pushfontstring
|
B pushfontstring
]
B callaswi
B ExitWimp
B ExitWimp2
......@@ -374,6 +399,11 @@ extendjumptable
B exitcicon
B int_setcolour
[ CnP
extendjumptable_pushfontstring
MOV R7, #nullptr
B pushfontstring
]
^ 0, userblk
furnblock_handle # 4
furnblock_lborder # 4
......
......@@ -995,6 +995,13 @@ menuhandles # 4*maxmenus ; handle of relevant window
menudata # 4*maxmenus ; ptrs to menu definitions (-1 if dial)
menuselections # 4*maxmenus ; selection index in each menu
[ CnP
ghostcaretdata # 28 ; window,icon,x,y coords,height,index
; [ghostcaretdata+24]=ghostcaretscrollx
selectionwindow # 4 ; external handle of the window that has the unshaded selection (or -1 if none)
font_cs_list # 4 ; for pointing to font control sequence list during pushfontstring
]
[ UTF8
keystring_buflen # 1 ; number of bytes in keystring_buffer (see below)
keyprocess_buflen # 1 ; number of bytes in keyprocess_buffer (see below)
......@@ -1445,10 +1452,14 @@ swap_filename # 4 ; File name for next swap file.
swap_path # 256 ; Path name for swap files.
]
[ PreservePointerOnError
[ NCErrorBox
ptrshlflag # 4 ; Pointer shape and linkage flag (saved here during
; ReportError) JRC 25 Jul 1997
]
ptrsuspenddata # 12 ; To store x,y,b last generated by IconHigh
ptrsuspendflag # 4 ; 0 => normal
; 1 => waiting for mouse move generated by IconHigh
; 2 => waiting for next mouse move *not* generated by IconHigh
]
maxwork * :INDEX:@
......@@ -1464,11 +1475,14 @@ maxwork * :INDEX:@
[ PoppingIconBar
! 0, "#iconbar_pop_state = R12+&" :CC: :STR: :INDEX: iconbar_pop_state
]
[ CnP
! 0, "#ghostcaretdata = R12+&" :CC: :STR: :INDEX: ghostcaretdata
! 0, "#selectionwindow = R12+&" :CC: :STR: :INDEX: selectionwindow
]
[ Autoscr
! 0, "#dragtype = R12+&" :CC: :STR: :INDEX: dragtype
! 0, "#dragflags = R12+&" :CC: :STR: :INDEX: dragflags
! 0, "#autoscr_state = R12+&" :CC: :STR: :INDEX: autoscr_state
! 0, " autoscr data size = " :CC: :STR: (:INDEX: autoscr_END - :INDEX: autoscr_state)
]
......@@ -1500,6 +1514,10 @@ w_toggleheight # 4 ; height of previous work area if toggle
w_origflags # 4
]
[ CnP
w_seldata # 32 ; selection icon, x offset, width, y offset, height+flags, low,high indexes
] ; [w_seldata+28] = w_selscrollx
[ ChildWindows
w_bwax0 # 4 ; previous position/size (for toggling)
w_bway0 # 4
......@@ -1615,6 +1633,9 @@ w_size # 0 ; end of window data
[ ChildWindows
ASSERT (w_old_end - w_old_data) = (w_new_end - w_new_data)
]
[ CnP
! 0, "Selection data = handle+&" :CC: :STR: :INDEX: w_seldata
]
; bit masks for flags/status
......
......@@ -2749,6 +2749,10 @@ inittasks
STR R0,commandhandle
STR R0,redrawhandle
STR R0,caretdata
[ CnP
STR R0,ghostcaretdata
STR R0,selectionwindow
]
STR R0,menucaretwindow
STR R0,pendingtask
;
......@@ -2862,6 +2866,10 @@ inittasks
ADRL R14,fontnamebuffer
STR R0,[R14] ; ok to use STR, puts 0 in first loc of buffer
]
[ NCErrorBox
ADRL R14, ptrsuspendflag
STR R0, [R14]
]
;
MOV R0,#nullptr
STR R0,ptrwindow
......@@ -3633,6 +3641,10 @@ crw5e
STR R14,[handle,#w_old_flags]
STR R14,[handle,#w_opening_link + ll_forwards] ; not on the list of opening windows
]
[ CnP
MOV R14, #nullptr
STR R14, [handle, #w_seldata] ; no icon contains a selection
]
; Window is now completely valid
......
......@@ -2266,7 +2266,7 @@ trykeys_getinternalkeycode
02 STRB R3, keyin_buflen
; Get a key from our input buffer
ADR R7, keyin_buflen ; R5 already set up
ADRL R7, keyin_buflen ; R5 already set up
BL get_internal_keycode_from_buffer
CMP R6, #-1 ; was there one?
BEQ nothing ; no keys to handle
......@@ -4026,6 +4026,34 @@ newmouseposn
STR R1,mouseypos
STR R2,mousebuttons
]
[ NCErrorBox
Push "R0-R6"
ASSERT ptrsuspendflag = ptrsuspenddata + 12
ADRL R14, ptrsuspenddata
LDMIA R14, {R3-R6}
TEQ R6, #1 ; waiting for keyboard-generated move?
MOVEQ R3, #2
STMEQIA R14, {R0-R3} ; store mouse state and new flag value
TEQ R6, #2 ; waiting for mouse-generated move?
BNE %FT06
TEQ R0, R3
TEQEQ R1, R4
TEQEQ R2, R5
BEQ %FT06 ; no change
ADRL R14, ptrsuspendflag
MOV R0, #0
STR R0, [R14] ; store new flag value
MOV R0, #106
MOV R1, #1
SWI XOS_Byte ; turn on pointer
TEQ R1, #0
SWINE XOS_Byte ; just in case it's been turned on by someone else already!
06
Pull "R0-R6"
]
10
TEQ R3,#0 ; was it set up?
BEQ bodgetime
......
......@@ -1107,18 +1107,7 @@ drawcolouredicon
BNE %FT01
TST R1, #is_inverted
BEQ %FT01
; apply EOR iversion *before* main icon draw
; recover EOR colour from the window and icon background colours
BL getpalpointer
[ TrueIcon3
LDR R0, trueworkbg
|
LDRB R0, work_back_colour
AND R0, R0, #&F
LDR R0, [R14, R0, LSL #2]
]
LDR R14, truebgcolour
EOR R0, R0, R14
; apply EOR inversion *before* main icon draw
BL trueeorrectangle
01
Pull "R0-R9"
......@@ -1142,11 +1131,24 @@ exitcicon
Pull "cx1,cy1,PC"
trueeorrectangle
; In: R0 = palette entry
; determine EOR colour from the window and icon background colours
Push "R14"
MOV R3, #&80 ; set background, don't dither
MOV R4, #3 ; EOR colour
SWI XColourTrans_SetGCOL
[ TrueIcon3
LDR R0, trueworkbg
|
BL getpalpointer
LDRB R0, work_back_colour
AND R0, R0, #&F
LDR R0, [R14, R0, LSL #2]
]
SWI XColourTrans_ReturnColourNumber
MOV R1, R0
LDR R0, truebgcolour
SWI XColourTrans_ReturnColourNumber
EOR R1, R0, R1 ; we want the window background to be mapped to the icon background
MOV R0, #&13 ; set background, EOR colours
SWI XOS_SetColour
BLVC solidrectangle
Pull "PC",,^
......@@ -1802,6 +1804,9 @@ icontext_pushfontstring
Trace menuw, "icontext: icon flags ", X, R1
MOV R0, R1
[ CnP
MOV R7, #nullptr
]
BL pushfontstring
BNE icontext_dont_justify
......@@ -2114,6 +2119,9 @@ iconformatted_fancy TraceL L40
BL remembercurrentfont
BL setfancyfontcolours
[ CnP
MOV R7, #nullptr
]
BL pushfontstring
MOV R0,R3
......@@ -2574,6 +2582,9 @@ textwidth_current_font_known
; R3 = font handle to use for text
Push "R3"
STR R1,tempworkspace+28
[ CnP
MOV R7, #nullptr
]
BL pushfontstring
LDR R0,[SP,R7] ; stack has moved!!!
; R1 -> string
......@@ -2638,7 +2649,7 @@ my_StringBBox
; Now we've still got to find the height using a Font_CharBBox loop, due to rounding errors in the
; Font Manager's string bounding box code (PRM 3-463). However, we can make some simplifications, based upon
; knowledge of what pushfontstring will have given us (ie only printable characters and font changes)
; knowledge of what pushfontstring will have given us (ie only printable characters and font/colour changes)
MOV R7, #0 ; cumulative maximum (starts at 0, so we'll always go up to the baseline at least)
[ UTF8
......@@ -2660,6 +2671,11 @@ my_StringBBox
TEQ R1, #26 ; font change?
LDREQB R0, [R5], #1 ; set R0 to hold font handle
BEQ %BT01
[ CnP
TEQ R1, #19 ; colour change?
ADDEQ R5, R5, #8-1 ; skip
BEQ %BT01
]
MOV R2, #1:SHL:4 ; return OS units
SWI XFont_CharBBox
......@@ -6656,9 +6672,18 @@ getpalpointer ROUT
; in R1 = flags for icon
; R2 -> string to paint
; R3 = handle for icon font
; R7 -> control sequence list ( <= 0 indicates no list)
; out R1 -> string to use
; R7 = difference in stack (*word aligned*)
; all others preserved
;
; R7 on entry points to a list of control sequences that need inserting into
; the pushed font string. The list has the following form:
; +0 = byte index into original string where sequence is to be inserted
; these must be kept in ascending order
; +4 = number of bytes in sequence
; +8 = bytes to insert (eg colour change), padded to next word boundary
; The sequence is terminated by the word -1. The list may need to be writeable.
;---------------------------------------------------------------------------
State_CurrentFont * 0
......@@ -6688,13 +6713,19 @@ pushfontstring TraceL font
TraceX font, R3
TraceNL font
[ CnP
CMP R7, #0
ADRLEL R7, null_control_sequence_list
STR R7, font_cs_list
]
[ UTF8
; Initialise R11 (flag word, containing list of characters that need mapping to WimpSymbol)
BL read_current_alphabet
LDR R14, systemfont
TEQ R3, R14 ; is it a desktop font icon?
LDREQ R11, systemfont_wimpsymbol_map ; get the cached map if so (speedup)
BLNE measure_symbols
MOVNE R11, #0 ; else mark as not yet calculated (may be set during test_arrow)
]
MOV R8, R2
......@@ -6756,7 +6787,7 @@ pushfontstring_scan_string TraceL font
]
MOV R6, #0
; R0 = index into destination
; R1 = state (State_CurrentFont, State_IconFont or State_SymbolFont)
; R1 = state
; R2 = alphabet
; R3 = handle of icon font
; R6 = index into source
......@@ -6864,6 +6895,9 @@ pushfontstring_switch
pushfontstring_copy_string TraceL font
;R7 := ALIGN (R0 + 1)
ADD R7, R0, #4
[ CnP
BL add_control_sequences_to_length
]
BIC R7, R7, #3
SUB SP, SP, R7
......@@ -6908,7 +6942,7 @@ pushfontstring_copy_string TraceL font
; R2 = alphabet
; R3 = handle of icon font
; R4 = index into source
; R5 = state (State_CurrentFont, State_IconFont or State_SymbolFont)
; R5 = state
; R6 = maximum index into source (either index of terminator, or max length of buffer)
; R7 = stack alignment
; R8 -> source
......@@ -6917,6 +6951,23 @@ pushfontstring_copy_string TraceL font
B pushfontstring_end_copy_loop
pushfontstring_start_copy_loop
[ CnP
LDR R9, font_cs_list
LDR R10, [R9, #0] ; check to see if we need to insert a control sequence
TEQ R10, R4
BNE %FT02
LDR R10, [R9, #4] ; byte count
ADD R9, R9, #8
01 LDRB R14, [R9], #1 ; copy control bytes
STRB R14, [R1, R0]
ADD R0, R0, #1
SUBS R10, R10, #1
BGT %BT01
ADD R9, R9, #3 ; align, and store back in font_cs_list
BIC R9, R9, #3
STR R9, font_cs_list
02
]
[ UTF8
LDRB R9, [R8, R4] ; get byte
MOV R10, #1
......@@ -7041,6 +7092,9 @@ pushfontstring_copy_loop_done
pushfontstring_use_replacement_string TraceL font
;R7 := Align (R6 + 4 + 1)
ADD R7, R6, #8
[ CnP
BL add_control_sequences_to_length
]
BIC R7, R7, #3
SUB SP, SP, R7
......@@ -7061,7 +7115,26 @@ pushfontstring_use_replacement_string TraceL font
MOV R2, #0
; R2 = counter for source
[ CnP
LDR R9, font_cs_list
LDR R11, [R9, #0]
pushfontstring_replacement_loop
TEQ R11, R2 ; check if we need to insert a control sequence
BNE %FT02
LDR R11, [R9, #4]
ADD R9, R9, #8
01 LDRB R14, [R9], #1 ; copy control bytes
STRB R14, [R1, R0]
ADD R0, R0, #1
SUBS R11, R11, #1
BGT %BT01
ADD R9, R9, #3 ; align
BIC R9, R9, #3
LDR R11, [R9, #0]
02
|
pushfontstring_replacement_loop
]
TEQ R2, R6
;store replacement character
STRNEB R10, [R1, R0]
......@@ -7088,7 +7161,20 @@ pushfontstring_scan_UTF8_string
MOV R2, R8 ; rover
MOV R6, R9
ADD R7, R8, R9 ; -> byte after end of source
01 MOV R4, R2
[ CnP
LDR R11, font_cs_list ; -> control sequence list
01 LDR R14, [R11, #0] ; is there a control sequence at this byte offset?
SUB R4, R2, R8 ; convert back to offset
CMP R4, R14
STRHS R0, [R11, #0] ; if so, then store *character* offset back into list
LDRHS R14, [R11, #4] ; and advance to next item
ADDHS R11, R11, R14
ADDHS R11, R11, #8 + 3
BICHS R11, R11, #3
|
01
]
MOV R4, R2
BL skipcharR
CMP R2, R4
BEQ %FT02 ; break from loop if we've not advanced
......@@ -7103,6 +7189,9 @@ pushfontstring_scan_UTF8_string
ADD sp, sp, #8
; R4 = number of bytes per replacement character
MUL R7, R4, R0
[ CnP
BL add_control_sequences_to_length
]
ADD R7, R7, #3 + 3
BIC R7, R7, #3
; R7 = Align (R0 + 2 + 1)
......@@ -7113,20 +7202,38 @@ pushfontstring_scan_UTF8_string
MOV R5, sp
MOV R6, R10
BL convert_UCS4_to_UTF8
MOV R2, #0 ; character count into destination
[ CnP
LDR R11, font_cs_list ; -> control sequence list
]
; first, select font:
MOV R14, #26
STRB R14, [R1], #1
STRB R3, [R1], #1
; now put in characters:
01 CMP R0, #0 ; finished?
BLE %FT03
MOV R5, #0 ; reinitialise index into replacement character
01 CMP R2, R0 ; finished?
BGE %FT03
[ CnP
LDR R14, [R11, #0] ; is there a control sequence at this character offset?
TEQ R2, R14
BNE %FT12
LDR R5, [R11, #4] ; byte count
ADD R11, R11, #8
11 LDRB R14, [R11], #1 ; copy control bytes
STRB R14, [R1], #1
SUBS R5, R5, #1
BGT %BT11
ADD R11, R11, #3 ; align
BIC R11, R11, #3
12
]
MOV R5, #0 ; initialise index into replacement character
02 LDRB R14, [sp, R5]
STRB R14, [R1], #1 ; copy across byte
ADD R5, R5, #1
CMP R5, R4
BLT %BT02
SUB R0, R0, #1 ; decrement character count
ADD R2, R2, #1 ; increment character count
B %BT01
03 ADD sp, sp, #8 ; realign stack
; finally, terminate the string
......@@ -7198,6 +7305,24 @@ remembercurrentfont TraceL font
Pull "R0-R3, PC",, ^
]
[ CnP
null_control_sequence_list DCD -1
add_control_sequences_to_length
; On exit, R7 is incremented by the total of the control sequence lengths indicated in font_cs_list
Entry "R0"
LDR R0, font_cs_list
01 LDR R14, [R0, #0]
CMP R14, #nullptr
EXITS EQ
LDR R14, [R0, #4]
ADD R7, R7, R14
ADD R0, R0, R14
ADD R0, R0, #8 + 3
BIC R0, R0, #3
B %BT01
]
[ AllowMatrix
font_matrix
; italic
......@@ -7306,6 +7431,7 @@ measure_symbols
; Compare a UCS-4 character against the WimpSymbol mapping bitmap, to see if it needs to be mapped
; Entry: R2 = alphabet
; R3 = icon's font handle
; R9 = UCS-4 character
; R11 = mapping bitmap (as set up in measure_symbols)
; Exit: EQ => needs mapping
......@@ -7328,6 +7454,8 @@ test_arrow
CMP PC, #0