NetSurf
Macros | Functions | Variables
url_complete.c File Reference

GUI URL auto-completion implementation. More...

#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oslib/wimp.h>
#include "utils/log.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
#include "netsurf/url_db.h"
#include "netsurf/browser_window.h"
#include "riscos/global_history.h"
#include "riscos/gui.h"
#include "riscos/window.h"
#include "riscos/mouse.h"
#include "riscos/toolbar.h"
#include "riscos/url_complete.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/wimputils.h"
#include "riscos/filetype.h"
Include dependency graph for url_complete.c:

Go to the source code of this file.

Macros

#define MAXIMUM_VISIBLE_LINES   7
 

Functions

static bool url_complete_callback (nsurl *url, const struct url_data *data)
 Callback function for urldb_iterate_partial. More...
 
static void ro_gui_url_complete_mouse_at (wimp_pointer *pointer, void *data)
 Handle mouse movement over the URL completion window. More...
 
void ro_gui_url_complete_start (struct toolbar *toolbar)
 Should be called when the caret is placed into a URL completion icon. More...
 
bool ro_gui_url_complete_keypress (struct toolbar *toolbar, uint32_t key)
 Handles a keypress for URL completion. More...
 
void ro_gui_url_complete_resize (struct toolbar *toolbar, wimp_open *open)
 Move and resize the url completion window to match the toolbar. More...
 
bool ro_gui_url_complete_close (void)
 Try to close the current url completion window. More...
 
void ro_gui_url_complete_redraw (wimp_draw *redraw)
 Redraws a section of the URL completion window. More...
 
void ro_gui_url_complete_entering (wimp_entering *entering)
 Handle the pointer entering the URL completion window. More...
 
bool ro_gui_url_complete_click (wimp_pointer *pointer)
 Handle mouse clicks in the URL completion window. More...
 

Variables

static nsurl ** url_complete_matches = NULL
 
static int url_complete_matches_allocated = 0
 
static int url_complete_matches_available = 0
 
static char * url_complete_matched_string = NULL
 
static int url_complete_matches_selection = -1
 
static int url_complete_keypress_selection = -1
 
static wimp_w url_complete_parent = 0
 
static bool url_complete_matches_reset = false
 
static char * url_complete_original_url = NULL
 
static bool url_complete_memory_exhausted = false
 
static nsurlurl_complete_redraw [MAXIMUM_VISIBLE_LINES]
 
static char url_complete_icon_null [] = ""
 
static char url_complete_icon_sprite [12]
 
static wimp_icon url_complete_icon
 
static wimp_icon url_complete_sprite
 
static int mouse_x
 
static int mouse_y
 

Detailed Description

GUI URL auto-completion implementation.

Definition in file url_complete.c.

Macro Definition Documentation

◆ MAXIMUM_VISIBLE_LINES

#define MAXIMUM_VISIBLE_LINES   7

Definition at line 48 of file url_complete.c.

Function Documentation

◆ ro_gui_url_complete_click()

bool ro_gui_url_complete_click ( wimp_pointer *  pointer)

Handle mouse clicks in the URL completion window.

Parameters
pointerthe pointer state
Returns
whether the click was handled
Todo:
The interaction of components here is hideous

Definition at line 667 of file url_complete.c.

References browser_window_navigate(), gui_window::bw, BW_NAVIGATE_HISTORY, dialog_url_complete, mouse_x, mouse_y, NSLOG, nsurl_access(), ro_gui_url_complete_close(), ro_gui_url_complete_keypress(), ro_gui_window_lookup(), ro_toolbar_get_url(), ro_toolbar_set_url(), ro_warn_user(), gui_window::state, gui_window::toolbar, gui_window::url, url_complete_matches, url_complete_matches_selection, url_complete_original_url, and url_complete_parent.

Referenced by ro_gui_dialog_init(), and ro_gui_url_complete_mouse_at().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_url_complete_close()

bool ro_gui_url_complete_close ( void  )

Try to close the current url completion window.

Returns
whether the window was closed

Definition at line 497 of file url_complete.c.

References dialog_url_complete, NSLOG, ro_warn_user(), url_complete_keypress_selection, url_complete_matched_string, url_complete_matches, url_complete_matches_allocated, url_complete_matches_available, url_complete_matches_selection, url_complete_original_url, and url_complete_parent.

Referenced by gui_window_destroy(), ro_gui_url_complete_click(), ro_gui_url_complete_keypress(), ro_gui_url_complete_resize(), ro_gui_url_complete_start(), ro_gui_window_click(), ro_gui_window_handle_local_keypress(), ro_gui_window_launch_url(), ro_gui_window_menu_prepare(), and ro_toolbar_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_url_complete_entering()

void ro_gui_url_complete_entering ( wimp_entering *  entering)

Handle the pointer entering the URL completion window.

Parameters
*enteringThe pointer entering data block.

Definition at line 641 of file url_complete.c.

References ro_gui_url_complete_mouse_at(), and ro_mouse_track_start().

Referenced by ro_gui_dialog_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_url_complete_keypress()

bool ro_gui_url_complete_keypress ( struct toolbar toolbar,
uint32_t  key 
)

Handles a keypress for URL completion.

Parameters
*toolbarThe toolbar to be updated.
keythe key pressed (as UTF32 code or wimp key + bit31 set)
Returns
true to indicate keypress handled; else false.

Definition at line 100 of file url_complete.c.

References dialog_url_complete, height, IS_WIMP_KEY, MAXIMUM_VISIBLE_LINES, NSLOG, nsoption_bool, nsurl_access(), parent, PTR_WIMP_OPEN, ro_gui_url_complete_close(), ro_gui_url_complete_resize(), ro_toolbar_get_display_url(), ro_toolbar_get_parent_window(), ro_toolbar_get_url(), ro_toolbar_set_url(), ro_warn_user(), url_complete_callback(), url_complete_keypress_selection, url_complete_matched_string, url_complete_matches, url_complete_matches_allocated, url_complete_matches_available, url_complete_matches_reset, url_complete_matches_selection, url_complete_memory_exhausted, url_complete_original_url, url_complete_parent, url_complete_redraw, urldb_iterate_entries(), and urldb_iterate_partial().

Referenced by ro_gui_url_complete_click(), ro_gui_window_handle_local_keypress(), and ro_toolbar_keypress().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_url_complete_mouse_at()

void ro_gui_url_complete_mouse_at ( wimp_pointer *  pointer,
void *  data 
)
static

Handle mouse movement over the URL completion window.

Parameters
*pointerThe pointer state
*dataNULL data pointer expected by mouse tracker

Definition at line 654 of file url_complete.c.

References ro_gui_url_complete_click().

Referenced by ro_gui_url_complete_entering().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_url_complete_redraw()

void ro_gui_url_complete_redraw ( wimp_draw *  redraw)

Redraws a section of the URL completion window.

Parameters
redrawthe area to redraw

Definition at line 537 of file url_complete.c.

References line(), NSLOG, nsurl_access(), nsurl_length(), ro_content_filetype_from_type(), ro_gui_user_redraw(), ro_gui_wimp_sprite_exists(), ro_warn_user(), type, url_data::type, url_complete_icon, url_complete_icon_null, url_complete_icon_sprite, url_complete_matches, url_complete_matches_selection, url_complete_sprite, and urldb_get_url_data().

Referenced by ro_gui_dialog_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_url_complete_resize()

void ro_gui_url_complete_resize ( struct toolbar toolbar,
wimp_open *  open 
)

Move and resize the url completion window to match the toolbar.

Parameters
*toolbarThe toolbar to update
*openthe wimp_open request (updated on exit)

Definition at line 398 of file url_complete.c.

References dialog_url_complete, MAXIMUM_VISIBLE_LINES, NSLOG, ro_get_vscroll_width(), ro_gui_url_complete_close(), ro_toolbar_get_display_url(), ro_toolbar_get_url_field_extent(), ro_toolbar_get_window(), ro_warn_user(), url_complete_matches, url_complete_matches_available, url_complete_matches_reset, and url_complete_parent.

Referenced by ro_gui_url_complete_keypress(), and ro_gui_window_open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_url_complete_start()

void ro_gui_url_complete_start ( struct toolbar toolbar)

Should be called when the caret is placed into a URL completion icon.

Parameters
*toolbarThe toolbar to initialise URL completion for.

Definition at line 76 of file url_complete.c.

References parent, ro_gui_url_complete_close(), ro_toolbar_get_display_url(), ro_toolbar_get_parent_window(), ro_toolbar_get_url(), url_complete_matched_string, and url_complete_parent.

Referenced by gui_window_create(), ro_gui_window_handle_local_keypress(), ro_gui_window_set_url(), and ro_toolbar_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ url_complete_callback()

bool url_complete_callback ( nsurl url,
const struct url_data data 
)
static

Callback function for urldb_iterate_partial.

Parameters
urlURL which matches
dataData associated with URL
Returns
true to continue iteration, false otherwise

Definition at line 366 of file url_complete.c.

References url_complete_matches, url_complete_matches_allocated, url_complete_matches_available, url_complete_memory_exhausted, and url_data::visits.

Referenced by ro_gui_url_complete_keypress().

Here is the caller graph for this function:

Variable Documentation

◆ mouse_x

int mouse_x
static

◆ mouse_y

int mouse_y
static

◆ url_complete_icon

wimp_icon url_complete_icon
static

Definition at line 64 of file url_complete.c.

Referenced by ro_gui_url_complete_redraw().

◆ url_complete_icon_null

char url_complete_icon_null[] = ""
static

Definition at line 62 of file url_complete.c.

Referenced by ro_gui_url_complete_redraw().

◆ url_complete_icon_sprite

char url_complete_icon_sprite[12]
static

Definition at line 63 of file url_complete.c.

Referenced by ro_gui_url_complete_redraw().

◆ url_complete_keypress_selection

int url_complete_keypress_selection = -1
static

Definition at line 55 of file url_complete.c.

Referenced by ro_gui_url_complete_close(), and ro_gui_url_complete_keypress().

◆ url_complete_matched_string

char* url_complete_matched_string = NULL
static

◆ url_complete_matches

nsurl** url_complete_matches = NULL
static

◆ url_complete_matches_allocated

int url_complete_matches_allocated = 0
static

◆ url_complete_matches_available

int url_complete_matches_available = 0
static

◆ url_complete_matches_reset

bool url_complete_matches_reset = false
static

Definition at line 57 of file url_complete.c.

Referenced by ro_gui_url_complete_keypress(), and ro_gui_url_complete_resize().

◆ url_complete_matches_selection

int url_complete_matches_selection = -1
static

◆ url_complete_memory_exhausted

bool url_complete_memory_exhausted = false
static

Definition at line 59 of file url_complete.c.

Referenced by ro_gui_url_complete_keypress(), and url_complete_callback().

◆ url_complete_original_url

char* url_complete_original_url = NULL
static

◆ url_complete_parent

wimp_w url_complete_parent = 0
static

◆ url_complete_redraw

nsurl* url_complete_redraw[MAXIMUM_VISIBLE_LINES]
static

Definition at line 61 of file url_complete.c.

Referenced by ro_gui_url_complete_keypress().

◆ url_complete_sprite

wimp_icon url_complete_sprite
static

Definition at line 65 of file url_complete.c.

Referenced by ro_gui_url_complete_redraw().