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
28struct redraw_context;
29struct nsurl;
30struct rect;
32struct browser_window;
33
34/**
35 * Initialise the local history.
36 *
37 * This iterates through the history object of a browser window and
38 * creates tree of visited pages with thumbnails which may be selected
39 * to cause navigation.
40 *
41 * This must be called before any other local_history_* function.
42 *
43 * \param[in] cw_t Callback table for core_window containing the treeview.
44 * \param[in] core_window_handle The core_window in which the treeview is shown.
45 * \param[in] bw browser window to show history of.
46 * \param[out] session The created local history session context.
47 * \return NSERROR_OK on success and session set, appropriate error code otherwise
48 */
49nserror local_history_init(void *core_window_handle,
50 struct browser_window *bw,
51 struct local_history_session **session);
52
53/**
54 * Finalise the local history.
55 *
56 * This destroys the local history view and the local history module's
57 * internal data. After calling this if local history is required again,
58 * local_history_init must be called to create a new session.
59 *
60 * \param session The local history session to finalise.
61 * \return NSERROR_OK on success and session freed appropriate error otherwise
62 */
64
65
66/**
67 * Redraw the local history.
68 *
69 * Causes the local history viewer to issue plot operations to redraw
70 * the specified area of the viewport.
71 *
72 * \param[in] session The local history session context.
73 * \param[in] x X coordinate to render history at
74 * \param[in] y Y coordinate to render history at
75 * \param[in] clip Current clip rectangle (wrt tree origin)
76 * \param[in] ctx Current redraw context
77 */
78nserror local_history_redraw(struct local_history_session *session, int x, int y, struct rect *clip, const struct redraw_context *ctx);
79
80
81/**
82 * Handles all kinds of mouse action
83 *
84 * \param[in] session The local history session context.
85 * \param[in] mouse The current mouse state
86 * \param[in] x The current mouse X coordinate
87 * \param[in] y The current mouse Y coordinate
88 * \return NSERROR_OK if mouse action was processed.
89 * NSERROR_NOT_FOUND if nothing under the pointer where it was clicked
90 * NSERROR_NOT_IMPLEMENTED if the action was not processed.
91 * NSERROR_PERMISSION if the clicked item was the current page
92 */
94
95
96/**
97 * Key press handling.
98 *
99 * \param[in] session The local history session context.
100 * \param[in] key The ucs4 character codepoint
101 * \return true if the keypress is dealt with, false otherwise.
102 */
103bool local_history_keypress(struct local_history_session *session, uint32_t key);
104
105
106/**
107 * Change the browser window to draw local history for.
108 *
109 * \param[in] session The local history session context.
110 * \param bw browser window to show history of.
111 * \return NSERROR_OK or appropriate error code.
112 */
114
115
116/**
117 * get size of local history content area.
118 *
119 * \param[in] session The local history session context.
120 * \param[out] width on sucessful return the width of the localhistory content
121 * \param[out] height on sucessful return the height of the localhistory content
122 * \return NSERROR_OK or appropriate error code.
123 */
125
126
127/**
128 * get url of entry at position in local history content area.
129 *
130 * \todo the returned url should be a referenced nsurl.
131 *
132 * \param[in] session The local history session context.
133 * \param[in] x The x coordinate to get url of.
134 * \param[in] y The y coordinate to get url of.
135 * \param[out] url_out referenced url.
136 * \return NSERROR_OK and url_out updated or NSERROR_NOT_FOUND if no url at
137 * location.
138 */
139nserror local_history_get_url(struct local_history_session *session, int x, int y, struct nsurl **url_out);
140
141/**
142 * Scroll the local history window to ensure the current cursor is shown.
143 *
144 * \param session The local history session
145 */
147
148
149#endif
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_init(void *core_window_handle, struct browser_window *bw, struct local_history_session **session)
Initialise the local history.
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
Core mouse and pointer states.
browser_mouse_state
Mouse state: 1 is primary mouse button.
Definition: mouse.h:52
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
int width
Definition: gui.c:160
int height
Definition: gui.c:161
Browser window data.
int x
Window dimensions.
struct browser_window * bw
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