NetSurf
Data Structures | Functions | Variables
local_history.c File Reference

Local history viewer implementation. More...

#include <stdlib.h>
#include <string.h>
#include "utils/nsurl.h"
#include "utils/errors.h"
#include "netsurf/types.h"
#include "netsurf/layout.h"
#include "netsurf/browser_window.h"
#include "netsurf/core_window.h"
#include "netsurf/plotters.h"
#include "netsurf/keypress.h"
#include "utils/nscolour.h"
#include "desktop/cw_helper.h"
#include "desktop/gui_internal.h"
#include "desktop/system_colour.h"
#include "desktop/browser_private.h"
#include "desktop/browser_history.h"
#include "desktop/local_history_private.h"
#include "desktop/local_history.h"
Include dependency graph for local_history.c:

Go to the source code of this file.

Data Structures

struct  local_history_session
 local history viewer context More...
 

Functions

static nserror redraw_entry (struct history *history, struct history_entry *entry, struct history_entry *cursor, struct rect *clip, int x, int y, const struct redraw_context *ctx)
 Recursively redraw a history entry. More...
 
static struct history_entryfind_entry_position (struct history_entry *entry, int x, int y)
 Find the history entry at a position. More...
 
nserror local_history_scroll_to_cursor (struct local_history_session *session)
 Scroll the local history window to ensure the current cursor is shown. More...
 
nserror local_history_init (struct core_window_callback_table *cw_t, void *core_window_handle, struct browser_window *bw, struct local_history_session **session)
 Initialise the local history. More...
 
nserror local_history_fini (struct local_history_session *session)
 Finalise the local history. More...
 
nserror local_history_redraw (struct local_history_session *session, int x, int y, struct rect *clip, const struct redraw_context *ctx)
 Redraw the local history. More...
 
nserror local_history_mouse_action (struct local_history_session *session, enum browser_mouse_state mouse, int x, int y)
 Handles all kinds of mouse action. More...
 
static void _local_history_find_branch_point (struct history_entry *ent, struct history_entry **branch_point)
 Determine the point on the parent line where this history line branches. More...
 
bool local_history_keypress (struct local_history_session *session, uint32_t key)
 Key press handling. More...
 
nserror local_history_set (struct local_history_session *session, struct browser_window *bw)
 Change the browser window to draw local history for. More...
 
nserror local_history_get_size (struct local_history_session *session, int *width, int *height)
 get size of local history content area. More...
 
nserror local_history_get_url (struct local_history_session *session, int x, int y, nsurl **url_out)
 get url of entry at position in local history content area. More...
 

Variables

static plot_style_t pstyle_line
 plot style for drawing lines between nodes More...
 
static plot_style_t pstyle_bg
 plot style for drawing background More...
 
static plot_style_t pstyle_rect
 plot style for drawing rectangle round unselected nodes More...
 
static plot_style_t pstyle_rect_sel
 plot style for drawing rectangle round selected nodes More...
 
static plot_style_t pstyle_rect_cursor
 plot style for drawing rectangle round the cursor node More...
 
static plot_font_style_t pfstyle_node
 plot style for font on unselected nodes More...
 
static plot_font_style_t pfstyle_node_sel
 plot style for font on unselected nodes More...
 

Detailed Description

Local history viewer implementation.

Definition in file local_history.c.

Function Documentation

◆ _local_history_find_branch_point()

static void _local_history_find_branch_point ( struct history_entry ent,
struct history_entry **  branch_point 
)
static

Determine the point on the parent line where this history line branches.

If branch_point gets set then there is a guarantee that (a) ent is a transitive child (forward) of that point. and (b) branch_point has a parent.

Parameters
[in]entThe entry to work backward from
[out]branch_pointThe entry to set to the branch point if one is found

Definition at line 441 of file local_history.c.

References history_entry::back, history_entry::forward, and history_entry::forward_last.

Referenced by local_history_keypress().

Here is the caller graph for this function:

◆ find_entry_position()

static struct history_entry * find_entry_position ( struct history_entry entry,
int  x,
int  y 
)
static

Find the history entry at a position.

Parameters
entryentry to search from
xcoordinate
ycoordinate
Returns
an entry if found, 0 if none

Definition at line 262 of file local_history.c.

References find_entry_position(), history_entry::forward, LOCAL_HISTORY_HEIGHT, LOCAL_HISTORY_WIDTH, history_entry::next, history_entry::x, and history_entry::y.

Referenced by find_entry_position(), local_history_get_url(), and local_history_mouse_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ local_history_fini()

nserror local_history_fini ( struct local_history_session session)

Finalise the local history.

This destroys the local history view and the local history module's internal data. After calling this if local history is required again, local_history_init must be called to create a new session.

Parameters
sessionThe local history session to finalise.
Returns
NSERROR_OK on success and session freed appropriate error otherwise

Definition at line 347 of file local_history.c.

References NSERROR_OK.

Referenced by ami_history_local_destroy(), fb_local_history_destroy(), nsgtk_local_history_destroy(), nsw32_local_history_finalise(), and ro_gui_local_history_finalise().

Here is the caller graph for this function:

◆ local_history_get_size()

nserror local_history_get_size ( struct local_history_session session,
int *  width,
int *  height 
)

get size of local history content area.

Parameters
[in]sessionThe local history session context.
[out]widthon sucessful return the width of the localhistory content
[out]heighton sucessful return the height of the localhistory content
Returns
NSERROR_OK or appropriate error code.

Definition at line 571 of file local_history.c.

References local_history_session::bw, history::height, height, browser_window::history, NSERROR_OK, history::width, and width.

Referenced by ami_history_local_present(), fb_local_history_present(), nsgtk_local_history_present(), nsw32_local_history_present(), and ro_local_history_open().

Here is the caller graph for this function:

◆ local_history_get_url()

nserror local_history_get_url ( struct local_history_session session,
int  x,
int  y,
struct nsurl **  url_out 
)

get url of entry at position in local history content area.

Todo:
the returned url should be a referenced nsurl.
Parameters
[in]sessionThe local history session context.
[in]xThe x coordinate to get url of.
[in]yThe y coordinate to get url of.
[out]url_outreferenced url.
Returns
NSERROR_OK and url_out updated or NSERROR_NOT_FOUND if no url at location.

Definition at line 584 of file local_history.c.

References local_history_session::bw, find_entry_position(), browser_window::history, NSERROR_BAD_PARAMETER, NSERROR_NOT_FOUND, NSERROR_OK, nsurl_ref(), history_entry::page, history::start, history_page::url, history_entry::x, and history_entry::y.

Referenced by ami_history_local_mouse(), and ro_local_history_tooltip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ local_history_init()

nserror local_history_init ( struct core_window_callback_table cw_t,
void *  core_window_handle,
struct browser_window bw,
struct local_history_session **  session 
)

Initialise the local history.

This iterates through the history object of a browser window and creates tree of visited pages with thumbnails which may be selected to cause navigation.

This must be called before any other local_history_* function.

Parameters
[in]cw_tCallback table for core_window containing the treeview.
[in]core_window_handleThe core_window in which the treeview is shown.
[in]bwbrowser window to show history of.
[out]sessionThe created local history session context.
Returns
NSERROR_OK on success and session set, appropriate error code otherwise

Definition at line 312 of file local_history.c.

References plot_font_style::background, local_history_session::bw, local_history_session::core_window_handle, local_history_session::cw_t, cw_t, plot_style_s::fill_colour, plot_font_style::foreground, local_history_set(), NSCOLOUR_SEL_BG, NSCOLOUR_WIN_EVEN_BG, NSCOLOUR_WIN_EVEN_BORDER, NSCOLOUR_WIN_EVEN_FG, nscolours, NSERROR_NOMEM, NSERROR_OK, pfstyle_node, pfstyle_node_sel, pstyle_bg, pstyle_line, pstyle_rect, pstyle_rect_cursor, pstyle_rect_sel, and plot_style_s::stroke_colour.

Referenced by ami_history_local_present(), fb_local_history_init(), nsgtk_local_history_init(), nsw32_local_history_init(), and ro_local_history_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ local_history_keypress()

bool local_history_keypress ( struct local_history_session session,
uint32_t  key 
)

Key press handling.

Parameters
[in]sessionThe local history session context.
[in]keyThe ucs4 character codepoint
Returns
true if the keypress is dealt with, false otherwise.

Definition at line 462 of file local_history.c.

References _local_history_find_branch_point(), history_entry::back, browser_window_history_go(), local_history_session::bw, local_history_session::core_window_handle, history::current, local_history_session::cursor, local_history_session::cw_t, history_entry::forward, history_entry::forward_pref, browser_window::history, core_window_callback_table::invalidate, local_history_scroll_to_cursor(), history_entry::next, NS_KEY_CR, NS_KEY_DOWN, NS_KEY_LEFT, NS_KEY_NL, NS_KEY_RIGHT, and NS_KEY_UP.

Referenced by ami_history_local_key(), fb_local_history_key(), nsgtk_local_history_key(), nsw32_local_history_key(), and ro_local_history_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ local_history_mouse_action()

nserror local_history_mouse_action ( struct local_history_session session,
enum browser_mouse_state  mouse,
int  x,
int  y 
)

Handles all kinds of mouse action.

Parameters
[in]sessionThe local history session context.
[in]mouseThe current mouse state
[in]xThe current mouse X coordinate
[in]yThe current mouse Y coordinate
Returns
NSERROR_OK if mouse action was processed. NSERROR_NOT_FOUND if nothing under the pointer where it was clicked NSERROR_NOT_IMPLEMENTED if the action was not processed. NSERROR_PERMISSION if the clicked item was the current page

Definition at line 392 of file local_history.c.

References BROWSER_MOUSE_PRESS_1, BROWSER_MOUSE_PRESS_2, browser_window_history_go(), local_history_session::bw, history::current, find_entry_position(), browser_window::history, NSERROR_BAD_PARAMETER, NSERROR_NOT_FOUND, NSERROR_NOT_IMPLEMENTED, NSERROR_OK, NSERROR_PERMISSION, history::start, history_entry::x, and history_entry::y.

Referenced by ami_history_local_mouse(), fb_local_history_mouse(), nsgtk_local_history_mouse(), nsw32_local_history_mouse(), and ro_local_history_mouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ local_history_redraw()

nserror local_history_redraw ( struct local_history_session session,
int  x,
int  y,
struct rect clip,
const struct redraw_context ctx 
)

Redraw the local history.

Causes the local history viewer to issue plot operations to redraw the specified area of the viewport.

Parameters
[in]sessionThe local history session context.
[in]xX coordinate to render history at
[in]yY coordinate to render history at
[in]clipCurrent clip rectangle (wrt tree origin)
[in]ctxCurrent redraw context

Definition at line 357 of file local_history.c.

References local_history_session::bw, clip(), plotter_table::clip, local_history_session::cursor, browser_window::history, NSERROR_OK, redraw_context::plot, pstyle_bg, plotter_table::rectangle, redraw_entry(), history::start, and rect::x0.

Referenced by ami_history_local_draw(), fb_local_history_draw(), nsgtk_local_history_draw(), nsw32_local_history_draw(), and ro_local_history_draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ local_history_scroll_to_cursor()

nserror local_history_scroll_to_cursor ( struct local_history_session session)

Scroll the local history window to ensure the current cursor is shown.

Parameters
sessionThe local history session

Definition at line 290 of file local_history.c.

References local_history_session::core_window_handle, local_history_session::cursor, cw_helper_scroll_visible(), local_history_session::cw_t, LOCAL_HISTORY_BOTTOM_MARGIN, LOCAL_HISTORY_HEIGHT, LOCAL_HISTORY_RIGHT_MARGIN, LOCAL_HISTORY_WIDTH, NSERROR_OK, history_entry::x, rect::x0, rect::x1, history_entry::y, rect::y0, and rect::y1.

Referenced by ami_history_local_present(), fb_local_history_present(), local_history_keypress(), local_history_set(), nsgtk_local_history_present(), nsw32_local_history_present(), and ro_local_history_open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ local_history_set()

nserror local_history_set ( struct local_history_session session,
struct browser_window bw 
)

Change the browser window to draw local history for.

Parameters
[in]sessionThe local history session context.
bwbrowser window to show history of.
Returns
NSERROR_OK or appropriate error code.

Definition at line 549 of file local_history.c.

References local_history_session::bw, local_history_session::core_window_handle, history::current, local_history_session::cursor, local_history_session::cw_t, history::height, browser_window::history, local_history_scroll_to_cursor(), NSERROR_OK, core_window_callback_table::update_size, and history::width.

Referenced by ami_history_local_present(), fb_local_history_hide(), fb_local_history_init(), local_history_init(), nsgtk_local_history_hide(), nsgtk_local_history_init(), nsw32_local_history_hide(), nsw32_local_history_init(), and ro_local_history_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ redraw_entry()

static nserror redraw_entry ( struct history history,
struct history_entry entry,
struct history_entry cursor,
struct rect clip,
int  x,
int  y,
const struct redraw_context ctx 
)
static

Recursively redraw a history entry.

Parameters
historyhistory containing the entry
entryentry to render
clipredraw area
xwindow x offset
ywindow y offset
ctxcurrent redraw context

Definition at line 135 of file local_history.c.

References history_page::bitmap, plotter_table::bitmap, clip(), history::current, history_entry::forward, guit, netsurf_table::layout, plotter_table::line, LOCAL_HISTORY_HEIGHT, LOCAL_HISTORY_WIDTH, history_entry::next, NSERROR_OK, history_entry::page, pfstyle_node, pfstyle_node_sel, redraw_context::plot, plot_style_font, gui_layout_table::position, pstyle_line, pstyle_rect, pstyle_rect_cursor, pstyle_rect_sel, plotter_table::rectangle, redraw_entry(), plotter_table::text, history_page::title, history_entry::x, rect::x0, rect::x1, history_entry::y, rect::y0, and rect::y1.

Referenced by local_history_redraw(), and redraw_entry().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ pfstyle_node

plot_font_style_t pfstyle_node
static
Initial value:
= {
.size = 8 * PLOT_STYLE_SCALE,
.weight = 400,
.flags = FONTF_NONE,
}
@ FONTF_NONE
Definition: plot_style.h:102
@ PLOT_FONT_FAMILY_SANS_SERIF
Definition: plot_style.h:89
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
Definition: plot_style.h:45

plot style for font on unselected nodes

Definition at line 105 of file local_history.c.

Referenced by local_history_init(), and redraw_entry().

◆ pfstyle_node_sel

plot_font_style_t pfstyle_node_sel
static
Initial value:
= {
.size = 8 * PLOT_STYLE_SCALE,
.weight = 900,
.flags = FONTF_NONE,
}

plot style for font on unselected nodes

Definition at line 116 of file local_history.c.

Referenced by local_history_init(), and redraw_entry().

◆ pstyle_bg

plot_style_t pstyle_bg
static
Initial value:
= {
.fill_type = PLOT_OP_TYPE_SOLID,
}
@ PLOT_OP_TYPE_SOLID
Solid colour.
Definition: plot_style.h:67

plot style for drawing background

Definition at line 70 of file local_history.c.

Referenced by local_history_init(), and local_history_redraw().

◆ pstyle_line

plot_style_t pstyle_line
static
Initial value:
= {
.stroke_type = PLOT_OP_TYPE_SOLID,
.stroke_width = plot_style_int_to_fixed(2),
}
#define plot_style_int_to_fixed(v)
Definition: plot_style.h:51

plot style for drawing lines between nodes

Definition at line 61 of file local_history.c.

Referenced by local_history_init(), and redraw_entry().

◆ pstyle_rect

plot_style_t pstyle_rect
static
Initial value:
= {
.stroke_type = PLOT_OP_TYPE_SOLID,
.stroke_width = plot_style_int_to_fixed(1),
}

plot style for drawing rectangle round unselected nodes

Definition at line 78 of file local_history.c.

Referenced by local_history_init(), and redraw_entry().

◆ pstyle_rect_cursor

plot_style_t pstyle_rect_cursor
static
Initial value:
= {
.stroke_type = PLOT_OP_TYPE_DASH,
.stroke_width = plot_style_int_to_fixed(3),
}
@ PLOT_OP_TYPE_DASH
Dashed plot.
Definition: plot_style.h:69

plot style for drawing rectangle round the cursor node

Definition at line 96 of file local_history.c.

Referenced by local_history_init(), and redraw_entry().

◆ pstyle_rect_sel

plot_style_t pstyle_rect_sel
static
Initial value:
= {
.stroke_type = PLOT_OP_TYPE_SOLID,
.stroke_width = plot_style_int_to_fixed(3),
}

plot style for drawing rectangle round selected nodes

Definition at line 87 of file local_history.c.

Referenced by local_history_init(), and redraw_entry().