Skip to content

Latest commit

 

History

History
172 lines (125 loc) · 6.03 KB

File metadata and controls

172 lines (125 loc) · 6.03 KB

Readme

Basic Editor

This is an experiment writing a simple editor in Lisp.

It is built on top of: https://github.com/bigos/clops-gui

file:~/Programming/Lisp/clops-gui/src/gui-window-gtk.lisp::1

file:~/Programming/Lisp/clops-gui/src/

It is not meant to be a BASIC (programming language) editor, but simple and not complicated, so able to provide the base or starting point from which something can develop.

Testing

5am

how to write fixtures https://www.darkchestnut.com/2018/how-to-write-5am-test-fixtures/

basic editor

defsystem file:basic-editor.asd::(defsystem “basic-editor/tests”

tests folder file:~/Programming/Lisp/basic-editor/tests/

clops gui

defsystem ~/Programming/Lisp/clops-gui/clops-gui.asd

Old Notes

Below are my old notes

counter

We have file:~/Programming/Lisp/lispy-experiments/clops-gui/counter/ project with src file:~/Programming/Lisp/lispy-experiments/clops-gui/counter/src/ that can be used as example and to derive new project

src folder

basic-editor src file:~/Programming/Lisp/lispy-experiments/clops-gui/basic-editor/src/

editor

sections

We will try to have a reactive toolbar, edit area and status area. using this example file:~/Programming/Lisp/clops-gui/examples/boxes2.lisp::1

representation of text

needed for cursor movement file:src/basic-editor.lisp::((text :std file:src/basic-editor.lisp::for c across

rope

https://en.wikipedia.org/wiki/Rope_(data_structure)

creating new rope

(sycamore:rope-map #'identity my-new-text)

other experiments

file:Programming/Lisp/lispy-experiments/to-do-list.lisp file:Programming/Lisp/lispy-experiments/klopsik.lisp

libraries to check

Curated libraries

https://github.com/garlic0x1/rope

https://github.com/orthecreedence/cl-hash-util https://gitlab.common-lisp.net/fset/fset/-/wikis/home https://github.com/sirherrbatka/cl-data-structures

interesting sources

Gaborean AAAAA Lisp Reference books

ACME

https://www.youtube.com/watch?v=TBnPxe4e6Ek https://www.youtube.com/watch?v=dP1xVpMPn8M https://github.com/jinyangustc/acme-editor

notes

REPL discovery

I can press F8 to go to debugger. At this point the Gtk loop is suspended and I can use the REPL to modify the state of the app. I was able to modify the cursor position using REPL and the slime scratch buffer.

clops gui

Clops-Gui file:~/Programming/Lisp/clops-gui/src/packages.lisp::1

FileDialog

https://docs.gtk.org/gtk4/class.FileDialog.html

window and callback file:~/Programming/Lisp/lispy-experiments/clops-gui/basic-editor/src/basic-editor.lisp::gui-drawing:*client-fn-draw-objects* ‘basic-editor::draw-window

<a href=”file:~/Programming/Lisp/clops-gui/src/gui-drawing.lisp::defparameter @@html:@@client-fn-draw-objects@@html:@@ nil”>file:~/Programming/Lisp/clops-gui/src/gui-drawing.lisp::defparameter client-fn-draw-objects nil

drawfunc callback file:~/Programming/Lisp/clops-gui/src/gui-window-gtk.lisp::gtk4:drawing-area-draw-func canvas) (list (cffi:callback gui-drawing:%draw-func file:~/Programming/Lisp/clops-gui/src/gui-drawing.lisp::cffi:defcallback %draw-func :void ((area :pointer

dialogs file:~/Programming/Lisp/clops-gui/src/gui-window-gtk.lisp::defun present-about-dialog (data

correcting gir wrapper https://github.com/bohonghuang/cl-gobject-introspection-wrapper

file:~/quicklisp/dists/ultralisp/software/bohonghuang-cl-gobject-introspection-wrapper-20230426155536/desc.lisp::1 file:~/quicklisp/dists/ultralisp/software/bohonghuang-cl-gobject-introspection-wrapper-20230426155536/macro.lisp::1

testing cursor movement

file:~/Programming/Lisp/basic-editor/tests/basic-editor-tests.lisp::1

first line left and up

file:tests/basic-editor-tests.lisp::(def-suite basic-editor-text-first-line-left

last line right and bottom

trying to change

what we had so far

model file:src/basic-editor.lisp::(defclass/std basic-editor-model key handling file:src/basic-editor.lisp::(defun handle-key-pressed drawing file:src/basic-editor.lisp::(defmethod draw-window file opening file:src/basic-editor.lisp::(defun open-file setting function for open file library function for file dialog and callback reload file structure file:src/basic-editor.lisp::setf (text model) text-content file:src/basic-editor.lisp::reload-text-structure model)))) file:src/basic-editor.lisp::(defmethod reload-text-structure text stats file:src/basic-editor.lisp::let ((stats (text-stats (text model))) file:src/basic-editor.lisp::defun text-stats (text file:src/basic-editor.lisp::defun sample-text-stats (text so after loading the test we have model text and text-structure The text-structure comes from file:src/basic-editor.lisp::defun sample-text-stats (text and contains a hash of line stats which are instances of file:src/basic-editor.lisp::(defclass/std text-row

cursor

cursor is created by default file:src/basic-editor.lisp::cursor :std (make-instance ‘cursor :row 0 :col 0)

methods file:src/basic-editor.lisp::defmethod cursor-stats ((model basic-editor-model)

file:src/basic-editor.lisp::defmethod cursor-position ((cursor cursor)

file:src/basic-editor.lisp::defmethod move-cursor-to ((model basic-editor-model) row col

text-row

file:src/basic-editor.lisp::defmethod row-text ((row text-row) text

problem with cursor movement on wrapped text

text-stats file:src/basic-editor.lisp::defun sample-text-stats (text