Skip to content

Commit

Permalink
Display control characters in caret notation.
Browse files Browse the repository at this point in the history
  • Loading branch information
shugo committed Jan 4, 2017
1 parent 55326f0 commit b693764
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/text_bringer/echo_area.rb
Expand Up @@ -43,7 +43,7 @@ def redisplay
if c == "\n"
break
end
@window << c
@window << escape(c)
@buffer.forward_char
end
if @buffer.point_at_mark?(saved)
Expand Down
8 changes: 7 additions & 1 deletion lib/text_bringer/window.rb
Expand Up @@ -36,7 +36,7 @@ def redisplay
@window.clrtoeol
break if @window.cury == @window.maxy - 1
end
@window << c
@window << escape(c)
break if @window.cury == @window.maxy - 1 &&
@window.curx == @window.maxx - 1
@buffer.forward_char
Expand Down Expand Up @@ -80,6 +80,12 @@ def framer
end
end

def escape(s)
s.gsub(/[\0-\b\v-\x1f]/) { |c|
"^" + (c.ord ^ 0x40).chr
}
end

def beginning_of_line
e = @buffer.point
@buffer.beginning_of_line
Expand Down

0 comments on commit b693764

Please sign in to comment.