From 0aa539f551560df43660943f653374b5dda35f76 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Wed, 28 Aug 2024 12:37:17 -0500 Subject: Make slots and code look nicer --- src/runscreen.sh | 37 ++++++++++++++++++++++++------------- src/screen.c | 10 ++++++---- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/runscreen.sh b/src/runscreen.sh index 1bbdc78..14dabe5 100755 --- a/src/runscreen.sh +++ b/src/runscreen.sh @@ -1,18 +1,29 @@ #!/usr/bin/env -S sh -# Stop interrupts -trap '' INT +# This file exists because I've gotten to the point where I need to open the terminal in specific dimensions +# or the thing looks bad -# Get location of script -SCRIPT_DIR="$(cd $(dirname "$0") && echo "$PWD")" -if [ -z "$SCRIPT_DIR" ]; then - printf "\033[38;2;255;0;0m\033[1m[runscreen.sh] Couldn't get location of script. Exiting...\n\033[m" 1>&2 - exit 1 -fi +main() { + # Stop interrupts + trap '' INT -# Run the thing in gnome terminal -gnome-terminal --hide-menubar --geometry=132x24 --wait -- "$SCRIPT_DIR/screen" \ - && exit $? + # Get location of script + SCRIPT_DIR="$(cd "$(dirname "$0")" && echo "$PWD")" + if [ -z "$SCRIPT_DIR" ]; then + printf "\033[38;2;255;0;0m\033[1m[runscreen.sh] Couldn't get location of script. Exiting...\n\033[m" 1>&2 + return 1 + fi -# This file exists because I've gotten to the point where I need to open the terminal in specific dimensions -# or the thing looks bad \ No newline at end of file + # Check to make sure the screen binary exists + if [ ! -x "$SCRIPT_DIR/screen" ]; then + printf "\033[38;2;255;0;0m\033[1m[runscreen.sh] Screen binary doesn't exist. Exiting...\n\033[m" 1>&2 + return 1 + fi + + # Run the thing in gnome terminal + gnome-terminal --hide-menubar --geometry=132x24 --wait -- "$SCRIPT_DIR/screen" \ + && return $? + +} + +main && exit $? \ No newline at end of file diff --git a/src/screen.c b/src/screen.c index 2f1955e..d6806ad 100644 --- a/src/screen.c +++ b/src/screen.c @@ -225,17 +225,19 @@ static int init_slotholder(struct slotholder *slots) { for(size_t i = 0; i < STATIC_ARRSIZE(slots->subslot); i++) { slots->subslot[i] = derwin(slots->slotwin, slots->sloty, slots->slotx/3, 0, slots->slotx/3 * i); - // This works but I need to figure out how to use box() because it should be nicer int mx = 0, my = 0; getmaxyx(slots->subslot[i], my, mx); - - mvwcreate_box(slots->subslot[i], 1, 1, my - 2, mx - 2, NULL); + + const int height = my - 2, width = mx - 2; + mvwcreate_box(slots->subslot[i], 1, 1, height, width, NULL); for(int j = 0; j < 3; j++) { - mvwcreate_box(slots->subslot[i], 2 + (j * ((my - 2) / 3)), ((mx - 2) / 2) - (((mx - 2) / 3) / 2), (my - 2) / 3, (mx - 2) / 3, NULL); + mvwcreate_box(slots->subslot[i], 2 + (j * (height / 3)), width / 4, height / 3, width / 2, NULL); } wnoutrefresh(slots->subslot[i]); } + + // Not getting rid of the magic numbers. SUck it return 0; } -- cgit v1.2.3