Thanks for the patch. Works great. I have a new problem though. I updated my
elinks from the git and now the alt-keys does not work. If I run my old elinks,
all the alt-key commands work fine, but not with the new one. Also, please send
me your paypal billing at myself at ligesh.com.
Can you also implement a key to take the cursor to the start of line. Like you
have in VIM with '0'. Press 0 and the cursor moves to the start of line. DOes
this already exist in Elinks?
Thanks.
On Sat, Aug 11, 2007 at 11:10:52PM +0200, Witold Filipczyk wrote:
> Use the patch from the attachment for ELinks-0.12.GIT. I hope it works as
> expected.
> I have no write permission to the main branch, so you must ask someone to
> commit it.
> --
> Witek
> 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.
>
> ---
> commit 7882384bce49ab8d09e4c6d7a4b7b0eb0c945797
> tree a8b3e69e402f3f5fe74f4676e196d5af83f9d536
> parent ee83dca303963e26f5811fab895283e2e70cd2b9
> author Witold Filipczyk <[EMAIL PROTECTED]> Sat, 11 Aug 2007 23:06:10 +0200
> committer Witold Filipczyk <[EMAIL PROTECTED]> Sat, 11 Aug 2007 23:06:10 +0200
>
> 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 939943d..a62adcd 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 662dd50..4ebc99b 100644
> --- a/src/viewer/action.c
> +++ b/src/viewer/action.c
> @@ -361,10 +361,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;
> @@ -377,10 +385,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 48adf91..30e1734 100644
> --- a/src/viewer/text/link.c
> +++ b/src/viewer/text/link.c
> @@ -552,7 +552,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 1e20434..a3ffe2e 100644
> --- a/src/viewer/text/link.h
> +++ b/src/viewer/text/link.h
> @@ -45,11 +45,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 238ca2e..c985c5d 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)
> @@ -164,6 +165,91 @@ move_page_up(struct session *ses, struct document_view
> *doc_view)
> }
>
> 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 e87fae6..ad9049b 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);
> _______________________________________________
> elinks-dev mailing list
> [email protected]
> http://linuxfromscratch.org/mailman/listinfo/elinks-dev
_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev