mirror of https://github.com/buggins/dlangui.git
example1: SourceEdit instead of EditBox
This commit is contained in:
parent
0632f3eec4
commit
a75d50c6c6
|
@ -581,28 +581,33 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
editLine.popupMenu = editPopupItem;
|
editLine.popupMenu = editPopupItem;
|
||||||
|
|
||||||
// EditBox sample
|
// EditBox sample
|
||||||
editors.addChild(new TextWidget(null, "EditBox: Multiline editor"d));
|
editors.addChild(new TextWidget(null, "SourceEdit: multiline editor, for source code editing"d));
|
||||||
|
|
||||||
EditBox editBox = new EditBox("editbox1", "Some text\nSecond line\nYet another line\n\n\tforeach(s;lines);\n\t\twriteln(s);\n"d);
|
SourceEdit editBox = new SourceEdit("editbox1");
|
||||||
editBox.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
editBox.text = q{#!/usr/bin/env rdmd
|
||||||
dstring text = editBox.text;
|
// Computes average line length for standard input.
|
||||||
for (int i = 0; i < 100; i++) {
|
import std.stdio;
|
||||||
text ~= "\n Line ";
|
|
||||||
text ~= to!dstring(i + 5);
|
void main()
|
||||||
text ~= " Some long long line. Blah blah blah.";
|
{
|
||||||
for (int j = 0; j <= i % 4; j++)
|
ulong lines = 0;
|
||||||
text ~= " The quick brown fox jumps over the lazy dog.";
|
double sumLength = 0;
|
||||||
}
|
foreach (line; stdin.byLine())
|
||||||
editBox.text = text;
|
{
|
||||||
editBox.minFontSize(12).maxFontSize(75); // allow font zoom with Ctrl + MouseWheel
|
++lines;
|
||||||
|
sumLength += line.length;
|
||||||
|
}
|
||||||
|
writeln("Average line length: ",
|
||||||
|
lines ? sumLength / lines : 0);
|
||||||
|
}
|
||||||
|
}d;
|
||||||
editors.addChild(createEditorSettingsControl(editBox));
|
editors.addChild(createEditorSettingsControl(editBox));
|
||||||
editors.addChild(editBox);
|
editors.addChild(editBox);
|
||||||
editBox.popupMenu = editPopupItem;
|
editBox.popupMenu = editPopupItem;
|
||||||
|
|
||||||
editors.addChild(new TextWidget(null, "EditBox: additional view for the same content (split view testing)"d));
|
editors.addChild(new TextWidget(null, "EditBox: additional view for the same content (split view testing)"d));
|
||||||
EditBox editBox2 = new EditBox("editbox2", ""d);
|
SourceEdit editBox2 = new SourceEdit("editbox2");
|
||||||
editBox2.content = editBox.content; // view the same content as first editbox
|
editBox2.content = editBox.content; // view the same content as first editbox
|
||||||
editBox2.minFontSize(12).maxFontSize(75); // allow font zoom with Ctrl + MouseWheel
|
|
||||||
editors.addChild(editBox2);
|
editors.addChild(editBox2);
|
||||||
editors.layoutHeight(FILL_PARENT).layoutWidth(FILL_PARENT);
|
editors.layoutHeight(FILL_PARENT).layoutWidth(FILL_PARENT);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue