aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjixiufeng <jixiufeng@luojilab.com>2018-12-01 01:02:07 +0800
committerjixiufeng <jixiufeng@luojilab.com>2018-12-01 01:15:35 +0800
commitb3bb2997b8b91d77da5382b7a77c76c704024e60 (patch)
treea63b702f11d4e85f7f0bed12e1b65c942a0ed046
parentd0fef6124ed6398097fdf3b9593104cabb901fc3 (diff)
ignore black at end of line
-rw-r--r--vterm-module.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/vterm-module.c b/vterm-module.c
index 775d724..d401eb0 100644
--- a/vterm-module.c
+++ b/vterm-module.c
@@ -120,10 +120,32 @@ static void fetch_cell(Term *term, int row, int col, VTermScreenCell *cell) {
}
}
+static bool is_eol(Term *term, int end_col, int row, int col) {
+ /* This cell is EOL if this and every cell to the right is black */
+ if (row >= 0) {
+ VTermPos pos = {.row = row, .col = col};
+ return vterm_screen_is_eol(term->vts, pos);
+ }
+
+ ScrollbackLine *sbrow = term->sb_buffer[-row - 1];
+ int c;
+ for (c = col; c < end_col && c < sbrow->cols;) {
+ if (sbrow->cells[c].chars[0]) {
+ return 0;
+ }
+ c += sbrow->cells[c].width;
+ }
+ return 1;
+}
+
static size_t get_col_offset(Term *term, int row, int end_col) {
int col = 0;
size_t offset = 0;
unsigned char buf[4];
+ int height;
+ int width;
+ vterm_get_size(term->vt, &height, &width);
+
while (col < end_col) {
VTermScreenCell cell;
@@ -132,6 +154,10 @@ static size_t get_col_offset(Term *term, int row, int end_col) {
if (cell.width > 1) {
offset += cell.width - 1;
}
+ } else {
+ if (is_eol(term, term->width, row, col)) {
+ offset += cell.width;
+ }
}
col += cell.width;
}
@@ -164,6 +190,10 @@ static void refresh_lines(Term *term, emacs_env *env, int start_row,
lastCell = cell;
if (cell.chars[0] == 0) {
+ if (is_eol(term, end_col, i, j)) {
+ /* This cell is EOL if this and every cell to the right is black */
+ break;
+ }
buffer[length] = ' ';
length++;
} else {