mirror of https://github.com/adamdruppe/arsd.git
Merge branch 'adamdruppe:master' into accurateCursorPos
This commit is contained in:
commit
2b35882926
15
cgi.d
15
cgi.d
|
@ -3513,7 +3513,11 @@ string toHexUpper(long num) {
|
|||
|
||||
// the generic mixins
|
||||
|
||||
/// Use this instead of writing your own main
|
||||
/++
|
||||
Use this instead of writing your own main
|
||||
|
||||
It ultimately calls [cgiMainImpl] which creates a [RequestServer] for you.
|
||||
+/
|
||||
mixin template GenericMain(alias fun, long maxContentLength = defaultMaxContentLength) {
|
||||
mixin CustomCgiMain!(Cgi, fun, maxContentLength);
|
||||
}
|
||||
|
@ -5478,7 +5482,8 @@ class ListeningConnectionManager {
|
|||
fd_set read_fds;
|
||||
FD_ZERO(&read_fds);
|
||||
FD_SET(listener.handle, &read_fds);
|
||||
FD_SET(cancelfd, &read_fds);
|
||||
if(cancelfd != -1)
|
||||
FD_SET(cancelfd, &read_fds);
|
||||
auto max = listener.handle > cancelfd ? listener.handle : cancelfd;
|
||||
auto ret = select(max + 1, &read_fds, null, null, null);
|
||||
if(ret == -1) {
|
||||
|
@ -5489,7 +5494,7 @@ class ListeningConnectionManager {
|
|||
throw new Exception("wtf select");
|
||||
}
|
||||
|
||||
if(FD_ISSET(cancelfd, &read_fds)) {
|
||||
if(cancelfd != -1 && FD_ISSET(cancelfd, &read_fds)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -9480,8 +9485,10 @@ css";
|
|||
Element htmlContainer() {
|
||||
auto document = new Document(q"html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html class="no-script">
|
||||
<head>
|
||||
<script>document.documentElement.classList.remove("no-script");</script>
|
||||
<style>.no-script requires-script { display: none; }</style>
|
||||
<title>D Application</title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
</head>
|
||||
|
|
3
dub.json
3
dub.json
|
@ -474,7 +474,8 @@
|
|||
"description": "Postgresql client library. Wraps the libpq C library with my database.d interface.",
|
||||
"targetType": "library",
|
||||
"dependencies": {"arsd-official:database_base":"*"},
|
||||
"libs": ["pq"],
|
||||
"libs-posix": ["pq"],
|
||||
"libs-windows": ["libpq"],
|
||||
"sourceFiles": ["postgres.d"],
|
||||
"importPaths": ["."],
|
||||
"dflags-dmd": ["-mv=arsd.postgres=$PACKAGE_DIR/postgres.d"],
|
||||
|
|
83
minigui.d
83
minigui.d
|
@ -11754,6 +11754,19 @@ class TextDisplayHelper : Widget {
|
|||
return ctx;
|
||||
}
|
||||
|
||||
override void defaultEventHandler_blur(Event ev) {
|
||||
super.defaultEventHandler_blur(ev);
|
||||
if(l.wasMutated()) {
|
||||
auto evt = new ChangeEvent!string(this, &this.content);
|
||||
evt.dispatch();
|
||||
l.clearWasMutatedFlag();
|
||||
}
|
||||
}
|
||||
|
||||
private string content() {
|
||||
return l.getTextString();
|
||||
}
|
||||
|
||||
void undo() {
|
||||
if(undoStack.length) {
|
||||
auto state = undoStack[$-1];
|
||||
|
@ -12347,9 +12360,9 @@ abstract class EditableTextWidget : EditableTextWidgetParent {
|
|||
else
|
||||
return null;
|
||||
} else version(custom_widgets) {
|
||||
version(use_new_text_system)
|
||||
version(use_new_text_system) {
|
||||
return textLayout.getTextString();
|
||||
else
|
||||
} else
|
||||
return textLayout.getPlainText();
|
||||
} else static assert(false);
|
||||
}
|
||||
|
@ -12505,10 +12518,7 @@ abstract class EditableTextWidget : EditableTextWidgetParent {
|
|||
}
|
||||
else static assert(false);
|
||||
|
||||
|
||||
version(trash_text) {
|
||||
|
||||
|
||||
version(trash_text)
|
||||
version(custom_widgets)
|
||||
override void defaultEventHandler_mousedown(MouseDownEvent ev) {
|
||||
super.defaultEventHandler_mousedown(ev);
|
||||
|
@ -12532,12 +12542,14 @@ abstract class EditableTextWidget : EditableTextWidgetParent {
|
|||
}
|
||||
}
|
||||
|
||||
version(trash_text)
|
||||
version(custom_widgets)
|
||||
override void defaultEventHandler_mouseup(MouseUpEvent ev) {
|
||||
//this.parentWindow.win.releaseInputGrab();
|
||||
super.defaultEventHandler_mouseup(ev);
|
||||
}
|
||||
|
||||
version(trash_text)
|
||||
version(custom_widgets)
|
||||
override void defaultEventHandler_mousemove(MouseMoveEvent ev) {
|
||||
super.defaultEventHandler_mousemove(ev);
|
||||
|
@ -12547,6 +12559,7 @@ abstract class EditableTextWidget : EditableTextWidgetParent {
|
|||
}
|
||||
}
|
||||
|
||||
version(trash_text)
|
||||
version(custom_widgets)
|
||||
override void defaultEventHandler_focus(Event ev) {
|
||||
super.defaultEventHandler_focus(ev);
|
||||
|
@ -12582,28 +12595,46 @@ abstract class EditableTextWidget : EditableTextWidgetParent {
|
|||
});
|
||||
}
|
||||
|
||||
private string lastContentBlur;
|
||||
version(trash_text) {
|
||||
private string lastContentBlur;
|
||||
|
||||
override void defaultEventHandler_blur(Event ev) {
|
||||
super.defaultEventHandler_blur(ev);
|
||||
if(parentWindow.win.closed) return;
|
||||
version(custom_widgets) {
|
||||
auto painter = this.draw();
|
||||
textLayout.eraseCaret(painter);
|
||||
static if(SimpledisplayTimerAvailable)
|
||||
if(caretTimer) {
|
||||
caretTimer.destroy();
|
||||
caretTimer = null;
|
||||
override void defaultEventHandler_blur(Event ev) {
|
||||
super.defaultEventHandler_blur(ev);
|
||||
if(parentWindow.win.closed) return;
|
||||
version(custom_widgets) {
|
||||
auto painter = this.draw();
|
||||
textLayout.eraseCaret(painter);
|
||||
static if(SimpledisplayTimerAvailable)
|
||||
if(caretTimer) {
|
||||
caretTimer.destroy();
|
||||
caretTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content != lastContentBlur) {
|
||||
auto evt = new ChangeEvent!string(this, &this.content);
|
||||
evt.dispatch();
|
||||
lastContentBlur = this.content;
|
||||
if(this.content != lastContentBlur) {
|
||||
auto evt = new ChangeEvent!string(this, &this.content);
|
||||
evt.dispatch();
|
||||
lastContentBlur = this.content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
version(win32_widgets) {
|
||||
private string lastContentBlur;
|
||||
|
||||
override void defaultEventHandler_blur(Event ev) {
|
||||
super.defaultEventHandler_blur(ev);
|
||||
|
||||
if(this.content != lastContentBlur) {
|
||||
auto evt = new ChangeEvent!string(this, &this.content);
|
||||
evt.dispatch();
|
||||
lastContentBlur = this.content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
version(trash_text)
|
||||
version(custom_widgets)
|
||||
override void defaultEventHandler_char(CharEvent ev) {
|
||||
super.defaultEventHandler_char(ev);
|
||||
|
@ -12614,6 +12645,7 @@ abstract class EditableTextWidget : EditableTextWidgetParent {
|
|||
auto cbb = textLayout.contentBoundingBox();
|
||||
setContentSize(cbb.width, cbb.height);
|
||||
}
|
||||
version(trash_text)
|
||||
version(custom_widgets)
|
||||
override void defaultEventHandler_keydown(KeyDownEvent ev) {
|
||||
//super.defaultEventHandler_keydown(ev);
|
||||
|
@ -12669,8 +12701,6 @@ abstract class EditableTextWidget : EditableTextWidgetParent {
|
|||
ensureVisibleInScroll(textLayout.caretBoundingBox());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
version(use_new_text_system) {
|
||||
bool showingVerticalScroll() { return true; }
|
||||
bool showingHorizontalScroll() { return true; }
|
||||
|
@ -14999,6 +15029,11 @@ class AutomaticDialog(T) : Dialog {
|
|||
}
|
||||
});
|
||||
|
||||
this.addEventListener((scope ClosedEvent ce) {
|
||||
if(onCancel)
|
||||
onCancel();
|
||||
});
|
||||
|
||||
//this.children[0].focus();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,11 @@
|
|||
should be found in the PostgreSQL lib and/or bin folders (check them both!).
|
||||
+/
|
||||
module arsd.postgres;
|
||||
pragma(lib, "pq");
|
||||
|
||||
version(Windows)
|
||||
pragma(lib, "libpq");
|
||||
else
|
||||
pragma(lib, "pq");
|
||||
|
||||
public import arsd.database;
|
||||
|
||||
|
|
|
@ -474,6 +474,7 @@ public struct Selection {
|
|||
FIXME: what if i want to replace it with some multiply styled text? Could probably call it in sequence actually.
|
||||
+/
|
||||
Selection replaceContent(scope const(char)[] newText, TextLayouter.StyleHandle style = TextLayouter.StyleHandle.init) {
|
||||
layouter.wasMutated_ = true;
|
||||
|
||||
if(style == TextLayouter.StyleHandle.init)
|
||||
style = layouter.getInsertionStyleAt(impl.focus);
|
||||
|
@ -1068,6 +1069,19 @@ class TextLayouter {
|
|||
WrappedAround = 2
|
||||
}
|
||||
|
||||
private bool wasMutated_ = false;
|
||||
/++
|
||||
The layouter maintains a flag to tell if the content has been changed.
|
||||
+/
|
||||
public bool wasMutated() {
|
||||
return wasMutated_;
|
||||
}
|
||||
|
||||
/// ditto
|
||||
public void clearWasMutatedFlag() {
|
||||
wasMutated_ = false;
|
||||
}
|
||||
|
||||
/++
|
||||
Represents a possible registered style for a segment of text.
|
||||
+/
|
||||
|
@ -1090,6 +1104,7 @@ class TextLayouter {
|
|||
Appends text at the end, without disturbing user selection.
|
||||
+/
|
||||
public void appendText(scope const(char)[] text, StyleHandle style = StyleHandle.init) {
|
||||
wasMutated_ = true;
|
||||
auto before = this.text;
|
||||
this.text.length += text.length;
|
||||
this.text[before.length-1 .. before.length-1 + text.length] = text[];
|
||||
|
@ -1117,7 +1132,7 @@ class TextLayouter {
|
|||
FIXME: have some kind of index stuff so you can select some text found in here (think regex search)
|
||||
+/
|
||||
void getText(scope void delegate(scope const(char)[] segment, TextStyle style) handler) {
|
||||
handler(text, null);
|
||||
handler(text[0 .. $-1], null); // cut off the null terminator
|
||||
}
|
||||
|
||||
/++
|
||||
|
|
Loading…
Reference in New Issue