mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-20 19:24:53 +00:00
* Add build.zig, remove makefile, add .idea directory to .gitignore * Remove submodules, add projects directly * Remove submodules * Add projects * Rename sub/ to dep/, remove makefiles * Rewrite main.c * Remove Argoat dependency * Remove unused dependencies * Rewrite config.c * Add files * Change default fg to 8 in config.ini * Partially rewrite utils.c * Use Zig package manager * Rewrite INPUTS enum in Zig * Commit unfinished full rewrite (Zig 0.11.0) What needs to be dealt with: - Matrix animation - Authentication part - Testing on actual TTY (not just virtual console) Signed-off-by: AnErrupTion <anerruption@disroot.org> * Implement more (untested) authentication code Signed-off-by: AnErrupTion <anerruption@disroot.org> * Fix some bugs (hopefully) Signed-off-by: AnErrupTion <anerruption@disroot.org> * Try to fix some more bugs Signed-off-by: AnErrupTion <anerruption@disroot.org> * Oops, forgot to allocate hehe Signed-off-by: AnErrupTion <anerruption@disroot.org> * Changes in the Zig rewrite (#596) * Everything * make matrix.zig a bit cleaner * make long lines shorter and add changelog * vi mode * update changelog * get errors from child process and (hopefully) fix some other things * fix utmp entry * run authentication in a child process * update changelog * small code improvements * change that * clear terminal on SIGTERM * Remove LogFile * moved ini to a lib, fixed alternative langs * fix logging out * oops * code improvements * consistency * clearing the env isn't needed anymore (afaik) * replace vi_mode with a bool * type aliases, avoiding zeroes(), breaking a long line * lowercase insert/normal, merge conditionals, code improvements * Add experimental save file migrator + bug fixes + add "-dev" version suffix Signed-off-by: AnErrupTion <anerruption@disroot.org> * Resolve conflicts Signed-off-by: AnErrupTion <anerruption@disroot.org> * Clean up when SIGTERM is received (#597) * clean up child processes on SIGTERM * small code improvement * consistency.. i guess? * Properly set XDG_CURRENT_DESKTOP Signed-off-by: AnErrupTion <anerruption@disroot.org> * Zig 0.12.0 and more! (#599) * less alloc, update migrator, get DesktopNames from .desktop * small cleanup * Update zigini to improve compatibility with old config * Code improvements * Update to zig version 0.12.0 * Some fixes * tiny changes * remove useless comment * migrator changes, and small things * set XDG env vars differently * free memory on error when appending environments * Fix out of bounds issue when using the Delete key Signed-off-by: AnErrupTion <anerruption@disroot.org> * Update zig-ini to fix configuration issue (#603) * Mention display-manager-init for Gentoo/OpenRC in readme.md Signed-off-by: AnErrupTion <anerruption@disroot.org> * Tidy up readme.md Signed-off-by: AnErrupTion <anerruption@disroot.org> * Fix authentication in a few edge cases (#604) * fix loginConv and auth * fix potential mem leak with configs * BIG changes --------- Signed-off-by: AnErrupTion <anerruption@disroot.org> Co-authored-by: アシュ <120780645+Kawaii-Ash@users.noreply.github.com>
157 lines
2.3 KiB
C
157 lines
2.3 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "../termbox.h"
|
|
|
|
static const char chars[] = "nnnnnnnnnbbbbbbbbbuuuuuuuuuBBBBBBBBB";
|
|
|
|
static const uint32_t all_attrs[] =
|
|
{
|
|
0,
|
|
TB_BOLD,
|
|
TB_UNDERLINE,
|
|
TB_BOLD | TB_UNDERLINE,
|
|
};
|
|
|
|
static int next_char(int current)
|
|
{
|
|
current++;
|
|
|
|
if (!chars[current])
|
|
{
|
|
current = 0;
|
|
}
|
|
|
|
return current;
|
|
}
|
|
|
|
static void draw_line(int x, int y, uint32_t bg)
|
|
{
|
|
int a, c;
|
|
int current_char = 0;
|
|
|
|
for (a = 0; a < 4; a++)
|
|
{
|
|
for (c = TB_DEFAULT; c <= TB_WHITE; c++)
|
|
{
|
|
uint32_t fg = all_attrs[a] | c;
|
|
tb_change_cell(x, y, chars[current_char], fg, bg);
|
|
current_char = next_char(current_char);
|
|
x++;
|
|
}
|
|
}
|
|
}
|
|
|
|
static void print_combinations_table(int sx, int sy, const uint32_t* attrs,
|
|
int attrs_n)
|
|
{
|
|
int i, c;
|
|
|
|
for (i = 0; i < attrs_n; i++)
|
|
{
|
|
for (c = TB_DEFAULT; c <= TB_WHITE; c++)
|
|
{
|
|
uint32_t bg = attrs[i] | c;
|
|
draw_line(sx, sy, bg);
|
|
sy++;
|
|
}
|
|
}
|
|
}
|
|
|
|
static void draw_all()
|
|
{
|
|
tb_clear();
|
|
|
|
tb_select_output_mode(TB_OUTPUT_NORMAL);
|
|
static const uint32_t col1[] = {0, TB_BOLD};
|
|
static const uint32_t col2[] = {TB_REVERSE};
|
|
print_combinations_table(1, 1, col1, 2);
|
|
print_combinations_table(2 + strlen(chars), 1, col2, 1);
|
|
tb_present();
|
|
|
|
tb_select_output_mode(TB_OUTPUT_GRAYSCALE);
|
|
int c, x, y;
|
|
|
|
for (x = 0, y = 23; x < 24; ++x)
|
|
{
|
|
tb_change_cell(x, y, '@', x, 0);
|
|
tb_change_cell(x + 25, y, ' ', 0, x);
|
|
}
|
|
|
|
tb_present();
|
|
|
|
tb_select_output_mode(TB_OUTPUT_216);
|
|
y++;
|
|
|
|
for (c = 0, x = 0; c < 216; ++c, ++x)
|
|
{
|
|
if (!(x % 24))
|
|
{
|
|
x = 0;
|
|
++y;
|
|
}
|
|
|
|
tb_change_cell(x, y, '@', c, 0);
|
|
tb_change_cell(x + 25, y, ' ', 0, c);
|
|
}
|
|
|
|
tb_present();
|
|
|
|
tb_select_output_mode(TB_OUTPUT_256);
|
|
y++;
|
|
|
|
for (c = 0, x = 0; c < 256; ++c, ++x)
|
|
{
|
|
if (!(x % 24))
|
|
{
|
|
x = 0;
|
|
++y;
|
|
}
|
|
|
|
tb_change_cell(x, y, '+', c | ((y & 1) ? TB_UNDERLINE : 0), 0);
|
|
tb_change_cell(x + 25, y, ' ', 0, c);
|
|
}
|
|
|
|
tb_present();
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
(void)argc;
|
|
(void)argv;
|
|
int ret = tb_init();
|
|
|
|
if (ret)
|
|
{
|
|
fprintf(stderr, "tb_init() failed with error code %d\n", ret);
|
|
return 1;
|
|
}
|
|
|
|
draw_all();
|
|
|
|
struct tb_event ev;
|
|
|
|
while (tb_poll_event(&ev))
|
|
{
|
|
switch (ev.type)
|
|
{
|
|
case TB_EVENT_KEY:
|
|
switch (ev.key)
|
|
{
|
|
case TB_KEY_ESC:
|
|
goto done;
|
|
break;
|
|
}
|
|
|
|
break;
|
|
|
|
case TB_EVENT_RESIZE:
|
|
draw_all();
|
|
break;
|
|
}
|
|
}
|
|
|
|
done:
|
|
tb_shutdown();
|
|
return 0;
|
|
}
|