Jinsong Zhao <
jsz...@yeah.net> writes:
> Hi there,
>
> Is there any tiny editor (the smaller, the better) that is written in Common
> Lisp?
I have written a terminfo to lisp code compiler. I was trying to
implement a readline like interface to terminfo for the ED function.
Unfortunately I got interrupted again. Let me know if your interested.
It is only ~ 2000 lines :)
I am trying to figure out how to implement the buffer. I would like fast
searching so a gap buffer would be better than a line structure.
I started it out as a rule/planning system to implement the best
possible sequences - the rule engine is too slow for practical use but
it is very fun to play with.
I have a working version that uses linux kernel keysyms. I am
struggling with signals and intervals for text highlighting.
Anyone have a solution for intervals. I was thinking to use displaced
arrays.
The other problem is unicode. I do not understand this. I planned on
just supporting the 96 letters in common lisp.
The rules are simple, they look like:
(define-motion ("cursor_home") (curscr)
(cm-cursor-save-xy curscr)
(setf (screen-cur-x curscr) (screen-beg-x curscr))
(setf (screen-cur-y curscr) (screen-beg-y curscr))
(output-cond! ((=> "home"))
((=> "cup") (output-sequence! "cup" (screen-beg-x curscr) (screen-beg-y curscr)))))
.
After the terminal definition is loaded it expands the rule into the following.
(PROGN
(DEFUN CM-CURSOR-HOME ()
"[cursor_home;home;ho]: home cursor (if no cup)"
(DECLARE
(OPTIMIZE SPEED (SAFETY 1) (DEBUG 2) (SPACE 0) (COMPILATION-SPEED 0)))
(LET ((CURSCR (CURRENT-SCREEN)))
(DECLARE (SCREEN CURSCR))
(CM-CURSOR-SAVE-XY CURSCR)
(SETF (SCREEN-CUR-X CURSCR) (SCREEN-BEG-X CURSCR))
(SETF (SCREEN-CUR-Y CURSCR) (SCREEN-BEG-Y CURSCR))
(BLOCK #:CURSOR-HOME
(LOCALLY
(DECLARE
(OPTIMIZE SPEED (SPACE 0) (DEBUG 3) (SAFETY 3) (COMPILATION-SPEED 0)))
(SB-UNIX:UNIX-WRITE (SCREEN-OFD CURSCR) "\E[H" 0 3)
T))))
(PUSHNEW 'CM-CURSOR-HOME *CM-FUNCTIONS* :TEST #'EQ))
I wanted to use it for goal planning - but this would be far to slow for
a read text editor.
I am using it across virtual terminals successfully. The buffering is a
pain. It also implements termios so that you can set the read to 4 bytes
UTF8.
If you have an example that is simple I would love to hear more.