Skip to content

Commit 9a42f7d

Browse files
committed
Teal: Ctrl+N means next error, Alt+L switch to .lua
Word wrap moves to Alt+N
1 parent f18a0a7 commit 9a42f7d

File tree

4 files changed

+46
-14
lines changed

4 files changed

+46
-14
lines changed

bindings/default

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ CTRL_G Dit_goto
77
CTRL_J Dit_previousTabPage
88
CTRL_K Dit_nextTabPage
99
CTRL_L Dit_refresh
10-
CTRL_N Dit_wordWrap
1110
CTRL_Q Dit_quit
1211
CTRL_S Dit_save
1312
CTRL_T Buffer_toggleTabCharacters
@@ -74,6 +73,7 @@ ALT_A Dit_selectUpLine
7473
ALT_B Dit_selectDownLine
7574
ALT_C Dit_selectForwardChar
7675
ALT_D Dit_selectBackwardChar
76+
ALT_N Dit_wordWrap
7777
WHEELUP Dit_scrollDown
7878
WHEELDOWN Dit_scrollUp
7979
ESC Dit_cancelSelection

highlight/teal.dithl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ context enum `$ bright bright brightdiff
4444

4545
rule as bright
4646
rule is bright
47+
rule where bright

scripts/lua.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,13 @@ function on_key(code)
345345
end
346346
return tab_handled or handled
347347
end
348+
349+
function on_alt(key)
350+
if key == 'L' then
351+
local filename = buffer:filename()
352+
local x, y = buffer:xy()
353+
local page = tabs:open(filename:gsub("%.lua$", ".tl"))
354+
tabs:set_page(page)
355+
tabs:get_buffer(page):go_to(x, y)
356+
end
357+
end

scripts/teal.lua

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local mobdebug = require("dit.lua.mobdebug")
55
local json = require("cjson")
66

77
local lines
8+
local last_line = 0
89
local commented_lines = {}
910
local controlled_change = false
1011
local 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
162167
end
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+
164179
function 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

Comments
 (0)