From 588e9144704e916c2442b78a5c2e62e06f31e37d Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 22 Nov 2007 19:09:20 +0100 Subject: [PATCH 01/20] bug 978: Python's webbrowser.open_new_tab(URL) works since now. --- NEWS | 1 + src/config/cmdline.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 517e7f843..d6d0015b2 100644 --- a/NEWS +++ b/NEWS @@ -316,6 +316,7 @@ To be released as 0.11.4. * build: disable GCC 4.2 warning about builtin_modules * minor build bug 960: fix errors in loadmsgcat.c if mmap() exists but munmap() doesn't +* bug 978: Python's webbrowser.open_new_tab(URL) works since now ////////////////////////////////////////////////////////////////////// The following changes should be removed from NEWS before ELinks 0.11.4 diff --git a/src/config/cmdline.c b/src/config/cmdline.c index 27eb83b8f..b4787b24e 100644 --- a/src/config/cmdline.c +++ b/src/config/cmdline.c @@ -299,9 +299,12 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc) } else { end = strchr(start, ','); - if (!end) + if (!end) { end = start + strlen(start); - arg = end; + arg = end; + } else { + arg = end + 1; + } skipback_whitespace(start, end); if (start != end) From cca6ab7034efb039a6ac90b6af6ced9e018d9bee Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 25 Nov 2007 09:00:00 +0200 Subject: [PATCH 02/20] Enable asciidoc7compatible mode. AsciiDoc 8 has changed the syntax again and generates e.g. subscripts where we don't want them. Instead of updating the documents, I'll just enable a compatibility mode so that ELinks doesn't require AsciiDoc 8 yet. --- doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index 9badf021e..15ab5b2df 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -14,7 +14,7 @@ PDF_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/pdf TXT_DIR = $(DESTDIR)$(docdir)/$(PACKAGE)/txt ASCIIDOC_CONF = $(srcdir)asciidoc.conf -ASCIIDOC_FLAGS += -f $(ASCIIDOC_CONF) -a "builddir=$(CURDIR)/" +ASCIIDOC_FLAGS += -f $(ASCIIDOC_CONF) -a "builddir=$(CURDIR)/" -a asciidoc7compatible ############################################################################# # Build files From 02ffed2fff183fc3d2033b1f315382cbf5fb99d6 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Thu, 6 Dec 2007 23:46:19 +0200 Subject: [PATCH 03/20] Document that GNU Make >= 3.78 is needed, and check it. (cherry picked from commit 4ffbf1faed6717ae6e32da44529be3a57526d6d4) --- Makefile | 12 ++++++++++++ doc/installation.txt | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 08d92fe32..703616ada 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ top_builddir=. SUBDIRS = doc src SUBDIRS-$(CONFIG_NLS) += po CLEAN = features.log +calltest = $1-$1 all-recursive: config.h @@ -49,6 +50,16 @@ $(top_srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) @echo timestamp > $(top_srcdir)/stamp-h.in 2> /dev/null +# Makefile.lib heavily uses $(call ...), which was added in GNU Make 3.78. +# An elinks-users post on 2007-12-04 reported trouble with GNU Make 3.68. +# Detect this situation and give an error message. $(MAKECMDGOALS) is +# only defined by 3.76 and later, so specify the "all" target as well. +# This check has been tested with GNU Make 3.68, 3.77, 3.78.1, and 3.81. +ifneq ($(call calltest,ok),ok-ok) +$(MAKECMDGOALS) default all: + @echo >&2 "You need GNU Make 3.78 or later" + @false +else ifeq ($(wildcard Makefile.config),) # Catch all $(MAKECMDGOALS) default: @@ -56,3 +67,4 @@ $(MAKECMDGOALS) default: else include $(top_srcdir)/Makefile.lib endif +endif diff --git a/doc/installation.txt b/doc/installation.txt index 95c7da037..8c9d7073c 100644 --- a/doc/installation.txt +++ b/doc/installation.txt @@ -19,9 +19,10 @@ required or recommended that you install. Requirements ~~~~~~~~~~~~ -To successfully install ELinks all that is required is GNU make and a C -compiler. If you want to install directly from GIT it is also required that -automake and autoconf is installed on your system. +To successfully install ELinks all that is required is GNU make +(version 3.78 or later) and a C compiler. If you want to install +directly from GIT it is also required that automake and autoconf +is installed on your system. Recommended Libraries and Programs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 61341d92375ad9f0902b60e55d400498471389e3 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 16 Dec 2007 01:06:48 +0200 Subject: [PATCH 04/20] Bug 822: Show --disable-utf-8 in configure --help. Because features.conf now contains CONFIG_UTF8=yes, configure --enable-utf-8 is not useful, and it is better to document configure --disable-utf-8. Reported by witekfl. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 4520b3bf7..7be3a9655 100644 --- a/configure.in +++ b/configure.in @@ -1334,7 +1334,7 @@ EL_ARG_ENABLE(CONFIG_SMALL, small, [Small binary], [ --enable-small reduce binary size as far as possible (but see the bottom of doc/small.txt!)]) EL_ARG_ENABLE(CONFIG_UTF8, utf-8, [UTF-8], - [ --enable-utf-8 enable UTF-8 support]) + [ --disable-utf-8 disable UTF-8 support]) AC_ARG_ENABLE(weehoofooboomookerchoo, From f8863183b86b8dd64f9316965cfb69d69b5719d2 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 16 Dec 2007 01:09:18 +0200 Subject: [PATCH 05/20] option_types: Add comments to be found by grep. I was looking for code that handles OPT_COMMAND, so I grepped for it, but did not immediately find this array. Next time, I will. --- src/config/opttypes.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/config/opttypes.c b/src/config/opttypes.c index 3a5c8915d..5b0e25792 100644 --- a/src/config/opttypes.c +++ b/src/config/opttypes.c @@ -396,20 +396,31 @@ tree_dup(struct option *opt, struct option *template) } const struct option_type_info option_types[] = { + /* The OPT_ comments below are here to be found by grep. */ + + /* OPT_BOOL */ { N_("Boolean"), bool_cmd, num_rd, num_wr, NULL, num_set, N_("[0|1]") }, + /* OPT_INT */ { N_("Integer"), gen_cmd, num_rd, num_wr, NULL, num_set, N_("") }, + /* OPT_LONG */ { N_("Longint"), gen_cmd, num_rd, long_wr, NULL, long_set, N_("") }, + /* OPT_STRING */ { N_("String"), gen_cmd, str_rd, str_wr, str_dup, str_set, N_("") }, + /* OPT_CODEPAGE */ { N_("Codepage"), gen_cmd, str_rd, cp_wr, NULL, cp_set, N_("") }, + /* OPT_LANGUAGE */ { N_("Language"), gen_cmd, str_rd, lang_wr, NULL, lang_set, N_("") }, + /* OPT_COLOR */ { N_("Color"), gen_cmd, str_rd, color_wr, NULL, color_set, N_("") }, + /* OPT_COMMAND */ { N_("Special"), exec_cmd, NULL, NULL, NULL, NULL, "" }, + /* OPT_ALIAS */ { N_("Alias"), redir_cmd, redir_rd, redir_wr, NULL, redir_set, "" }, - /* tree */ + /* OPT_TREE */ { N_("Folder"), NULL, NULL, NULL, tree_dup, NULL, "" }, }; From 52dfc92523402d55e2fea21bfa03c4de231115c4 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sat, 11 Aug 2007 23:06:10 +0200 Subject: [PATCH 06/20] viewer: Added new four actions requested by Ligesh. move-link-down-line moves the cursor down to the line with a link. move-link-up-line moves the cursor up to the line with a link. move-link-prev-line moves to the previous link horizontally. move-link-next-line moves to the next link horizontally. (cherry picked from commit 8259a56e99ca135961719bb72a7dd585ec96e68a) (cherry picked from commit 2eb35324169f6e8867faf0d08d5cf40919c8fe8d) --- src/config/actions-main.inc | 4 ++ src/viewer/action.c | 16 +++++ src/viewer/text/link.c | 2 +- src/viewer/text/link.h | 3 + src/viewer/text/view.c | 120 +++++++++++++++++++++++++++++++++++- src/viewer/text/view.h | 7 +++ 6 files changed, 150 insertions(+), 2 deletions(-) diff --git a/src/config/actions-main.inc b/src/config/actions-main.inc index 9626c9dd5..a5de82fc0 100644 --- a/src/config/actions-main.inc +++ b/src/config/actions-main.inc @@ -59,11 +59,15 @@ ACTION_(MAIN, "move-cursor-up", MOVE_CURSOR_UP, N__("Move cursor up"), ACTION_RE ACTION_(MAIN, "move-document-end", MOVE_DOCUMENT_END, N__("Move to the end of the document"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-document-start", MOVE_DOCUMENT_START, N__("Move to the start of the document"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-link-down", MOVE_LINK_DOWN, N__("Move one link down"), ACTION_REQUIRE_VIEW_STATE), +ACTION_(MAIN, "move-link-down-line", MOVE_LINK_DOWN_LINE, N__("Move to the next line with a link"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-link-left", MOVE_LINK_LEFT, N__("Move one link left"), ACTION_REQUIRE_VIEW_STATE), +ACTION_(MAIN, "move-link-left-line", MOVE_LINK_LEFT_LINE, N__("Move one link left or to the previous link"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-link-next", MOVE_LINK_NEXT, N__("Move to the next link"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-link-prev", MOVE_LINK_PREV, N__("Move to the previous link"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-link-right", MOVE_LINK_RIGHT, N__("Move one link right"), ACTION_REQUIRE_VIEW_STATE), +ACTION_(MAIN, "move-link-right-line", MOVE_LINK_RIGHT_LINE, N__("Move one link right or to the next link"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-link-up", MOVE_LINK_UP, N__("Move one link up"), ACTION_REQUIRE_VIEW_STATE), +ACTION_(MAIN, "move-link-up-line", MOVE_LINK_UP_LINE, N__("Move to the previous line with a link"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-page-down", MOVE_PAGE_DOWN, N__("Move downwards by a page"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "move-page-up", MOVE_PAGE_UP, N__("Move upwards by a page"), ACTION_REQUIRE_VIEW_STATE), ACTION_(MAIN, "open-link-in-new-tab", OPEN_LINK_IN_NEW_TAB, N__("Open the current link in a new tab"), ACTION_REQUIRE_VIEW_STATE | ACTION_JUMP_TO_LINK | ACTION_REQUIRE_LINK), diff --git a/src/viewer/action.c b/src/viewer/action.c index 3089a19f1..9f7231a19 100644 --- a/src/viewer/action.c +++ b/src/viewer/action.c @@ -360,10 +360,18 @@ do_action(struct session *ses, enum main_action action_id, int verbose) status = move_link_down(ses, doc_view); break; + case ACT_MAIN_MOVE_LINK_DOWN_LINE: + status = move_link_down_line(ses, doc_view); + break; + case ACT_MAIN_MOVE_LINK_LEFT: status = move_link_left(ses, doc_view); break; + case ACT_MAIN_MOVE_LINK_LEFT_LINE: + status = move_link_prev_line(ses, doc_view); + break; + case ACT_MAIN_MOVE_LINK_NEXT: status = move_link_next(ses, doc_view); break; @@ -376,10 +384,18 @@ do_action(struct session *ses, enum main_action action_id, int verbose) status = move_link_right(ses, doc_view); break; + case ACT_MAIN_MOVE_LINK_RIGHT_LINE: + status = move_link_next_line(ses, doc_view); + break; + case ACT_MAIN_MOVE_LINK_UP: status = move_link_up(ses, doc_view); break; + case ACT_MAIN_MOVE_LINK_UP_LINE: + status = move_link_up_line(ses, doc_view); + break; + case ACT_MAIN_MOVE_PAGE_DOWN: status = move_page_down(ses, doc_view); break; diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 77f0cb2ac..ab5f7252b 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -545,7 +545,7 @@ next_link_in_view_y(struct document_view *doc_view, int current, int direction) /** Get the bounding columns of @a link at line @a y (or all lines if * @a y == -1). */ -static void +void get_link_x_bounds(struct link *link, int y, int *min_x, int *max_x) { int point; diff --git a/src/viewer/text/link.h b/src/viewer/text/link.h index a27c2d26d..07502fe9f 100644 --- a/src/viewer/text/link.h +++ b/src/viewer/text/link.h @@ -43,11 +43,14 @@ int current_link_is_visible(struct document_view *doc_view); int next_link_in_view(struct document_view *doc_view, int current, int direction); int next_link_in_view_y(struct document_view *doc_view, int current, int direction); int next_link_in_dir(struct document_view *doc_view, int dir_x, int dir_y); +int next_link_vertical(struct session *ses, struct document_view *doc_view, int dir_y); void jump_to_link_number(struct session *ses, struct document_view *doc_view, int); struct link *goto_current_link(struct session *ses, struct document_view *, int); void goto_link_number(struct session *ses, unsigned char *num); +void get_link_x_bounds(struct link *link, int y, int *min_x, int *max_x); + /* Bruteforce compilation fixes */ enum frame_event_status enter(struct session *ses, struct document_view *doc_view, int do_reload); diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 238ca2eb7..c985c5de0 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -61,6 +61,7 @@ #include "viewer/text/vs.h" +static enum frame_event_status move_cursor_rel(struct session *ses, struct document_view *view, int rx, int ry); void detach_formatted(struct document_view *doc_view) @@ -163,6 +164,91 @@ move_page_up(struct session *ses, struct document_view *doc_view) return doc_view->vs->y == oldy ? FRAME_EVENT_OK : FRAME_EVENT_REFRESH; } +enum frame_event_status +move_link_prev_line(struct session *ses, struct document_view *doc_view) +{ + struct view_state *vs; + struct document *document; + struct link *link, *last = NULL; + int y1, y, min_x, max_x, x1; + + assert(ses && doc_view && doc_view->vs && doc_view->document); + if_assert_failed return FRAME_EVENT_OK; + + vs = doc_view->vs; + document = doc_view->document; + if (!document->lines1) return FRAME_EVENT_OK; + + y = y1 = vs->y + ses->tab->y - ses->status.show_title_bar + - (ses->status.show_tabs_bar && ses->status.show_tabs_bar_at_top); + x1 = vs->x + ses->tab->x; + + link = get_current_link(doc_view); + if (link) { + get_link_x_bounds(link, y1, &min_x, &max_x); + } else { + min_x = max_x = x1; + int_upper_bound(&y, document->height - 1); + } + + for (; y >= 0; y--, min_x = INT_MAX) { + link = document->lines1[y]; + if (!link) continue; + for (; link <= document->lines2[y]; link++) { + if (link->points[0].y != y) continue; + if (link->points[0].x >= min_x) continue; + if (!last) last = link; + else if (link->points[0].x > last->points[0].x) last = link; + } + if (last) + return move_cursor_rel(ses, doc_view, last->points[0].x - x1, last->points[0].y - y1); + } + return FRAME_EVENT_OK; +} + + +enum frame_event_status +move_link_next_line(struct session *ses, struct document_view *doc_view) +{ + struct view_state *vs; + struct document *document; + struct link *link, *last = NULL; + int y1, y, min_x, max_x, x1; + + assert(ses && doc_view && doc_view->vs && doc_view->document); + if_assert_failed return FRAME_EVENT_OK; + + vs = doc_view->vs; + document = doc_view->document; + if (!document->lines1) return FRAME_EVENT_OK; + + y = y1 = vs->y + ses->tab->y - ses->status.show_title_bar + - (ses->status.show_tabs_bar && ses->status.show_tabs_bar_at_top); + x1 = vs->x + ses->tab->x; + + link = get_current_link(doc_view); + if (link) { + get_link_x_bounds(link, y1, &min_x, &max_x); + } else { + min_x = max_x = x1; + int_upper_bound(&y, document->height - 1); + } + + for (; y < document->height; y++, min_x = -1) { + link = document->lines1[y]; + if (!link) continue; + for (; link <= document->lines2[y]; link++) { + if (link->points[0].y != y) continue; + if (link->points[0].x <= min_x) continue; + if (!last) last = link; + else if (link->points[0].x < last->points[0].x) last = link; + } + if (last) + return move_cursor_rel(ses, doc_view, last->points[0].x - x1, last->points[0].y - y1); + } + return FRAME_EVENT_OK; +} + enum frame_event_status move_link(struct session *ses, struct document_view *doc_view, int direction, int wraparound_bound, int wraparound_link) @@ -555,7 +641,7 @@ move_cursor(struct session *ses, struct document_view *doc_view, int x, int y) return status; } -enum frame_event_status +static enum frame_event_status move_cursor_rel(struct session *ses, struct document_view *view, int rx, int ry) { @@ -593,6 +679,38 @@ move_cursor_down(struct session *ses, struct document_view *view) return move_cursor_rel(ses, view, 0, 1); } +enum frame_event_status +move_link_vertical(struct session *ses, struct document_view *doc_view, int dir_y) +{ + struct document *document; + struct view_state *vs; + int y, y1; + + assert(ses && doc_view && doc_view->vs && doc_view->document); + if_assert_failed return FRAME_EVENT_OK; + vs = doc_view->vs; + document = doc_view->document; + if (!document->lines1) return FRAME_EVENT_OK; + + y1 = vs->y + ses->tab->y - ses->status.show_status_bar + - (ses->status.show_tabs_bar && ses->status.show_tabs_bar_at_top); + y = y1 + dir_y; + if (dir_y < 0) + int_upper_bound(&y, document->height - 1); + else + int_lower_bound(&y, 0); + for (; dir_y > 0 ? y < document->height : y >= 0; y += dir_y) { + struct link *link = document->lines1[y]; + + if (!link) continue; + for (; link <= document->lines2[y]; link++) { + if (link->points[0].y == y) { + return move_cursor_rel(ses, doc_view, 0, y - y1); + } + } + } + return FRAME_EVENT_OK; +} enum frame_event_status copy_current_link_to_clipboard(struct session *ses, diff --git a/src/viewer/text/view.h b/src/viewer/text/view.h index e87fae643..ad9049bdd 100644 --- a/src/viewer/text/view.h +++ b/src/viewer/text/view.h @@ -30,6 +30,13 @@ enum frame_event_status move_link_dir(struct session *ses, struct document_view #define move_link_left(ses, doc_view) move_link_dir(ses, doc_view, -1, 0) #define move_link_right(ses, doc_view) move_link_dir(ses, doc_view, 1, 0) +enum frame_event_status move_link_prev_line(struct session *ses, struct document_view *doc_view); +enum frame_event_status move_link_next_line(struct session *ses, struct document_view *doc_view); +enum frame_event_status move_link_vertical(struct session *ses, struct document_view *doc_view, int dir_y); + +#define move_link_up_line(ses, doc_view) move_link_vertical(ses, doc_view, -1) +#define move_link_down_line(ses, doc_view) move_link_vertical(ses, doc_view, 1) + enum frame_event_status scroll_up(struct session *ses, struct document_view *doc_view); enum frame_event_status scroll_down(struct session *ses, struct document_view *doc_view); enum frame_event_status scroll_left(struct session *ses, struct document_view *doc_view); From cb07a2630ccc43bdd73758b403819f08054f351f Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 12 Aug 2007 10:34:00 +0200 Subject: [PATCH 07/20] actions: Fixed moving in frames. (cherry picked from commit 2045574edca170a47b1e9f1e05cd210bdae8a49a) (cherry picked from commit 02af6696f537a24d41a5a1fc510b6d29f8244899) --- src/viewer/text/view.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index c985c5de0..887f30169 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -169,6 +169,7 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) { struct view_state *vs; struct document *document; + struct box *box; struct link *link, *last = NULL; int y1, y, min_x, max_x, x1; @@ -178,10 +179,10 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) vs = doc_view->vs; document = doc_view->document; if (!document->lines1) return FRAME_EVENT_OK; + box = &doc_view->box; - y = y1 = vs->y + ses->tab->y - ses->status.show_title_bar - - (ses->status.show_tabs_bar && ses->status.show_tabs_bar_at_top); - x1 = vs->x + ses->tab->x; + y = y1 = vs->y + ses->tab->y - box->y; + x1 = vs->x + ses->tab->x - box->x; link = get_current_link(doc_view); if (link) { @@ -212,6 +213,7 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) { struct view_state *vs; struct document *document; + struct box *box; struct link *link, *last = NULL; int y1, y, min_x, max_x, x1; @@ -221,10 +223,10 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) vs = doc_view->vs; document = doc_view->document; if (!document->lines1) return FRAME_EVENT_OK; + box = &doc_view->box; - y = y1 = vs->y + ses->tab->y - ses->status.show_title_bar - - (ses->status.show_tabs_bar && ses->status.show_tabs_bar_at_top); - x1 = vs->x + ses->tab->x; + y = y1 = vs->y + ses->tab->y - box->y; + x1 = vs->x + ses->tab->x - box->x; link = get_current_link(doc_view); if (link) { @@ -684,6 +686,7 @@ move_link_vertical(struct session *ses, struct document_view *doc_view, int dir_ { struct document *document; struct view_state *vs; + struct box *box; int y, y1; assert(ses && doc_view && doc_view->vs && doc_view->document); @@ -692,8 +695,8 @@ move_link_vertical(struct session *ses, struct document_view *doc_view, int dir_ document = doc_view->document; if (!document->lines1) return FRAME_EVENT_OK; - y1 = vs->y + ses->tab->y - ses->status.show_status_bar - - (ses->status.show_tabs_bar && ses->status.show_tabs_bar_at_top); + box = &doc_view->box; + y1 = vs->y + ses->tab->y - box->y; y = y1 + dir_y; if (dir_y < 0) int_upper_bound(&y, document->height - 1); From d830833e621819e16603cd53debb24a34abe0c24 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 14 Aug 2007 19:56:02 +0200 Subject: [PATCH 08/20] move-link-down-line, move-link-prev-line, etc.: Change mode to NAVIGATE_LINKWISE to preserve the link position when going back. (cherry picked from commit 14b37d0362f9963cb2803d08d2c3e6e84574cdbe) (cherry picked from commit a594b2a0020bb31be99bf1b9632a42ef909c5450) --- src/viewer/text/view.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 887f30169..a0ebefa43 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -201,8 +201,13 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) if (!last) last = link; else if (link->points[0].x > last->points[0].x) last = link; } - if (last) - return move_cursor_rel(ses, doc_view, last->points[0].x - x1, last->points[0].y - y1); + if (last) { + enum frame_event_status status = move_cursor_rel(ses, doc_view, + last->points[0].x - x1, last->points[0].y - y1); + + ses->navigate_mode = NAVIGATE_LINKWISE; + return status; + } } return FRAME_EVENT_OK; } @@ -245,8 +250,13 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) if (!last) last = link; else if (link->points[0].x < last->points[0].x) last = link; } - if (last) - return move_cursor_rel(ses, doc_view, last->points[0].x - x1, last->points[0].y - y1); + if (last) { + enum frame_event_status status = move_cursor_rel(ses, doc_view, + last->points[0].x - x1, last->points[0].y - y1); + + ses->navigate_mode = NAVIGATE_LINKWISE; + return status; + } } return FRAME_EVENT_OK; } @@ -708,7 +718,12 @@ move_link_vertical(struct session *ses, struct document_view *doc_view, int dir_ if (!link) continue; for (; link <= document->lines2[y]; link++) { if (link->points[0].y == y) { - return move_cursor_rel(ses, doc_view, 0, y - y1); + enum frame_event_status status = move_cursor_rel(ses, + doc_view, 0, y - y1); + + if (vs->current_link != -1) + ses->navigate_mode = NAVIGATE_LINKWISE; + return status; } } } From a282a98d4aac43e15c75e4f70b621a02ebe2ac3e Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 14 Aug 2007 20:43:22 +0200 Subject: [PATCH 09/20] Avoid segfault. Go to the page with a few lines. Follow a link to a page with more lines. Move cursor down, do not stay on a link. Go back and do move-link-prev-line. This caused a segmentation fault. (cherry picked from commit 888ba8751674471768d846ff3443aa7bb71ecf82) (cherry picked from commit 1cbd02c141a117071900a58d4c30960237d3f37f) --- src/viewer/text/view.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index a0ebefa43..8724603f4 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -189,8 +189,8 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) get_link_x_bounds(link, y1, &min_x, &max_x); } else { min_x = max_x = x1; - int_upper_bound(&y, document->height - 1); } + int_upper_bound(&y, document->height - 1); for (; y >= 0; y--, min_x = INT_MAX) { link = document->lines1[y]; @@ -238,8 +238,8 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) get_link_x_bounds(link, y1, &min_x, &max_x); } else { min_x = max_x = x1; - int_upper_bound(&y, document->height - 1); } + int_upper_bound(&y, document->height - 1); for (; y < document->height; y++, min_x = -1) { link = document->lines1[y]; From f2de26b2d56ec9b70bfa7dc6a4e538efc2396ad9 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 14 Aug 2007 21:16:16 +0200 Subject: [PATCH 10/20] Fixed the issue with multiline links. (cherry picked from commit 3555f68059035c786211a2bad38718d0c462033b) (cherry picked from commit 8863f4335f2e15cae5f424fd80ae05a6504ed914) --- src/viewer/text/view.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 8724603f4..8863137a4 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -721,7 +721,7 @@ move_link_vertical(struct session *ses, struct document_view *doc_view, int dir_ enum frame_event_status status = move_cursor_rel(ses, doc_view, 0, y - y1); - if (vs->current_link != -1) + if (link == get_current_link(doc_view)) ses->navigate_mode = NAVIGATE_LINKWISE; return status; } From 885adc7a579a460152b54eb44f491cd9382c5110 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 19 Aug 2007 13:58:30 +0200 Subject: [PATCH 11/20] move-link-prev-line .. move-link-down-line: Fixed. (cherry picked from commit bb0166279f6db9692b67914f334dc1a463ef4b4d) (cherry picked from commit 27361d141a4da9e8161017d1cba2ce6ed56636df) --- src/viewer/text/view.c | 319 ++++++++++++++++++++++++++--------------- src/viewer/text/view.h | 6 +- 2 files changed, 205 insertions(+), 120 deletions(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 8863137a4..4d8860150 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -60,9 +60,6 @@ #include "viewer/text/view.h" #include "viewer/text/vs.h" - -static enum frame_event_status move_cursor_rel(struct session *ses, struct document_view *view, int rx, int ry); - void detach_formatted(struct document_view *doc_view) { @@ -164,102 +161,6 @@ move_page_up(struct session *ses, struct document_view *doc_view) return doc_view->vs->y == oldy ? FRAME_EVENT_OK : FRAME_EVENT_REFRESH; } -enum frame_event_status -move_link_prev_line(struct session *ses, struct document_view *doc_view) -{ - struct view_state *vs; - struct document *document; - struct box *box; - struct link *link, *last = NULL; - int y1, y, min_x, max_x, x1; - - assert(ses && doc_view && doc_view->vs && doc_view->document); - if_assert_failed return FRAME_EVENT_OK; - - vs = doc_view->vs; - document = doc_view->document; - if (!document->lines1) return FRAME_EVENT_OK; - box = &doc_view->box; - - y = y1 = vs->y + ses->tab->y - box->y; - x1 = vs->x + ses->tab->x - box->x; - - link = get_current_link(doc_view); - if (link) { - get_link_x_bounds(link, y1, &min_x, &max_x); - } else { - min_x = max_x = x1; - } - int_upper_bound(&y, document->height - 1); - - for (; y >= 0; y--, min_x = INT_MAX) { - link = document->lines1[y]; - if (!link) continue; - for (; link <= document->lines2[y]; link++) { - if (link->points[0].y != y) continue; - if (link->points[0].x >= min_x) continue; - if (!last) last = link; - else if (link->points[0].x > last->points[0].x) last = link; - } - if (last) { - enum frame_event_status status = move_cursor_rel(ses, doc_view, - last->points[0].x - x1, last->points[0].y - y1); - - ses->navigate_mode = NAVIGATE_LINKWISE; - return status; - } - } - return FRAME_EVENT_OK; -} - - -enum frame_event_status -move_link_next_line(struct session *ses, struct document_view *doc_view) -{ - struct view_state *vs; - struct document *document; - struct box *box; - struct link *link, *last = NULL; - int y1, y, min_x, max_x, x1; - - assert(ses && doc_view && doc_view->vs && doc_view->document); - if_assert_failed return FRAME_EVENT_OK; - - vs = doc_view->vs; - document = doc_view->document; - if (!document->lines1) return FRAME_EVENT_OK; - box = &doc_view->box; - - y = y1 = vs->y + ses->tab->y - box->y; - x1 = vs->x + ses->tab->x - box->x; - - link = get_current_link(doc_view); - if (link) { - get_link_x_bounds(link, y1, &min_x, &max_x); - } else { - min_x = max_x = x1; - } - int_upper_bound(&y, document->height - 1); - - for (; y < document->height; y++, min_x = -1) { - link = document->lines1[y]; - if (!link) continue; - for (; link <= document->lines2[y]; link++) { - if (link->points[0].y != y) continue; - if (link->points[0].x <= min_x) continue; - if (!last) last = link; - else if (link->points[0].x < last->points[0].x) last = link; - } - if (last) { - enum frame_event_status status = move_cursor_rel(ses, doc_view, - last->points[0].x - x1, last->points[0].y - y1); - - ses->navigate_mode = NAVIGATE_LINKWISE; - return status; - } - } - return FRAME_EVENT_OK; -} enum frame_event_status move_link(struct session *ses, struct document_view *doc_view, int direction, @@ -692,41 +593,227 @@ move_cursor_down(struct session *ses, struct document_view *view) } enum frame_event_status -move_link_vertical(struct session *ses, struct document_view *doc_view, int dir_y) +move_link_up_line(struct session *ses, struct document_view *doc_view) { struct document *document; struct view_state *vs; struct box *box; - int y, y1; + int min_y, y, y1; assert(ses && doc_view && doc_view->vs && doc_view->document); if_assert_failed return FRAME_EVENT_OK; vs = doc_view->vs; document = doc_view->document; - if (!document->lines1) return FRAME_EVENT_OK; - box = &doc_view->box; - y1 = vs->y + ses->tab->y - box->y; - y = y1 + dir_y; - if (dir_y < 0) - int_upper_bound(&y, document->height - 1); - else - int_lower_bound(&y, 0); - for (; dir_y > 0 ? y < document->height : y >= 0; y += dir_y) { + if (!document->lines1) { + if (vs->y) { + vs->y -= box->height; + int_lower_bound(&vs->y, 0); + return FRAME_EVENT_REFRESH; + } + return FRAME_EVENT_OK; + } + min_y = vs->y - box->height; + int_lower_bound(&min_y, 0); + y1 = y = vs->y + ses->tab->y - box->y; + for (y--; y >= min_y; y--) { struct link *link = document->lines1[y]; if (!link) continue; for (; link <= document->lines2[y]; link++) { - if (link->points[0].y == y) { - enum frame_event_status status = move_cursor_rel(ses, - doc_view, 0, y - y1); + enum frame_event_status status; - if (link == get_current_link(doc_view)) - ses->navigate_mode = NAVIGATE_LINKWISE; - return status; + if (link->points[0].y != y) continue; + if (y < vs->y) { + int mini = int_min(box->height, vs->y); + + vs->y -= mini; + y += mini; } + status = move_cursor_rel(ses, doc_view, 0, y - y1); + if (link == get_current_link(doc_view)) + ses->navigate_mode = NAVIGATE_LINKWISE; + return status; } } + if (vs->y) { + vs->y -= box->height; + int_lower_bound(&vs->y, 0); + return FRAME_EVENT_REFRESH; + } + return FRAME_EVENT_OK; +} + +enum frame_event_status +move_link_down_line(struct session *ses, struct document_view *doc_view) +{ + struct document *document; + struct view_state *vs; + struct box *box; + int max_y, y, y1; + + assert(ses && doc_view && doc_view->vs && doc_view->document); + if_assert_failed return FRAME_EVENT_OK; + vs = doc_view->vs; + document = doc_view->document; + box = &doc_view->box; + if (!document->lines1) { + if (vs->y + box->height < document->height) { + vs->y += box->height; + return FRAME_EVENT_REFRESH; + } + return FRAME_EVENT_OK; + } + max_y = vs->y + box->height * 2 - 1; + int_upper_bound(&max_y, document->height - 1); + y1 = y = vs->y + ses->tab->y - box->y; + for (y++; y <= max_y; y++) { + struct link *link = document->lines1[y]; + + if (!link) continue; + for (; link <= document->lines2[y]; link++) { + enum frame_event_status status; + + if (link->points[0].y != y) continue; + if (y >= vs->y + box->height) { + int mini = int_min(box->height, document->height - vs->y - 1); + + vs->y += mini; + y -= mini; + } + status = move_cursor_rel(ses, doc_view, 0, y - y1); + if (link == get_current_link(doc_view)) + ses->navigate_mode = NAVIGATE_LINKWISE; + return status; + } + } + if (vs->y + box->height < document->height) { + vs->y += box->height; + return FRAME_EVENT_REFRESH; + } + return FRAME_EVENT_OK; +} + +enum frame_event_status +move_link_prev_line(struct session *ses, struct document_view *doc_view) +{ + struct view_state *vs; + struct document *document; + struct box *box; + struct link *link, *last = NULL; + int y1, y, min_y, min_x, max_x, x1; + + assert(ses && doc_view && doc_view->vs && doc_view->document); + if_assert_failed return FRAME_EVENT_OK; + + vs = doc_view->vs; + document = doc_view->document; + if (!document->lines1) return FRAME_EVENT_OK; + box = &doc_view->box; + + y = y1 = vs->y + ses->tab->y - box->y; + x1 = vs->x + ses->tab->x - box->x; + + link = get_current_link(doc_view); + if (link) { + get_link_x_bounds(link, y1, &min_x, &max_x); + } else { + min_x = max_x = x1; + } + int_upper_bound(&y, document->height - 1); + min_y = int_min(0, vs->y - box->height); + + for (; y >= min_y; y--, min_x = INT_MAX) { + link = document->lines1[y]; + if (!link) continue; + for (; link <= document->lines2[y]; link++) { + if (link->points[0].y != y) continue; + if (link->points[0].x >= min_x) continue; + if (!last) last = link; + else if (link->points[0].x > last->points[0].x) last = link; + } + if (last) { + enum frame_event_status status; + + y = last->points[0].y; + if (y < vs->y) { + int mini = int_min(box->height, vs->y); + + vs->y -= mini; + y += mini; + } + status = move_cursor_rel(ses, doc_view, last->points[0].x - x1, y - y1); + if (link == get_current_link(doc_view)) + ses->navigate_mode = NAVIGATE_LINKWISE; + return status; + } + } + if (vs->y) { + vs->y -= box->height; + int_lower_bound(&vs->y, 0); + return FRAME_EVENT_REFRESH; + } + return FRAME_EVENT_OK; +} + +enum frame_event_status +move_link_next_line(struct session *ses, struct document_view *doc_view) +{ + struct view_state *vs; + struct document *document; + struct box *box; + struct link *link, *last = NULL; + int y1, y, max_y, min_x, max_x, x1; + + assert(ses && doc_view && doc_view->vs && doc_view->document); + if_assert_failed return FRAME_EVENT_OK; + + vs = doc_view->vs; + document = doc_view->document; + if (!document->lines1) return FRAME_EVENT_OK; + box = &doc_view->box; + + y = y1 = vs->y + ses->tab->y - box->y; + x1 = vs->x + ses->tab->x - box->x; + + link = get_current_link(doc_view); + if (link) { + get_link_x_bounds(link, y1, &min_x, &max_x); + } else { + min_x = max_x = x1; + } + int_upper_bound(&y, document->height - 1); + max_y = int_min(vs->y + 2 * box->height - 1, document->height - 1); + + for (; y <= max_y; y++, min_x = -1) { + link = document->lines1[y]; + if (!link) continue; + for (; link <= document->lines2[y]; link++) { + if (link->points[0].y != y) continue; + if (link->points[0].x <= min_x) continue; + if (!last) last = link; + else if (link->points[0].x < last->points[0].x) last = link; + } + if (last) { + enum frame_event_status status; + + y = last->points[0].y; + if (y >= vs->y + box->height) { + int mini = int_min(box->height, document->height - vs->y - 1); + + vs->y += mini; + y -= mini; + } + status = move_cursor_rel(ses, doc_view, last->points[0].x - x1, y - y1); + if (link == get_current_link(doc_view)) + ses->navigate_mode = NAVIGATE_LINKWISE; + return status; + } + } + if (vs->y + box->height < document->height) { + vs->y += box->height; + return FRAME_EVENT_REFRESH; + } return FRAME_EVENT_OK; } diff --git a/src/viewer/text/view.h b/src/viewer/text/view.h index ad9049bdd..1262ee376 100644 --- a/src/viewer/text/view.h +++ b/src/viewer/text/view.h @@ -32,10 +32,8 @@ enum frame_event_status move_link_dir(struct session *ses, struct document_view enum frame_event_status move_link_prev_line(struct session *ses, struct document_view *doc_view); enum frame_event_status move_link_next_line(struct session *ses, struct document_view *doc_view); -enum frame_event_status move_link_vertical(struct session *ses, struct document_view *doc_view, int dir_y); - -#define move_link_up_line(ses, doc_view) move_link_vertical(ses, doc_view, -1) -#define move_link_down_line(ses, doc_view) move_link_vertical(ses, doc_view, 1) +enum frame_event_status move_link_up_line(struct session *ses, struct document_view *doc_view); +enum frame_event_status move_link_down_line(struct session *ses, struct document_view *doc_view); enum frame_event_status scroll_up(struct session *ses, struct document_view *doc_view); enum frame_event_status scroll_down(struct session *ses, struct document_view *doc_view); From 175f355320bb3b6b2565869325abaea0900398b2 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 19 Aug 2007 20:46:32 +0200 Subject: [PATCH 12/20] move-link-prev-line: Really fixed. (cherry picked from commit 052f7a93bb4548b858bf8832a87a595f9d630b48) (cherry picked from commit 1a9112945b273e562474e13c5bd6dba572cf58e4) --- src/viewer/text/view.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 4d8860150..7378a6e74 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -708,9 +708,15 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) vs = doc_view->vs; document = doc_view->document; - if (!document->lines1) return FRAME_EVENT_OK; box = &doc_view->box; - + if (!document->lines1) { + if (vs->y) { + vs->y -= box->height; + int_lower_bound(&vs->y, 0); + return FRAME_EVENT_REFRESH; + } + return FRAME_EVENT_OK; + } y = y1 = vs->y + ses->tab->y - box->y; x1 = vs->x + ses->tab->x - box->x; @@ -721,7 +727,7 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) min_x = max_x = x1; } int_upper_bound(&y, document->height - 1); - min_y = int_min(0, vs->y - box->height); + min_y = int_max(0, vs->y - box->height); for (; y >= min_y; y--, min_x = INT_MAX) { link = document->lines1[y]; @@ -770,9 +776,14 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) vs = doc_view->vs; document = doc_view->document; - if (!document->lines1) return FRAME_EVENT_OK; box = &doc_view->box; - + if (!document->lines1) { + if (vs->y + box->height < document->height) { + vs->y += box->height; + return FRAME_EVENT_REFRESH; + } + return FRAME_EVENT_OK; + } y = y1 = vs->y + ses->tab->y - box->y; x1 = vs->x + ses->tab->x - box->x; From d1d8c0632a0e3bee5496fe9dcf9cd0ad900e72bc Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Mon, 20 Aug 2007 09:01:49 +0200 Subject: [PATCH 13/20] move-link-up-line: segfault when cursor was below last line. (cherry picked from commit c646c860cdb4ba641bd36f0469b752fec93962fd) (cherry picked from commit 9561d8d0fd0a134e6dbdd463b4d0f3924e5a0a61) --- src/viewer/text/view.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 7378a6e74..b32b87ffa 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -616,6 +616,7 @@ move_link_up_line(struct session *ses, struct document_view *doc_view) min_y = vs->y - box->height; int_lower_bound(&min_y, 0); y1 = y = vs->y + ses->tab->y - box->y; + int_upper_bound(&y, document->height - 1); for (y--; y >= min_y; y--) { struct link *link = document->lines1[y]; From d358810a5f421f63c50205bafc99fff05bc8d470 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Mon, 20 Aug 2007 09:38:38 +0200 Subject: [PATCH 14/20] move-link-prev(next)-line: Typo with cut-n-paste. s/line/last/. (cherry picked from commit 848852b75f93aae3d86c565f09283bc3e579fb2b) (cherry picked from commit 64c385f0db8dcff54b526a6ca5c3cc0ed0c79007) --- src/viewer/text/view.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index b32b87ffa..295faac49 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -750,7 +750,7 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) y += mini; } status = move_cursor_rel(ses, doc_view, last->points[0].x - x1, y - y1); - if (link == get_current_link(doc_view)) + if (last == get_current_link(doc_view)) ses->navigate_mode = NAVIGATE_LINKWISE; return status; } @@ -817,7 +817,7 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) y -= mini; } status = move_cursor_rel(ses, doc_view, last->points[0].x - x1, y - y1); - if (link == get_current_link(doc_view)) + if (last == get_current_link(doc_view)) ses->navigate_mode = NAVIGATE_LINKWISE; return status; } From 61eb46e94de47003fea50dec47586f09a96a96e5 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 23 Aug 2007 20:05:07 +0200 Subject: [PATCH 15/20] New action: move-cursor-line-start. It moves cursor to the start of the line. (cherry picked from commit 5ee1d3b2b39ea958f2a77300d326117e88f80c7a) (cherry picked from commit 3a87ec55fc8ddb10d535e573bf1852aa17f9fd44) --- src/config/actions-main.inc | 1 + src/viewer/action.c | 4 ++++ src/viewer/text/view.c | 16 ++++++++++++++++ src/viewer/text/view.h | 2 ++ 4 files changed, 23 insertions(+) diff --git a/src/config/actions-main.inc b/src/config/actions-main.inc index a5de82fc0..331af947f 100644 --- a/src/config/actions-main.inc +++ b/src/config/actions-main.inc @@ -54,6 +54,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 9f7231a19..b24979f1f 100644 --- a/src/viewer/action.c +++ b/src/viewer/action.c @@ -356,6 +356,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 295faac49..c7de6d60a 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); From 617e33187d7634bde33c85716ed38ae72f222749 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Mon, 27 Aug 2007 21:14:56 +0200 Subject: [PATCH 16/20] move-link-up-line and others: changed mode to NAVIGATE_CURSOR_ROUTING when there is no link. (cherry picked from commit 7db2f8c629ab4ab84016466813d38670bb4b3108) (cherry picked from commit f62eca8d928383b5f94062df904f905426854d5a) --- src/viewer/text/view.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index c7de6d60a..cafebf38e 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -640,6 +640,7 @@ move_link_up_line(struct session *ses, struct document_view *doc_view) if (vs->y) { vs->y -= box->height; int_lower_bound(&vs->y, 0); + ses->navigate_mode = NAVIGATE_CURSOR_ROUTING; return FRAME_EVENT_REFRESH; } return FRAME_EVENT_OK; @@ -690,6 +691,7 @@ move_link_down_line(struct session *ses, struct document_view *doc_view) } if (vs->y + box->height < document->height) { vs->y += box->height; + ses->navigate_mode = NAVIGATE_CURSOR_ROUTING; return FRAME_EVENT_REFRESH; } return FRAME_EVENT_OK; @@ -758,6 +760,7 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) if (vs->y) { vs->y -= box->height; int_lower_bound(&vs->y, 0); + ses->navigate_mode = NAVIGATE_CURSOR_ROUTING; return FRAME_EVENT_REFRESH; } return FRAME_EVENT_OK; @@ -824,6 +827,7 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) } if (vs->y + box->height < document->height) { vs->y += box->height; + ses->navigate_mode = NAVIGATE_CURSOR_ROUTING; return FRAME_EVENT_REFRESH; } return FRAME_EVENT_OK; From f33b7dea02847ae10ee9ad340099cfe067a0eed8 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 7 Oct 2007 15:50:08 +0200 Subject: [PATCH 17/20] Removed not existent function. Spotted by Kalle. (cherry picked from commit a76ecfb8ca049945a960500ae49b9fe398596068) (cherry picked from commit 54cf868429a2e5d13523bb7af3bd72a9f2e1a8fa) --- src/viewer/text/link.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/viewer/text/link.h b/src/viewer/text/link.h index 07502fe9f..2f68b405f 100644 --- a/src/viewer/text/link.h +++ b/src/viewer/text/link.h @@ -43,7 +43,6 @@ int current_link_is_visible(struct document_view *doc_view); int next_link_in_view(struct document_view *doc_view, int current, int direction); int next_link_in_view_y(struct document_view *doc_view, int current, int direction); int next_link_in_dir(struct document_view *doc_view, int dir_x, int dir_y); -int next_link_vertical(struct session *ses, struct document_view *doc_view, int dir_y); void jump_to_link_number(struct session *ses, struct document_view *doc_view, int); From 04387d8d6cece2c9b4af9dfa59eb08f4e97aec82 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 7 Oct 2007 16:10:26 +0200 Subject: [PATCH 18/20] Added function move_cursor_rel_count and used it in move-link-left-line and others, so move-link-left-line ans others do not use the keyboard prefix. (cherry picked from commit 8b281e1404048fe2b6bfd542a1689286ee894f78) (cherry picked from commit 4f2a9eadfcf1d87f2cf75d2c38675e1eabde6e20) --- src/viewer/text/view.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index cafebf38e..bbf44ad92 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -555,19 +555,27 @@ move_cursor(struct session *ses, struct document_view *doc_view, int x, int y) } static enum frame_event_status -move_cursor_rel(struct session *ses, struct document_view *view, - int rx, int ry) +move_cursor_rel_count(struct session *ses, struct document_view *view, + int rx, int ry, int count) { - int count = eat_kbd_repeat_count(ses); int x, y; - int_lower_bound(&count, 1); - x = ses->tab->x + rx*count; y = ses->tab->y + ry*count; return move_cursor(ses, view, x, y); } +static enum frame_event_status +move_cursor_rel(struct session *ses, struct document_view *view, + int rx, int ry) +{ + int count = eat_kbd_repeat_count(ses); + + int_lower_bound(&count, 1); + + return move_cursor_rel_count(ses, view, rx, ry, count); +} + enum frame_event_status move_cursor_left(struct session *ses, struct document_view *view) { @@ -631,7 +639,7 @@ move_link_up_line(struct session *ses, struct document_view *doc_view) vs->y -= mini; y += mini; } - status = move_cursor_rel(ses, doc_view, 0, y - y1); + status = move_cursor_rel_count(ses, doc_view, 0, y - y1, 1); if (link == get_current_link(doc_view)) ses->navigate_mode = NAVIGATE_LINKWISE; return status; @@ -683,7 +691,7 @@ move_link_down_line(struct session *ses, struct document_view *doc_view) vs->y += mini; y -= mini; } - status = move_cursor_rel(ses, doc_view, 0, y - y1); + status = move_cursor_rel_count(ses, doc_view, 0, y - y1, 1); if (link == get_current_link(doc_view)) ses->navigate_mode = NAVIGATE_LINKWISE; return status; @@ -751,7 +759,7 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) vs->y -= mini; y += mini; } - status = move_cursor_rel(ses, doc_view, last->points[0].x - x1, y - y1); + status = move_cursor_rel_count(ses, doc_view, last->points[0].x - x1, y - y1, 1); if (last == get_current_link(doc_view)) ses->navigate_mode = NAVIGATE_LINKWISE; return status; @@ -819,7 +827,7 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) vs->y += mini; y -= mini; } - status = move_cursor_rel(ses, doc_view, last->points[0].x - x1, y - y1); + status = move_cursor_rel_count(ses, doc_view, last->points[0].x - x1, y - y1, 1); if (last == get_current_link(doc_view)) ses->navigate_mode = NAVIGATE_LINKWISE; return status; From a307371d9e3e6656f57dbc04e2b37bed8e48a73a Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 25 Nov 2007 22:20:18 +0200 Subject: [PATCH 19/20] Comments about arithmetic in scrolling. (cherry picked from commit 4871ad06432a16283bca929a4109d7b919367fc1) --- src/viewer/text/view.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index bbf44ad92..407be69af 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -634,8 +634,19 @@ move_link_up_line(struct session *ses, struct document_view *doc_view) if (link->points[0].y != y) continue; if (y < vs->y) { + /* The line is above the visible part + * of the document. Scroll it by one + * page, but not at all past the + * beginning of the document. */ int mini = int_min(box->height, vs->y); + /* Before this update, y is the line + * number in the document, and y - y1 + * is the number of lines the cursor + * must move in the document. + * Afterwards, y does not make sense, + * but y - y1 is the number of lines + * the cursor must move on the screen. */ vs->y -= mini; y += mini; } @@ -686,8 +697,19 @@ move_link_down_line(struct session *ses, struct document_view *doc_view) if (link->points[0].y != y) continue; if (y >= vs->y + box->height) { + /* The line is below the visible part + * of the document. Scroll it by one + * page, but keep at least one line of + * the document on the screen. */ int mini = int_min(box->height, document->height - vs->y - 1); + /* Before this update, y is the line + * number in the document, and y - y1 + * is the number of lines the cursor + * must move in the document. + * Afterwards, y does not make sense, + * but y - y1 is the number of lines + * the cursor must move on the screen. */ vs->y += mini; y -= mini; } @@ -754,8 +776,19 @@ move_link_prev_line(struct session *ses, struct document_view *doc_view) y = last->points[0].y; if (y < vs->y) { + /* The line is above the visible part + * of the document. Scroll it by one + * page, but not at all past the + * beginning of the document. */ int mini = int_min(box->height, vs->y); + /* Before this update, y is the line + * number in the document, and y - y1 + * is the number of lines the cursor + * must move in the document. + * Afterwards, y does not make sense, + * but y - y1 is the number of lines + * the cursor must move on the screen. */ vs->y -= mini; y += mini; } @@ -822,8 +855,19 @@ move_link_next_line(struct session *ses, struct document_view *doc_view) y = last->points[0].y; if (y >= vs->y + box->height) { + /* The line is below the visible part + * of the document. Scroll it by one + * page, but keep at least one line of + * the document on the screen. */ int mini = int_min(box->height, document->height - vs->y - 1); + /* Before this update, y is the line + * number in the document, and y - y1 + * is the number of lines the cursor + * must move in the document. + * Afterwards, y does not make sense, + * but y - y1 is the number of lines + * the cursor must move on the screen. */ vs->y += mini; y -= mini; } From 654108c4f961deabf71a97d4ed612809cef5c5f9 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 25 Nov 2007 22:24:35 +0200 Subject: [PATCH 20/20] NEWS: Mention the five new move-* actions. --- NEWS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d6d0015b2..eca1a50f0 100644 --- a/NEWS +++ b/NEWS @@ -100,7 +100,10 @@ Miscellaneous: * enhancement 887: ``Save'' in the cookie manager now saves cookies even if unmodified * enhancement 145: internal clipboard support -* enhancement: new actions kill-word-back, move-backward-word, +* enhancement: new main actions move-cursor-line-start, + move-link-down-line, move-link-left-line, move-link-right-line, + move-link-up-line +* enhancement: new edit actions kill-word-back, move-backward-word, move-forward-word * enhancements 687, 688: options ui.tabs.top, ui.show_menu_bar_always * enhancement: highlight links as one enters link prefixes