[vte/wip/egmont/bidi: 2/15] widget: Set the soft_wrapped flag via wrapper methods
- From: Egmont Koblinger <egmontkob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/egmont/bidi: 2/15] widget: Set the soft_wrapped flag via wrapper methods
- Date: Sat, 29 Jun 2019 12:34:15 +0000 (UTC)
commit 9dd409e09d18fdc53f82ccc3bec9289cf8279ff1
Author: Egmont Koblinger <egmont gmail com>
Date: Fri May 31 12:33:39 2019 +0200
widget: Set the soft_wrapped flag via wrapper methods
This is in preparation for RingView and BiDi where there'll be more to do.
src/vte.cc | 32 +++++++++++++++++++++++++++++++-
src/vteinternal.hh | 3 +++
src/vteseq.cc | 10 +++++-----
3 files changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index ee1c673f..f87be139 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -470,6 +470,36 @@ Terminal::find_end_column(vte::grid::column_t col,
return MIN(col + columns, m_column_count);
}
+/* Sets the line ending to hard wrapped (explicit newline). */
+void
+Terminal::set_hard_wrapped(vte::grid::row_t row)
+{
+ /* We can set the row just above insert_delta to hard wrapped. */
+ g_assert_cmpint(row, >=, m_screen->insert_delta - 1);
+ g_assert_cmpint(row, <, m_screen->insert_delta + m_row_count);
+
+ VteRowData *row_data = find_row_data_writable(row);
+
+ /* It's okay for this row not to be covered by the ring. */
+ if (row_data == nullptr)
+ return;
+
+ row_data->attr.soft_wrapped = false;
+}
+
+/* Sets the line ending to soft wrapped (overflow to the next line). */
+void
+Terminal::set_soft_wrapped(vte::grid::row_t row)
+{
+ g_assert_cmpint(row, >=, m_screen->insert_delta);
+ g_assert_cmpint(row, <, m_screen->insert_delta + m_row_count);
+
+ VteRowData *row_data = find_row_data_writable(row);
+ g_assert(row_data != nullptr);
+
+ row_data->attr.soft_wrapped = true;
+}
+
/* Determine the width of the portion of the preedit string which lies
* to the left of the cursor, or the entire string, in columns. */
// FIXMEchpe this is for the view, so use int not gssize
@@ -2855,7 +2885,7 @@ Terminal::insert_char(gunichar c,
col = m_screen->cursor.col = 0;
/* Mark this line as soft-wrapped. */
row = ensure_row();
- row->attr.soft_wrapped = 1;
+ set_soft_wrapped(m_screen->cursor.row);
cursor_down(false);
} else {
/* Don't wrap, stay at the rightmost column. */
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index f321105e..7d4815e0 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -636,6 +636,9 @@ public:
VteRowData *ensure_cursor();
void update_insert_delta();
+ void set_hard_wrapped(vte::grid::row_t row);
+ void set_soft_wrapped(vte::grid::row_t row);
+
void cleanup_fragments(long start,
long end);
diff --git a/src/vteseq.cc b/src/vteseq.cc
index f01da516..07dc3be6 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -314,7 +314,7 @@ Terminal::clear_current_line()
_vte_row_data_shrink (rowdata, 0);
/* Add enough cells to the end of the line to fill out the row. */
_vte_row_data_fill (rowdata, &m_fill_defaults, m_column_count);
- rowdata->attr.soft_wrapped = 0;
+ set_hard_wrapped(m_screen->cursor.row);
/* Repaint this row. */
invalidate_row(m_screen->cursor.row);
}
@@ -338,7 +338,7 @@ Terminal::clear_above_current()
_vte_row_data_shrink (rowdata, 0);
/* Add new cells until we fill the row. */
_vte_row_data_fill (rowdata, &m_fill_defaults, m_column_count);
- rowdata->attr.soft_wrapped = 0;
+ set_hard_wrapped(i);
/* Repaint the row. */
invalidate_row(i);
}
@@ -731,7 +731,7 @@ Terminal::clear_below_current()
if (not_default_bg) {
_vte_row_data_fill(rowdata, &m_fill_defaults, m_column_count);
}
- rowdata->attr.soft_wrapped = 0;
+ set_hard_wrapped(i);
/* Repaint this row. */
invalidate_row(i);
}
@@ -770,7 +770,7 @@ Terminal::clear_to_eol()
/* Add enough cells to fill out the row. */
_vte_row_data_fill(rowdata, &m_fill_defaults, m_column_count);
}
- rowdata->attr.soft_wrapped = 0;
+ set_hard_wrapped(m_screen->cursor.row);
/* Repaint this row. */
invalidate_row(m_screen->cursor.row);
}
@@ -902,7 +902,7 @@ Terminal::delete_character()
_vte_row_data_fill(rowdata, &m_fill_defaults, m_column_count);
len = m_column_count;
}
- rowdata->attr.soft_wrapped = 0;
+ set_hard_wrapped(m_screen->cursor.row);
/* Repaint this row. */
invalidate_row(m_screen->cursor.row);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]