Commit 986fed5e authored by Troels Henriksen's avatar Troels Henriksen

Removed the Basic syntax and the `cache' slot in the `climacs-pane'

class. Fundamental syntax is now the default. This also required
moving some things around, but there has not been any functionality
changes.
parent a3215d4d
......@@ -111,7 +111,7 @@
(make-instance 'other-entry))))))))
(define-syntax cl-syntax (basic-syntax)
(define-syntax cl-syntax (fundamental-syntax)
((lexer :reader lexer)
(valid-parse :initform 1)
(parser))
......
......@@ -459,7 +459,7 @@ spaces only."))
:test (lambda (x y)
(member x y :test #'string-equal))
:key #'climacs-syntax::syntax-description-pathname-types))
'basic-syntax))
*default-syntax*))
(defun evaluate-attributes (buffer options)
"Evaluate the attributes `options' and modify `buffer' as
......@@ -627,10 +627,6 @@ spaces only."))
(make-buffer-from-stream stream *application-frame*))
(make-new-buffer *application-frame*)))
(pane (current-window)))
;; Clear the pane's cache; otherwise residue from the
;; previously displayed buffer may under certain
;; circumstances be displayed.
(clear-cache pane)
(setf (offset (point (buffer pane))) (offset (point pane))
(buffer (current-window)) buffer
(syntax buffer) (make-instance (syntax-class-name-for-filepath filepath)
......
This diff is collapsed.
......@@ -22,7 +22,7 @@
(in-package :climacs-html-syntax)
(define-syntax html-syntax (basic-syntax)
(define-syntax html-syntax (fundamental-syntax)
((lexer :reader lexer)
(valid-parse :initform 1)
(parser))
......
......@@ -60,7 +60,7 @@
;;;
;;; the syntax object
(define-syntax lisp-syntax (basic-syntax)
(define-syntax lisp-syntax (fundamental-syntax)
((stack-top :initform nil)
(potentially-valid-trees)
(lookahead-lexeme :initform nil :accessor lookahead-lexeme)
......
......@@ -118,13 +118,12 @@
(defpackage :climacs-syntax
(:use :clim-lisp :clim :climacs-buffer :climacs-base :flexichain)
(:export #:syntax #:define-syntax
(:export #:syntax #:define-syntax #:*default-syntax*
#:eval-option
#:define-option-for-syntax
#:current-attributes-for-syntax
#:make-attribute-line
#:syntax-from-name
#:basic-syntax
#:update-syntax #:update-syntax-for-display
#:grammar #:grammar-rule #:add-rule
#:parser #:initial-state
......@@ -179,6 +178,7 @@
#:redisplay-pane #:full-redisplay
#:display-cursor
#:display-region
#:offset-to-screen-position
#:page-down #:page-up
#:top #:bot
#:tab-space-count #:space-width #:tab-width
......@@ -311,6 +311,11 @@
manipulating belong to. These functions are also directly used
to implement the editing commands."))
(defpackage :climacs-fundamental-syntax
(:use :clim-lisp :clim :climacs-buffer :climacs-base
:climacs-syntax :flexichain :climacs-pane)
(:export #:fundamental-syntax))
(defpackage :climacs-gui
(:use :clim-lisp :clim :climacs-buffer :climacs-base
:climacs-abbrev :climacs-syntax :climacs-motion
......@@ -367,7 +372,7 @@
))
(defpackage :climacs-core
(:use :clim-lisp :climacs-base :climacs-buffer
(:use :clim-lisp :climacs-base :climacs-buffer :climacs-fundamental-syntax
:climacs-syntax :climacs-motion :climacs-pane :climacs-kill-ring
:climacs-editing :climacs-gui :clim :climacs-abbrev :esa :esa-buffer :esa-io)
(:export #:display-string
......@@ -432,28 +437,23 @@
command definitions, as well as some useful automatic
command-defining facilities."))
(defpackage :climacs-fundamental-syntax
(:use :clim-lisp :clim :climacs-buffer :climacs-base
:climacs-syntax :flexichain :climacs-pane)
(:export #:fundamental-syntax))
(defpackage :climacs-html-syntax
(:use :clim-lisp :clim :climacs-buffer :climacs-base
:climacs-syntax :flexichain :climacs-pane))
:climacs-syntax :flexichain :climacs-pane :climacs-fundamental-syntax))
(defpackage :climacs-prolog-syntax
(:use :clim-lisp :clim :climacs-buffer :climacs-base
:climacs-syntax :flexichain :climacs-pane :climacs-core)
:climacs-syntax :flexichain :climacs-pane :climacs-core :climacs-fundamental-syntax)
(:shadow #:atom #:close #:exp #:integer #:open #:variable))
(defpackage :climacs-cl-syntax
(:use :clim-lisp :clim :climacs-buffer :climacs-base
:climacs-syntax :flexichain :climacs-pane)
:climacs-syntax :flexichain :climacs-pane :climacs-fundamental-syntax)
(:export))
(defpackage :climacs-lisp-syntax
(:use :clim-lisp :clim :clim-extensions :climacs-buffer :climacs-base
:climacs-syntax :flexichain :climacs-pane :climacs-gui
:climacs-syntax :climacs-fundamental-syntax :flexichain :climacs-pane :climacs-gui
:climacs-motion :climacs-editing :climacs-core)
(:export #:lisp-string
#:edit-definition))
......
This diff is collapsed.
......@@ -26,7 +26,7 @@
(defclass prolog-parse-tree (parse-tree)
())
(define-syntax prolog-syntax (basic-syntax)
(define-syntax prolog-syntax (fundamental-syntax)
((lexer :reader lexer)
(valid-parse :initform 1)
(parser)
......
......@@ -22,7 +22,7 @@
(defpackage :climacs-slidemacs-editor
(:use :clim-lisp :clim :clim-extensions :climacs-buffer :climacs-base
:climacs-syntax :flexichain :climacs-pane)
:climacs-syntax :flexichain :climacs-pane :climacs-fundamental-syntax)
(:export))
(in-package :climacs-slidemacs-editor)
......@@ -105,7 +105,7 @@
(make-instance 'slidemacs-keyword))
(t (fo) (make-instance 'other-entry)))))))))
(define-syntax slidemacs-editor-syntax (basic-syntax)
(define-syntax slidemacs-editor-syntax (fundamental-syntax)
((lexer :reader lexer)
(valid-parse :initform 1) (parser))
(:name "Slidemacs-Editor")
......
......@@ -112,11 +112,15 @@ in the specific syntax.")
(defgeneric name-for-info-pane (syntax &key &allow-other-keys)
(:documentation "Return the name that should be used for the
info-pane for panes displaying a buffer in this syntax."))
info-pane for panes displaying a buffer in this syntax.")
(:method (syntax &key &allow-other-keys)
(name syntax)))
(defgeneric display-syntax-name (syntax stream &key &allow-other-keys)
(:documentation "Draw the name of the syntax `syntax' to
`stream'. This is meant to be called for the info-pane."))
`stream'. This is meant to be called for the info-pane.")
(:method (syntax stream &rest args &key)
(princ (apply #'name-for-info-pane syntax args) stream)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
......@@ -124,6 +128,12 @@ in the specific syntax.")
(defparameter *syntaxes* '())
(defvar *default-syntax* nil
"The name of the default syntax. Must be a symbol.
This syntax will be used by default, when no other syntax is
mandated by file types or attribute lists.")
(defstruct (syntax-description (:type list))
(name (error "required argument") :type string)
(class-name (error "required argument") :type symbol)
......@@ -249,37 +259,6 @@ in the specific syntax.")
(when description
(find-class (syntax-description-class-name description)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Basic syntax
;;; FIXME: this is a really bad name. It's even worse if it's
;;; case-insensitive. Emacs' "Fundamental" isn't too bad.
(define-syntax basic-syntax (syntax)
()
(:name "Basic"))
(defmethod update-syntax (buffer (syntax basic-syntax))
(declare (ignore buffer))
nil)
(defmethod update-syntax-for-display (buffer (syntax basic-syntax) from to)
(declare (ignore buffer from to))
nil)
(defmethod name-for-info-pane ((syntax basic-syntax) &key)
(name syntax))
(defmethod display-syntax-name ((syntax basic-syntax) stream &rest args &key)
(princ (apply #'name-for-info-pane syntax args) stream))
(defmethod syntax-line-indentation (mark tab-width (syntax basic-syntax))
(declare (ignore mark tab-width))
0)
(defmethod eval-defun (mark syntax)
(error 'no-such-operation))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Incremental Earley parser
......
......@@ -65,7 +65,7 @@
(setf low-position (floor (+ low-position 1 high-position) 2)))
finally (return low-position)))
(define-syntax text-syntax (basic-syntax)
(define-syntax text-syntax (climacs-fundamental-syntax:fundamental-syntax)
((paragraphs :initform (make-instance 'standard-flexichain))
(sentence-beginnings :initform (make-instance 'standard-flexichain))
(sentence-endings :initform (make-instance 'standard-flexichain)))
......@@ -79,74 +79,75 @@
(let ((pos1 (index-of-mark-after-offset paragraphs low-offset))
(pos-sentence-beginnings (index-of-mark-after-offset sentence-beginnings low-offset))
(pos-sentence-endings (index-of-mark-after-offset sentence-endings low-offset)))
;; start by deleting all syntax marks that are between the low and
;; the high marks
(loop repeat (- (nb-elements paragraphs) pos1)
while (mark<= (element* paragraphs pos1) high-offset)
do (delete* paragraphs pos1))
(loop repeat (- (nb-elements sentence-beginnings) pos-sentence-beginnings)
while (mark<= (element* sentence-beginnings pos-sentence-beginnings) high-offset)
do (delete* sentence-beginnings pos-sentence-beginnings))
(loop repeat (- (nb-elements sentence-endings) pos-sentence-endings)
while (mark<= (element* sentence-endings pos-sentence-endings) high-offset)
do (delete* sentence-endings pos-sentence-endings))
;; check the zone between low-offset and high-offset for
;; paragraph delimiters and sentence delimiters
(loop with buffer-size = (size buffer)
for offset from low-offset to high-offset ;; Could be rewritten with even fewer buffer-object calls,
for current-object = nil then (if (>= offset high-offset) nil (buffer-object buffer offset)) ;; but it'd be premature optimization, and messy besides.
for next-object = nil then (if (>= offset (- high-offset 1)) nil (buffer-object buffer (1+ offset)))
for prev-object = nil then (if (= offset low-offset) nil (buffer-object buffer (1- offset)))
for before-prev-object = nil then (if (<= offset (1+ low-offset)) nil (buffer-object buffer (- offset 2)))
do (progn
(cond ((and (< offset buffer-size)
(member prev-object '(#\. #\? #\!))
(or (= offset (1- buffer-size))
(and (member current-object '(#\Newline #\Space #\Tab))
(or (= offset 1)
(not (member before-prev-object '(#\Newline #\Space #\Tab)))))))
(let ((m (clone-mark (low-mark buffer) :left)))
(setf (offset m) offset)
(insert* sentence-endings pos-sentence-endings m))
(incf pos-sentence-endings))
((and (>= offset 0)
(not (member current-object '(#\. #\? #\! #\Newline #\Space #\Tab)))
(or (= offset 0)
(member prev-object '(#\Newline #\Space #\Tab)))
(or (<= offset 1)
(member before-prev-object '(#\. #\? #\! #\Newline #\Space #\Tab))))
(let ((m (clone-mark (low-mark buffer) :right)))
(setf (offset m) offset)
(insert* sentence-beginnings pos-sentence-beginnings m))
(incf pos-sentence-beginnings))
(t nil))
;; Paragraphs
(cond ((and (< offset buffer-size) ;; Ends
(not (eql current-object #\Newline))
(or (zerop offset)
(and (eql prev-object #\Newline)
(or (= offset 1)
(eql before-prev-object #\Newline)))))
(let ((m (clone-mark (low-mark buffer) :left)))
(setf (offset m) offset)
(insert* paragraphs pos1 m))
(incf pos1))
((and (plusp offset) ;;Beginnings
(not (eql prev-object #\Newline))
(or (= offset buffer-size)
(and (eql current-object #\Newline)
(or (= offset (1- buffer-size))
(eql next-object #\Newline)))))
(let ((m (clone-mark (low-mark buffer) :right)))
(setf (offset m) offset)
(insert* paragraphs pos1 m))
(incf pos1))
(t nil))))))))
;; start by deleting all syntax marks that are between the low and
;; the high marks
(loop repeat (- (nb-elements paragraphs) pos1)
while (mark<= (element* paragraphs pos1) high-offset)
do (delete* paragraphs pos1))
(loop repeat (- (nb-elements sentence-beginnings) pos-sentence-beginnings)
while (mark<= (element* sentence-beginnings pos-sentence-beginnings) high-offset)
do (delete* sentence-beginnings pos-sentence-beginnings))
(loop repeat (- (nb-elements sentence-endings) pos-sentence-endings)
while (mark<= (element* sentence-endings pos-sentence-endings) high-offset)
do (delete* sentence-endings pos-sentence-endings))
;; check the zone between low-offset and high-offset for
;; paragraph delimiters and sentence delimiters
(loop with buffer-size = (size buffer)
for offset from low-offset to high-offset ;; Could be rewritten with even fewer buffer-object calls,
for current-object = nil then (if (>= offset high-offset) nil (buffer-object buffer offset)) ;; but it'd be premature optimization, and messy besides.
for next-object = nil then (if (>= offset (- high-offset 1)) nil (buffer-object buffer (1+ offset)))
for prev-object = nil then (if (= offset low-offset) nil (buffer-object buffer (1- offset)))
for before-prev-object = nil then (if (<= offset (1+ low-offset)) nil (buffer-object buffer (- offset 2)))
do (progn
(cond ((and (< offset buffer-size)
(member prev-object '(#\. #\? #\!))
(or (= offset (1- buffer-size))
(and (member current-object '(#\Newline #\Space #\Tab))
(or (= offset 1)
(not (member before-prev-object '(#\Newline #\Space #\Tab)))))))
(let ((m (clone-mark (low-mark buffer) :left)))
(setf (offset m) offset)
(insert* sentence-endings pos-sentence-endings m))
(incf pos-sentence-endings))
((and (>= offset 0)
(not (member current-object '(#\. #\? #\! #\Newline #\Space #\Tab)))
(or (= offset 0)
(member prev-object '(#\Newline #\Space #\Tab)))
(or (<= offset 1)
(member before-prev-object '(#\. #\? #\! #\Newline #\Space #\Tab))))
(let ((m (clone-mark (low-mark buffer) :right)))
(setf (offset m) offset)
(insert* sentence-beginnings pos-sentence-beginnings m))
(incf pos-sentence-beginnings))
(t nil))
;; Paragraphs
(cond ((and (< offset buffer-size) ;; Ends
(not (eql current-object #\Newline))
(or (zerop offset)
(and (eql prev-object #\Newline)
(or (= offset 1)
(eql before-prev-object #\Newline)))))
(let ((m (clone-mark (low-mark buffer) :left)))
(setf (offset m) offset)
(insert* paragraphs pos1 m))
(incf pos1))
((and (plusp offset) ;;Beginnings
(not (eql prev-object #\Newline))
(or (= offset buffer-size)
(and (eql current-object #\Newline)
(or (= offset (1- buffer-size))
(eql next-object #\Newline)))))
(let ((m (clone-mark (low-mark buffer) :right)))
(setf (offset m) offset)
(insert* paragraphs pos1 m))
(incf pos1))
(t nil)))))))
(call-next-method))
(defmethod backward-one-paragraph (mark (syntax text-syntax))
(with-slots (paragraphs) syntax
......
......@@ -22,7 +22,7 @@
(defpackage :climacs-ttcn3-syntax
(:use :clim-lisp :clim :clim-extensions :climacs-buffer :climacs-base
:climacs-syntax :flexichain :climacs-pane)
:climacs-syntax :flexichain :climacs-pane :climacs-fundamental-syntax)
(:export))
(in-package :climacs-ttcn3-syntax)
......@@ -119,7 +119,7 @@
(make-instance 'identifier))
(t (fo) (make-instance 'other-entry)))))))))
(define-syntax ttcn3-syntax (basic-syntax)
(define-syntax ttcn3-syntax (fundamental-syntax)
((lexer :reader lexer)
(valid-parse :initform 1)
(parser))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment