support hyperlinks in the source editor
[?]
Sep 5, 2022, 9:16 PM
UN7GKYV5YP5DQRKDYNYJTGX3CPXQYBVFJ7SLW44NWCN53VEZ3GAACDependencies
- [2]
OI4FPFINsupport drawings in the source editor - [*]
KKMFQDR4editing source code from within the app - [*]
VHQCNMARseveral more modules
Change contents
- edit in source_text.lua at line 113
-- Make [[WikiWords]] (single word, all in one screen line) clickable.local trimmed_word = rtrim(frag) -- compute_fragments puts whitespace at the endif starts_with(trimmed_word, '[[') and ends_with(trimmed_word, ']]') thenlocal filename = trimmed_word:gsub('^..(.*)..$', '%1')if source.link_exists(State, filename) thenlocal filename_text = App.newText(love.graphics.getFont(), filename)button(State, 'link', {x=x+App.width(to_text('[[')), y=y, w=App.width(filename_text), h=State.line_height, color={1,1,1},icon = icon.hyperlink_decoration,onpress1 = function()source.switch_to_file(filename)end,})endend - edit in source_text.lua at line 1627
function source.link_exists(State, filename)if State.link_cache == nil thenState.link_cache = {}endif State.link_cache[filename] == nil thenState.link_cache[filename] = file_exists(filename)endreturn State.link_cache[filename]end - edit in source_text.lua at line 1643
State.link_cache = {} - edit in source_text.lua at line 1663
endfunction starts_with(s, sub)return s:find(sub, 1, --[[no escapes]] true) == 1endfunction ends_with(s, sub)return s:reverse():find(sub:reverse(), 1, --[[no escapes]] true) == 1 - edit in source_edit.lua at line 4
Hyperlink_decoration_color = {r=0.4, g=0.4, b=1} - edit in icons.lua at line 9[5.5526][5.5560]
endfunction icon.hyperlink_decoration(button_params)local x,y = button_params.x, button_params.yApp.color(Hyperlink_decoration_color)love.graphics.line(x,y+Editor_state.line_height, x+button_params.w,y+Editor_state.line_height)