diff --git a/source/dcell/screen.d b/source/dcell/screen.d index c1239ba..7690921 100644 --- a/source/dcell/screen.d +++ b/source/dcell/screen.d @@ -129,14 +129,6 @@ interface Screen */ void enableFocus(bool b); - /** - * Do we have a mouse? This may be overly optimistic for some - * terminals, but it is a good first guess. - * - * Returns: true if the terminal is thought to support mouse events - */ - bool hasMouse(); - /** * Enable mouse mode. This can cause terminals/emulators * to behave differently -- for example affecting the ability diff --git a/source/dcell/termio.d b/source/dcell/termio.d index 40c3dc4..8f39681 100644 --- a/source/dcell/termio.d +++ b/source/dcell/termio.d @@ -79,7 +79,7 @@ interface TtyImpl void stop(); /** - * Close the ttye device. + * Close the tty device. */ void close(); @@ -250,7 +250,7 @@ version (Posix) void write(string s) { - file.rawWrite(s); + file.write(s); } bool resized() diff --git a/source/dcell/ttyscreen.d b/source/dcell/ttyscreen.d index d1e41c8..c802eca 100644 --- a/source/dcell/ttyscreen.d +++ b/source/dcell/ttyscreen.d @@ -86,6 +86,11 @@ class TtyScreen : Screen enum string setFgBgRGB = "\x1b[38;2;%d;%d;%d;48;2;%d;%d;%dm"; // for RGB, in one shot enum string resetFgBg = "\x1b[39;49m"; // ECMA defined enum string requestDA = "\x1b[c"; // request primary device attributes + enum string disableMouse = "\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l"; + enum string enableButtons = "\x1b[?1000h"; + enum string enableDrag = "\x1b[?1002h"; + enum string enableMotion = "\x1b[?1003h"; + enum string mouseSgr = "\x1b[?1006h"; // SGR reporting (use with other enables) // these can be overridden (e.g. disabled for legacy) string enterURL = "\x1b]8;;%s\x1b\\"; @@ -240,7 +245,7 @@ class TtyScreen : Screen puts(vt.clear); puts(vt.exitKeypad); puts(vt.disablePaste); - enableMouse(MouseEnable.disable); + puts(vt.disableMouse); puts(vt.disableFocus); flush(); stopping.set(true); @@ -316,11 +321,6 @@ class TtyScreen : Screen sendPasteEnable(b); } - bool hasMouse() const pure - { - return true; - } - int colors() const pure { return vt.numColors; @@ -684,17 +684,25 @@ private: // there is no standard terminfo sequence for reporting this // information. // start by disabling everything - puts("\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l"); + puts(vt.disableMouse); // then turn on specific enables if (en & MouseEnable.buttons) - puts("\x1b[?1000h"); + { + puts(vt.enableButtons); + } if (en & MouseEnable.drag) - puts("\x1b[?1002h"); + { + puts(vt.enableDrag); + } if (en & MouseEnable.motion) - puts("\x1b[?1003h"); + { + puts(vt.enableMotion); + } // and if any are set, we need to send this if (en & MouseEnable.all) - puts("\x1b[?1006h"); + { + puts(vt.mouseSgr); + } flush(); }