Fork of lines.love without drawings; useful starting point for further forks http://akkartik.name/lines.html
Go to file
Kartik K. Agaram fa778f95a1 _yet another_ bugfix to the version check X-(
When I stopped running the version check before the tests I also stopped
initializing Version, which can be used in tests to watch out for font
changes across versions. As a result I started seeing a test failure
with LÖVE v12.

It looks like all manual tests pass now. And we're also printing the
warning about version checks before running tests, which can come in
handy if a new version ever causes test failures. The only thing that
makes me unhappy is the fact that we're calling the version check twice.
And oh, the fact that this part around initialization and version
management is clearly still immature.

I'll capture some desires and fragmentary thought processes around them:

* If there's an error, go to the source editor.

* But oh, don't go to source editor on some unactionable errors, so we
  include a new `Current_app` mode for them:
  * Unsupported version requires an expert. Just muddle through if you
    can or give a warning someone can send me.
  * A failing test might be spurious depending on the platform and font
    rendering scheme. So again just provide a warning someone can send
    me.

  [Source editor can be confusing for errors. Also an editor! But not
  showing the file you asked for!]

* But our framework clears the warning after running tests:
  * If someone is deep in developing a new feature and quits -> restore
    back in the source editor.

  [Perhaps `Current_app` is the wrong place for this third hacky mode,
  since we actually want to continue running. Perhaps it's orthogonal to
  `Current_app`.]

  [Ideally I wouldn't run the tests after the version check. I'd pause,
  wait for a key and then resume tests? "Muddle through" is a pain to
  orchestrate.]

* We store `Current_app` in settings. But we don't really intend to
  persist a `Current_app` of 'error'. Only the main app or 'source'
  editor.

  [Another vote against storing 'error' in `Current_app`.]

* So we need to rerun the version check after running tests to actually
  show the warning.

  [Perhaps I need to separate out the side-effect of setting `Version`
  from the side-effect of changing `Current_app`. But that's not right
  either, because I do still want to raise an error message if the
  version check fails before running tests. Which brings us back to
  wanting to run the tests after raising the version check..]

One good thing: none of the bugs so far have been about silently
ignoring test failures. I thought that might be the case for a bit,
which was unnerving.

I grew similar muddiness in Mu's bootstrap system over time, with
several surrounding modes around the core program that interacted poorly
or at least unsatisfyingly with each other. On one level it just feels
like this outer layer reflects muddy constraints in the real world. But
perhaps there's some skill I still need to learn here..

Why am I even displaying this error if we're going to try to muddle
through anyway? In (vain) hopes that someone will send me that
information. It's not terribly actionable even to me. But it's really
intended for when making changes. If a test fails then, you want to
know.

The code would be cleaner if I just threw an unrecoverable error from
the version check. Historically, the way I arrived at this solution was:
  * I used the default love.errorhandler for a while
  * I added xpcall and error recovery, but now I have situations where I
    would rather fall back on love.errorhandler. How to tell xpcall
    that?
But no, this whole line of thought is wrong. LÖVE has a precedent for
trying to muddle through on an unexpected version. And spurious test
failures don't merit a hard crash. There's some irreducible requirement
here. No point making the code simplistic when the world is complex.

Perhaps I should stop caching Version and just recompute it each time.
It's only used once so far, hardly seems worth the global.

We have two bits of irreducible complexity here:
  * If tests fail it might be a real failure, or it might not.
  * Even if it's an unexpected version, everything might be fine.
And the major remaining problem happens at the intersection of these two
bits. What if we get an unexpected version with some difference that
causes tests to fail? But this is a hypothetical and not worth thinking
about since I'll update the app fairly quickly in response to new
versions.
2023-12-06 17:34:04 -08:00
LICENSE.txt add a license 2022-05-16 18:51:28 -07:00
Manual_tests.md _yet another_ bugfix to the version check X-( 2023-12-06 17:34:04 -08:00
MemoryReferenceInfo.lua.0 remove some memory leaks from rendered fragments 2022-06-10 11:16:41 -07:00
MemoryReferenceInfo.lua.unused clean up memory leak experiments 2022-06-10 13:46:59 -07:00
README.md Revert "deemphasize the source editor" 2023-09-10 21:45:59 -07:00
app.lua _yet another_ bugfix to the version check X-( 2023-12-06 17:34:04 -08:00
button.lua use color alpha in button backgrounds 2023-10-16 22:59:04 -07:00
colorize.lua stop highlighting strings in code 2023-06-17 10:41:50 -07:00
commands.lua audit all asserts 2023-11-18 11:32:01 -08:00
drawing.lua audit all asserts 2023-11-18 11:32:01 -08:00
drawing_tests.lua bugfix: naming points 2023-03-26 09:36:41 -07:00
edit.lua clearing starty is redundant in mutations 2023-12-03 10:32:05 -08:00
file.lua audit all asserts 2023-11-18 11:32:01 -08:00
geom.lua audit all asserts 2023-11-18 11:32:01 -08:00
help.lua get rid of to_text 2023-04-01 16:12:55 -07:00
icons.lua switch source side to new screen-line-based render 2023-04-03 08:33:07 -07:00
json.lua forgot to add json.lua 2022-05-15 14:36:25 -07:00
keychord.lua support for num pad 2023-07-07 18:40:12 -07:00
log.lua change section delimiters in log for OpenBSD 2023-10-20 15:53:03 -07:00
log_browser.lua audit all asserts 2023-11-18 11:32:01 -08:00
main.lua speculatively recommend new LÖVE v11.5 in all forks 2023-12-03 12:12:56 -08:00
nativefs.lua cleaner API for file-system access 2023-08-30 19:04:06 -07:00
reference.md cleaner API for file-system access 2023-08-30 19:04:06 -07:00
run.lua use my name for a dir 2023-10-27 23:58:42 -07:00
run_tests.lua deduce test names on failures 2023-01-20 21:48:49 -08:00
search.lua audit all asserts 2023-11-18 11:32:01 -08:00
select.lua manually maintain mouse button press state 2023-12-01 21:56:35 -08:00
source.lua source: show file being edited in window title bar 2023-09-15 13:36:27 -07:00
source_edit.lua clearing starty is redundant in mutations 2023-12-03 10:32:05 -08:00
source_file.lua audit all asserts 2023-11-18 11:32:01 -08:00
source_select.lua mouse button state in source editor 2023-12-01 22:07:24 -08:00
source_tests.lua bugfix: Windows pushing title bar off screen 2023-07-10 17:09:09 -07:00
source_text.lua port keyboard layout handling to source editor 2023-11-25 15:31:42 -08:00
source_text_tests.lua fix all tests in LÖVE v12 2023-10-09 20:25:08 -07:00
source_undo.lua audit all asserts 2023-11-18 11:32:01 -08:00
test.lua show another detail on test failure 2023-01-20 21:48:49 -08:00
text.lua improved handling of other keyboard layouts 2023-11-25 15:20:55 -08:00
text_tests bugfix: clear selection when clicking above or below lines 2023-09-20 13:39:29 -07:00
text_tests.lua fix all tests in LÖVE v12 2023-10-09 20:25:08 -07:00
undo.lua audit all asserts 2023-11-18 11:32:01 -08:00

README.md

Plain text with lines

An editor for plain text where you can also seamlessly insert line drawings. Designed above all to be easy to modify and give you early warning if your modifications break something.

http://akkartik.name/lines.html

Getting started

Install LÖVE. It's just a 5MB download, open-source and extremely well-behaved. I'll assume below that you can invoke it using the love command, but that might vary depending on your OS.

To run from the terminal, pass this directory to LÖVE, optionally with a file path to edit.

Alternatively, turn it into a .love file you can double-click on:

$ zip -r /tmp/lines.love *.lua

By default, lines.love reads/writes the file lines.txt in a directory relative to this app.

To open a different file, drop it on the lines.love window.

Keyboard shortcuts

While editing text:

  • ctrl+f to find patterns within a file
  • ctrl+c to copy, ctrl+x to cut, ctrl+v to paste
  • ctrl+z to undo, ctrl+y to redo
  • ctrl+= to zoom in, ctrl+- to zoom out, ctrl+0 to reset zoom
  • alt+right/alt+left to jump to the next/previous word, respectively
  • mouse drag or shift + movement to select text, ctrl+a to select all
  • ctrl+e to modify the sources

For shortcuts while editing drawings, consult the online help. Either:

  • hover on a drawing and hit ctrl+h, or
  • click on a drawing to start a stroke and then press and hold h to see your options at any point during a stroke.

lines.love has been exclusively tested so far with a US keyboard layout. If you use a different layout, please let me know if things worked, or if you found anything amiss: http://akkartik.name/contact

Known issues

  • No support yet for Unicode graphemes spanning multiple codepoints.

  • No support yet for right-to-left languages.

  • Undo/redo may be sluggish in large files. Large files may grow sluggish in other ways. lines.love works well in all circumstances with files under 50KB.

  • If you kill the process, say by force-quitting because things things get sluggish, you can lose data.

  • The text cursor will always stay on the screen. This can have some strange implications:

    • A long series of drawings will get silently skipped when you hit page-down, until a line of text can be showed on screen.
    • If there's no line of text at the top of the file, you may not be able to scroll back up to the top with page-up.

    So far this app isn't really designed for drawing-heavy files. For now I'm targeting mostly-text files with a few drawings mixed in.

  • No clipping yet for drawings. In particular, circles/squares/rectangles and point labels can overflow a drawing.

  • Touchpads can drag the mouse pointer using a light touch or a heavy click. On Linux, drags using the light touch get interrupted when a key is pressed. You'll have to press down to drag.

  • Can't scroll while selecting text with mouse.

  • No scrollbars yet. That stuff is hard.

Mirrors and Forks

Updates to lines.love can be downloaded from the following mirrors in addition to the website above:

Forks of lines.love are encouraged. If you show me your fork, I'll link to it here.

Associated tools

Feedback

Most appreciated.