1 | import xhtml from '../xhtml';
|
2 |
|
3 |
|
4 |
|
5 | export function updateView() {
|
6 |
|
7 | let template = "";
|
8 |
|
9 | this.__formatData.forEach((line, index) => {
|
10 |
|
11 | let bgcolor = "";
|
12 | if (index == this.__lineNum) {
|
13 | bgcolor = "background-color:" + this._colorEdit;
|
14 | }
|
15 |
|
16 | template += "<div style='min-width: fit-content;white-space: nowrap;line-height:21px;height:21px;" + bgcolor + "'>";
|
17 |
|
18 | template += "<em style='color:" + this._colorNumber + ";user-select: none;display:inline-block;font-style:normal;width:35px;text-align:right;margin-right:5px;'>" + (index + 1) + "</em>";
|
19 |
|
20 | line.forEach(text => {
|
21 |
|
22 | let contentText = text.content;
|
23 |
|
24 |
|
25 | contentText = contentText.replace(/\&/g, "&");
|
26 | contentText = contentText.replace(/</g, "<"); contentText = contentText.replace(/>/g, ">");
|
27 |
|
28 | template += "<span style='font-weight:" + this._fontWeight + ";white-space: pre;color:" + text.color + "'>" + contentText + "</span>";
|
29 |
|
30 | });
|
31 |
|
32 | template += "</div>";
|
33 |
|
34 | });
|
35 |
|
36 | this.__showDOM.innerHTML = template;
|
37 |
|
38 | };
|
39 |
|
40 |
|
41 |
|
42 | export function updateCursorPosition(text) {
|
43 |
|
44 | xhtml.css(this.__focusDOM, {
|
45 | top: (this.__lineNum * 21 + 10) + "px",
|
46 | left: (40 + this.$$textWidth(this._contentArray[this.__lineNum].substring(0, this.__leftNum))) + "px",
|
47 | });
|
48 |
|
49 | };
|
50 |
|