Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/cgram cgram: define a word as a sequence of letters, n...



details:   https://anonhg.NetBSD.org/src/rev/46e42f8b8978
branches:  trunk
changeset: 364556:46e42f8b8978
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Mar 28 20:00:29 2022 +0000

description:
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.

diffstat:

 games/cgram/cgram.c |  18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diffs (56 lines):

diff -r cb1a1063900e -r 46e42f8b8978 games/cgram/cgram.c
--- a/games/cgram/cgram.c       Mon Mar 28 19:59:35 2022 +0000
+++ b/games/cgram/cgram.c       Mon Mar 28 20:00:29 2022 +0000
@@ -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 @@
 
 
 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 @@
 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();
 }
 



Home | Main Index | Thread Index | Old Index