Just Another Line Editor
Go to file
Productive2 5d56d59c7f Testing events 2021-02-19 11:49:18 +01:00
.github/ISSUE_TEMPLATE Update issue templates 2021-02-15 23:41:55 +01:00
examples Created nimble package 2021-02-19 11:27:27 +01:00
src/jale Testing events 2021-02-19 11:49:18 +01:00
tests Testing events 2021-02-19 11:49:18 +01:00
.gitignore Testing events 2021-02-19 11:49:18 +01:00
LICENSE Create LICENSE 2021-02-15 22:00:25 +01:00
README.md update readme 2021-02-19 00:03:01 +01:00
getkey.nim new keybindings 2021-02-15 21:51:23 +01:00
jale.nimble Created nimble package 2021-02-19 11:27:27 +01:00
testing.md History progress, but current behavior is broken 2021-02-18 00:23:31 +01:00

README.md

Just Another Line Editor

or jale.nim

Note

This is a new (and very immature) alternative to other line editors such as linenoise (see rdstdin in the nim standard library) or nimline (https://github.com/h3rald/nimline). Currently you probably want to use either of those because this is a wip.

Building

Have nim (tested on 1.4.2, x86_64 gnu/linux) installed.

git clone https://github.com/japl-lang/jale
cd jale
nim c main
./main

You should enter a temporary testing prompt, which you can quit with ctrl+c. Pressing enter when the last line is empty submits the output.

Features

  • multiline support
  • easily add new keybindings (using templates)
  • very customizable (even inserting characters is a keybinding that's optional)
  • plugin system based
  • history

Example usage

# for now, from the same directory where it's cloned
# import the line editor
import editor
# import the default keybindings for basic stuff
# like arrow key movement or inserting characters
import plugin/defaults
# import helper templates for adding custom key or
# event bindings
import templates

# create the line editor
let e = newLineEditor()
# set its prompt to something
e.prompt = "> "
# add the default keybindings
e.populateDefaults()

var printOutput = true

# very weird use case, but if ctrl+b is pressed during reading, don't
# print the output
e.bindKey("ctrl+b"):
	printOutput = false

let input = e.read()
if printOutput:
	echo "output:"
	echo input

Also see examples folder if the above example does not suffice, and look at defaults.nim for many binding examples. Look at multiline.nim's procs and editor.nim's LineEditor type for an "API". It's wip, docs will improve if it ever gets more stable.

Missing features

Note: they won't be missing forever hopefully.

  • No utf-8
  • No tab autocompletion support
  • No syntax highlighting support
  • Windows keybindings not finished, windows was not tested yet