mirror of https://github.com/adamdruppe/arsd.git
mac update
This commit is contained in:
parent
65d5983303
commit
3d42a6e6f0
73
terminal.d
73
terminal.d
|
@ -741,15 +741,11 @@ struct Terminal {
|
||||||
// work the way they're advertised. I just have to best-guess hack and hope it
|
// work the way they're advertised. I just have to best-guess hack and hope it
|
||||||
// doesn't break anything else. (If you know a better way, let me know!)
|
// doesn't break anything else. (If you know a better way, let me know!)
|
||||||
bool isMacTerminal() {
|
bool isMacTerminal() {
|
||||||
return false;
|
// it gives 1,2 in getTerminalCapabilities and sets term...
|
||||||
/+
|
|
||||||
// it gives 1,2 in getTerminalCapabilities...
|
|
||||||
// FIXME
|
|
||||||
import std.process;
|
import std.process;
|
||||||
import std.string;
|
import std.string;
|
||||||
auto term = environment.get("TERM");
|
auto term = environment.get("TERM");
|
||||||
return term == "xterm-256color";
|
return term == "xterm-256color" && tcaps == TerminalCapabilities.vt100;
|
||||||
+/
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
bool isMacTerminal() { return false; }
|
bool isMacTerminal() { return false; }
|
||||||
|
@ -1040,7 +1036,19 @@ struct Terminal {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint tcaps;
|
private uint _tcaps;
|
||||||
|
private bool tcapsRequested;
|
||||||
|
|
||||||
|
uint tcaps() const {
|
||||||
|
if(!tcapsRequested) {
|
||||||
|
Terminal* mutable = cast(Terminal*) &this;
|
||||||
|
mutable._tcaps = getTerminalCapabilities(fdIn, fdOut);
|
||||||
|
mutable.tcapsRequested = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _tcaps;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool inlineImagesSupported() const {
|
bool inlineImagesSupported() const {
|
||||||
return (tcaps & TerminalCapabilities.arsdImage) ? true : false;
|
return (tcaps & TerminalCapabilities.arsdImage) ? true : false;
|
||||||
|
@ -1443,9 +1451,6 @@ struct Terminal {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcaps = getTerminalCapabilities(fdIn, fdOut);
|
|
||||||
//writeln(tcaps);
|
|
||||||
|
|
||||||
initializeVt();
|
initializeVt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4697,6 +4702,8 @@ void main() {
|
||||||
|
|
||||||
//terminal.color(Color.DEFAULT, Color.DEFAULT);
|
//terminal.color(Color.DEFAULT, Color.DEFAULT);
|
||||||
|
|
||||||
|
terminal.writeln(terminal.tcaps);
|
||||||
|
|
||||||
//
|
//
|
||||||
///*
|
///*
|
||||||
auto getter = new FileLineGetter(&terminal, "test");
|
auto getter = new FileLineGetter(&terminal, "test");
|
||||||
|
@ -4818,8 +4825,13 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TerminalCapabilities : uint {
|
enum TerminalCapabilities : uint {
|
||||||
|
// the low byte is just a linear progression
|
||||||
minimal = 0,
|
minimal = 0,
|
||||||
vt100 = 1 << 0,
|
vt100 = 1, // caps == 1, 2
|
||||||
|
vt220 = 6, // initial 6 in caps. aka the linux console
|
||||||
|
xterm = 64,
|
||||||
|
|
||||||
|
// the rest of them are bitmasks
|
||||||
|
|
||||||
// my special terminal emulator extensions
|
// my special terminal emulator extensions
|
||||||
arsdClipboard = 1 << 15, // 90 in caps
|
arsdClipboard = 1 << 15, // 90 in caps
|
||||||
|
@ -4946,22 +4958,31 @@ private uint /* TerminalCapabilities bitmask */ getTerminalCapabilities(int fdIn
|
||||||
|
|
||||||
import std.string;
|
import std.string;
|
||||||
|
|
||||||
auto pieces = split(gots, ";");
|
// import std.stdio; File("tcaps.txt", "wt").writeln(gots);
|
||||||
uint ret = TerminalCapabilities.vt100;
|
|
||||||
foreach(p; pieces)
|
if(gots == "1;2") {
|
||||||
switch(p) {
|
return TerminalCapabilities.vt100;
|
||||||
case "90":
|
} else if(gots == "6") {
|
||||||
ret |= TerminalCapabilities.arsdClipboard;
|
return TerminalCapabilities.vt220;
|
||||||
break;
|
} else {
|
||||||
case "91":
|
auto pieces = split(gots, ";");
|
||||||
ret |= TerminalCapabilities.arsdImage;
|
uint ret = TerminalCapabilities.xterm;
|
||||||
break;
|
foreach(p; pieces) {
|
||||||
case "92":
|
switch(p) {
|
||||||
ret |= TerminalCapabilities.arsdHyperlinks;
|
case "90":
|
||||||
break;
|
ret |= TerminalCapabilities.arsdClipboard;
|
||||||
default:
|
break;
|
||||||
|
case "91":
|
||||||
|
ret |= TerminalCapabilities.arsdImage;
|
||||||
|
break;
|
||||||
|
case "92":
|
||||||
|
ret |= TerminalCapabilities.arsdHyperlinks;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extern(C) int mkstemp(char *templ);
|
private extern(C) int mkstemp(char *templ);
|
||||||
|
|
Loading…
Reference in New Issue