Skip to content

Commit

Permalink
Port ncurses 6.1 compatibility fix from termbox-go.
Browse files Browse the repository at this point in the history
  • Loading branch information
nsf authored and nullgemm committed Aug 26, 2018
1 parent 2d9beff commit 17ca055
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/term.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ static char *load_terminfo(void) {
}

#define TI_MAGIC 0432
#define TI_ALT_MAGIC 542
#define TI_HEADER_LENGTH 12
#define TB_KEYS_NUM 22

Expand Down Expand Up @@ -245,13 +246,16 @@ int init_term(void) {
}

int16_t *header = (int16_t*)data;

const int number_sec_len = header[0] == TI_ALT_MAGIC ? 4 : 2;

if ((header[1] + header[2]) % 2) {
// old quirk to align everything on word boundaries
header[2] += 1;
}

const int str_offset = TI_HEADER_LENGTH +
header[1] + header[2] + 2 * header[3];
header[1] + header[2] + number_sec_len * header[3];
const int table_offset = str_offset + 2 * header[4];

keys = malloc(sizeof(const char*) * TB_KEYS_NUM);
Expand Down

0 comments on commit 17ca055

Please sign in to comment.