Rev 9190 | Rev 9194 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9190 | Rev 9193 | ||
---|---|---|---|
Line 125... | Line 125... | ||
125 | text.lang := Lang.langIni |
125 | text.lang := Lang.langIni |
126 | ELSIF ext = "JSON" THEN |
126 | ELSIF ext = "JSON" THEN |
127 | text.lang := Lang.langJSON |
127 | text.lang := Lang.langJSON |
128 | ELSE |
128 | ELSE |
129 | text.lang := Lang.langText |
129 | text.lang := Lang.langText |
130 | END |
130 | END; |
- | 131 | Lang.setCurLang(text.lang) |
|
131 | END setName; |
132 | END setName; |
Line 132... | Line 133... | ||
132 | 133 | ||
133 | 134 | ||
134 | PROCEDURE setLang* (text: tText; lang: INTEGER); |
135 | PROCEDURE setLang* (text: tText; lang: INTEGER); |
135 | BEGIN |
136 | BEGIN |
- | 137 | text.lang := lang; |
|
136 | text.lang := lang; |
138 | text.comments := TRUE; |
Line 137... | Line 139... | ||
137 | text.comments := TRUE |
139 | Lang.setCurLang(text.lang) |
138 | END setLang; |
140 | END setLang; |
Line 291... | Line 293... | ||
291 | VAR |
293 | VAR |
292 | lexLen: INTEGER; |
294 | lexLen: INTEGER; |
293 | BEGIN |
295 | BEGIN |
294 | SetColor(color, backColor); |
296 | SetColor(color, backColor); |
295 | lexLen := MAX(MIN(line.length - lexStart, lexEnd - lexStart + 1), 0); |
297 | lexLen := MAX(MIN(line.length - lexStart, lexEnd - lexStart + 1), 0); |
296 | G.TextOut(canvas, padding.left + (lexStart - text.scroll.X) * charWidth, y, Lines.getPChar(line, lexStart), lexLen) |
298 | G.TextOut(canvas, padding.left + (lexStart - text.scroll.X) * charWidth, y, Lines.getPChar(line, lexStart), lexLen, color) |
297 | END PrintLex; |
299 | END PrintLex; |
Line 298... | Line 300... | ||
298 | 300 | ||
299 | 301 | ||
300 | PROCEDURE PrintComment (text: tText; line: tLine; VAR depth, i: INTEGER; y: INTEGER; backColor: INTEGER); |
302 | PROCEDURE PrintComment (text: tText; line: tLine; VAR depth, i: INTEGER; w, y: INTEGER; backColor: INTEGER); |
301 | VAR |
303 | VAR |
302 | lexStart: INTEGER; |
304 | lexStart: INTEGER; |
303 | color: INTEGER; |
305 | color: INTEGER; |
Line 309... | Line 311... | ||
309 | ELSIF (text.lang = Lang.langPascal) & (depth = 3) THEN |
311 | ELSIF (text.lang = Lang.langPascal) & (depth = 3) THEN |
310 | color := colors.key3 |
312 | color := colors.key3 |
311 | ELSE |
313 | ELSE |
312 | color := colors.comment |
314 | color := colors.comment |
313 | END; |
315 | END; |
314 | lexStart := MAX(i - 2, 0); |
316 | lexStart := MAX(i - w, 0); |
315 | ProcessComments(line, depth, i, 0, line.length - 1, text.lang); |
317 | ProcessComments(line, depth, i, 0, line.length - 1, text.lang); |
316 | PrintLex(text, line, lexStart, i, y, color, backColor) |
318 | PrintLex(text, line, lexStart, i, y, color, backColor) |
317 | END PrintComment; |
319 | END PrintComment; |
Line 332... | Line 334... | ||
332 | PROCEDURE FL (c: WCHAR): BOOLEAN; |
334 | PROCEDURE FL (c: WCHAR): BOOLEAN; |
333 | RETURN (cap(c) = "F") OR (cap(c) = "L") |
335 | RETURN (cap(c) = "F") OR (cap(c) = "L") |
334 | END FL; |
336 | END FL; |
Line 335... | Line -... | ||
335 | - | ||
336 | - | ||
337 | PROCEDURE isFASMdelim (c: WCHAR): BOOLEAN; |
- | |
338 | VAR |
- | |
339 | s: ARRAY 19 OF WCHAR; |
- | |
340 | i: INTEGER; |
- | |
341 | BEGIN |
- | |
342 | s := "{}[]<>:,()&*/|+-\#"; |
- | |
343 | i := LEN(s) - 2; |
- | |
344 | WHILE (i >= 0) & (c # s[i]) DO |
- | |
345 | DEC(i) |
- | |
346 | END |
- | |
347 | RETURN i >= 0 |
- | |
348 | END isFASMdelim; |
- | |
349 | 337 | ||
350 | 338 | ||
351 | PROCEDURE ident (text: tText; VAR i: INTEGER; first, y: INTEGER; line: tLine; backColor: INTEGER; cs: BOOLEAN); |
339 | PROCEDURE ident (text: tText; VAR i: INTEGER; first, y: INTEGER; line: tLine; backColor: INTEGER; cs: BOOLEAN); |
352 | VAR |
340 | VAR |
353 | c: WCHAR; |
341 | c: WCHAR; |
Line 393... | Line 381... | ||
393 | BEGIN |
381 | BEGIN |
394 | depth := line.cin; |
382 | depth := line.cin; |
395 | n := line.length - 1; |
383 | n := line.length - 1; |
396 | i := 0; |
384 | i := 0; |
397 | IF (depth > 0) & (n >= 0) THEN |
385 | IF (depth > 0) & (n >= 0) THEN |
398 | PrintComment(text, line, depth, i, y, backColor) |
386 | PrintComment(text, line, depth, i, 2, y, backColor) |
399 | END; |
387 | END; |
400 | cond := 0; |
388 | cond := 0; |
401 | WHILE i <= n DO |
389 | WHILE i <= n DO |
402 | c := getChar(line, i); |
390 | c := getChar(line, i); |
Line 408... | Line 396... | ||
408 | i := n |
396 | i := n |
409 | ELSIF (c = "'") OR (c = '"') THEN |
397 | ELSIF (c = "'") OR (c = '"') THEN |
410 | String(text, line, i, y, backColor) |
398 | String(text, line, i, y, backColor) |
411 | ELSIF (U.isLetter(c) OR (c = "_")) THEN |
399 | ELSIF (U.isLetter(c) OR (c = "_")) THEN |
412 | ident(text, i, i, y, line, backColor, Lang.isCS(lang)) |
400 | ident(text, i, i, y, line, backColor, Lang.isCS(lang)) |
413 | ELSIF isFASMdelim(c) THEN |
- | |
414 | PrintLex(text, line, i, i, y, colors.delim, backColor) |
- | |
415 | ELSIF U.isDigit(c) THEN |
401 | ELSIF U.isDigit(c) THEN |
416 | hex := FALSE; |
402 | hex := FALSE; |
417 | k := i; |
403 | k := i; |
418 | INC(i); |
404 | INC(i); |
419 | c := getChar(line, i); |
405 | c := getChar(line, i); |
Line 446... | Line 432... | ||
446 | i := n |
432 | i := n |
447 | END |
433 | END |
448 | ELSIF (c = "*") & (cond = 1) THEN |
434 | ELSIF (c = "*") & (cond = 1) THEN |
449 | depth := 1; |
435 | depth := 1; |
450 | INC(i); |
436 | INC(i); |
451 | PrintComment(text, line, depth, i, y, backColor); |
437 | PrintComment(text, line, depth, i, 2, y, backColor); |
452 | cond := 0 |
438 | cond := 0 |
453 | ELSIF U.isLetter(c) OR (c = "_") OR (c = "'") OR (c = '"') THEN |
439 | ELSIF U.isLetter(c) OR (c = "_") OR (c = "'") OR (c = '"') THEN |
454 | k := i; |
440 | k := i; |
455 | IF (c = "'") OR (c = '"') THEN |
441 | IF (c = "'") OR (c = '"') THEN |
456 | String(text, line, i, y, backColor); |
442 | String(text, line, i, y, backColor); |
Line 589... | Line 575... | ||
589 | cond := 1 |
575 | cond := 1 |
590 | ELSIF c = "*" THEN |
576 | ELSIF c = "*" THEN |
591 | IF cond = 1 THEN |
577 | IF cond = 1 THEN |
592 | INC(depth); |
578 | INC(depth); |
593 | INC(i); |
579 | INC(i); |
594 | PrintComment(text, line, depth, i, y, backColor); |
580 | PrintComment(text, line, depth, i, 2, y, backColor); |
595 | cond := 0 |
581 | cond := 0 |
596 | ELSE |
582 | ELSE |
597 | cond := 2 |
583 | cond := 2 |
598 | END |
584 | END |
599 | ELSIF c = ")" THEN |
585 | ELSIF c = ")" THEN |
Line 613... | Line 599... | ||
613 | IF c = "-" THEN |
599 | IF c = "-" THEN |
614 | IF cond = 1 THEN |
600 | IF cond = 1 THEN |
615 | IF Lang.LuaLong(line, i + 1) >= 0 THEN |
601 | IF Lang.LuaLong(line, i + 1) >= 0 THEN |
616 | depth := Lang.LuaLong(line, i + 1)*2 + 1; |
602 | depth := Lang.LuaLong(line, i + 1)*2 + 1; |
617 | INC(i); |
603 | INC(i); |
618 | PrintComment(text, line, depth, i, y, backColor) |
604 | PrintComment(text, line, depth, i, 2, y, backColor) |
619 | ELSE |
605 | ELSE |
620 | PrintLex(text, line, i - 1, n, y, colors.comment, backColor); |
606 | PrintLex(text, line, i - 1, n, y, colors.comment, backColor); |
621 | i := n |
607 | i := n |
622 | END; |
608 | END; |
623 | cond := 0 |
609 | cond := 0 |
Line 628... | Line 614... | ||
628 | cond := 0; |
614 | cond := 0; |
629 | k := Lang.LuaLong(line, i); |
615 | k := Lang.LuaLong(line, i); |
630 | IF k >= 0 THEN |
616 | IF k >= 0 THEN |
631 | depth := (k + 1)*2; |
617 | depth := (k + 1)*2; |
632 | INC(i, 2); |
618 | INC(i, 2); |
633 | PrintComment(text, line, depth, i, y, backColor); |
619 | PrintComment(text, line, depth, i, 2, y, backColor); |
634 | cond := 0 |
620 | cond := 0 |
635 | END |
621 | END |
636 | ELSIF (c = "'") OR (c = '"') THEN |
622 | ELSIF (c = "'") OR (c = '"') THEN |
637 | String(text, line, i, y, backColor); |
623 | String(text, line, i, y, backColor); |
638 | cond := 0 |
624 | cond := 0 |
Line 696... | Line 682... | ||
696 | IF c = "(" THEN |
682 | IF c = "(" THEN |
697 | cond := 1 |
683 | cond := 1 |
698 | ELSIF (c = "*") & (cond = 1) THEN |
684 | ELSIF (c = "*") & (cond = 1) THEN |
699 | depth := 2; |
685 | depth := 2; |
700 | INC(i); |
686 | INC(i); |
701 | PrintComment(text, line, depth, i, y, backColor); |
687 | PrintComment(text, line, depth, i, 2, y, backColor); |
702 | cond := 0 |
688 | cond := 0 |
703 | ELSIF c = "/" THEN |
689 | ELSIF c = "/" THEN |
704 | IF cond = 2 THEN |
690 | IF cond = 2 THEN |
705 | PrintLex(text, line, i - 1, n, y, colors.comment, backColor); |
691 | PrintLex(text, line, i - 1, n, y, colors.comment, backColor); |
706 | cond := 0; |
692 | cond := 0; |
Line 715... | Line 701... | ||
715 | IF getChar(line, i + 1) = "$" THEN |
701 | IF getChar(line, i + 1) = "$" THEN |
716 | depth := 3 |
702 | depth := 3 |
717 | ELSE |
703 | ELSE |
718 | depth := 1 |
704 | depth := 1 |
719 | END; |
705 | END; |
720 | INC(i, 2); |
706 | INC(i); |
721 | PrintComment(text, line, depth, i, y, backColor); |
707 | PrintComment(text, line, depth, i, 1, y, backColor); |
722 | cond := 0 |
708 | cond := 0 |
723 | ELSIF c = "#" THEN |
709 | ELSIF c = "#" THEN |
724 | k := i; |
710 | k := i; |
725 | INC(i); |
711 | INC(i); |
726 | WHILE U.isDigit(getChar(line, i)) DO |
712 | WHILE U.isDigit(getChar(line, i)) DO |
Line 796... | Line 782... | ||
796 | IF (c = ";") OR (c = "#") THEN |
782 | IF (c = ";") OR (c = "#") THEN |
797 | PrintLex(text, line, i, n, y, colors.comment, backColor); |
783 | PrintLex(text, line, i, n, y, colors.comment, backColor); |
798 | i := n |
784 | i := n |
799 | ELSIF c = '"' THEN |
785 | ELSIF c = '"' THEN |
800 | String(text, line, i, y, backColor) |
786 | String(text, line, i, y, backColor) |
801 | ELSIF c = "=" THEN |
- | |
802 | PrintLex(text, line, i, i, y, colors.delim, backColor) |
- | |
803 | ELSIF c = "[" THEN |
787 | ELSIF c = "[" THEN |
804 | depth := 1; |
788 | depth := 1; |
805 | INC(i, 2); |
789 | INC(i); |
806 | PrintComment(text, line, depth, i, y, backColor) |
790 | PrintComment(text, line, depth, i, 1, y, backColor) |
807 | ELSIF U.isDigit(c) THEN |
791 | ELSIF U.isDigit(c) THEN |
808 | k := i; |
792 | k := i; |
809 | WHILE U.isDigit(getChar(line, i)) DO |
793 | WHILE U.isDigit(getChar(line, i)) DO |
810 | INC(i) |
794 | INC(i) |
811 | END; |
795 | END; |
Line 2012... | Line 1996... | ||
2012 | SetColor(colors.seltext, colors.selback); |
1996 | SetColor(colors.seltext, colors.selback); |
2013 | pos := MAX((selBeg - text.scroll.X), 0); |
1997 | pos := MAX((selBeg - text.scroll.X), 0); |
2014 | x := pos*charWidth + padding.left; |
1998 | x := pos*charWidth + padding.left; |
2015 | G.SetColor(canvas, colors.selback); |
1999 | G.SetColor(canvas, colors.selback); |
2016 | G.FillRect(canvas, x - 2, y - inter DIV 2, x + 1 + Len*charWidth, y - inter DIV 2 + charHeight); |
2000 | G.FillRect(canvas, x - 2, y - inter DIV 2, x + 1 + Len*charWidth, y - inter DIV 2 + charHeight); |
2017 | G.TextOut(canvas, pos*charWidth + padding.left, y, Lines.getPChar(line, firstCharIdx), Len) |
2001 | G.TextOut(canvas, pos*charWidth + padding.left, y, Lines.getPChar(line, firstCharIdx), Len, colors.seltext) |
2018 | END drawSelect; |
2002 | END drawSelect; |
Line 2019... | Line 2003... | ||
2019 | 2003 | ||
2020 | 2004 | ||
Line 2099... | Line 2083... | ||
2099 | G.FillRect(canvas, padding.left - 2, y - inter DIV 2, size.X - 1, y - inter DIV 2 + charHeight); |
2083 | G.FillRect(canvas, padding.left - 2, y - inter DIV 2, size.X - 1, y - inter DIV 2 + charHeight); |
2100 | backColor := colors.curline |
2084 | backColor := colors.curline |
2101 | END; |
2085 | END; |
2102 | SetColor(colors.text, backColor); |
2086 | SetColor(colors.text, backColor); |
2103 | Len := MAX(line.length - text.scroll.X, 0); |
2087 | Len := MAX(line.length - text.scroll.X, 0); |
2104 | G.TextOut(canvas, padding.left, y, Lines.getPChar(line, text.scroll.X), MIN(Len, textsize.X + 1)); |
2088 | G.TextOut(canvas, padding.left, y, Lines.getPChar(line, text.scroll.X), MIN(Len, textsize.X + 1), colors.delim); |
2105 | IF text.lang # Lang.langText THEN |
2089 | IF text.lang # Lang.langText THEN |
2106 | parse(text, line, y, backColor, text.lang) |
2090 | parse(text, line, y, backColor, text.lang) |
2107 | END; |
2091 | END; |
2108 | mark(line, y - inter DIV 2); |
2092 | mark(line, y - inter DIV 2); |
2109 | IF (selBeg.Y < n) & (n < selEnd.Y) THEN |
2093 | IF (selBeg.Y < n) & (n < selEnd.Y) THEN |
Line 2240... | Line 2224... | ||
2240 | text.edition := NIL; |
2224 | text.edition := NIL; |
2241 | text.foundList := List.create(NIL); |
2225 | text.foundList := List.create(NIL); |
2242 | text.searchText := ""; |
2226 | text.searchText := ""; |
2243 | text.foundSel := 0; |
2227 | text.foundSel := 0; |
2244 | text.CurX := -1; |
2228 | text.CurX := -1; |
- | 2229 | text.lang := Lang.langText; |
|
- | 2230 | Lang.setCurLang(Lang.langText); |
|
2245 | setName(text, fileName); |
2231 | setName(text, fileName); |
2246 | ASSERT(text = List.create(text)) |
2232 | ASSERT(text = List.create(text)) |
2247 | RETURN text |
2233 | RETURN text |
2248 | END create; |
2234 | END create; |