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VDUIUJRKJ7QC
function run.draw_file_select_bar()
local h = Editor_state.line_height+2
local y = App.screen.height-h
love.graphics.setColor(0.9,0.9,0.9)
love.graphics.rectangle('fill', 0, y-10, App.screen.width-1, h+8)
love.graphics.setColor(0.6,0.6,0.6)
love.graphics.line(0, y-10, App.screen.width-1, y-10)
App.color(Text_color)
local prompt = to_text('open file: ')
love.graphics.draw(prompt, 15, y-5)
love.graphics.setColor(1,1,1)
local text_start_x = App.width(prompt)+20
love.graphics.rectangle('fill', text_start_x-5, y-6, App.screen.width-text_start_x-20, h+2, 2,2)
love.graphics.setColor(0.6,0.6,0.6)
love.graphics.rectangle('line', text_start_x-5, y-6, App.screen.width-text_start_x-20, h+2, 2,2)
App.color(Text_color)
if File_select_bar_text == nil then
File_select_bar_text = App.newText(love.graphics.getFont(), File_select_bar_value)
end
App.screen.draw(File_select_bar_text, text_start_x,y-5)
Text.draw_cursor(Editor_state, text_start_x+App.width(File_select_bar_text),y-5)
end
if File_select_bar_value then
if chord == 'escape' then
File_select_bar_value = nil
File_select_bar_text = nil
elseif chord == 'return' then
run.switch_to_file(File_select_bar_value)
File_select_bar_value = nil
File_select_bar_text = nil
elseif chord == 'backspace' then
local len = utf8.len(File_select_bar_value)
local byte_offset = Text.offset(File_select_bar_value, len)
File_select_bar_value = string.sub(File_select_bar_value, 1, byte_offset-1)
File_select_bar_text = nil
end
return
elseif chord == 'C-w' then
File_select_bar_value = ''
File_select_bar_text = nil
end
function run.switch_to_file(filename)
-- first make sure to save edits on any existing file
if Editor_state.next_save then
save_to_disk(Editor_state)
end
-- clear the slate for the new file
Editor_state.filename = filename
load_from_disk(Editor_state)
Text.redraw_all(Editor_state)
Editor_state.screen_top1 = {line=1, pos=1}
Editor_state.cursor1 = {line=1, pos=1}
love.window.setTitle('lines.love - '..Editor_state.filename)
end
By default, lines.love reads/writes the file `lines.txt` in your default
user/home directory (`https://love2d.org/wiki/love.filesystem.getUserDirectory`).
By default, lines.love reads/writes the file `lines.txt` in a directory
specific to this app (https://love2d.org/wiki/love.filesystem.getSourceBaseDirectory).
Updates to lines.love can be downloaded from the following mirrors in addition
to the website above:
* https://github.com/akkartik/lines.love
* https://repo.or.cz/lines.love.git
* https://tildegit.org/akkartik/lines.love
* https://git.tilde.institute/akkartik/lines.love
* https://git.sr.ht/~akkartik/lines.love
* https://notabug.org/akkartik/lines.love
* https://codeberg.org/akkartik/lines.love
* https://pagure.io/lines.love
Forks of lines.love are encouraged. If you show me your fork, I'll link to it
here.
* https://github.com/akkartik/lines-polygon-experiment -- an experiment that
uses separate shortcuts for regular polygons. `ctrl+3` for triangles,
`ctrl+4` for squares, etc.
* https://git.sr.ht/~akkartik/text.love -- a stripped down version without
drawings; useful starting point for some forks
* https://git.sr.ht/~akkartik/pensieve.love -- a note-taking app on an
infinite 2D surface. Still in development.
* https://git.sr.ht/~akkartik/capture.love -- a blank-slate mode for the
note-taking app, so all the stuff pensieve.love puts on screen doesn't cause
you to forget what you came to write down.
This repo is a fork of [lines.love](http://akkartik.name/lines.html), an
editor for plain text where you can also seamlessly insert line drawings.
Updates to it can be downloaded from:
* https://codeberg.org/akkartik/lines2md exports lines.love files to Markdown
and (non-editable) SVG.
* https://git.sr.ht/~akkartik/lines2html.love exports lines.love files to html
and inline SVG.
Further forks are encouraged. If you show me your fork, I'll link to it here.