Bladeren bron

Cleaned few bugs and added carrige return plus line feed...

master
Ognjen Milan Robovic 8 maanden geleden
bovenliggende
commit
2363b859e1
2 gewijzigde bestanden met toevoegingen van 16 en 7 verwijderingen
  1. +15
    -7
      xurses.c
  2. +1
    -0
      xurses.h

+ 15
- 7
xurses.c Bestand weergeven

@@ -27,10 +27,10 @@ struct termios curses_old_terminal;
struct termios curses_new_terminal;

void curses_initialize (void) {
char key;

struct winsize screen_dimension;

char i = 0;

fatal_failure (ioctl (STDOUT_FILENO, TIOCGWINSZ, & screen_dimension) == -1, "ioctl: Failed to get terminal dimensions.");

curses_screen_width = (int) screen_dimension.ws_col;
@@ -50,13 +50,19 @@ void curses_initialize (void) {

fatal_failure (tcsetattr (STDIN_FILENO, TCSAFLUSH, & curses_new_terminal) == -1, "tcsetattr: Failed to set reverse terminal attributes.");

curses_screen = allocate (CURSES_OFFSET + CURSES_LENGTH * curses_screen_width * curses_screen_height + 1);
curses_screen = allocate (CURSES_OFFSET + CURSES_LENGTH * curses_screen_width * curses_screen_height + (curses_screen_height - 1) * CURSES_RETURN + 1);

for (key = ' '; key != '~'; ++key) {
curses_unbind (key);
for (i = ' '; i != '~'; ++i) {
curses_unbind ((char) i);
}

terminal_clear ();

curses_screen_offset ();

for (i = 0; i != curses_screen_height - 1; ++i) {
string_copy_limit (& curses_screen [CURSES_LENGTH * curses_screen_width * i + CURSES_OFFSET], "\r\n", string_length ("\r\n"));
}
}

void curses_deinitialize (void) {
@@ -69,8 +75,10 @@ void curses_deinitialize (void) {

void curses_synchronize (void) {
curses_signal = '\0';
/*
out (curses_screen, curses_screen_size);
*/
out (curses_screen, CURSES_OFFSET + CURSES_LENGTH * curses_screen_width * curses_screen_height);

in (& curses_signal, 1);

@@ -92,7 +100,7 @@ char * curses_screen_position (int x, int y) {
fatal_failure (x >= curses_screen_width, "curses_screen_position: X position is beyond the upper bound.");
fatal_failure (y >= curses_screen_height, "curses_screen_position: Y position is beyond the upper bound.");

return (& curses_screen [CURSES_LENGTH * (y * curses_screen_width + x) + CURSES_OFFSET]);
return (& curses_screen [CURSES_LENGTH * (y * curses_screen_width + x) + y * CURSES_RETURN + CURSES_OFFSET]);
}

char * curses_format_character (char character, int colour, int effect) {


+ 1
- 0
xurses.h Bestand weergeven

@@ -19,6 +19,7 @@

#define CURSES_LENGTH ((int) sizeof ("\033[-;3-m-\033[0m") - 1)
#define CURSES_OFFSET ((int) sizeof ("\033[H") - 1)
#define CURSES_RETURN ((int) sizeof ("\r\n") - 1)

extern int curses_active;
extern int curses_cursor;


Laden…
Annuleren
Opslaan