Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions source/dcell/screen.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions source/dcell/termio.d
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interface TtyImpl
void stop();

/**
* Close the ttye device.
* Close the tty device.
*/
void close();

Expand Down Expand Up @@ -250,7 +250,7 @@ version (Posix)

void write(string s)
{
file.rawWrite(s);
file.write(s);
}

bool resized()
Expand Down
30 changes: 19 additions & 11 deletions source/dcell/ttyscreen.d
Original file line number Diff line number Diff line change
Expand Up @@ -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\\";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -316,11 +321,6 @@ class TtyScreen : Screen
sendPasteEnable(b);
}

bool hasMouse() const pure
{
return true;
}

int colors() const pure
{
return vt.numColors;
Expand Down Expand Up @@ -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();
}

Expand Down