Misc update.

This commit is contained in:
CismonX 2020-12-15 20:49:45 +08:00
parent b4b456db66
commit f646b2d9de
Signed by: cismonx
GPG Key ID: 3094873E29A482FB
6 changed files with 19 additions and 26 deletions

4
.gitattributes vendored
View File

@ -7,6 +7,6 @@
#
# Attributes for GitHub Linguist
*.h linguist-language=c
*.h linguist-language=c
configure.ac linguist-detectable=false
Makefile.am linguist-detectable=false
Makefile.am linguist-detectable=false

3
.gitignore vendored
View File

@ -9,7 +9,8 @@
# IDE & plugins
.idea/
.vscode/
.ccls*
.ccls-cache/
.ccls
# OSX stuff
.DS_Store

View File

@ -193,12 +193,13 @@ sixdraw_prepare(struct sixdraw_ctx *ctx)
}
// Set terminal to noncanonical mode
struct termios termios;
if (tcgetattr(ctx->in_fd, &ctx->termios) != 0) {
sixdraw_print_error(ctx, "failed to get terminal attributes");
return false;
}
termios = ctx->termios;
struct termios termios = ctx->termios;
termios.c_cc[VMIN] = 0;
termios.c_cc[VTIME] = 0;
termios.c_lflag &= ~(ICANON | ISIG | ECHO);
if (tcsetattr(ctx->in_fd, TCSANOW, &termios) != 0) {
sixdraw_print_error(ctx, "failed to get terminal attributes");

View File

@ -1,22 +1,13 @@
##
## Copyright (C) 2020 CismonX <admin@cismon.net>
##
## This file is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This file is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this file. If not, see <https://www.gnu.org/licenses/>.
##
#
# Copyright (C) 2020 CismonX <admin@cismon.net>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty, provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.
#
lib_LTLIBRARIES = libctlseqs.la
libctlseqs_la_SOURCES = ctlseqs.c
libctlseqs_la_LDFLAGS = -version-info ${CTLSEQS_LT_VERSION}
libctlseqs_la_LDFLAGS = -version-info $(CTLSEQS_LT_VERSION)
include_HEADERS = ctlseqs.h

View File

@ -521,13 +521,11 @@ ctlseqs_read(struct ctlseqs_reader *reader, struct ctlseqs_matcher const *matche
void
ctlseqs_purge(struct ctlseqs_reader *reader, size_t nbytes)
{
size_t bufsize = reader->buf_end - reader->buf_start;
nbytes = nbytes > bufsize ? bufsize : nbytes;
if (nbytes == 0) {
if (CTLSEQS_UNLIKELY(nbytes == 0)) {
return;
}
reader->buf_start += nbytes;
if (reader->buf_start == reader->buf_end) {
if (reader->buf_start >= reader->buf_end) {
reader->buf_start = 0;
reader->buf_end = 0;
}

View File

@ -359,6 +359,8 @@ main(int argc, char **argv)
return 1;
}
struct termios new_termios = old_termios;
new_termios.c_cc[VMIN] = 0;
new_termios.c_cc[VTIME] = 0;
new_termios.c_lflag &= ~(ICANON | ISIG | ECHO);
if (tcsetattr(STDIN_FILENO, TCSANOW, &new_termios) != 0) {
print_error(&ctx, "failed to set terminal attributes");