Skip to content

Commit 949c470

Browse files
committed
libchafa: Move new terminal classes to backend library
This will expose API for: ChafaByteFifo ChafaParser ChafaStreamReader ChafaStreamWriter ChafaTerm
1 parent 3f98624 commit 949c470

18 files changed

+121
-33
lines changed

chafa/Makefile.am

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,41 @@ libchafa_la_LDFLAGS = $(LIBCHAFA_LDFLAGS) -no-undefined -version-info 11:0:11
1313
libchafa_la_LIBADD = $(GLIB_LIBS) internal/libchafa-internal.la -lm
1414

1515
libchafa_la_SOURCES = \
16-
chafa-canvas.c \
16+
chafa-byte-fifo.c \
1717
chafa-canvas-config.c \
18+
chafa-canvas.c \
1819
chafa-features.c \
1920
chafa-frame.c \
2021
chafa-image.c \
22+
chafa-parser.c \
2123
chafa-placement.c \
24+
chafa-stream-reader.c \
25+
chafa-stream-writer.c \
2226
chafa-symbol-map.c \
2327
chafa-term-db.c \
2428
chafa-term-info.c \
29+
chafa-term.c \
2530
chafa-util.c
2631

2732
chafaincludedir=$(includedir)/chafa
2833
chafainclude_HEADERS = \
2934
chafa.h \
30-
chafa-canvas.h \
35+
chafa-byte-fifo.h \
3136
chafa-canvas-config.h \
37+
chafa-canvas.h \
3238
chafa-common.h \
3339
chafa-features.h \
3440
chafa-frame.h \
3541
chafa-image.h \
42+
chafa-parser.h \
3643
chafa-placement.h \
44+
chafa-stream-reader.h \
45+
chafa-stream-writer.h \
3746
chafa-symbol-map.h \
3847
chafa-term-db.h \
3948
chafa-term-info.h \
4049
chafa-term-seq-def.h \
50+
chafa-term.h \
4151
chafa-util.h \
4252
chafa-version-macros.h
4353

tools/chafa/chafa-byte-fifo.c renamed to chafa/chafa-byte-fifo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include "config.h"
2121

22-
#include "chafa-byte-fifo.h"
22+
#include "chafa.h"
2323

2424
#define BUFFER_SIZE_MAX 16384
2525

tools/chafa/chafa-byte-fifo.h renamed to chafa/chafa-byte-fifo.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,38 @@
2020
#ifndef __CHAFA_BYTE_FIFO_H__
2121
#define __CHAFA_BYTE_FIFO_H__
2222

23+
#if !defined (__CHAFA_H_INSIDE__) && !defined (CHAFA_COMPILATION)
24+
# error "Only <chafa.h> can be included directly."
25+
#endif
26+
2327
#include <glib.h>
2428

2529
G_BEGIN_DECLS
2630

2731
typedef struct ChafaByteFifo ChafaByteFifo;
2832

33+
CHAFA_AVAILABLE_IN_1_20
2934
ChafaByteFifo *chafa_byte_fifo_new (void);
35+
CHAFA_AVAILABLE_IN_1_20
3036
void chafa_byte_fifo_destroy (ChafaByteFifo *byte_fifo);
3137

38+
CHAFA_AVAILABLE_IN_1_20
3239
gint64 chafa_byte_fifo_get_pos (ChafaByteFifo *byte_fifo);
40+
CHAFA_AVAILABLE_IN_1_20
3341
gint chafa_byte_fifo_get_len (ChafaByteFifo *byte_fifo);
42+
CHAFA_AVAILABLE_IN_1_20
3443
void chafa_byte_fifo_push (ChafaByteFifo *byte_fifo, gconstpointer src, gint src_len);
44+
CHAFA_AVAILABLE_IN_1_20
3545
gint chafa_byte_fifo_pop (ChafaByteFifo *byte_fifo, gpointer dest, gint dest_len);
46+
CHAFA_AVAILABLE_IN_1_20
3647
gconstpointer chafa_byte_fifo_peek (ChafaByteFifo *byte_fifo, gint *len);
48+
CHAFA_AVAILABLE_IN_1_20
3749
gint chafa_byte_fifo_drop (ChafaByteFifo *byte_fifo, gint len);
50+
CHAFA_AVAILABLE_IN_1_20
3851
gint chafa_byte_fifo_search (ChafaByteFifo *byte_fifo,
3952
gconstpointer data, gint data_len,
4053
gint64 *pos);
54+
CHAFA_AVAILABLE_IN_1_20
4155
gpointer chafa_byte_fifo_split_next (ChafaByteFifo *byte_fifo,
4256
gconstpointer separator, gint separator_len,
4357
gint64 *restart_pos, gint *len_out);

tools/chafa/chafa-parser.c renamed to chafa/chafa-parser.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include <string.h> /* memcpy, memset */
2323
#include "chafa.h"
24-
#include "chafa-parser.h"
2524

2625
struct ChafaEvent
2726
{

tools/chafa/chafa-parser.h renamed to chafa/chafa-parser.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#ifndef __CHAFA_PARSER_H__
2121
#define __CHAFA_PARSER_H__
2222

23+
#if !defined (__CHAFA_H_INSIDE__) && !defined (CHAFA_COMPILATION)
24+
# error "Only <chafa.h> can be included directly."
25+
#endif
26+
2327
#include <glib.h>
2428

2529
G_BEGIN_DECLS
@@ -35,19 +39,31 @@ ChafaEventType;
3539
typedef struct ChafaEvent ChafaEvent;
3640
typedef struct ChafaParser ChafaParser;
3741

42+
CHAFA_AVAILABLE_IN_1_20
3843
ChafaEventType chafa_event_get_type (ChafaEvent *event);
44+
CHAFA_AVAILABLE_IN_1_20
3945
gunichar chafa_event_get_unichar (ChafaEvent *event);
46+
CHAFA_AVAILABLE_IN_1_20
4047
ChafaTermSeq chafa_event_get_seq (ChafaEvent *event);
48+
CHAFA_AVAILABLE_IN_1_20
4149
gint chafa_event_get_seq_arg (ChafaEvent *event, gint n);
50+
CHAFA_AVAILABLE_IN_1_20
4251
gint chafa_event_get_n_seq_args (ChafaEvent *event);
4352

53+
CHAFA_AVAILABLE_IN_1_20
4454
ChafaParser *chafa_parser_new (ChafaTermInfo *term_info);
55+
CHAFA_AVAILABLE_IN_1_20
4556
void chafa_parser_destroy (ChafaParser *parser);
57+
CHAFA_AVAILABLE_IN_1_20
4658
void chafa_parser_init (ChafaParser *parser_out, ChafaTermInfo *term_info);
59+
CHAFA_AVAILABLE_IN_1_20
4760
void chafa_parser_deinit (ChafaParser *parser);
4861

62+
CHAFA_AVAILABLE_IN_1_20
4963
void chafa_parser_push_data (ChafaParser *parser, gconstpointer data, gint data_len);
64+
CHAFA_AVAILABLE_IN_1_20
5065
void chafa_parser_push_eof (ChafaParser *parser);
66+
CHAFA_AVAILABLE_IN_1_20
5167
ChafaEvent *chafa_parser_pop_event (ChafaParser *parser);
5268

5369
G_END_DECLS

tools/chafa/chafa-stream-reader.c renamed to chafa/chafa-stream-reader.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@
2424
#include <fcntl.h> /* open */
2525
#include <unistd.h> /* STDOUT_FILENO */
2626

27-
/* Our copy of glib's internal GWakeup */
28-
#include "chafa-wakeup.h"
29-
3027
#include "chafa.h"
31-
#include "chafa-byte-fifo.h"
32-
#include "chafa-stream-reader.h"
28+
#include "internal/chafa-wakeup.h"
3329

3430
/* Include after glib.h for G_OS_WIN32 */
3531
#ifdef G_OS_WIN32

tools/chafa/chafa-stream-reader.h renamed to chafa/chafa-stream-reader.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,43 @@
2020
#ifndef __CHAFA_STREAM_READER_H__
2121
#define __CHAFA_STREAM_READER_H__
2222

23+
#if !defined (__CHAFA_H_INSIDE__) && !defined (CHAFA_COMPILATION)
24+
# error "Only <chafa.h> can be included directly."
25+
#endif
26+
2327
#include <glib.h>
2428

2529
G_BEGIN_DECLS
2630

2731
typedef struct ChafaStreamReader ChafaStreamReader;
2832

33+
CHAFA_AVAILABLE_IN_1_20
2934
ChafaStreamReader *chafa_stream_reader_new_from_fd (gint fd);
35+
CHAFA_AVAILABLE_IN_1_20
3036
ChafaStreamReader *chafa_stream_reader_new_from_fd_full (gint fd,
3137
gconstpointer token_separator,
3238
gint token_separator_len);
39+
CHAFA_AVAILABLE_IN_1_20
3340
void chafa_stream_reader_ref (ChafaStreamReader *stream_reader);
41+
CHAFA_AVAILABLE_IN_1_20
3442
void chafa_stream_reader_unref (ChafaStreamReader *stream_reader);
3543

44+
CHAFA_AVAILABLE_IN_1_20
3645
gint chafa_stream_reader_get_fd (ChafaStreamReader *stream_reader);
46+
CHAFA_AVAILABLE_IN_1_20
3747
gboolean chafa_stream_reader_is_console (ChafaStreamReader *stream_reader);
3848

49+
CHAFA_AVAILABLE_IN_1_20
3950
gint chafa_stream_reader_read (ChafaStreamReader *stream_reader, gpointer out, gint max_len);
51+
CHAFA_AVAILABLE_IN_1_20
4052
gint chafa_stream_reader_read_token (ChafaStreamReader *stream_reader, gpointer *out, gint max_len);
4153

54+
CHAFA_AVAILABLE_IN_1_20
4255
gboolean chafa_stream_reader_wait_until (ChafaStreamReader *stream_reader, gint64 end_time_us);
56+
CHAFA_AVAILABLE_IN_1_20
4357
void chafa_stream_reader_wait (ChafaStreamReader *stream_reader, gint timeout_ms);
4458

59+
CHAFA_AVAILABLE_IN_1_20
4560
gboolean chafa_stream_reader_is_eof (ChafaStreamReader *stream_reader);
4661

4762
G_END_DECLS

tools/chafa/chafa-stream-writer.c renamed to chafa/chafa-stream-writer.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@
2525
#include <unistd.h> /* STDOUT_FILENO */
2626
#include <glib/gprintf.h> /* g_vasprintf */
2727

28-
/* Our copy of glib's internal GWakeup */
29-
#include "chafa-wakeup.h"
30-
3128
#include "chafa.h"
32-
#include "chafa-byte-fifo.h"
33-
#include "chafa-stream-writer.h"
29+
#include "internal/chafa-wakeup.h"
3430

3531
/* Include after glib.h for G_OS_WIN32 */
3632
#ifdef G_OS_WIN32

tools/chafa/chafa-stream-writer.h renamed to chafa/chafa-stream-writer.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,38 @@
2020
#ifndef __CHAFA_STREAM_WRITER_H__
2121
#define __CHAFA_STREAM_WRITER_H__
2222

23+
#if !defined (__CHAFA_H_INSIDE__) && !defined (CHAFA_COMPILATION)
24+
# error "Only <chafa.h> can be included directly."
25+
#endif
26+
2327
#include <glib.h>
2428

2529
G_BEGIN_DECLS
2630

2731
typedef struct ChafaStreamWriter ChafaStreamWriter;
2832

33+
CHAFA_AVAILABLE_IN_1_20
2934
ChafaStreamWriter *chafa_stream_writer_new_from_fd (gint fd);
35+
CHAFA_AVAILABLE_IN_1_20
3036
void chafa_stream_writer_ref (ChafaStreamWriter *stream_writer);
37+
CHAFA_AVAILABLE_IN_1_20
3138
void chafa_stream_writer_unref (ChafaStreamWriter *stream_writer);
3239

40+
CHAFA_AVAILABLE_IN_1_20
3341
gint chafa_stream_writer_get_fd (ChafaStreamWriter *stream_writer);
42+
CHAFA_AVAILABLE_IN_1_20
3443
gboolean chafa_stream_writer_is_console (ChafaStreamWriter *stream_writer);
3544

45+
CHAFA_AVAILABLE_IN_1_20
3646
gint chafa_stream_writer_get_buffer_max (ChafaStreamWriter *stream_writer);
47+
CHAFA_AVAILABLE_IN_1_20
3748
void chafa_stream_writer_set_buffer_max (ChafaStreamWriter *stream_writer, gint buf_max);
3849

50+
CHAFA_AVAILABLE_IN_1_20
3951
void chafa_stream_writer_write (ChafaStreamWriter *stream_writer, gconstpointer data, gint len);
52+
CHAFA_AVAILABLE_IN_1_20
4053
gint chafa_stream_writer_print (ChafaStreamWriter *stream_writer, const gchar *format, ...);
54+
CHAFA_AVAILABLE_IN_1_20
4155
gboolean chafa_stream_writer_flush (ChafaStreamWriter *stream_writer);
4256

4357
G_END_DECLS

tools/chafa/chafa-term.c renamed to chafa/chafa-term.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
#include <glib/gstdio.h> /* g_open, g_close */
3434

3535
#include "chafa.h"
36-
#include "chafa-byte-fifo.h"
37-
#include "chafa-stream-reader.h"
38-
#include "chafa-stream-writer.h"
39-
#include "chafa-term.h"
4036

4137
/* Include after glib.h for G_OS_WIN32 */
4238
#ifdef G_OS_WIN32

0 commit comments

Comments
 (0)