2005-04-15 09:51:32 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Adrian Lees <adrianl@users.sourceforge.net>
|
2008-04-01 02:22:14 +04:00
|
|
|
* Copyright 2008 Michael Drake <tlsa@netsurf-browser.org>
|
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 (implementation).
|
2005-04-15 09:51:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
2008-07-29 00:32:51 +04:00
|
|
|
#include <string.h>
|
2012-03-25 00:55:22 +04:00
|
|
|
#include <dom/dom.h>
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2014-10-13 14:56:31 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/utf8.h"
|
|
|
|
#include "utils/utils.h"
|
2016-06-14 14:39:54 +03:00
|
|
|
#include "netsurf/form.h"
|
2014-10-13 14:56:31 +04:00
|
|
|
#include "render/box.h"
|
|
|
|
#include "render/html_internal.h"
|
|
|
|
#include "render/font.h"
|
|
|
|
#include "render/textplain.h"
|
|
|
|
|
2016-05-30 14:07:16 +03:00
|
|
|
#include "netsurf/mouse.h"
|
2014-10-17 15:21:06 +04:00
|
|
|
#include "desktop/browser_private.h"
|
2016-05-30 23:05:57 +03:00
|
|
|
#include "netsurf/plotters.h"
|
2008-04-13 22:21:22 +04:00
|
|
|
#include "desktop/save_text.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/selection.h"
|
2016-05-30 13:04:32 +03:00
|
|
|
#include "netsurf/clipboard.h"
|
2016-05-30 13:01:40 +03:00
|
|
|
#include "netsurf/window.h"
|
2014-10-16 12:48:09 +04:00
|
|
|
#include "desktop/gui_internal.h"
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2006-02-11 21:33:05 +03:00
|
|
|
/**
|
|
|
|
* Text selection works by labelling each node in the box tree with its
|
|
|
|
* start index in the textual representation of the tree's content.
|
|
|
|
*/
|
|
|
|
|
2011-03-06 21:04:13 +03:00
|
|
|
#define SPACE_LEN(b) ((b->space == 0) ? 0 : 1)
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
struct rdw_info {
|
|
|
|
bool inited;
|
2006-02-16 02:09:55 +03:00
|
|
|
struct rect r;
|
2005-04-15 09:51:32 +04:00
|
|
|
};
|
|
|
|
|
2012-08-13 20:09:42 +04:00
|
|
|
struct selection_string {
|
|
|
|
char *buffer;
|
|
|
|
size_t buffer_len;
|
|
|
|
size_t length;
|
2013-01-08 20:54:46 +04:00
|
|
|
|
|
|
|
int n_styles;
|
|
|
|
nsclipboard_styles *styles;
|
2012-08-13 20:09:42 +04:00
|
|
|
};
|
|
|
|
|
2012-08-13 20:48:03 +04:00
|
|
|
|
|
|
|
typedef bool (*seln_traverse_handler)(const char *text, size_t length,
|
2018-01-04 02:58:18 +03:00
|
|
|
struct box *box, const nscss_len_ctx *len_ctx, void *handle,
|
|
|
|
const char *whitespace_text, size_t whitespace_length);
|
2012-08-13 20:48:03 +04:00
|
|
|
|
|
|
|
|
2018-01-04 02:58:18 +03:00
|
|
|
static bool redraw_handler(const char *text, size_t length,
|
|
|
|
struct box *box, const nscss_len_ctx *len_ctx,
|
2008-03-31 22:59:23 +04:00
|
|
|
void *handle, const char *whitespace_text,
|
|
|
|
size_t whitespace_length);
|
2008-03-31 22:04:36 +04:00
|
|
|
static void selection_redraw(struct selection *s, unsigned start_idx,
|
|
|
|
unsigned end_idx);
|
2005-07-24 10:13:25 +04:00
|
|
|
static bool selected_part(struct box *box, unsigned start_idx, unsigned end_idx,
|
|
|
|
unsigned *start_offset, unsigned *end_offset);
|
2018-01-04 02:58:18 +03:00
|
|
|
static bool traverse_tree(struct box *box, const nscss_len_ctx *len_ctx,
|
|
|
|
unsigned start_idx, unsigned end_idx,
|
2013-02-07 18:21:48 +04:00
|
|
|
seln_traverse_handler handler,
|
2008-04-13 22:21:22 +04:00
|
|
|
void *handle, save_text_whitespace *before, bool *first,
|
2008-04-07 13:00:21 +04:00
|
|
|
bool do_marker);
|
2013-04-30 00:55:32 +04:00
|
|
|
static unsigned selection_label_subtree(struct box *box, unsigned idx);
|
2011-07-26 17:53:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the browser window containing the content a selection object belongs to.
|
|
|
|
*
|
|
|
|
* \param s selection object
|
|
|
|
* \return the browser window
|
|
|
|
*/
|
|
|
|
static struct browser_window * selection_get_browser_window(struct selection *s)
|
|
|
|
{
|
|
|
|
if (s->is_html)
|
|
|
|
return html_get_browser_window(s->c);
|
|
|
|
else
|
|
|
|
return textplain_get_browser_window(s->c);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
/**
|
|
|
|
* Creates a new selection object associated with a browser window.
|
|
|
|
*
|
2011-07-13 17:20:26 +04:00
|
|
|
* \return new selection context
|
2005-04-15 09:51:32 +04:00
|
|
|
*/
|
|
|
|
|
2011-07-26 17:53:42 +04:00
|
|
|
struct selection *selection_create(struct content *c, bool is_html)
|
2011-06-15 00:00:18 +04:00
|
|
|
{
|
2011-07-01 15:16:43 +04:00
|
|
|
struct selection *s = calloc(1, sizeof(struct selection));
|
2011-07-13 17:20:26 +04:00
|
|
|
if (s) {
|
2011-07-26 17:53:42 +04:00
|
|
|
selection_prepare(s, c, is_html);
|
2011-07-13 17:20:26 +04:00
|
|
|
}
|
2011-07-26 17:53:42 +04:00
|
|
|
|
2011-07-13 17:20:26 +04:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare a newly created selection object for use.
|
|
|
|
*
|
2011-07-26 17:53:42 +04:00
|
|
|
* \param s selection object
|
|
|
|
* \param c content
|
|
|
|
* \param is_html true if content is html false if content is textplain
|
2011-07-13 17:20:26 +04:00
|
|
|
*/
|
|
|
|
|
2011-07-26 17:53:42 +04:00
|
|
|
void selection_prepare(struct selection *s, struct content *c, bool is_html)
|
2011-07-13 17:20:26 +04:00
|
|
|
{
|
2011-07-01 15:16:43 +04:00
|
|
|
if (s) {
|
2011-07-26 17:53:42 +04:00
|
|
|
s->c = c;
|
|
|
|
s->is_html = is_html;
|
2011-07-01 15:16:43 +04:00
|
|
|
s->root = NULL;
|
|
|
|
s->drag_state = DRAG_NONE;
|
2011-07-13 17:20:26 +04:00
|
|
|
s->max_idx = 0;
|
2011-07-01 15:16:43 +04:00
|
|
|
selection_clear(s, false);
|
|
|
|
}
|
2011-06-15 00:00:18 +04:00
|
|
|
}
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
/**
|
2006-02-13 00:23:22 +03:00
|
|
|
* Destroys a selection object, without updating the
|
|
|
|
* owning window (caller should call selection_clear()
|
|
|
|
* first if update is desired)
|
2005-04-15 09:51:32 +04:00
|
|
|
*
|
2006-02-13 00:23:22 +03:00
|
|
|
* \param s selection object
|
2005-04-15 09:51:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
void selection_destroy(struct selection *s)
|
|
|
|
{
|
2011-06-15 00:00:18 +04:00
|
|
|
if (s != NULL)
|
|
|
|
free(s);
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise the selection object to use the given box subtree as its root,
|
|
|
|
* ie. selections are confined to that subtree, whilst maintaining the current
|
|
|
|
* selection whenever possible because, for example, it's just the page being
|
|
|
|
* resized causing the layout to change.
|
|
|
|
*
|
|
|
|
* \param s selection object
|
2013-04-29 17:00:36 +04:00
|
|
|
* \param root the root box for html document or NULL for text/plain
|
2005-04-15 09:51:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
void selection_reinit(struct selection *s, struct box *root)
|
|
|
|
{
|
2006-02-11 21:33:05 +03:00
|
|
|
unsigned root_idx;
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
assert(s);
|
|
|
|
|
2013-02-07 18:21:48 +04:00
|
|
|
root_idx = 0;
|
2006-02-13 00:23:22 +03:00
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
s->root = root;
|
2005-07-21 03:27:28 +04:00
|
|
|
if (root) {
|
2008-04-07 13:00:21 +04:00
|
|
|
s->max_idx = selection_label_subtree(root, root_idx);
|
2011-07-26 17:53:42 +04:00
|
|
|
} else {
|
|
|
|
if (s->is_html == false)
|
|
|
|
s->max_idx = textplain_size(s->c);
|
2006-02-16 02:09:55 +03:00
|
|
|
else
|
|
|
|
s->max_idx = 0;
|
|
|
|
}
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
if (s->defined) {
|
|
|
|
if (s->end_idx > s->max_idx) s->end_idx = s->max_idx;
|
|
|
|
if (s->start_idx > s->max_idx) s->start_idx = s->max_idx;
|
|
|
|
s->defined = (s->end_idx > s->start_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise the selection object to use the given box subtree as its root,
|
|
|
|
* ie. selections are confined to that subtree.
|
|
|
|
*
|
|
|
|
* \param s selection object
|
2013-04-29 17:00:36 +04:00
|
|
|
* \param root the root box for html document or NULL for text/plain
|
2005-04-15 09:51:32 +04:00
|
|
|
*/
|
|
|
|
|
2018-01-04 02:58:18 +03:00
|
|
|
void selection_init(
|
|
|
|
struct selection *s,
|
|
|
|
struct box *root,
|
|
|
|
const nscss_len_ctx *len_ctx)
|
2005-04-15 09:51:32 +04:00
|
|
|
{
|
2005-07-21 03:27:28 +04:00
|
|
|
if (s->defined)
|
|
|
|
selection_clear(s, true);
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
s->defined = false;
|
|
|
|
s->start_idx = 0;
|
|
|
|
s->end_idx = 0;
|
|
|
|
s->drag_state = DRAG_NONE;
|
2018-01-04 02:58:18 +03:00
|
|
|
if (len_ctx != NULL) {
|
|
|
|
s->len_ctx = *len_ctx;
|
|
|
|
} else {
|
|
|
|
s->len_ctx.vw = 0;
|
|
|
|
s->len_ctx.vh = 0;
|
|
|
|
s->len_ctx.root_style = NULL;
|
|
|
|
}
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
selection_reinit(s, root);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Label each text box in the given box subtree with its position
|
|
|
|
* in a textual representation of the content.
|
|
|
|
*
|
2014-11-10 20:00:15 +03:00
|
|
|
* \param box The box at root of subtree
|
|
|
|
* \param idx current position within textual representation
|
2005-04-15 09:51:32 +04:00
|
|
|
* \return updated position
|
|
|
|
*/
|
|
|
|
|
2008-04-07 13:00:21 +04:00
|
|
|
unsigned selection_label_subtree(struct box *box, unsigned idx)
|
2005-04-15 09:51:32 +04:00
|
|
|
{
|
2008-04-07 13:00:21 +04:00
|
|
|
struct box *child = box->children;
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2008-04-07 13:00:21 +04:00
|
|
|
box->byte_offset = idx;
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2008-04-08 16:40:05 +04:00
|
|
|
if (box->text)
|
2011-03-06 21:04:13 +03:00
|
|
|
idx += box->length + SPACE_LEN(box);
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
while (child) {
|
2013-02-07 18:21:48 +04:00
|
|
|
if (child->list_marker)
|
|
|
|
idx = selection_label_subtree(child->list_marker, idx);
|
2008-04-07 13:00:21 +04:00
|
|
|
|
2013-02-07 18:21:48 +04:00
|
|
|
idx = selection_label_subtree(child, idx);
|
2005-04-15 09:51:32 +04:00
|
|
|
child = child->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles mouse clicks (including drag starts) in or near a selection
|
|
|
|
*
|
|
|
|
* \param s selection object
|
|
|
|
* \param mouse state of mouse buttons and modifier keys
|
2006-02-16 02:09:55 +03:00
|
|
|
* \param idx byte offset within textual representation
|
2005-04-15 09:51:32 +04:00
|
|
|
*
|
|
|
|
* \return true iff the click has been handled by the selection code
|
|
|
|
*/
|
|
|
|
|
2008-03-31 22:04:36 +04:00
|
|
|
bool selection_click(struct selection *s, browser_mouse_state mouse,
|
2008-03-31 22:59:23 +04:00
|
|
|
unsigned idx)
|
2005-04-15 09:51:32 +04:00
|
|
|
{
|
2008-03-31 22:04:36 +04:00
|
|
|
browser_mouse_state modkeys =
|
|
|
|
(mouse & (BROWSER_MOUSE_MOD_1 | BROWSER_MOUSE_MOD_2));
|
2005-04-15 09:51:32 +04:00
|
|
|
int pos = -1; /* 0 = inside selection, 1 = after it */
|
2011-07-26 17:53:42 +04:00
|
|
|
struct browser_window *top = selection_get_browser_window(s);
|
|
|
|
top = browser_window_get_root(top);
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
if (selection_defined(s)) {
|
2008-03-30 04:06:16 +04:00
|
|
|
if (idx > s->start_idx) {
|
2008-04-07 13:00:21 +04:00
|
|
|
if (idx <= s->end_idx)
|
2005-04-15 09:51:32 +04:00
|
|
|
pos = 0;
|
|
|
|
else
|
|
|
|
pos = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-06 03:07:18 +03:00
|
|
|
if (!pos &&
|
2006-02-16 02:09:55 +03:00
|
|
|
((mouse & BROWSER_MOUSE_DRAG_1) ||
|
|
|
|
(modkeys && (mouse & BROWSER_MOUSE_DRAG_2)))) {
|
2005-04-15 09:51:32 +04:00
|
|
|
/* drag-saving selection */
|
2013-05-10 14:54:26 +04:00
|
|
|
char *sel = selection_get_copy(s);
|
2014-01-14 02:54:19 +04:00
|
|
|
guit->window->drag_save_selection(top->window, sel);
|
2013-05-10 14:54:26 +04:00
|
|
|
free(sel);
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
else if (!modkeys) {
|
2011-07-13 17:20:26 +04:00
|
|
|
if (pos && (mouse & BROWSER_MOUSE_PRESS_1)) {
|
2013-02-22 16:19:35 +04:00
|
|
|
/* Clear the selection if mouse is pressed outside the
|
|
|
|
* selection, Otherwise clear on release (to allow for drags) */
|
2011-07-13 17:20:26 +04:00
|
|
|
|
Merged revisions 4282-4285,4288-4293,4297-4298,4307,4309-4313,4322,4324-4680 via svnmerge from
svn://svn.netsurf-browser.org/branches/mikeL/netsurf
........
r4432 | mikeL | 2008-06-24 04:00:36 +0100 (Tue, 24 Jun 2008) | 1 line
Drag events are now emited from where the press originated, instead of from where they became a drag
........
r4433 | mikeL | 2008-06-24 04:25:33 +0100 (Tue, 24 Jun 2008) | 1 line
Added accelerator to 'Select All'
........
r4495 | mikeL | 2008-07-02 21:36:32 +0100 (Wed, 02 Jul 2008) | 1 line
Selections are now deleted and replaced when a key is typed in a text area or text box. All input box behavior while a selection is active is now implemented (ex: pressing the right arrow key moves the caret to the end of the selection). Cut now works properly in both versions. Fixed discrepancy between where the caret was placed and selection began when starting a drag-select. Fixed bug with calculation of a selections end box.
........
r4496 | mikeL | 2008-07-02 22:11:24 +0100 (Wed, 02 Jul 2008) | 1 line
Added support for cut in input boxes
........
r4497 | mikeL | 2008-07-02 22:21:35 +0100 (Wed, 02 Jul 2008) | 1 line
Removed unused variables (Thanks tlsa)
........
r4498 | mikeL | 2008-07-02 23:30:30 +0100 (Wed, 02 Jul 2008) | 1 line
Modified selection clearing behavior to allow for drag-saves
........
r4499 | mikeL | 2008-07-03 00:51:50 +0100 (Thu, 03 Jul 2008) | 1 line
Fixed regression where it would take two clicks to place caret in an input (Thanks tlsa)
........
r4509 | mikeL | 2008-07-06 07:55:09 +0100 (Sun, 06 Jul 2008) | 1 line
Basic download support implemented. Only downloading of text files works
........
r4510 | mikeL | 2008-07-06 18:55:31 +0100 (Sun, 06 Jul 2008) | 1 line
Downloading of non-text files is now possible. Progress bar and size downloaded are now updated
........
r4511 | mikeL | 2008-07-06 20:46:00 +0100 (Sun, 06 Jul 2008) | 1 line
Added downloads glade file
........
r4512 | mikeL | 2008-07-06 20:47:39 +0100 (Sun, 06 Jul 2008) | 1 line
Downloads window now spawns in the center of the parent browser window
........
r4513 | mikeL | 2008-07-06 20:56:12 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed bug where backspace would be ignored if the selection began at the beginning on an input
........
r4514 | mikeL | 2008-07-06 21:26:45 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed compiler warnings by adding casts
........
r4516 | mikeL | 2008-07-06 21:32:41 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed initialization of size string, added initialization of progress
........
r4518 | mikeL | 2008-07-06 21:51:08 +0100 (Sun, 06 Jul 2008) | 1 line
Added an option for short units (with space) to human_friendly_bytesize
........
r4519 | mikeL | 2008-07-06 21:52:05 +0100 (Sun, 06 Jul 2008) | 1 line
Removed function size_to_string
........
r4520 | mikeL | 2008-07-06 22:03:11 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed pedantic error (kB instead of KB). Added missing necessary parameters to human_friendly_bytesize. Fixed incorrect bool types
........
r4521 | mikeL | 2008-07-06 22:08:15 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnecessary parameter and units list from human_friendly_bytesize
........
r4522 | mikeL | 2008-07-06 22:57:03 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnused variable
........
r4523 | mikeL | 2008-07-06 23:03:46 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed url parsing by replacing url_parse_filename with url_nice. Total size and size downloaded are now in human readable form. Speed is now calculated (roughly)
........
r4524 | mikeL | 2008-07-07 01:19:01 +0100 (Mon, 07 Jul 2008) | 1 line
Added file overwrite confirmation. Changed speed to a double
........
r4546 | mikeL | 2008-07-09 17:21:43 +0100 (Wed, 09 Jul 2008) | 1 line
Changed parameter of selection_get_end/start to a size_t instead of int and changed all offset variables to size_t as well
........
r4547 | mikeL | 2008-07-09 17:30:47 +0100 (Wed, 09 Jul 2008) | 1 line
Added action buttons to the bottom toolbar. Added ability to clear selected (and completed) downloads with a framework for other actions.
........
r4556 | jmb | 2008-07-10 00:17:24 +0100 (Thu, 10 Jul 2008) | 3 lines
A large bunch of tidying and general fixes to text input handling.
Make selection code treat password fields as inputs, too.
........
r4557 | mikeL | 2008-07-10 00:24:46 +0100 (Thu, 10 Jul 2008) | 1 line
Added functionality to gui_empty_clipboard and gui_start_selection (Thanks jmb)
........
r4573 | mikeL | 2008-07-10 16:33:27 +0100 (Thu, 10 Jul 2008) | 1 line
Removed example download. Made the list store row aware of its download and vise versa. Added new way of handling actions from the dialog (e.g. buttons) which handles all rows in the selection. Added a few memory management function calls to clean up better
........
r4577 | mikeL | 2008-07-10 21:11:51 +0100 (Thu, 10 Jul 2008) | 1 line
Download write channels now close properly. Added status column to the tree store which will change the progress bar text if a download is canceled or completed. Implemented cancel button functionality.
........
r4578 | mikeL | 2008-07-10 21:17:51 +0100 (Thu, 10 Jul 2008) | 1 line
Speed is now displayed as '-' when 0 or download has stopped
........
r4580 | mikeL | 2008-07-11 02:10:57 +0100 (Fri, 11 Jul 2008) | 1 line
Added two download related options (Download directory & Clear completed downloads) and a Downloads tab to the preferences dialog. Also moved the option to ask when overwriting files to Downloads tab. Added another option to the pre-download dialog, Save, which downloads the file immediately to your 'Download directory'
........
r4581 | mikeL | 2008-07-11 02:26:00 +0100 (Fri, 11 Jul 2008) | 1 line
Rearranged pre-download dialog buttons to conform to the HIG
........
r4616 | mikeL | 2008-07-11 19:54:12 +0100 (Fri, 11 Jul 2008) | 1 line
Limited download window updates to a user-defined variable that can be set in options (default is .5). Updates are now only done if the download window is visible. This greatly reduces the cpu usage.
........
r4617 | mikeL | 2008-07-11 20:07:48 +0100 (Fri, 11 Jul 2008) | 1 line
Removed unnecessary update limit option (it is now fixed at .5)
........
r4629 | mikeL | 2008-07-13 04:21:07 +0100 (Sun, 13 Jul 2008) | 1 line
Reorganized button sensitivity functions. Sensitivities are now updated when the selection changes as well as when a selected download's state changes.
........
r4635 | mikeL | 2008-07-13 17:00:05 +0100 (Sun, 13 Jul 2008) | 1 line
Added error handling. Added word-wrap to the "info" cell renderer so that to keep everything under control. Fixed bug where downloads would always go to you default folder (missing breaks).
........
r4642 | mikeL | 2008-07-13 21:46:09 +0100 (Sun, 13 Jul 2008) | 1 line
Added time remaining column. Fixed regression where the download info would be erased upon completion/cancelation.
........
r4655 | mikeL | 2008-07-14 23:20:33 +0100 (Mon, 14 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. When it is closed (when NS shuts down) all incomplete downloads are canceled (and the files deleted). Added a warning dialog when netsurf tries to close with incomplete downloads. Fixed bug where default save directory would initialize to NULL.
........
r4676 | mikeL | 2008-07-15 21:01:17 +0100 (Tue, 15 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. (This is the second half of the patch, last commit was only partial for some reason)
........
r4678 | mikeL | 2008-07-16 01:18:52 +0100 (Wed, 16 Jul 2008) | 1 line
Addresses almost all of rjek and jmb's concerns, fixes most of the sloppiness that was present earlier. Downloads without a total_size are now handled correctly (thanks tlsa). Changes to the default download directly are now saved correctly. Billions of other small bugs fixed
........
svn path=/trunk/netsurf/; revision=4681
2008-07-16 14:19:30 +04:00
|
|
|
selection_clear(s, true);
|
2011-07-13 17:20:26 +04:00
|
|
|
} else if (mouse & BROWSER_MOUSE_DRAG_1) {
|
2005-04-15 09:51:32 +04:00
|
|
|
/* start new selection drag */
|
2011-07-13 17:20:26 +04:00
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
selection_clear(s, true);
|
Merged revisions 4282-4285,4288-4293,4297-4298,4307,4309-4313,4322,4324-4680 via svnmerge from
svn://svn.netsurf-browser.org/branches/mikeL/netsurf
........
r4432 | mikeL | 2008-06-24 04:00:36 +0100 (Tue, 24 Jun 2008) | 1 line
Drag events are now emited from where the press originated, instead of from where they became a drag
........
r4433 | mikeL | 2008-06-24 04:25:33 +0100 (Tue, 24 Jun 2008) | 1 line
Added accelerator to 'Select All'
........
r4495 | mikeL | 2008-07-02 21:36:32 +0100 (Wed, 02 Jul 2008) | 1 line
Selections are now deleted and replaced when a key is typed in a text area or text box. All input box behavior while a selection is active is now implemented (ex: pressing the right arrow key moves the caret to the end of the selection). Cut now works properly in both versions. Fixed discrepancy between where the caret was placed and selection began when starting a drag-select. Fixed bug with calculation of a selections end box.
........
r4496 | mikeL | 2008-07-02 22:11:24 +0100 (Wed, 02 Jul 2008) | 1 line
Added support for cut in input boxes
........
r4497 | mikeL | 2008-07-02 22:21:35 +0100 (Wed, 02 Jul 2008) | 1 line
Removed unused variables (Thanks tlsa)
........
r4498 | mikeL | 2008-07-02 23:30:30 +0100 (Wed, 02 Jul 2008) | 1 line
Modified selection clearing behavior to allow for drag-saves
........
r4499 | mikeL | 2008-07-03 00:51:50 +0100 (Thu, 03 Jul 2008) | 1 line
Fixed regression where it would take two clicks to place caret in an input (Thanks tlsa)
........
r4509 | mikeL | 2008-07-06 07:55:09 +0100 (Sun, 06 Jul 2008) | 1 line
Basic download support implemented. Only downloading of text files works
........
r4510 | mikeL | 2008-07-06 18:55:31 +0100 (Sun, 06 Jul 2008) | 1 line
Downloading of non-text files is now possible. Progress bar and size downloaded are now updated
........
r4511 | mikeL | 2008-07-06 20:46:00 +0100 (Sun, 06 Jul 2008) | 1 line
Added downloads glade file
........
r4512 | mikeL | 2008-07-06 20:47:39 +0100 (Sun, 06 Jul 2008) | 1 line
Downloads window now spawns in the center of the parent browser window
........
r4513 | mikeL | 2008-07-06 20:56:12 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed bug where backspace would be ignored if the selection began at the beginning on an input
........
r4514 | mikeL | 2008-07-06 21:26:45 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed compiler warnings by adding casts
........
r4516 | mikeL | 2008-07-06 21:32:41 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed initialization of size string, added initialization of progress
........
r4518 | mikeL | 2008-07-06 21:51:08 +0100 (Sun, 06 Jul 2008) | 1 line
Added an option for short units (with space) to human_friendly_bytesize
........
r4519 | mikeL | 2008-07-06 21:52:05 +0100 (Sun, 06 Jul 2008) | 1 line
Removed function size_to_string
........
r4520 | mikeL | 2008-07-06 22:03:11 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed pedantic error (kB instead of KB). Added missing necessary parameters to human_friendly_bytesize. Fixed incorrect bool types
........
r4521 | mikeL | 2008-07-06 22:08:15 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnecessary parameter and units list from human_friendly_bytesize
........
r4522 | mikeL | 2008-07-06 22:57:03 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnused variable
........
r4523 | mikeL | 2008-07-06 23:03:46 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed url parsing by replacing url_parse_filename with url_nice. Total size and size downloaded are now in human readable form. Speed is now calculated (roughly)
........
r4524 | mikeL | 2008-07-07 01:19:01 +0100 (Mon, 07 Jul 2008) | 1 line
Added file overwrite confirmation. Changed speed to a double
........
r4546 | mikeL | 2008-07-09 17:21:43 +0100 (Wed, 09 Jul 2008) | 1 line
Changed parameter of selection_get_end/start to a size_t instead of int and changed all offset variables to size_t as well
........
r4547 | mikeL | 2008-07-09 17:30:47 +0100 (Wed, 09 Jul 2008) | 1 line
Added action buttons to the bottom toolbar. Added ability to clear selected (and completed) downloads with a framework for other actions.
........
r4556 | jmb | 2008-07-10 00:17:24 +0100 (Thu, 10 Jul 2008) | 3 lines
A large bunch of tidying and general fixes to text input handling.
Make selection code treat password fields as inputs, too.
........
r4557 | mikeL | 2008-07-10 00:24:46 +0100 (Thu, 10 Jul 2008) | 1 line
Added functionality to gui_empty_clipboard and gui_start_selection (Thanks jmb)
........
r4573 | mikeL | 2008-07-10 16:33:27 +0100 (Thu, 10 Jul 2008) | 1 line
Removed example download. Made the list store row aware of its download and vise versa. Added new way of handling actions from the dialog (e.g. buttons) which handles all rows in the selection. Added a few memory management function calls to clean up better
........
r4577 | mikeL | 2008-07-10 21:11:51 +0100 (Thu, 10 Jul 2008) | 1 line
Download write channels now close properly. Added status column to the tree store which will change the progress bar text if a download is canceled or completed. Implemented cancel button functionality.
........
r4578 | mikeL | 2008-07-10 21:17:51 +0100 (Thu, 10 Jul 2008) | 1 line
Speed is now displayed as '-' when 0 or download has stopped
........
r4580 | mikeL | 2008-07-11 02:10:57 +0100 (Fri, 11 Jul 2008) | 1 line
Added two download related options (Download directory & Clear completed downloads) and a Downloads tab to the preferences dialog. Also moved the option to ask when overwriting files to Downloads tab. Added another option to the pre-download dialog, Save, which downloads the file immediately to your 'Download directory'
........
r4581 | mikeL | 2008-07-11 02:26:00 +0100 (Fri, 11 Jul 2008) | 1 line
Rearranged pre-download dialog buttons to conform to the HIG
........
r4616 | mikeL | 2008-07-11 19:54:12 +0100 (Fri, 11 Jul 2008) | 1 line
Limited download window updates to a user-defined variable that can be set in options (default is .5). Updates are now only done if the download window is visible. This greatly reduces the cpu usage.
........
r4617 | mikeL | 2008-07-11 20:07:48 +0100 (Fri, 11 Jul 2008) | 1 line
Removed unnecessary update limit option (it is now fixed at .5)
........
r4629 | mikeL | 2008-07-13 04:21:07 +0100 (Sun, 13 Jul 2008) | 1 line
Reorganized button sensitivity functions. Sensitivities are now updated when the selection changes as well as when a selected download's state changes.
........
r4635 | mikeL | 2008-07-13 17:00:05 +0100 (Sun, 13 Jul 2008) | 1 line
Added error handling. Added word-wrap to the "info" cell renderer so that to keep everything under control. Fixed bug where downloads would always go to you default folder (missing breaks).
........
r4642 | mikeL | 2008-07-13 21:46:09 +0100 (Sun, 13 Jul 2008) | 1 line
Added time remaining column. Fixed regression where the download info would be erased upon completion/cancelation.
........
r4655 | mikeL | 2008-07-14 23:20:33 +0100 (Mon, 14 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. When it is closed (when NS shuts down) all incomplete downloads are canceled (and the files deleted). Added a warning dialog when netsurf tries to close with incomplete downloads. Fixed bug where default save directory would initialize to NULL.
........
r4676 | mikeL | 2008-07-15 21:01:17 +0100 (Tue, 15 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. (This is the second half of the patch, last commit was only partial for some reason)
........
r4678 | mikeL | 2008-07-16 01:18:52 +0100 (Wed, 16 Jul 2008) | 1 line
Addresses almost all of rjek and jmb's concerns, fixes most of the sloppiness that was present earlier. Downloads without a total_size are now handled correctly (thanks tlsa). Changes to the default download directly are now saved correctly. Billions of other small bugs fixed
........
svn path=/trunk/netsurf/; revision=4681
2008-07-16 14:19:30 +04:00
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
selection_set_start(s, idx);
|
|
|
|
selection_set_end(s, idx);
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
s->drag_state = DRAG_END;
|
|
|
|
|
2014-01-14 02:54:19 +04:00
|
|
|
guit->window->start_selection(top->window);
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
else if (mouse & BROWSER_MOUSE_DRAG_2) {
|
|
|
|
|
|
|
|
/* adjust selection, but only if there is one */
|
|
|
|
if (!selection_defined(s))
|
|
|
|
return false; /* ignore Adjust drags */
|
|
|
|
|
2008-03-30 01:26:04 +03:00
|
|
|
if (pos >= 0) {
|
2006-02-16 02:09:55 +03:00
|
|
|
selection_set_end(s, idx);
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
s->drag_state = DRAG_END;
|
|
|
|
}
|
|
|
|
else {
|
2006-02-16 02:09:55 +03:00
|
|
|
selection_set_start(s, idx);
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
s->drag_state = DRAG_START;
|
|
|
|
}
|
2011-06-15 00:00:18 +04:00
|
|
|
|
2014-01-14 02:54:19 +04:00
|
|
|
guit->window->start_selection(top->window);
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
else if (mouse & BROWSER_MOUSE_CLICK_2) {
|
|
|
|
|
|
|
|
/* ignore Adjust clicks when there's no selection */
|
|
|
|
if (!selection_defined(s))
|
|
|
|
return false;
|
|
|
|
|
2008-03-30 01:26:04 +03:00
|
|
|
if (pos >= 0)
|
2006-02-16 02:09:55 +03:00
|
|
|
selection_set_end(s, idx);
|
2005-04-15 09:51:32 +04:00
|
|
|
else
|
2006-02-16 02:09:55 +03:00
|
|
|
selection_set_start(s, idx);
|
2005-04-15 09:51:32 +04:00
|
|
|
s->drag_state = DRAG_NONE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* not our problem */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this mouse click is selection-related */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles movements related to the selection, eg. dragging of start and
|
|
|
|
* end points.
|
|
|
|
*
|
|
|
|
* \param s selection object
|
|
|
|
* \param mouse state of mouse buttons and modifier keys
|
2006-02-16 02:09:55 +03:00
|
|
|
* \param idx byte offset within text representation
|
2005-04-15 09:51:32 +04:00
|
|
|
*/
|
|
|
|
|
2008-03-31 22:59:23 +04:00
|
|
|
void selection_track(struct selection *s, browser_mouse_state mouse,
|
|
|
|
unsigned idx)
|
2005-04-15 09:51:32 +04:00
|
|
|
{
|
2011-07-13 17:20:26 +04:00
|
|
|
if (!mouse) {
|
|
|
|
s->drag_state = DRAG_NONE;
|
|
|
|
}
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
switch (s->drag_state) {
|
|
|
|
|
|
|
|
case DRAG_START:
|
2006-02-16 02:09:55 +03:00
|
|
|
if (idx > s->end_idx) {
|
2005-07-21 03:27:28 +04:00
|
|
|
unsigned old_end = s->end_idx;
|
2006-02-16 02:09:55 +03:00
|
|
|
selection_set_end(s, idx);
|
|
|
|
selection_set_start(s, old_end);
|
2005-04-15 09:51:32 +04:00
|
|
|
s->drag_state = DRAG_END;
|
|
|
|
}
|
|
|
|
else
|
2006-02-16 02:09:55 +03:00
|
|
|
selection_set_start(s, idx);
|
2005-04-15 09:51:32 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAG_END:
|
2006-02-16 02:09:55 +03:00
|
|
|
if (idx < s->start_idx) {
|
2005-07-21 03:27:28 +04:00
|
|
|
unsigned old_start = s->start_idx;
|
2006-02-16 02:09:55 +03:00
|
|
|
selection_set_start(s, idx);
|
|
|
|
selection_set_end(s, old_start);
|
2005-04-15 09:51:32 +04:00
|
|
|
s->drag_state = DRAG_START;
|
|
|
|
}
|
|
|
|
else
|
2006-02-16 02:09:55 +03:00
|
|
|
selection_set_end(s, idx);
|
2005-04-15 09:51:32 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-24 10:13:25 +04:00
|
|
|
/**
|
|
|
|
* Tests whether a text box lies partially within the given range of
|
|
|
|
* byte offsets, returning the start and end indexes of the bytes
|
|
|
|
* that are enclosed.
|
|
|
|
*
|
|
|
|
* \param box box to be tested
|
|
|
|
* \param start_idx byte offset of start of range
|
|
|
|
* \param end_idx byte offset of end of range
|
|
|
|
* \param start_offset receives the start offset of the selected part
|
|
|
|
* \param end_offset receives the end offset of the selected part
|
|
|
|
* \return true iff the range encloses at least part of the box
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool selected_part(struct box *box, unsigned start_idx, unsigned end_idx,
|
|
|
|
unsigned *start_offset, unsigned *end_offset)
|
|
|
|
{
|
2011-03-06 21:04:13 +03:00
|
|
|
size_t box_length = box->length + SPACE_LEN(box);
|
2005-07-24 10:13:25 +04:00
|
|
|
|
2005-09-01 07:20:21 +04:00
|
|
|
if (box_length > 0) {
|
|
|
|
if (box->byte_offset >= start_idx &&
|
|
|
|
box->byte_offset + box_length <= end_idx) {
|
2006-04-26 21:26:03 +04:00
|
|
|
|
2005-09-01 07:20:21 +04:00
|
|
|
/* fully enclosed */
|
|
|
|
*start_offset = 0;
|
|
|
|
*end_offset = box_length;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (box->byte_offset + box_length > start_idx &&
|
|
|
|
box->byte_offset < end_idx) {
|
|
|
|
/* partly enclosed */
|
|
|
|
int offset = 0;
|
|
|
|
int len;
|
2006-04-26 21:26:03 +04:00
|
|
|
|
2005-09-01 07:20:21 +04:00
|
|
|
if (box->byte_offset < start_idx)
|
|
|
|
offset = start_idx - box->byte_offset;
|
2006-04-26 21:26:03 +04:00
|
|
|
|
2005-09-01 07:20:21 +04:00
|
|
|
len = box_length - offset;
|
2006-04-26 21:26:03 +04:00
|
|
|
|
2005-09-01 07:20:21 +04:00
|
|
|
if (box->byte_offset + box_length > end_idx)
|
|
|
|
len = end_idx - (box->byte_offset + offset);
|
2006-04-26 21:26:03 +04:00
|
|
|
|
2005-09-01 07:20:21 +04:00
|
|
|
*start_offset = offset;
|
|
|
|
*end_offset = offset + len;
|
2006-04-26 21:26:03 +04:00
|
|
|
|
2005-09-01 07:20:21 +04:00
|
|
|
return true;
|
|
|
|
}
|
2005-07-24 10:13:25 +04:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
/**
|
|
|
|
* Traverse the given box subtree, calling the handler function (with its handle)
|
|
|
|
* for all boxes that lie (partially) within the given range
|
|
|
|
*
|
|
|
|
* \param box box subtree
|
2018-01-04 02:58:18 +03:00
|
|
|
* \param len_ctx Length conversion context.
|
2005-04-15 09:51:32 +04:00
|
|
|
* \param start_idx start of range within textual representation (bytes)
|
|
|
|
* \param end_idx end of range
|
|
|
|
* \param handler handler function to call
|
|
|
|
* \param handle handle to pass
|
2008-03-31 22:04:36 +04:00
|
|
|
* \param before type of whitespace to place before next encountered text
|
|
|
|
* \param first whether this is the first box with text
|
2008-04-07 13:00:21 +04:00
|
|
|
* \param do_marker whether deal enter any marker box
|
2005-04-15 09:51:32 +04:00
|
|
|
* \return false iff traversal abandoned part-way through
|
|
|
|
*/
|
|
|
|
|
2018-01-04 02:58:18 +03:00
|
|
|
bool traverse_tree(
|
|
|
|
struct box *box, const nscss_len_ctx *len_ctx,
|
|
|
|
unsigned start_idx, unsigned end_idx,
|
2013-02-07 18:21:48 +04:00
|
|
|
seln_traverse_handler handler,
|
2008-04-13 22:21:22 +04:00
|
|
|
void *handle, save_text_whitespace *before, bool *first,
|
2008-04-07 13:00:21 +04:00
|
|
|
bool do_marker)
|
2005-04-15 09:51:32 +04:00
|
|
|
{
|
|
|
|
struct box *child;
|
2008-03-31 22:04:36 +04:00
|
|
|
const char *whitespace_text = "";
|
2008-03-31 22:59:23 +04:00
|
|
|
size_t whitespace_length = 0;
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
assert(box);
|
2008-04-07 13:00:21 +04:00
|
|
|
|
|
|
|
/* If selection starts inside marker */
|
2008-06-04 02:18:15 +04:00
|
|
|
if (box->parent && box->parent->list_marker == box && !do_marker) {
|
2008-04-07 13:00:21 +04:00
|
|
|
/* set box to main list element */
|
|
|
|
box = box->parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If box has a list marker */
|
|
|
|
if (box->list_marker) {
|
|
|
|
/* do the marker box before continuing with the rest of the
|
|
|
|
* list element */
|
2018-01-04 02:58:18 +03:00
|
|
|
if (!traverse_tree(box->list_marker, len_ctx,
|
|
|
|
start_idx, end_idx, handler, handle,
|
|
|
|
before, first, true))
|
2008-04-07 13:00:21 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we can prune this subtree, it's after the selection */
|
2005-04-15 09:51:32 +04:00
|
|
|
if (box->byte_offset >= end_idx)
|
|
|
|
return true;
|
|
|
|
|
2005-07-21 03:27:28 +04:00
|
|
|
/* read before calling the handler in case it modifies the tree */
|
|
|
|
child = box->children;
|
|
|
|
|
2008-03-31 22:04:36 +04:00
|
|
|
/* If nicely formatted output of the selected text is required, work
|
|
|
|
* out what whitespace should be placed before the next bit of text */
|
|
|
|
if (before) {
|
2008-04-13 22:21:22 +04:00
|
|
|
save_text_solve_whitespace(box, first, before, &whitespace_text,
|
|
|
|
&whitespace_length);
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-03-31 22:04:36 +04:00
|
|
|
whitespace_text = NULL;
|
|
|
|
}
|
2013-02-07 18:21:48 +04:00
|
|
|
if (box->type != BOX_BR &&
|
2008-04-11 19:52:56 +04:00
|
|
|
!((box->type == BOX_FLOAT_LEFT ||
|
|
|
|
box->type == BOX_FLOAT_RIGHT) &&
|
|
|
|
!box->text)) {
|
2008-03-31 22:04:36 +04:00
|
|
|
unsigned start_offset;
|
|
|
|
unsigned end_offset;
|
|
|
|
|
|
|
|
if (selected_part(box, start_idx, end_idx, &start_offset,
|
|
|
|
&end_offset)) {
|
|
|
|
if (!handler(box->text + start_offset, min(box->length,
|
|
|
|
end_offset) - start_offset,
|
2018-01-04 02:58:18 +03:00
|
|
|
box, len_ctx, handle, whitespace_text,
|
2008-03-31 22:59:23 +04:00
|
|
|
whitespace_length))
|
2005-04-15 09:51:32 +04:00
|
|
|
return false;
|
2008-03-31 22:04:36 +04:00
|
|
|
if (before) {
|
|
|
|
*first = false;
|
|
|
|
*before = WHITESPACE_NONE;
|
|
|
|
}
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find the first child that could lie partially within the selection;
|
2008-03-31 22:04:36 +04:00
|
|
|
* this is important at the top-levels of the tree for pruning subtrees
|
|
|
|
* that lie entirely before the selection */
|
2005-04-15 09:51:32 +04:00
|
|
|
|
|
|
|
if (child) {
|
|
|
|
struct box *next = child->next;
|
|
|
|
|
|
|
|
while (next && next->byte_offset < start_idx) {
|
|
|
|
child = next;
|
|
|
|
next = child->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (child) {
|
2008-03-31 22:04:36 +04:00
|
|
|
/* read before calling the handler in case it modifies
|
|
|
|
* the tree */
|
2005-07-21 03:27:28 +04:00
|
|
|
struct box *next = child->next;
|
|
|
|
|
2018-01-04 02:58:18 +03:00
|
|
|
if (!traverse_tree(child, len_ctx, start_idx, end_idx,
|
2008-04-07 13:00:21 +04:00
|
|
|
handler, handle, before, first, false))
|
2005-04-15 09:51:32 +04:00
|
|
|
return false;
|
2005-07-21 03:27:28 +04:00
|
|
|
|
|
|
|
child = next;
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-03-31 22:04:36 +04:00
|
|
|
* Traverse the current selection, calling the handler function (with its
|
|
|
|
* handle) for all boxes that lie (partially) within the given range
|
2005-04-15 09:51:32 +04:00
|
|
|
*
|
2014-11-10 20:00:15 +03:00
|
|
|
* \param s The selection context.
|
|
|
|
* \param handler handler function to call
|
|
|
|
* \param handle handle to pass
|
2005-04-15 09:51:32 +04:00
|
|
|
* \return false iff traversal abandoned part-way through
|
|
|
|
*/
|
|
|
|
|
2012-08-13 20:48:03 +04:00
|
|
|
static bool selection_traverse(struct selection *s,
|
|
|
|
seln_traverse_handler handler, void *handle)
|
2005-04-15 09:51:32 +04:00
|
|
|
{
|
2008-04-13 22:21:22 +04:00
|
|
|
save_text_whitespace before = WHITESPACE_NONE;
|
2008-03-31 22:04:36 +04:00
|
|
|
bool first = true;
|
2008-07-29 13:28:45 +04:00
|
|
|
const char *text;
|
|
|
|
size_t length;
|
2006-02-16 02:09:55 +03:00
|
|
|
|
|
|
|
if (!selection_defined(s))
|
|
|
|
return true; /* easy case, nothing to do */
|
|
|
|
|
2011-07-01 15:16:43 +04:00
|
|
|
if (s->root) {
|
|
|
|
/* HTML */
|
2018-01-04 02:58:18 +03:00
|
|
|
return traverse_tree(s->root, &s->len_ctx,
|
|
|
|
s->start_idx, s->end_idx,
|
|
|
|
handler, handle,
|
|
|
|
&before, &first, false);
|
2011-07-01 15:16:43 +04:00
|
|
|
}
|
2006-02-16 02:09:55 +03:00
|
|
|
|
2011-07-01 15:16:43 +04:00
|
|
|
/* Text */
|
2011-07-26 17:53:42 +04:00
|
|
|
text = textplain_get_raw_data(s->c, s->start_idx, s->end_idx, &length);
|
2006-02-16 02:09:55 +03:00
|
|
|
|
2018-01-04 02:58:18 +03:00
|
|
|
if (text && !handler(text, length, NULL, NULL, handle, NULL, 0))
|
2006-02-16 02:09:55 +03:00
|
|
|
return false;
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selection traversal handler for redrawing the screen when the selection
|
|
|
|
* has been altered.
|
|
|
|
*
|
2008-03-31 22:59:23 +04:00
|
|
|
* \param text pointer to text string
|
|
|
|
* \param length length of text to be appended (bytes)
|
|
|
|
* \param box pointer to text box being (partially) added
|
|
|
|
* \param handle unused handle, we don't need one
|
|
|
|
* \param whitespace_text whitespace to place before text for formatting
|
|
|
|
* may be NULL
|
|
|
|
* \param whitespace_length length of whitespace_text
|
2005-04-15 09:51:32 +04:00
|
|
|
* \return true iff successful and traversal should continue
|
|
|
|
*/
|
|
|
|
|
2008-03-31 22:04:36 +04:00
|
|
|
bool redraw_handler(const char *text, size_t length, struct box *box,
|
2018-01-04 02:58:18 +03:00
|
|
|
const nscss_len_ctx *len_ctx, void *handle,
|
|
|
|
const char *whitespace_text, size_t whitespace_length)
|
2005-04-15 09:51:32 +04:00
|
|
|
{
|
|
|
|
if (box) {
|
|
|
|
struct rdw_info *r = (struct rdw_info*)handle;
|
2011-03-06 21:04:13 +03:00
|
|
|
int width, height;
|
2005-04-15 09:51:32 +04:00
|
|
|
int x, y;
|
2009-07-21 14:59:53 +04:00
|
|
|
plot_font_style_t fstyle;
|
|
|
|
|
2018-01-04 02:58:18 +03:00
|
|
|
font_plot_style_from_css(len_ctx, box->style, &fstyle);
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
/* \todo - it should be possible to reduce the redrawn area by
|
2008-03-31 22:04:36 +04:00
|
|
|
* considering the 'text', 'length' and 'space' parameters */
|
2005-04-15 09:51:32 +04:00
|
|
|
box_coords(box, &x, &y);
|
|
|
|
|
|
|
|
width = box->padding[LEFT] + box->width + box->padding[RIGHT];
|
|
|
|
height = box->padding[TOP] + box->height + box->padding[BOTTOM];
|
|
|
|
|
2011-03-06 21:04:13 +03:00
|
|
|
if (box->type == BOX_TEXT && box->space != 0)
|
|
|
|
width += box->space;
|
2008-04-07 13:00:21 +04:00
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
if (r->inited) {
|
2006-02-16 02:09:55 +03:00
|
|
|
if (x < r->r.x0) r->r.x0 = x;
|
|
|
|
if (y < r->r.y0) r->r.y0 = y;
|
|
|
|
if (x + width > r->r.x1) r->r.x1 = x + width;
|
|
|
|
if (y + height > r->r.y1) r->r.y1 = y + height;
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
r->inited = true;
|
2006-02-16 02:09:55 +03:00
|
|
|
r->r.x0 = x;
|
|
|
|
r->r.y0 = y;
|
|
|
|
r->r.x1 = x + width;
|
|
|
|
r->r.y1 = y + height;
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Redraws the given range of text.
|
|
|
|
*
|
|
|
|
* \param s selection object
|
|
|
|
* \param start_idx start offset (bytes) within the textual representation
|
|
|
|
* \param end_idx end offset (bytes) within the textual representation
|
|
|
|
*/
|
|
|
|
|
|
|
|
void selection_redraw(struct selection *s, unsigned start_idx, unsigned end_idx)
|
|
|
|
{
|
|
|
|
struct rdw_info rdw;
|
|
|
|
|
|
|
|
assert(end_idx >= start_idx);
|
|
|
|
rdw.inited = false;
|
2006-02-16 02:09:55 +03:00
|
|
|
|
|
|
|
if (s->root) {
|
2018-01-04 02:58:18 +03:00
|
|
|
if (!traverse_tree(s->root, &s->len_ctx, start_idx, end_idx,
|
2013-02-07 18:21:48 +04:00
|
|
|
redraw_handler, &rdw,
|
2008-04-07 13:00:21 +04:00
|
|
|
NULL, NULL, false))
|
2006-02-16 02:09:55 +03:00
|
|
|
return;
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
2006-02-16 02:09:55 +03:00
|
|
|
else {
|
2011-07-26 17:53:42 +04:00
|
|
|
if (s->is_html == false && end_idx > start_idx) {
|
|
|
|
textplain_coords_from_range(s->c, start_idx,
|
2008-03-31 22:04:36 +04:00
|
|
|
end_idx, &rdw.r);
|
2006-02-16 02:09:55 +03:00
|
|
|
rdw.inited = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rdw.inited)
|
2011-07-26 17:53:42 +04:00
|
|
|
content__request_redraw(s->c, rdw.r.x0, rdw.r.y0,
|
2011-06-15 00:00:18 +04:00
|
|
|
rdw.r.x1 - rdw.r.x0, rdw.r.y1 - rdw.r.y0);
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-13 20:09:42 +04:00
|
|
|
/**
|
|
|
|
* Append text to selection string.
|
|
|
|
*
|
2014-11-10 20:00:15 +03:00
|
|
|
* \param text text to be added
|
|
|
|
* \param length length of text in bytes
|
|
|
|
* \param space indicates whether a trailing space should be appended
|
|
|
|
* \param style The font style to use.
|
|
|
|
* \param sel_string string to append to, may be resized
|
2012-08-13 20:09:42 +04:00
|
|
|
* \return true iff successful
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool selection_string_append(const char *text, size_t length, bool space,
|
2013-01-08 20:54:46 +04:00
|
|
|
plot_font_style_t *style, struct selection_string *sel_string)
|
2012-08-13 20:09:42 +04:00
|
|
|
{
|
|
|
|
size_t new_length = sel_string->length + length + (space ? 1 : 0) + 1;
|
|
|
|
|
2013-01-08 20:54:46 +04:00
|
|
|
if (style != NULL) {
|
|
|
|
/* Add text run style */
|
|
|
|
nsclipboard_styles *new_styles;
|
|
|
|
|
|
|
|
if (sel_string->n_styles == 0)
|
|
|
|
assert(sel_string->length == 0);
|
|
|
|
|
|
|
|
new_styles = realloc(sel_string->styles,
|
|
|
|
(sel_string->n_styles + 1) *
|
|
|
|
sizeof(nsclipboard_styles));
|
|
|
|
if (new_styles == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
sel_string->styles = new_styles;
|
|
|
|
|
|
|
|
sel_string->styles[sel_string->n_styles].style = *style;
|
|
|
|
sel_string->styles[sel_string->n_styles].start =
|
|
|
|
sel_string->length;
|
|
|
|
|
|
|
|
sel_string->n_styles++;
|
|
|
|
}
|
|
|
|
|
2012-08-13 20:09:42 +04:00
|
|
|
if (new_length > sel_string->buffer_len) {
|
2013-01-08 20:54:46 +04:00
|
|
|
/* Need to extend buffer */
|
2012-08-13 20:09:42 +04:00
|
|
|
size_t new_alloc = new_length + (new_length / 4);
|
|
|
|
char *new_buff;
|
|
|
|
|
|
|
|
new_buff = realloc(sel_string->buffer, new_alloc);
|
|
|
|
if (new_buff == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
sel_string->buffer = new_buff;
|
|
|
|
sel_string->buffer_len = new_alloc;
|
|
|
|
}
|
|
|
|
|
2013-01-08 20:54:46 +04:00
|
|
|
/* Copy text onto end of existing text in buffer */
|
2012-08-13 20:09:42 +04:00
|
|
|
memcpy(sel_string->buffer + sel_string->length, text, length);
|
|
|
|
sel_string->length += length;
|
|
|
|
|
|
|
|
if (space)
|
|
|
|
sel_string->buffer[sel_string->length++] = ' ';
|
|
|
|
|
2013-01-08 20:54:46 +04:00
|
|
|
/* Ensure NULL termination */
|
2012-08-13 20:09:42 +04:00
|
|
|
sel_string->buffer[sel_string->length] = '\0';
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selection traversal routine for appending text to a string
|
|
|
|
*
|
2018-01-04 02:58:18 +03:00
|
|
|
* \param text pointer to text being added, or NULL for newline
|
|
|
|
* \param length length of text to be appended (bytes)
|
|
|
|
* \param box pointer to text box, or NULL if from textplain
|
|
|
|
* \param len_ctx Length conversion context
|
|
|
|
* \param handle selection string to append to
|
2012-08-13 20:09:42 +04:00
|
|
|
* \param whitespace_text whitespace to place before text for formatting
|
|
|
|
* may be NULL
|
|
|
|
* \param whitespace_length length of whitespace_text
|
|
|
|
* \return true iff successful and traversal should continue
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool selection_copy_handler(const char *text, size_t length,
|
2018-01-04 02:58:18 +03:00
|
|
|
struct box *box, const nscss_len_ctx *len_ctx,
|
|
|
|
void *handle, const char *whitespace_text,
|
2012-08-13 20:09:42 +04:00
|
|
|
size_t whitespace_length)
|
|
|
|
{
|
|
|
|
bool add_space = false;
|
2013-01-08 20:54:46 +04:00
|
|
|
plot_font_style_t style;
|
|
|
|
plot_font_style_t *pstyle = NULL;
|
2012-08-13 20:09:42 +04:00
|
|
|
|
|
|
|
/* add any whitespace which precedes the text from this box */
|
|
|
|
if (whitespace_text != NULL && whitespace_length > 0) {
|
|
|
|
if (!selection_string_append(whitespace_text,
|
2013-01-08 20:54:46 +04:00
|
|
|
whitespace_length, false, pstyle, handle)) {
|
2012-08-13 20:09:42 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (box != NULL) {
|
|
|
|
/* HTML */
|
|
|
|
add_space = (box->space != 0);
|
2013-01-08 20:54:46 +04:00
|
|
|
|
|
|
|
if (box->style != NULL) {
|
|
|
|
/* Override default font style */
|
2018-01-04 02:58:18 +03:00
|
|
|
font_plot_style_from_css(len_ctx, box->style, &style);
|
2013-01-08 20:54:46 +04:00
|
|
|
pstyle = &style;
|
|
|
|
} else {
|
|
|
|
/* If there's no style, there must be no text */
|
|
|
|
assert(box->text == NULL);
|
|
|
|
}
|
2012-08-13 20:09:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add the text from this box */
|
2013-01-08 20:54:46 +04:00
|
|
|
if (!selection_string_append(text, length, add_space, pstyle, handle))
|
2012-08-13 20:09:42 +04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get copy of selection as string
|
|
|
|
*
|
|
|
|
* \param s selection
|
|
|
|
* \return string of selected text, or NULL. Ownership passed to caller.
|
|
|
|
*/
|
|
|
|
|
2013-01-08 20:54:46 +04:00
|
|
|
char *selection_get_copy(struct selection *s)
|
2012-08-13 20:09:42 +04:00
|
|
|
{
|
2012-08-13 20:21:04 +04:00
|
|
|
struct selection_string sel_string = {
|
|
|
|
.buffer = NULL,
|
|
|
|
.buffer_len = 0,
|
2013-01-08 20:54:46 +04:00
|
|
|
.length = 0,
|
|
|
|
|
|
|
|
.n_styles = 0,
|
|
|
|
.styles = NULL
|
2012-08-13 20:21:04 +04:00
|
|
|
};
|
2012-08-13 20:09:42 +04:00
|
|
|
|
2012-08-13 20:38:09 +04:00
|
|
|
if (s == NULL || !s->defined)
|
2012-08-13 20:09:42 +04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!selection_traverse(s, selection_copy_handler, &sel_string)) {
|
2013-01-08 20:54:46 +04:00
|
|
|
free(sel_string.buffer);
|
|
|
|
free(sel_string.styles);
|
2012-08-13 20:09:42 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-01-08 20:54:46 +04:00
|
|
|
free(sel_string.styles);
|
|
|
|
|
2012-08-13 20:09:42 +04:00
|
|
|
return sel_string.buffer;
|
2012-08-02 17:23:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-08 20:54:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy the selected contents to the clipboard
|
|
|
|
*
|
|
|
|
* \param s selection
|
|
|
|
* \return true iff successful
|
|
|
|
*/
|
|
|
|
bool selection_copy_to_clipboard(struct selection *s)
|
|
|
|
{
|
|
|
|
struct selection_string sel_string = {
|
|
|
|
.buffer = NULL,
|
|
|
|
.buffer_len = 0,
|
|
|
|
.length = 0,
|
|
|
|
|
|
|
|
.n_styles = 0,
|
|
|
|
.styles = NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
if (s == NULL || !s->defined)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!selection_traverse(s, selection_copy_handler, &sel_string)) {
|
|
|
|
free(sel_string.buffer);
|
|
|
|
free(sel_string.styles);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-15 23:37:05 +04:00
|
|
|
guit->clipboard->set(sel_string.buffer, sel_string.length,
|
2013-01-08 20:54:46 +04:00
|
|
|
sel_string.styles, sel_string.n_styles);
|
|
|
|
|
|
|
|
free(sel_string.buffer);
|
|
|
|
free(sel_string.styles);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
/**
|
|
|
|
* Clears the current selection, optionally causing the screen to be updated.
|
|
|
|
*
|
|
|
|
* \param s selection object
|
|
|
|
* \param redraw true iff the previously selected region of the browser
|
|
|
|
* window should be redrawn
|
|
|
|
*/
|
|
|
|
|
|
|
|
void selection_clear(struct selection *s, bool redraw)
|
|
|
|
{
|
|
|
|
int old_start, old_end;
|
|
|
|
bool was_defined;
|
|
|
|
|
|
|
|
assert(s);
|
|
|
|
was_defined = selection_defined(s);
|
|
|
|
old_start = s->start_idx;
|
|
|
|
old_end = s->end_idx;
|
|
|
|
|
|
|
|
s->defined = false;
|
|
|
|
s->start_idx = 0;
|
|
|
|
s->end_idx = 0;
|
|
|
|
|
|
|
|
if (redraw && was_defined)
|
|
|
|
selection_redraw(s, old_start, old_end);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects all the text within the box subtree controlled by
|
|
|
|
* this selection object, updating the screen accordingly.
|
|
|
|
*
|
|
|
|
* \param s selection object
|
|
|
|
*/
|
|
|
|
|
|
|
|
void selection_select_all(struct selection *s)
|
|
|
|
{
|
|
|
|
assert(s);
|
|
|
|
s->defined = true;
|
Merged revisions 4282-4285,4288-4293,4297-4298,4307,4309-4313,4322,4324-4680 via svnmerge from
svn://svn.netsurf-browser.org/branches/mikeL/netsurf
........
r4432 | mikeL | 2008-06-24 04:00:36 +0100 (Tue, 24 Jun 2008) | 1 line
Drag events are now emited from where the press originated, instead of from where they became a drag
........
r4433 | mikeL | 2008-06-24 04:25:33 +0100 (Tue, 24 Jun 2008) | 1 line
Added accelerator to 'Select All'
........
r4495 | mikeL | 2008-07-02 21:36:32 +0100 (Wed, 02 Jul 2008) | 1 line
Selections are now deleted and replaced when a key is typed in a text area or text box. All input box behavior while a selection is active is now implemented (ex: pressing the right arrow key moves the caret to the end of the selection). Cut now works properly in both versions. Fixed discrepancy between where the caret was placed and selection began when starting a drag-select. Fixed bug with calculation of a selections end box.
........
r4496 | mikeL | 2008-07-02 22:11:24 +0100 (Wed, 02 Jul 2008) | 1 line
Added support for cut in input boxes
........
r4497 | mikeL | 2008-07-02 22:21:35 +0100 (Wed, 02 Jul 2008) | 1 line
Removed unused variables (Thanks tlsa)
........
r4498 | mikeL | 2008-07-02 23:30:30 +0100 (Wed, 02 Jul 2008) | 1 line
Modified selection clearing behavior to allow for drag-saves
........
r4499 | mikeL | 2008-07-03 00:51:50 +0100 (Thu, 03 Jul 2008) | 1 line
Fixed regression where it would take two clicks to place caret in an input (Thanks tlsa)
........
r4509 | mikeL | 2008-07-06 07:55:09 +0100 (Sun, 06 Jul 2008) | 1 line
Basic download support implemented. Only downloading of text files works
........
r4510 | mikeL | 2008-07-06 18:55:31 +0100 (Sun, 06 Jul 2008) | 1 line
Downloading of non-text files is now possible. Progress bar and size downloaded are now updated
........
r4511 | mikeL | 2008-07-06 20:46:00 +0100 (Sun, 06 Jul 2008) | 1 line
Added downloads glade file
........
r4512 | mikeL | 2008-07-06 20:47:39 +0100 (Sun, 06 Jul 2008) | 1 line
Downloads window now spawns in the center of the parent browser window
........
r4513 | mikeL | 2008-07-06 20:56:12 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed bug where backspace would be ignored if the selection began at the beginning on an input
........
r4514 | mikeL | 2008-07-06 21:26:45 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed compiler warnings by adding casts
........
r4516 | mikeL | 2008-07-06 21:32:41 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed initialization of size string, added initialization of progress
........
r4518 | mikeL | 2008-07-06 21:51:08 +0100 (Sun, 06 Jul 2008) | 1 line
Added an option for short units (with space) to human_friendly_bytesize
........
r4519 | mikeL | 2008-07-06 21:52:05 +0100 (Sun, 06 Jul 2008) | 1 line
Removed function size_to_string
........
r4520 | mikeL | 2008-07-06 22:03:11 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed pedantic error (kB instead of KB). Added missing necessary parameters to human_friendly_bytesize. Fixed incorrect bool types
........
r4521 | mikeL | 2008-07-06 22:08:15 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnecessary parameter and units list from human_friendly_bytesize
........
r4522 | mikeL | 2008-07-06 22:57:03 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnused variable
........
r4523 | mikeL | 2008-07-06 23:03:46 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed url parsing by replacing url_parse_filename with url_nice. Total size and size downloaded are now in human readable form. Speed is now calculated (roughly)
........
r4524 | mikeL | 2008-07-07 01:19:01 +0100 (Mon, 07 Jul 2008) | 1 line
Added file overwrite confirmation. Changed speed to a double
........
r4546 | mikeL | 2008-07-09 17:21:43 +0100 (Wed, 09 Jul 2008) | 1 line
Changed parameter of selection_get_end/start to a size_t instead of int and changed all offset variables to size_t as well
........
r4547 | mikeL | 2008-07-09 17:30:47 +0100 (Wed, 09 Jul 2008) | 1 line
Added action buttons to the bottom toolbar. Added ability to clear selected (and completed) downloads with a framework for other actions.
........
r4556 | jmb | 2008-07-10 00:17:24 +0100 (Thu, 10 Jul 2008) | 3 lines
A large bunch of tidying and general fixes to text input handling.
Make selection code treat password fields as inputs, too.
........
r4557 | mikeL | 2008-07-10 00:24:46 +0100 (Thu, 10 Jul 2008) | 1 line
Added functionality to gui_empty_clipboard and gui_start_selection (Thanks jmb)
........
r4573 | mikeL | 2008-07-10 16:33:27 +0100 (Thu, 10 Jul 2008) | 1 line
Removed example download. Made the list store row aware of its download and vise versa. Added new way of handling actions from the dialog (e.g. buttons) which handles all rows in the selection. Added a few memory management function calls to clean up better
........
r4577 | mikeL | 2008-07-10 21:11:51 +0100 (Thu, 10 Jul 2008) | 1 line
Download write channels now close properly. Added status column to the tree store which will change the progress bar text if a download is canceled or completed. Implemented cancel button functionality.
........
r4578 | mikeL | 2008-07-10 21:17:51 +0100 (Thu, 10 Jul 2008) | 1 line
Speed is now displayed as '-' when 0 or download has stopped
........
r4580 | mikeL | 2008-07-11 02:10:57 +0100 (Fri, 11 Jul 2008) | 1 line
Added two download related options (Download directory & Clear completed downloads) and a Downloads tab to the preferences dialog. Also moved the option to ask when overwriting files to Downloads tab. Added another option to the pre-download dialog, Save, which downloads the file immediately to your 'Download directory'
........
r4581 | mikeL | 2008-07-11 02:26:00 +0100 (Fri, 11 Jul 2008) | 1 line
Rearranged pre-download dialog buttons to conform to the HIG
........
r4616 | mikeL | 2008-07-11 19:54:12 +0100 (Fri, 11 Jul 2008) | 1 line
Limited download window updates to a user-defined variable that can be set in options (default is .5). Updates are now only done if the download window is visible. This greatly reduces the cpu usage.
........
r4617 | mikeL | 2008-07-11 20:07:48 +0100 (Fri, 11 Jul 2008) | 1 line
Removed unnecessary update limit option (it is now fixed at .5)
........
r4629 | mikeL | 2008-07-13 04:21:07 +0100 (Sun, 13 Jul 2008) | 1 line
Reorganized button sensitivity functions. Sensitivities are now updated when the selection changes as well as when a selected download's state changes.
........
r4635 | mikeL | 2008-07-13 17:00:05 +0100 (Sun, 13 Jul 2008) | 1 line
Added error handling. Added word-wrap to the "info" cell renderer so that to keep everything under control. Fixed bug where downloads would always go to you default folder (missing breaks).
........
r4642 | mikeL | 2008-07-13 21:46:09 +0100 (Sun, 13 Jul 2008) | 1 line
Added time remaining column. Fixed regression where the download info would be erased upon completion/cancelation.
........
r4655 | mikeL | 2008-07-14 23:20:33 +0100 (Mon, 14 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. When it is closed (when NS shuts down) all incomplete downloads are canceled (and the files deleted). Added a warning dialog when netsurf tries to close with incomplete downloads. Fixed bug where default save directory would initialize to NULL.
........
r4676 | mikeL | 2008-07-15 21:01:17 +0100 (Tue, 15 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. (This is the second half of the patch, last commit was only partial for some reason)
........
r4678 | mikeL | 2008-07-16 01:18:52 +0100 (Wed, 16 Jul 2008) | 1 line
Addresses almost all of rjek and jmb's concerns, fixes most of the sloppiness that was present earlier. Downloads without a total_size are now handled correctly (thanks tlsa). Changes to the default download directly are now saved correctly. Billions of other small bugs fixed
........
svn path=/trunk/netsurf/; revision=4681
2008-07-16 14:19:30 +04:00
|
|
|
|
2013-02-07 18:21:48 +04:00
|
|
|
selection_set_start(s, 0);
|
Merged revisions 4282-4285,4288-4293,4297-4298,4307,4309-4313,4322,4324-4680 via svnmerge from
svn://svn.netsurf-browser.org/branches/mikeL/netsurf
........
r4432 | mikeL | 2008-06-24 04:00:36 +0100 (Tue, 24 Jun 2008) | 1 line
Drag events are now emited from where the press originated, instead of from where they became a drag
........
r4433 | mikeL | 2008-06-24 04:25:33 +0100 (Tue, 24 Jun 2008) | 1 line
Added accelerator to 'Select All'
........
r4495 | mikeL | 2008-07-02 21:36:32 +0100 (Wed, 02 Jul 2008) | 1 line
Selections are now deleted and replaced when a key is typed in a text area or text box. All input box behavior while a selection is active is now implemented (ex: pressing the right arrow key moves the caret to the end of the selection). Cut now works properly in both versions. Fixed discrepancy between where the caret was placed and selection began when starting a drag-select. Fixed bug with calculation of a selections end box.
........
r4496 | mikeL | 2008-07-02 22:11:24 +0100 (Wed, 02 Jul 2008) | 1 line
Added support for cut in input boxes
........
r4497 | mikeL | 2008-07-02 22:21:35 +0100 (Wed, 02 Jul 2008) | 1 line
Removed unused variables (Thanks tlsa)
........
r4498 | mikeL | 2008-07-02 23:30:30 +0100 (Wed, 02 Jul 2008) | 1 line
Modified selection clearing behavior to allow for drag-saves
........
r4499 | mikeL | 2008-07-03 00:51:50 +0100 (Thu, 03 Jul 2008) | 1 line
Fixed regression where it would take two clicks to place caret in an input (Thanks tlsa)
........
r4509 | mikeL | 2008-07-06 07:55:09 +0100 (Sun, 06 Jul 2008) | 1 line
Basic download support implemented. Only downloading of text files works
........
r4510 | mikeL | 2008-07-06 18:55:31 +0100 (Sun, 06 Jul 2008) | 1 line
Downloading of non-text files is now possible. Progress bar and size downloaded are now updated
........
r4511 | mikeL | 2008-07-06 20:46:00 +0100 (Sun, 06 Jul 2008) | 1 line
Added downloads glade file
........
r4512 | mikeL | 2008-07-06 20:47:39 +0100 (Sun, 06 Jul 2008) | 1 line
Downloads window now spawns in the center of the parent browser window
........
r4513 | mikeL | 2008-07-06 20:56:12 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed bug where backspace would be ignored if the selection began at the beginning on an input
........
r4514 | mikeL | 2008-07-06 21:26:45 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed compiler warnings by adding casts
........
r4516 | mikeL | 2008-07-06 21:32:41 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed initialization of size string, added initialization of progress
........
r4518 | mikeL | 2008-07-06 21:51:08 +0100 (Sun, 06 Jul 2008) | 1 line
Added an option for short units (with space) to human_friendly_bytesize
........
r4519 | mikeL | 2008-07-06 21:52:05 +0100 (Sun, 06 Jul 2008) | 1 line
Removed function size_to_string
........
r4520 | mikeL | 2008-07-06 22:03:11 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed pedantic error (kB instead of KB). Added missing necessary parameters to human_friendly_bytesize. Fixed incorrect bool types
........
r4521 | mikeL | 2008-07-06 22:08:15 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnecessary parameter and units list from human_friendly_bytesize
........
r4522 | mikeL | 2008-07-06 22:57:03 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnused variable
........
r4523 | mikeL | 2008-07-06 23:03:46 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed url parsing by replacing url_parse_filename with url_nice. Total size and size downloaded are now in human readable form. Speed is now calculated (roughly)
........
r4524 | mikeL | 2008-07-07 01:19:01 +0100 (Mon, 07 Jul 2008) | 1 line
Added file overwrite confirmation. Changed speed to a double
........
r4546 | mikeL | 2008-07-09 17:21:43 +0100 (Wed, 09 Jul 2008) | 1 line
Changed parameter of selection_get_end/start to a size_t instead of int and changed all offset variables to size_t as well
........
r4547 | mikeL | 2008-07-09 17:30:47 +0100 (Wed, 09 Jul 2008) | 1 line
Added action buttons to the bottom toolbar. Added ability to clear selected (and completed) downloads with a framework for other actions.
........
r4556 | jmb | 2008-07-10 00:17:24 +0100 (Thu, 10 Jul 2008) | 3 lines
A large bunch of tidying and general fixes to text input handling.
Make selection code treat password fields as inputs, too.
........
r4557 | mikeL | 2008-07-10 00:24:46 +0100 (Thu, 10 Jul 2008) | 1 line
Added functionality to gui_empty_clipboard and gui_start_selection (Thanks jmb)
........
r4573 | mikeL | 2008-07-10 16:33:27 +0100 (Thu, 10 Jul 2008) | 1 line
Removed example download. Made the list store row aware of its download and vise versa. Added new way of handling actions from the dialog (e.g. buttons) which handles all rows in the selection. Added a few memory management function calls to clean up better
........
r4577 | mikeL | 2008-07-10 21:11:51 +0100 (Thu, 10 Jul 2008) | 1 line
Download write channels now close properly. Added status column to the tree store which will change the progress bar text if a download is canceled or completed. Implemented cancel button functionality.
........
r4578 | mikeL | 2008-07-10 21:17:51 +0100 (Thu, 10 Jul 2008) | 1 line
Speed is now displayed as '-' when 0 or download has stopped
........
r4580 | mikeL | 2008-07-11 02:10:57 +0100 (Fri, 11 Jul 2008) | 1 line
Added two download related options (Download directory & Clear completed downloads) and a Downloads tab to the preferences dialog. Also moved the option to ask when overwriting files to Downloads tab. Added another option to the pre-download dialog, Save, which downloads the file immediately to your 'Download directory'
........
r4581 | mikeL | 2008-07-11 02:26:00 +0100 (Fri, 11 Jul 2008) | 1 line
Rearranged pre-download dialog buttons to conform to the HIG
........
r4616 | mikeL | 2008-07-11 19:54:12 +0100 (Fri, 11 Jul 2008) | 1 line
Limited download window updates to a user-defined variable that can be set in options (default is .5). Updates are now only done if the download window is visible. This greatly reduces the cpu usage.
........
r4617 | mikeL | 2008-07-11 20:07:48 +0100 (Fri, 11 Jul 2008) | 1 line
Removed unnecessary update limit option (it is now fixed at .5)
........
r4629 | mikeL | 2008-07-13 04:21:07 +0100 (Sun, 13 Jul 2008) | 1 line
Reorganized button sensitivity functions. Sensitivities are now updated when the selection changes as well as when a selected download's state changes.
........
r4635 | mikeL | 2008-07-13 17:00:05 +0100 (Sun, 13 Jul 2008) | 1 line
Added error handling. Added word-wrap to the "info" cell renderer so that to keep everything under control. Fixed bug where downloads would always go to you default folder (missing breaks).
........
r4642 | mikeL | 2008-07-13 21:46:09 +0100 (Sun, 13 Jul 2008) | 1 line
Added time remaining column. Fixed regression where the download info would be erased upon completion/cancelation.
........
r4655 | mikeL | 2008-07-14 23:20:33 +0100 (Mon, 14 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. When it is closed (when NS shuts down) all incomplete downloads are canceled (and the files deleted). Added a warning dialog when netsurf tries to close with incomplete downloads. Fixed bug where default save directory would initialize to NULL.
........
r4676 | mikeL | 2008-07-15 21:01:17 +0100 (Tue, 15 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. (This is the second half of the patch, last commit was only partial for some reason)
........
r4678 | mikeL | 2008-07-16 01:18:52 +0100 (Wed, 16 Jul 2008) | 1 line
Addresses almost all of rjek and jmb's concerns, fixes most of the sloppiness that was present earlier. Downloads without a total_size are now handled correctly (thanks tlsa). Changes to the default download directly are now saved correctly. Billions of other small bugs fixed
........
svn path=/trunk/netsurf/; revision=4681
2008-07-16 14:19:30 +04:00
|
|
|
selection_set_end(s, s->max_idx);
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
/**
|
|
|
|
* Set the start position of the current selection, updating the screen.
|
|
|
|
*
|
|
|
|
* \param s selection object
|
|
|
|
* \param offset byte offset within textual representation
|
|
|
|
*/
|
|
|
|
|
|
|
|
void selection_set_start(struct selection *s, unsigned offset)
|
2005-04-15 09:51:32 +04:00
|
|
|
{
|
|
|
|
bool was_defined = selection_defined(s);
|
2005-07-21 03:27:28 +04:00
|
|
|
unsigned old_start = s->start_idx;
|
Merged revisions 4282-4285,4288-4293,4297-4298,4307,4309-4313,4322,4324-4680 via svnmerge from
svn://svn.netsurf-browser.org/branches/mikeL/netsurf
........
r4432 | mikeL | 2008-06-24 04:00:36 +0100 (Tue, 24 Jun 2008) | 1 line
Drag events are now emited from where the press originated, instead of from where they became a drag
........
r4433 | mikeL | 2008-06-24 04:25:33 +0100 (Tue, 24 Jun 2008) | 1 line
Added accelerator to 'Select All'
........
r4495 | mikeL | 2008-07-02 21:36:32 +0100 (Wed, 02 Jul 2008) | 1 line
Selections are now deleted and replaced when a key is typed in a text area or text box. All input box behavior while a selection is active is now implemented (ex: pressing the right arrow key moves the caret to the end of the selection). Cut now works properly in both versions. Fixed discrepancy between where the caret was placed and selection began when starting a drag-select. Fixed bug with calculation of a selections end box.
........
r4496 | mikeL | 2008-07-02 22:11:24 +0100 (Wed, 02 Jul 2008) | 1 line
Added support for cut in input boxes
........
r4497 | mikeL | 2008-07-02 22:21:35 +0100 (Wed, 02 Jul 2008) | 1 line
Removed unused variables (Thanks tlsa)
........
r4498 | mikeL | 2008-07-02 23:30:30 +0100 (Wed, 02 Jul 2008) | 1 line
Modified selection clearing behavior to allow for drag-saves
........
r4499 | mikeL | 2008-07-03 00:51:50 +0100 (Thu, 03 Jul 2008) | 1 line
Fixed regression where it would take two clicks to place caret in an input (Thanks tlsa)
........
r4509 | mikeL | 2008-07-06 07:55:09 +0100 (Sun, 06 Jul 2008) | 1 line
Basic download support implemented. Only downloading of text files works
........
r4510 | mikeL | 2008-07-06 18:55:31 +0100 (Sun, 06 Jul 2008) | 1 line
Downloading of non-text files is now possible. Progress bar and size downloaded are now updated
........
r4511 | mikeL | 2008-07-06 20:46:00 +0100 (Sun, 06 Jul 2008) | 1 line
Added downloads glade file
........
r4512 | mikeL | 2008-07-06 20:47:39 +0100 (Sun, 06 Jul 2008) | 1 line
Downloads window now spawns in the center of the parent browser window
........
r4513 | mikeL | 2008-07-06 20:56:12 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed bug where backspace would be ignored if the selection began at the beginning on an input
........
r4514 | mikeL | 2008-07-06 21:26:45 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed compiler warnings by adding casts
........
r4516 | mikeL | 2008-07-06 21:32:41 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed initialization of size string, added initialization of progress
........
r4518 | mikeL | 2008-07-06 21:51:08 +0100 (Sun, 06 Jul 2008) | 1 line
Added an option for short units (with space) to human_friendly_bytesize
........
r4519 | mikeL | 2008-07-06 21:52:05 +0100 (Sun, 06 Jul 2008) | 1 line
Removed function size_to_string
........
r4520 | mikeL | 2008-07-06 22:03:11 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed pedantic error (kB instead of KB). Added missing necessary parameters to human_friendly_bytesize. Fixed incorrect bool types
........
r4521 | mikeL | 2008-07-06 22:08:15 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnecessary parameter and units list from human_friendly_bytesize
........
r4522 | mikeL | 2008-07-06 22:57:03 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnused variable
........
r4523 | mikeL | 2008-07-06 23:03:46 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed url parsing by replacing url_parse_filename with url_nice. Total size and size downloaded are now in human readable form. Speed is now calculated (roughly)
........
r4524 | mikeL | 2008-07-07 01:19:01 +0100 (Mon, 07 Jul 2008) | 1 line
Added file overwrite confirmation. Changed speed to a double
........
r4546 | mikeL | 2008-07-09 17:21:43 +0100 (Wed, 09 Jul 2008) | 1 line
Changed parameter of selection_get_end/start to a size_t instead of int and changed all offset variables to size_t as well
........
r4547 | mikeL | 2008-07-09 17:30:47 +0100 (Wed, 09 Jul 2008) | 1 line
Added action buttons to the bottom toolbar. Added ability to clear selected (and completed) downloads with a framework for other actions.
........
r4556 | jmb | 2008-07-10 00:17:24 +0100 (Thu, 10 Jul 2008) | 3 lines
A large bunch of tidying and general fixes to text input handling.
Make selection code treat password fields as inputs, too.
........
r4557 | mikeL | 2008-07-10 00:24:46 +0100 (Thu, 10 Jul 2008) | 1 line
Added functionality to gui_empty_clipboard and gui_start_selection (Thanks jmb)
........
r4573 | mikeL | 2008-07-10 16:33:27 +0100 (Thu, 10 Jul 2008) | 1 line
Removed example download. Made the list store row aware of its download and vise versa. Added new way of handling actions from the dialog (e.g. buttons) which handles all rows in the selection. Added a few memory management function calls to clean up better
........
r4577 | mikeL | 2008-07-10 21:11:51 +0100 (Thu, 10 Jul 2008) | 1 line
Download write channels now close properly. Added status column to the tree store which will change the progress bar text if a download is canceled or completed. Implemented cancel button functionality.
........
r4578 | mikeL | 2008-07-10 21:17:51 +0100 (Thu, 10 Jul 2008) | 1 line
Speed is now displayed as '-' when 0 or download has stopped
........
r4580 | mikeL | 2008-07-11 02:10:57 +0100 (Fri, 11 Jul 2008) | 1 line
Added two download related options (Download directory & Clear completed downloads) and a Downloads tab to the preferences dialog. Also moved the option to ask when overwriting files to Downloads tab. Added another option to the pre-download dialog, Save, which downloads the file immediately to your 'Download directory'
........
r4581 | mikeL | 2008-07-11 02:26:00 +0100 (Fri, 11 Jul 2008) | 1 line
Rearranged pre-download dialog buttons to conform to the HIG
........
r4616 | mikeL | 2008-07-11 19:54:12 +0100 (Fri, 11 Jul 2008) | 1 line
Limited download window updates to a user-defined variable that can be set in options (default is .5). Updates are now only done if the download window is visible. This greatly reduces the cpu usage.
........
r4617 | mikeL | 2008-07-11 20:07:48 +0100 (Fri, 11 Jul 2008) | 1 line
Removed unnecessary update limit option (it is now fixed at .5)
........
r4629 | mikeL | 2008-07-13 04:21:07 +0100 (Sun, 13 Jul 2008) | 1 line
Reorganized button sensitivity functions. Sensitivities are now updated when the selection changes as well as when a selected download's state changes.
........
r4635 | mikeL | 2008-07-13 17:00:05 +0100 (Sun, 13 Jul 2008) | 1 line
Added error handling. Added word-wrap to the "info" cell renderer so that to keep everything under control. Fixed bug where downloads would always go to you default folder (missing breaks).
........
r4642 | mikeL | 2008-07-13 21:46:09 +0100 (Sun, 13 Jul 2008) | 1 line
Added time remaining column. Fixed regression where the download info would be erased upon completion/cancelation.
........
r4655 | mikeL | 2008-07-14 23:20:33 +0100 (Mon, 14 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. When it is closed (when NS shuts down) all incomplete downloads are canceled (and the files deleted). Added a warning dialog when netsurf tries to close with incomplete downloads. Fixed bug where default save directory would initialize to NULL.
........
r4676 | mikeL | 2008-07-15 21:01:17 +0100 (Tue, 15 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. (This is the second half of the patch, last commit was only partial for some reason)
........
r4678 | mikeL | 2008-07-16 01:18:52 +0100 (Wed, 16 Jul 2008) | 1 line
Addresses almost all of rjek and jmb's concerns, fixes most of the sloppiness that was present earlier. Downloads without a total_size are now handled correctly (thanks tlsa). Changes to the default download directly are now saved correctly. Billions of other small bugs fixed
........
svn path=/trunk/netsurf/; revision=4681
2008-07-16 14:19:30 +04:00
|
|
|
|
2005-07-21 03:27:28 +04:00
|
|
|
s->start_idx = offset;
|
2005-04-15 09:51:32 +04:00
|
|
|
s->defined = (s->start_idx < s->end_idx);
|
Merged revisions 4282-4285,4288-4293,4297-4298,4307,4309-4313,4322,4324-4680 via svnmerge from
svn://svn.netsurf-browser.org/branches/mikeL/netsurf
........
r4432 | mikeL | 2008-06-24 04:00:36 +0100 (Tue, 24 Jun 2008) | 1 line
Drag events are now emited from where the press originated, instead of from where they became a drag
........
r4433 | mikeL | 2008-06-24 04:25:33 +0100 (Tue, 24 Jun 2008) | 1 line
Added accelerator to 'Select All'
........
r4495 | mikeL | 2008-07-02 21:36:32 +0100 (Wed, 02 Jul 2008) | 1 line
Selections are now deleted and replaced when a key is typed in a text area or text box. All input box behavior while a selection is active is now implemented (ex: pressing the right arrow key moves the caret to the end of the selection). Cut now works properly in both versions. Fixed discrepancy between where the caret was placed and selection began when starting a drag-select. Fixed bug with calculation of a selections end box.
........
r4496 | mikeL | 2008-07-02 22:11:24 +0100 (Wed, 02 Jul 2008) | 1 line
Added support for cut in input boxes
........
r4497 | mikeL | 2008-07-02 22:21:35 +0100 (Wed, 02 Jul 2008) | 1 line
Removed unused variables (Thanks tlsa)
........
r4498 | mikeL | 2008-07-02 23:30:30 +0100 (Wed, 02 Jul 2008) | 1 line
Modified selection clearing behavior to allow for drag-saves
........
r4499 | mikeL | 2008-07-03 00:51:50 +0100 (Thu, 03 Jul 2008) | 1 line
Fixed regression where it would take two clicks to place caret in an input (Thanks tlsa)
........
r4509 | mikeL | 2008-07-06 07:55:09 +0100 (Sun, 06 Jul 2008) | 1 line
Basic download support implemented. Only downloading of text files works
........
r4510 | mikeL | 2008-07-06 18:55:31 +0100 (Sun, 06 Jul 2008) | 1 line
Downloading of non-text files is now possible. Progress bar and size downloaded are now updated
........
r4511 | mikeL | 2008-07-06 20:46:00 +0100 (Sun, 06 Jul 2008) | 1 line
Added downloads glade file
........
r4512 | mikeL | 2008-07-06 20:47:39 +0100 (Sun, 06 Jul 2008) | 1 line
Downloads window now spawns in the center of the parent browser window
........
r4513 | mikeL | 2008-07-06 20:56:12 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed bug where backspace would be ignored if the selection began at the beginning on an input
........
r4514 | mikeL | 2008-07-06 21:26:45 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed compiler warnings by adding casts
........
r4516 | mikeL | 2008-07-06 21:32:41 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed initialization of size string, added initialization of progress
........
r4518 | mikeL | 2008-07-06 21:51:08 +0100 (Sun, 06 Jul 2008) | 1 line
Added an option for short units (with space) to human_friendly_bytesize
........
r4519 | mikeL | 2008-07-06 21:52:05 +0100 (Sun, 06 Jul 2008) | 1 line
Removed function size_to_string
........
r4520 | mikeL | 2008-07-06 22:03:11 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed pedantic error (kB instead of KB). Added missing necessary parameters to human_friendly_bytesize. Fixed incorrect bool types
........
r4521 | mikeL | 2008-07-06 22:08:15 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnecessary parameter and units list from human_friendly_bytesize
........
r4522 | mikeL | 2008-07-06 22:57:03 +0100 (Sun, 06 Jul 2008) | 1 line
Removed unnused variable
........
r4523 | mikeL | 2008-07-06 23:03:46 +0100 (Sun, 06 Jul 2008) | 1 line
Fixed url parsing by replacing url_parse_filename with url_nice. Total size and size downloaded are now in human readable form. Speed is now calculated (roughly)
........
r4524 | mikeL | 2008-07-07 01:19:01 +0100 (Mon, 07 Jul 2008) | 1 line
Added file overwrite confirmation. Changed speed to a double
........
r4546 | mikeL | 2008-07-09 17:21:43 +0100 (Wed, 09 Jul 2008) | 1 line
Changed parameter of selection_get_end/start to a size_t instead of int and changed all offset variables to size_t as well
........
r4547 | mikeL | 2008-07-09 17:30:47 +0100 (Wed, 09 Jul 2008) | 1 line
Added action buttons to the bottom toolbar. Added ability to clear selected (and completed) downloads with a framework for other actions.
........
r4556 | jmb | 2008-07-10 00:17:24 +0100 (Thu, 10 Jul 2008) | 3 lines
A large bunch of tidying and general fixes to text input handling.
Make selection code treat password fields as inputs, too.
........
r4557 | mikeL | 2008-07-10 00:24:46 +0100 (Thu, 10 Jul 2008) | 1 line
Added functionality to gui_empty_clipboard and gui_start_selection (Thanks jmb)
........
r4573 | mikeL | 2008-07-10 16:33:27 +0100 (Thu, 10 Jul 2008) | 1 line
Removed example download. Made the list store row aware of its download and vise versa. Added new way of handling actions from the dialog (e.g. buttons) which handles all rows in the selection. Added a few memory management function calls to clean up better
........
r4577 | mikeL | 2008-07-10 21:11:51 +0100 (Thu, 10 Jul 2008) | 1 line
Download write channels now close properly. Added status column to the tree store which will change the progress bar text if a download is canceled or completed. Implemented cancel button functionality.
........
r4578 | mikeL | 2008-07-10 21:17:51 +0100 (Thu, 10 Jul 2008) | 1 line
Speed is now displayed as '-' when 0 or download has stopped
........
r4580 | mikeL | 2008-07-11 02:10:57 +0100 (Fri, 11 Jul 2008) | 1 line
Added two download related options (Download directory & Clear completed downloads) and a Downloads tab to the preferences dialog. Also moved the option to ask when overwriting files to Downloads tab. Added another option to the pre-download dialog, Save, which downloads the file immediately to your 'Download directory'
........
r4581 | mikeL | 2008-07-11 02:26:00 +0100 (Fri, 11 Jul 2008) | 1 line
Rearranged pre-download dialog buttons to conform to the HIG
........
r4616 | mikeL | 2008-07-11 19:54:12 +0100 (Fri, 11 Jul 2008) | 1 line
Limited download window updates to a user-defined variable that can be set in options (default is .5). Updates are now only done if the download window is visible. This greatly reduces the cpu usage.
........
r4617 | mikeL | 2008-07-11 20:07:48 +0100 (Fri, 11 Jul 2008) | 1 line
Removed unnecessary update limit option (it is now fixed at .5)
........
r4629 | mikeL | 2008-07-13 04:21:07 +0100 (Sun, 13 Jul 2008) | 1 line
Reorganized button sensitivity functions. Sensitivities are now updated when the selection changes as well as when a selected download's state changes.
........
r4635 | mikeL | 2008-07-13 17:00:05 +0100 (Sun, 13 Jul 2008) | 1 line
Added error handling. Added word-wrap to the "info" cell renderer so that to keep everything under control. Fixed bug where downloads would always go to you default folder (missing breaks).
........
r4642 | mikeL | 2008-07-13 21:46:09 +0100 (Sun, 13 Jul 2008) | 1 line
Added time remaining column. Fixed regression where the download info would be erased upon completion/cancelation.
........
r4655 | mikeL | 2008-07-14 23:20:33 +0100 (Mon, 14 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. When it is closed (when NS shuts down) all incomplete downloads are canceled (and the files deleted). Added a warning dialog when netsurf tries to close with incomplete downloads. Fixed bug where default save directory would initialize to NULL.
........
r4676 | mikeL | 2008-07-15 21:01:17 +0100 (Tue, 15 Jul 2008) | 1 line
Downloads dialog is now initialized in gtk_gui.c with no parent window. The parent windows are now set when a download is created (through an extra parameter in gui_download_window_create) and when nsgtk_download_show is called. (This is the second half of the patch, last commit was only partial for some reason)
........
r4678 | mikeL | 2008-07-16 01:18:52 +0100 (Wed, 16 Jul 2008) | 1 line
Addresses almost all of rjek and jmb's concerns, fixes most of the sloppiness that was present earlier. Downloads without a total_size are now handled correctly (thanks tlsa). Changes to the default download directly are now saved correctly. Billions of other small bugs fixed
........
svn path=/trunk/netsurf/; revision=4681
2008-07-16 14:19:30 +04:00
|
|
|
|
2005-04-15 09:51:32 +04:00
|
|
|
if (was_defined) {
|
2005-07-21 03:27:28 +04:00
|
|
|
if (offset < old_start)
|
2005-04-15 09:51:32 +04:00
|
|
|
selection_redraw(s, s->start_idx, old_start);
|
|
|
|
else
|
|
|
|
selection_redraw(s, old_start, s->start_idx);
|
|
|
|
}
|
|
|
|
else if (selection_defined(s))
|
|
|
|
selection_redraw(s, s->start_idx, s->end_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
/**
|
|
|
|
* Set the end position of the current selection, updating the screen.
|
|
|
|
*
|
|
|
|
* \param s selection object
|
|
|
|
* \param offset byte offset within textual representation
|
|
|
|
*/
|
|
|
|
|
|
|
|
void selection_set_end(struct selection *s, unsigned offset)
|
2005-04-15 09:51:32 +04:00
|
|
|
{
|
|
|
|
bool was_defined = selection_defined(s);
|
2005-07-21 03:27:28 +04:00
|
|
|
unsigned old_end = s->end_idx;
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2005-07-21 03:27:28 +04:00
|
|
|
s->end_idx = offset;
|
2005-04-15 09:51:32 +04:00
|
|
|
s->defined = (s->start_idx < s->end_idx);
|
|
|
|
|
|
|
|
if (was_defined) {
|
2005-07-21 03:27:28 +04:00
|
|
|
if (offset < old_end)
|
2005-04-15 09:51:32 +04:00
|
|
|
selection_redraw(s, s->end_idx, old_end);
|
|
|
|
else
|
|
|
|
selection_redraw(s, old_end, s->end_idx);
|
|
|
|
}
|
|
|
|
else if (selection_defined(s))
|
|
|
|
selection_redraw(s, s->start_idx, s->end_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-02-16 02:09:55 +03:00
|
|
|
* Tests whether a text range lies partially within the selection, if there is
|
2005-04-15 09:51:32 +04:00
|
|
|
* a selection defined, returning the start and end indexes of the bytes
|
|
|
|
* that should be selected.
|
|
|
|
*
|
|
|
|
* \param s the selection object
|
2006-02-16 02:09:55 +03:00
|
|
|
* \param start byte offset of start of text
|
2014-11-10 20:00:15 +03:00
|
|
|
* \param end byte offset of end of text
|
2005-04-15 09:51:32 +04:00
|
|
|
* \param start_idx receives the start index (in bytes) of the highlighted portion
|
|
|
|
* \param end_idx receives the end index (in bytes)
|
|
|
|
* \return true iff part of the given box lies within the selection
|
|
|
|
*/
|
|
|
|
|
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)
|
|
|
|
{
|
2005-04-17 07:30:35 +04:00
|
|
|
/* caller should have checked first for efficiency */
|
2005-07-24 10:13:25 +04:00
|
|
|
assert(s);
|
2005-04-17 07:30:35 +04:00
|
|
|
assert(selection_defined(s));
|
2005-04-15 09:51:32 +04:00
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
if (end <= s->start_idx || start >= s->end_idx)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
*start_idx = (s->start_idx >= start) ? (s->start_idx - start) : 0;
|
|
|
|
*end_idx = min(end, s->end_idx) - start;
|
|
|
|
|
|
|
|
return true;
|
2005-04-15 09:51:32 +04:00
|
|
|
}
|