Fix error if up/down arrows pressed when table has no rows

db4
Slava Pestov 2009-01-22 01:19:15 -06:00
parent 87a1363c95
commit 7114fd294f
1 changed files with 7 additions and 4 deletions

View File

@ -122,7 +122,7 @@ M: table layout*
line-height /i ; line-height /i ;
: validate-row ( m table -- n ) : validate-row ( m table -- n )
control-value length 1- min 0 max ; control-value [ drop f ] [ length 1- min 0 max ] if-empty ;
: visible-row ( table quot -- n ) : visible-row ( table quot -- n )
'[ '[
@ -228,7 +228,7 @@ M: table model-changed
row-rect [ { 0 1 } v* ] change-dim ; row-rect [ { 0 1 } v* ] change-dim ;
: (select-row) ( table n -- ) : (select-row) ( table n -- )
[ [ thin-row-rect ] [ drop ] 2bi scroll>rect ] [ dup [ [ thin-row-rect ] [ drop ] 2bi scroll>rect ] [ 2drop ] if ]
[ >>selected-index relayout-1 ] [ >>selected-index relayout-1 ]
2bi ; 2bi ;
@ -260,11 +260,14 @@ PRIVATE>
[ show-row-summary ] [ show-row-summary ]
2tri ; 2tri ;
: prev/next-row ( table n -- )
[ dup selected-index>> ] dip '[ _ + ] [ 0 ] if* select-row ;
: prev-row ( table -- ) : prev-row ( table -- )
dup selected-index>> [ 1- ] [ 0 ] if* select-row ; -1 prev/next-row ;
: next-row ( table -- ) : next-row ( table -- )
dup selected-index>> [ 1+ ] [ 0 ] if* select-row ; 1 prev/next-row ;
: first-row ( table -- ) : first-row ( table -- )
0 select-row ; 0 select-row ;