Skip to content

Instantly share code, notes, and snippets.

@saitoha
saitoha / drcsconv.pl
Last active April 11, 2019 14:10
Convert an image to DRCS characters
#!/usr/bin/env perl
#
# This snippet is in public domain.
#
use strict;
use warnings;
use encoding "UTF-8";
if ($#ARGV != 0) {
#!/usr/bin/env perl
foreach (<stdin>) {
# DCS/OSC/SOS/PM/APC
$_ =~ s/\x1b[P\]X\^_].*(\x07|\x1b\\)//g;
# CSI
$_ =~ s/\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]//g;
# single shift
@saitoha
saitoha / vim-DECLRMM.diff
Created January 12, 2013 08:41
Vim DECLRMM test
diff -r b89e2bdcc6e5 src/screen.c
--- a/src/screen.c Sun Dec 16 12:50:40 2012 +0100
+++ b/src/screen.c Sat Jan 12 17:38:58 2013 +0900
@@ -8890,6 +8890,24 @@
*/
clear_cmdline = TRUE;
+ char buf[256];
+ if (del) {
+ sprintf(buf,
@saitoha
saitoha / xterm-fix-anyevent.diff
Last active December 11, 2015 01:59
Fix motion event behavior when xterm mouse mode is in ANY_EVENT_MOUSE.
diff -u xterm-288.old/button.c xterm-288/button.c
--- xterm-288.old/button.c 2013-01-14 10:47:52.000000000 +0900
+++ xterm-288/button.c 2013-01-14 11:32:26.000000000 +0900
@@ -4333,7 +4333,7 @@
break;
}
}
- screen->mouse_button = button;
+ screen->mouse_button = 3;
count = EMIT_BUTTON(button);
@saitoha
saitoha / vim-detect-ambiguous-state
Last active December 12, 2015 01:38
Detect east-asian-ambiguous-width state of the terminal automatically (vim).
diff -cr vim.ba8835947b8b/runtime/doc/options.txt vim/runtime/doc/options.txt
*** vim.ba8835947b8b/runtime/doc/options.txt 2013-02-10 14:03:58.000000000 +0900
--- vim/runtime/doc/options.txt 2013-02-10 14:03:58.000000000 +0900
***************
*** 699,704 ****
--- 699,709 ----
when the system locale is set to one of CJK locales. See Unicode
Standard Annex #11 (http://www.unicode.org/reports/tr11).
+ Vim may set this option automatically at the startup time.
"
" This snippet is licensed under NYSL.
" See http://www.kmonos.net/nysl/NYSL.TXT
"
if !has('gui_running')
" 以下の条件を満たさない場合vim本体がbackgroundを上書きするので自前での判定はやらない
" http://yskwkzhr.blogspot.jp/2012/12/set-background-color-of-vim-with-environment-variable.html
if $TERM !~ 'linux\|screen.linux\|cygwin\|putty' && $COLORFGBG == ''
" 背景色を問い合わせるクエリ文字列を設定
@saitoha
saitoha / mined-cpr.md
Created February 28, 2013 11:32
MinEdのCPR判定の部分。端末判定全体を4フェーズに分けたうちの2フェーズ目。
1.  "\u00e5\u0644\u0627\u0e29\u0e29\u5208\u58a2"("åلاษษ刈墢")の幅を計測し、変数swidthに代入する。2.へ
2. swidthが3かつ端末がGNU Screen(DA2応答の端末IDが83)なら"\u00e5\u006c\u0e29\u0e29\u5208\u58a2"("ålษษ刈墢")の幅を計測し、変数swidthに代入する。3.へ
3.  swidthが13なら、4.へ、そうでなければ5.へ
4.  "a\u0321"("å")の幅が1なら、5.へ。そうでなければ、エンコーディングをTIS-620(タイ)と判定し、7へ。
5.  UTF-8モードのPoderosaを判定候補としてマークし、swidthを9で上書き。7.へ
6.  swidthが16なら、ISO Latain1モードのPoderosaとマークする。そうでなければ、7.へ
7.  swidthが9以下なら、8.へ
8.  "a̡"の幅が1なら端末は文字結合をサポートしているとみなす。9.へ
@saitoha
saitoha / gist:5175048
Created March 16, 2013 04:47
Fix for Patch #859 (for TERM=ansi environment)
diff -cr vim.2e5e2e82a737/src/term.c vim/src/term.c
*** vim.2e5e2e82a737/src/term.c 2013-03-16 13:44:58.000000000 +0900
--- vim/src/term.c 2013-03-16 13:44:58.000000000 +0900
***************
*** 4098,4104 ****
#ifdef FEAT_TERMRESPONSE
if (key_name[0] == NUL
/* URXVT mouse uses <ESC>[#;#;#M, but we are matching <ESC>[ */
! || key_name[0] == KS_URXVT_MOUSE)
{
@saitoha
saitoha / fix-for-alternate-scroll-mode.diff
Last active December 15, 2015 07:59
less(1) - add support for alternate scroll mode (xterm, DECSET 1007) http://www.greenwoodsoftware.com/less/
diff -u less-457/opttbl.c less-457-alternate-scroll/opttbl.c
--- less-457/opttbl.c 2012-12-09 07:15:56.000000000 +0900
+++ less-457-alternate-scroll/opttbl.c 2013-03-23 20:05:50.000000000 +0900
@@ -44,6 +44,7 @@
public int chopline; /* Truncate displayed lines at screen width */
public int no_init; /* Disable sending ti/te termcap strings */
public int no_keypad; /* Disable sending ks/ke termcap strings */
+public int no_wheel; /* Disable alternate wheel mode */
public int twiddle; /* Show tildes after EOF */
public int show_attn; /* Hilite first unread line */
@saitoha
saitoha / focus-mode-reporting.diff
Last active December 15, 2015 08:29
Vim - Add support for focus reporting mode (DECSET/DECRST 1004) works on xterm compatible terminals
*** a/src/term.c 2015-01-10 13:26:55.000000000 +0900
--- b/src/term.c 2015-01-10 13:26:44.000000000 +0900
***************
*** 154,159 ****
--- 154,163 ----
#endif /* HAVE_TGETENT */
static int detected_8bit = FALSE; /* detected 8-bit terminal */
+ #if defined(FEAT_AUTOCMD) && (defined(UNIX) || defined(VMS))
+ static int focus_mode = FALSE; /* xterm's "focus reporting" availability */