~akkartik/luaML.love

dff4587219221d00a15d8a6907583643d8127090 — Kartik K. Agaram 2 years ago 2973324
just keep the cursor visible after any input events

This is much nicer.
1 files changed, 8 insertions(+), 2 deletions(-)

M main.lua
M main.lua => main.lua +8 -2
@@ 333,6 333,8 @@ end

function App.mousepressed(x,y, mouse_button)
  if Search_term then return end
  -- ensure cursor is visible immediately after it moves
  Cursor_time = 0
--?   print('press', Selection1.line, Selection1.pos)
  propagate_to_button_handlers(x,y, mouse_button)



@@ 370,6 372,8 @@ end
function App.mousereleased(x,y, button)
  if Search_term then return end
--?   print('release')
  -- ensure cursor is visible immediately after it moves
  Cursor_time = 0
  if Lines.current_drawing then
    Drawing.mouse_released(x,y, button)
    schedule_save()


@@ 384,8 388,6 @@ function App.mousereleased(x,y, button)
--?           print('reset selection')
          Cursor1 = {line=line_index, pos=Text.to_pos_on_line(line, x, y)}
--?           print('cursor', Cursor1.line, Cursor1.pos)
          -- ensure cursor is immediately visible
          Cursor_time = 0
          if Mousepress_shift then
            if Old_selection1.line == nil then
              Selection1 = Old_cursor1


@@ 403,6 405,8 @@ function App.mousereleased(x,y, button)
end

function App.textinput(t)
  -- ensure cursor is visible immediately after it moves
  Cursor_time = 0
  for _,line in ipairs(Lines) do line.y = nil end  -- just in case we scroll
  if Search_term then
    Search_term = Search_term..t


@@ 421,6 425,8 @@ function App.textinput(t)
end

function App.keychord_pressed(chord, key)
  -- ensure cursor is visible immediately after it moves
  Cursor_time = 0
  if Selection1.line and
      not Lines.current_drawing and
      -- printable character created using shift key => delete selection