Module Name:    src
Committed By:   rillig
Date:           Mon Mar 28 20:00:29 UTC 2022

Modified Files:
        src/games/cgram: cgram.c

Log Message:
cgram: define a word as a sequence of letters, not non-whitespace

Pressing Tab or Shift+Tab now advances to the next letter that could be
substituted, it no longer stops at punctuation or digits.  Since only
letters are scrambled, these are most interesting to be edited.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/games/cgram/cgram.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/cgram/cgram.c
diff -u src/games/cgram/cgram.c:1.26 src/games/cgram/cgram.c:1.27
--- src/games/cgram/cgram.c:1.26	Fri Oct 29 11:45:39 2021
+++ src/games/cgram/cgram.c	Mon Mar 28 20:00:29 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: cgram.c,v 1.26 2021/10/29 11:45:39 nia Exp $ */
+/* $NetBSD: cgram.c,v 1.27 2022/03/28 20:00:29 rillig Exp $ */
 
 /*-
  * Copyright (c) 2013, 2021 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.c,v 1.26 2021/10/29 11:45:39 nia Exp $");
+__RCSID("$NetBSD: cgram.c,v 1.27 2022/03/28 20:00:29 rillig Exp $");
 #endif
 
 #include <assert.h>
@@ -48,12 +48,6 @@ __RCSID("$NetBSD: cgram.c,v 1.26 2021/10
 
 
 static bool
-ch_isspace(char ch)
-{
-	return isspace((unsigned char)ch) != 0;
-}
-
-static bool
 ch_islower(char ch)
 {
 	return ch >= 'a' && ch <= 'z';
@@ -451,20 +445,20 @@ go_right(void)
 static void
 go_to_prev_word(void)
 {
-	while (can_go_left() && ch_isspace(char_left_of_cursor()))
+	while (can_go_left() && !ch_isalpha(char_left_of_cursor()))
 		go_left();
 
-	while (can_go_left() && !ch_isspace(char_left_of_cursor()))
+	while (can_go_left() && ch_isalpha(char_left_of_cursor()))
 		go_left();
 }
 
 static void
 go_to_next_word(void)
 {
-	while (can_go_right() && !ch_isspace(char_at_cursor()))
+	while (can_go_right() && ch_isalpha(char_at_cursor()))
 		go_right();
 
-	while (can_go_right() && ch_isspace(char_at_cursor()))
+	while (can_go_right() && !ch_isalpha(char_at_cursor()))
 		go_right();
 }
 

Reply via email to