mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#344 nav to start/end of fields
This commit is contained in:
parent
645a5f5137
commit
18bcfb4014
@ -216,14 +216,7 @@ function core.new_ifield(e, max_len, fg_bg, dis_fg_bg)
|
|||||||
---@param val string
|
---@param val string
|
||||||
function public.set_value(val)
|
function public.set_value(val)
|
||||||
e.value = string.sub(val, 1, math.min(max_len, string.len(val)))
|
e.value = string.sub(val, 1, math.min(max_len, string.len(val)))
|
||||||
|
public.nav_end()
|
||||||
self.selected_all = false
|
|
||||||
self.frame_start = math.max(1, string.len(e.value) - e.frame.w + 2)
|
|
||||||
|
|
||||||
_update_visible()
|
|
||||||
self.cursor_pos = string.len(self.visible_text) + 1
|
|
||||||
|
|
||||||
public.show()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- try to insert a character if there is space
|
-- try to insert a character if there is space
|
||||||
@ -282,6 +275,21 @@ function core.new_ifield(e, max_len, fg_bg, dis_fg_bg)
|
|||||||
elseif _try_rshift() then public.show() end
|
elseif _try_rshift() then public.show() end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- move cursor to the start
|
||||||
|
function public.nav_start()
|
||||||
|
self.cursor_pos = 1
|
||||||
|
self.frame_start = 1
|
||||||
|
public.show()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- move cursor to the end
|
||||||
|
function public.nav_end()
|
||||||
|
self.frame_start = math.max(1, string.len(e.value) - e.frame.w + 2)
|
||||||
|
_update_visible()
|
||||||
|
self.cursor_pos = string.len(self.visible_text) + 1
|
||||||
|
public.show()
|
||||||
|
end
|
||||||
|
|
||||||
return public
|
return public
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -106,6 +106,10 @@ local function number_field(args)
|
|||||||
ifield.nav_right()
|
ifield.nav_right()
|
||||||
elseif event.key == keys.a and event.ctrl then
|
elseif event.key == keys.a and event.ctrl then
|
||||||
ifield.select_all()
|
ifield.select_all()
|
||||||
|
elseif event.key == keys.home or event.key == keys.up then
|
||||||
|
ifield.nav_start()
|
||||||
|
elseif event.key == keys["end"] or event.key == keys.down then
|
||||||
|
ifield.nav_end()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,6 +65,10 @@ local function text_field(args)
|
|||||||
ifield.nav_right()
|
ifield.nav_right()
|
||||||
elseif event.key == keys.a and event.ctrl then
|
elseif event.key == keys.a and event.ctrl then
|
||||||
ifield.select_all()
|
ifield.select_all()
|
||||||
|
elseif event.key == keys.home or event.key == keys.up then
|
||||||
|
ifield.nav_start()
|
||||||
|
elseif event.key == keys["end"] or event.key == keys.down then
|
||||||
|
ifield.nav_end()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user