Adding an example
This commit is contained in:
parent
88ae83937d
commit
fbd47333ed
2
Makefile
2
Makefile
|
@ -14,7 +14,7 @@ LINKERNAME = lib$(NAME).so
|
|||
SONAME = $(LINKERNAME).$(VERSION)
|
||||
REALNAME = $(SONAME).$(MINOR).$(RELEASE)
|
||||
|
||||
SRC = src/lw_terminal.c src/lw_terminal_vt100.c src/hl_vt100.c
|
||||
SRC = src/lw_terminal_parser.c src/lw_terminal_vt100.c src/hl_vt100.c
|
||||
SRC_TEST = src/test.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
OBJ_TEST = $(SRC_TEST:.c=.o)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
##
|
||||
## Makefile for lw_vt100 examples
|
||||
##
|
||||
## Made by julien palard <vt100@mandark.fr>
|
||||
##
|
||||
|
||||
NAME = parser
|
||||
|
||||
SRC = parser.c ../src/lw_terminal_parser.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
CC = gcc
|
||||
INCLUDE = ../src
|
||||
DEFINE = _GNU_SOURCE
|
||||
CFLAGS = -g3 -Wextra -Wstrict-prototypes -Wall -ansi -pedantic -I$(INCLUDE)
|
||||
LIB = -lutil
|
||||
RM = rm -f
|
||||
|
||||
$(NAME): $(OBJ)
|
||||
$(CC) $(OBJ) $(LIB) -o $(NAME)
|
||||
|
||||
all:
|
||||
@make $(NAME)
|
||||
|
||||
.c.o:
|
||||
$(CC) -D $(DEFINE) -c $(CFLAGS) $< -o $(<:.c=.o)
|
||||
|
||||
clean:
|
||||
$(RM) $(NAME) *~ \#*\# *.o *core
|
||||
|
||||
re: clean all
|
||||
|
||||
check-syntax:
|
||||
gcc -Isrc -Wall -Wextra -ansi -pedantic -o /dev/null -S ${CHK_SOURCES}
|
|
@ -0,0 +1,33 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "../src/lw_terminal_parser.h"
|
||||
|
||||
static void vt100_write(struct lw_terminal *term_emul __attribute__((unused)),
|
||||
char c)
|
||||
{
|
||||
printf("Got a char : %c\n", c);
|
||||
}
|
||||
|
||||
static void csi_f(struct lw_terminal *term_emul)
|
||||
{
|
||||
printf("\\033[...f with %d parameters\n", term_emul->argc);
|
||||
}
|
||||
|
||||
static void csi_K(struct lw_terminal *term_emul)
|
||||
{
|
||||
printf("\\033[...K with %d parameters\n", term_emul->argc);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct lw_terminal *lw_terminal;
|
||||
|
||||
lw_terminal = lw_terminal_init();
|
||||
if (lw_terminal == NULL)
|
||||
return EXIT_FAILURE;
|
||||
lw_terminal->write = vt100_write;
|
||||
lw_terminal->callbacks.csi.f = csi_f;
|
||||
lw_terminal->callbacks.csi.K = csi_K;
|
||||
lw_terminal_read_str(lw_terminal, "\033[2KHello world !\033[f");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "lw_terminal.h"
|
||||
#include "lw_terminal_parser.h"
|
||||
|
||||
static void lw_terminal_push(struct lw_terminal *this, char c)
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __LW_TERMINAL_VT100_H__
|
||||
#define __LW_TERMINAL_VT100_H__
|
||||
|
||||
#include "lw_terminal.h"
|
||||
#include "lw_terminal_parser.h"
|
||||
|
||||
/*
|
||||
* Source : http://vt100.net/docs/vt100-ug/chapter3.html
|
||||
|
|
Loading…
Reference in New Issue