Subversion Repositories Kolibri OS

Rev

Rev 9073 | Rev 9175 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9073 Rev 9174
Line 31... Line 31...
31
    Lang := Languages;
31
    Lang := Languages;
Line 32... Line 32...
32
 
32
 
Line 33... Line 33...
33
 
33
 
34
CONST
34
CONST
-
 
35
 
35
 
36
    SPACE = Lines.SPACE;
Line 36... Line 37...
36
    SPACE = 20X;
37
    TAB = Lines.TAB;
37
    TAB = RW.TAB_SIZE;
38
    TAB1 = Lines.TAB1;
38
    lenEOL = CB.lenEOL;
39
    lenEOL = CB.lenEOL;
Line 94... Line 95...
94
    colors*: RECORD
95
    colors*: RECORD
95
                text, back, seltext, selback, modified, saved, curline, numtext, numback: INTEGER;
96
                text, back, seltext, selback, modified, saved, curline, numtext, numback: INTEGER;
96
                comment, string, num, delim, key1, key2, key3: INTEGER
97
                comment, string, num, delim, key1, key2, key3: INTEGER
97
             END;
98
             END;
98
    canvas: G.tCanvas;
99
    canvas: G.tCanvas;
99
    drawCursor*: BOOLEAN;
100
    drawCursor: BOOLEAN;
100
    padding: RECORD left, top: INTEGER END;
101
    padding: RECORD left, top: INTEGER END;
101
    size, textsize: tPoint;
102
    size, textsize: tPoint;
102
    charWidth, charHeight: INTEGER;
103
    charWidth, charHeight: INTEGER;
Line 119... Line 120...
119
        text.lang := Lang.langFasm
120
        text.lang := Lang.langFasm
120
    ELSIF ext = "LUA" THEN
121
    ELSIF ext = "LUA" THEN
121
        text.lang := Lang.langLua
122
        text.lang := Lang.langLua
122
    ELSIF ext = "INI" THEN
123
    ELSIF ext = "INI" THEN
123
        text.lang := Lang.langIni
124
        text.lang := Lang.langIni
-
 
125
    ELSIF ext = "JSON" THEN
-
 
126
        text.lang := Lang.langJSON
124
    ELSE
127
    ELSE
125
        text.lang := Lang.langNone
128
        text.lang := Lang.langNone
126
    END
129
    END
127
END setName;
130
END setName;
Line 174... Line 177...
174
BEGIN
177
BEGIN
175
    drawCursor := ~drawCursor
178
    drawCursor := ~drawCursor
176
END toggleCursor;
179
END toggleCursor;
Line -... Line 180...
-
 
180
 
-
 
181
 
-
 
182
PROCEDURE showCursor*;
-
 
183
BEGIN
-
 
184
	drawCursor := TRUE
-
 
185
END showCursor;
-
 
186
 
-
 
187
 
-
 
188
PROCEDURE hideCursor*;
-
 
189
BEGIN
-
 
190
	drawCursor := FALSE
-
 
191
END hideCursor;
177
 
192
 
178
 
193
 
179
PROCEDURE getChar (line: tLine; i: INTEGER): WCHAR;
194
PROCEDURE getChar (line: tLine; i: INTEGER): WCHAR;
180
VAR
195
VAR
181
    res: WCHAR;
196
    res: WCHAR;
Line 416... Line 431...
416
 
431
 
417
                DEC(i);
432
                DEC(i);
418
                PrintLex(text, line, k, i, y, colors.num, backColor)
433
                PrintLex(text, line, k, i, y, colors.num, backColor)
Line 419... Line 434...
419
            END
434
            END
Line 420... Line 435...
420
 
435
 
421
        ELSIF lang = Lang.langC THEN
436
        ELSIF (lang = Lang.langC) OR (lang = Lang.langJSON) THEN
422
 
437
 
423
        IF depth = 0 THEN
438
        IF depth = 0 THEN
Line 432... Line 447...
432
            ELSIF (c = "*") & (cond = 1) THEN
447
            ELSIF (c = "*") & (cond = 1) THEN
433
                depth := 1;
448
                depth := 1;
434
                INC(i);
449
                INC(i);
435
                PrintComment(text, line, depth, i, y, backColor);
450
                PrintComment(text, line, depth, i, y, backColor);
436
                cond := 0
451
                cond := 0
-
 
452
            ELSIF U.isLetter(c) OR (c = "_") OR (c = "'") OR (c = '"') THEN
-
 
453
            	k := i;
437
            ELSIF (c = "'") OR (c = '"') THEN
454
            	IF (c = "'") OR (c = '"') THEN
438
                String(text, line, i, y, backColor);
455
            		String(text, line, i, y, backColor);
-
 
456
            	ELSE
-
 
457
            		ident(text, i, i - ORD((lang = Lang.langC) & (i > 0) & (getChar(line, i - 1) = "#")), y, line, backColor, Lang.isCS(lang))
-
 
458
            	END;
-
 
459
                IF lang = Lang.langJSON THEN
-
 
460
	                WHILE Lines.isSpace(getChar(line, i + 1)) DO
-
 
461
	                	INC(i)
439
                cond := 0
462
	                END;
440
            ELSIF (U.isLetter(c) OR (c = "_")) THEN
463
	                IF getChar(line, i + 1) = ":" THEN
441
                ident(text, i, i - ORD((i > 0) & (getChar(line, i - 1) = "#")), y, line, backColor, Lang.isCS(lang));
464
	                	PrintLex(text, line, k, i, y, colors.key1, backColor)
-
 
465
	                END
-
 
466
                END;
442
                cond := 0
467
                cond := 0
443
            ELSIF U.isDigit(c) THEN
468
            ELSIF U.isDigit(c) THEN
444
                k := i;
469
                k := i;
445
                INC(i);
470
                INC(i);
446
                c := getChar(line, i);
471
                c := getChar(line, i);
Line 803... Line 828...
803
PROCEDURE leadingSpaces (line: tLine): INTEGER;
828
PROCEDURE leadingSpaces (line: tLine): INTEGER;
804
VAR
829
VAR
805
    i: INTEGER;
830
    i: INTEGER;
806
BEGIN
831
BEGIN
807
    i := 0;
832
    i := 0;
808
    WHILE getChar(line, i) = SPACE DO
833
    WHILE Lines.isSpace(getChar(line, i)) DO
809
        INC(i)
834
        INC(i)
810
    END
835
    END
811
    RETURN i
836
    RETURN i
812
END leadingSpaces;
837
END leadingSpaces;
Line 924... Line 949...
924
END getLine;
949
END getLine;
Line 925... Line 950...
925
 
950
 
926
 
951
 
927
PROCEDURE SetPos* (text: tText; x, y: INTEGER);
952
PROCEDURE SetPos* (text: tText; x, y: INTEGER);
928
VAR
953
VAR
-
 
954
    deltaY, n, L, R: INTEGER;
929
    deltaY: INTEGER;
955
    cursor: pPoint;
930
    cursor: pPoint;
956
    c: WCHAR;
931
   (* trimLength: INTEGER; *)
957
   (* trimLength: INTEGER; *)
932
BEGIN
958
BEGIN
933
    cursor := text.cursor;
959
    cursor := text.cursor;
Line 947... Line 973...
947
        ELSE
973
        ELSE
948
            text.curLine := getLine(text, y)
974
            text.curLine := getLine(text, y)
949
        END
975
        END
950
    END;
976
    END;
951
    cursor.X := MIN(MAX(x, 0), text.curLine.length);
977
    cursor.X := MIN(MAX(x, 0), text.curLine.length);
-
 
978
    c := getChar(text.curLine, cursor.X);
-
 
979
    IF c = TAB1 THEN
-
 
980
        n := cursor.X;
-
 
981
        WHILE getChar(text.curLine, n) = TAB1 DO
-
 
982
            INC(n)
-
 
983
        END;
-
 
984
        R := n - cursor.X;
-
 
985
        n := cursor.X;
-
 
986
        WHILE getChar(text.curLine, n) # TAB DO
-
 
987
            DEC(n)
-
 
988
        END;
-
 
989
        L := cursor.X - n;
-
 
990
        IF L < R THEN
-
 
991
            DEC(cursor.X, L)
-
 
992
        ELSE
-
 
993
            INC(cursor.X, R)
-
 
994
        END
-
 
995
    END;
952
    IF text.scroll.Y > cursor.Y THEN
996
    IF text.scroll.Y > cursor.Y THEN
953
        text.scroll.Y := cursor.Y
997
        text.scroll.Y := cursor.Y
954
    ELSIF text.scroll.Y + textsize.Y <= cursor.Y THEN
998
    ELSIF text.scroll.Y + textsize.Y <= cursor.Y THEN
955
        text.scroll.Y := cursor.Y - textsize.Y + 1
999
        text.scroll.Y := cursor.Y - textsize.Y + 1
956
    END;
1000
    END;
Line 963... Line 1007...
963
        text.select.X := text.curLine.length
1007
        text.select.X := text.curLine.length
964
    END;
1008
    END;
965
    setSelect(text);
1009
    setSelect(text);
966
    text.foundSel := 0;
1010
    text.foundSel := 0;
967
    ShowCursor;
1011
    ShowCursor;
968
    drawCursor := TRUE;
-
 
969
    text.CurX := -1
1012
    text.CurX := -1
970
END SetPos;
1013
END SetPos;
Line 971... Line 1014...
971
 
1014
 
Line 1020... Line 1063...
1020
END delSelect;
1063
END delSelect;
Line 1021... Line 1064...
1021
 
1064
 
1022
 
1065
 
1023
PROCEDURE delete (text: tText);
1066
PROCEDURE delete (text: tText);
1024
VAR
1067
VAR
1025
    i: INTEGER;
1068
    i, n: INTEGER;
1026
    nextLine, curLine: tLine;
1069
    nextLine, curLine: tLine;
1027
BEGIN
1070
BEGIN
1028
    IF selected(text) THEN
1071
    IF selected(text) THEN
1029
        delSelect(text)
1072
        delSelect(text)
1030
    ELSE
1073
    ELSE
1031
        i := text.cursor.X;
1074
        i := text.cursor.X;
-
 
1075
        curLine := text.curLine;
-
 
1076
        IF i < curLine.length THEN
-
 
1077
            n := i;
-
 
1078
            INC(i);
-
 
1079
            IF getChar(curLine, i - 1) = TAB THEN
-
 
1080
                WHILE getChar(curLine, i) = TAB1 DO
-
 
1081
                    INC(i)
1032
        curLine := text.curLine;
1082
                END
1033
        IF i < curLine.length THEN
1083
            END;
1034
            Lines.delChar(curLine, i);
1084
            Lines.delCharN(curLine, n, i - n);
1035
            Lines.modify(curLine);
1085
            Lines.modify(curLine);
1036
            modify(text)
1086
            modify(text)
1037
        ELSE
1087
        ELSE
1038
            nextLine := curLine.next(tLine);
-
 
1039
            IF nextLine # NIL THEN
-
 
1040
                Lines.modify(curLine);
1088
            nextLine := curLine.next(tLine);
1041
                modify(text);
1089
            IF nextLine # NIL THEN
-
 
1090
                Lines.insert2(curLine, i, nextLine);
-
 
1091
                DelLine(text, nextLine);
1042
                Lines.insert2(curLine, i, nextLine);
1092
                Lines.modify(curLine);
1043
                DelLine(text, nextLine)
1093
                modify(text)
1044
            END
1094
            END
1045
        END
1095
        END
1046
    END;
1096
    END;
Line -... Line 1097...
-
 
1097
    setSelect(text)
-
 
1098
END delete;
-
 
1099
 
-
 
1100
 
-
 
1101
PROCEDURE move (text: tText; d: INTEGER);
-
 
1102
VAR
-
 
1103
    pos: INTEGER;
-
 
1104
BEGIN
-
 
1105
    pos := text.cursor.X + d;
-
 
1106
    WHILE getChar(text.curLine, pos) = TAB1 DO
-
 
1107
        INC(pos, d)
-
 
1108
    END;
1047
    setSelect(text)
1109
    SetPos(text, pos, text.cursor.Y)
1048
END delete;
1110
END move;
1049
 
1111
 
1050
 
1112
 
1051
PROCEDURE BkSpace (text: tText);
1113
PROCEDURE BkSpace (text: tText);
1052
VAR
1114
VAR
1053
    i, n, k: INTEGER;
1115
    i, k, n: INTEGER;
1054
    curLine, line: tLine;
1116
    curLine, line, line2: tLine;
1055
BEGIN
1117
BEGIN
1056
    IF selected(text) THEN
-
 
1057
        delSelect(text)
1118
    IF selected(text) THEN
1058
    ELSE
1119
        delSelect(text)
1059
        resetSelect(text);
1120
    ELSE
1060
        i := text.cursor.X;
1121
        resetSelect(text);
1061
        curLine := text.curLine;
1122
        curLine := text.curLine;
1062
        IF i > 0 THEN
1123
        IF text.cursor.X > 0 THEN
1063
            modify(text);
1124
            i := text.cursor.X;
1064
            n := leadingSpaces(curLine);
1125
            n := leadingSpaces(curLine);
1065
            IF n < i THEN
1126
            IF n < i THEN
1066
                Lines.delChar(curLine, i - 1);
1127
                modify(text);
1067
                Lines.modify(curLine);
1128
                move(text, -1);
-
 
1129
                delete(text)
1068
                k := 1
1130
            ELSE
1069
            ELSE
1131
                n := i;
1070
                n := i;
1132
                line := curLine.prev(tLine);
1071
                line := curLine.prev(tLine);
1133
                line2 := line;
-
 
1134
                k := n;
1072
                k := n;
1135
                WHILE (line # NIL) & (k >= n) DO
1073
                WHILE (line # NIL) & (k >= n) DO
1136
                    IF Lines.trimLength(line) # 0 THEN
1074
                    IF Lines.trimLength(line) # 0 THEN
1137
                        k := leadingSpaces(line);
1075
                        k := leadingSpaces(line)
1138
                        line2 := line;
1076
                    END;
1139
                    END;
1077
                    PrevLine(line)
1140
                    PrevLine(line)
1078
                END;
1141
                END;
1079
                IF k >= n THEN
1142
                IF k >= n THEN
1080
                    k := 0
1143
                    k := 0
-
 
1144
                END;
1081
                END;
1145
                n := k;
-
 
1146
                Lines.delCharN(curLine, 0, i);
1082
                DEC(n, k);
1147
                Lines.insert3(curLine, 0, k);
-
 
1148
                WHILE k > 0 DO
1083
                k := n;
1149
                    Lines.setChar(curLine, k - 1, getChar(line2, k - 1));
-
 
1150
                    DEC(k)
1084
                Lines.modify(curLine);
1151
                END;
1085
                Lines.delCharN(curLine, 0, n)
1152
                Lines.modify(curLine);
1086
            END;
1153
                SetPos(text, n, text.cursor.Y)
1087
            SetPos(text, text.cursor.X - k, text.cursor.Y)
1154
            END
1088
        ELSE
1155
        ELSE
Line 1098... Line 1165...
1098
 
1165
 
1099
 
1166
 
1100
PROCEDURE enter (text: tText);
1167
PROCEDURE enter (text: tText);
1101
VAR
1168
VAR
1102
    n: INTEGER;
1169
    n: INTEGER;
1103
    curLine, newLine, line: tLine;
1170
    curLine, newLine, line, line2: tLine;
1104
BEGIN
1171
BEGIN
1105
    delSelect(text);
-
 
1106
    newLine := Lines.create(FALSE);
1172
    delSelect(text);
1107
    Lines.modify(newLine);
1173
    newLine := Lines.create(FALSE);
1108
    modify(text);
1174
    modify(text);
1109
    curLine := text.curLine;
1175
    curLine := text.curLine;
1110
    IF text.cursor.X < curLine.length THEN
1176
    IF text.cursor.X < curLine.length THEN
1111
        Lines.modify(curLine);
1177
        Lines.wrap(curLine, newLine, text.cursor.X);
1112
        Lines.wrap(curLine, newLine, text.cursor.X)
1178
        Lines.modify(curLine)
1113
    END;
1179
    END;
1114
    List._insert(text, curLine, newLine);
1180
    List._insert(text, curLine, newLine);
1115
    SetPos(text, 0, text.cursor.Y + 1);
1181
    SetPos(text, 0, text.cursor.Y + 1);
1116
    line := text.curLine.prev(tLine);
1182
    line := text.curLine.prev(tLine);
1117
    n := -1;
1183
    n := -1;
1118
    WHILE (line # NIL) & (n = -1) DO
1184
    WHILE (line # NIL) & (n = -1) DO
-
 
1185
        IF (*line.length*)Lines.trimLength(line) # 0 THEN
1119
        IF (*line.length*)Lines.trimLength(line) # 0 THEN
1186
            n := leadingSpaces(line);
1120
            n := leadingSpaces(line)
1187
            line2 := line
1121
        END;
1188
        END;
1122
        PrevLine(line)
1189
        PrevLine(line)
1123
    END;
1190
    END;
1124
    IF n = -1 THEN
1191
    IF n = -1 THEN
1125
        n := 0
1192
        n := 0
1126
    END;
1193
    END;
1127
    Lines.insert3(text.curLine, 0, n);
1194
    Lines.insert3(text.curLine, 0, n);
1128
    SetPos(text, n, text.cursor.Y);
1195
    SetPos(text, n, text.cursor.Y);
1129
    resetSelect(text);
1196
    resetSelect(text);
1130
    WHILE n > 0 DO
1197
    WHILE n > 0 DO
1131
        Lines.setChar(text.curLine, n - 1, SPACE);
1198
        Lines.setChar(text.curLine, n - 1, getChar(line2, n - 1));
-
 
1199
        DEC(n)
1132
        DEC(n)
1200
    END;
Line -... Line 1201...
-
 
1201
    Lines.modify(newLine)
-
 
1202
END enter;
-
 
1203
 
-
 
1204
 
-
 
1205
PROCEDURE incIndent (line: tLine);
-
 
1206
VAR
-
 
1207
	c: WCHAR;
-
 
1208
	i: INTEGER;
-
 
1209
BEGIN
-
 
1210
	Lines.modify(line);
-
 
1211
	Lines.insert3(line, 0, Lines.tab);
-
 
1212
	IF Lines.tabs THEN
-
 
1213
		c := TAB1
-
 
1214
	ELSE
-
 
1215
		c := SPACE
-
 
1216
	END;
-
 
1217
	i := Lines.tab - 1;
-
 
1218
	WHILE i >= 0 DO
-
 
1219
		Lines.setChar(line, i, c);
-
 
1220
		DEC(i)
-
 
1221
	END;
-
 
1222
	IF Lines.tabs THEN
-
 
1223
		Lines.setChar(line, 0, TAB)
-
 
1224
	END
-
 
1225
END incIndent;
-
 
1226
 
-
 
1227
 
-
 
1228
PROCEDURE decIndent (line: tLine): BOOLEAN;
-
 
1229
VAR
-
 
1230
	n: INTEGER;
-
 
1231
BEGIN
-
 
1232
	n := leadingSpaces(line);
-
 
1233
	IF n > 0 THEN
-
 
1234
		Lines.delCharN(line, 0, MIN(Lines.tab, n));
-
 
1235
		Lines.modify(line)
-
 
1236
	END
-
 
1237
	RETURN n > 0
-
 
1238
END decIndent;
-
 
1239
 
-
 
1240
 
-
 
1241
PROCEDURE Indent* (text: tText; incr: BOOLEAN);
-
 
1242
VAR
-
 
1243
    i: INTEGER;
-
 
1244
    line: tLine;
-
 
1245
    selBeg, selEnd: tPoint;
-
 
1246
    modified: BOOLEAN;
-
 
1247
BEGIN
-
 
1248
	getSelect(text, selBeg, selEnd);
-
 
1249
	i := selEnd.Y - selBeg.Y + 1;
-
 
1250
	line := getLine(text, selBeg.Y);
-
 
1251
	modified := incr;
-
 
1252
	WHILE i > 0 DO
-
 
1253
		IF incr THEN
-
 
1254
			incIndent(line)
-
 
1255
		ELSE
-
 
1256
    		modified := decIndent(line) OR modified
-
 
1257
		END;
-
 
1258
		NextLine(line);
-
 
1259
		DEC(i)
-
 
1260
	END;
-
 
1261
	line := getLine(text, selEnd.Y);
-
 
1262
	text.select^ := selBeg;
-
 
1263
	text.select.X := 0;
-
 
1264
	SetPos(text, line.length, selEnd.Y);
-
 
1265
	IF modified THEN
-
 
1266
   		modify(text)
1133
    END
1267
	END
1134
END enter;
1268
END Indent;
1135
 
1269
 
Line -... Line 1270...
-
 
1270
 
1136
 
1271
PROCEDURE input* (text: tText; code: INTEGER);
1137
PROCEDURE input* (text: tText; code: INTEGER);
1272
VAR
1138
VAR
1273
    curLine: tLine;
1139
    curLine: tLine;
1274
 
-
 
1275
 
1140
 
1276
    PROCEDURE tab (text: tText);
1141
    PROCEDURE tab (text: tText);
1277
    VAR
1142
    VAR
1278
        i, x: INTEGER;
1143
        i, x: INTEGER;
1279
        curLine: tLine;
1144
        curLine: tLine;
-
 
1145
    BEGIN
-
 
1146
        delSelect(text);
1280
        c: WCHAR;
1147
        curLine := text.curLine;
1281
    BEGIN
1148
        x := text.cursor.X;
1282
		delSelect(text);
-
 
1283
		curLine := text.curLine;
-
 
1284
		x := text.cursor.X;
-
 
1285
		i := Lines.tab - x MOD Lines.tab;
-
 
1286
		Lines.insert3(curLine, x, i);
-
 
1287
		SetPos(text, x + i, text.cursor.Y);
1149
        Lines.modify(curLine);
1288
		IF Lines.tabs THEN
1150
        modify(text);
1289
			c := TAB1
1151
        i := TAB - x MOD TAB;
1290
		ELSE
-
 
1291
			c := SPACE
-
 
1292
		END;
-
 
1293
		WHILE i > 0 DO
1152
        Lines.insert3(curLine, x, i);
1294
			Lines.setChar(curLine, x + i - 1, c);
-
 
1295
			DEC(i)
-
 
1296
		END;
1153
        SetPos(text, x + i, text.cursor.Y);
1297
		IF Lines.tabs THEN
Line -... Line 1298...
-
 
1298
			Lines.setChar(curLine, x + i, TAB)
1154
        WHILE i > 0 DO
1299
		END;
1155
            Lines.setChar(curLine, x + i - 1, SPACE);
1300
		Lines.modify(curLine);
1156
            DEC(i)
1301
		modify(text)
1157
        END
1302
    END tab;
1158
    END tab;
1303
 
1159
 
1304
 
1160
BEGIN
1305
BEGIN
1161
    IF (code >= ORD(SPACE)) & (code # 127) THEN
1306
    IF (code >= ORD(SPACE)) & (code # 127) THEN
1162
        delSelect(text);
1307
        delSelect(text);
1163
        curLine := text.curLine;
1308
        curLine := text.curLine;
-
 
1309
        Lines.insert(curLine, text.cursor.X, WCHR(code));
-
 
1310
        Lines.modify(curLine);
-
 
1311
        modify(text);
-
 
1312
        SetPos(text, text.cursor.X + 1, text.cursor.Y)
1164
        Lines.insert(curLine, text.cursor.X, WCHR(code));
1313
    ELSIF code = 8 THEN
-
 
1314
		BkSpace(text)
-
 
1315
    ELSIF code = -8 THEN
-
 
1316
    	IF selected(text) THEN
1165
        Lines.modify(curLine);
1317
    		Indent(text, FALSE)
-
 
1318
        END
1166
        modify(text);
1319
    ELSIF code = 9 THEN
1167
        SetPos(text, text.cursor.X + 1, text.cursor.Y)
1320
    	IF selected(text) THEN
1168
    ELSIF code = 8 THEN
1321
    		Indent(text, TRUE)
1169
        BkSpace(text)
1322
    	ELSE
Line 1274... Line 1427...
1274
        ChangeLog.redo(item);
1427
        ChangeLog.redo(item);
1275
        item := item.next
1428
        item := item.next
1276
    END;
1429
    END;
1277
    redoGuard(text, guard);
1430
    redoGuard(text, guard);
1278
    ChangeLog.setGuard(guard);
1431
    ChangeLog.setGuard(guard);
1279
    text.modified := ~guard.saved
1432
    text.modified := ~guard.saved;
-
 
1433
    ShowCursor
1280
END undo;
1434
END undo;
Line 1281... Line 1435...
1281
 
1435
 
1282
 
1436
 
Line 1294... Line 1448...
1294
    IF item # NIL THEN
1448
    IF item # NIL THEN
1295
        guard := item(tGuard);
1449
        guard := item(tGuard);
1296
        redoGuard(text, guard)
1450
        redoGuard(text, guard)
1297
    END;
1451
    END;
1298
    ChangeLog.setGuard(guard);
1452
    ChangeLog.setGuard(guard);
1299
    text.modified := ~guard.saved
1453
    text.modified := ~guard.saved;
-
 
1454
    ShowCursor
1300
END redo;
1455
END redo;
Line 1301... Line 1456...
1301
 
1456
 
1302
 
1457
 
Line 1359... Line 1514...
1359
 
1514
 
1360
 
1515
 
1361
PROCEDURE paste (text: tText);
1516
PROCEDURE paste (text: tText);
1362
VAR
1517
VAR
1363
    line, newLine, curLine: tLine;
1518
    line, newLine, curLine: tLine;
1364
    L: INTEGER;
1519
    w: INTEGER;
1365
    cliptext: RW.tInput;
1520
    cliptext: RW.tInput;
-
 
1521
    eol: BOOLEAN;
-
 
1522
    cursor: pPoint;
-
 
1523
 
-
 
1524
 
-
 
1525
    PROCEDURE lineWidth (line: tLine; pos: INTEGER): INTEGER;
-
 
1526
    VAR
-
 
1527
    	i, res: INTEGER;
-
 
1528
    	c: WCHAR;
-
 
1529
    BEGIN
-
 
1530
    	res := pos;
-
 
1531
    	i := 0;
-
 
1532
    	REPEAT
-
 
1533
	    	c := getChar(line, i);
-
 
1534
	    	IF c = TAB THEN
-
 
1535
	    		INC(res, Lines.tab - res MOD Lines.tab)
-
 
1536
	    	ELSIF c # TAB1 THEN
-
 
1537
	    		INC(res)
-
 
1538
	    	END;
-
 
1539
	    	INC(i)
-
 
1540
    	UNTIL c = 0X
-
 
1541
    	RETURN res - pos - 1
-
 
1542
    END lineWidth;
1366
    eol: BOOLEAN;
1543
 
1367
    cursor: pPoint;
1544
 
1368
BEGIN
1545
BEGIN
1369
    line := Lines.create(TRUE);
1546
    line := Lines.create(TRUE);
1370
    cliptext := RW.clipboard();
1547
    cliptext := RW.clipboard();
1371
    delSelect(text);
1548
    delSelect(text);
1372
    cursor := text.cursor;
1549
    cursor := text.cursor;
1373
    WHILE (cliptext # NIL) & (RW.getString(cliptext, line, eol) >= 0) DO
1550
    WHILE (cliptext # NIL) & (RW.getString(cliptext, line, Lines.tabs, eol) >= 0) DO
1374
        L := line.length;
1551
        IF line.length > 0 THEN
1375
        IF L > 0 THEN
1552
        	w := lineWidth(line, cursor.X);
1376
            Lines.insert2(text.curLine, cursor.X, line);
1553
            Lines.insert2(text.curLine, cursor.X, line);
1377
            Lines.modify(text.curLine);
1554
            Lines.modify(text.curLine);
1378
            modify(text);
1555
            modify(text);
1379
            SetPos(text, cursor.X + L, cursor.Y);
1556
            SetPos(text, cursor.X + w, cursor.Y);
1380
            resetSelect(text)
1557
            resetSelect(text)
1381
        END;
1558
        END;
1382
        IF eol THEN
-
 
1383
            newLine := Lines.create(FALSE);
1559
        IF eol THEN
1384
            Lines.modify(newLine);
1560
            newLine := Lines.create(FALSE);
1385
            modify(text);
1561
            modify(text);
1386
            curLine := text.curLine;
1562
            curLine := text.curLine;
1387
            IF cursor.X < curLine.length THEN
1563
            IF cursor.X < curLine.length THEN
1388
                Lines.modify(curLine);
1564
                Lines.wrap(curLine, newLine, cursor.X);
1389
                Lines.wrap(curLine, newLine, cursor.X)
1565
                Lines.modify(curLine)
-
 
1566
            END;
1390
            END;
1567
            List._insert(text, curLine, newLine);
1391
            List._insert(text, curLine, newLine);
1568
            Lines.modify(newLine);
1392
            SetPos(text, 0, cursor.Y + 1);
1569
            SetPos(text, 0, cursor.Y + 1);
1393
            resetSelect(text)
1570
            resetSelect(text)
1394
        END;
1571
        END;
Line 1564... Line 1741...
1564
        delete(text)
1741
        delete(text)
1565
    END
1742
    END
1566
END delLine;
1743
END delLine;
Line 1567... Line 1744...
1567
 
1744
 
1568
 
1745
 
1569
PROCEDURE dupLine (text: tText);
1746
PROCEDURE dupLine* (text: tText);
1570
VAR
1747
VAR
1571
    newLine, curLine: tLine;
1748
    newLine, curLine: tLine;
1572
BEGIN
1749
BEGIN
1573
    curLine := text.curLine;
-
 
1574
    newLine := Lines.create(FALSE);
1750
    curLine := text.curLine;
1575
    Lines.modify(newLine);
1751
    newLine := Lines.create(FALSE);
1576
    modify(text);
1752
    modify(text);
1577
    Lines.insert3(newLine, 0, curLine.length);
1753
    Lines.insert3(newLine, 0, curLine.length);
-
 
1754
    List._insert(text, curLine, newLine);
1578
    List._insert(text, curLine, newLine);
1755
    Lines.move(curLine, newLine);
Line 1579... Line 1756...
1579
    Lines.move(curLine, newLine)
1756
    Lines.modify(newLine)
1580
END dupLine;
1757
END dupLine;
Line 1587... Line 1764...
1587
    modify(text);
1764
    modify(text);
1588
    UpDown(text, 0)
1765
    UpDown(text, 0)
1589
END exchange;
1766
END exchange;
Line 1590... Line 1767...
1590
 
1767
 
1591
 
1768
 
-
 
1769
PROCEDURE upLine* (text: tText);
1592
PROCEDURE upLine (text: tText);
1770
BEGIN
1593
BEGIN
1771
	resetSelect(text);
1594
    IF text.cursor.Y > 0 THEN
1772
    IF text.cursor.Y > 0 THEN
1595
        DEC(text.cursor.Y);
1773
        DEC(text.cursor.Y);
1596
        exchange(text, text.curLine.prev(tLine), text.curLine)
1774
        exchange(text, text.curLine.prev(tLine), text.curLine)
Line 1597... Line 1775...
1597
    END
1775
    END
1598
END upLine;
1776
END upLine;
-
 
1777
 
1599
 
1778
 
1600
 
1779
PROCEDURE downLine* (text: tText);
1601
PROCEDURE downLine (text: tText);
1780
BEGIN
1602
BEGIN
1781
	resetSelect(text);
1603
    IF text.cursor.Y < text.count - 1 THEN
1782
    IF text.cursor.Y < text.count - 1 THEN
Line 1642... Line 1821...
1642
    IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END
1821
    IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END
1643
END wordSel;
1822
END wordSel;
Line 1644... Line 1823...
1644
 
1823
 
-
 
1824
 
-
 
1825
PROCEDURE key* (text: tText; code: INTEGER; shift, ctrl: BOOLEAN);
1645
 
1826
VAR
1646
PROCEDURE key* (text: tText; code: INTEGER; shift, ctrl: BOOLEAN);
1827
	n: INTEGER;
1647
BEGIN
1828
BEGIN
1648
    IF shift THEN
1829
    IF shift THEN
1649
        setSelect(text)
1830
        setSelect(text)
Line 1676... Line 1857...
1676
        END
1857
        END
1677
    |36:
1858
    |36:
1678
        IF ctrl THEN
1859
        IF ctrl THEN
1679
            SetPos(text, 0, 0)
1860
            SetPos(text, 0, 0)
1680
        ELSE
1861
        ELSE
-
 
1862
        	n := leadingSpaces(text.curLine);
-
 
1863
        	IF text.cursor.X > n THEN
-
 
1864
	            SetPos(text, n, text.cursor.Y)
-
 
1865
        	ELSE
1681
            SetPos(text, 0, text.cursor.Y)
1866
        		SetPos(text, 0, text.cursor.Y)
1682
        END
1867
        	END
-
 
1868
        END
1683
    |37:
1869
    |37:
1684
        IF (text.cursor.X = 0) & (text.curLine.prev # NIL) THEN
1870
        IF (text.cursor.X = 0) & (text.curLine.prev # NIL) THEN
1685
            SetPos(text, text.curLine.prev(tLine).length, text.cursor.Y - 1)
1871
            SetPos(text, text.curLine.prev(tLine).length, text.cursor.Y - 1)
1686
        ELSE
1872
        ELSE
1687
            SetPos(text, text.cursor.X - 1, text.cursor.Y)
1873
            move(text, -1)
1688
        END
1874
        END
1689
    |38:
1875
    |38:
1690
        IF ctrl THEN
1876
        IF ctrl THEN
1691
            upLine(text)
1877
            upLine(text)
1692
        ELSE
1878
        ELSE
Line 1694... Line 1880...
1694
        END
1880
        END
1695
    |39:
1881
    |39:
1696
        IF (text.cursor.X = text.curLine.length) & (text.curLine.next # NIL) THEN
1882
        IF (text.cursor.X = text.curLine.length) & (text.curLine.next # NIL) THEN
1697
            SetPos(text, 0, text.cursor.Y + 1)
1883
            SetPos(text, 0, text.cursor.Y + 1)
1698
        ELSE
1884
        ELSE
1699
            SetPos(text, text.cursor.X + 1, text.cursor.Y)
1885
            move(text, 1)
1700
        END
1886
        END
1701
    |40:
1887
    |40:
1702
        IF ctrl THEN
1888
        IF ctrl THEN
1703
            downLine(text)
1889
            downLine(text)
1704
        ELSE
1890
        ELSE
Line 1706... Line 1892...
1706
        END
1892
        END
1707
    |46:
1893
    |46:
1708
        IF ctrl THEN
1894
        IF ctrl THEN
1709
            delLine(text)
1895
            delLine(text)
1710
        ELSE
1896
        ELSE
1711
            delete(text); ShowCursor; drawCursor := TRUE
1897
            delete(text);
-
 
1898
            ShowCursor
1712
        END
1899
        END
1713
    |ORD("C"):
1900
    |ORD("C"):
1714
        IF ctrl THEN
1901
        IF ctrl THEN
1715
            IF selected(text) THEN
1902
            IF selected(text) THEN
1716
                copy(text)
1903
                copy(text)
Line 1736... Line 1923...
1736
            text.select := text.select2;
1923
            text.select := text.select2;
1737
            SetPos(text, text.last(tLine).length, text.count - 1)
1924
            SetPos(text, text.last(tLine).length, text.count - 1)
1738
        END
1925
        END
1739
    |ORD("L"), ORD("U"):
1926
    |ORD("L"), ORD("U"):
1740
        IF ctrl THEN
1927
        IF ctrl THEN
-
 
1928
        	IF selected(text) THEN
-
 
1929
            	chCase(text, code = ORD("U"))
-
 
1930
            ELSE
1741
            changeCase(text, code = ORD("U"))
1931
            	changeCase(text, code = ORD("U"))
-
 
1932
            END;
-
 
1933
            ShowCursor
1742
        END
1934
        END
1743
    |ORD("D"):
1935
    |ORD("D"):
1744
        IF ctrl THEN
1936
        IF ctrl THEN
1745
            dupLine(text)
1937
            dupLine(text)
1746
        END
1938
        END
Line 2122... Line 2314...
2122
    IF file # NIL THEN
2314
    IF file # NIL THEN
2123
        text := create(name);
2315
        text := create(name);
2124
        text.enc := enc;
2316
        text.enc := enc;
2125
        REPEAT
2317
        REPEAT
2126
            line := Lines.create(FALSE);
2318
            line := Lines.create(FALSE);
2127
            n := RW.getString(file, line, eol);
2319
            n := RW.getString(file, line, Lines.tabs, eol);
2128
            IF n >= 0 THEN
2320
            IF n >= 0 THEN
2129
                List._append(text, line)
2321
                List._append(text, line)
2130
            ELSE
2322
            ELSE
2131
                Lines.destroy(line)
2323
                Lines.destroy(line)
2132
            END
2324
            END
Line 2289... Line 2481...
2289
    resetSelect(text)
2481
    resetSelect(text)
2290
    RETURN text
2482
    RETURN text
2291
END New;
2483
END New;
Line 2292... Line -...
2292
 
-
 
2293
 
-
 
2294
PROCEDURE empty;
-
 
2295
END empty;
-
 
2296
 
2484
 
2297
 
2485
 
2298
PROCEDURE init* (pShowCursor: tProcedure);
-
 
2299
BEGIN
-
 
2300
    ShowCursor := empty;
2486
PROCEDURE init* (pShowCursor: tProcedure);
2301
    IF pShowCursor # NIL THEN
-
 
2302
        ShowCursor := pShowCursor
2487
BEGIN
2303
    END;
2488
    ShowCursor := pShowCursor;
2304
    pdelete := delete;
2489
    pdelete := delete;
2305
    drawCursor := TRUE;
2490
    drawCursor := TRUE;
2306
    padding.left := pad_left;
2491
    padding.left := pad_left;