More things

This commit is contained in:
Fulton Browne 2021-08-29 12:39:21 -07:00
parent c6b0d4160a
commit 9e53fde325
3 changed files with 104 additions and 2 deletions

67
src/fred.ls9 Normal file
View File

@ -0,0 +1,67 @@
;; _____ _
;; | ___| __ ___ __| |
;; | |_ | '__/ _ \/ _` |
;; | _|| | | __/ (_| |
;; |_| |_| \___|\__,_|
;;
;; A simple set of text editing functions
;; This is the first "real" program for NW-lisp
;; will experiment with style and manual things
;; fred is a very simple *buffer* editor for NWL
;; A buffer editor is just a text editor that
;; doesn't care where the buffer comes from
;; fred will have to main modes of operation
;; interactive and non-interactive
;; interactive will be basically a lispy ed
;; non interactive will be a collection of
;; functions that deal with text in buffers
;; the most basic is a random access char editor
;; (sref) and (sset) let us change chars at random
;; we just need to be able to add and remove stings
;; at random.
(defun (fred-insert-string buf pos s) ;; insert string s after offset pos in buffer buf and return the new state of buf
(sconc (substr buf 0 pos) s (substr buf (+ pos 1) (ssize buf))))
(defun (fred-cut-string buf spos epos)
(sconc (substr buf 0 spos) (substr buf epos (ssize buf)))) ;; cut the chars starting at spos and ending at epos
(defun (fred-append-buffer buf s)
(sconc buf s))
;; now we need an interface based on cursor position
;; fred-buffer: (pos buf)
;; fred-backspace, fred-insert
(defun (fred-backspace buf cpos)
(if (eqv cpos (ssize buf))
(substr buf 0 ( - cpos 1))
(sconc (substr buf 0 (- cpos 1) (substr buf (+ cpos 1) (ssize buf))))))
(defun (fred-insert buf cpos s)
(if (eqv cpos (ssize buf)
(sconc buf s)
(fred-insert-string buf cpos s))))
;; now we have the most basic editing commands
;; Lets get some cursor moving commands
;; (fred-next-nl) (fred-prev-nl)
;; (fred-next-line) (fred-prev-line)
;; (fred-start-line) (fred-end-line)
(defun (fred-next-nl buf cpos)
)
(defun (fred-prev-nl buf cpos)
)
(defun (fred-start-line buf cpos)
(+ (fred-prev-nl buf cpos) 1)) ;; go back until you find a new line and then add one to that
(defun (fred-end-line buf cpos)
(- (fred-next-nl buf cpos) 1)) ;; go forword until a newline - minus one
(defun (fred-next-line buf cpos)
(+ (fred-next-nl buf cpos) 1)) ;; go forward until new line - plus one
(defun (fed-prev-line buf cpos)
(- (fred-prev-nl buf cpos) 1)) ;; go back until new line - minus one

View File

@ -1,4 +1,18 @@
(def man-pages '(("man" "Man test")))
(defun (man-info)
(h1 "man")
(l "The documentation system for NW-LISP")
(h2 "SYNOPSIS")
(l "(man term#string)")
(h2 "DESCRIPTION")
(p "Man takes a single argument")
(c "term")
(p "which is the name of the page your looking for.")
(p "if")
(c "term")
(p "mathes a page title, the title's asscoiated (sdoc) function,")
(p "the function is executed."))
(def man-pages '(("man" (man-info))))
(defun (man term)
(print (cdr (asss term man-pages))))
(eval (car (cdr (asss term man-pages)))))
(defun (look-man term) (printc "not done")) ;; TODO

21
src/sdoc.ls9 Normal file
View File

@ -0,0 +1,21 @@
;; The internal system for docs is NW LISP
;; Header functions: (H1) (H2) (H3)...
;; (P)
;; Ok - I need this to work in more than just org -_-
(defun (H1 s)
(printc "*" s))
(defun (H2 s)
(printc "**" s))
(defun (H3 s)
(printc "***" s))
(defun (p s)
(princ " ")
(princ s)
(princ " "))
(defun (l s)
(printc s))
(defun (c s)
(princ "~")
(princ s)
(princ "~"))