Change how scrolling works, add home/end (#1212)

Conflicts fixed by gull
This commit is contained in:
Kyle Reed 2023-06-29 13:17:31 -07:00 committed by GitHub
parent ceaa115025
commit ca7840557b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 36 deletions

View file

@ -72,6 +72,9 @@ class TextViewer : public Widget {
uint32_t col() const { return cursor_.col; }
uint32_t offset() const;
void cursor_home();
void cursor_end();
// Gets the length of the current line.
uint16_t line_length();
@ -125,14 +128,12 @@ class TextEditorMenu : public View {
void on_show() override;
void on_hide() override;
std::function<void()>& on_cut() { return button_cut.on_select; }
std::function<void()>& on_paste() { return button_paste.on_select; }
std::function<void()>& on_zoom() { return button_zoom.on_select; }
std::function<void()>& on_home() { return button_home.on_select; }
std::function<void()>& on_end() { return button_end.on_select; }
std::function<void()>& on_copy() { return button_copy.on_select; }
std::function<void()>& on_delete_line() { return button_delline.on_select; }
std::function<void()>& on_edit_line() { return button_edit.on_select; }
std::function<void()>& on_add_line() { return button_addline.on_select; }
std::function<void()>& on_open() { return button_open.on_select; }
std::function<void()>& on_save() { return button_save.on_select; }
std::function<void()>& on_exit() { return button_exit.on_select; }
@ -144,16 +145,16 @@ class TextEditorMenu : public View {
{0 * 8, 0 * 8, 23 * 8, 23 * 8},
Color::dark_grey()};
NewButton button_cut{
NewButton button_home{
{1 * 8, 1 * 8, 7 * 8, 7 * 8},
"Cut",
&bitmap_icon_cut,
"Home",
&bitmap_arrow_left,
Color::dark_grey()};
NewButton button_paste{
NewButton button_end{
{8 * 8, 1 * 8, 7 * 8, 7 * 8},
"Paste",
&bitmap_icon_paste,
"End",
&bitmap_arrow_right,
Color::dark_grey()};
NewButton button_zoom{
@ -225,7 +226,6 @@ class TextEditorView : public View {
void hide_menu(bool hidden = true);
void show_file_picker(bool immediate = true);
void show_edit_line();
void show_nyi();
void show_save_prompt(std::function<void()> continuation);
void prepare_for_write();