Skip to content

Instantly share code, notes, and snippets.

@saitoha
saitoha / sixel.py
Created September 30, 2012 09:30
convert an image into VT320 sixel color graphics (depends on PIL)
#!/usr/bin/env python
import sys, termios, StringIO
import Image # PIL
class SixelConverter:
def __init__(self, image, f8bit = False):
if f8bit: # 8bit mode
@saitoha
saitoha / iTerm2-support-DECSCUSR.diff
Created October 4, 2012 08:39
Support DECSCUSR / xterm patch#282 compatible, for iTerm2
diff --git a/VT100Screen.m b/VT100Screen.m
index cd303ae..03cc274 100644
--- a/VT100Screen.m
+++ b/VT100Screen.m
@@ -1571,6 +1571,38 @@ static char* FormatCont(int c)
break;
case VT100CSI_RM:
break;
+ case VT100CSI_DECSCUSR:
+ switch (token.u.csi.p[0]) {
@saitoha
saitoha / iterm2-prevent-csi_t-DoS
Last active October 11, 2015 14:17
Prevent DoS with CSI 4 t / CSI 8 t, for iTerm2
diff --git a/VT100Screen.m b/VT100Screen.m
index 65cb599..415e125 100644
--- a/VT100Screen.m
+++ b/VT100Screen.m
@@ -1791,47 +1791,66 @@ static char* FormatCont(int c)
//NSLog(@"setting window size from (%d, %d) to (%d, %d)", WIDTH, HEIGHT, token.u.csi.p[1], token.u.csi.p[2]);
if (![[[SESSION addressBookEntry] objectForKey:KEY_DISABLE_WINDOW_RESIZING] boolValue] &&
![[[SESSION tab] parentWindow] anyFullScreen]) {
+ NSRect windowFrame = [[[SESSION tab] parentWindow] windowFrame];
+ NSRect screenFrame = [[[[SESSION tab] parentWindow] windowScreen] frame];
@saitoha
saitoha / mappings.txt
Created October 13, 2012 11:05
My Vimperator Command Usage Statistics
nnoremap j 3j
nnoremap k 3k
nnoremap h <C-p>
nnoremap l <C-n>
nnoremap y Y
nnoremap Y y
nnoremap _ r
cnoremap <Down> <Tab>
cnoremap <Up> <S-Tab>
cnoremap <C-n> <Tab>
@saitoha
saitoha / tmux-fix-comb.diff
Created October 16, 2012 13:34
Fix the issue of wide base chacter + combined character, tmux
diff --git a/screen-write.c b/screen-write.c
index 66a62b3..09242be 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -1073,7 +1073,6 @@ screen_write_cell(struct screen_write_ctx *ctx,
screen_write_initctx(ctx, &ttyctx, 0);
tty_write(tty_cmd_utf8character, &ttyctx);
}
- return;
}
@saitoha
saitoha / LICENSE
Created October 22, 2012 13:09
倍角端末(for xterm/putty系, Terminal.appとtanasinnではカーソル位置を調整する必要がある)
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
@saitoha
saitoha / LICENSE
Created October 24, 2012 18:07
UTF-8/CP932/EUC-JP混在テキスト対応フィルタ端末(あまりうまくいってない)
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
@saitoha
saitoha / DA1.py
Created October 27, 2012 16:55
get DA1 report from terminal
#!/usr/bin/env python
import sys, os, termios, select
TIMEOUT=2
stdin_fileno = sys.stdin.fileno()
backup = termios.tcgetattr(stdin_fileno)
new = termios.tcgetattr(stdin_fileno)
new[3] = new[3] &~ (termios.ECHO | termios.ICANON)
@saitoha
saitoha / rlogin-decdld.sh
Created October 29, 2012 14:33
RLogin(http://nanno.dip.jp/softlib/man/rlogin/) DECDLD/Sixel extension test
width=15;height=24 && for row in {0..25}; do printf '\x1bP;;;$width;;3;$height;{ ' && `printf "printf '\\\\x%x'" $((64+$row))` && curl http://25.media.tumblr.com/tumblr_m3h88lZ7UM1rntypfo1_500.jpg | jpegtopnm | pnmscale --width=$(($width*80)) | pnmcut 0 $(($height*$row)) $(($width*80)) $height | ppmquant 256 | ppmtosixel && echo -en '\x1b\\\x1b( ' && `printf "printf \\\\\\\\x%x" $(($row+64))` && for col in {0..79}; do `printf "printf \\\\\\\\x%x" $(($col+32))`; done && printf '\x1b(B'; done 2> /dev/null
> node wcwidth_test.js
test: 135027ms