mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 06:46:07 +00:00
test: format C test files and fix clang-tidy warnings
It's probably not worth adding the C test files to regular formatting as they're pretty much never touched, but ensuring the files are formatted according to our standards and getting rid of warnings is a cheap one-time fix.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
for (int i=1; i<argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
printf("arg%d=%s;", i, argv[i]);
|
printf("arg%d=%s;", i, argv[i]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <Windows.h>
|
# include <Windows.h>
|
||||||
#define usleep(usecs) Sleep(usecs/1000)
|
# define usleep(usecs) Sleep(usecs/1000)
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void flush_wait(void)
|
static void flush_wait(void)
|
||||||
@@ -56,7 +57,7 @@ int main(int argc, char **argv)
|
|||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
if (strcmp(argv[1], "-t") == 0) {
|
if (strcmp(argv[1], "-t") == 0) {
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
fprintf(stderr,"Missing prompt text for -t option\n");
|
fprintf(stderr, "Missing prompt text for -t option\n");
|
||||||
return 5;
|
return 5;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s $ ", argv[2]);
|
fprintf(stderr, "%s $ ", argv[2]);
|
||||||
@@ -107,18 +108,18 @@ int main(int argc, char **argv)
|
|||||||
char cmd[100];
|
char cmd[100];
|
||||||
int arg;
|
int arg;
|
||||||
|
|
||||||
while (1) {
|
while (true) {
|
||||||
fprintf(stderr, "interact $ ");
|
fprintf(stderr, "interact $ ");
|
||||||
|
|
||||||
if (fgets(input, sizeof(input), stdin) == NULL) {
|
if (fgets(input, sizeof(input), stdin) == NULL) {
|
||||||
break; // EOF
|
break; // EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
if(1 == sscanf(input, "%99s %d", cmd, &arg)) {
|
if (1 == sscanf(input, "%99s %d", cmd, &arg)) {
|
||||||
arg = 0;
|
arg = 0;
|
||||||
}
|
}
|
||||||
if (strcmp(cmd, "exit") == 0) {
|
if (strcmp(cmd, "exit") == 0) {
|
||||||
return arg;
|
return arg;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "command not found: %s\n", cmd);
|
fprintf(stderr, "command not found: %s\n", cmd);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
/// Helper program to exit and keep stdout open (like "xclip -i -loops 1").
|
/// Helper program to exit and keep stdout open (like "xclip -i -loops 1").
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
@@ -8,7 +7,7 @@ int main(int argc, char **argv)
|
|||||||
uv_loop_t *loop = uv_default_loop();
|
uv_loop_t *loop = uv_default_loop();
|
||||||
uv_process_t child_req;
|
uv_process_t child_req;
|
||||||
|
|
||||||
char * args[3];
|
char *args[3];
|
||||||
args[0] = "sleep";
|
args[0] = "sleep";
|
||||||
args[1] = "10";
|
args[1] = "10";
|
||||||
args[2] = NULL;
|
args[2] = NULL;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "nvim/event/multiqueue.h"
|
#include <string.h>
|
||||||
|
|
||||||
#include "multiqueue.h"
|
#include "multiqueue.h"
|
||||||
|
|
||||||
|
#include "nvim/event/multiqueue.h"
|
||||||
|
|
||||||
void ut_multiqueue_put(MultiQueue *self, const char *str)
|
void ut_multiqueue_put(MultiQueue *self, const char *str)
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include "nvim/event/multiqueue.h"
|
#include "nvim/event/multiqueue.h"
|
||||||
|
|
||||||
void ut_multiqueue_put(MultiQueue *queue, const char *str);
|
void ut_multiqueue_put(MultiQueue *self, const char *str);
|
||||||
const char *ut_multiqueue_get(MultiQueue *queue);
|
const char *ut_multiqueue_get(MultiQueue *self);
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kPOSIXErrnoEINTR = EINTR,
|
kPOSIXErrnoEINTR = EINTR,
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
#include "vterm_test.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "vterm_test.h"
|
||||||
|
|
||||||
int parser_text(const char bytes[], size_t len, void *user)
|
int parser_text(const char bytes[], size_t len, void *user)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "text ");
|
fprintf(f, "text ");
|
||||||
size_t i;
|
size_t i;
|
||||||
for(i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
unsigned char b = (unsigned char)bytes[i];
|
unsigned char b = (unsigned char)bytes[i];
|
||||||
if(b < 0x20 || b == 0x7f || (b >= 0x80 && b < 0xa0)) {
|
if (b < 0x20 || b == 0x7f || (b >= 0x80 && b < 0xa0)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(f, i ? ",%x" : "%x", b);
|
fprintf(f, i ? ",%x" : "%x", b);
|
||||||
@@ -22,36 +22,37 @@ int parser_text(const char bytes[], size_t len, void *user)
|
|||||||
|
|
||||||
static void printchars(const char *s, size_t len, FILE *f)
|
static void printchars(const char *s, size_t len, FILE *f)
|
||||||
{
|
{
|
||||||
while(len--) {
|
while (len--) {
|
||||||
fprintf(f, "%c", (s++)[0]);
|
fprintf(f, "%c", (s++)[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int parser_csi(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user)
|
int parser_csi(const char *leader, const long args[], int argcount, const char *intermed,
|
||||||
|
char command, void *user)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "csi %02x", command);
|
fprintf(f, "csi %02x", command);
|
||||||
|
|
||||||
if(leader && leader[0]) {
|
if (leader && leader[0]) {
|
||||||
fprintf(f, " L=");
|
fprintf(f, " L=");
|
||||||
for(int i = 0; leader[i]; i++) {
|
for (int i = 0; leader[i]; i++) {
|
||||||
fprintf(f, "%02x", leader[i]);
|
fprintf(f, "%02x", leader[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < argcount; i++) {
|
for (int i = 0; i < argcount; i++) {
|
||||||
char sep = i ? ',' : ' ';
|
char sep = i ? ',' : ' ';
|
||||||
|
|
||||||
if(args[i] == CSI_ARG_MISSING) {
|
if (args[i] == CSI_ARG_MISSING) {
|
||||||
fprintf(f, "%c*", sep);
|
fprintf(f, "%c*", sep);
|
||||||
} else {
|
} else {
|
||||||
fprintf(f, "%c%ld%s", sep, CSI_ARG(args[i]), CSI_ARG_HAS_MORE(args[i]) ? "+" : "");
|
fprintf(f, "%c%ld%s", sep, CSI_ARG(args[i]), CSI_ARG_HAS_MORE(args[i]) ? "+" : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(intermed && intermed[0]) {
|
if (intermed && intermed[0]) {
|
||||||
fprintf(f, " I=");
|
fprintf(f, " I=");
|
||||||
for(int i = 0; intermed[i]; i++) {
|
for (int i = 0; intermed[i]; i++) {
|
||||||
fprintf(f, "%02x", intermed[i]);
|
fprintf(f, "%02x", intermed[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,8 +69,8 @@ int parser_osc(int command, VTermStringFragment frag, void *user)
|
|||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "osc ");
|
fprintf(f, "osc ");
|
||||||
|
|
||||||
if(frag.initial) {
|
if (frag.initial) {
|
||||||
if(command == -1) {
|
if (command == -1) {
|
||||||
fprintf(f, "[");
|
fprintf(f, "[");
|
||||||
} else {
|
} else {
|
||||||
fprintf(f, "[%d;", command);
|
fprintf(f, "[%d;", command);
|
||||||
@@ -78,7 +79,7 @@ int parser_osc(int command, VTermStringFragment frag, void *user)
|
|||||||
|
|
||||||
printchars(frag.str, frag.len, f);
|
printchars(frag.str, frag.len, f);
|
||||||
|
|
||||||
if(frag.final) {
|
if (frag.final) {
|
||||||
fprintf(f, "]");
|
fprintf(f, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,16 +94,16 @@ int parser_dcs(const char *command, size_t commandlen, VTermStringFragment frag,
|
|||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "dcs ");
|
fprintf(f, "dcs ");
|
||||||
|
|
||||||
if(frag.initial) {
|
if (frag.initial) {
|
||||||
fprintf(f, "[");
|
fprintf(f, "[");
|
||||||
for(size_t i = 0; i < commandlen; i++) {
|
for (size_t i = 0; i < commandlen; i++) {
|
||||||
fprintf(f, "%c", command[i]);
|
fprintf(f, "%c", command[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printchars(frag.str, frag.len,f);
|
printchars(frag.str, frag.len, f);
|
||||||
|
|
||||||
if(frag.final) {
|
if (frag.final) {
|
||||||
fprintf(f, "]");
|
fprintf(f, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,13 +118,13 @@ int parser_apc(VTermStringFragment frag, void *user)
|
|||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "apc ");
|
fprintf(f, "apc ");
|
||||||
|
|
||||||
if(frag.initial) {
|
if (frag.initial) {
|
||||||
fprintf(f, "[");
|
fprintf(f, "[");
|
||||||
}
|
}
|
||||||
|
|
||||||
printchars(frag.str, frag.len, f);
|
printchars(frag.str, frag.len, f);
|
||||||
|
|
||||||
if(frag.final) {
|
if (frag.final) {
|
||||||
fprintf(f, "]");
|
fprintf(f, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,13 +139,13 @@ int parser_pm(VTermStringFragment frag, void *user)
|
|||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "pm ");
|
fprintf(f, "pm ");
|
||||||
|
|
||||||
if(frag.initial) {
|
if (frag.initial) {
|
||||||
fprintf(f, "[");
|
fprintf(f, "[");
|
||||||
}
|
}
|
||||||
|
|
||||||
printchars(frag.str, frag.len,f);
|
printchars(frag.str, frag.len, f);
|
||||||
|
|
||||||
if(frag.final) {
|
if (frag.final) {
|
||||||
fprintf(f, "]");
|
fprintf(f, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,13 +160,13 @@ int parser_sos(VTermStringFragment frag, void *user)
|
|||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "sos ");
|
fprintf(f, "sos ");
|
||||||
|
|
||||||
if(frag.initial) {
|
if (frag.initial) {
|
||||||
fprintf(f, "[");
|
fprintf(f, "[");
|
||||||
}
|
}
|
||||||
|
|
||||||
printchars(frag.str, frag.len,f);
|
printchars(frag.str, frag.len, f);
|
||||||
|
|
||||||
if(frag.final) {
|
if (frag.final) {
|
||||||
fprintf(f, "]");
|
fprintf(f, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,14 +180,14 @@ int selection_set(VTermSelectionMask mask, VTermStringFragment frag, void *user)
|
|||||||
{
|
{
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "selection-set mask=%04X ", mask);
|
fprintf(f, "selection-set mask=%04X ", mask);
|
||||||
if(frag.initial) {
|
if (frag.initial) {
|
||||||
fprintf(f, "[");
|
fprintf(f, "[");
|
||||||
}
|
}
|
||||||
printchars(frag.str, frag.len, f);
|
printchars(frag.str, frag.len, f);
|
||||||
if(frag.final) {
|
if (frag.final) {
|
||||||
fprintf(f, "]");
|
fprintf(f, "]");
|
||||||
}
|
}
|
||||||
fprintf(f,"\n");
|
fprintf(f, "\n");
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -195,7 +196,7 @@ int selection_set(VTermSelectionMask mask, VTermStringFragment frag, void *user)
|
|||||||
int selection_query(VTermSelectionMask mask, void *user)
|
int selection_query(VTermSelectionMask mask, void *user)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f,"selection-query mask=%04X\n", mask);
|
fprintf(f, "selection-query mask=%04X\n", mask);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -204,24 +205,24 @@ int selection_query(VTermSelectionMask mask, void *user)
|
|||||||
bool want_state_putglyph;
|
bool want_state_putglyph;
|
||||||
int state_putglyph(VTermGlyphInfo *info, VTermPos pos, void *user)
|
int state_putglyph(VTermGlyphInfo *info, VTermPos pos, void *user)
|
||||||
{
|
{
|
||||||
if(!want_state_putglyph) {
|
if (!want_state_putglyph) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "putglyph ");
|
fprintf(f, "putglyph ");
|
||||||
for(int i = 0; i < VTERM_MAX_CHARS_PER_CELL && info->chars[i]; i++) {
|
for (int i = 0; i < VTERM_MAX_CHARS_PER_CELL && info->chars[i]; i++) {
|
||||||
fprintf(f, i ? ",%x" : "%x", info->chars[i]);
|
fprintf(f, i ? ",%x" : "%x", info->chars[i]);
|
||||||
}
|
}
|
||||||
fprintf(f, " %d %d,%d", info->width, pos.row, pos.col);
|
fprintf(f, " %d %d,%d", info->width, pos.row, pos.col);
|
||||||
if(info->protected_cell) {
|
if (info->protected_cell) {
|
||||||
fprintf(f, " prot");
|
fprintf(f, " prot");
|
||||||
}
|
}
|
||||||
if(info->dwl) {
|
if (info->dwl) {
|
||||||
fprintf(f, " dwl");
|
fprintf(f, " dwl");
|
||||||
}
|
}
|
||||||
if(info->dhl) {
|
if (info->dhl) {
|
||||||
fprintf(f, " dhl-%s", info->dhl == 1 ? "top" : info->dhl == 2 ? "bottom" : "?" );
|
fprintf(f, " dhl-%s", info->dhl == 1 ? "top" : info->dhl == 2 ? "bottom" : "?");
|
||||||
}
|
}
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
|
|
||||||
@@ -237,8 +238,8 @@ int state_movecursor(VTermPos pos, VTermPos oldpos, int visible, void *user)
|
|||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
state_pos = pos;
|
state_pos = pos;
|
||||||
|
|
||||||
if(want_state_movecursor) {
|
if (want_state_movecursor) {
|
||||||
fprintf(f,"movecursor %d,%d\n", pos.row, pos.col);
|
fprintf(f, "movecursor %d,%d\n", pos.row, pos.col);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@@ -248,15 +249,15 @@ int state_movecursor(VTermPos pos, VTermPos oldpos, int visible, void *user)
|
|||||||
bool want_state_scrollrect;
|
bool want_state_scrollrect;
|
||||||
int state_scrollrect(VTermRect rect, int downward, int rightward, void *user)
|
int state_scrollrect(VTermRect rect, int downward, int rightward, void *user)
|
||||||
{
|
{
|
||||||
if(!want_state_scrollrect) {
|
if (!want_state_scrollrect) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
|
|
||||||
fprintf(f,"scrollrect %d..%d,%d..%d => %+d,%+d\n",
|
fprintf(f, "scrollrect %d..%d,%d..%d => %+d,%+d\n",
|
||||||
rect.start_row, rect.end_row, rect.start_col, rect.end_col,
|
rect.start_row, rect.end_row, rect.start_col, rect.end_col,
|
||||||
downward, rightward);
|
downward, rightward);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -265,14 +266,14 @@ int state_scrollrect(VTermRect rect, int downward, int rightward, void *user)
|
|||||||
bool want_state_moverect;
|
bool want_state_moverect;
|
||||||
int state_moverect(VTermRect dest, VTermRect src, void *user)
|
int state_moverect(VTermRect dest, VTermRect src, void *user)
|
||||||
{
|
{
|
||||||
if(!want_state_moverect) {
|
if (!want_state_moverect) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f,"moverect %d..%d,%d..%d -> %d..%d,%d..%d\n",
|
fprintf(f, "moverect %d..%d,%d..%d -> %d..%d,%d..%d\n",
|
||||||
src.start_row, src.end_row, src.start_col, src.end_col,
|
src.start_row, src.end_row, src.start_col, src.end_col,
|
||||||
dest.start_row, dest.end_row, dest.start_col, dest.end_col);
|
dest.start_row, dest.end_row, dest.start_col, dest.end_col);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -282,28 +283,26 @@ void print_color(const VTermColor *col)
|
|||||||
{
|
{
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
if (VTERM_COLOR_IS_RGB(col)) {
|
if (VTERM_COLOR_IS_RGB(col)) {
|
||||||
fprintf(f,"rgb(%d,%d,%d", col->rgb.red, col->rgb.green, col->rgb.blue);
|
fprintf(f, "rgb(%d,%d,%d", col->rgb.red, col->rgb.green, col->rgb.blue);
|
||||||
}
|
} else if (VTERM_COLOR_IS_INDEXED(col)) {
|
||||||
else if (VTERM_COLOR_IS_INDEXED(col)) {
|
fprintf(f, "idx(%d", col->indexed.idx);
|
||||||
fprintf(f,"idx(%d", col->indexed.idx);
|
} else {
|
||||||
}
|
fprintf(f, "invalid(%d", col->type);
|
||||||
else {
|
|
||||||
fprintf(f,"invalid(%d", col->type);
|
|
||||||
}
|
}
|
||||||
if (VTERM_COLOR_IS_DEFAULT_FG(col)) {
|
if (VTERM_COLOR_IS_DEFAULT_FG(col)) {
|
||||||
fprintf(f,",is_default_fg");
|
fprintf(f, ",is_default_fg");
|
||||||
}
|
}
|
||||||
if (VTERM_COLOR_IS_DEFAULT_BG(col)) {
|
if (VTERM_COLOR_IS_DEFAULT_BG(col)) {
|
||||||
fprintf(f,",is_default_bg");
|
fprintf(f, ",is_default_bg");
|
||||||
}
|
}
|
||||||
fprintf(f,")");
|
fprintf(f, ")");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool want_state_settermprop;
|
bool want_state_settermprop;
|
||||||
int state_settermprop(VTermProp prop, VTermValue *val, void *user)
|
int state_settermprop(VTermProp prop, VTermValue *val, void *user)
|
||||||
{
|
{
|
||||||
if(!want_state_settermprop) {
|
if (!want_state_settermprop) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,28 +310,29 @@ int state_settermprop(VTermProp prop, VTermValue *val, void *user)
|
|||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
|
|
||||||
VTermValueType type = vterm_get_prop_type(prop);
|
VTermValueType type = vterm_get_prop_type(prop);
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case VTERM_VALUETYPE_BOOL:
|
case VTERM_VALUETYPE_BOOL:
|
||||||
fprintf(f,"settermprop %d %s\n", prop, val->boolean ? "true" : "false");
|
fprintf(f, "settermprop %d %s\n", prop, val->boolean ? "true" : "false");
|
||||||
errcode = 1;
|
errcode = 1;
|
||||||
goto end;
|
goto end;
|
||||||
case VTERM_VALUETYPE_INT:
|
case VTERM_VALUETYPE_INT:
|
||||||
fprintf(f,"settermprop %d %d\n", prop, val->number);
|
fprintf(f, "settermprop %d %d\n", prop, val->number);
|
||||||
errcode = 1;
|
errcode = 1;
|
||||||
goto end;
|
goto end;
|
||||||
case VTERM_VALUETYPE_STRING:
|
case VTERM_VALUETYPE_STRING:
|
||||||
fprintf(f,"settermprop %d %s\"%.*s\"%s\n", prop,
|
fprintf(f, "settermprop %d %s\"%.*s\"%s\n", prop,
|
||||||
val->string.initial ? "[" : "", (int)val->string.len, val->string.str, val->string.final ? "]" : "");
|
val->string.initial ? "[" : "", (int)val->string.len, val->string.str,
|
||||||
errcode=0;
|
val->string.final ? "]" : "");
|
||||||
goto end;
|
errcode = 0;
|
||||||
case VTERM_VALUETYPE_COLOR:
|
goto end;
|
||||||
fprintf(f,"settermprop %d ", prop);
|
case VTERM_VALUETYPE_COLOR:
|
||||||
print_color(&val->color);
|
fprintf(f, "settermprop %d ", prop);
|
||||||
fprintf(f,"\n");
|
print_color(&val->color);
|
||||||
errcode=1;
|
fprintf(f, "\n");
|
||||||
goto end;
|
errcode = 1;
|
||||||
case VTERM_N_VALUETYPES:
|
goto end;
|
||||||
goto end;
|
case VTERM_N_VALUETYPES:
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
@@ -343,15 +343,15 @@ end:
|
|||||||
bool want_state_erase;
|
bool want_state_erase;
|
||||||
int state_erase(VTermRect rect, int selective, void *user)
|
int state_erase(VTermRect rect, int selective, void *user)
|
||||||
{
|
{
|
||||||
if(!want_state_erase) {
|
if (!want_state_erase) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
|
|
||||||
fprintf(f,"erase %d..%d,%d..%d%s\n",
|
fprintf(f, "erase %d..%d,%d..%d%s\n",
|
||||||
rect.start_row, rect.end_row, rect.start_col, rect.end_col,
|
rect.start_row, rect.end_row, rect.start_col, rect.end_col,
|
||||||
selective ? " selective" : "");
|
selective ? " selective" : "");
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -374,7 +374,7 @@ struct {
|
|||||||
|
|
||||||
int state_setpenattr(VTermAttr attr, VTermValue *val, void *user)
|
int state_setpenattr(VTermAttr attr, VTermValue *val, void *user)
|
||||||
{
|
{
|
||||||
switch(attr) {
|
switch (attr) {
|
||||||
case VTERM_ATTR_BOLD:
|
case VTERM_ATTR_BOLD:
|
||||||
state_pen.bold = val->boolean;
|
state_pen.bold = val->boolean;
|
||||||
break;
|
break;
|
||||||
@@ -422,13 +422,14 @@ int state_setpenattr(VTermAttr attr, VTermValue *val, void *user)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool want_state_scrollback;
|
bool want_state_scrollback;
|
||||||
int state_sb_clear(void *user) {
|
int state_sb_clear(void *user)
|
||||||
if(!want_state_scrollback) {
|
{
|
||||||
|
if (!want_state_scrollback) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f,"sb_clear\n");
|
fprintf(f, "sb_clear\n");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -437,18 +438,18 @@ int state_sb_clear(void *user) {
|
|||||||
bool want_screen_scrollback;
|
bool want_screen_scrollback;
|
||||||
int screen_sb_pushline(int cols, const VTermScreenCell *cells, void *user)
|
int screen_sb_pushline(int cols, const VTermScreenCell *cells, void *user)
|
||||||
{
|
{
|
||||||
if(!want_screen_scrollback) {
|
if (!want_screen_scrollback) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int eol = cols;
|
int eol = cols;
|
||||||
while(eol && !cells[eol-1].chars[0]) {
|
while (eol && !cells[eol - 1].chars[0]) {
|
||||||
eol--;
|
eol--;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "sb_pushline %d =", cols);
|
fprintf(f, "sb_pushline %d =", cols);
|
||||||
for(int c = 0; c < eol; c++) {
|
for (int c = 0; c < eol; c++) {
|
||||||
fprintf(f, " %02X", cells[c].chars[0]);
|
fprintf(f, " %02X", cells[c].chars[0]);
|
||||||
}
|
}
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
@@ -460,13 +461,13 @@ int screen_sb_pushline(int cols, const VTermScreenCell *cells, void *user)
|
|||||||
|
|
||||||
int screen_sb_popline(int cols, VTermScreenCell *cells, void *user)
|
int screen_sb_popline(int cols, VTermScreenCell *cells, void *user)
|
||||||
{
|
{
|
||||||
if(!want_screen_scrollback) {
|
if (!want_screen_scrollback) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All lines of scrollback contain "ABCDE"
|
// All lines of scrollback contain "ABCDE"
|
||||||
for(int col = 0; col < cols; col++) {
|
for (int col = 0; col < cols; col++) {
|
||||||
if(col < 5) {
|
if (col < 5) {
|
||||||
cells[col].chars[0] = (uint32_t)('A' + col);
|
cells[col].chars[0] = (uint32_t)('A' + col);
|
||||||
} else {
|
} else {
|
||||||
cells[col].chars[0] = 0;
|
cells[col].chars[0] = 0;
|
||||||
@@ -476,14 +477,14 @@ int screen_sb_popline(int cols, VTermScreenCell *cells, void *user)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f,"sb_popline %d\n", cols);
|
fprintf(f, "sb_popline %d\n", cols);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int screen_sb_clear(void *user)
|
int screen_sb_clear(void *user)
|
||||||
{
|
{
|
||||||
if(!want_screen_scrollback) {
|
if (!want_screen_scrollback) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,8 +498,8 @@ void term_output(const char *s, size_t len, void *user)
|
|||||||
{
|
{
|
||||||
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
FILE *f = fopen(VTERM_TEST_FILE, "a");
|
||||||
fprintf(f, "output ");
|
fprintf(f, "output ");
|
||||||
for(size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
fprintf(f, "%x%s", (unsigned char)s[i], i < len-1 ? "," : "\n");
|
fprintf(f, "%x%s", (unsigned char)s[i], i < len - 1 ? "," : "\n");
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,8 @@
|
|||||||
#include "vterm/vterm.h"
|
#include "vterm/vterm.h"
|
||||||
|
|
||||||
int parser_text(const char bytes[], size_t len, void *user);
|
int parser_text(const char bytes[], size_t len, void *user);
|
||||||
int parser_csi(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user);
|
int parser_csi(const char *leader, const long args[], int argcount, const char *intermed,
|
||||||
|
char command, void *user);
|
||||||
int parser_osc(int command, VTermStringFragment frag, void *user);
|
int parser_osc(int command, VTermStringFragment frag, void *user);
|
||||||
int parser_dcs(const char *command, size_t commandlen, VTermStringFragment frag, void *user);
|
int parser_dcs(const char *command, size_t commandlen, VTermStringFragment frag, void *user);
|
||||||
int parser_apc(VTermStringFragment frag, void *user);
|
int parser_apc(VTermStringFragment frag, void *user);
|
||||||
|
Reference in New Issue
Block a user