NetSurf
|
RISC OS text selection implementation. More...
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <oslib/osfile.h>
#include <oslib/wimp.h>
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
#include "netsurf/clipboard.h"
#include "netsurf/window.h"
#include "netsurf/browser_window.h"
#include "riscos/gui.h"
#include "riscos/window.h"
#include "riscos/menus.h"
#include "riscos/message.h"
#include "riscos/mouse.h"
#include "riscos/save.h"
#include "riscos/textselection.h"
#include "riscos/ucstables.h"
Go to the source code of this file.
Macros | |
#define | wimp_DRAG_CLAIM_SUPPRESS_DRAGBOX ((wimp_drag_claim_flags) 0x2u) |
Functions | |
static void | ro_gui_selection_drag_end (wimp_dragged *drag, void *data) |
End of text selection drag operation. More... | |
static void | ro_gui_discard_clipboard_contents (void) |
Discard the current contents of the clipboard, if any, releasing the memory it uses. More... | |
static void | ro_gui_dragging_bounced (wimp_message *message) |
Our message_DRAGGING message was bounced, ie. More... | |
void | gui_start_selection (struct gui_window *g) |
Start drag-selecting text within a browser window (RO-dependent part) More... | |
static void | gui_set_clipboard (const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles) |
Core tells front end to put given text in clipboard. More... | |
static void | gui_get_clipboard (char **buffer, size_t *length) |
Core asks front end for clipboard contents. More... | |
static void | ro_gui_selection_prepare_paste_complete (void) |
static void | ro_gui_selection_prepare_paste_bounced (wimp_message *message) |
void | ro_gui_selection_prepare_paste (wimp_w w, ro_gui_selection_prepare_paste_cb cb, void *pw) |
Prepare to paste data from another application. More... | |
bool | ro_gui_selection_prepare_paste_datasave (wimp_full_message_data_xfer *dataxfer) |
Prepare to paste data from another application (step 2) More... | |
bool | ro_gui_selection_prepare_paste_dataload (wimp_full_message_data_xfer *dataxfer) |
Prepare to paste data from another application (step 3) More... | |
void | ro_gui_selection_claim_entity (wimp_full_message_claim_entity *claim) |
Responds to CLAIM_ENTITY message notifying us that the caret and selection or clipboard have been claimed by another application. More... | |
void | ro_gui_selection_data_request (wimp_full_message_data_request *req) |
Responds to DATA_REQUEST message, returning information about the clipboard contents if we own the clipboard. More... | |
bool | ro_gui_save_clipboard (const char *path) |
Save the clipboard contents to a file. More... | |
void | ro_gui_selection_dragging (wimp_message *message) |
Handler for Message_Dragging, used to implement auto-scrolling and ghost caret when a drag is in progress. More... | |
void | ro_gui_selection_drag_reset (void) |
Reset drag-and-drop state when drag completes (DataSave received) More... | |
void | ro_gui_selection_drag_claim (wimp_message *message) |
void | ro_gui_selection_send_dragging (wimp_pointer *pointer) |
Variables | |
static bool | dragging_claimed = false |
Receive of Dragging message has claimed it. More... | |
static wimp_t | dragging_claimant |
static os_box | dragging_box = { -34, -34, 34, 34 } |
static wimp_drag_claim_flags | last_claim_flags = 0 |
static struct gui_window * | last_start_window |
static bool | drag_claimed = false |
static bool | owns_clipboard = false |
static bool | owns_caret_and_selection = false |
static char * | clipboard = NULL |
static size_t | clip_length = 0 |
static ro_gui_selection_prepare_paste_cb | paste_cb = NULL |
static void * | paste_cb_pw = NULL |
static int | paste_prev_message = 0 |
static struct gui_clipboard_table | clipboard_table |
struct gui_clipboard_table * | riscos_clipboard_table = &clipboard_table |
RISC OS text selection implementation.
Definition in file textselection.c.
#define wimp_DRAG_CLAIM_SUPPRESS_DRAGBOX ((wimp_drag_claim_flags) 0x2u) |
Definition at line 49 of file textselection.c.
|
static |
Core asks front end for clipboard contents.
buffer | UTF-8 text, allocated by front end, ownership yielded to core |
length | Byte length of UTF-8 text in buffer |
Definition at line 255 of file textselection.c.
References buffer, clip_length, and clipboard.
|
static |
Core tells front end to put given text in clipboard.
buffer | UTF-8 text, owned by core |
length | Byte length of UTF-8 text in buffer |
styles | Array of styles given to text runs, owned by core, or NULL |
n_styles | Number of text run styles in array |
Definition at line 204 of file textselection.c.
References buffer, clip_length, clipboard, NSLOG, owns_clipboard, and ro_warn_user().
void gui_start_selection | ( | struct gui_window * | g | ) |
Start drag-selecting text within a browser window (RO-dependent part)
g | gui window |
Definition at line 87 of file textselection.c.
References last_start_window, NSLOG, owns_caret_and_selection, ro_gui_selection_drag_end(), ro_gui_window_mouse_at(), ro_mouse_drag_start(), ro_warn_user(), gui_window::state, and gui_window::window.
|
static |
Discard the current contents of the clipboard, if any, releasing the memory it uses.
Definition at line 276 of file textselection.c.
References clip_length, and clipboard.
Referenced by ro_gui_selection_claim_entity(), and ro_gui_selection_prepare_paste().
|
static |
Our message_DRAGGING message was bounced, ie.
the intended recipient does not support the drag-and-drop protocol or cannot receive the data at the pointer position.
Definition at line 658 of file textselection.c.
References dragging_claimed.
Referenced by ro_gui_selection_send_dragging().
bool ro_gui_save_clipboard | ( | const char * | path | ) |
Save the clipboard contents to a file.
path | the pathname of the file |
Definition at line 515 of file textselection.c.
References clip_length, clipboard, NSERROR_OK, NSLOG, path(), ro_warn_user(), and utf8_to_local_encoding().
Referenced by ro_gui_save_content().
void ro_gui_selection_claim_entity | ( | wimp_full_message_claim_entity * | claim | ) |
Responds to CLAIM_ENTITY message notifying us that the caret and selection or clipboard have been claimed by another application.
claim | CLAIM_ENTITY message |
Definition at line 448 of file textselection.c.
References NSLOG, owns_caret_and_selection, owns_clipboard, ro_gui_discard_clipboard_contents(), and task_handle.
Referenced by ro_gui_user_message().
void ro_gui_selection_data_request | ( | wimp_full_message_data_request * | req | ) |
Responds to DATA_REQUEST message, returning information about the clipboard contents if we own the clipboard.
req | DATA_REQUEST message |
Definition at line 474 of file textselection.c.
References clip_length, GUI_SAVE_CLIPBOARD_CONTENTS, owns_clipboard, and ro_gui_send_datasave().
Referenced by ro_gui_user_message().
void ro_gui_selection_drag_claim | ( | wimp_message * | message | ) |
Definition at line 590 of file textselection.c.
References dragging_claimant, dragging_claimed, GUI_POINTER_DEFAULT, gui_window_set_pointer(), last_claim_flags, last_start_window, ro_gui_drag_box_cancel(), and wimp_DRAG_CLAIM_SUPPRESS_DRAGBOX.
Referenced by gui_init().
|
static |
End of text selection drag operation.
*drag | position of pointer at conclusion of drag |
*data | gui window pointer. |
Definition at line 162 of file textselection.c.
References browser_window_mouse_track(), gui_window::bw, NSLOG, ro_gui_window_to_window_pos(), ro_warn_user(), gui_window::window, and browser_window::x.
Referenced by gui_start_selection().
void ro_gui_selection_drag_reset | ( | void | ) |
Reset drag-and-drop state when drag completes (DataSave received)
Definition at line 580 of file textselection.c.
References drag_claimed.
void ro_gui_selection_dragging | ( | wimp_message * | message | ) |
Handler for Message_Dragging, used to implement auto-scrolling and ghost caret when a drag is in progress.
Definition at line 551 of file textselection.c.
References drag_claimed, ro_gui_window_lookup(), and ro_gui_window_to_window_pos().
Referenced by gui_init().
void ro_gui_selection_prepare_paste | ( | wimp_w | w, |
ro_gui_selection_prepare_paste_cb | cb, | ||
void * | pw | ||
) |
Prepare to paste data from another application.
w | Window being pasted into |
cb | Callback to call once preparation is complete |
pw | Private data for callback |
Definition at line 309 of file textselection.c.
References owns_clipboard, paste_cb, paste_cb_pw, paste_prev_message, ro_gui_discard_clipboard_contents(), ro_gui_selection_prepare_paste_bounced(), and ro_message_send_message().
Referenced by ro_gui_keypress(), and ro_gui_window_menu_select().
|
static |
Definition at line 296 of file textselection.c.
References ro_gui_selection_prepare_paste_complete().
Referenced by ro_gui_selection_prepare_paste(), and ro_gui_selection_prepare_paste_datasave().
|
static |
Definition at line 284 of file textselection.c.
References paste_cb, paste_cb_pw, and paste_prev_message.
Referenced by ro_gui_selection_prepare_paste_bounced(), ro_gui_selection_prepare_paste_dataload(), and ro_gui_selection_prepare_paste_datasave().
bool ro_gui_selection_prepare_paste_dataload | ( | wimp_full_message_data_xfer * | dataxfer | ) |
Prepare to paste data from another application (step 3)
dataxfer | DataLoad message |
Definition at line 395 of file textselection.c.
References clip_length, clipboard, NSERROR_OK, paste_prev_message, ro_gui_selection_prepare_paste_complete(), ro_message_send_message(), and utf8_from_local_encoding().
Referenced by ro_gui_user_message().
bool ro_gui_selection_prepare_paste_datasave | ( | wimp_full_message_data_xfer * | dataxfer | ) |
Prepare to paste data from another application (step 2)
dataxfer | DataSave message |
Definition at line 354 of file textselection.c.
References paste_prev_message, ro_gui_selection_prepare_paste_bounced(), ro_gui_selection_prepare_paste_complete(), ro_message_send_message(), and SLEN.
Referenced by ro_msg_datasave().
void ro_gui_selection_send_dragging | ( | wimp_pointer * | pointer | ) |
Definition at line 615 of file textselection.c.
References dragging_box, dragging_claimant, dragging_claimed, NSLOG, ro_gui_dragging_bounced(), ro_message_send_message(), and ro_message_send_message_to_window().
|
static |
Definition at line 69 of file textselection.c.
Referenced by gui_get_clipboard(), gui_set_clipboard(), ro_gui_discard_clipboard_contents(), ro_gui_save_clipboard(), ro_gui_selection_data_request(), ro_gui_selection_prepare_paste_dataload(), and toolbar_key_input().
|
static |
Definition at line 68 of file textselection.c.
Referenced by gui_get_clipboard(), gui_set_clipboard(), ro_gui_discard_clipboard_contents(), ro_gui_save_clipboard(), and ro_gui_selection_prepare_paste_dataload().
|
static |
Definition at line 663 of file textselection.c.
|
static |
Definition at line 60 of file textselection.c.
Referenced by ro_gui_selection_drag_reset(), and ro_gui_selection_dragging().
|
static |
Definition at line 56 of file textselection.c.
Referenced by ro_gui_selection_send_dragging().
|
static |
Definition at line 55 of file textselection.c.
Referenced by ro_gui_selection_drag_claim(), and ro_gui_selection_send_dragging().
|
static |
Receive of Dragging message has claimed it.
Definition at line 54 of file textselection.c.
Referenced by ro_gui_dragging_bounced(), ro_gui_selection_drag_claim(), and ro_gui_selection_send_dragging().
|
static |
Definition at line 57 of file textselection.c.
Referenced by ro_gui_selection_drag_claim().
|
static |
Definition at line 58 of file textselection.c.
Referenced by gui_start_selection(), and ro_gui_selection_drag_claim().
|
static |
Definition at line 63 of file textselection.c.
Referenced by gui_start_selection(), and ro_gui_selection_claim_entity().
|
static |
Definition at line 62 of file textselection.c.
Referenced by gui_set_clipboard(), ro_gui_selection_claim_entity(), ro_gui_selection_data_request(), and ro_gui_selection_prepare_paste().
|
static |
Definition at line 72 of file textselection.c.
Referenced by ro_gui_selection_prepare_paste(), and ro_gui_selection_prepare_paste_complete().
|
static |
Definition at line 73 of file textselection.c.
Referenced by ro_gui_selection_prepare_paste(), and ro_gui_selection_prepare_paste_complete().
|
static |
Definition at line 74 of file textselection.c.
Referenced by ro_gui_selection_prepare_paste(), ro_gui_selection_prepare_paste_complete(), ro_gui_selection_prepare_paste_dataload(), and ro_gui_selection_prepare_paste_datasave().
struct gui_clipboard_table* riscos_clipboard_table = &clipboard_table |
Definition at line 668 of file textselection.c.
Referenced by main().