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

Commit 1cae112

Browse files
Merge pull request #1666 from livecode/feature-default_handlers
[[ Default Handlers ]] Various fixes
2 parents e338a8a + 532246b commit 1cae112

7 files changed

Lines changed: 112 additions & 28 deletions

File tree

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

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ function handlerTypeSortCallback pItem
129129
end switch
130130
end handlerTypeSortCallback
131131

132+
constant kDefaultHandlerTextColor = "#777777"
132133

133134
# Description
134135
# Called when the group might need to be updated. Updates the handler list. Also resizes the group.
@@ -139,7 +140,9 @@ command update
139140
put the result into tHandlers
140141

141142
local tDefaultHandlers, tIndex
142-
put revSEDefaultHandlers() into tDefaultHandlers
143+
if sePrefGet("editor,showDefaultHandlers") then
144+
put revSEDefaultHandlers() into tDefaultHandlers
145+
end if
143146
set the wholematches to false
144147

145148
local tCanAdd
@@ -170,7 +173,7 @@ command update
170173
end if
171174

172175
if tHandlers is not empty then
173-
put return &return after tHandlers
176+
put return & return & return after tHandlers
174177
end if
175178
put tCanAdd after tHandlers
176179

@@ -183,13 +186,15 @@ command update
183186

184187
if the number of words in tHandler is 1 then
185188
put false into tHandlerExists
189+
-- Existing handler names have a space after the icon
190+
put " " before tParseHandler
186191
end if
187192

188193
put "<p>" after tText
189194

190195
local tIsPrivate
191196
put false into tIsPrivate
192-
if char 1 of tParseHandler is "P" then
197+
if tHandlerExists and char 1 of tParseHandler is "P" then
193198
put true into tIsPrivate
194199
delete char 1 of tParseHandler
195200
end if
@@ -207,6 +212,11 @@ command update
207212
put merge("<sup shift=2><img src=[[tICon]]></img></sup>") after tText
208213
end if
209214

215+
if not tHandlerExists then
216+
put merge("<font color='[[kDefaultHandlerTextColor]]'>[[tParseHandler]]</font>") \
217+
into tParseHandler
218+
end if
219+
210220
put tParseHandler & "</p>" after tText
211221
end repeat
212222

@@ -274,28 +284,30 @@ command jumpToHandler pHandler, pAdded
274284
hideGroup
275285
end jumpToHandler
276286

277-
command closeAccept
278-
lock screen
279-
local tHandler
280-
put line (the hilitedLine of field "Handlers" of me) of the cHandlers of field "Handlers" of me into tHandler
281-
287+
command handlerPicked pHandler
282288
local tAdded
283289
put false into tAdded
284-
if the number of words in tHandler is 1 then
290+
if the number of words in pHandler is 1 then
285291
put true into tAdded
286292
-- Adding a default handler
287-
revSEAddDefaultHandler tHandler
293+
revSEAddDefaultHandler pHandler
288294
update
289295
set the wholematches to false
290296
local tLine
291-
put lineOffset(tHandler, the cHandlers of field "Handlers" of me) into tLine
297+
put lineOffset(pHandler, the cHandlers of field "Handlers" of me) into tLine
292298
select line tLine of field "Handlers" of me
293-
put line tLine of the cHandlers of field "Handlers" of me into tHandler
299+
put line tLine of the cHandlers of field "Handlers" of me into pHandler
294300
end if
295301

296302
-- Select the (now) extant handler
297-
jumpToHandler tHandler, tAdded
298-
303+
jumpToHandler pHandler, tAdded
304+
end handlerPicked
305+
306+
command closeAccept
307+
lock screen
308+
local tHandler
309+
put line (the hilitedLine of field "Handlers" of me) of the cHandlers of field "Handlers" of me into tHandler
310+
handlerPicked tHandler
299311
unlock screen
300312
end closeAccept
301313

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

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,41 @@ private command buildHandlerMenu pContext
275275

276276
local tFormattedHandlers
277277
repeat for each line tHandler in tHandlers
278-
put word 2 of tHandler & return after tFormattedHandlers
278+
put tab & word 2 of tHandler & return after tFormattedHandlers
279279
end repeat
280280
delete the last char of tFormattedHandlers
281281

282-
if the number of lines of tHandlers = 0 then
283-
put "(No Handlers" into tFormattedHandlers
284-
set the cHandlers of me to empty
282+
local tDefaultHandlers
283+
put revSEDefaultHandlers() into tDefaultHandlers
284+
285+
local tFormattedDefaultHandlers
286+
repeat for each line tHandler in tDefaultHandlers
287+
put tab & tHandler & return after tFormattedDefaultHandlers
288+
end repeat
289+
delete the last char of tFormattedDefaultHandlers
290+
291+
local tShowDefaultHandlers
292+
dispatch function "sePrefGet" to me with "editor,showDefaultHandlers"
293+
put the result into tShowDefaultHandlers
294+
295+
local tMenu
296+
if tHandlers is not empty then
297+
put enableMenuItem("Go to handler...", true) into tMenu
298+
put return & tFormattedHandlers after tMenu
285299
else
286-
set the cHandlers of me to tHandlers
300+
put enableMenuItem("Go to handler...", false) into tMenu
287301
end if
302+
if tDefaultHandlers is not empty then
303+
put return & enableMenuItem("Add default handler...", true) after tMenu
304+
put return & tFormattedDefaultHandlers after tMenu
305+
else
306+
put return & enableMenuItem("Add default handler...", false) after tMenu
307+
end if
308+
put return & toggleMenuItem("Show default handlers", tShowDefaultHandlers) after tMenu
309+
310+
set the cHandlers of me to tHandlers
288311

289-
set the text of button "Handler" of me to modifyMenu("Handler", tFormattedHandlers)
312+
set the text of button "Handler" of me to modifyMenu("Handler", tMenu)
290313
end buildHandlerMenu
291314

292315
on menuPick pItemName
@@ -321,15 +344,31 @@ private command handleHandlerMenuPick pItemName
321344
exit handleHandlerMenuPick
322345
end if
323346

324-
local tLineNumber
325-
put the menuHistory of button "Handler" of me into tLineNumber
326-
327-
local tHandler
328-
put line tLineNumber of the cHandlers of me into tHandler
347+
set the itemdelimiter to "|"
348+
switch item 1 of pItemName
349+
case "Go to handler..."
350+
local tPick, tHandlerInfo
351+
put item 2 of pItemName into tPick
352+
if not matchText(the cHandlers of me, "(.* " & tPick & " .*)", \
353+
tHandlerInfo) then
354+
exit handleHandlerMenuPick
355+
end if
356+
357+
dispatch "handlerPicked" to group "Left Handler List" \
358+
with tHandlerInfo
359+
break
360+
case "Add default handler..."
361+
dispatch "handlerPicked" to group "Left Handler List" \
362+
with item 2 of pItemName
363+
break
364+
case "Show default handlers"
365+
local tShowDefaultHandlers
366+
dispatch function "sePrefGet" to me with "editor,showDefaultHandlers"
367+
put the result into tShowDefaultHandlers
368+
dispatch "sePrefSet" to me with "editor,showDefaultHandlers", not tShowDefaultHandlers
369+
break
370+
end switch
329371

330-
local tScriptLineNumber
331-
put word 3 of tHandler into tScriptLineNumber
332-
send "goLine tScriptLineNumber, true" to group "Editor"
333372
seUpdateLeftBar
334373
seUpdateToolbar
335374
end handleHandlerMenuPick
@@ -511,6 +550,20 @@ end handleHelpMenuPick
511550

512551
#########
513552

553+
private function toggleMenuItem pItem, pHilited
554+
if pHilited then
555+
return "!c" & pItem
556+
end if
557+
return "!n" & pItem
558+
end toggleMenuItem
559+
560+
private function enableMenuItem pItem, pEnabled
561+
if pEnabled then
562+
return pItem
563+
end if
564+
return "(" & pItem
565+
end enableMenuItem
566+
514567
private function modifyMenu pMenuName, pMenu
515568
if the last char of pMenu is not return then
516569
put return after pMenu

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ command sePrefGetDefaults
659659

660660
put 7 into tPrefs["print,textSize"]
661661

662+
put true into tPrefs["editor,showDefaultHandlers"]
663+
662664
return tPrefs
663665
end sePrefGetDefaults
664666

notes/bugfix-20071.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Make default handler name text grey

notes/bugfix-20072.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Add space above default handler list and before each name

notes/bugfix-20074.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Prevent removal of initial P from default handler name
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Script editor handler menu
2+
The Handler menu of the script editor menubar has been modified
3+
in accordance with the default handler changes to the script
4+
editor handler list. It now has the following structure:
5+
6+
Go to handler...
7+
-> list of extant handlers
8+
Add default handler...
9+
-> list of default handlers
10+
Show default handlers
11+
12+
The show default handlers menu item toggles the script editor
13+
preference to show the default handler list, which defaults
14+
to true.

0 commit comments

Comments
 (0)