1- script "com.livecode.scripteditor.behavior.editorcommon"
1+ script "com.livecode.scripteditor.behavior.editorcommon"
22local sObjectId
33
44# The following variables store information used for the undo / redo system.
@@ -51,6 +51,14 @@ local sEditPlaceholder
5151constant kPlaceholderDefaultSearchLines = 20
5252constant kPlaceholderDefaultBackgroundColor = "240,240,240"
5353
54+ # 2017-08-01 bhall2001 previous vScroll position of the Editor field
55+ local sVScroll
56+
57+ # 2017-08-01 bhall2001 Toggles between true/false on each up arrow key pressed
58+ # Note: up arrow key sends 2 scrollBarDrag messages. Used as flag
59+ # to process only 1 of the messages.
60+ local sSkipUpArrow = false
61+
5462# OK-2009-01-17 : Bug 7169
5563command setDirty pObject, pValue
5664 put pValue into sDirty [pObject ]
@@ -902,7 +910,7 @@ command textReplace pOffset, pOldText, pNewText, pObject, pDontGroup
902910
903911 add tNewLength - tSelectedLength to tToAdd
904912 add tNewLength - tSelectedLength to sEditChunks [tIndex ]["end" ]
905- set the linkText of char sEditChunks [tIndex ]["start" ] to sEditChunks [tIndex ]["end" ] of field "script" of me to sEditPlaceholder
913+ set the metadata of char sEditChunks [tIndex ]["start" ] to sEditChunks [tIndex ]["end" ] of field "script" of me to sEditPlaceholder
906914 if tIndex is 1 then
907915 set the backgroundColor of char sEditChunks [tIndex ]["start" ] to sEditChunks [tIndex ]["end" ] of field "script" of me to empty
908916 else
@@ -917,7 +925,6 @@ command textReplace pOffset, pOldText, pNewText, pObject, pDontGroup
917925 add 1 to sTextGroupLengths [tObject ,sTextGroupIndex [tObject ]]
918926 end repeat
919927 put true into sPlaceholders [sEditPlaceholder ]["edited" ]
920- set the linkText of char pOffset to pOffset + max (1 ,tNewLength - 1 ) of field "script" of me to sEditPlaceholder
921928
922929 if tSelection is not empty then
923930 select tSelection
@@ -1200,8 +1207,8 @@ end getUpdateGutterRequestDetails
12001207# pUpdateCompilationErrors : whether to update the gutter's compilation errors
12011208# Description
12021209# Sends a request to update the gutter. This is called whenever the current script is edited, or the field
1203- # is scrolled etc. A request is sent using a short delay and any previous requests are cancelled.
1204- # The gutter's scroll is updated immediately however . Also a message is sent to the gutter to hide its
1210+ # is scrolled etc.
1211+ # The gutter's scroll is updated immediately. Also a message is sent to the gutter to hide its
12051212# mutable objects (the breakpoint / compilation error images). These are show again when the update is
12061213# actually carried out.
12071214command updateGutterRequest pOffset, pSelectedLine, pOldLines, pNewLines, pTextChanged, pUpdateCompilationErrors, pForceBreakpointRedraw
@@ -1210,11 +1217,17 @@ command updateGutterRequest pOffset, pSelectedLine, pOldLines, pNewLines, pTextC
12101217 cancel sGutterUpdateRequest
12111218 end if
12121219
1213- # We always update the gutter's scroll immediately, as otherwise it looks bad. Other stuff is delayed though.
1214- if there is a group "Gutter" of me then
1215- send "updateScroll" to group "Gutter" of me
1220+ # BUGFIX-20140
1221+ # 2017-JUL-28 bhall2001
1222+ # We always update the gutter's scroll immediately, as otherwise it looks bad.
1223+ # For best scroll performance, we set the Gutter scroll directly.
1224+ if exists(field "Numbers" of group "Gutter" ) then
1225+ set the vScroll of field "Numbers" of group "Gutter" to the vScroll of field "Script" of me
12161226 end if
1217- send "updateGutterDo" to me in 5 milliseconds
1227+ # BUGFIX-20140
1228+ # 2017-JUL-28 bhall2001 Due to blocking nature of scrolling and key presses, don't send in time.
1229+ # UI effect is Gutter lags behind scrolling of Script Editor
1230+ updateGutterDo
12181231 put the result into sGutterUpdateRequest
12191232end updateGutterRequest
12201233
@@ -1344,10 +1357,6 @@ private command saveLastSelections
13441357end saveLastSelections
13451358
13461359private command selectionUpdateRequest
1347- if not handleEvent("selectionUpdateRequest" , the long id of the target) then
1348- exit selectionUpdateRequest
1349- end if
1350-
13511360 if sSelectionUpdateRequest is not empty then
13521361 cancel sSelectionUpdateRequest
13531362 end if
@@ -1431,7 +1440,7 @@ private command caretUpdate pField, pScript
14311440 put __GetPreference("editor,placeholdersearchlines" , kPlaceholderDefaultSearchLines ) into tSearchLines
14321441
14331442 if tChunk is not empty and exists(tChunk ) then
1434- get the linkText of tChunk
1443+ get the metadata of tChunk
14351444 if it is not empty then
14361445 __ClearCurrentPlaceholder true
14371446 __SelectPlaceholder \
@@ -1999,8 +2008,21 @@ on scrollBarDrag
19992008 if the short name of the target is "Gutter" or the short name of the owner of the target is "Gutter" then
20002009 exit scrollBarDrag
20012010 end if
2011+
2012+ local tVScroll
2013+
2014+ # 2017-JUL-28 bhall2001
2015+ # update only when vScroll changes. Mouse wheel scrolling sends
2016+ # vScrolls that don't change. Up arrow causes 2 scrollBarDrag message
2017+ # so we skip the message when up arrow flag is set.
2018+ put the vScroll of the target into tVScroll
2019+ if (tVScroll = sVScroll ) or sSkipUpArrow then exit scrollBarDrag
2020+
2021+ lock screen
2022+ put tVScroll into sVScroll
20022023
20032024 updateGutterRequest empty , empty , empty , empty , false , true
2025+ unlock screen
20042026end scrollBarDrag
20052027
20062028on keyDown pChar
@@ -2107,9 +2129,6 @@ on backspaceKey
21072129 if tTo > tFrom then
21082130 textEndGroup
21092131 end if
2110-
2111- # OK-2009-01-19 : Update the handler list
2112- selectionUpdateRequest
21132132end backspaceKey
21142133
21152134on deleteKey
@@ -2144,9 +2163,6 @@ on deleteKey
21442163 if tTo > tFrom then
21452164 textEndGroup
21462165 end if
2147-
2148- # OK-2009-01-19 : Update the handler list
2149- selectionUpdateRequest
21502166end deleteKey
21512167
21522168on tabKey
@@ -2334,7 +2350,6 @@ private command pageDown
23342350 end if
23352351end pageDown
23362352
2337-
23382353# Description
23392354# RawKeyDown is handled mainly because of the home and end keys. These need to be manually implemented on OS X
23402355# and both platforms after pressing the home key we have to ensure the caret ends up in the right place.
@@ -2418,6 +2433,10 @@ on rawKeyDown pKey
24182433 put "right" into tKeyName
24192434 break
24202435 case kKeyUpArrow
2436+ # 2017-JUL-28 bhall2001
2437+ # when scrolling on up arrow, scrollBarDrag is sent twice. Set
2438+ # flag to update on every other up arrow message
2439+ put not sSkipUpArrow into sSkipUpArrow
24212440 put "up" into tKeyName
24222441 break
24232442 case kKeyDownArrow
@@ -2574,9 +2593,6 @@ command actionCut
25742593 copy -- set the clipboard (dont cut as we do not allow field modification here)
25752594 textReplace tFrom , char tFrom to tTo of field "Script" of me, empty
25762595 textEndGroup
2577-
2578- # OK-2009-01-19 : Update the handler list
2579- selectionUpdateRequest
25802596 end if
25812597end actionCut
25822598
@@ -2603,27 +2619,20 @@ command actionPaste
26032619 end if
26042620 textEndGroup
26052621 unlock screen
2606-
2607- # OK-2009-01-19 : Update the handler list
2608- selectionUpdateRequest
26092622end actionPaste
26102623
26112624command actionUndo
26122625 if scriptLocked() then
26132626 exit actionUndo
26142627 end if
26152628 textUndo
2616- # OK-2009-01-19 : Update the handler list
2617- selectionUpdateRequest
26182629end actionUndo
26192630
26202631command actionRedo
26212632 if scriptLocked() then
26222633 exit actionRedo
26232634 end if
26242635 textRedo
2625- # OK-2009-01-19 : Update the handler list
2626- selectionUpdateRequest
26272636end actionRedo
26282637
26292638command actionDeselectAll
@@ -3354,7 +3363,7 @@ private command __ClearCurrentPlaceholder pForce
33543363 put the selectedChunk into tChunk
33553364 if exists(tChunk ) then
33563365 local tUUID
3357- put the linkText of tChunk into tUUID
3366+ put the metadata of tChunk into tUUID
33583367 if tUUID is sEditPlaceholder then
33593368 exit __ClearCurrentPlaceholder
33603369 end if
@@ -3365,7 +3374,7 @@ private command __ClearCurrentPlaceholder pForce
33653374
33663375 if the number of elements of sEditChunks > 0 then
33673376 repeat for each element tChunk in sEditChunks
3368- set the linkText of char tChunk ["start" ] to tChunk ["end" ] of field "script" of me to empty
3377+ set the metadata of char tChunk ["start" ] to tChunk ["end" ] of field "script" of me to empty
33693378 set the backgroundColor of char tChunk ["start" ] to tChunk ["end" ] of field "script" of me to empty
33703379 end repeat
33713380 delete variable sEditChunks
@@ -3385,7 +3394,7 @@ private command __SelectPlaceholder pUUID, pFromParagraph, pToParagraph, pStyled
33853394 local tUUID , tChunk
33863395 put the selectedChunk into tChunk
33873396 if exists(tChunk ) then
3388- put the linkText of tChunk into tUUID
3397+ put the metadata of tChunk into tUUID
33893398 end if
33903399
33913400 local tOffset
@@ -3413,18 +3422,18 @@ private command __SelectPlaceholder pUUID, pFromParagraph, pToParagraph, pStyled
34133422 repeat with tParagraphIndex = 1 to the number of elements of pStyledText
34143423 local tRunIndex
34153424 repeat with tRunIndex = 1 to the number of elements of pStyledText [tParagraphIndex ]["runs" ]
3416- if pUUID is pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["style" ][ "linkText " ] then
3425+ if pUUID is pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["metadata " ] then
34173426 put the effective hiliteColor of field "Script" of me \
34183427 into pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["style" ]["backgroundColor" ]
34193428 local tPlaceholderNum
34203429 put the number of elements of sEditChunks + 1 into tPlaceholderNum
34213430 put tOffset + 1 into sEditChunks [tPlaceholderNum ]["start" ]
34223431 put tOffset + the length of pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["text" ] into sEditChunks [tPlaceholderNum ]["end" ]
3423- else if pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["style" ][ "linkText " ] is not empty then
3432+ else if pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["metadata " ] is not empty then
34243433 if pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["text" ] is space or \
3425- pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["style" ][ "linkText " ] is tUUID then
3426- delete variable sPlaceholders [pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["style" ][ "linkText " ]]
3427- delete variable pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["style" ][ "linkText " ]
3434+ pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["metadata " ] is tUUID then
3435+ delete variable sPlaceholders [pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["metadata " ]]
3436+ delete variable pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["metadata " ]
34283437 delete variable pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["style" ]["backgroundColor" ]
34293438 else
34303439 put tColor into pStyledText [tParagraphIndex ]["runs" ][tRunIndex ]["style" ]["backgroundColor" ]
@@ -3460,11 +3469,11 @@ command SelectNextPlaceholder pChar, pFromParagraph, pToParagraph
34603469 local tRunIndex
34613470 repeat with tRunIndex = 1 to the number of elements of tStyle [tParagraphIndex ]["runs" ]
34623471 if tParagraphIndex > 1 or (tParagraphIndex is 1 and (tRunOffset + 1 ) >= pChar ) then
3463- if tStyle [tParagraphIndex ]["runs" ][tRunIndex ]["style" ][ "linkText " ] is not empty and \
3464- tStyle [tParagraphIndex ]["runs" ][tRunIndex ]["style" ][ "linkText " ] is not sEditPlaceholder then
3472+ if tStyle [tParagraphIndex ]["runs" ][tRunIndex ]["metadata " ] is not empty and \
3473+ tStyle [tParagraphIndex ]["runs" ][tRunIndex ]["metadata " ] is not sEditPlaceholder then
34653474 if tStyle [tParagraphIndex ]["runs" ][tRunIndex ]["text" ] is not space then
34663475 __SelectPlaceholder \
3467- tStyle [tParagraphIndex ]["runs" ][tRunIndex ]["style" ][ "linkText " ], \
3476+ tStyle [tParagraphIndex ]["runs" ][tRunIndex ]["metadata " ], \
34683477 pFromParagraph , \
34693478 pToParagraph , \
34703479 tStyle
@@ -3483,7 +3492,7 @@ command SelectNextPlaceholder pChar, pFromParagraph, pToParagraph
34833492
34843493 repeat for each key tUUID in tPlaceholdersToDelete
34853494 repeat for each element tRange in tPlaceholdersToDelete [tUUID ]
3486- set the linkText of char (item 1 of tRange ) of line (item 2 of tRange ) of field "script" of me to empty
3495+ set the metadata of char (item 1 of tRange ) of line (item 2 of tRange ) of field "script" of me to empty
34873496 set the backgroundColor of char (item 1 of tRange ) of line (item 2 of tRange ) of field "script" of me to empty
34883497 end repeat
34893498 delete variable sPlaceholders [tUUID ]
0 commit comments