mirror of https://github.com/adamdruppe/arsd.git
better TextDisplay = better MessageBox on linux
This commit is contained in:
parent
84c1e8162d
commit
fcc840df4e
47
minigui.d
47
minigui.d
|
@ -7624,8 +7624,8 @@ class ScrollMessageWidget : Widget {
|
||||||
auto _this = this;
|
auto _this = this;
|
||||||
container.addEventListener((scope ClickEvent ce) {
|
container.addEventListener((scope ClickEvent ce) {
|
||||||
|
|
||||||
if(ce.target && ce.target.tabStop)
|
//if(ce.target && ce.target.tabStop)
|
||||||
ce.target.focus();
|
//ce.target.focus();
|
||||||
|
|
||||||
// ctrl is reserved for the application
|
// ctrl is reserved for the application
|
||||||
if(ce.ctrlKey)
|
if(ce.ctrlKey)
|
||||||
|
@ -8232,8 +8232,10 @@ class Window : Widget {
|
||||||
|
|
||||||
version(custom_widgets)
|
version(custom_widgets)
|
||||||
override void defaultEventHandler_click(ClickEvent event) {
|
override void defaultEventHandler_click(ClickEvent event) {
|
||||||
if(event.target && event.target.tabStop)
|
if(event.button != MouseButton.wheelDown && event.button != MouseButton.wheelUp) {
|
||||||
event.target.focus();
|
if(event.target && event.target.tabStop)
|
||||||
|
event.target.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void delegate(Window) newWindowCreated;
|
private static void delegate(Window) newWindowCreated;
|
||||||
|
@ -12072,13 +12074,18 @@ class TextDisplayHelper : Widget {
|
||||||
override Menu contextMenu(int x, int y) {
|
override Menu contextMenu(int x, int y) {
|
||||||
if(ctx is null) {
|
if(ctx is null) {
|
||||||
ctx = new Menu("Actions", this);
|
ctx = new Menu("Actions", this);
|
||||||
ctx.addItem(new MenuItem(new Action("&Undo", GenericIcons.Undo, &undo)));
|
if(!readonly) {
|
||||||
ctx.addItem(new MenuItem(new Action("&Redo", GenericIcons.Redo, &redo)));
|
ctx.addItem(new MenuItem(new Action("&Undo", GenericIcons.Undo, &undo)));
|
||||||
ctx.addSeparator();
|
ctx.addItem(new MenuItem(new Action("&Redo", GenericIcons.Redo, &redo)));
|
||||||
ctx.addItem(new MenuItem(new Action("Cu&t", GenericIcons.Cut, &cut)));
|
ctx.addSeparator();
|
||||||
|
}
|
||||||
|
if(!readonly)
|
||||||
|
ctx.addItem(new MenuItem(new Action("Cu&t", GenericIcons.Cut, &cut)));
|
||||||
ctx.addItem(new MenuItem(new Action("&Copy", GenericIcons.Copy, ©)));
|
ctx.addItem(new MenuItem(new Action("&Copy", GenericIcons.Copy, ©)));
|
||||||
ctx.addItem(new MenuItem(new Action("&Paste", GenericIcons.Paste, &paste)));
|
if(!readonly)
|
||||||
ctx.addItem(new MenuItem(new Action("&Delete", 0, &deleteContentOfSelection)));
|
ctx.addItem(new MenuItem(new Action("&Paste", GenericIcons.Paste, &paste)));
|
||||||
|
if(!readonly)
|
||||||
|
ctx.addItem(new MenuItem(new Action("&Delete", 0, &deleteContentOfSelection)));
|
||||||
ctx.addSeparator();
|
ctx.addSeparator();
|
||||||
ctx.addItem(new MenuItem(new Action("Select &All", 0, &selectAll)));
|
ctx.addItem(new MenuItem(new Action("Select &All", 0, &selectAll)));
|
||||||
}
|
}
|
||||||
|
@ -12099,6 +12106,7 @@ class TextDisplayHelper : Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void undo() {
|
void undo() {
|
||||||
|
if(readonly) return;
|
||||||
if(undoStack.length) {
|
if(undoStack.length) {
|
||||||
auto state = undoStack[$-1];
|
auto state = undoStack[$-1];
|
||||||
undoStack = undoStack[0 .. $-1];
|
undoStack = undoStack[0 .. $-1];
|
||||||
|
@ -12113,6 +12121,7 @@ class TextDisplayHelper : Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void redo() {
|
void redo() {
|
||||||
|
if(readonly) return;
|
||||||
if(redoStack.length) {
|
if(redoStack.length) {
|
||||||
doStateCheckpoint();
|
doStateCheckpoint();
|
||||||
auto state = redoStack[$-1];
|
auto state = redoStack[$-1];
|
||||||
|
@ -12127,6 +12136,7 @@ class TextDisplayHelper : Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void cut() {
|
void cut() {
|
||||||
|
if(readonly) return;
|
||||||
with(l.selection()) {
|
with(l.selection()) {
|
||||||
if(!isEmpty()) {
|
if(!isEmpty()) {
|
||||||
setClipboardText(parentWindow.win, getContentString());
|
setClipboardText(parentWindow.win, getContentString());
|
||||||
|
@ -12150,6 +12160,7 @@ class TextDisplayHelper : Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void paste() {
|
void paste() {
|
||||||
|
if(readonly) return;
|
||||||
getClipboardText(parentWindow.win, (txt) {
|
getClipboardText(parentWindow.win, (txt) {
|
||||||
doStateCheckpoint();
|
doStateCheckpoint();
|
||||||
l.selection.replaceContent(txt);
|
l.selection.replaceContent(txt);
|
||||||
|
@ -12160,6 +12171,7 @@ class TextDisplayHelper : Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteContentOfSelection() {
|
void deleteContentOfSelection() {
|
||||||
|
if(readonly) return;
|
||||||
doStateCheckpoint();
|
doStateCheckpoint();
|
||||||
l.selection.replaceContent("");
|
l.selection.replaceContent("");
|
||||||
l.selection.setUserXCoordinate();
|
l.selection.setUserXCoordinate();
|
||||||
|
@ -13255,6 +13267,21 @@ class TextDisplay : EditableTextWidget {
|
||||||
this.readonly = true;
|
this.readonly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override void registerMovement() {
|
||||||
|
super.registerMovement();
|
||||||
|
|
||||||
|
// FIXME: do the horizontal one too as needed and make sure that it does
|
||||||
|
// wordwrapping again
|
||||||
|
if(l.height + smw.horizontalScrollBar.height > this.height)
|
||||||
|
smw.verticalScrollBar.show();
|
||||||
|
else
|
||||||
|
smw.verticalScrollBar.hide();
|
||||||
|
|
||||||
|
l.wordWrapWidth = this.width;
|
||||||
|
|
||||||
|
smw.verticalScrollBar.setPosition = 0;
|
||||||
|
}
|
||||||
|
|
||||||
class Style : Widget.Style {
|
class Style : Widget.Style {
|
||||||
// just want the generic look for these
|
// just want the generic look for these
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue