Skip to content
Snippets Groups Projects
Commit 6d5b10fe authored by deuce's avatar deuce
Browse files

Always allocate enough stoage in the lines array for a full screen

(Two new macros CONSOLE_MAX_COLS and CONSOLE_MAX_ROWS)
Don't change mode or beep if events are pending.
parent 8e3c4bf7
No related branches found
No related tags found
No related merge requests found
...@@ -114,6 +114,9 @@ ...@@ -114,6 +114,9 @@
#include "mouse.h" #include "mouse.h"
#include "vgafont.h" #include "vgafont.h"
#define CONSOLE_MAX_ROWS 256
#define CONSOLE_MAX_COLS 256
/* Console definition variables */ /* Console definition variables */
int console_new_mode=NO_NEW_MODE; int console_new_mode=NO_NEW_MODE;
int CurrMode; int CurrMode;
...@@ -502,28 +505,16 @@ void ...@@ -502,28 +505,16 @@ void
get_lines() get_lines()
{ {
int i; int i;
TextLine *newlines;
if (lines == NULL) { if (lines == NULL) {
lines = (TextLine *)malloc(sizeof(TextLine) * (DpyRows+1)); lines = (TextLine *)malloc(sizeof(TextLine) * (CONSOLE_MAX_ROWS+1));
if (lines == NULL)
err(1, "Could not allocate data structure for text lines\n");
for (i = 0; i < (DpyRows+1); ++i) {
lines[i].max_length = DpyCols;
lines[i].data = (WORD *)malloc(DpyCols * sizeof(WORD));
if (lines[i].data == NULL)
err(1, "Could not allocate data structure for text lines\n");
lines[i].changed = 1;
}
} else {
lines = (TextLine *)realloc(lines, sizeof(TextLine) * (DpyRows+1));
if (lines == NULL) if (lines == NULL)
err(1, "Could not allocate data structure for text lines\n"); err(1, "Could not allocate data structure for text lines\n");
for (i = 0; i < (DpyRows+1); ++i) { for (i = 0; i < (CONSOLE_MAX_ROWS+1); ++i) {
lines[i].max_length = DpyCols; lines[i].max_length = DpyCols;
lines[i].data = (WORD *)realloc(lines[i].data, lines[i].data = (WORD *)malloc(CONSOLE_MAX_COLS * sizeof(WORD));
DpyCols * sizeof(WORD));
if (lines[i].data == NULL) if (lines[i].data == NULL)
err(1, "Could not allocate data structure for text lines\n"); err(1, "Could not allocate data structure for text lines\n");
lines[i].changed = 1; lines[i].changed = 1;
...@@ -934,13 +925,6 @@ video_async_event(void *crap) ...@@ -934,13 +925,6 @@ video_async_event(void *crap)
for (;;) { for (;;) {
video_update(); video_update();
if(console_new_mode!=NO_NEW_MODE)
init_mode(console_new_mode);
while(!sem_trywait(&x11_beep))
x11.XBell(dpy, 0);
if(!sem_trywait(&x11_title))
x11.XStoreName(dpy, win, window_title);
tv.tv_sec=0; tv.tv_sec=0;
tv.tv_usec=54925; tv.tv_usec=54925;
/* /*
...@@ -967,6 +951,12 @@ video_async_event(void *crap) ...@@ -967,6 +951,12 @@ video_async_event(void *crap)
perror("select"); perror("select");
break; break;
case 0: case 0:
if(console_new_mode!=NO_NEW_MODE)
init_mode(console_new_mode);
while(!sem_trywait(&x11_beep))
x11.XBell(dpy, 0);
if(!sem_trywait(&x11_title))
x11.XStoreName(dpy, win, window_title);
break; break;
default: default:
if (FD_ISSET(xfd, &fdset)) { if (FD_ISSET(xfd, &fdset)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment