NetSurf
local_history.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 Vincent Sanders <vince@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef NETSURF_DESKTOP_LOCAL_HISTORY_H
20#define NETSURF_DESKTOP_LOCAL_HISTORY_H
21
22#include <stdbool.h>
23#include <stdint.h>
24
25#include "utils/errors.h"
26#include "netsurf/mouse.h"
27
29struct redraw_context;
30struct nsurl;
31struct rect;
33struct browser_window;
34
35/**
36 * Initialise the local history.
37 *
38 * This iterates through the history object of a browser window and
39 * creates tree of visited pages with thumbnails which may be selected
40 * to cause navigation.
41 *
42 * This must be called before any other local_history_* function.
43 *
44 * \param[in] cw_t Callback table for core_window containing the treeview.
45 * \param[in] core_window_handle The core_window in which the treeview is shown.
46 * \param[in] bw browser window to show history of.
47 * \param[out] session The created local history session context.
48 * \return NSERROR_OK on success and session set, appropriate error code otherwise
49 */
51 void *core_window_handle,
52 struct browser_window *bw,
53 struct local_history_session **session);
54
55/**
56 * Finalise the local history.
57 *
58 * This destroys the local history view and the local history module's
59 * internal data. After calling this if local history is required again,
60 * local_history_init must be called to create a new session.
61 *
62 * \param session The local history session to finalise.
63 * \return NSERROR_OK on success and session freed appropriate error otherwise
64 */
66
67
68/**
69 * Redraw the local history.
70 *
71 * Causes the local history viewer to issue plot operations to redraw
72 * the specified area of the viewport.
73 *
74 * \param[in] session The local history session context.
75 * \param[in] x X coordinate to render history at
76 * \param[in] y Y coordinate to render history at
77 * \param[in] clip Current clip rectangle (wrt tree origin)
78 * \param[in] ctx Current redraw context
79 */
80nserror local_history_redraw(struct local_history_session *session, int x, int y, struct rect *clip, const struct redraw_context *ctx);
81
82
83/**
84 * Handles all kinds of mouse action
85 *
86 * \param[in] session The local history session context.
87 * \param[in] mouse The current mouse state
88 * \param[in] x The current mouse X coordinate
89 * \param[in] y The current mouse Y coordinate
90 * \return NSERROR_OK if mouse action was processed.
91 * NSERROR_NOT_FOUND if nothing under the pointer where it was clicked
92 * NSERROR_NOT_IMPLEMENTED if the action was not processed.
93 * NSERROR_PERMISSION if the clicked item was the current page
94 */
96
97
98/**
99 * Key press handling.
100 *
101 * \param[in] session The local history session context.
102 * \param[in] key The ucs4 character codepoint
103 * \return true if the keypress is dealt with, false otherwise.
104 */
105bool local_history_keypress(struct local_history_session *session, uint32_t key);
106
107
108/**
109 * Change the browser window to draw local history for.
110 *
111 * \param[in] session The local history session context.
112 * \param bw browser window to show history of.
113 * \return NSERROR_OK or appropriate error code.
114 */
116
117
118/**
119 * get size of local history content area.
120 *
121 * \param[in] session The local history session context.
122 * \param[out] width on sucessful return the width of the localhistory content
123 * \param[out] height on sucessful return the height of the localhistory content
124 * \return NSERROR_OK or appropriate error code.
125 */
127
128
129/**
130 * get url of entry at position in local history content area.
131 *
132 * \todo the returned url should be a referenced nsurl.
133 *
134 * \param[in] session The local history session context.
135 * \param[in] x The x coordinate to get url of.
136 * \param[in] y The y coordinate to get url of.
137 * \param[out] url_out referenced url.
138 * \return NSERROR_OK and url_out updated or NSERROR_NOT_FOUND if no url at
139 * location.
140 */
141nserror local_history_get_url(struct local_history_session *session, int x, int y, struct nsurl **url_out);
142
143/**
144 * Scroll the local history window to ensure the current cursor is shown.
145 *
146 * \param session The local history session
147 */
149
150
151#endif
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.
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.
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.
nserror local_history_scroll_to_cursor(struct local_history_session *session)
Scroll the local history window to ensure the current cursor is shown.
nserror local_history_get_size(struct local_history_session *session, int *width, int *height)
get size of local history content area.
nserror local_history_set(struct local_history_session *session, struct browser_window *bw)
Change the browser window to draw local history for.
nserror local_history_fini(struct local_history_session *session)
Finalise the local history.
bool local_history_keypress(struct local_history_session *session, uint32_t key)
Key press handling.
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.
Error codes.
nserror
Enumeration of error codes.
Definition: errors.h:29
static struct core_window_callback_table cw_t
Declare Core Window Callbacks:
Definition: treeview.c:534
Core mouse and pointer states.
browser_mouse_state
Mouse state.
Definition: mouse.h:43
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
int width
Definition: gui.c:159
int height
Definition: gui.c:160
Browser window data.
int x
Window dimensions.
struct browser_window * bw
Callbacks to achieve various core window functionality.
Definition: core_window.h:51
local history viewer context
Definition: local_history.c:50
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357