cgram: replace comments with code

No binary change.
This commit is contained in:
rillig 2023-05-10 12:30:27 +00:00
parent 33e56a937d
commit e550a84370
1 changed files with 10 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cgram.c,v 1.29 2022/06/12 14:59:44 rillig Exp $ */ /* $NetBSD: cgram.c,v 1.30 2023/05/10 12:30:27 rillig Exp $ */
/*- /*-
* Copyright (c) 2013, 2021 The NetBSD Foundation, Inc. * Copyright (c) 2013, 2021 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint) #if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: cgram.c,v 1.29 2022/06/12 14:59:44 rillig Exp $"); __RCSID("$NetBSD: cgram.c,v 1.30 2023/05/10 12:30:27 rillig Exp $");
#endif #endif
#include <assert.h> #include <assert.h>
@ -488,21 +488,22 @@ handle_key(void)
{ {
int ch = getch(); int ch = getch();
#define CTRL(letter) (letter - 64)
switch (ch) { switch (ch) {
case 1: /* ^A */ case CTRL('A'):
case KEY_BEG: case KEY_BEG:
case KEY_HOME: case KEY_HOME:
cursor_x = 0; cursor_x = 0;
break; break;
case 2: /* ^B */ case CTRL('B'):
case KEY_LEFT: case KEY_LEFT:
go_left(); go_left();
break; break;
case 5: /* ^E */ case CTRL('E'):
case KEY_END: case KEY_END:
cursor_x = cur_max_x(); cursor_x = cur_max_x();
break; break;
case 6: /* ^F */ case CTRL('F'):
case KEY_RIGHT: case KEY_RIGHT:
go_right(); go_right();
break; break;
@ -515,14 +516,14 @@ handle_key(void)
case '\n': case '\n':
go_to_next_line(); go_to_next_line();
break; break;
case 12: /* ^L */ case CTRL('L'):
clear(); clear();
break; break;
case 14: /* ^N */ case CTRL('N'):
case KEY_DOWN: case KEY_DOWN:
cursor_y++; cursor_y++;
break; break;
case 16: /* ^P */ case CTRL('P'):
case KEY_UP: case KEY_UP:
cursor_y--; cursor_y--;
break; break;