Skip to content

Commit 5733b6a

Browse files
authored
Merge pull request DFHack#1023 from myk002/myk_minimal_search
[gui/launcher] fix up/down arrow keys being captured in minimal mode by unrendered widgets when in minimal mode
2 parents e57f241 + 3613660 commit 5733b6a

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ Template for new versions:
3434

3535
## Fixes
3636
- `gui/notify`: persist notification settings when toggled in the UI
37+
- `gui/launcher`: fix history scanning (Up/Down arrow keys) being slow to respond when in minimal mode
3738

3839
## Misc Improvements
3940
- `gui/launcher`: add interface for browsing and filtering commands by tags
41+
- `gui/launcher`: add support for history search (Alt-s hotkey) when in minimal mode
4042

4143
## Removed
4244

gui/launcher.lua

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ end
345345

346346
AutocompletePanel = defclass(AutocompletePanel, widgets.Panel)
347347
AutocompletePanel.ATTRS{
348+
frame_background=gui.CLEAR_PEN,
348349
on_autocomplete=DEFAULT_NIL,
349350
tag_filter_panel=DEFAULT_NIL,
350351
on_double_click=DEFAULT_NIL,
@@ -459,8 +460,10 @@ function EditPanel:init()
459460
self:addviews{
460461
widgets.Label{
461462
view_id='prefix',
462-
frame={l=0, t=0},
463+
frame={l=0, t=0, r=0},
464+
frame_background=gui.CLEAR_PEN,
463465
text='[DFHack]#',
466+
auto_width=false,
464467
visible=self.prefix_visible},
465468
widgets.EditField{
466469
view_id='editfield',
@@ -480,6 +483,7 @@ function EditPanel:init()
480483
frame={l=1, t=3, w=10},
481484
key='SELECT',
482485
label='run',
486+
disabled=self.prefix_visible,
483487
on_activate=function()
484488
if dfhack.internal.getModifiers().shift then
485489
self.on_submit2(self.subviews.editfield.text)
@@ -495,7 +499,8 @@ function EditPanel:init()
495499
on_activate=self.on_toggle_minimal},
496500
widgets.EditField{
497501
view_id='search',
498-
frame={l=13, t=3, r=1},
502+
frame={l=13, b=0, r=1},
503+
frame_background=gui.CLEAR_PEN,
499504
key='CUSTOM_ALT_S',
500505
label_text='history search: ',
501506
disabled=function() return selecting_filters end,
@@ -508,7 +513,10 @@ function EditPanel:init()
508513
end end,
509514
on_unfocus=function()
510515
self.subviews.search:setText('')
511-
self.subviews.editfield:setFocus(true) end,
516+
self.subviews.editfield:setFocus(true)
517+
self.subviews.search.visible = not self.prefix_visible()
518+
gui.Screen.request_full_screen_refresh = true
519+
end,
512520
on_submit=function()
513521
self.on_submit(self.subviews.editfield.text) end,
514522
on_submit2=function()
@@ -567,6 +575,11 @@ function EditPanel:on_search_text(search_str, next_match)
567575
end
568576

569577
function EditPanel:onInput(keys)
578+
if self.prefix_visible() then
579+
local search = self.subviews.search
580+
search.visible = keys.CUSTOM_ALT_S or search.focus
581+
end
582+
570583
if EditPanel.super.onInput(self, keys) then return true end
571584

572585
if keys.STANDARDSCROLL_UP then
@@ -583,12 +596,28 @@ function EditPanel:onInput(keys)
583596
end
584597
end
585598

599+
function EditPanel:preUpdateLayout()
600+
local search = self.subviews.search
601+
local minimized = self.prefix_visible()
602+
if minimized then
603+
self.frame_background = nil
604+
search.frame.l = 0
605+
search.frame.r = 11
606+
else
607+
self.frame_background = gui.CLEAR_PEN
608+
search.frame.l = 13
609+
search.frame.r = 1
610+
end
611+
search.visible = not minimized or search.focus
612+
end
613+
586614
----------------------------------
587615
-- HelpPanel
588616
--
589617

590618
HelpPanel = defclass(HelpPanel, widgets.Panel)
591619
HelpPanel.ATTRS{
620+
frame_background=gui.CLEAR_PEN,
592621
autoarrange_subviews=true,
593622
autoarrange_gap=1,
594623
frame_inset={t=0, l=1, r=1, b=0},
@@ -725,10 +754,11 @@ end
725754
-- MainPanel
726755
--
727756

728-
MainPanel = defclass(MainPanel, widgets.Window)
757+
MainPanel = defclass(MainPanel, widgets.Panel)
729758
MainPanel.ATTRS{
730759
frame_title=TITLE,
731760
frame_inset=0,
761+
draggable=true,
732762
resizable=true,
733763
resize_min={w=AUTOCOMPLETE_PANEL_WIDTH+49, h=EDIT_PANEL_HEIGHT+20},
734764
get_minimal=DEFAULT_NIL,
@@ -812,7 +842,7 @@ function LauncherUI:init(args)
812842
new_frame.l = 0
813843
new_frame.r = frame_r
814844
new_frame.t = 0
815-
new_frame.h = 1
845+
new_frame.h = 2
816846
else
817847
new_frame = config.data
818848
if not next(new_frame) then
@@ -831,7 +861,7 @@ function LauncherUI:init(args)
831861
local edit_frame = self.subviews.edit.frame
832862
edit_frame.r = self.minimal and
833863
0 or AUTOCOMPLETE_PANEL_WIDTH+2
834-
edit_frame.h = self.minimal and 1 or EDIT_PANEL_HEIGHT
864+
edit_frame.h = self.minimal and 2 or EDIT_PANEL_HEIGHT
835865

836866
local editfield_frame = self.subviews.editfield.frame
837867
editfield_frame.t = self.minimal and 0 or 1

0 commit comments

Comments
 (0)