-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
64 lines (52 loc) · 1.35 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "raylib.h"
#include "vterm.h"
#include <stdio.h>
int main() {
const uint16_t width = 800;
const uint16_t height = 450;
VTerm vt;
InitWindow(width, height, "vterm");
if (!VTermInit(&vt, width, height, VTERM_MODE_MONOCHROME_TEXT_40_25))
{
return -1;
}
// SetTargetFPS(60);
SetWindowState(FLAG_WINDOW_UNDECORATED);
SetExitKey(KEY_NULL);
while (!WindowShouldClose()) {
// Handle shortcuts first
// 1 must be keydown so polling not too quick
if (IsKeyDown(KEY_LEFT_SUPER))
{
if(IsKeyPressed(KEY_EQUAL) && (IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT)))
VTermIncreaseFontSize(&vt, 1);
if (IsKeyPressed(KEY_MINUS) && (IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT)))
VTermIncreaseFontSize(&vt, -1);
}
// Input
if (!VTermSendInput(&vt))
return 1;
// Update
if (!VTermUpdate(&vt))
return 1;
// Draw
BeginDrawing();
ClearBackground(DARKGRAY);
if (!VTermDraw(&vt))
return 2;
DrawRectangle(vt.pixel_width - 100, 0, 100, 40, DARKGRAY);
DrawFPS(vt.pixel_width - 100, 0);
bool alt = VTermInAlternateBuffer(&vt);
DrawText(
(alt ? "ALT" : "MAIN"),
vt.pixel_width - 100,
20,
20,
(alt ? RED : GREEN)
);
EndDrawing();
}
// De-Initialization
CloseWindow();
return 0;
}