Commit f03b57f32918e3c352f6e7ce6fd48fe4aee3a578

Authored by Perry Werneck
1 parent e85f5749
Exists in master and in 1 other branch develop

Adding Page Up/Down keys support.

src/include/internals.h
@@ -151,6 +151,7 @@ @@ -151,6 +151,7 @@
151 V3270_ACCELERATOR_TYPE_INTERNAL, ///< @brief Accelerator is internal. 151 V3270_ACCELERATOR_TYPE_INTERNAL, ///< @brief Accelerator is internal.
152 V3270_ACCELERATOR_TYPE_LIB3270_ACTION, ///< @brief Accelerator is a lib3270 action. 152 V3270_ACCELERATOR_TYPE_LIB3270_ACTION, ///< @brief Accelerator is a lib3270 action.
153 V3270_ACCELERATOR_TYPE_LIB3270_TOGGLE, ///< @brief Accelerator is a lib3270 toggle. 153 V3270_ACCELERATOR_TYPE_LIB3270_TOGGLE, ///< @brief Accelerator is a lib3270 toggle.
  154 + V3270_ACCELERATOR_TYPE_PFKEY, ///< @brief Accelerator is a PFKey redirector.
154 V3270_ACCELERATOR_TYPE_CUSTOM, ///< @brief Custom (application based) accelerator. 155 V3270_ACCELERATOR_TYPE_CUSTOM, ///< @brief Custom (application based) accelerator.
155 }; 156 };
156 157
@@ -169,6 +170,13 @@ @@ -169,6 +170,13 @@
169 const gchar *name; 170 const gchar *name;
170 } V3270CustomAccelerator; 171 } V3270CustomAccelerator;
171 172
  173 + typedef struct _V3270PFKeyAccelerator
  174 + {
  175 + struct _V3270Accelerator parent;
  176 + const gchar *name;
  177 + unsigned short keycode;
  178 + } V3270PFKeyAccelerator;
  179 +
172 typedef enum v3270_toggleable_dialog 180 typedef enum v3270_toggleable_dialog
173 { 181 {
174 V3270_TOGGLEABLE_DIALOG_PASTE_FAILED, 182 V3270_TOGGLEABLE_DIALOG_PASTE_FAILED,
src/terminal/keyboard/keyfile.c
@@ -30,10 +30,9 @@ @@ -30,10 +30,9 @@
30 #include <config.h> 30 #include <config.h>
31 #include <gtk/gtk.h> 31 #include <gtk/gtk.h>
32 #include <terminal.h> 32 #include <terminal.h>
  33 + #include <lib3270/actions.h>
33 #include "private.h" 34 #include "private.h"
34 35
35 - //#include <v3270/actions.h>  
36 -  
37 struct Args 36 struct Args
38 { 37 {
39 GKeyFile * key_file; 38 GKeyFile * key_file;
@@ -44,18 +43,37 @@ @@ -44,18 +43,37 @@
44 43
45 static void save_accelerator(const V3270Accelerator * accel, const char *keys, gpointer ptr) 44 static void save_accelerator(const V3270Accelerator * accel, const char *keys, gpointer ptr)
46 { 45 {
47 - const gchar * key = v3270_accelerator_get_name(accel);  
48 - if(!key)  
49 - return;  
50 46
51 - debug("%s=%s",v3270_accelerator_get_name(accel),keys); 47 + if(accel->type == V3270_ACCELERATOR_TYPE_PFKEY)
  48 + {
  49 + // It's a PF-Key action!
  50 + g_autofree gchar * key = g_strdup_printf("pf%u",((V3270PFKeyAccelerator *)accel)->keycode);
  51 +
  52 + debug("%s=%s",((V3270PFKeyAccelerator *)accel)->name,key);
52 53
53 - g_key_file_set_string(  
54 - ((struct Args *) ptr)->key_file,  
55 - ((struct Args *) ptr)->group_name,  
56 - key,  
57 - (keys ? keys : "")  
58 - ); 54 + g_key_file_set_string(
  55 + ((struct Args *) ptr)->key_file,
  56 + ((struct Args *) ptr)->group_name,
  57 + ((V3270PFKeyAccelerator *)accel)->name,
  58 + key
  59 + );
  60 +
  61 + }
  62 + else
  63 + {
  64 + const gchar * key = v3270_accelerator_get_name(accel);
  65 + if(!key)
  66 + return;
  67 +
  68 + debug("%s=%s",v3270_accelerator_get_name(accel),keys);
  69 +
  70 + g_key_file_set_string(
  71 + ((struct Args *) ptr)->key_file,
  72 + ((struct Args *) ptr)->group_name,
  73 + key,
  74 + (keys ? keys : "")
  75 + );
  76 + }
59 77
60 } 78 }
61 79
@@ -68,6 +86,11 @@ @@ -68,6 +86,11 @@
68 86
69 } 87 }
70 88
  89 + static int fire_pfkey_action(GtkWidget *widget, V3270PFKeyAccelerator *accel)
  90 + {
  91 + return lib3270_pfkey(v3270_get_session(widget),(int) accel->keycode);
  92 + }
  93 +
71 void v3270_accelerator_map_set_entry(v3270 *terminal, const gchar *name, const gchar *keys) 94 void v3270_accelerator_map_set_entry(v3270 *terminal, const gchar *name, const gchar *keys)
72 { 95 {
73 V3270Accelerator * accel = NULL; 96 V3270Accelerator * accel = NULL;
@@ -103,8 +126,47 @@ @@ -103,8 +126,47 @@
103 126
104 if(!accel) 127 if(!accel)
105 { 128 {
106 - debug("Can't find accelerator \"%s\"",name);  
107 - g_warning("Can't find accelerator \"%s\"",name); 129 + // Is a special PFKey action?
  130 +
  131 + // Page_Down=pf8
  132 +
  133 + unsigned int pfkey = 0;
  134 +
  135 + if(sscanf(keys,"pf%u",&pfkey) == 1)
  136 + {
  137 + guint key;
  138 + GdkModifierType mods;
  139 +
  140 + debug("Creating special accelerator for PF%u",pfkey);
  141 +
  142 + gtk_accelerator_parse(name,&key,&mods);
  143 +
  144 + if(!key)
  145 + {
  146 + g_warning("Can't parse accelerator %s",name);
  147 + return;
  148 + }
  149 +
  150 + // Remap PFKey accelerator
  151 + V3270PFKeyAccelerator *pfAccel = g_new0(V3270PFKeyAccelerator,1);
  152 +
  153 + pfAccel->keycode = (unsigned short) pfkey;
  154 + pfAccel->name = g_intern_string(name);
  155 + pfAccel->parent.type = V3270_ACCELERATOR_TYPE_PFKEY;
  156 + pfAccel->parent.key = key;
  157 + pfAccel->parent.mods = mods;
  158 + pfAccel->parent.arg = (gconstpointer) pfAccel;
  159 + pfAccel->parent.activate = G_CALLBACK(fire_pfkey_action);
  160 +
  161 + terminal->accelerators = g_slist_prepend(terminal->accelerators,pfAccel);
  162 +
  163 + }
  164 + else
  165 + {
  166 + debug("Can't find accelerator \"%s\"",name);
  167 + g_warning("Can't find accelerator \"%s\"",name);
  168 + }
  169 +
108 return; 170 return;
109 } 171 }
110 172
@@ -112,7 +174,7 @@ @@ -112,7 +174,7 @@
112 174
113 { 175 {
114 size_t ix; 176 size_t ix;
115 - gchar ** keycodes = g_strsplit(keys,",",-1); 177 + gchar ** keycodes = g_strsplit(keys," ",-1);
116 178
117 for(ix=0;keycodes[ix];ix++) 179 for(ix=0;keycodes[ix];ix++)
118 { 180 {