From 8db21ddf99bcd3e020c83b4a63b7a913bb51e323 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 30 Aug 2019 15:47:30 +1200 Subject: [PATCH] Add tab support to textview --- src/plugins/textview.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/plugins/textview.rs b/src/plugins/textview.rs index aefb09992f..81097179a5 100644 --- a/src/plugins/textview.rs +++ b/src/plugins/textview.rs @@ -54,13 +54,25 @@ fn paint_textview( match command { DrawCommand::DrawString(style, string) => { for chr in string.chars() { - frame_buffer.push(( - chr, - style.foreground.r, - style.foreground.g, - style.foreground.b, - )); - pos += 1; + if chr == '\t' { + for _ in 0..8 { + frame_buffer.push(( + ' ', + style.foreground.r, + style.foreground.g, + style.foreground.b, + )); + } + pos += 8; + } else { + frame_buffer.push(( + chr, + style.foreground.r, + style.foreground.g, + style.foreground.b, + )); + pos += 1; + } } } DrawCommand::NextLine => {