mirror of
https://github.com/lbonn/rofi
synced 2024-11-15 08:37:17 +00:00
Merge branch 'master' of github:DaveDavenport/rofi
This commit is contained in:
commit
a063715652
9 changed files with 487 additions and 59 deletions
49
Makefile.am
49
Makefile.am
|
@ -143,7 +143,16 @@ update-manpage: $(top_srcdir)/doc/rofi-manpage.markdown
|
|||
##
|
||||
# Rofi test program
|
||||
##
|
||||
check_PROGRAMS=history_test textbox_test helper_test helper_expand helper_config_cmdline_parser widget_test
|
||||
check_PROGRAMS=\
|
||||
history_test\
|
||||
textbox_test\
|
||||
helper_test\
|
||||
helper_expand\
|
||||
helper_pidfile\
|
||||
helper_tokenize\
|
||||
helper_config_cmdline_parser\
|
||||
widget_test
|
||||
|
||||
|
||||
history_test_CFLAGS=\
|
||||
$(AM_CFLAGS)\
|
||||
|
@ -185,6 +194,36 @@ textbox_test_LDADD=\
|
|||
$(cairo_LIBS)\
|
||||
$(libsn_LIBS)
|
||||
|
||||
helper_pidfile_CFLAGS=$(textbox_test_CFLAGS)
|
||||
helper_pidfile_LDADD=$(textbox_test_LDADD)
|
||||
helper_pidfile_SOURCES=\
|
||||
config/config.c\
|
||||
include/rofi.h\
|
||||
include/mode.h\
|
||||
include/mode-private.h\
|
||||
source/helper.c\
|
||||
include/helper.h\
|
||||
include/xrmoptions.h\
|
||||
source/xrmoptions.c\
|
||||
source/x11-helper.c\
|
||||
include/x11-helper.h\
|
||||
test/helper-pidfile.c
|
||||
|
||||
helper_tokenize_CFLAGS=$(textbox_test_CFLAGS)
|
||||
helper_tokenize_LDADD=$(textbox_test_LDADD)
|
||||
helper_tokenize_SOURCES=\
|
||||
config/config.c\
|
||||
include/rofi.h\
|
||||
include/mode.h\
|
||||
include/mode-private.h\
|
||||
source/helper.c\
|
||||
include/helper.h\
|
||||
include/xrmoptions.h\
|
||||
source/xrmoptions.c\
|
||||
source/x11-helper.c\
|
||||
include/x11-helper.h\
|
||||
test/helper-tokenize.c
|
||||
|
||||
widget_test_LDADD=$(textbox_test_LDADD)
|
||||
widget_test_CFLAGS=$(textbox_test_CFLAGS)
|
||||
widget_test_SOURCES=\
|
||||
|
@ -271,13 +310,14 @@ TESTS=\
|
|||
history_test\
|
||||
helper_test\
|
||||
helper_expand\
|
||||
helper_pidfile\
|
||||
helper_tokenize\
|
||||
helper_config_cmdline_parser\
|
||||
textbox_test\
|
||||
widget_test
|
||||
|
||||
.PHONY: test-x
|
||||
test-x: $(bin_PROGRAMS) textbox_test
|
||||
echo "Test 1"
|
||||
$(top_srcdir)/test/run_test.sh 123 $(top_builddir)/textbox_test $(top_builddir)
|
||||
test-x: $(bin_PROGRAMS)
|
||||
echo "Test 2"
|
||||
$(top_srcdir)/test/run_test.sh 200 $(top_srcdir)/test/run_errormsg_test.sh $(top_builddir)
|
||||
echo "Test 3"
|
||||
|
@ -366,6 +406,7 @@ coverage/index.html: coverage.info
|
|||
.PHONY: coverage-clean
|
||||
coverage-clean:
|
||||
-rm -r coverage.info coverage/
|
||||
-find $(top_builddir) -name '*.gcda' | xargs rm
|
||||
|
||||
.PHONY: .FORCE
|
||||
.FORCE:
|
||||
|
|
|
@ -136,13 +136,6 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action );
|
|||
*/
|
||||
gboolean textbox_append_char ( textbox *tb, const char *pad, const int pad_len );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Move the cursor to the end of the string.
|
||||
*/
|
||||
void textbox_cursor_end ( textbox *tb );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
* @param pos New cursor position
|
||||
|
@ -207,34 +200,6 @@ int textbox_get_font_width ( const textbox *tb );
|
|||
*/
|
||||
double textbox_get_estimated_char_width ( void );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Delete character before cursor.
|
||||
*/
|
||||
void textbox_cursor_bkspc ( textbox *tb );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Delete character after cursor.
|
||||
*/
|
||||
void textbox_cursor_del ( textbox *tb );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Move cursor one position backward.
|
||||
*/
|
||||
void textbox_cursor_dec ( textbox *tb );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Move cursor one position forward.
|
||||
*/
|
||||
void textbox_cursor_inc ( textbox *tb );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
* @param pos The start position
|
||||
|
|
|
@ -656,7 +656,7 @@ inline static void rofi_view_nav_row_select ( RofiViewState *state )
|
|||
char *str = mode_get_completion ( state->sw, state->line_map[selected] );
|
||||
textbox_text ( state->text, str );
|
||||
g_free ( str );
|
||||
textbox_cursor_end ( state->text );
|
||||
textbox_keybinding ( state->text, MOVE_END );
|
||||
state->refilter = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,13 @@ static void textbox_free ( widget * );
|
|||
static int textbox_get_width ( widget * );
|
||||
static int _textbox_get_height ( widget * );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Move the cursor to the end of the string.
|
||||
*/
|
||||
static void textbox_cursor_end ( textbox *tb );
|
||||
|
||||
/**
|
||||
* Font + font color cache.
|
||||
* Avoid re-loading font on every change on every textbox.
|
||||
|
@ -406,14 +413,22 @@ void textbox_cursor ( textbox *tb, int pos )
|
|||
widget_queue_redraw ( WIDGET ( tb ) );
|
||||
}
|
||||
|
||||
// move right
|
||||
void textbox_cursor_inc ( textbox *tb )
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Move cursor one position forward.
|
||||
*/
|
||||
static void textbox_cursor_inc ( textbox *tb )
|
||||
{
|
||||
textbox_cursor ( tb, tb->cursor + 1 );
|
||||
}
|
||||
|
||||
// move left
|
||||
void textbox_cursor_dec ( textbox *tb )
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Move cursor one position backward.
|
||||
*/
|
||||
static void textbox_cursor_dec ( textbox *tb )
|
||||
{
|
||||
textbox_cursor ( tb, tb->cursor - 1 );
|
||||
}
|
||||
|
@ -481,7 +496,7 @@ static void textbox_cursor_dec_word ( textbox *tb )
|
|||
}
|
||||
|
||||
// end of line
|
||||
void textbox_cursor_end ( textbox *tb )
|
||||
static void textbox_cursor_end ( textbox *tb )
|
||||
{
|
||||
if ( tb->text == NULL ) {
|
||||
tb->cursor = 0;
|
||||
|
@ -547,8 +562,12 @@ void textbox_delete ( textbox *tb, int pos, int dlen )
|
|||
tb->update = TRUE;
|
||||
}
|
||||
|
||||
// delete on character
|
||||
void textbox_cursor_del ( textbox *tb )
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Delete character after cursor.
|
||||
*/
|
||||
static void textbox_cursor_del ( textbox *tb )
|
||||
{
|
||||
if ( tb->text == NULL ) {
|
||||
return;
|
||||
|
@ -556,8 +575,12 @@ void textbox_cursor_del ( textbox *tb )
|
|||
textbox_delete ( tb, tb->cursor, 1 );
|
||||
}
|
||||
|
||||
// back up and delete one character
|
||||
void textbox_cursor_bkspc ( textbox *tb )
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* Delete character before cursor.
|
||||
*/
|
||||
static void textbox_cursor_bkspc ( textbox *tb )
|
||||
{
|
||||
if ( tb->cursor > 0 ) {
|
||||
textbox_cursor_dec ( tb );
|
||||
|
|
|
@ -47,17 +47,45 @@ int main ( int argc, char ** argv )
|
|||
char **list = NULL;
|
||||
int llength = 0;
|
||||
char * test_str =
|
||||
"{host} {terminal} -e bash -c \"{ssh-client} {host}; echo '{terminal} {host}'\"";
|
||||
"{host} {terminal} -e bash -c \"{ssh-client} {host}; echo '{terminal} {host}'\" -i -3 -u 4";
|
||||
helper_parse_setup ( test_str, &list, &llength, "{host}", "chuck",
|
||||
"{terminal}", "x-terminal-emulator", NULL );
|
||||
|
||||
TASSERT ( llength == 6 );
|
||||
TASSERT ( llength == 10);
|
||||
TASSERT ( strcmp ( list[0], "chuck" ) == 0 );
|
||||
TASSERT ( strcmp ( list[1], "x-terminal-emulator" ) == 0 );
|
||||
TASSERT ( strcmp ( list[2], "-e" ) == 0 );
|
||||
TASSERT ( strcmp ( list[3], "bash" ) == 0 );
|
||||
TASSERT ( strcmp ( list[4], "-c" ) == 0 );
|
||||
TASSERT ( strcmp ( list[5], "ssh chuck; echo 'x-terminal-emulator chuck'" ) == 0 );
|
||||
TASSERT ( strcmp ( list[6], "-i" ) == 0 );
|
||||
TASSERT ( strcmp ( list[7], "-3" ) == 0 );
|
||||
TASSERT ( strcmp ( list[8], "-u" ) == 0 );
|
||||
TASSERT ( strcmp ( list[9], "4" ) == 0 );
|
||||
|
||||
cmd_set_arguments ( llength, list);
|
||||
TASSERT( find_arg ( "-e") == 2 );
|
||||
TASSERT( find_arg ( "-x") == -1 );
|
||||
char *str;
|
||||
TASSERT( find_arg_str ( "-e", &str) == TRUE );
|
||||
TASSERT ( str == list[3] );
|
||||
TASSERT( find_arg_str ( "-x", &str) == FALSE );
|
||||
// Should be unmodified.
|
||||
TASSERT ( str == list[3] );
|
||||
|
||||
unsigned int u = 1234;
|
||||
unsigned int i = -1234;
|
||||
TASSERT ( find_arg_uint ( "-x", &u ) == FALSE );
|
||||
TASSERT ( u == 1234 );
|
||||
TASSERT ( find_arg_int ( "-x", &i ) == FALSE );
|
||||
TASSERT ( i == -1234 );
|
||||
TASSERT ( find_arg_uint ( "-u", &u ) == TRUE );
|
||||
TASSERT ( u == 4 );
|
||||
TASSERT ( find_arg_uint ( "-i", &u ) == TRUE );
|
||||
TASSERT ( u == 4294967293 );
|
||||
TASSERT ( find_arg_int ( "-i", &i ) == TRUE );
|
||||
TASSERT ( i == -3 );
|
||||
|
||||
g_strfreev ( list );
|
||||
|
||||
}
|
||||
|
|
57
test/helper-pidfile.c
Normal file
57
test/helper-pidfile.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <helper.h>
|
||||
#include <string.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
#include "xcb-internal.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
|
||||
static int test = 0;
|
||||
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %i passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int show_error_message ( const char *msg, int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return 0;
|
||||
}
|
||||
xcb_screen_t *xcb_screen;
|
||||
xcb_ewmh_connection_t xcb_ewmh;
|
||||
int xcb_screen_nbr;
|
||||
#include <x11-helper.h>
|
||||
|
||||
int main ( int argc, char ** argv )
|
||||
{
|
||||
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
||||
fprintf ( stderr, "Failed to set locale.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Pid test.
|
||||
// Tests basic functionality of writing it, locking, seeing if I can write same again
|
||||
// And close/reopen it again.
|
||||
{
|
||||
const char *path = "/tmp/rofi-test.pid";
|
||||
TASSERT( create_pid_file ( NULL ) == -1 );
|
||||
int fd = create_pid_file ( path );
|
||||
TASSERT( fd >= 0 );
|
||||
int fd2 = create_pid_file ( path );
|
||||
TASSERT ( fd2 < 0 );
|
||||
|
||||
remove_pid_file ( fd );
|
||||
fd = create_pid_file ( path );
|
||||
TASSERT( fd >= 0 );
|
||||
remove_pid_file ( fd );
|
||||
}
|
||||
}
|
|
@ -78,4 +78,40 @@ int main ( int argc, char ** argv )
|
|||
TASSERTE ( levenshtein ( "aap", "noot aap mies" ), 10 );
|
||||
TASSERTE ( levenshtein ( "noot aap mies", "aap" ), 10 );
|
||||
TASSERTE ( levenshtein ( "otp", "noot aap" ), 5 );
|
||||
/**
|
||||
* Quick converision check.
|
||||
*/
|
||||
{
|
||||
char *str = rofi_latin_to_utf8_strdup ( "\xA1\xB5", 2);
|
||||
TASSERT ( g_utf8_collate ( str, "¡µ") == 0 );
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
{
|
||||
char *str = rofi_force_utf8("Valid utf8", 10);
|
||||
TASSERT ( g_utf8_collate ( str, "Valid utf8") == 0 );
|
||||
g_free(str);
|
||||
char in[] = "Valid utf8 until \xc3\x28 we continue here";
|
||||
TASSERT ( g_utf8_validate ( in, -1, NULL ) == FALSE );
|
||||
str = rofi_force_utf8(in, strlen(in));
|
||||
TASSERT ( g_utf8_validate ( str, -1, NULL ) == TRUE );
|
||||
TASSERT ( g_utf8_collate ( str, "Valid utf8 until <20>( we continue here") == 0 );
|
||||
g_free(str);
|
||||
}
|
||||
// Pid test.
|
||||
// Tests basic functionality of writing it, locking, seeing if I can write same again
|
||||
// And close/reopen it again.
|
||||
{
|
||||
const char *path = "/tmp/rofi-test.pid";
|
||||
TASSERT( create_pid_file ( NULL ) == -1 );
|
||||
int fd = create_pid_file ( path );
|
||||
TASSERT( fd >= 0 );
|
||||
int fd2 = create_pid_file ( path );
|
||||
TASSERT ( fd2 < 0 );
|
||||
|
||||
remove_pid_file ( fd );
|
||||
fd = create_pid_file ( path );
|
||||
TASSERT( fd >= 0 );
|
||||
remove_pid_file ( fd );
|
||||
}
|
||||
}
|
||||
|
|
251
test/helper-tokenize.c
Normal file
251
test/helper-tokenize.c
Normal file
|
@ -0,0 +1,251 @@
|
|||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <helper.h>
|
||||
#include <string.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
#include "xcb-internal.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
|
||||
static int test = 0;
|
||||
|
||||
#define TASSERT( a ) { \
|
||||
assert ( a ); \
|
||||
printf ( "Test %i passed (%s)\n", ++test, # a ); \
|
||||
}
|
||||
|
||||
int rofi_view_error_dialog ( const char *msg, G_GNUC_UNUSED int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int show_error_message ( const char *msg, int markup )
|
||||
{
|
||||
fputs ( msg, stderr );
|
||||
return 0;
|
||||
}
|
||||
xcb_screen_t *xcb_screen;
|
||||
xcb_ewmh_connection_t xcb_ewmh;
|
||||
int xcb_screen_nbr;
|
||||
#include <x11-helper.h>
|
||||
|
||||
int main ( int argc, char ** argv )
|
||||
{
|
||||
if ( setlocale ( LC_ALL, "" ) == NULL ) {
|
||||
fprintf ( stderr, "Failed to set locale.\n" );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Pid test.
|
||||
// Tests basic functionality of writing it, locking, seeing if I can write same again
|
||||
// And close/reopen it again.
|
||||
{
|
||||
tokenize_free ( NULL );
|
||||
}
|
||||
{
|
||||
config.matching_method = MM_NORMAL;
|
||||
GRegex **tokens = tokenize ( "noot", FALSE );
|
||||
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap Noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "Nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "noOTap mies") == TRUE );
|
||||
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "noot", TRUE );
|
||||
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap Noot mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "Nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "noOTap mies") == FALSE );
|
||||
|
||||
tokenize_free ( tokens );
|
||||
tokens = tokenize ( "no ot", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == TRUE );
|
||||
tokenize_free ( tokens );
|
||||
}
|
||||
{
|
||||
config.matching_method = MM_GLOB;
|
||||
GRegex **tokens = tokenize ( "noot", FALSE );
|
||||
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap Noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "Nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "noOTap mies") == TRUE );
|
||||
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "noot", TRUE );
|
||||
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap Noot mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "Nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "noOTap mies") == FALSE );
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "no ot", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == TRUE );
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "n?ot", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == FALSE);
|
||||
tokenize_free ( tokens );
|
||||
tokens = tokenize ( "n*ot", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == TRUE);
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "n* ot", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == TRUE);
|
||||
TASSERT ( token_match ( tokens, "ot nap mies") == TRUE);
|
||||
tokenize_free ( tokens );
|
||||
}
|
||||
{
|
||||
config.matching_method = MM_FUZZY;
|
||||
GRegex **tokens = tokenize ( "noot", FALSE );
|
||||
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap Noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "Nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "noOTap mies") == TRUE );
|
||||
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "noot", TRUE );
|
||||
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap Noot mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "Nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "noOTap mies") == FALSE );
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "no ot", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == TRUE );
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "n ot", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == TRUE);
|
||||
tokenize_free ( tokens );
|
||||
tokens = tokenize ( "ont", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == FALSE);
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap nmiest") == TRUE );
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "o n t", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == TRUE);
|
||||
TASSERT ( token_match ( tokens, "ot nap mies") == TRUE);
|
||||
tokenize_free ( tokens );
|
||||
}
|
||||
{
|
||||
config.matching_method = MM_REGEX;
|
||||
GRegex **tokens = tokenize ( "noot", FALSE );
|
||||
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap Noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "Nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "noOTap mies") == TRUE );
|
||||
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "noot", TRUE );
|
||||
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap Noot mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "Nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "noOTap mies") == FALSE );
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "no ot", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == TRUE );
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "n.?ot", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == FALSE);
|
||||
tokenize_free ( tokens );
|
||||
tokens = tokenize ( "n[oa]{2}t", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == TRUE );
|
||||
TASSERT ( token_match ( tokens, "noat miesot") == TRUE);
|
||||
TASSERT ( token_match ( tokens, "noaat miesot") == FALSE);
|
||||
tokenize_free ( tokens );
|
||||
|
||||
tokens = tokenize ( "^(aap|noap)\\sMie.*", FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap noot mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "aap mies") == TRUE);
|
||||
TASSERT ( token_match ( tokens, "nooaap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "nootap mies") == FALSE );
|
||||
TASSERT ( token_match ( tokens, "noap miesot") == TRUE);
|
||||
TASSERT ( token_match ( tokens, "ot nap mies") == FALSE );
|
||||
tokenize_free ( tokens );
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
|||
NORMAL, "test" );
|
||||
TASSERT ( box != NULL );
|
||||
|
||||
textbox_cursor_end ( box );
|
||||
textbox_keybinding ( box, MOVE_END );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
textbox_cursor ( box, -1 );
|
||||
TASSERT ( box->cursor == 0 );
|
||||
|
@ -67,7 +67,7 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
|||
TASSERT ( box->cursor == 2 );
|
||||
textbox_insert ( box, 3, "bo", 2 );
|
||||
TASSERT ( strcmp ( box->text, "tesbot" ) == 0 );
|
||||
textbox_cursor_end ( box );
|
||||
textbox_keybinding ( box, MOVE_END );
|
||||
TASSERT ( box->cursor == 6 );
|
||||
|
||||
TASSERT ( widget_get_width ( WIDGET ( box ) ) > 0 );
|
||||
|
@ -78,19 +78,19 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
|||
|
||||
TASSERT ( textbox_get_estimated_char_width ( ) > 0 );
|
||||
|
||||
textbox_cursor_bkspc ( box );
|
||||
textbox_keybinding ( box, REMOVE_CHAR_BACK );
|
||||
TASSERT ( strcmp ( box->text, "tesbo" ) == 0 );
|
||||
TASSERT ( box->cursor == 5 );
|
||||
|
||||
textbox_cursor_dec ( box );
|
||||
textbox_keybinding ( box, MOVE_CHAR_BACK );
|
||||
TASSERT ( box->cursor == 4 );
|
||||
textbox_cursor_del ( box );
|
||||
textbox_keybinding ( box, REMOVE_CHAR_FORWARD );
|
||||
TASSERT ( strcmp ( box->text, "tesb" ) == 0 );
|
||||
textbox_cursor_dec ( box );
|
||||
textbox_keybinding ( box, MOVE_CHAR_BACK );
|
||||
TASSERT ( box->cursor == 3 );
|
||||
textbox_cursor_inc ( box );
|
||||
textbox_keybinding ( box, MOVE_CHAR_FORWARD);
|
||||
TASSERT ( box->cursor == 4 );
|
||||
textbox_cursor_inc ( box );
|
||||
textbox_keybinding ( box, MOVE_CHAR_FORWARD);
|
||||
TASSERT ( box->cursor == 4 );
|
||||
// Cursor after delete section.
|
||||
textbox_delete ( box, 0, 1 );
|
||||
|
@ -122,6 +122,33 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
|||
TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
|
||||
TASSERT ( box->cursor == 5 );
|
||||
|
||||
|
||||
textbox_text ( box, "aap noot mies");
|
||||
textbox_cursor ( box, 8 );
|
||||
textbox_keybinding ( box, REMOVE_WORD_BACK );
|
||||
TASSERT ( box->cursor == 4);
|
||||
TASSERT ( strcmp ( box->text, "aap mies") == 0 );
|
||||
textbox_keybinding ( box, REMOVE_TO_EOL );
|
||||
TASSERT ( box->cursor == 4);
|
||||
TASSERT ( strcmp ( box->text, "aap ") == 0 );
|
||||
textbox_text ( box, "aap noot mies");
|
||||
textbox_cursor ( box, 8 );
|
||||
textbox_keybinding ( box, REMOVE_WORD_FORWARD );
|
||||
TASSERT ( strcmp ( box->text, "aap noot") == 0 );
|
||||
textbox_keybinding ( box, MOVE_FRONT );
|
||||
TASSERT ( box->cursor == 0);
|
||||
textbox_keybinding ( box, CLEAR_LINE );
|
||||
TASSERT ( strcmp ( box->text, "") == 0 );
|
||||
textbox_text ( box, "aap noot mies");
|
||||
textbox_keybinding ( box, MOVE_END);
|
||||
textbox_keybinding ( box, MOVE_WORD_BACK );
|
||||
TASSERT ( box->cursor == 9);
|
||||
textbox_keybinding ( box, MOVE_WORD_BACK );
|
||||
TASSERT ( box->cursor == 4);
|
||||
textbox_keybinding ( box, REMOVE_TO_SOL );
|
||||
TASSERT ( strcmp ( box->text, "noot mies") == 0 );
|
||||
TASSERT ( box->cursor == 0);
|
||||
|
||||
textbox_font ( box, HIGHLIGHT );
|
||||
//textbox_draw ( box, draw );
|
||||
|
||||
|
|
Loading…
Reference in a new issue