Editor: only redraw visible lines

darcs
slava 2006-09-16 02:43:00 +00:00
parent eb09b5ffd0
commit f699a781d5
2 changed files with 27 additions and 11 deletions

View File

@ -27,7 +27,6 @@
- add-gadget, model-changed, set-model should compile - add-gadget, model-changed, set-model should compile
- graphical module manager tool - graphical module manager tool
- editor: - editor:
- only redraw visible lines
- more efficient multi-line inserts - more efficient multi-line inserts
- write "foo| " and put caret at | then select word element: selects - write "foo| " and put caret at | then select word element: selects
space space
@ -44,6 +43,7 @@
+ ui: + ui:
- if i do 10000 [ . ] each and then clear, the listener window is slow
- dataflow UI needs various improvements: - dataflow UI needs various improvements:
full-height nodes should really be full height full-height nodes should really be full height
- draw-world: bail out if world is 0x0 - draw-world: bail out if world is 0x0

View File

@ -134,22 +134,41 @@ M: loc-monitor model-changed
caret-rect rect-extent gl-line caret-rect rect-extent gl-line
] when ; ] when ;
: translate-lines ( n editor -- ) : translate-lines ( n -- )
line-height * 0.0 swap 0.0 glTranslated ; editor get line-height * 0.0 swap 0.0 glTranslated ;
: draw-line ( editor str -- ) : draw-line ( editor str -- )
over editor-color gl-color over editor-color gl-color
>r editor-font r> draw-string ; >r editor-font r> draw-string ;
: first-visible-line ( editor -- n )
clip get rect-loc second origin get second -
swap y>line ;
: last-visible-line ( editor -- n )
clip get rect-extent nip second origin get second -
swap y>line 1+ ;
: with-editor ( editor quot -- ) : with-editor ( editor quot -- )
[ [
swap dup control-model document set editor set call swap
dup first-visible-line \ first-visible-line set
dup last-visible-line \ last-visible-line set
dup control-model document set
editor set
call
] with-scope ; inline ] with-scope ; inline
: visible-lines ( editor -- seq )
\ first-visible-line get
\ last-visible-line get
rot editor-lines <slice> ;
: draw-lines ( -- ) : draw-lines ( -- )
GL_MODELVIEW [ GL_MODELVIEW [
editor get dup editor-lines \ first-visible-line get translate-lines
[ over >r draw-line 1 r> translate-lines ] each-with editor get dup visible-lines
[ draw-line 1 translate-lines ] each-with
] do-matrix ; ] do-matrix ;
: selection-start/end ( editor -- start end ) : selection-start/end ( editor -- start end )
@ -166,18 +185,15 @@ M: loc-monitor model-changed
editor get offset>x editor get offset>x
(draw-selection) ; (draw-selection) ;
: translate>selection-start ( start -- )
first editor get translate-lines ;
: draw-selection ( -- ) : draw-selection ( -- )
GL_MODELVIEW [ GL_MODELVIEW [
editor get editor get
dup editor-selection-color gl-color dup editor-selection-color gl-color
selection-start/end selection-start/end
over translate>selection-start over first translate-lines
2dup [ 2dup [
>r 2dup r> draw-selected-line >r 2dup r> draw-selected-line
1 editor get translate-lines 1 translate-lines
] each-line 2drop ] each-line 2drop
] do-matrix ; ] do-matrix ;