Skip to content

Commit

Permalink
Add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
soegaard committed Aug 14, 2018
1 parent 591b85d commit 0682a40
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions point.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,28 @@
;;; POINT
;;;

; Each buffer has a point. The point is the position where character and strings
; insertions happen. The point is represented as a mark.
; Use get-point to get the mark representing the point.
; Use point to get the position of the mark.
; Use with-saved-point to preserverve the point placement.
; If narrowing is in effect, the point movement is restricted.
; The functions point-min and point-max in "narrowing.rkt" returns
; the minimum and maximum point positions.

(require (for-syntax racket/base syntax/parse "parameters.rkt" "representation.rkt")
racket/list
"mark.rkt"
"parameters.rkt"
"representation.rkt")

; get-point : window -> mark
; get the mark that represent the point
(define (get-point [b (current-buffer)])
(buffer-point b))

; point : window -> integer
; get the position of the mark
(define (point [b (current-buffer)])
(mark-position (buffer-point b)))

Expand All @@ -25,6 +36,11 @@
[m (mark-move-to-position! m (position pos))]
[else (mark-move-to-position! (get-point) (position pos))]))


; SYNTAX (with-saved-point body ...)
; Save the position of the body.
; Evaluate the body.
; Restore the original position of the point.
(define-syntax (with-saved-point stx)
(syntax-parse stx
[(_with-saved-point body ...)
Expand Down

0 comments on commit 0682a40

Please sign in to comment.