ELinks 0.18.0
link.c File Reference
#include <stdlib.h>
#include <string.h>
#include "elinks.h"
#include "bfu/listmenu.h"
#include "bfu/menu.h"
#include "bfu/style.h"
#include "dialogs/menu.h"
#include "dialogs/status.h"
#include "document/document.h"
#include "document/forms.h"
#include "document/html/iframes.h"
#include "document/html/renderer.h"
#include "document/options.h"
#include "document/view.h"
#include "intl/libintl.h"
#include "main/object.h"
#include "protocol/uri.h"
#include "session/session.h"
#include "session/task.h"
#include "terminal/color.h"
#include "terminal/draw.h"
#include "terminal/kbd.h"
#include "terminal/screen.h"
#include "terminal/tab.h"
#include "terminal/terminal.h"
#include "util/box.h"
#include "util/conv.h"
#include "util/error.h"
#include "util/memory.h"
#include "util/string.h"
#include "viewer/action.h"
#include "viewer/text/form.h"
#include "viewer/text/link.h"
#include "viewer/text/search.h"
#include "viewer/text/textarea.h"
#include "viewer/text/view.h"
#include "viewer/text/vs.h"
Include dependency graph for link.c:

Macros

#define current_link_hover(dv)
 
#define current_link_blur(dv)
 

Functions

int current_link_evhook (struct document_view *doc_view, enum script_event_hook_type type)
 
void set_link (struct document_view *doc_view)
 
static int get_link_cursor_offset (struct document_view *doc_view, struct link *link)
 
static struct screen_charinit_link_drawing (struct document_view *doc_view, struct link *link, int invert, int input)
 Initialise a static template character with the colour and attributes appropriate for an active link and return that character.
 
void draw_current_link (struct session *ses, struct document_view *doc_view)
 Give the current link the appropriate colour and attributes.
 
static void draw_link (struct terminal *term, struct document_view *doc_view, struct link *link)
 
void clear_link (struct terminal *term, struct document_view *doc_view)
 Restore the colours and attributes that the active link had before it was selected.
 
void highlight_links_with_prefixes_that_start_with_n (struct terminal *term, struct document_view *doc_view, int n)
 
struct linkget_first_link (struct document_view *doc_view)
 
struct linkget_last_link (struct document_view *doc_view)
 
static int link_in_view_x (struct document_view *doc_view, struct link *link)
 
static int link_in_view_y (struct document_view *doc_view, struct link *link)
 
static int link_in_view (struct document_view *doc_view, struct link *link)
 
int current_link_is_visible (struct document_view *doc_view)
 
static void get_visible_links_range (struct document_view *doc_view, int *first, int *last)
 Look for the first and the last link currently visible in our viewport.
 
static int next_link_in_view_ (struct document_view *doc_view, int current, int direction, int(*fn)(struct document_view *, struct link *), void(*cntr)(struct document_view *, struct link *))
 
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)
 
void get_link_x_bounds (struct link *link, int y, int *min_x, int *max_x)
 Get the bounding columns of link at line y (or all lines if y == -1).
 
static int get_link_x_intersect (struct link *link, int y, int min_x, int max_x)
 Check whether there is any point between min_x and max_x at the line y in link link.
 
static int get_link_y_intersect (struct link *link, int x, int min_y, int max_y)
 Check whether there is any point between min_y and max_y in the column x in link link.
 
int next_link_in_dir (struct document_view *doc_view, int dir_x, int dir_y)
 
void set_pos_x (struct document_view *doc_view, struct link *link)
 
void set_pos_y (struct document_view *doc_view, struct link *link)
 
static void find_link (struct document_view *doc_view, int direction, int page_mode)
 Focus the next link in the specified direction.
 
void find_link_up (struct document_view *doc_view)
 
void find_link_page_up (struct document_view *doc_view)
 
void find_link_down (struct document_view *doc_view)
 
void find_link_page_down (struct document_view *doc_view)
 
struct uriget_link_uri (struct session *ses, struct document_view *doc_view, struct link *link)
 
static int call_onsubmit_and_submit (struct session *ses, struct document_view *doc_view, struct el_form_control *fc, int do_reload)
 
struct linkgoto_link (struct session *ses, struct document_view *doc_view, struct link *link, int do_reload)
 
struct linkgoto_current_link (struct session *ses, struct document_view *doc_view, int do_reload)
 
static enum frame_event_status activate_link (struct session *ses, struct document_view *doc_view, struct link *link, int do_reload)
 
enum frame_event_status enter (struct session *ses, struct document_view *doc_view, int do_reload)
 
struct linkget_link_at_coordinates (struct document_view *doc_view, int x, int y)
 Get the link at the coordinates x and y, or NULL if none.
 
void jump_to_link_number (struct session *ses, struct document_view *doc_view, int n)
 This is backend of the backend goto_link_number_do() below ;)).
 
static void goto_link_number_do (struct session *ses, struct document_view *doc_view, int n)
 This is common backend for goto_link_number() and try_document_key().
 
void goto_link_number (struct session *ses, char *num)
 
void goto_link_symbol (struct session *ses, char *sym)
 
enum frame_event_status try_document_key (struct session *ses, struct document_view *doc_view, struct term_event *ev)
 See if this document is interested in the key user pressed.
 
void link_menu (struct terminal *term, void *xxx, void *ses_)
 Open a contextual menu on a link, form or image element.
 
char * get_current_link_title (struct document_view *doc_view)
 Return current link's title.
 
char * get_current_link_info (struct session *ses, struct document_view *doc_view)
 

Macro Definition Documentation

◆ current_link_blur

#define current_link_blur ( dv)
Value:
do { \
current_link_evhook(dv, SEVHOOK_ONMOUSEOUT); \
current_link_evhook(dv, SEVHOOK_ONBLUR); \
} while (0)
@ SEVHOOK_ONBLUR
Definition document.h:101
@ SEVHOOK_ONMOUSEOUT
Definition document.h:100

◆ current_link_hover

#define current_link_hover ( dv)
Value:
do { \
current_link_evhook(dv, SEVHOOK_ONMOUSEOVER); \
current_link_evhook(dv, SEVHOOK_ONHOVER); \
current_link_evhook(dv, SEVHOOK_ONFOCUS); \
} while (0)
@ SEVHOOK_ONFOCUS
Definition document.h:99
@ SEVHOOK_ONHOVER
Definition document.h:98
@ SEVHOOK_ONMOUSEOVER
Definition document.h:97

Function Documentation

◆ activate_link()

static enum frame_event_status activate_link ( struct session * ses,
struct document_view * doc_view,
struct link * link,
int do_reload )
static

◆ call_onsubmit_and_submit()

static int call_onsubmit_and_submit ( struct session * ses,
struct document_view * doc_view,
struct el_form_control * fc,
int do_reload )
static

◆ clear_link()

void clear_link ( struct terminal * term,
struct document_view * doc_view )

Restore the colours and attributes that the active link had before it was selected.

◆ current_link_evhook()

int current_link_evhook ( struct document_view * doc_view,
enum script_event_hook_type type )

◆ current_link_is_visible()

int current_link_is_visible ( struct document_view * doc_view)

◆ draw_current_link()

void draw_current_link ( struct session * ses,
struct document_view * doc_view )

Give the current link the appropriate colour and attributes.

◆ draw_link()

static void draw_link ( struct terminal * term,
struct document_view * doc_view,
struct link * link )
static

◆ enter()

enum frame_event_status enter ( struct session * ses,
struct document_view * doc_view,
int do_reload )

◆ find_link()

static void find_link ( struct document_view * doc_view,
int direction,
int page_mode )
static

Focus the next link in the specified direction.

direction == 1 -> DOWN; direction == -1 -> UP

◆ find_link_down()

void find_link_down ( struct document_view * doc_view)

◆ find_link_page_down()

void find_link_page_down ( struct document_view * doc_view)

◆ find_link_page_up()

void find_link_page_up ( struct document_view * doc_view)

◆ find_link_up()

void find_link_up ( struct document_view * doc_view)

◆ get_current_link_info()

char * get_current_link_info ( struct session * ses,
struct document_view * doc_view )
Todo
TODO: Provide info about script event hooks too. –pasky

◆ get_current_link_title()

char * get_current_link_title ( struct document_view * doc_view)

Return current link's title.

◆ get_first_link()

struct link * get_first_link ( struct document_view * doc_view)

◆ get_last_link()

struct link * get_last_link ( struct document_view * doc_view)

◆ get_link_at_coordinates()

struct link * get_link_at_coordinates ( struct document_view * doc_view,
int x,
int y )

Get the link at the coordinates x and y, or NULL if none.

The coordinates are relative to the document view; not to the terminal, nor to the document. So (0, 0) means whatever part of the document has been scrolled to the top left corner of the document view.

◆ get_link_cursor_offset()

static int get_link_cursor_offset ( struct document_view * doc_view,
struct link * link )
inlinestatic

◆ get_link_uri()

struct uri * get_link_uri ( struct session * ses,
struct document_view * doc_view,
struct link * link )

◆ get_link_x_bounds()

void get_link_x_bounds ( struct link * link,
int y,
int * min_x,
int * max_x )

Get the bounding columns of link at line y (or all lines if y == -1).

◆ get_link_x_intersect()

static int get_link_x_intersect ( struct link * link,
int y,
int min_x,
int max_x )
static

Check whether there is any point between min_x and max_x at the line y in link link.

◆ get_link_y_intersect()

static int get_link_y_intersect ( struct link * link,
int x,
int min_y,
int max_y )
static

Check whether there is any point between min_y and max_y in the column x in link link.

◆ get_visible_links_range()

static void get_visible_links_range ( struct document_view * doc_view,
int * first,
int * last )
static

Look for the first and the last link currently visible in our viewport.

◆ goto_current_link()

struct link * goto_current_link ( struct session * ses,
struct document_view * doc_view,
int do_reload )

◆ goto_link()

struct link * goto_link ( struct session * ses,
struct document_view * doc_view,
struct link * link,
int do_reload )

◆ goto_link_number()

void goto_link_number ( struct session * ses,
char * num )

◆ goto_link_number_do()

static void goto_link_number_do ( struct session * ses,
struct document_view * doc_view,
int n )
static

This is common backend for goto_link_number() and try_document_key().

◆ goto_link_symbol()

void goto_link_symbol ( struct session * ses,
char * sym )

◆ highlight_links_with_prefixes_that_start_with_n()

void highlight_links_with_prefixes_that_start_with_n ( struct terminal * term,
struct document_view * doc_view,
int n )

◆ init_link_drawing()

static struct screen_char * init_link_drawing ( struct document_view * doc_view,
struct link * link,
int invert,
int input )
inlinestatic

Initialise a static template character with the colour and attributes appropriate for an active link and return that character.

◆ jump_to_link_number()

void jump_to_link_number ( struct session * ses,
struct document_view * doc_view,
int n )

This is backend of the backend goto_link_number_do() below ;)).

◆ link_in_view()

static int link_in_view ( struct document_view * doc_view,
struct link * link )
static

◆ link_in_view_x()

static int link_in_view_x ( struct document_view * doc_view,
struct link * link )
static

◆ link_in_view_y()

static int link_in_view_y ( struct document_view * doc_view,
struct link * link )
static

◆ link_menu()

void link_menu ( struct terminal * term,
void * xxx,
void * ses_ )

Open a contextual menu on a link, form or image element.

Todo
TODO: This should be completely configurable.
Todo
TODO: Make it possible to trigger any script event hooks associated to the link. –pasky

◆ next_link_in_dir()

int next_link_in_dir ( struct document_view * doc_view,
int dir_x,
int dir_y )

◆ next_link_in_view()

int next_link_in_view ( struct document_view * doc_view,
int current,
int direction )

◆ next_link_in_view_()

static int next_link_in_view_ ( struct document_view * doc_view,
int current,
int direction,
int(* fn )(struct document_view *, struct link *),
void(* cntr )(struct document_view *, struct link *) )
static

◆ next_link_in_view_y()

int next_link_in_view_y ( struct document_view * doc_view,
int current,
int direction )

◆ set_link()

void set_link ( struct document_view * doc_view)

◆ set_pos_x()

void set_pos_x ( struct document_view * doc_view,
struct link * link )

◆ set_pos_y()

void set_pos_y ( struct document_view * doc_view,
struct link * link )

◆ try_document_key()

enum frame_event_status try_document_key ( struct session * ses,
struct document_view * doc_view,
struct term_event * ev )

See if this document is interested in the key user pressed.