This commit is contained in:
Adam D. Ruppe 2017-01-07 09:24:18 -05:00
parent a45f9da6bf
commit b2f1022ad8
3 changed files with 84 additions and 5 deletions

View File

@ -559,8 +559,10 @@ version(linux) {
throw new Exception("epoll_wait");
}
foreach(n; 0 .. nfds) {
auto fd = events[n].data.fd;
if(fd == pipes[0]) {
if(readFromEventPipe() == false)
break outer_loop;

13
http2.d
View File

@ -848,6 +848,8 @@ class HttpRequest {
headers ~= "Host: "~requestParameters.host~"\r\n";
if(requestParameters.userAgent.length)
headers ~= "User-Agent: "~requestParameters.userAgent~"\r\n";
if(requestParameters.contentType.length)
headers ~= "Content-Type: "~requestParameters.contentType~"\r\n";
if(requestParameters.authorization.length)
headers ~= "Authorization: "~requestParameters.authorization~"\r\n";
if(requestParameters.bodyData.length)
@ -1160,6 +1162,7 @@ version(use_openssl) {
@trusted
override ptrdiff_t send(const(void)[] buf, SocketFlags flags) {
//import std.stdio;writeln(cast(string) buf);
auto retval = SSL_write(ssl, buf.ptr, cast(uint) buf.length);
if(retval == -1) {
ERR_print_errors_fp(core.stdc.stdio.stderr);
@ -1296,6 +1299,9 @@ class HttpApiClient() {
RestBuilder opIndex(string str) {
return RestBuilder(apiClient, pathParts ~ str, queryParts);
}
RestBuilder opIndex(var str) {
return RestBuilder(apiClient, pathParts ~ str.get!string, queryParts);
}
RestBuilder opIndex(int i) {
return RestBuilder(apiClient, pathParts ~ to!string(i), queryParts);
}
@ -1332,7 +1338,12 @@ class HttpApiClient() {
final HttpRequestWrapper PUT(T...)(T t) { return _EXECUTE(HttpVerb.PUT, this.toUri(), toBytes(t)); }
private ubyte[] toBytes(T...)(T t) {
return null; // FIXME
static if(T.length == 0)
return null;
else static if(T.length == 1 && is(T[0] == var))
return cast(ubyte[]) t[0].toJson(); // FIXME: cast
else
static assert(0); // FIXME
}

View File

@ -294,7 +294,7 @@ Eterm|Eterm Terminal Emulator (X11 Window System):\
:sc=\E7:se=\E[27m:sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:\
:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:ue=\E[24m:up=\E[A:\
:us=\E[4m:vb=\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:\
:ac=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:
:ac=aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:
# DOS terminal emulator such as Telix or TeleMate.
# This probably also works for the SCO console, though it's incomplete.
@ -3501,13 +3501,48 @@ struct ScrollbackBuffer {
scrollbackPosition = 0;
}
void scrollToBottom() {
scrollbackPosition = 0;
}
// this needs width and height to know how to word wrap it
void scrollToTop(int width, int height) {
scrollbackPosition = scrollTopPosition(width, height);
}
struct LineComponent {
string text;
int color = Color.DEFAULT;
int background = Color.DEFAULT;
bool isRgb;
union {
int color;
RGB colorRgb;
}
union {
int background;
RGB backgroundRgb;
}
bool delegate() onclick; // return true if you need to redraw
// 16 color ctor
this(string text, int color = Color.DEFAULT, int background = Color.DEFAULT, bool delegate() onclick = null) {
this.text = text;
this.color = color;
this.background = background;
this.onclick = onclick;
this.isRgb = false;
}
// true color ctor
this(string text, RGB colorRgb, RGB backgroundRgb = RGB(0, 0, 0), bool delegate() onclick = null) {
this.text = text;
this.colorRgb = colorRgb;
this.backgroundRgb = backgroundRgb;
this.onclick = onclick;
this.isRgb = true;
}
}
struct Line {
@ -3529,6 +3564,34 @@ struct ScrollbackBuffer {
int scrollbackPosition;
int scrollTopPosition(int width, int height) {
int lineCount;
foreach_reverse(line; lines) {
int written = 0;
comp_loop: foreach(cidx, component; line.components) {
auto towrite = component.text;
foreach(idx, dchar ch; towrite) {
if(written >= width) {
lineCount++;
written = 0;
}
if(ch == '\t')
written += 8; // FIXME
else
written++;
}
}
lineCount++;
}
//if(lineCount > height)
return lineCount - height;
//return 0;
}
void drawInto(Terminal* terminal, in int x = 0, in int y = 0, int width = 0, int height = 0) {
if(lines.length == 0)
return;
@ -3641,7 +3704,10 @@ struct ScrollbackBuffer {
}
foreach(ref component; todo) {
terminal.color(component.color, component.background);
if(component.isRgb)
terminal.setTrueColor(component.colorRgb, component.backgroundRgb);
else
terminal.color(component.color, component.background);
auto towrite = component.text;
again: