/xile

A toy front-end to xi-editor written in Guile Scheme

Primary LanguageSchemeMIT LicenseMIT

[WIP] Xile : Xi + Guile

Let’s find out if Guile goes with everything ; and make a front-end for Xi Editor using GNU Guile and libraries.

Table of Contents

Quickstart

Compile Xi editor

Update the submodule and cargo build --release the bundled Xi editor

Start

By default it will load a user config located in this repo in config/xile.scm. It’s hardcoded for now but hopefully will be configurable later.

Dependencies

All dependencies are managed with guix shell, you can setup direnv to work properly with “`bash eval $(guix shell -Df guix.scm –search-paths) path_add GUILE_LOAD_PATH src “`

SDL2

./examples/sdl.scm

Curses

./examples/curses.scm

Test script

For the time being we are just opening this README file to see how it’s displayed.

You can :

  • switch to insert state using i
  • Insert letters at this point
  • use [ESC] to switch back to normal state

There is no visual indicator for the current state, and it’s possible not all letters are supported in insert state. The list can be found looking at how many keys are bound to some sort of self-insert-* function in Editor States module (in the insert-state-keymap variable probably).

Logs

All the logs are located in the logs folder after the run :

xi-core.log
hold the logs from Xi editor process
xile-listen-{out,err}.log
hold the logs from xile functions regarding callbacks and Xi message parsing
xile-{out,err}.log
hold the logs from xile functions outside message callbacks

Stop

Hit q in normal state to stop Xile (it may error out, but you’re still out, right ?). In SDL you can also send a quit-event.

Roadmap

[X] Display buffer
[X] Scroll window
[X] Move cursor
[X] User config as scheme
[X] Xile state (buffer local and session-global variables)
[X] Implement the complete protocol
That is
  1. front -> back serializing, and
  2. back -> front parsing + callbacks

Currently only the {find,replace}_status notifications and the show_hover response message are missing. For the notifications, we will see when we want to support it. For the Show Hover message, this needs to be implemented at the buffer level ; since the buffer will attach the correct id at runtime and register the correct callback.

[X] Keymaps
holding keymaps to ease the event-loop code is also necessary to have multiple editor states
[ ] Editor states (normal and insert at least)
“Normal” state has been ‘done’ (it exists, and is the default). Now 1 more state is needed :
  1. Insert state where every letter is bound to some self-insert method in the buffer
[ ] Proper header/footer
I want to decouple buffer from its curses window, and have the curses-window module actually handle all of header, footer, and main window together
  • Decoupling is done, so now each “xile {sdl,curses} window” can implement their own methods and callback handling to draw headers/footers as they want
  • Management of header/footer is now missing in SDL application
[ ] Scheme evaluator
on : in a vim-like manner, I want to wrap evaluating a user-input string. This probably means a new mode to handle this, using the eval-string method of Guile or something. The Footer handling is a prerequisite, as the input should be checkable by the user.
[ ] Edit file
Set the pristing flag correctly and be able to insert characters. The insert state is a prerequisite, since, well, insert bindings are only going to live there
[ ] Syntax Highlighting
(using xi-core bundled syntect)

Objectives

  • Learn about using a lisp in a complex project
  • Play with ncurses interfaces
  • Play with SDL2 a little bit (Postponed until I can get a proper ncurses interface)
  • See how difficult it is to build software with a json interface to a provider (here we are using Xi Editor as the core text editor).