GrafX2 2.9.3227
The ultimate 256-color painting program
|
Text input GUI widget. More...
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "const.h"
#include "struct.h"
#include "global.h"
#include "misc.h"
#include "osdep.h"
#include "errors.h"
#include "screen.h"
#include "readline.h"
#include "windows.h"
#include "input.h"
#include "engine.h"
#include "unicode.h"
#include "keycodes.h"
Macros | |
#define | VIRT_KEY_DEFAULT_ON 0 |
#define | TEXT_COLOR MC_Black |
#define | BACKGROUND_COLOR MC_Light |
#define | CURSOR_COLOR MC_Black |
#define | CURSOR_BACKGROUND_COLOR MC_Dark |
Functions | |
static void | Remove_character (char *str, int position) |
remove a character from a string More... | |
static void | Remove_character_unicode (word *str, int position) |
remove a character from a unicode string More... | |
static void | Insert_character (char *str, char letter, int position) |
Insert a character in string at position. More... | |
static void | Insert_character_unicode (word *str, word c, int position) |
Insert a character in unicode string at position. More... | |
static int | Prepend_string (char *dest, const char *src, int max) |
Insert a string at the start of another. More... | |
static int | Prepend_string_unicode (word *dest, const word *src, int max) |
Insert a unicode string at the start of another. More... | |
static int | Valid_character (word c, enum INPUT_TYPE input_type) |
Check validy of character depending on input_type. More... | |
static void | Cleanup_string (char *str, int input_type) |
remove invalid characters More... | |
static void | Cleanup_string_unicode (word *str, int input_type) |
remove invalid characters More... | |
static void | Display_whole_string (word x_pos, word y_pos, const char *str, byte position) |
Prints the string and the cursor on screen. More... | |
static void | Display_whole_string_unicode (word x_pos, word y_pos, const word *str_unicode, byte position) |
Prints the unicode string and the cursor on screen. More... | |
void | Init_virtual_keyboard (word y_pos, word keyboard_width, word keyboard_height) |
Initializes and displays the visual keyboard. More... | |
byte | Readline (word x_pos, word y_pos, char *str, byte visible_size, enum INPUT_TYPE input_type) |
Lets the user input a line of text, exit by Esc or Return. More... | |
byte | Readline_ex (word x_pos, word y_pos, char *str, byte visible_size, byte max_size, enum INPUT_TYPE input_type, byte decimal_places) |
Lets the user input a line of text, exit by Esc or Return. More... | |
byte | Readline_ex_unicode (word x_pos, word y_pos, char *str, word *str_unicode, byte visible_size, byte max_size, enum INPUT_TYPE input_type, byte decimal_places) |
Lets the user input a line of text, exit by Esc or Return. More... | |
void | Sprint_double (char *str, double value, byte decimal_places, byte min_positions) |
Converts a double to string. More... | |
Text input GUI widget.
#define VIRT_KEY_DEFAULT_ON 0 |
#define TEXT_COLOR MC_Black |
#define BACKGROUND_COLOR MC_Light |
#define CURSOR_COLOR MC_Black |
#define CURSOR_BACKGROUND_COLOR MC_Dark |
|
static |
remove a character from a string
Referenced by Readline_ex_unicode().
|
static |
remove a character from a unicode string
Referenced by Readline_ex_unicode().
|
static |
Insert a character in string at position.
Referenced by Readline_ex_unicode().
Insert a character in unicode string at position.
Referenced by Readline_ex_unicode().
|
static |
Insert a string at the start of another.
Up to MAX characters only.
Referenced by Readline_ex_unicode().
Insert a unicode string at the start of another.
Up to MAX characters only.
References Unicode_strlen().
Referenced by Readline_ex_unicode().
|
static |
Check validy of character depending on input_type.
References INPUT_TYPE_DECIMAL, INPUT_TYPE_FILENAME, INPUT_TYPE_HEXA, INPUT_TYPE_INTEGER, and INPUT_TYPE_STRING.
Referenced by Cleanup_string(), Cleanup_string_unicode(), and Readline_ex_unicode().
|
static |
|
static |
Prints the string and the cursor on screen.
x_pos,y_pos | position on screen |
str | the string to display |
position | the cursor position |
References BACKGROUND_COLOR, CURSOR_BACKGROUND_COLOR, CURSOR_COLOR, Menu_factor_X, Print_general(), and TEXT_COLOR.
Referenced by Readline_ex_unicode().
|
static |
Prints the unicode string and the cursor on screen.
x_pos,y_pos | position on screen |
str_unicode | the string to display |
position | the cursor position |
References BACKGROUND_COLOR, CURSOR_BACKGROUND_COLOR, CURSOR_COLOR, Menu_factor_X, Print_general_unicode(), and TEXT_COLOR.
Referenced by Readline_ex_unicode().
Initializes and displays the visual keyboard.
References Hide_cursor, MC_Black, MC_Light, MC_White, Menu_factor_X, Menu_factor_Y, Open_popup(), Screen_height, Screen_width, Window_height, Window_pos_X, Window_pos_Y, Window_rectangle(), and Window_width.
Referenced by Readline_ex_unicode().
byte Readline | ( | word | x_pos, |
word | y_pos, | ||
char * | str, | ||
byte | visible_size, | ||
enum INPUT_TYPE | input_type | ||
) |
Lets the user input a line of text, exit by Esc or Return.
x_pos | Coordinates of input, in window coordinates before scaling. |
y_pos | Coordinates of input, in window coordinates before scaling. |
str | The original string value (will be modified, unless user cancels. |
visible_size | Number of characters visible and editable. |
input_type | one of enum INPUT_TYPE |
References INPUT_TYPE_FILENAME, and Readline_ex().
Referenced by Button_Airbrush_menu(), Button_Anim_time(), Button_Colorize_menu(), Button_Grid_menu(), Button_Load_or_Save(), Button_Palette(), Button_Quick_shade_menu(), Button_Resolution(), Button_Settings(), Button_Smooth_menu(), Button_Text(), Button_Tiling_menu(), Button_Transform_menu(), Load_SCR(), Menu_shade(), and Requester_window().
byte Readline_ex | ( | word | x_pos, |
word | y_pos, | ||
char * | str, | ||
byte | visible_size, | ||
byte | max_size, | ||
enum INPUT_TYPE | input_type, | ||
byte | decimal_places | ||
) |
Lets the user input a line of text, exit by Esc or Return.
x_pos | Coordinates of input, in window coordinates before scaling. |
y_pos | Coordinates of input, in window coordinates before scaling. |
str | The original string value (will be modified, unless user cancels. |
visible_size | Number of characters visible. |
max_size | Number of characters editable. |
input_type | one of enum INPUT_TYPE |
decimal_places | Number of decimal places (used only with decimal type) |
References NULL, and Readline_ex_unicode().
Referenced by Button_Load_or_Save(), Button_Text(), and Readline().
byte Readline_ex_unicode | ( | word | x_pos, |
word | y_pos, | ||
char * | str, | ||
word * | unicode_str, | ||
byte | visible_size, | ||
byte | max_size, | ||
enum INPUT_TYPE | input_type, | ||
byte | decimal_places | ||
) |
Lets the user input a line of text, exit by Esc or Return.
x_pos,y_pos | Coordinates of input, in window coordinates before scaling. |
str | The original string value. Will be modified, unless user cancels or unicode_str is not NULL. |
unicode_str | The original unicode string value or NULL for ANSI editing. Will be modified if not NULL, unless user cancels. |
visible_size | Number of characters visible. |
max_size | Number of characters editable. |
input_type | one of enum INPUT_TYPE |
decimal_places | Number of decimal places (used only with decimal type) |
References BACKGROUND_COLOR, Cleanup_string(), Cleanup_string_unicode(), Close_popup(), Config, Display_cursor(), Display_whole_string(), Display_whole_string_unicode(), Flush_update(), Fround(), Get_input(), GFX2_GetTextClipboard(), GFX2_INFO, GFX2_Log(), GFX2_WARNING, Hide_cursor, Init_virtual_keyboard(), Input_sticky_control, INPUT_TYPE_DECIMAL, INPUT_TYPE_FILENAME, INPUT_TYPE_HEXA, INPUT_TYPE_INTEGER, INPUT_TYPE_STRING, Insert_character(), Insert_character_unicode(), Key, Key_ANSI, KEY_BACKSPACE, KEY_CAPSLOCK, KEY_CLEAR, KEY_DELETE, KEY_END, KEY_ESC, KEY_HOME, KEY_LEFT, KEY_NONE, KEY_RETURN, KEY_RIGHT, Key_UNICODE, Keyboard_click_allowed, label, LEFT_SIDE, LEFT_TRIANGLE_CHARACTER, MC_Black, MC_Light, Menu_factor_X, Menu_factor_Y, Mouse_K, Mouse_X, NULL, Pixel_height, Pixel_width, Prepend_string(), Prepend_string_unicode(), Print_in_window(), Print_in_window_limited(), Remove_character(), Remove_character_unicode(), RIGHT_SIDE, RIGHT_TRIANGLE_CHARACTER, Screen_FillRect(), SHORTCUT_PASTE, Sprint_double(), TEXT_COLOR, Unicode_char_strlcat(), Unicode_char_strlcpy(), Unicode_strlcpy(), Unicode_strlen(), Update_rect(), Update_window_area, T_Config::Use_virtual_keyboard, Valid_character(), VIRT_KEY_DEFAULT_ON, Wait_end_of_click(), Window_clicked_button(), Window_display_frame_in(), Window_height, Window_pos_X, Window_pos_Y, Window_set_normal_button(), and Window_width.
Referenced by Button_Load_or_Save(), and Readline_ex().
Converts a double to string.
str | Target string, should be pre-allocated and at least 40 characters, to be safe. |
value | The number to convert |
decimal_places | Number of decimal places to keep. 15 seems the maximum. |
min_positions | Minimum number of characters: Will pad spaces on the left to meet this minimum. |
Referenced by Readline_ex_unicode().