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)  

tutor.c File Reference
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <errno.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include "main.h"
#include "auxiliar.h"
#include "callbacks.h"
#include "translation.h"
#include "keyboard.h"
#include "cursor.h"
#include "basic.h"
#include "adaptability.h"
#include "velocity.h"
#include "fluidness.h"
#include "accuracy.h"
#include "top10.h"
#include "tutor.h"
Include dependency graph for tutor.c:

Go to the source code of this file.

Macros

#define MAX_TOUCH_TICS   4000
 
#define GOAL_GSET(MODULE, GOAL, DEFAULT_VAL)
 
#define LEVEL_GSET(MODULE, GOAL, DEFAULT_VAL)
 
#define DECEIVENESS_LIMIT   0.205
 

Functions

TutorType tutor_get_type ()
 
gchar * tutor_get_type_name ()
 
gboolean tutor_is_tibetan ()
 
TutorQuery tutor_get_query ()
 
void tutor_set_query (TutorQuery query)
 
gint tutor_get_correcting ()
 
void tutor_init_timers ()
 
void tutor_init_goals ()
 
gdouble tutor_goal_accuracy ()
 
gdouble tutor_goal_speed ()
 
gdouble tutor_goal_fluidity ()
 
gdouble tutor_goal_level (guint n)
 
void tutor_init (TutorType tt_type)
 
void tutor_update ()
 
void tutor_update_intro ()
 
void tutor_update_start ()
 
void tutor_process_touch (gunichar user_chr)
 
gboolean tutor_eval_forward (gunichar user_chr)
 
gboolean tutor_eval_forward_backward (gunichar user_chr)
 
void tutor_calc_stats ()
 
gboolean tutor_char_distribution_approved ()
 
void tutor_char_distribution_count (gchar *text, Char_Distribution *dist)
 
void tutor_draw_paragraph (gchar *utf8_text)
 
void tutor_load_list_other (gchar *file_name_end, GtkListStore *list)
 
void tutor_other_rename (const gchar *new_tx, const gchar *old_tx)
 
void tutor_message (gchar *mesg)
 
void tutor_beep ()
 
void tutor_speak_string (gchar *string, gboolean wait)
 
gboolean tutor_delayed_finger_tip (gpointer unich)
 
void tutor_speak_char ()
 
void tutor_speak_word ()
 

Variables

GtkCssProvider * keyb_css
 
struct {
   TutorType   type
 
   TutorQuery   query
 
   GTimer *   tmr
 
   gdouble   elapsed_time
 
   gdouble   touch_time [4000+1]
 
   guint   ttidx
 
   gint   n_touchs
 
   gint   n_errors
 
   gint   retro_pos
 
   gint   correcting
 
tutor
 
struct {
   struct {
      double   accuracy
 
      double   speed
 
   }   basic
 
   struct {
      double   accuracy
 
      double   speed
 
      double   accuracy_learning
 
      double   accuracy_improving
 
      double   accuracy_reaching
 
   }   adapt
 
   struct {
      double   accuracy
 
      double   speed
 
      double   speed_crawling
 
      double   speed_stepping
 
      double   speed_walking
 
      double   speed_jogging
 
      double   speed_running
 
      double   speed_professional
 
      double   speed_racer
 
      double   speed_flying
 
   }   velo
 
   struct {
      double   accuracy
 
      double   speed
 
      double   fluidity
 
      double   fluidity_stumbling
 
      double   speed_flying
 
   }   fluid
 
goal
 
gchar * OTHER_DEFAULT
 

Macro Definition Documentation

◆ DECEIVENESS_LIMIT

#define DECEIVENESS_LIMIT   0.205

Ensure the user is not trying to type with weird texts in the fluidness contest

Definition at line 1399 of file tutor.c.

◆ GOAL_GSET

#define GOAL_GSET (   MODULE,
  GOAL,
  DEFAULT_VAL 
)
Value:
if (main_preferences_exist ("goals", #MODULE "_" #GOAL))\
goal.MODULE.GOAL = (gdouble) main_preferences_get_int ("goals", #MODULE "_" #GOAL);\
else\
{\
goal.MODULE.GOAL = DEFAULT_VAL;\
main_preferences_set_int ("goals", #MODULE "_" #GOAL, DEFAULT_VAL);\
}
gint main_preferences_get_int(gchar *group, gchar *key)
Definition: main.c:121
gboolean main_preferences_exist(gchar *group, gchar *key)
Definition: main.c:97

Definition at line 165 of file tutor.c.

◆ LEVEL_GSET

#define LEVEL_GSET (   MODULE,
  GOAL,
  DEFAULT_VAL 
)
Value:
if (main_preferences_exist ("levels", #MODULE "_" #GOAL))\
goal.MODULE.GOAL = (gdouble) main_preferences_get_int ("levels", #MODULE "_" #GOAL);\
else\
{\
goal.MODULE.GOAL = DEFAULT_VAL;\
main_preferences_set_int ("levels", #MODULE "_" #GOAL, DEFAULT_VAL);\
}

Definition at line 173 of file tutor.c.

◆ MAX_TOUCH_TICS

#define MAX_TOUCH_TICS   4000

Definition at line 48 of file tutor.c.

Function Documentation

◆ tutor_beep()

void tutor_beep ( void  )

Beeps (or not) at the user, in the tutor window

Definition at line 1734 of file tutor.c.

References main_preferences_get_boolean().

Referenced by tutor_eval_forward(), tutor_eval_forward_backward(), and tutor_process_touch().

◆ tutor_calc_stats()

◆ tutor_char_distribution_approved()

gboolean tutor_char_distribution_approved ( void  )

◆ tutor_char_distribution_count()

void tutor_char_distribution_count ( gchar *  text,
Char_Distribution dist 
)

◆ tutor_delayed_finger_tip()

gboolean tutor_delayed_finger_tip ( gpointer  unich)

Control delayed tips for the finger to be used

Definition at line 1799 of file tutor.c.

References hints_finger_name_from_char(), and tutor_speak_string().

Referenced by tutor_speak_char().

◆ tutor_draw_paragraph()

void tutor_draw_paragraph ( gchar *  utf8_text)

Formats and draws one paragraph at the tutor window

Definition at line 1575 of file tutor.c.

References get_wg(), and keyb_get_utf8_paragraph_symbol().

Referenced by adapt_draw_random_pattern(), fluid_draw_random_paragraphs(), and velo_draw_random_words().

◆ tutor_eval_forward()

gboolean tutor_eval_forward ( gunichar  user_chr)

Advances the cursor one position and test for correctness, in the shared tutor window. Updates the variables: cursor_pos, n_touchs and n_errors.

Definition at line 784 of file tutor.c.

References accur_correct(), accur_wrong(), cursor_advance(), cursor_get_char(), cursor_paint_char(), MAX_TOUCH_TICS, n_touchs, TT_BASIC, tutor, tutor_beep(), and UPSYM.

Referenced by tutor_process_touch().

◆ tutor_eval_forward_backward()

gboolean tutor_eval_forward_backward ( gunichar  user_chr)

Like the previous, but allows to go back and forth.

Definition at line 850 of file tutor.c.

References accur_correct(), accur_wrong(), cursor_advance(), cursor_get_char(), cursor_paint_char(), MAX_TOUCH_TICS, n_touchs, tutor, tutor_beep(), and UPSYM.

Referenced by tutor_process_touch().

◆ tutor_get_correcting()

gint tutor_get_correcting ( void  )

Definition at line 152 of file tutor.c.

References TT_FLUID, and tutor.

Referenced by cursor_switch_off(), and cursor_switch_on().

◆ tutor_get_query()

TutorQuery tutor_get_query ( void  )

Definition at line 140 of file tutor.c.

References tutor.

Referenced by cb_quick_restart().

◆ tutor_get_type()

◆ tutor_get_type_name()

gchar* tutor_get_type_name ( void  )

◆ tutor_goal_accuracy()

gdouble tutor_goal_accuracy ( void  )

◆ tutor_goal_fluidity()

gdouble tutor_goal_fluidity ( void  )

Definition at line 266 of file tutor.c.

References goal, TT_ADAPT, TT_BASIC, TT_FLUID, TT_VELO, and tutor.

Referenced by fluid_comment(), plot_draw_chart(), and tutor_calc_stats().

◆ tutor_goal_level()

gdouble tutor_goal_level ( guint  n)

Definition at line 279 of file tutor.c.

References goal, TT_ADAPT, TT_FLUID, TT_VELO, and tutor.

Referenced by adapt_comment(), fluid_comment(), and velo_comment().

◆ tutor_goal_speed()

gdouble tutor_goal_speed ( void  )

Definition at line 253 of file tutor.c.

References goal, TT_ADAPT, TT_BASIC, TT_FLUID, TT_VELO, and tutor.

Referenced by fluid_comment(), plot_draw_chart(), tutor_calc_stats(), and velo_comment().

◆ tutor_init()

void tutor_init ( TutorType  tt_type)

Initialize the course

Set the layout for each exercise type

Set decoration texts and tips

Set tooltips of tutor entry (drag and drop)

Set specific variables

Definition at line 294 of file tutor.c.

References _, basic_get_lesson(), basic_init(), callbacks_shield_set(), cursor_set_blink(), fluid_init(), get_wg(), get_win(), MAX_BASIC_LESSONS, QUERY_INTRO, TT_ADAPT, TT_BASIC, TT_FLUID, TT_VELO, tutor, tutor_process_touch(), tutor_update(), and velo_init().

Referenced by on_button_adapt_clicked(), on_button_basic_clicked(), on_button_fluid_clicked(), on_button_velo_clicked(), on_combobox_stat_module_changed(), and on_combobox_top10_language_changed().

◆ tutor_init_goals()

◆ tutor_init_timers()

void tutor_init_timers ( void  )

Definition at line 160 of file tutor.c.

References tutor.

Referenced by main_initialize_global_variables().

◆ tutor_is_tibetan()

◆ tutor_load_list_other()

void tutor_load_list_other ( gchar *  file_name_end,
GtkListStore *  list 
)

Load the list of files to include in the set of "other exercises"

Definition at line 1611 of file tutor.c.

References assert_user_dir(), get_wg(), list, main_path_user(), and OTHER_DEFAULT.

Referenced by on_button_filechooser_open_clicked(), on_button_other_paste_clicked(), and on_button_tutor_other_clicked().

◆ tutor_message()

void tutor_message ( gchar *  mesg)

Put 'mesg' in the message entry line of the shared tutor window

Definition at line 1711 of file tutor.c.

References callbacks_shield_set(), get_wg(), and pos.

Referenced by tutor_process_touch(), tutor_update(), tutor_update_intro(), and tutor_update_start().

◆ tutor_other_rename()

void tutor_other_rename ( const gchar *  new_tx,
const gchar *  old_tx 
)

◆ tutor_process_touch()

◆ tutor_set_query()

◆ tutor_speak_char()

void tutor_speak_char ( )

Speak the current character to be typed

Definition at line 1826 of file tutor.c.

References _, cursor_get_char(), TT_BASIC, tutor, tutor_delayed_finger_tip(), tutor_speak_string(), and UPSYM.

Referenced by tutor_process_touch().

◆ tutor_speak_string()

void tutor_speak_string ( gchar *  string,
gboolean  wait 
)

Speak some phrase

Definition at line 1744 of file tutor.c.

References _, get_wg(), TT_VELO, and tutor.

Referenced by tutor_delayed_finger_tip(), tutor_speak_char(), and tutor_speak_word().

◆ tutor_speak_word()

void tutor_speak_word ( )

Speak the next word to be typed

Definition at line 1878 of file tutor.c.

References cursor_advance(), cursor_get_char(), i, tutor_speak_string(), and UPSYM.

Referenced by tutor_process_touch().

◆ tutor_update()

void tutor_update ( void  )

Update what is shown in the tutor window.

Definition at line 434 of file tutor.c.

References _, QUERY_END, QUERY_INTRO, QUERY_PROCESS_TOUCHS, QUERY_START, tutor, tutor_message(), tutor_update_intro(), and tutor_update_start().

Referenced by on_togglebutton_tutor_intro_toggled(), tutor_init(), and tutor_process_touch().

◆ tutor_update_intro()

◆ tutor_update_start()

Variable Documentation

◆ accuracy

double accuracy

◆ accuracy_improving

double accuracy_improving

Definition at line 75 of file tutor.c.

Referenced by tutor_init_goals().

◆ accuracy_learning

double accuracy_learning

Definition at line 74 of file tutor.c.

Referenced by tutor_init_goals().

◆ accuracy_reaching

double accuracy_reaching

Definition at line 76 of file tutor.c.

Referenced by tutor_init_goals().

◆ 

adapt { ... } struct

Referenced by tutor_init_goals().

◆ 

basic { ... } struct

Referenced by tutor_init_goals().

◆ correcting

gint correcting

Definition at line 60 of file tutor.c.

◆ elapsed_time

gdouble elapsed_time

Definition at line 54 of file tutor.c.

◆ 

fluid { ... } struct

Referenced by tutor_init_goals().

◆ fluidity

double fluidity

Definition at line 95 of file tutor.c.

Referenced by tutor_init_goals().

◆ fluidity_stumbling

double fluidity_stumbling

Definition at line 96 of file tutor.c.

Referenced by tutor_init_goals().

◆ 

◆ keyb_css

GtkCssProvider* keyb_css
extern

Definition at line 41 of file keyboard.c.

Referenced by hints_set_colors(), and keyb_create_virtual_keys().

◆ n_errors

gint n_errors

Definition at line 58 of file tutor.c.

◆ n_touchs

gint n_touchs

Definition at line 57 of file tutor.c.

Referenced by tutor_eval_forward(), and tutor_eval_forward_backward().

◆ OTHER_DEFAULT

gchar* OTHER_DEFAULT
extern

Definition at line 43 of file main.c.

Referenced by tutor_load_list_other(), and tutor_other_rename().

◆ query

TutorQuery query

Definition at line 52 of file tutor.c.

Referenced by tutor_set_query().

◆ retro_pos

gint retro_pos

Definition at line 59 of file tutor.c.

◆ speed

double speed

Definition at line 68 of file tutor.c.

Referenced by tutor_init_goals().

◆ speed_crawling

double speed_crawling

Definition at line 82 of file tutor.c.

Referenced by tutor_init_goals().

◆ speed_flying

double speed_flying

Definition at line 89 of file tutor.c.

Referenced by tutor_init_goals().

◆ speed_jogging

double speed_jogging

Definition at line 85 of file tutor.c.

Referenced by tutor_init_goals().

◆ speed_professional

double speed_professional

Definition at line 87 of file tutor.c.

Referenced by tutor_init_goals().

◆ speed_racer

double speed_racer

Definition at line 88 of file tutor.c.

Referenced by tutor_init_goals().

◆ speed_running

double speed_running

Definition at line 86 of file tutor.c.

Referenced by tutor_init_goals().

◆ speed_stepping

double speed_stepping

Definition at line 83 of file tutor.c.

Referenced by tutor_init_goals().

◆ speed_walking

double speed_walking

Definition at line 84 of file tutor.c.

Referenced by tutor_init_goals().

◆ tmr

GTimer* tmr

Definition at line 53 of file tutor.c.

◆ touch_time

gdouble touch_time[4000+1]

Definition at line 55 of file tutor.c.

Referenced by accur_correct().

◆ ttidx

guint ttidx

Definition at line 56 of file tutor.c.

◆ 

◆ type

TutorType type

Definition at line 51 of file tutor.c.

◆ 

velo { ... } struct

Referenced by tutor_init_goals().