From: Daniel Carl Date: Tue, 3 Jun 2014 13:45:36 +0000 (+0200) Subject: Moved char related macro to ascii.h. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=27cdc34ce285194b91876e9636c4428300a394ca;p=vimb.git Moved char related macro to ascii.h. --- diff --git a/src/ascii.h b/src/ascii.h index 9180a80..928e128 100644 --- a/src/ascii.h +++ b/src/ascii.h @@ -42,22 +42,22 @@ #define SC VB_SPACE|VB_CTRL #define PI VB_PUNKT|VB_IDENT static const unsigned char chartable[256] = { - C, C, C, C, C, C, C, C, C, SC, SC, C, SC, SC, C, C, - C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, - S, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, - D, D, D, D, D, D, D, D, D, D, P, P, P, P, P, P, - PI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, - UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, P, P, P, P, PI, - P, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, - LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, P, P, P, P, C, - P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, - P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, - P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, - P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, - P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, - P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, - P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, - P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P +/* 0x00-0x0f */ C, C, C, C, C, C, C, C, C, SC, SC, C, SC, SC, C, C, +/* 0x10-0x1f */ C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, +/* 0x20-0x2f */ S, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, +/* 0x30-0x3f */ D, D, D, D, D, D, D, D, D, D, P, P, P, P, P, P, +/* 0x40-0x4f */ PI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, +/* 0x50-0x5f */ UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, UI, P, P, P, P, PI, +/* 0x60-0x6f */ P, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, +/* 0x70-0x7f */ LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, LI, P, P, P, P, C, +/* 0x80-0x8f */ P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, +/* 0x90-0x9f */ P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, +/* 0xa0-0xaf */ P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, +/* 0xb0-0xbf */ P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, +/* 0xc0-0xcf */ P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, +/* 0xd0-0xdf */ P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, +/* 0xe0-0xef */ P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, +/* 0xf0-0xff */ P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P }; #undef U #undef L @@ -85,6 +85,10 @@ static const unsigned char chartable[256] = { #define CSI 0x80 #define CSI_STR "\x80" +/* check if the char c is a char with CTRL like ^C */ +#define IS_CTRL(c) (((unsigned char)c) <= 0x1f) +#define CTRL(c) ((c) ^ 0x40) + #define IS_SPECIAL(c) (c < 0) #define TERMCAP2KEY(a, b) (-((a) + ((int)(b) << 8))) diff --git a/src/ex.c b/src/ex.c index 0dd3fc4..a4fa0f1 100644 --- a/src/ex.c +++ b/src/ex.c @@ -21,8 +21,8 @@ * This file contains function to handle input editing, parsing of called ex * commands from inputbox and the ex commands. */ -#include #include "config.h" +#include #include "main.h" #include "ex.h" #include "ascii.h" diff --git a/src/input.c b/src/input.c index 9ae2a52..56f135c 100644 --- a/src/input.c +++ b/src/input.c @@ -24,6 +24,7 @@ #include "input.h" #include "dom.h" #include "util.h" +#include "ascii.h" typedef struct { char *file; diff --git a/src/main.h b/src/main.h index 553f23a..d9d061c 100644 --- a/src/main.h +++ b/src/main.h @@ -42,10 +42,6 @@ #define LENGTH(x) (sizeof x / sizeof x[0]) -#define CTRL(x) ((x) ^ 0x40) -/* check if the char x is a char with CTRL like ^C */ -#define IS_CTRL(x) (((guchar)x) <= 0x1f) - #define FLOCK(fd, cmd) { \ struct flock lock = {.l_type=cmd,.l_start=0,.l_whence=SEEK_SET,.l_len=0}; \ fcntl(fd, F_SETLK, lock); \ diff --git a/src/map.c b/src/map.c index 5f538a0..f04cceb 100644 --- a/src/map.c +++ b/src/map.c @@ -507,13 +507,11 @@ static char *convert_keys(char *in, int inlen, int *len) if (symlen == 5 && p[2] == '-') { /* is it a */ if (p[1] == 'C') { - /* TODO add macro to check if the char is a upper or lower - * with these ranges */ - if (p[3] >= 0x41 && p[3] <= 0x5d) { + if (VB_IS_UPPER(p[3])) { ch[0] = p[3] - 0x40; raw = ch; rawlen = 1; - } else if (p[3] >= 0x61 && p[3] <= 0x7a) { + } else if (VB_IS_LOWER(p[3])) { ch[0] = p[3] - 0x60; raw = ch; rawlen = 1; diff --git a/src/mode.c b/src/mode.c index b33d933..7d6d074 100644 --- a/src/mode.c +++ b/src/mode.c @@ -21,6 +21,7 @@ #include "main.h" #include "mode.h" #include "normal.h" +#include "ascii.h" static GHashTable *modes = NULL; extern VbCore vb; diff --git a/src/pass.c b/src/pass.c index 8e06b92..4fb62ec 100644 --- a/src/pass.c +++ b/src/pass.c @@ -22,6 +22,7 @@ #include "pass.h" #include "mode.h" #include "dom.h" +#include "ascii.h" extern VbCore vb;