Skip to content

Commit

Permalink
Word wrap on Gtk::TextView
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinL10 committed Jun 14, 2023
1 parent 1626fc7 commit cdbb642
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cpp_browser/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ MyWindow::MyWindow() {

auto iter = refTextBuffer->get_iter_at_offset(0);
for (LayoutElement element : elements) {
iter = refTextBuffer->insert_with_tag(iter, element.text, element.toTextTag(refTextBuffer));
iter = refTextBuffer->insert_with_tag(iter, element.text,
element.toTextTag(refTextBuffer));
}

m_TextView.set_buffer(refTextBuffer);
m_TextView.set_editable(false);
m_TextView.set_cursor_visible(false);
m_TextView.set_wrap_mode(Gtk::WrapMode::WORD);
m_ScrolledWindow.set_child(m_TextView);
}

Expand Down
4 changes: 1 addition & 3 deletions cpp_browser/layout.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#include "layout.h"

#include <iostream>
Expand Down Expand Up @@ -55,7 +53,7 @@ vector<LayoutElement> layout(vector<Token> tokens) {
continue;
} else if (token.text == "/p") {
// HACK: add new line and indent after </p>
out.push_back(LayoutElement(weight, style, size, "\n\t"));
out.push_back(LayoutElement(weight, style, size, "\n\n"));
}
}

Expand Down

0 comments on commit cdbb642

Please sign in to comment.