aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2012-02-16 00:58:16 +0100
committerAurélien Aptel <aurelien.aptel@gmail.com>2012-02-16 00:58:16 +0100
commit6cd5c3dab7e47553bc14a8a7cf76708f708b508e (patch)
treec9347b466db504908a1a5e89a50d6071abf94d54
parent8ebab415921d534461b0fb8bce8fa1442afaba42 (diff)
downloadst-6cd5c3dab7e47553bc14a8a7cf76708f708b508e.tar.gz
st-6cd5c3dab7e47553bc14a8a7cf76708f708b508e.tar.bz2
rewrite csidump().
-rw-r--r--st.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/st.c b/st.c
index 89d123c..3b7eb78 100644
--- a/st.c
+++ b/st.c
@@ -1387,8 +1387,17 @@ csihandle(void) {
void
csidump(void) {
- fwrite("\033[", 1, 2, stdout);
- fwrite(escseq.buf, 1, escseq.len, stdout);
+ int i;
+ fwrite("ESC[", 1, 4, stdout);
+ for(i = 0; i < escseq.len; i++) {
+ uint c = escseq.buf[i] & 0xff;
+ if(isprint(c)) putchar(c);
+ else if(c == '\n') printf("(\\n)");
+ else if(c == '\r') printf("(\\r)");
+ else if(c == 0x1b) printf("(\\e)");
+ else printf("(%02x)", c);
+ }
+ putchar('\n');
}
void