Skip to content

Commit 9c495b8

Browse files
committed
remove some includes and add some docs
1 parent 17193f9 commit 9c495b8

File tree

6 files changed

+55
-39
lines changed

6 files changed

+55
-39
lines changed

doc/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# doc
2+
Some documentation for yterm
3+
4+
- [config](/doc/config.md) - info on configuring yterm

doc/config.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# yterm config
2+
yterm config is stored in `~/.config/yterm`
3+
4+
All config is stored as json
5+
6+
## config.json
7+
This is the main config file for yterm, it contains these properties:
8+
- `theme`: contains the name of the theme being used
9+
10+
## Theme files
11+
Theme files are stored in `~/.config/yterm/themes`
12+
13+
They contain these colours that you can set:
14+
- `black`
15+
- `red`
16+
- `green`
17+
- `yellow`
18+
- `blue`
19+
- `magenta`
20+
- `cyan`
21+
- `white`
22+
- `grey`
23+
- `bright_red`
24+
- `bright_green`
25+
- `bright_yellow`
26+
- `bright_blue`
27+
- `bright_magenta`
28+
- `bright_cyan`
29+
- `bright_white`
30+
- `fg` (the default foreground colour)
31+
- `bg` (the default background colour)

source/components.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
#include <pwd.h>
1414
#include <fcntl.h>
1515
#include <unistd.h>
16-
#include <termios.h>
1716
#include <sys/stat.h>
1817
#include <sys/types.h>
1918
#include <sys/ioctl.h>
2019
#include <sys/select.h>
21-
#include <X11/Xlib.h>
22-
#include <X11/Xutil.h>
2320
#include <SDL2/SDL.h>
2421
#include <SDL2/SDL_ttf.h>
2522
#include <noch/json.h>

source/escapes.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -252,32 +252,7 @@ void HandleEscape(Terminal* terminal) {
252252

253253
NEXT_BYTE();
254254

255-
if (in == ']') {
256-
NEXT_BYTE();
257-
}
258-
259255
if (in != '[') {
260-
// TODO: clean up this mess
261-
NEXT_BYTE();
262-
if (in != '0') {
263-
return;
264-
}
265-
NEXT_BYTE();
266-
if (in != ';') {
267-
return;
268-
}
269-
270-
char* title = SafeMalloc(1);
271-
title[0] = 0;
272-
273-
NEXT_BYTE();
274-
while (in != 7) {
275-
title = SafeRealloc(title, strlen(title) + 2);
276-
strncat(title, &in, 1);
277-
NEXT_BYTE();
278-
}
279-
// TODO: set title
280-
free(title);
281256
return;
282257
}
283258

source/main.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ static void Usage(FILE* file) {
3131
args_usage_fprint(file, execPath, usages, ARRAY_LEN(usages), APP_DESC, true);
3232
}
3333

34-
static void ParseFlags(args_t* args) {
35-
bool flagHelp = false;
36-
bool flagVersion = false;
34+
static void ParseFlags(args_t* args, Terminal* terminal) {
35+
bool flagHelp = false;
36+
bool flagVersion = false;
37+
bool flagNoEscape = false;
3738
flag_bool("h", "help", "Show the usage", &flagHelp);
3839
flag_bool("v", "version", "Show the version", &flagVersion);
40+
flag_bool(
41+
"e", "no-escape", "Disables interpreting escape sequences", &flagNoEscape
42+
);
3943

4044
size_t where;
4145
bool extra;
@@ -60,17 +64,20 @@ static void ParseFlags(args_t* args) {
6064

6165
exit(0);
6266
}
67+
68+
if (flagNoEscape) {
69+
terminal->config.interpretEscapes = false;
70+
}
6371
}
6472

6573
int main(int argc, const char** argv, char** env) {
66-
args_t args = args_new(argc, argv);
67-
execPath = args_shift(&args);
68-
ParseFlags(&args);
69-
7074
Terminal terminal;
71-
7275
Terminal_Init(&terminal);
7376

77+
args_t args = args_new(argc, argv);
78+
execPath = args_shift(&args);
79+
ParseFlags(&args, &terminal);
80+
7481
// init video
7582
terminal.video = Video_Init();
7683
SDL_StartTextInput();

source/terminal.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ void Terminal_Update(Terminal* terminal) {
4646

4747
switch (in) {
4848
case '\x1b': {
49-
HandleEscape(terminal);
50-
break;
51-
}
49+
if (terminal->config.interpretEscapes) {
50+
HandleEscape(terminal);
51+
break;
52+
}
53+
} // fall through
5254
default: {
5355
TextScreen_PutCharacter(&terminal->buffer, in);
5456
}

0 commit comments

Comments
 (0)