Skip to content

Commit 6a55b75

Browse files
committed
wrap text from helpdb for the current window size
1 parent 773a6ec commit 6a55b75

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

gui/launcher.lua

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function AutocompletePanel:init()
129129
self:addviews{
130130
widgets.Label{
131131
frame={l=0, t=0},
132-
text='Autocomplete'
132+
text='Click or select via'
133133
},
134134
widgets.HotkeyLabel{
135135
frame={l=1, t=1},
@@ -323,7 +323,7 @@ To see help for this command launcher, type
323323
"gui/launcher" to autocomplete.]]
324324

325325
function HelpPanel:init()
326-
self.cur_entry = ""
326+
self.cur_entry = ''
327327

328328
self:addviews{
329329
widgets.WrappedLabel{
@@ -340,11 +340,14 @@ function HelpPanel:init()
340340
}
341341
end
342342

343-
function HelpPanel:set_help(help_text)
343+
function HelpPanel:set_help(help_text, in_layout)
344344
local label = self.subviews.help_label
345345
label.text_to_wrap = help_text
346-
label:postComputeFrame()
347-
label:updateLayout() -- to update the scroll arrows after rewrapping text
346+
if not in_layout then
347+
self.cur_entry = ''
348+
label:postComputeFrame()
349+
label:updateLayout() -- update the scroll arrows after rewrapping text
350+
end
348351
end
349352

350353
function HelpPanel:set_entry(entry_name)
@@ -354,8 +357,16 @@ function HelpPanel:set_entry(entry_name)
354357
if #entry_name == 0 or entry_name == self.cur_entry then
355358
return
356359
end
360+
self:set_help(helpdb.get_entry_long_help(entry_name,
361+
self.frame_body.width - 1))
357362
self.cur_entry = entry_name
358-
self:set_help(helpdb.get_entry_long_help(entry_name))
363+
end
364+
365+
function HelpPanel:postComputeFrame()
366+
if #self.cur_entry == 0 then return end
367+
self:set_help(helpdb.get_entry_long_help(self.cur_entry,
368+
self.frame_body.width - 1),
369+
true)
359370
end
360371

361372
function HelpPanel:onInput(keys)

0 commit comments

Comments
 (0)