From 724a6e81202e07472b5c3c9275546c7f1ab599ce Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 21 Mar 2012 21:24:25 +0100 Subject: [PATCH] Support escape sequences used by 'ls --color=auto' --- gems/include/terminal/decoder.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gems/include/terminal/decoder.h b/gems/include/terminal/decoder.h index 5b254ae5b..7cb20e4df 100644 --- a/gems/include/terminal/decoder.h +++ b/gems/include/terminal/decoder.h @@ -329,7 +329,20 @@ namespace Terminal { case 'H': return (_screen.cup(p1, p2), true); case 'm': if ((p1 == 39) && (p2 == 49)) return (_screen.op(), true); - if ((p1 == 0) && (p2 == 10)) return (_screen.sgr(0), true); + if ((p1 == 0 || p1 == 1) && (p2 >= 30) && (p2 <= 37)) { + /* + * p1 encodes attribute (see 'dircolors -p') + * 0 -> normal + * 1 -> bold (turn into highlight) + * + * p2 encodes color + * 30...37 text colors + * 40...47 background colors + */ + _screen.sgr(p1); + _screen.setaf(p2 - 30); + return true; + } return false; case 'R': return (_screen.u6(p1, p2), true); default: return false;