diff --git a/src/config/actions-main.inc b/src/config/actions-main.inc index 71b11719d..21ff838ee 100644 --- a/src/config/actions-main.inc +++ b/src/config/actions-main.inc @@ -55,6 +55,7 @@ ACTION_(MAIN, "mark-set", MARK_SET, N__("Set a mark"), ACTION_REQUIRE_VIEW_STATE ACTION_(MAIN, "menu", MENU, N__("Activate the menu"), 0), ACTION_(MAIN, "move-cursor-down", MOVE_CURSOR_DOWN, N__("Move cursor down"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-cursor-left", MOVE_CURSOR_LEFT, N__("Move cursor left"), ACTION_REQUIRE_VIEW_STATE), +ACTION_(MAIN, "move-cursor-line-start", MOVE_CURSOR_LINE_START, N__("Move cursor to the start of the line"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-cursor-right", MOVE_CURSOR_RIGHT, N__("Move cursor right"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-cursor-up", MOVE_CURSOR_UP, N__("Move cursor up"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-document-end", MOVE_DOCUMENT_END, N__("Move to the end of the document"), ACTION_REQUIRE_VIEW_STATE), diff --git a/src/viewer/action.c b/src/viewer/action.c index 093a2d17e..66e20bb12 100644 --- a/src/viewer/action.c +++ b/src/viewer/action.c @@ -360,6 +360,10 @@ do_action(struct session *ses, enum main_action action_id, int verbose) status = move_cursor_right(ses, doc_view); break; + case ACT_MAIN_MOVE_CURSOR_LINE_START: + status = move_cursor_line_start(ses, doc_view); + break; + case ACT_MAIN_MOVE_LINK_DOWN: status = move_link_down(ses, doc_view); break; diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 06ecc09f4..38196a27e 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -829,6 +829,22 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) return FRAME_EVENT_OK; } +enum frame_event_status +move_cursor_line_start(struct session *ses, struct document_view *doc_view) +{ + struct view_state *vs; + struct box *box; + int x; + + assert(ses && doc_view && doc_view->vs); + if_assert_failed return FRAME_EVENT_OK; + + vs = doc_view->vs; + box = &doc_view->box; + x = vs->x + ses->tab->x - box->x; + return move_cursor_rel(ses, doc_view, -x, 0); +} + enum frame_event_status copy_current_link_to_clipboard(struct session *ses, struct document_view *doc_view, diff --git a/src/viewer/text/view.h b/src/viewer/text/view.h index 1262ee376..6bbfdc734 100644 --- a/src/viewer/text/view.h +++ b/src/viewer/text/view.h @@ -58,6 +58,8 @@ enum frame_event_status move_cursor_up(struct session *ses, enum frame_event_status move_cursor_down(struct session *ses, struct document_view *view); +enum frame_event_status move_cursor_line_start(struct session *ses, struct document_view *doc_view); + enum frame_event_status move_cursor(struct session *ses, struct document_view *doc_view, int x, int y);