mirror of https://github.com/buggins/dlangide.git
Syntax highlight for DML and JSON in editor
This commit is contained in:
parent
932afca154
commit
06247f3fb2
|
@ -9,6 +9,7 @@ import dlangui.widgets.menu;
|
||||||
import dlangui.widgets.popup;
|
import dlangui.widgets.popup;
|
||||||
import dlangui.widgets.controls;
|
import dlangui.widgets.controls;
|
||||||
import dlangui.widgets.scroll;
|
import dlangui.widgets.scroll;
|
||||||
|
import dlangui.dml.dmlhighlight;
|
||||||
|
|
||||||
import ddc.lexer.textsource;
|
import ddc.lexer.textsource;
|
||||||
import ddc.lexer.exceptions;
|
import ddc.lexer.exceptions;
|
||||||
|
@ -106,7 +107,19 @@ class DSourceEdit : SourceEdit, EditableContentMarksChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@property bool isDSourceFile() {
|
@property bool isDSourceFile() {
|
||||||
return filename.endsWith(".d") || filename.endsWith(".dd") || filename.endsWith(".dh") || filename.endsWith(".ddoc");
|
return filename.endsWith(".d") || filename.endsWith(".dd") || filename.endsWith(".dd") || filename.endsWith(".di") || filename.endsWith(".dh") || filename.endsWith(".ddoc");
|
||||||
|
}
|
||||||
|
|
||||||
|
@property bool isJsonFile() {
|
||||||
|
return filename.endsWith(".json") || filename.endsWith(".JSON");
|
||||||
|
}
|
||||||
|
|
||||||
|
@property bool isDMLFile() {
|
||||||
|
return filename.endsWith(".dml") || filename.endsWith(".DML");
|
||||||
|
}
|
||||||
|
|
||||||
|
@property bool isXMLFile() {
|
||||||
|
return filename.endsWith(".xml") || filename.endsWith(".XML");
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected MenuItem getLeftPaneIconsPopupMenu(int line) {
|
override protected MenuItem getLeftPaneIconsPopupMenu(int line) {
|
||||||
|
@ -151,6 +164,10 @@ class DSourceEdit : SourceEdit, EditableContentMarksChangeListener {
|
||||||
void setSyntaxSupport() {
|
void setSyntaxSupport() {
|
||||||
if (isDSourceFile) {
|
if (isDSourceFile) {
|
||||||
content.syntaxSupport = new SimpleDSyntaxSupport(filename);
|
content.syntaxSupport = new SimpleDSyntaxSupport(filename);
|
||||||
|
} else if (isJsonFile) {
|
||||||
|
content.syntaxSupport = new DMLSyntaxSupport(filename);
|
||||||
|
} else if (isDMLFile) {
|
||||||
|
content.syntaxSupport = new DMLSyntaxSupport(filename);
|
||||||
} else {
|
} else {
|
||||||
content.syntaxSupport = null;
|
content.syntaxSupport = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,14 @@ class WorkspacePanel : DockWindow {
|
||||||
p.objectParam = child;
|
p.objectParam = child;
|
||||||
addProjectItems(p, child);
|
addProjectItems(p, child);
|
||||||
} else {
|
} else {
|
||||||
TreeItem p = root.newChild(child.filename, child.name, "text-d");
|
string icon = "text-other";
|
||||||
|
if (child.isDSourceFile)
|
||||||
|
icon = "text-d";
|
||||||
|
if (child.isJsonFile)
|
||||||
|
icon = "text-json";
|
||||||
|
if (child.isDMLFile)
|
||||||
|
icon = "text-dml";
|
||||||
|
TreeItem p = root.newChild(child.filename, child.name, icon);
|
||||||
p.intParam = ProjectItemType.SourceFile;
|
p.intParam = ProjectItemType.SourceFile;
|
||||||
p.objectParam = child;
|
p.objectParam = child;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,30 @@ class ProjectItem {
|
||||||
return cast(ProjectSourceFile)this;
|
return cast(ProjectSourceFile)this;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property bool isDSourceFile() {
|
||||||
|
if (isFolder)
|
||||||
|
return false;
|
||||||
|
return filename.endsWith(".d") || filename.endsWith(".dd") || filename.endsWith(".dd") || filename.endsWith(".di") || filename.endsWith(".dh") || filename.endsWith(".ddoc");
|
||||||
|
}
|
||||||
|
|
||||||
|
@property bool isJsonFile() {
|
||||||
|
if (isFolder)
|
||||||
|
return false;
|
||||||
|
return filename.endsWith(".json") || filename.endsWith(".JSON");
|
||||||
|
}
|
||||||
|
|
||||||
|
@property bool isDMLFile() {
|
||||||
|
if (isFolder)
|
||||||
|
return false;
|
||||||
|
return filename.endsWith(".dml") || filename.endsWith(".DML");
|
||||||
|
}
|
||||||
|
|
||||||
|
@property bool isXMLFile() {
|
||||||
|
if (isFolder)
|
||||||
|
return false;
|
||||||
|
return filename.endsWith(".xml") || filename.endsWith(".XML");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Project folder
|
/// Project folder
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 991 B |
Binary file not shown.
After Width: | Height: | Size: 896 B |
Binary file not shown.
After Width: | Height: | Size: 807 B |
Binary file not shown.
After Width: | Height: | Size: 637 B |
Binary file not shown.
After Width: | Height: | Size: 642 B |
Binary file not shown.
After Width: | Height: | Size: 598 B |
|
@ -29,6 +29,9 @@ res/hdpi/hdpi_run-build-clean.png
|
||||||
res/hdpi/hdpi_run-build-configure.png
|
res/hdpi/hdpi_run-build-configure.png
|
||||||
res/hdpi/hdpi_run-build.png
|
res/hdpi/hdpi_run-build.png
|
||||||
res/hdpi/hdpi_text-d.png
|
res/hdpi/hdpi_text-d.png
|
||||||
|
res/hdpi/hdpi_text-dml.png
|
||||||
|
res/hdpi/hdpi_text-json.png
|
||||||
|
res/hdpi/hdpi_text-other.png
|
||||||
res/mdpi/cr3_logo.png
|
res/mdpi/cr3_logo.png
|
||||||
res/mdpi/debug-run.png
|
res/mdpi/debug-run.png
|
||||||
res/mdpi/debug-pause.png
|
res/mdpi/debug-pause.png
|
||||||
|
@ -60,4 +63,7 @@ res/mdpi/run-build.png
|
||||||
res/mdpi/run-build-clean.png
|
res/mdpi/run-build-clean.png
|
||||||
res/mdpi/run-build-configure.png
|
res/mdpi/run-build-configure.png
|
||||||
res/mdpi/text-d.png
|
res/mdpi/text-d.png
|
||||||
|
res/mdpi/text-dml.png
|
||||||
|
res/mdpi/text-json.png
|
||||||
|
res/mdpi/text-other.png
|
||||||
res/mdpi/tx_fabric.jpg
|
res/mdpi/tx_fabric.jpg
|
||||||
|
|
Loading…
Reference in New Issue