2005-04-15 09:51:32 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Adrian Lees <adrianl@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-04-15 09:51:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
2008-04-13 22:21:22 +04:00
|
|
|
* Text selection within browser windows (interface).
|
2005-04-15 09:51:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_DESKTOP_SELECTION_H_
|
|
|
|
#define _NETSURF_DESKTOP_SELECTION_H_
|
|
|
|
|
2012-08-22 15:22:58 +04:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include "desktop/mouse.h"
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2012-03-24 21:42:29 +04:00
|
|
|
struct box;
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
DRAG_NONE,
|
|
|
|
DRAG_START,
|
|
|
|
DRAG_END
|
|
|
|
} seln_drag_state;
|
|
|
|
|
|
|
|
|
2005-04-17 15:10:05 +04:00
|
|
|
/* this structure should be treated as opaque outside selection.c
|
|
|
|
(it's defined here to accelerate selection_defined(s) for reduced
|
|
|
|
impact on redraw code) */
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
struct selection
|
|
|
|
{
|
2011-07-26 17:53:42 +04:00
|
|
|
struct content *c;
|
2005-04-15 09:51:32 +04:00
|
|
|
struct box *root;
|
|
|
|
|
|
|
|
unsigned max_idx; /* total bytes in text representation */
|
|
|
|
|
|
|
|
unsigned start_idx; /* offset in bytes within text representation */
|
|
|
|
unsigned end_idx;
|
|
|
|
|
|
|
|
bool defined;
|
2011-07-26 17:53:42 +04:00
|
|
|
bool is_html;
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
seln_drag_state drag_state;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-07-26 17:53:42 +04:00
|
|
|
struct selection *selection_create(struct content *c, bool is_html);
|
|
|
|
void selection_prepare(struct selection *s, struct content *c, bool is_html);
|
2005-04-15 09:51:32 +04:00
|
|
|
void selection_destroy(struct selection *s);
|
|
|
|
|
|
|
|
void selection_init(struct selection *s, struct box *root);
|
|
|
|
void selection_reinit(struct selection *s, struct box *root);
|
|
|
|
|
2006-02-11 21:33:05 +03:00
|
|
|
/* struct box *selection_root(struct selection *s); */
|
|
|
|
#define selection_root(s) ((s)->root)
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
/* bool selection_defined(struct selection *s); */
|
|
|
|
#define selection_defined(s) ((s)->defined)
|
|
|
|
|
|
|
|
/* bool selection_dragging(struct selection *s); */
|
|
|
|
#define selection_dragging(s) ((s)->drag_state != DRAG_NONE)
|
|
|
|
|
2005-07-24 22:35:57 +04:00
|
|
|
/* bool selection_dragging_start(struct selection *s); */
|
|
|
|
#define selection_dragging_start(s) ((s)->drag_state == DRAG_START)
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
void selection_clear(struct selection *s, bool redraw);
|
|
|
|
void selection_select_all(struct selection *s);
|
2005-07-21 03:27:28 +04:00
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
void selection_set_start(struct selection *s, unsigned idx);
|
|
|
|
void selection_set_end(struct selection *s, unsigned idx);
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2008-03-31 22:04:36 +04:00
|
|
|
bool selection_click(struct selection *s, browser_mouse_state mouse,
|
|
|
|
unsigned idx);
|
|
|
|
void selection_track(struct selection *s, browser_mouse_state mouse,
|
|
|
|
unsigned idx);
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2012-08-02 17:23:42 +04:00
|
|
|
bool selection_copy_to_clipboard(struct selection *s);
|
2012-08-13 20:09:42 +04:00
|
|
|
char * selection_get_copy(struct selection *s);
|
2012-08-02 17:23:42 +04:00
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
/** Handles completion of a drag operation */
|
|
|
|
/* void selection_drag_end(struct selection *s); */
|
|
|
|
#define selection_drag_end(s) ((s)->drag_state = DRAG_NONE)
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2011-07-13 17:20:26 +04:00
|
|
|
bool selection_highlighted(const struct selection *s,
|
|
|
|
unsigned start, unsigned end,
|
2005-04-15 09:51:32 +04:00
|
|
|
unsigned *start_idx, unsigned *end_idx);
|
|
|
|
|
|
|
|
#endif
|