Hi all,
I've been using pentadactyl off and on with vimprobable2 and one feature
I really enjoy is how pentadactyl allows pneumonic quickmarks by way of
assigning letters to quickmarks (not just numbers like we use).
The attached patch adds support for quickmarks in the ASCII character
range.
Unfortunately, it is not backwards compatible with old quickmark files
(numbers 1 to 9 will now map to their ASCII codes and require being set
by the user in the appropriate positions).
Also, top level mod keys will not work (g and z) as quickmarks (so while
'qr' will function, 'qz' or variations will not).
Let me know what you think, I know I'll find this useful (at a minimum,
its 48 new quickmarks a-z and A-Z sans g/z combos, although I did add '0').
diff --git a/keymap.h b/keymap.h
index 3c7dc05..395a92d 100644
--- a/keymap.h
+++ b/keymap.h
@@ -17,7 +17,7 @@
Key keys[] = {
/* modmask, modkey, key, function, argument */
{ 0, GDK_q, GDK_1, quickmark, { .s = "1" } },
- { 0, GDK_q, GDK_2, quickmark, { .s = "2" } },
+ { 0, GDK_q, GDK_2, quickmark, { .s = "2" } },
{ 0, GDK_q, GDK_3, quickmark, { .s = "3" } },
{ 0, GDK_q, GDK_4, quickmark, { .s = "4" } },
{ 0, GDK_q, GDK_5, quickmark, { .s = "5" } },
@@ -25,6 +25,59 @@ Key keys[] = {
{ 0, GDK_q, GDK_7, quickmark, { .s = "7" } },
{ 0, GDK_q, GDK_8, quickmark, { .s = "8" } },
{ 0, GDK_q, GDK_9, quickmark, { .s = "9" } },
+ { 0, GDK_q, GDK_0, quickmark, { .s = "0" } },
+ { 0, GDK_q, GDK_a, quickmark, { .s = "a" } },
+ { 0, GDK_q, GDK_b, quickmark, { .s = "b" } },
+ { 0, GDK_q, GDK_c, quickmark, { .s = "c" } },
+ { 0, GDK_q, GDK_d, quickmark, { .s = "d" } },
+ { 0, GDK_q, GDK_e, quickmark, { .s = "e" } },
+ { 0, GDK_q, GDK_f, quickmark, { .s = "f" } },
+ { 0, GDK_q, GDK_g, quickmark, { .s = "g" } },
+ { 0, GDK_q, GDK_h, quickmark, { .s = "h" } },
+ { 0, GDK_q, GDK_i, quickmark, { .s = "i" } },
+ { 0, GDK_q, GDK_j, quickmark, { .s = "j" } },
+ { 0, GDK_q, GDK_k, quickmark, { .s = "k" } },
+ { 0, GDK_q, GDK_l, quickmark, { .s = "l" } },
+ { 0, GDK_q, GDK_m, quickmark, { .s = "m" } },
+ { 0, GDK_q, GDK_n, quickmark, { .s = "n" } },
+ { 0, GDK_q, GDK_o, quickmark, { .s = "o" } },
+ { 0, GDK_q, GDK_p, quickmark, { .s = "p" } },
+ { 0, GDK_q, GDK_q, quickmark, { .s = "q" } },
+ { 0, GDK_q, GDK_r, quickmark, { .s = "r" } },
+ { 0, GDK_q, GDK_s, quickmark, { .s = "s" } },
+ { 0, GDK_q, GDK_t, quickmark, { .s = "t" } },
+ { 0, GDK_q, GDK_u, quickmark, { .s = "u" } },
+ { 0, GDK_q, GDK_v, quickmark, { .s = "v" } },
+ { 0, GDK_q, GDK_w, quickmark, { .s = "w" } },
+ { 0, GDK_q, GDK_x, quickmark, { .s = "x" } },
+ { 0, GDK_q, GDK_y, quickmark, { .s = "y" } },
+ { 0, GDK_q, GDK_z, quickmark, { .s = "z" } },
+ { 0, GDK_q, GDK_A, quickmark, { .s = "A" } },
+ { 0, GDK_q, GDK_B, quickmark, { .s = "B" } },
+ { 0, GDK_q, GDK_C, quickmark, { .s = "C" } },
+ { 0, GDK_q, GDK_D, quickmark, { .s = "D" } },
+ { 0, GDK_q, GDK_E, quickmark, { .s = "E" } },
+ { 0, GDK_q, GDK_F, quickmark, { .s = "F" } },
+ { 0, GDK_q, GDK_G, quickmark, { .s = "G" } },
+ { 0, GDK_q, GDK_H, quickmark, { .s = "H" } },
+ { 0, GDK_q, GDK_I, quickmark, { .s = "I" } },
+ { 0, GDK_q, GDK_J, quickmark, { .s = "J" } },
+ { 0, GDK_q, GDK_K, quickmark, { .s = "K" } },
+ { 0, GDK_q, GDK_L, quickmark, { .s = "L" } },
+ { 0, GDK_q, GDK_M, quickmark, { .s = "M" } },
+ { 0, GDK_q, GDK_N, quickmark, { .s = "N" } },
+ { 0, GDK_q, GDK_O, quickmark, { .s = "O" } },
+ { 0, GDK_q, GDK_P, quickmark, { .s = "P" } },
+ { 0, GDK_q, GDK_Q, quickmark, { .s = "Q" } },
+ { 0, GDK_q, GDK_R, quickmark, { .s = "R" } },
+ { 0, GDK_q, GDK_S, quickmark, { .s = "S" } },
+ { 0, GDK_q, GDK_T, quickmark, { .s = "T" } },
+ { 0, GDK_q, GDK_U, quickmark, { .s = "U" } },
+ { 0, GDK_q, GDK_V, quickmark, { .s = "V" } },
+ { 0, GDK_q, GDK_W, quickmark, { .s = "W" } },
+ { 0, GDK_q, GDK_X, quickmark, { .s = "X" } },
+ { 0, GDK_q, GDK_Y, quickmark, { .s = "Y" } },
+ { 0, GDK_q, GDK_Z, quickmark, { .s = "Z" } },
{ 0, GDK_Q, GDK_1, quickmark, { .s = "1", .i = 1 } },
{ 0, GDK_Q, GDK_2, quickmark, { .s = "2", .i = 1 } },
{ 0, GDK_Q, GDK_3, quickmark, { .s = "3", .i = 1 } },
@@ -34,6 +87,60 @@ Key keys[] = {
{ 0, GDK_Q, GDK_7, quickmark, { .s = "7", .i = 1 } },
{ 0, GDK_Q, GDK_8, quickmark, { .s = "8", .i = 1 } },
{ 0, GDK_Q, GDK_9, quickmark, { .s = "9", .i = 1 } },
+ { 0, GDK_Q, GDK_0, quickmark, { .s = "0", .i = 1 } },
+ { 0, GDK_Q, GDK_a, quickmark, { .s = "a", .i = 1 } },
+ { 0, GDK_Q, GDK_b, quickmark, { .s = "b", .i = 1 } },
+ { 0, GDK_Q, GDK_c, quickmark, { .s = "c", .i = 1 } },
+ { 0, GDK_Q, GDK_d, quickmark, { .s = "d", .i = 1 } },
+ { 0, GDK_Q, GDK_e, quickmark, { .s = "e", .i = 1 } },
+ { 0, GDK_Q, GDK_f, quickmark, { .s = "f", .i = 1 } },
+ { 0, GDK_Q, GDK_g, quickmark, { .s = "g", .i = 1 } },
+ { 0, GDK_Q, GDK_h, quickmark, { .s = "h", .i = 1 } },
+ { 0, GDK_Q, GDK_i, quickmark, { .s = "i", .i = 1 } },
+ { 0, GDK_Q, GDK_j, quickmark, { .s = "j", .i = 1 } },
+ { 0, GDK_Q, GDK_k, quickmark, { .s = "k", .i = 1 } },
+ { 0, GDK_Q, GDK_l, quickmark, { .s = "l", .i = 1 } },
+ { 0, GDK_Q, GDK_m, quickmark, { .s = "m", .i = 1 } },
+ { 0, GDK_Q, GDK_n, quickmark, { .s = "n", .i = 1 } },
+ { 0, GDK_Q, GDK_o, quickmark, { .s = "o", .i = 1 } },
+ { 0, GDK_Q, GDK_p, quickmark, { .s = "p", .i = 1 } },
+ { 0, GDK_Q, GDK_q, quickmark, { .s = "q", .i = 1 } },
+ { 0, GDK_Q, GDK_r, quickmark, { .s = "r", .i = 1 } },
+ { 0, GDK_Q, GDK_s, quickmark, { .s = "s", .i = 1 } },
+ { 0, GDK_Q, GDK_t, quickmark, { .s = "t", .i = 1 } },
+ { 0, GDK_Q, GDK_u, quickmark, { .s = "u", .i = 1 } },
+ { 0, GDK_Q, GDK_v, quickmark, { .s = "v", .i = 1 } },
+ { 0, GDK_Q, GDK_w, quickmark, { .s = "w", .i = 1 } },
+ { 0, GDK_Q, GDK_x, quickmark, { .s = "x", .i = 1 } },
+ { 0, GDK_Q, GDK_y, quickmark, { .s = "y", .i = 1 } },
+ { 0, GDK_Q, GDK_z, quickmark, { .s = "z", .i = 1 } },
+ { 0, GDK_Q, GDK_A, quickmark, { .s = "A", .i = 1 } },
+ { 0, GDK_Q, GDK_B, quickmark, { .s = "B", .i = 1 } },
+ { 0, GDK_Q, GDK_C, quickmark, { .s = "C", .i = 1 } },
+ { 0, GDK_Q, GDK_D, quickmark, { .s = "D", .i = 1 } },
+ { 0, GDK_Q, GDK_E, quickmark, { .s = "E", .i = 1 } },
+ { 0, GDK_Q, GDK_F, quickmark, { .s = "F", .i = 1 } },
+ { 0, GDK_Q, GDK_G, quickmark, { .s = "G", .i = 1 } },
+ { 0, GDK_Q, GDK_H, quickmark, { .s = "H", .i = 1 } },
+ { 0, GDK_Q, GDK_I, quickmark, { .s = "I", .i = 1 } },
+ { 0, GDK_Q, GDK_J, quickmark, { .s = "J", .i = 1 } },
+ { 0, GDK_Q, GDK_K, quickmark, { .s = "K", .i = 1 } },
+ { 0, GDK_Q, GDK_L, quickmark, { .s = "L", .i = 1 } },
+ { 0, GDK_Q, GDK_M, quickmark, { .s = "M", .i = 1 } },
+ { 0, GDK_Q, GDK_N, quickmark, { .s = "N", .i = 1 } },
+ { 0, GDK_Q, GDK_O, quickmark, { .s = "O", .i = 1 } },
+ { 0, GDK_Q, GDK_P, quickmark, { .s = "P", .i = 1 } },
+ { 0, GDK_Q, GDK_Q, quickmark, { .s = "Q", .i = 1 } },
+ { 0, GDK_Q, GDK_R, quickmark, { .s = "R", .i = 1 } },
+ { 0, GDK_Q, GDK_S, quickmark, { .s = "S", .i = 1 } },
+ { 0, GDK_Q, GDK_T, quickmark, { .s = "T", .i = 1 } },
+ { 0, GDK_Q, GDK_U, quickmark, { .s = "U", .i = 1 } },
+ { 0, GDK_Q, GDK_V, quickmark, { .s = "V", .i = 1 } },
+ { 0, GDK_Q, GDK_W, quickmark, { .s = "W", .i = 1 } },
+ { 0, GDK_Q, GDK_X, quickmark, { .s = "X", .i = 1 } },
+ { 0, GDK_Q, GDK_Y, quickmark, { .s = "Y", .i = 1 } },
+ { 0, GDK_Q, GDK_Z, quickmark, { .s = "Z", .i = 1 } },
+
{ 0, 0, GDK_0, scroll, {ScrollJumpTo | DirectionLeft} },
{ 0, 0, GDK_dollar, scroll, {ScrollJumpTo | DirectionRight} },
{ 0, GDK_g, GDK_g, scroll, {ScrollJumpTo | DirectionTop} },
diff --git a/main.c b/main.c
index d90c4c2..7a31edd 100644
--- a/main.c
+++ b/main.c
@@ -53,8 +53,8 @@ static void webview_load_committed_cb(WebKitWebView *webview, WebKitWebFrame *fr
static void webview_load_finished_cb(WebKitWebView *webview, WebKitWebFrame *frame, gpointer user_data);
static gboolean webview_mimetype_cb(WebKitWebView *webview, WebKitWebFrame *frame, WebKitNetworkRequest *request,
char *mime_type, WebKitWebPolicyDecision *decision, gpointer user_data);
-static void webview_open_js_window_cb(WebKitWebView *temp_view, WebKitWebFrame *frame,
- WebKitNetworkRequest *request, WebKitWebNavigationAction *action,
+static void webview_open_js_window_cb(WebKitWebView *temp_view, WebKitWebFrame *frame,
+ WebKitNetworkRequest *request, WebKitWebNavigationAction *action,
WebKitWebPolicyDecision *policy, gpointer data);
static gboolean webview_new_window_cb(WebKitWebView *webview, WebKitWebFrame *frame, WebKitNetworkRequest *request,
WebKitWebNavigationAction *action, WebKitWebPolicyDecision *decision, gpointer user_data);
@@ -210,8 +210,8 @@ webview_load_finished_cb(WebKitWebView *webview, WebKitWebFrame *frame, gpointer
}
void
-webview_open_js_window_cb(WebKitWebView *temp_view, WebKitWebFrame *frame,
- WebKitNetworkRequest *request, WebKitWebNavigationAction *action,
+webview_open_js_window_cb(WebKitWebView *temp_view, WebKitWebFrame *frame,
+ WebKitNetworkRequest *request, WebKitWebNavigationAction *action,
WebKitWebPolicyDecision *policy, gpointer data) {
Arg a = { .i = TargetNew, .s = (char*)webkit_network_request_get_uri(request)};
/* open the requested window */
@@ -1541,7 +1541,7 @@ jsapi_evaluate_script(const gchar *script, gchar **value, gchar **message) {
gboolean
quickmark(const Arg *a) {
int i, b;
- b = atoi(a->s);
+ b = (int) a->s[0];
char *fn = g_strdup_printf(QUICKMARK_FILE);
FILE *fp;
fp = fopen(fn, "r");
@@ -1549,7 +1549,7 @@ quickmark(const Arg *a) {
fn = NULL;
char buf[100];
- if (fp != NULL && b < 10) {
+ if (fp != NULL && b < 128) {
for( i=0; i < b; ++i ) {
if (feof(fp)) {
break;
@@ -1562,7 +1562,7 @@ quickmark(const Arg *a) {
Arg x = { .s = buf, .i = a->i ? TargetNew : TargetCurrent };
return open_arg(&x);
} else {
- echo_message(Error, "Quickmark %d not defined", b);
+ echo_message(Error, "Quickmark %c not defined", (char) b);
return false;
}
} else { return false; }
@@ -3028,7 +3028,7 @@ handle_response_headers(SoupMessage *soup_msg, gpointer unused)
GSList *resp_cookie = NULL, *cookie_list;
SoupCookie *cookie;
SoupURI *uri = soup_message_get_uri(soup_msg);
-
+
client.net.http_status = soup_msg->status_code;
if (CookiePolicy != SOUP_COOKIE_JAR_ACCEPT_NEVER) {
cookie_list = soup_cookies_from_response(soup_msg);
diff --git a/utilities.c b/utilities.c
index 40df239..7f11c32 100644
--- a/utilities.c
+++ b/utilities.c
@@ -72,34 +72,33 @@ process_save_qmark(const char *bm, WebKitWebView *webview)
FILE *fp;
const char *filename;
const char *uri = webkit_web_view_get_uri(webview);
- char qmarks[10][101];
+ char qmarks[128][101];
char buf[100];
int i, mark, l=0;
- mark = -1;
- mark = atoi(bm);
- if ( mark < 1 || mark > 9 ) {
- echo_message(Error, "Invalid quickmark, only 1-9");
+ mark = (int) bm[0];
+ if ( mark < 1 || mark > 127 ) {
+ echo_message(Error, "Invalid quickmark (%c), only ASCII character range.", (char) mark);
return TRUE;
- }
+ }
if ( uri == NULL ) return FALSE;
- for( i=0; i < 9; ++i ) strcpy( qmarks[i], "");
+ for( i=0; i < 128; ++i ) strcpy( qmarks[i], "");
filename = g_strdup_printf(QUICKMARK_FILE);
/* get current quickmarks */
-
+
fp = fopen(filename, "r");
if (fp != NULL){
- for( i=0; i < 10; ++i ) {
+ for( i=0; i < 128; ++i ) {
if (feof(fp)) {
break;
}
fgets(buf, 100, fp);
l = 0;
while (buf[l] && l < 100 && buf[l] != '\n') {
- qmarks[i][l]=buf[l];
+ qmarks[i][l]=buf[l];
l++;
- }
+ }
qmarks[i][l]='\0';
}
fclose(fp);
@@ -110,16 +109,16 @@ process_save_qmark(const char *bm, WebKitWebView *webview)
fp = fopen(filename, "w");
g_free((gpointer *)filename);
if (fp == NULL) return FALSE;
- for( i=0; i < 10; ++i )
+ for( i=0; i < 128; ++i )
fprintf(fp, "%s\n", qmarks[i]);
fclose(fp);
- echo_message(Error, "Saved as quickmark %d: %s", mark, uri);
+ echo_message(Error, "Saved as quickmark %c: %s", (char) mark, uri);
return TRUE;
}
void
-make_keyslist(void)
+make_keyslist(void)
{
int i;
KeyList *ptr, *current;
@@ -291,7 +290,7 @@ void add_modkeys(char key)
{
unsigned int k, len;
len = strlen(client.config.modkeys );
- while (k < len ) {
+ while (k < len ) {
if (client.config.modkeys[k] == key ) return;
k++;
}
@@ -317,7 +316,7 @@ mappings(const Arg *arg) {
}
}
-int
+int
get_modkey(char key) {
switch (key) {
case '1':
@@ -376,7 +375,7 @@ process_mapping(char *keystring, int maprecord, char *cmd) {
or stuff like <M1-v>a for Mod1-v,a (strlen = 7)
*/
if (
- ((strlen(keystring) == 5 || strlen(keystring) == 6) && keystring[0] == '<' && keystring[4] == '>') ||
+ ((strlen(keystring) == 5 || strlen(keystring) == 6) && keystring[0] == '<' && keystring[4] == '>') ||
((strlen(keystring) == 6 || strlen(keystring) == 7) && keystring[0] == '<' && keystring[5] == '>')
) {
switch (toupper(keystring[1])) {
@@ -417,7 +416,7 @@ process_mapping(char *keystring, int maprecord, char *cmd) {
or stuff like a<M1-v> for a,Mod1-v (strlen == 7)
*/
if (
- (strlen(keystring) == 6 && keystring[1] == '<' && keystring[5] == '>') ||
+ (strlen(keystring) == 6 && keystring[1] == '<' && keystring[5] == '>') ||
(strlen(keystring) == 7 && keystring[1] == '<' && keystring[6] == '>')
) {
switch (toupper(keystring[2])) {
@@ -474,13 +473,13 @@ process_map_line(char *line) {
}
/* if this is reached, the mapping is not for one of the internal symbol - test for command line structure */
if (strlen(my_pair.value) > 1 && strncmp(my_pair.value, ":", 1) == 0) {
- /* The string begins with a colon, like a command line, but it's not _just_ a colon,
+ /* The string begins with a colon, like a command line, but it's not _just_ a colon,
* i.e. increasing the pointer by one will not go 'out of bounds'.
* We don't actually check that the command line after the = is valid.
* This is user responsibility, the worst case is the new mapping simply doing nothing.
* Since we will pass the command to the same function which also handles the config file lines,
* we have to strip the colon itself (a colon counts as a commented line there - like in vim).
- * Last, but not least, the second argument being < 0 signifies to the function that this is a
+ * Last, but not least, the second argument being < 0 signifies to the function that this is a
* command line mapping, not a mapping to an existing internal symbol. */
cmd = (char *)malloc(sizeof(char) * strlen(my_pair.value));
memset(cmd, 0, strlen(my_pair.value));
@@ -527,8 +526,8 @@ build_taglist(const Arg *arg, FILE *f) {
void
set_error(const char *error) {
- /* it should never happen that set_error is called more than once,
- * but to avoid any potential memory leaks, we ignore any subsequent
+ /* it should never happen that set_error is called more than once,
+ * but to avoid any potential memory leaks, we ignore any subsequent
* error if the current one has not been shown */
if (client.state.error_msg == NULL) {
client.state.error_msg = g_strdup_printf("%s", error);
@@ -637,7 +636,7 @@ add_list(const char *element, Listelement *elementlist)
if (elementlist == NULL) { /* first element */
newelement = malloc(sizeof(Listelement));
- if (newelement == NULL)
+ if (newelement == NULL)
return (elementlist);
strncpy(newelement->element, element, 254);
newelement->next = NULL;
@@ -648,7 +647,7 @@ add_list(const char *element, Listelement *elementlist)
/* check if element is already in list */
while (elementpointer != NULL) {
- if (strlen(elementpointer->element) == n &&
+ if (strlen(elementpointer->element) == n &&
strncmp(elementpointer->element, element, n) == 0)
return (elementlist);
lastelement = elementpointer;
@@ -687,7 +686,7 @@ count_list(Listelement *elementlist)
n++;
elementpointer = elementpointer->next;
}
-
+
return n;
}
@@ -781,7 +780,7 @@ read_rcfile(const char *config)
while (fgets(s, 254, fpin)) {
linum++;
/*
- * ignore lines that begin with #, / and such
+ * ignore lines that begin with #, / and such
*/
if (!isalpha(s[0]))
continue;
@@ -859,7 +858,7 @@ open_handler_pid(char *uri, GPid *child_pid) {
char *p = NULL, *arg, arg_temp[MAX_SETTING_SIZE], *temp, temp2[MAX_SETTING_SIZE] = "", *temp3;
int j;
GList *l;
- GSpawnFlags flags = G_SPAWN_SEARCH_PATH;
+ GSpawnFlags flags = G_SPAWN_SEARCH_PATH;
if (child_pid) {
flags |= G_SPAWN_DO_NOT_REAP_CHILD;
--
Matthew Carter ([email protected])
http://ahungry.com
------------------------------------------------------------------------------
_______________________________________________
Vimprobable-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vimprobable-users