mirror of https://github.com/buggins/dlangide.git
add output panel; add character literal support in tokenizer; fix styles
This commit is contained in:
parent
140e1a8e11
commit
a788369925
|
@ -202,6 +202,7 @@
|
||||||
<Folder name="ui">
|
<Folder name="ui">
|
||||||
<File path="src\dlangide\ui\commands.d" />
|
<File path="src\dlangide\ui\commands.d" />
|
||||||
<File path="src\dlangide\ui\frame.d" />
|
<File path="src\dlangide\ui\frame.d" />
|
||||||
|
<File path="outputpanel.d" />
|
||||||
<File path="src\dlangide\ui\wspanel.d" />
|
<File path="src\dlangide\ui\wspanel.d" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder name="workspace">
|
<Folder name="workspace">
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
module dlangide.ui.outputpanel;
|
||||||
|
|
||||||
|
import dlangui.all;
|
||||||
|
import dlangide.workspace.workspace;
|
||||||
|
import dlangide.workspace.project;
|
||||||
|
|
||||||
|
class OutputPanel : DockWindow {
|
||||||
|
protected LogWidget _logWidget;
|
||||||
|
|
||||||
|
this(string id) {
|
||||||
|
super(id);
|
||||||
|
_caption.text = "Output"d;
|
||||||
|
dockAlignment = DockAlignment.Bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
override protected Widget createBodyWidget() {
|
||||||
|
_logWidget = new LogWidget("logwidget");
|
||||||
|
_logWidget.readOnly = true;
|
||||||
|
_logWidget.layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||||
|
return _logWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addLogLines(string category, dstring[] msg...) {
|
||||||
|
_logWidget.appendLines(msg);
|
||||||
|
}
|
||||||
|
}
|
|
@ -302,15 +302,14 @@
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<style id="TREE_ITEM"
|
<style id="TREE_ITEM"
|
||||||
padding="2,2,2,2"
|
padding="1,1,1,1"
|
||||||
margins="0,0,0,0"
|
|
||||||
minWidth="100"
|
minWidth="100"
|
||||||
minHeight="16"
|
minHeight="16"
|
||||||
layoutWidth="FILL_PARENT"
|
layoutWidth="FILL_PARENT"
|
||||||
layoutHeight="WRAP_CONTENT"
|
layoutHeight="WRAP_CONTENT"
|
||||||
fontFace="Arial"
|
fontFace="Arial"
|
||||||
fontFamily="SansSerif"
|
fontFamily="SansSerif"
|
||||||
fontSize="16">
|
fontSize="12">
|
||||||
</style>
|
</style>
|
||||||
<style id="TREE_ITEM_EXPAND_ICON"
|
<style id="TREE_ITEM_EXPAND_ICON"
|
||||||
margins="2,0,2,0"
|
margins="2,0,2,0"
|
||||||
|
@ -333,6 +332,7 @@
|
||||||
layoutHeight="WRAP_CONTENT"
|
layoutHeight="WRAP_CONTENT"
|
||||||
align="Left|VCenter"
|
align="Left|VCenter"
|
||||||
textFlags="Parent"
|
textFlags="Parent"
|
||||||
|
fontSize="12"
|
||||||
/>
|
/>
|
||||||
<style id="RESIZER_VERTICAL"
|
<style id="RESIZER_VERTICAL"
|
||||||
layoutWidth="FILL_PARENT"
|
layoutWidth="FILL_PARENT"
|
||||||
|
|
|
@ -1209,6 +1209,29 @@ class StringLiteralToken : Token {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CharacterLiteralToken : Token {
|
||||||
|
dchar _character;
|
||||||
|
dchar _literalType;
|
||||||
|
@property override dchar literalType() { return _literalType; }
|
||||||
|
@property dchar character() { return _character; }
|
||||||
|
@property override dchar[] text() { return [_character]; }
|
||||||
|
void setCharacter(dchar ch, dchar type) { _character = ch; _literalType = type; }
|
||||||
|
this() {
|
||||||
|
super(TokenType.CHARACTER);
|
||||||
|
}
|
||||||
|
this(SourceFile file, uint line, uint pos, dchar character, dchar type) {
|
||||||
|
super(TokenType.CHARACTER, file, line, pos);
|
||||||
|
_character = character;
|
||||||
|
_literalType = type;
|
||||||
|
}
|
||||||
|
override public Token clone() {
|
||||||
|
return new CharacterLiteralToken(_file, _line, _pos, _character, _literalType);
|
||||||
|
}
|
||||||
|
public override @property string toString() {
|
||||||
|
return "Char:" ~ toUTF8([_character]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class IntegerLiteralToken : Token {
|
class IntegerLiteralToken : Token {
|
||||||
ulong _value;
|
ulong _value;
|
||||||
bool _unsigned;
|
bool _unsigned;
|
||||||
|
@ -1361,6 +1384,7 @@ class Tokenizer
|
||||||
protected IntegerLiteralToken _sharedIntegerToken = new IntegerLiteralToken();
|
protected IntegerLiteralToken _sharedIntegerToken = new IntegerLiteralToken();
|
||||||
protected RealLiteralToken _sharedRealToken = new RealLiteralToken();
|
protected RealLiteralToken _sharedRealToken = new RealLiteralToken();
|
||||||
protected InvalidToken _sharedInvalidToken = new InvalidToken();
|
protected InvalidToken _sharedInvalidToken = new InvalidToken();
|
||||||
|
protected CharacterLiteralToken _sharedCharacterLiteralToken = new CharacterLiteralToken();
|
||||||
protected StringAppender _stringLiteralAppender;
|
protected StringAppender _stringLiteralAppender;
|
||||||
protected StringAppender _commentAppender;
|
protected StringAppender _commentAppender;
|
||||||
protected StringAppender _identAppender;
|
protected StringAppender _identAppender;
|
||||||
|
@ -1401,6 +1425,7 @@ class Tokenizer
|
||||||
_sharedIntegerToken.setFile(file);
|
_sharedIntegerToken.setFile(file);
|
||||||
_sharedRealToken.setFile(file);
|
_sharedRealToken.setFile(file);
|
||||||
_sharedInvalidToken.setFile(file);
|
_sharedInvalidToken.setFile(file);
|
||||||
|
_sharedCharacterLiteralToken.setFile(file);
|
||||||
buildTime = Clock.currTime();
|
buildTime = Clock.currTime();
|
||||||
_line = lineStream.line;
|
_line = lineStream.line;
|
||||||
_pos = 0;
|
_pos = 0;
|
||||||
|
@ -2328,6 +2353,53 @@ class Tokenizer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Token processCharacterLiteral() {
|
||||||
|
_sharedCharacterLiteralToken.setPos(_line, _pos - 1);
|
||||||
|
if (_pos + 2 > _len)
|
||||||
|
return parserError("Invalid character literal", _sharedCharacterLiteralToken);
|
||||||
|
dchar ch = _lineText[_pos++];
|
||||||
|
dchar ch2 = _lineText[_pos++];
|
||||||
|
dchar type = 0;
|
||||||
|
if (ch == '\\') {
|
||||||
|
// process escaped character - store it in ch
|
||||||
|
// TODO: support all escape sequences
|
||||||
|
switch(ch2) {
|
||||||
|
case 'r':
|
||||||
|
ch = '\r';
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
ch = '\n';
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
ch = '\t';
|
||||||
|
break;
|
||||||
|
case '\\':
|
||||||
|
ch = '\\';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ch = ch2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// here must be closing '
|
||||||
|
if (_pos + 1 > _len)
|
||||||
|
return parserError("Invalid character literal", _sharedCharacterLiteralToken);
|
||||||
|
ch2 = _lineText[_pos++];
|
||||||
|
}
|
||||||
|
if (ch2 != '\'')
|
||||||
|
return parserError("Invalid character literal", _sharedCharacterLiteralToken);
|
||||||
|
if (_pos < _len) {
|
||||||
|
dchar t = _lineText[_pos];
|
||||||
|
if (t == 'd' || t == 'w' || t == 'c') {
|
||||||
|
type = t;
|
||||||
|
_pos++;
|
||||||
|
} else if (isIdentMiddleChar(ch)) {
|
||||||
|
return parserError("Unexpected character after character literal", _sharedCharacterLiteralToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_sharedCharacterLiteralToken.setCharacter(ch, type);
|
||||||
|
return _sharedCharacterLiteralToken;
|
||||||
|
}
|
||||||
|
|
||||||
protected Token processDoubleQuotedOrWysiwygString(dchar delimiter) {
|
protected Token processDoubleQuotedOrWysiwygString(dchar delimiter) {
|
||||||
bool wysiwyg = (delimiter == 'r' || delimiter == '`');
|
bool wysiwyg = (delimiter == 'r' || delimiter == '`');
|
||||||
//writeln("processDoubleQuotedString()");
|
//writeln("processDoubleQuotedString()");
|
||||||
|
@ -2455,6 +2527,8 @@ class Tokenizer
|
||||||
return processOneLineSharpComment();
|
return processOneLineSharpComment();
|
||||||
if (ch == '\"')
|
if (ch == '\"')
|
||||||
return processDoubleQuotedOrWysiwygString(ch);
|
return processDoubleQuotedOrWysiwygString(ch);
|
||||||
|
if (ch == '\'')
|
||||||
|
return processCharacterLiteral();
|
||||||
if (ch == 'x' && next == '\"')
|
if (ch == 'x' && next == '\"')
|
||||||
return processHexString();
|
return processHexString();
|
||||||
if (ch == 'q' && next == '\"')
|
if (ch == 'q' && next == '\"')
|
||||||
|
|
|
@ -14,6 +14,7 @@ import dlangui.dialogs.filedlg;
|
||||||
|
|
||||||
import dlangide.ui.commands;
|
import dlangide.ui.commands;
|
||||||
import dlangide.ui.wspanel;
|
import dlangide.ui.wspanel;
|
||||||
|
import dlangide.ui.outputpanel;
|
||||||
import dlangide.workspace.workspace;
|
import dlangide.workspace.workspace;
|
||||||
import dlangide.workspace.project;
|
import dlangide.workspace.project;
|
||||||
|
|
||||||
|
@ -144,6 +145,7 @@ class DSourceEdit : SourceEdit {
|
||||||
setTokenHightlightColor(TokenCategory.Comment, 0x008000); // green
|
setTokenHightlightColor(TokenCategory.Comment, 0x008000); // green
|
||||||
setTokenHightlightColor(TokenCategory.Keyword, 0x0000FF); // blue
|
setTokenHightlightColor(TokenCategory.Keyword, 0x0000FF); // blue
|
||||||
setTokenHightlightColor(TokenCategory.String, 0xA31515); // brown
|
setTokenHightlightColor(TokenCategory.String, 0xA31515); // brown
|
||||||
|
setTokenHightlightColor(TokenCategory.Character, 0xA31515); // brown
|
||||||
setTokenHightlightColor(TokenCategory.Error, 0xFF0000); // red
|
setTokenHightlightColor(TokenCategory.Error, 0xFF0000); // red
|
||||||
setTokenHightlightColor(TokenCategory.Comment_Documentation, 0x206000);
|
setTokenHightlightColor(TokenCategory.Comment_Documentation, 0x206000);
|
||||||
//setTokenHightlightColor(TokenCategory.Identifier, 0x206000); // no colors
|
//setTokenHightlightColor(TokenCategory.Identifier, 0x206000); // no colors
|
||||||
|
@ -186,6 +188,7 @@ class IDEFrame : AppFrame {
|
||||||
|
|
||||||
MenuItem mainMenuItems;
|
MenuItem mainMenuItems;
|
||||||
WorkspacePanel _wsPanel;
|
WorkspacePanel _wsPanel;
|
||||||
|
OutputPanel _logPanel;
|
||||||
DockHost _dockHost;
|
DockHost _dockHost;
|
||||||
TabWidget _tabs;
|
TabWidget _tabs;
|
||||||
|
|
||||||
|
@ -270,6 +273,13 @@ class IDEFrame : AppFrame {
|
||||||
_wsPanel.sourceFileSelectionListener = &onSourceFileSelected;
|
_wsPanel.sourceFileSelectionListener = &onSourceFileSelected;
|
||||||
_dockHost.addDockedWindow(_wsPanel);
|
_dockHost.addDockedWindow(_wsPanel);
|
||||||
|
|
||||||
|
_logPanel = new OutputPanel("output");
|
||||||
|
_logPanel.addLogLines(null, "Line 1"d);
|
||||||
|
_logPanel.addLogLines(null, "Line 2"d);
|
||||||
|
_logPanel.addLogLines(null, "Line 3"d, "Line 4"d);
|
||||||
|
|
||||||
|
_dockHost.addDockedWindow(_logPanel);
|
||||||
|
|
||||||
return _dockHost;
|
return _dockHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ class WorkspacePanel : DockWindow {
|
||||||
_tree = new TreeWidget("wstree");
|
_tree = new TreeWidget("wstree");
|
||||||
_tree.layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT);
|
_tree.layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||||
_tree.selectionListener = &onTreeItemSelected;
|
_tree.selectionListener = &onTreeItemSelected;
|
||||||
|
_tree.fontSize = 12;
|
||||||
return _tree;
|
return _tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue