Added few more functions...

This commit is contained in:
Ognjen Milan Robovic 2023-10-29 06:58:47 -04:00
parent 9b97082fe9
commit 7b6f33f39b
3 changed files with 50 additions and 19 deletions

View File

@ -12,10 +12,6 @@ static void i_left (void) { --i_x; limit (& i_x, 0, curses_screen_width - 1);
static void i_right (void) { ++i_x; limit (& i_x, 0, curses_screen_width - 1); }
int main (void) {
int i = -420;
char a [64] = "";
char b [5] = "Heyo";
curses_configure ();
curses_bind (SIGNAL_W, i_up);
@ -23,6 +19,8 @@ int main (void) {
curses_bind (SIGNAL_A, i_left);
curses_bind (SIGNAL_D, i_right);
terminal_show_cursor (0);
while (curses_active != 0) {
curses_render_background ('.', COLOUR_GREY, EFFECT_BOLD);
@ -39,10 +37,7 @@ int main (void) {
curses_synchronize ();
}
number_to_string (i, a);
printf ("%s <> ", b);
printf ("%i <> %s\n", string_length (b), string_reverse (b));
terminal_show_cursor (1);
return (EXIT_SUCCESS);
}

View File

@ -9,6 +9,8 @@ It is distributed in the hope that it will be useful or harmful, it really depen
#ifndef XURSES_SOURCE
#define XURSES_SOURCE
#include <xolatile/xtandard.c>
#include <xolatile/xurses.h>
#include <termios.h>
@ -24,10 +26,7 @@ It is distributed in the hope that it will be useful or harmful, it really depen
/* Internal variable definitions. */
static int curses_signal = SIGNAL_NONE;
static int curses_screen_width = 0;
static int curses_screen_height = 0;
static char * curses_screen = NULL;
static char * curses_screen = NULL;
static char curses_format [CURSES_FORMAT + 1] = "\033[-;3-m-\033[0m";
@ -96,7 +95,13 @@ static void curses_idle (void) {
/* External variable definitions. */
int curses_active = 1;
int curses_realign_x = 0;
int curses_realign_y = 0;
int curses_tab_width = 8;
int curses_signal = SIGNAL_NONE;
int curses_screen_width = 0;
int curses_screen_height = 0;
int curses_active = 1;
/* External function definitions. */
@ -192,19 +197,43 @@ void curses_render_background (char character, int colour, int effect) {
}
}
void curses_render_string_limit (char * string, int limit, int colour, int effect, int x, int y) {
void curses_render_string_point (char * string, int limit, int colour, int effect, int * x, int * y) {
int offset;
for (offset = 0; offset != limit; ++offset) {
if (x + offset < curses_screen_width) {
curses_render_character (string [offset], colour, effect, x + offset, y);
if (* x + offset < curses_screen_width) {
if (string [offset] == '\n') {
* x = curses_realign_x;
* y += 1;
} else if (string [offset] == '\t') {
* x += curses_tab_width;
} else {
curses_render_character (string [offset], colour, effect, * x, * y);
* x += 1;
}
} else {
curses_render_character ('+', COLOUR_GREY, EFFECT_BOLD, x + offset, y);
curses_render_character ('+', COLOUR_GREY, EFFECT_BOLD, * x, * y);
return;
}
}
}
void curses_render_number_point (int number, int limit, int colour, int effect, int * x, int * y) {
(void) number;
(void) limit;
(void) colour;
(void) effect;
(void) x;
(void) y;
return;
}
void curses_render_string_limit (char * string, int limit, int colour, int effect, int x, int y) {
int xx = x, yy = y;
curses_render_string_point (string, limit, colour, effect, & xx, & yy);
}
void curses_render_number_limit (int number, int limit, int colour, int effect, int x, int y) {
(void) number;
(void) limit;

View File

@ -9,8 +9,12 @@ It is distributed in the hope that it will be useful or harmful, it really depen
#ifndef XURSES_HEADER
#define XURSES_HEADER
#include <xolatile/xtandard.h>
extern int curses_realign_x;
extern int curses_realign_y;
extern int curses_tab_width;
extern int curses_signal;
extern int curses_screen_width;
extern int curses_screen_height;
extern int curses_active;
extern void curses_configure (void);
@ -24,6 +28,9 @@ extern void curses_render_cursor (int x, int y);
extern void curses_render_character (char character, int colour, int effect, int x, int y);
extern void curses_render_background (char character, int colour, int effect);
extern void curses_render_string_point (char * string, int limit, int colour, int effect, int * x, int * y);
extern void curses_render_number_point (int number, int limit, int colour, int effect, int * x, int * y);
extern void curses_render_string_limit (char * string, int limit, int colour, int effect, int x, int y);
extern void curses_render_number_limit (int number, int limit, int colour, int effect, int x, int y);