@@ -21,24 +21,26 @@ static void draw_scrollbar(RVMatrix *rvm) {
2121 int h = rvm -> h - 2 ;
2222 int total_h = rvm -> rows * rvm -> box_h ;
2323 int sbpos = rvm -> scroll_y * rvm -> h / total_h ;
24+ if (sbpos < 1 ) {
25+ sbpos = 1 ;
26+ }
27+ if (sbpos >= h - 1 ) {
28+ sbpos = h - 2 ;
29+ }
2430 for (i = 1 ; i < h ; i ++ ) {
25- const char * box = (i == sbpos ) ?"|#|" : "|.|" ;
31+ const char * box = (i == sbpos ) ? "|#|" : "|.|" ;
2632 r_cons_canvas_write_at (can , box , w , i );
2733 }
2834 r_cons_canvas_write_at (can , "[^]" , w , 0 );
29- r_cons_canvas_write_at (can , Color_INVERT "[v]" Color_RESET , w , h - 1 );
30- #if 0
31- r_strf_var (xxx , 128 , "(%d)" , sbpos );
32- r_cons_canvas_write_at (can , xxx , 5 , 5 );
33- #endif
35+ r_cons_canvas_write_at (can , Color_INVERT "[v]" Color_RESET , w , h - 1 );
3436}
3537
3638static void vmatrix_refresh (RVMatrix * rvm ) {
3739 RCons * cons = rvm -> core -> cons ;
38- int h , w = r_cons_get_size (cons , & h );
40+ int h , w = r_cons_get_size (cons , & h );
3941 rvm -> h = h ;
4042 rvm -> w = w ;
41- RConsCanvas * can = r_cons_canvas_new (cons , w , h - 1 , -2 );
43+ RConsCanvas * can = r_cons_canvas_new (cons , w , h - 1 , -2 );
4244 rvm -> can = can ;
4345 RListIter * iter ;
4446 w -= 6 ;
@@ -66,7 +68,7 @@ static void vmatrix_refresh(RVMatrix *rvm) {
6668
6769 char * s = r_cons_canvas_tostring (can );
6870 r_cons_clear00 (cons );
69- r_cons_printf (cons , "[0x%08" PFMT64x "\n%s" , rvm -> core -> addr , s );
71+ r_cons_printf (cons , "[0x%08" PFMT64x "\n%s" , rvm -> core -> addr , s );
7072 r_cons_visual_flush (cons );
7173 free (s );
7274 r_cons_canvas_free (can );
@@ -110,10 +112,10 @@ R_API void r_core_visual_matrix(RCore *core) {
110112 // filter
111113 break ;
112114 case 'j' :
113- rvm .scroll_y ++ ;
115+ rvm .scroll_y ++ ;
114116 break ;
115117 case 'k' :
116- rvm .scroll_y -- ;
118+ rvm .scroll_y -- ;
117119 if (rvm .scroll_y < 0 ) {
118120 rvm .scroll_y = 0 ;
119121 }
@@ -131,7 +133,7 @@ R_API void r_core_visual_matrix(RCore *core) {
131133 rvm .scroll_y = 0 ;
132134 break ;
133135 case 'G' :
134- rvm .scroll_y = rvm .rows * rvm .box_h - 1 ;
136+ rvm .scroll_y = rvm .rows * rvm .box_h - 1 ;
135137 break ;
136138 case 'l' :
137139 case 'h' :
0 commit comments