about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/kilo.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/kilo.c b/src/kilo.c
index 5b6a9a7..5840dba 100644
--- a/src/kilo.c
+++ b/src/kilo.c
@@ -975,7 +975,7 @@ static void editorMoveCursor(int key) {
         }
         break;
     case KEY_DOWN:
-        if (filerow < E.numrows) {
+        if (filerow < E.numrows-1) {
             if (E.startrow + E.cy == E.endrow-1) {
                 E.rowoff++;
             } else {
@@ -1272,6 +1272,8 @@ void editNonCode(char* filename) {
     }
 }
 
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
+
 void editNonCode2(char* filename) {
     Quit = 0;
     Back_to_big_picture = 0;
@@ -1287,7 +1289,7 @@ void editNonCode2(char* filename) {
         int y, x;
         getyx(stdscr, y, x);
         mvaddstr(0, 0, "function file_operation_permitted(filename, mode)");
-        mvaddstr(E.startrow + E.numrows - E.rowoff, 0, "end");
+        mvaddstr(MIN(E.startrow + E.numrows, E.endrow), 0, "end");
         mvaddstr(y, x, "");
         int c = getch();
         editorProcessKeypress2(c);
@@ -1359,7 +1361,7 @@ void resumeNonCodeEdit2() {
         int y, x;
         getyx(stdscr, y, x);
         mvaddstr(0, 0, "function file_operation_permitted(filename, mode)");
-        mvaddstr(E.startrow + E.numrows - E.rowoff, 0, "end");
+        mvaddstr(MIN(E.startrow + E.numrows, E.endrow), 0, "end");
         mvaddstr(y, x, "");
         int c = getch();
         editorProcessKeypress2(c);
aram <vc@akkartik.com> 2015-05-06 00:19:03 -0700 1279 - colorized rendering of the source files' href='/akkartik/mu/commit/html/073scenario_screen_test.mu.html?h=main&id=672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9'>672e3e50 ^
4a39d12d ^


4c4d325c ^
a654e4ec ^
c762564b ^


fe8bf967 ^
805d58c6 ^

672e3e50 ^

a654e4ec ^



e5c11a51 ^






















a654e4ec ^

672e3e50 ^
e5c11a51 ^
a654e4ec ^
204dae92 ^





805d58c6 ^
b301e0c0 ^
204dae92 ^

805d58c6 ^

204dae92 ^







b301e0c0 ^
204dae92 ^
b301e0c0 ^
204dae92 ^
b301e0c0 ^
204dae92 ^

805d58c6 ^


204dae92 ^

aac2775a ^




805d58c6 ^
b301e0c0 ^


aac2775a ^

805d58c6 ^

aac2775a ^

672e3e50 ^


a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108