klavaro  3.13
About: Klavaro is a touch typing tutor program.
  Fossies Dox: klavaro-3.13.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

keyboard.c File Reference
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include "auxiliar.h"
#include "main.h"
#include "callbacks.h"
#include "translation.h"
#include "keyboard.h"
Include dependency graph for keyboard.c:

Go to the source code of this file.

Macros

#define KEY_DX   35
 
#define KEY_DY   35
 
#define LAYOUT_BLOCK   64
 

Functions

gchar * keyb_get_name ()
 
gchar * keyb_get_name_last ()
 
void keyb_set_name (const gchar *name)
 
void keyb_init_name (const gchar *name)
 
gunichar keyb_get_lochars (gint i, gint j)
 
gunichar keyb_get_upchars (gint i, gint j)
 
gboolean keyb_get_modified_status ()
 
void keyb_set_modified_status (gboolean new_status)
 
void keyb_create_virtual_keys ()
 
void keyb_set_chars ()
 
gboolean keyb_is_inset (gunichar chr)
 
gboolean keyb_is_vowel (gunichar chr)
 
gboolean keyb_is_diacritic (gunichar chr)
 
gint keyb_get_vowels (gunichar *vows)
 
gint keyb_get_consonants (gunichar *consonants)
 
gint keyb_get_symbols (gunichar *symbols)
 
gint keyb_get_altnums (gunichar *altnums)
 
gunichar keyb_unichar_toupper (gunichar uchar)
 
void keyb_save_new_layout ()
 
void keyb_remove_user_layout ()
 
void keyb_update_virtual_layout ()
 
GList * keyb_get_layout_list_from_path (gchar *path)
 
gchar * keyb_get_country_code (const gchar *kbd)
 
gchar * keyb_get_country (const gchar *kbd)
 
gchar * keyb_get_variant (const gchar *kbd)
 
void keyb_set_keyboard_layouts ()
 
void keyb_update_from_variant (gchar *cmb_country, gchar *cmb_variant)
 
void keyb_set_combo_kbd_variant (gchar *cmb_country, gchar *cmb_variant)
 
void keyb_set_combo_kbd (gchar *cmb_country, gchar *cmb_variant)
 
void keyb_update_combos (gchar *cmb_country, gchar *cmb_variant)
 
void keyb_intro_step_next ()
 
void keyb_intro_step_previous ()
 
void keyb_intro_step (gint step)
 
gchar * keyb_mode_get_name ()
 
void keyb_mode_intro ()
 
void keyb_mode_hint ()
 
void keyb_mode_edit ()
 
void keyb_set_sensitive (gboolean state)
 
gboolean keyb_button_match (GtkButton *button)
 
void keyb_edit_button (GtkButton *button)
 
void keyb_edit_none (void)
 
gboolean keyb_edit_next (void)
 
void keyb_change_key (gunichar real_key)
 
gchar * keyb_get_utf8_paragraph_symbol ()
 
void hints_init ()
 
gchar * hints_string_from_charcode (gchar charcode)
 
gchar * hints_color_from_charcode (gchar charcode)
 
void hints_set_tips ()
 
void hints_set_colors ()
 
void hints_update_from_button (GtkButton *button)
 
void hints_update_from_char (gunichar character)
 
gboolean hints_demo_fingers_move (gpointer data)
 
void hints_demo_fingers (guint msec)
 
gchar * hints_finger_name_from_char (gunichar uch)
 

Variables

gchar * KEYB_CUSTOM
 
gchar * KEYB_EDIT
 
GtkCssProvider * keyb_css = NULL
 
struct {
   gchar *   name
 
   gchar *   name_last
 
   gboolean   modified_status
 
   gunichar   lochars [4][(14+1)+1]
 
   gunichar   upchars [4][(14+1)+1]
 
   GtkWidget *   but [4][(14+1) - 1]
 
   GtkWidget *   lab [4][(14+1) - 1]
 
   GtkWidget *   entry
 
   struct {
      guint   i
 
      guint   j
 
   }   pos
 
   gint   cmb_n
 
   gint   intro_step
 
keyb
 
static guint x0 [4] = {0, 49, 59, 43}
 
struct {
   KeybLayout *   orig
 
   gint   n_orig
 
   KeybLayout *   cust
 
   gint   n_cust
 
layouts
 
const gunichar vowels []
 
const gunichar diacritics []
 
static gchar hints [4][(14+1)+1]
 
static gboolean hints_is_initialized = FALSE
 

Macro Definition Documentation

◆ KEY_DX

#define KEY_DX   35

Definition at line 34 of file keyboard.c.

◆ KEY_DY

#define KEY_DY   35

Definition at line 35 of file keyboard.c.

◆ LAYOUT_BLOCK

#define LAYOUT_BLOCK   64

Definition at line 795 of file keyboard.c.

Function Documentation

◆ hints_color_from_charcode()

gchar* hints_color_from_charcode ( gchar  charcode)

◆ hints_demo_fingers()

void hints_demo_fingers ( guint  msec)

◆ hints_demo_fingers_move()

gboolean hints_demo_fingers_move ( gpointer  data)

Definition at line 1952 of file keyboard.c.

References data, i, keyb, and keyb_edit_next().

Referenced by hints_demo_fingers().

◆ hints_finger_name_from_char()

gchar* hints_finger_name_from_char ( gunichar  uch)

Definition at line 1987 of file keyboard.c.

References hints, hints_init(), hints_string_from_charcode(), i, j, keyb, and UPSYM.

Referenced by tutor_delayed_finger_tip().

◆ hints_init()

◆ hints_set_colors()

void hints_set_colors ( void  )

Definition at line 1848 of file keyboard.c.

References hints, hints_is_initialized, i, j, KEY_LINE_LEN, keyb, and keyb_css.

Referenced by hints_init().

◆ hints_set_tips()

void hints_set_tips ( void  )

◆ hints_string_from_charcode()

gchar* hints_string_from_charcode ( gchar  charcode)

Definition at line 1707 of file keyboard.c.

References _.

Referenced by hints_finger_name_from_char(), and hints_set_tips().

◆ hints_update_from_button()

void hints_update_from_button ( GtkButton *  button)

◆ hints_update_from_char()

void hints_update_from_char ( gunichar  character)

Definition at line 1911 of file keyboard.c.

References get_wg(), hints, hints_init(), i, j, keyb, set_pixmap(), and UPSYM.

Referenced by on_button_keyboard_hands_clicked(), and tutor_process_touch().

◆ keyb_button_match()

gboolean keyb_button_match ( GtkButton *  button)

Definition at line 1506 of file keyboard.c.

References i, j, KEY_LINE_LEN, and keyb.

Referenced by hints_update_from_button(), and keyb_edit_button().

◆ keyb_change_key()

void keyb_change_key ( gunichar  real_key)

Apply the key pressed to the virtual keyboard and to the upper or lower character sets

Definition at line 1609 of file keyboard.c.

References get_wg(), keyb, and keyb_set_modified_status().

Referenced by on_virtual_key_changed().

◆ keyb_create_virtual_keys()

◆ keyb_edit_button()

void keyb_edit_button ( GtkButton *  button)

Moves the entry widget to get a real key pressed and writes the name of the virtual one.

Definition at line 1532 of file keyboard.c.

References callbacks_shield_set(), get_wg(), KEY_DX, KEY_DY, keyb, keyb_button_match(), and x0.

Referenced by on_virtual_key_clicked(), and on_virtual_key_grab_focus().

◆ keyb_edit_next()

gboolean keyb_edit_next ( void  )

Definition at line 1563 of file keyboard.c.

References keyb.

Referenced by hints_demo_fingers_move().

◆ keyb_edit_none()

◆ keyb_get_altnums()

gint keyb_get_altnums ( gunichar *  altnums)

Get the set of available non-arabic digits in the keyboard

Definition at line 567 of file keyboard.c.

References i, j, KEY_LINE_LEN, and keyb.

Referenced by adapt_create_number().

◆ keyb_get_consonants()

gint keyb_get_consonants ( gunichar *  consonants)

Get the set of available consonants of the keyboard

Definition at line 518 of file keyboard.c.

References i, j, KEY_LINE_LEN, keyb, and keyb_is_vowel().

Referenced by adapt_create_word().

◆ keyb_get_country()

gchar* keyb_get_country ( const gchar *  kbd)

Definition at line 758 of file keyboard.c.

References keyb_get_country_code(), and trans_code_to_country().

Referenced by keyb_set_keyboard_layouts(), and keyb_update_combos().

◆ keyb_get_country_code()

gchar* keyb_get_country_code ( const gchar *  kbd)

Definition at line 740 of file keyboard.c.

Referenced by keyb_get_country(), and tutor_is_tibetan().

◆ keyb_get_layout_list_from_path()

GList* keyb_get_layout_list_from_path ( gchar *  path)

Definition at line 698 of file keyboard.c.

References compare_string_function(), and path.

Referenced by keyb_set_keyboard_layouts().

◆ keyb_get_lochars()

gunichar keyb_get_lochars ( gint  i,
gint  j 
)

Definition at line 232 of file keyboard.c.

References i, j, and keyb.

Referenced by basic_init_char_set().

◆ keyb_get_modified_status()

gboolean keyb_get_modified_status ( void  )

Definition at line 244 of file keyboard.c.

References keyb.

◆ keyb_get_name()

◆ keyb_get_name_last()

gchar* keyb_get_name_last ( void  )

Definition at line 210 of file keyboard.c.

References keyb.

◆ keyb_get_symbols()

gint keyb_get_symbols ( gunichar *  symbols)

Get the set of available symbols of the keyboard

Definition at line 543 of file keyboard.c.

References i, j, KEY_LINE_LEN, and keyb.

Referenced by adapt_create_word(), and fluid_filter_utf8().

◆ keyb_get_upchars()

gunichar keyb_get_upchars ( gint  i,
gint  j 
)

Definition at line 238 of file keyboard.c.

References i, j, and keyb.

Referenced by basic_init_char_set().

◆ keyb_get_utf8_paragraph_symbol()

gchar* keyb_get_utf8_paragraph_symbol ( void  )

Get an utf8 string for the par symbol

Definition at line 1649 of file keyboard.c.

References UPSYM.

Referenced by basic_draw_lesson(), on_entry_mesg_activate(), and tutor_draw_paragraph().

◆ keyb_get_variant()

gchar* keyb_get_variant ( const gchar *  kbd)

Definition at line 773 of file keyboard.c.

Referenced by keyb_set_combo_kbd_variant(), and keyb_set_keyboard_layouts().

◆ keyb_get_vowels()

gint keyb_get_vowels ( gunichar *  vows)

Get the set of available vowels of the keyboard

Definition at line 491 of file keyboard.c.

References i, j, KEY_LINE_LEN, keyb, keyb_is_diacritic(), and keyb_is_vowel().

Referenced by accur_create_word(), and adapt_create_word().

◆ keyb_init_name()

void keyb_init_name ( const gchar *  name)

Definition at line 225 of file keyboard.c.

References keyb, and name.

Referenced by keyb_set_combo_kbd().

◆ keyb_intro_step()

void keyb_intro_step ( gint  step)

◆ keyb_intro_step_next()

void keyb_intro_step_next ( void  )

Definition at line 1148 of file keyboard.c.

References keyb, and keyb_intro_step().

Referenced by on_button_keyboard_next_clicked().

◆ keyb_intro_step_previous()

void keyb_intro_step_previous ( void  )

Definition at line 1155 of file keyboard.c.

References keyb, and keyb_intro_step().

Referenced by on_button_keyboard_previous_clicked().

◆ keyb_is_diacritic()

gboolean keyb_is_diacritic ( gunichar  chr)

Test if chr is a diacritic character

Definition at line 476 of file keyboard.c.

References diacritics, and i.

Referenced by accur_create_word(), adapt_create_word(), basic_draw_lesson(), and keyb_get_vowels().

◆ keyb_is_inset()

gboolean keyb_is_inset ( gunichar  chr)

Test if chr belongs to the current key set

Definition at line 442 of file keyboard.c.

References i, j, KEY_LINE_LEN, and keyb.

Referenced by accur_correct(), and accur_wrong().

◆ keyb_is_vowel()

gboolean keyb_is_vowel ( gunichar  chr)

Test if chr is a vowel

Definition at line 462 of file keyboard.c.

References i, and vowels.

Referenced by basic_draw_lesson(), keyb_get_consonants(), and keyb_get_vowels().

◆ keyb_mode_edit()

◆ keyb_mode_get_name()

gchar* keyb_mode_get_name ( void  )

Definition at line 1358 of file keyboard.c.

References get_wg().

Referenced by keyb_mode_hint(), keyb_mode_intro(), and on_combobox_stat_module_changed().

◆ keyb_mode_hint()

◆ keyb_mode_intro()

void keyb_mode_intro ( void  )

◆ keyb_remove_user_layout()

void keyb_remove_user_layout ( void  )

Remove custom keyboard layout created by the user

Definition at line 640 of file keyboard.c.

References callbacks_shield_set(), get_wg(), keyb_set_keyboard_layouts(), and main_path_user().

Referenced by on_button_confirm_yes_clicked().

◆ keyb_save_new_layout()

void keyb_save_new_layout ( void  )

Save the custom keyboard layout created by the user

Definition at line 608 of file keyboard.c.

References assert_user_dir(), i, KEY_LINE_LEN, keyb, keyb_set_modified_status(), and main_path_user().

Referenced by on_button_confirm_yes_clicked().

◆ keyb_set_chars()

void keyb_set_chars ( void  )

Read the character sets (keyb.lochars[] & keyb.upchars[]) for the keyboard currently selected.

Definition at line 361 of file keyboard.c.

References i, KEY_LINE_LEN, keyb, keyb_set_modified_status(), keyb_set_name(), main_path_data(), main_path_user(), main_preferences_remove(), main_preferences_set_string(), and trans_get_default_keyboard().

Referenced by keyb_set_combo_kbd(), keyb_update_from_variant(), and on_button_keyboard_cancel_clicked().

◆ keyb_set_combo_kbd()

◆ keyb_set_combo_kbd_variant()

void keyb_set_combo_kbd_variant ( gchar *  cmb_country,
gchar *  cmb_variant 
)

◆ keyb_set_keyboard_layouts()

◆ keyb_set_modified_status()

void keyb_set_modified_status ( gboolean  new_status)

◆ keyb_set_name()

void keyb_set_name ( const gchar *  name)

◆ keyb_set_sensitive()

void keyb_set_sensitive ( gboolean  state)

Definition at line 1489 of file keyboard.c.

References get_wg(), i, j, KEY_LINE_LEN, and keyb.

Referenced by keyb_intro_step(), and keyb_mode_edit().

◆ keyb_unichar_toupper()

gunichar keyb_unichar_toupper ( gunichar  uchar)

Get the upper case of a letter, only if it's included in the keyboard (by shift)

Definition at line 591 of file keyboard.c.

References i, j, KEY_LINE_LEN, and keyb.

Referenced by adapt_create_word(), and adapt_draw_random_pattern().

◆ keyb_update_combos()

void keyb_update_combos ( gchar *  cmb_country,
gchar *  cmb_variant 
)

◆ keyb_update_from_variant()

void keyb_update_from_variant ( gchar *  cmb_country,
gchar *  cmb_variant 
)

◆ keyb_update_virtual_layout()

void keyb_update_virtual_layout ( void  )

Update the virtual keyboard accordingly to its character set and shift key state.

Definition at line 671 of file keyboard.c.

References get_wg(), i, j, KEY_LINE_LEN, and keyb.

Referenced by keyb_mode_edit(), keyb_mode_hint(), keyb_mode_intro(), keyb_update_from_variant(), on_toggle_shift1_toggled(), and on_toggle_shift2_toggled().

Variable Documentation

◆ but

GtkWidget* but[4][(14+1) - 1]

Definition at line 50 of file keyboard.c.

◆ cmb_n

gint cmb_n

Definition at line 58 of file keyboard.c.

◆ cust

KeybLayout* cust

Definition at line 67 of file keyboard.c.

◆ diacritics

const gunichar diacritics[]

Definition at line 95 of file keyboard.c.

Referenced by keyb_is_diacritic().

◆ entry

GtkWidget* entry

◆ hints

gchar hints[4][(14+1)+1]
static

Initialize the hints mapping array

Definition at line 1665 of file keyboard.c.

Referenced by hints_finger_name_from_char(), hints_init(), hints_set_colors(), hints_set_tips(), hints_update_from_button(), and hints_update_from_char().

◆ hints_is_initialized

gboolean hints_is_initialized = FALSE
static

Definition at line 1666 of file keyboard.c.

Referenced by hints_init(), hints_set_colors(), and hints_set_tips().

◆ i

guint i

Definition at line 55 of file keyboard.c.

Referenced by accur_close(), accur_correct(), accur_create_word(), accur_error_total(), accur_init(), accur_profi_aver(), accur_terror_char_utf8(), accur_terror_sort(), accur_ttime_char_utf8(), accur_ttime_print(), accur_ttime_sort(), accur_wrong(), accur_wrong_get(), adapt_create_number(), adapt_create_word(), adapt_draw_random_pattern(), basic_draw_lesson(), basic_init_char_set(), cursor_advance(), fluid_draw_random_paragraphs(), fluid_filter_utf8(), get_par(), hints_demo_fingers_move(), hints_finger_name_from_char(), hints_init(), hints_set_colors(), hints_set_tips(), hints_update_from_char(), keyb_button_match(), keyb_create_virtual_keys(), keyb_get_altnums(), keyb_get_consonants(), keyb_get_lochars(), keyb_get_symbols(), keyb_get_upchars(), keyb_get_vowels(), keyb_is_diacritic(), keyb_is_inset(), keyb_is_vowel(), keyb_save_new_layout(), keyb_set_chars(), keyb_set_combo_kbd(), keyb_set_combo_kbd_variant(), keyb_set_keyboard_layouts(), keyb_set_sensitive(), keyb_unichar_toupper(), keyb_update_combos(), keyb_update_from_variant(), keyb_update_virtual_layout(), on_combobox_stat_module_changed(), on_window_hints_check_resize(), plot_draw_chart(), plot_error_frequencies(), plot_initialize(), plot_touch_times(), top10_clean_stat(), top10_compare_insert_stat(), top10_delete_stat(), top10_global_publish(), top10_init(), top10_init_stats(), top10_insert_stat(), top10_merge_stats_from_file(), top10_read_stats_from_file(), top10_show_stats(), top10_write_stats(), trans_change_language(), trans_code_to_country(), trans_get_code(), trans_get_current_language(), trans_get_default_keyboard(), trans_init_lang_name_code(), trans_init_language_env(), trans_lang_get_similar(), trans_lang_get_similar_file(), trans_lang_get_similar_file_name(), trans_lang_is_available(), trans_set_combo_language(), tutor_calc_stats(), tutor_char_distribution_approved(), tutor_char_distribution_count(), tutor_speak_word(), velo_draw_random_words(), and velo_filter_utf8().

◆ intro_step

gint intro_step

Definition at line 59 of file keyboard.c.

◆ j

◆ 

◆ keyb_css

GtkCssProvider* keyb_css = NULL

Definition at line 41 of file keyboard.c.

Referenced by hints_set_colors(), and keyb_create_virtual_keys().

◆ KEYB_CUSTOM

gchar* KEYB_CUSTOM
extern

◆ KEYB_EDIT

gchar* KEYB_EDIT
extern

◆ lab

GtkWidget* lab[4][(14+1) - 1]

Definition at line 51 of file keyboard.c.

◆ 

◆ lochars

gunichar lochars[4][(14+1)+1]

Definition at line 48 of file keyboard.c.

◆ modified_status

gboolean modified_status

Definition at line 47 of file keyboard.c.

◆ n_cust

gint n_cust

Definition at line 68 of file keyboard.c.

◆ n_orig

gint n_orig

Definition at line 66 of file keyboard.c.

◆ name

◆ name_last

gchar* name_last

Definition at line 46 of file keyboard.c.

◆ orig

KeybLayout* orig

Definition at line 65 of file keyboard.c.

◆ 

pos { ... } struct

◆ upchars

gunichar upchars[4][(14+1)+1]

Definition at line 49 of file keyboard.c.

◆ vowels

const gunichar vowels[]
Initial value:
= {
L'a', L'e', L'i', L'o', L'u',
(gunichar) 945,
(gunichar) 949,
(gunichar) 953,
(gunichar) 959,
(gunichar) 965,
(gunichar) 1072,
(gunichar) 1077,
(gunichar) 1080,
(gunichar) 1086,
(gunichar) 1091,
(gunichar) 0x0F72,
(gunichar) 0x0F74,
(gunichar) 0x0F7A,
(gunichar) 0x0F7C,
L'\0'
}

Definition at line 73 of file keyboard.c.

Referenced by accur_create_word(), adapt_create_word(), and keyb_is_vowel().

◆ x0

guint x0[4] = {0, 49, 59, 43}
static

Definition at line 61 of file keyboard.c.

Referenced by keyb_create_virtual_keys(), and keyb_edit_button().