Small tweaks before switching to SDL2

This commit is contained in:
Joseph Ferano 2023-10-27 16:54:44 +07:00
parent 763ba92b86
commit 59473a4958
2 changed files with 33 additions and 6 deletions

11
bt.c
View File

@ -4,7 +4,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <pty.h> #include <pty.h>
#include <ctype.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
@ -35,7 +34,7 @@ void spawn(file_descriptors *fds) {
dup2(fds->child, 1); dup2(fds->child, 1);
dup2(fds->child, 2); dup2(fds->child, 2);
execle("/bin/dash", "-/bin/dash", (char *)NULL, (char *[]){ "TERM=dumb", NULL }); execle("/bin/bash", "-/bin/bash", (char *)NULL, (char *[]){ "TERM=dumb", NULL });
} else { } else {
close(fds->child); close(fds->child);
} }
@ -43,15 +42,15 @@ void spawn(file_descriptors *fds) {
static float fontsize = 12; static float fontsize = 12;
Font *load_font() { Font *load_font(void) {
unsigned int file_size = 0; unsigned int file_size = 0;
char *font = "./fira.ttf"; char *font = "./fira.ttf";
unsigned char *fontdata = LoadFileData(font, &file_size); unsigned char *fontdata = LoadFileData(font, &file_size);
Font *fontDefault = calloc(1, sizeof(Font)); Font *fontDefault = calloc(1, sizeof(Font));
fontDefault->baseSize = fontsize; fontDefault->baseSize = (int)fontsize;
fontDefault->glyphCount = 95; fontDefault->glyphCount = 95;
fontDefault->glyphs = LoadFontData(fontdata, file_size, 16, 0, 95, FONT_DEFAULT); fontDefault->glyphs = LoadFontData(fontdata, (int)file_size, 16, 0, 95, FONT_DEFAULT);
Image atlas = GenImageFontAtlas(fontDefault->glyphs, &fontDefault->recs, 95, 16, 4, 0); Image atlas = GenImageFontAtlas(fontDefault->glyphs, &fontDefault->recs, 95, 16, 4, 0);
fontDefault->texture = LoadTextureFromImage(atlas); fontDefault->texture = LoadTextureFromImage(atlas);
UnloadImage(atlas); UnloadImage(atlas);
@ -130,7 +129,7 @@ int main(void) {
sb.height = MeasureTextEx(*fontDefault, sb.buf, fontsize, 1).y; sb.height = MeasureTextEx(*fontDefault, sb.buf, fontsize, 1).y;
if (new_read || new_char) { if (new_read || new_char) {
if (sb.height - abs((int)sb.ypos) + fontsize > screenHeight) { if (sb.height - (float)abs((int)sb.ypos) + fontsize > (float)screenHeight) {
sb.ypos = -(sb.height - screenHeight) - fontsize; sb.ypos = -(sb.height - screenHeight) - fontsize;
} }
new_read = false; new_read = false;

28
project.todo Normal file
View File

@ -0,0 +1,28 @@
#-*- mode: org -*-
#+TODO: BLOCKED TODO INPROGRESS | DONE BACKLOG
#+STARTUP: overview
* DONE Render with Raylib
* DONE Load custom Mono font
* DONE Render input from user
* DONE Do not block Raylib so we can loop while reading
* DONE Create scrollback struct
* DONE Scrolling the scrollback buffer
* DONE Auto-scrolling
* DONE Render scrollback by rows
* DONE Handle color escape sequences
* TODO Backspace and Return aren't repeating [[https://github.com/raysan5/raylib/issues/2041][Issue Here]]
* TODO Switch to SDL2
* TODO Only draw scrollback that is visible
* TODO Improve the scrolling to match first and last lines
* TODO Handle unicode characters
* TODO Handle canonical and raw commands
* TODO Mouse copy/paste
* TODO Manually control when raylib updates/draws
* TODO Create basic vertical splits
* COMMENT Local variables
;; Local Variables:
;; eval: (olivetti-mode t)
;; End: