From: Asher Gordon <AsDaGo@posteo.net>
To: 40169@debbugs.gnu.org
Subject: bug#40169: Fix drawing the horizontal line
Date: Sun, 22 Mar 2020 23:26:16 -0400 [thread overview]
Message-ID: <87r1xjlpk7.fsf_-_@posteo.net> (raw)
In-Reply-To: <87pnd58f8t.fsf_-_@posteo.net> (Asher Gordon's message of "Sat, 21 Mar 2020 19:22:58 -0400")
[-- Attachment #1.1: Type: text/plain, Size: 114 bytes --]
Whoops! I accidentally broke drawing the horizontal line when someone
wins horizontally. Here is the patch below:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Fix drawing the horizontal line --]
[-- Type: text/x-patch, Size: 361 bytes --]
--- gomoku.el~ 2020-03-21 19:13:36.284656730 -0400
+++ gomoku.el 2020-03-22 23:11:48.313804581 -0400
@@ -1114,7 +1114,7 @@
(setq square1 (+ square1 depl))
(cond
((= dy 0) ; Horizontal
- (gomoku-move-right)
+ (forward-char 1)
(insert-char ?- (1- gomoku-square-width) t)
(delete-region (point) (progn
(skip-chars-forward " \t")
[-- Attachment #1.3: Type: text/plain, Size: 397 bytes --]
And as before, I've also attached the fixed patch so you only have to
apply one patch.
Asher
--
One picture is worth 128K words.
--------
I prefer to send and receive mail encrypted. Please send me your
public key, and if you do not have my public key, please let me
know. Thanks.
GPG fingerprint: 38F3 975C D173 4037 B397 8095 D4C9 C4FC 5460 8E68
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: Fixed patch --]
[-- Type: text/x-patch, Size: 4200 bytes --]
diff -u gomoku.el gomoku.el
--- gomoku.el 2020-03-21 19:13:36.284656730 -0400
+++ gomoku.el 2020-03-22 23:11:48.313804581 -0400
@@ -110,8 +110,8 @@
(define-key map "u" 'gomoku-move-ne) ; u
(define-key map "b" 'gomoku-move-sw) ; b
(define-key map "n" 'gomoku-move-se) ; n
- (define-key map "h" 'backward-char) ; h
- (define-key map "l" 'forward-char) ; l
+ (define-key map "h" 'gomoku-move-left) ; h
+ (define-key map "l" 'gomoku-move-right) ; l
(define-key map "j" 'gomoku-move-down) ; j
(define-key map "k" 'gomoku-move-up) ; k
@@ -119,11 +119,13 @@
(define-key map [kp-9] 'gomoku-move-ne)
(define-key map [kp-1] 'gomoku-move-sw)
(define-key map [kp-3] 'gomoku-move-se)
- (define-key map [kp-4] 'backward-char)
- (define-key map [kp-6] 'forward-char)
+ (define-key map [kp-4] 'gomoku-move-left)
+ (define-key map [kp-6] 'gomoku-move-right)
(define-key map [kp-2] 'gomoku-move-down)
(define-key map [kp-8] 'gomoku-move-up)
+ (define-key map "\C-b" 'gomoku-move-left) ; C-b
+ (define-key map "\C-f" 'gomoku-move-right) ; C-f
(define-key map "\C-n" 'gomoku-move-down) ; C-n
(define-key map "\C-p" 'gomoku-move-up) ; C-p
@@ -146,6 +148,10 @@
(define-key map [mouse-2] 'gomoku-mouse-play)
(define-key map [drag-mouse-2] 'gomoku-mouse-play)
+ (define-key map [remap backward-char] 'gomoku-move-left)
+ (define-key map [remap left-char] 'gomoku-move-left)
+ (define-key map [remap forward-char] 'gomoku-move-right)
+ (define-key map [remap right-char] 'gomoku-move-right)
(define-key map [remap previous-line] 'gomoku-move-up)
(define-key map [remap next-line] 'gomoku-move-down)
(define-key map [remap move-beginning-of-line] 'gomoku-beginning-of-line)
@@ -954,6 +960,11 @@
;; 2 instead of 1 because WINDOW-HEIGHT includes the mode line !
gomoku-square-height)))
+(defun gomoku-point-x ()
+ "Return the board column where point is."
+ (1+ (/ (- (current-column) gomoku-x-offset)
+ gomoku-square-width)))
+
(defun gomoku-point-y ()
"Return the board row where point is."
(1+ (/ (- (count-lines (point-min) (point))
@@ -1143,13 +1154,28 @@
(skip-chars-forward gomoku--intangible-chars)
(when (eobp)
(skip-chars-backward gomoku--intangible-chars)
- (forward-char -1)))
+ (gomoku-move-left)))
(skip-chars-backward gomoku--intangible-chars)
(if (bobp)
(skip-chars-forward gomoku--intangible-chars)
- (forward-char -1))))
+ (gomoku-move-left))))
(setq gomoku--last-pos (point)))
+;; forward-char and backward-char don't always move the right number
+;; of characters. Also, these functions check if you're on the edge of
+;; the screen.
+(defun gomoku-move-right ()
+ "Move point right one column on the Gomoku board."
+ (interactive)
+ (when (< (gomoku-point-x) gomoku-board-width)
+ (forward-char gomoku-square-width)))
+
+(defun gomoku-move-left ()
+ "Move point left one column on the Gomoku board."
+ (interactive)
+ (when (> (gomoku-point-x) 1)
+ (backward-char gomoku-square-width)))
+
;; previous-line and next-line don't work right with intangible newlines
(defun gomoku-move-down ()
"Move point down one row on the Gomoku board."
@@ -1171,25 +1197,25 @@
"Move point North East on the Gomoku board."
(interactive)
(gomoku-move-up)
- (forward-char))
+ (gomoku-move-right))
(defun gomoku-move-se ()
"Move point South East on the Gomoku board."
(interactive)
(gomoku-move-down)
- (forward-char))
+ (gomoku-move-right))
(defun gomoku-move-nw ()
"Move point North West on the Gomoku board."
(interactive)
(gomoku-move-up)
- (backward-char))
+ (gomoku-move-left))
(defun gomoku-move-sw ()
"Move point South West on the Gomoku board."
(interactive)
(gomoku-move-down)
- (backward-char))
+ (gomoku-move-left))
(defun gomoku-beginning-of-line ()
"Move point to first square on the Gomoku board row."
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
next prev parent reply other threads:[~2020-03-23 3:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-21 17:20 bug#40169: 26.1; gomoku.el: Fix character movement Asher Gordon
[not found] ` <handler.40169.B.15848125491336.ack@debbugs.gnu.org>
2020-03-21 19:10 ` bug#40169: Add missing keymaps Asher Gordon
2020-03-21 23:22 ` bug#40169: Fix gomoku-plot-square Asher Gordon
2020-03-23 3:26 ` Asher Gordon [this message]
2020-03-28 8:13 ` bug#40169: Fix drawing the horizontal line Eli Zaretskii
[not found] ` <87a740gw4d.fsf@>
2020-04-03 11:51 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1xjlpk7.fsf_-_@posteo.net \
--to=asdago@posteo.net \
--cc=40169@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.