@@ -5,6 +5,7 @@ local mobdebug = require("dit.lua.mobdebug")
55local json = require (" cjson" )
66
77local lines
8+ local last_line = 0
89local commented_lines = {}
910local controlled_change = false
1011local type_report
@@ -79,6 +80,7 @@ function on_save(filename)
7980 lines = {}
8081 local state = " start"
8182 local buf = {}
83+ last_line = 0
8284 for line in pd :lines () do
8385 if state == " start" then
8486 if line == " " then
@@ -117,6 +119,9 @@ function on_save(filename)
117119 text = err ,
118120 what = state ,
119121 })
122+ if y > last_line then
123+ last_line = y
124+ end
120125 end
121126 end
122127 end
@@ -161,24 +166,40 @@ local function type_at(px, py)
161166 end
162167end
163168
169+ function on_alt (key )
170+ if key == ' L' then
171+ local filename = buffer :filename ()
172+ local x , y = buffer :xy ()
173+ local page = tabs :open (filename :gsub (" %.tl$" , " .lua" ))
174+ tabs :set_page (page )
175+ tabs :get_buffer (page ):go_to (x , y )
176+ end
177+ end
178+
164179function on_ctrl (key )
165180 if key == ' _' then
166181 controlled_change = true
167182 code .comment_block (" --" , " %-%-" , lines , commented_lines )
168183 controlled_change = false
169- elseif key == " O" then
170- -- local str = buffer:selection()
171- -- if str == "" then
172- -- str = buffer:token()
173- -- end
174- -- if str and str ~= "" then
175- -- local out = mobdebug.command("eval " .. str)
176- -- if type(out) == "table" then
177- -- buffer:draw_popup(out)
178- -- end
179- -- else
180- -- buffer:draw_popup({ "Select a token to evaluate" })
181- -- end
184+ elseif key == " N" then
185+ if not lines then
186+ return
187+ end
188+ local x , y = buffer :xy ()
189+ if lines [y ] then
190+ for _ , note in ipairs (lines [y ]) do
191+ if note .column > x then
192+ buffer :go_to (note .column , y )
193+ return
194+ end
195+ end
196+ end
197+ for line = y + 1 , last_line do
198+ if lines [line ] then
199+ buffer :go_to (lines [line ][1 ].column , line )
200+ return
201+ end
202+ end
182203 elseif key == " D" then
183204 local x , y = buffer :xy ()
184205 local t = type_at (x , y )
0 commit comments