mirror of https://github.com/buggins/dlangui.git
match brackets in editors support
This commit is contained in:
parent
7d7dc6faee
commit
c67eac3432
|
@ -89,7 +89,9 @@ enum TokenCategory : ubyte {
|
||||||
/// invalid identifier token - error occured while parsing identifier
|
/// invalid identifier token - error occured while parsing identifier
|
||||||
Error_InvalidIdentifier = (15 << TOKEN_CATEGORY_SHIFT) | 4,
|
Error_InvalidIdentifier = (15 << TOKEN_CATEGORY_SHIFT) | 4,
|
||||||
/// invalid comment token - error occured while parsing comment
|
/// invalid comment token - error occured while parsing comment
|
||||||
Error_InvalidComment = (15 << TOKEN_CATEGORY_SHIFT) | 4,
|
Error_InvalidComment = (15 << TOKEN_CATEGORY_SHIFT) | 7,
|
||||||
|
/// invalid comment token - error occured while parsing comment
|
||||||
|
Error_InvalidOp = (15 << TOKEN_CATEGORY_SHIFT) | 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// extracts token category, clearing subcategory
|
/// extracts token category, clearing subcategory
|
||||||
|
@ -184,6 +186,10 @@ struct TextPosition {
|
||||||
@property string toString() {
|
@property string toString() {
|
||||||
return to!string(line) ~ ":" ~ to!string(pos);
|
return to!string(line) ~ ":" ~ to!string(pos);
|
||||||
}
|
}
|
||||||
|
/// adds deltaPos to position and returns result
|
||||||
|
TextPosition offset(int deltaPos) {
|
||||||
|
return TextPosition(line, pos + deltaPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// text content range
|
/// text content range
|
||||||
|
|
|
@ -1629,7 +1629,7 @@ class EditBox : EditWidgetBase {
|
||||||
new Action(EditorActions.ZoomOut, KeyCode.SUB, KeyFlag.Control),
|
new Action(EditorActions.ZoomOut, KeyCode.SUB, KeyFlag.Control),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
protected uint _matchingBracketHightlightColor = 0xFFF0E0;
|
protected uint _matchingBracketHightlightColor = 0x60FFE0B0;
|
||||||
|
|
||||||
protected int _firstVisibleLine;
|
protected int _firstVisibleLine;
|
||||||
|
|
||||||
|
@ -2119,8 +2119,7 @@ class EditBox : EditWidgetBase {
|
||||||
rc.right = _clientRect.left + endrc.right;
|
rc.right = _clientRect.left + endrc.right;
|
||||||
if (!rc.empty) {
|
if (!rc.empty) {
|
||||||
// draw selection rect for matching bracket
|
// draw selection rect for matching bracket
|
||||||
Log.d("highlight bracket 1: ", rc);
|
buf.fillRect(rc, color);
|
||||||
buf.fillRect(rc, 0xFFDD80);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2146,13 +2145,11 @@ class EditBox : EditWidgetBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_matchingBraces.start.line == lineIndex) {
|
if (_matchingBraces.start.line == lineIndex) {
|
||||||
TextRange r = TextRange(_matchingBraces.start, _matchingBraces.start);
|
TextRange r = TextRange(_matchingBraces.start, _matchingBraces.start.offset(1));
|
||||||
r.end.pos++;
|
|
||||||
highlightLineRange(buf, lineRect, _matchingBracketHightlightColor, r);
|
highlightLineRange(buf, lineRect, _matchingBracketHightlightColor, r);
|
||||||
}
|
}
|
||||||
if (_matchingBraces.end.line == lineIndex) {
|
if (_matchingBraces.end.line == lineIndex) {
|
||||||
TextRange r = TextRange(_matchingBraces.end, _matchingBraces.end);
|
TextRange r = TextRange(_matchingBraces.end, _matchingBraces.end.offset(1));
|
||||||
r.end.pos++;
|
|
||||||
highlightLineRange(buf, lineRect, _matchingBracketHightlightColor, r);
|
highlightLineRange(buf, lineRect, _matchingBracketHightlightColor, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue