Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 58c6889

Browse files
committed
Merge remote-tracking branch 'origin/develop-8.2' into merge-develop-8.2_20.09.17
2 parents 88d3bc0 + a37916c commit 58c6889

File tree

7 files changed

+124
-105
lines changed

7 files changed

+124
-105
lines changed

Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
script "com.livecode.scripteditor.behavior.editorcommon"
1+
script "com.livecode.scripteditor.behavior.editorcommon"
22
local sObjectId
33

44
# The following variables store information used for the undo / redo system.
@@ -51,6 +51,14 @@ local sEditPlaceholder
5151
constant kPlaceholderDefaultSearchLines = 20
5252
constant 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
5563
command 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.
12071214
command 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
12191232
end updateGutterRequest
12201233

@@ -1344,10 +1357,6 @@ private command saveLastSelections
13441357
end saveLastSelections
13451358

13461359
private 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
20042026
end scrollBarDrag
20052027

20062028
on 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
21132132
end backspaceKey
21142133

21152134
on 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
21502166
end deleteKey
21512167

21522168
on tabKey
@@ -2334,7 +2350,6 @@ private command pageDown
23342350
end if
23352351
end 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
25812597
end 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
26092622
end actionPaste
26102623

26112624
command actionUndo
26122625
if scriptLocked() then
26132626
exit actionUndo
26142627
end if
26152628
textUndo
2616-
# OK-2009-01-19 : Update the handler list
2617-
selectionUpdateRequest
26182629
end actionUndo
26192630

26202631
command actionRedo
26212632
if scriptLocked() then
26222633
exit actionRedo
26232634
end if
26242635
textRedo
2625-
# OK-2009-01-19 : Update the handler list
2626-
selectionUpdateRequest
26272636
end actionRedo
26282637

26292638
command 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]

Toolset/palettes/script editor/behaviors/revseeditorbehavior.livecodescript

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,10 +980,11 @@ end getLastGoneToLine
980980
# Deselects the last line that was selected by the goLine command if there was one
981981
# and it is still selected.
982982
command deselectLastGoneToLine
983+
lock screen
983984
get the selectedChunk
984985
-- MM-2012-06-20: [[ Bug 10027 ]] Make sure there was a last line selected - causes bugs deselects elsewhere within the IDE.
985986
if sLastSelectedGoneToChunk is not empty and word 2 of it is item 1 of sLastSelectedGoneToChunk and word 4 of it is item 2 of sLastSelectedGoneToChunk then
986-
lock screen
987+
987988
lock messages
988989
local tSelobj
989990
put revIDESelectedObjects() into tSelobj
@@ -993,12 +994,13 @@ command deselectLastGoneToLine
993994
end if
994995
set the backgroundColor of char (item 1 of sLastSelectedGoneToChunk) to (item 2 of sLastSelectedGoneToChunk) of field "Script" of me to empty
995996
unlock messages
996-
unlock screen
997+
997998
end if
998999
put empty into sLastSelectedGoneToChunk
9991000

10001001
# We update the gutter here to remove the current line indicator
10011002
updateGutterRequest empty, empty, empty, empty, false, false
1003+
unlock screen
10021004
end deselectLastGoneToLine
10031005

10041006

Toolset/palettes/script editor/behaviors/revsegutterbehavior.livecodescript

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ local sErrors
3333
# Causes the gutter to update itself.
3434
command update pOffset, pSelectedLine, pOldNumber, pNewNumber, pTextChanged, pUpdateCompilationErrors, pForceBreakpointRedraw
3535
local tContext, tUpdateRequired
36+
37+
lock screen
3638
put updateGetContext(pOffset, pSelectedLine, pOldNumber, pNewNumber, pTextChanged, pUpdateCompilationErrors, pForceBreakpointRedraw, tContext) into tUpdateRequired
3739

3840
if not tUpdateRequired then
41+
unlock screen
3942
exit update
4043
end if
4144

@@ -51,8 +54,6 @@ command update pOffset, pSelectedLine, pOldNumber, pNewNumber, pTextChanged, pUp
5154
put tContext["object"] into sLastObject
5255
end if
5356

54-
lock screen
55-
5657
updateBreakpoints pOffset, pSelectedLine, pOldNumber, pNewNumber, pTextChanged, tContext
5758
updateLineNumbers pTextChanged, pOldNumber, pNewNumber, tContext
5859
updateCurrentLine tContext
@@ -310,6 +311,10 @@ end updateCurrentLine
310311
# Description
311312
# If there are not enough line numbers to add to the field
312313
command updateLineNumbers pTextEdited, pOldNumber, pNewNumber, pContext
314+
315+
# only update if there's work to be done
316+
if pContext["numberOfAdditions"] <= 0 then exit updateLineNumbers
317+
313318
# Add the lines in a non-locking manner, and after we've finished adding lines, the scroll
314319
# of the line numbers field should be updated.
315320
repeat pContext["numberOfAdditions"] times
@@ -402,42 +407,22 @@ private command updateBreakpointPositions pObject, pOffset, pLine, pOldNumber, p
402407

403408
if pOldNumber < pNewNumber then
404409
repeat for each line tBreakpoint in tBreakpoints
405-
# In the case that the line that contained the breakpoint was where the text replacement
406-
# started, we have to check for one of three options. This is slow :(
407410
if item -1 of tBreakpoint = pLine then
408-
local tContext
409-
put char 1 to pOffset of getScriptField() into tContext
410-
local tNextChar
411-
put char -1 of tContext into tNextChar
411+
local tLineIndex
412+
put the lineIndex of char pOffset of getScriptField() into tLineIndex
412413

413-
local tPreviousChars
414-
repeat with x = the number of chars of tContext - 1 down to 1
415-
if char x of tContext is empty or char x of tContext is return then
416-
exit repeat
417-
end if
418-
put char x of tContext after tPreviousChars
419-
end repeat
414+
local tCharIndex
415+
put the charIndex of line tLineIndex of getScriptField() into tCharIndex
420416

421-
local tWhitespaceBefore
422-
put matchText(tPreviousChars, "^\s*$") into tWhitespaceBefore
417+
local tLine
418+
put the text of line tLineIndex of getScriptField() into tLine
423419

424-
local tEndofLine
425-
put (tNextChar is return or tNextChar is empty) into tEndofLine
426-
427-
# This means the user has split the line containing the breakpoint, in this case we leave the breakpoint as it was
428-
if (not tWhitespaceBefore) and (not tEndofLine) then
429-
next repeat
430-
end if
431-
432-
# This means that the user has added a return to the end of the line containing the breakpoint, again we ignore this
433-
#if (tPreviousChar is not return and tPreviousChar is not empty) and (tNextChar is return or tNextChar is empty) then
434-
if (not tWhitespaceBefore) and tEndofLine then
435-
next repeat
436-
end if
420+
local tBefore
421+
put char 1 to (pOffset - tCharIndex) of tLine into tBefore
437422

438423
# This means that the user has added a return before the beginning of the line containing the breakpoint. We move the breakpoint
439424
# to follow the line.
440-
if tWhitespaceBefore then
425+
if word 1 of tBefore is empty then
441426
revDebuggerMoveBreakpoint item 1 to -2 of tBreakpoint, item -1 of tBreakpoint, item 1 to -2 of tBreakpoint, item -1 of tBreakpoint + (pNewNumber - pOldNumber)
442427
end if
443428
end if
@@ -457,7 +442,7 @@ private command updateBreakpointPositions pObject, pOffset, pLine, pOldNumber, p
457442
local tScript
458443
put textGetScript() into tScript
459444
repeat for each line tBreakpoint in tBreakpoints
460-
if (item -1 of tBreakpoint >= pLine and item -1 of tBreakpoint < (pLine - (pNewNumber - pOldNumber))) and revDebuggerNextAvailableBreakpoint(tScript, item -1 of tBreakpoint + (pNewNumber - pOldNumber)) <> item -1 of tBreakpoint + (pNewNumber - pOldNumber) then
445+
if (item -1 of tBreakpoint >= pLine and item -1 of tBreakpoint < (pLine - (pNewNumber - pOldNumber))) and revDebuggerNextAvailableBreakpoint(tScript, item -1 of tBreakpoint - 1 + (pNewNumber - pOldNumber)) <> item -1 of tBreakpoint + (pNewNumber - pOldNumber) then
461446
revDebuggerRemoveBreakpoint item 1 to -2 of tBreakpoint, item -1 of tBreakpoint
462447
else if item -1 of tBreakpoint > (pLine + pNewNumber - pOldNumber) then
463448
# If the breakpoint was below the removed lines, move it up
@@ -784,6 +769,10 @@ on rawKeyDown
784769
# Block this message as the gutter must only be scrolled in response to the main script field
785770
end rawKeyDown
786771

772+
on scrollBarDrag
773+
# Block this message as the gutter must only be scrolled in response to the main script field
774+
end scrollBarDrag
775+
787776
# Returns
788777
# A random name used for naming mutable controls. In particular, breakpoint images.
789778
private function controlRandomName

0 commit comments

Comments
 (0)