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

Merve dont_move_cursor and hold_refresh into a single hold_update.

Should be set to true when many updates are being done and they don't need
to be shown as they happen.  After setting back to 0, any ciolib function
should do the full update.

Win32: The cursor doesn't move while hold_update is set.
Curses: No refresh() is called while hold_update is set.

This allows programs to be faster without compromising conio compatability.
parent f4ce29ba
No related branches found
No related tags found
No related merge requests found
...@@ -59,8 +59,7 @@ static struct text_info cio_textinfo; ...@@ -59,8 +59,7 @@ static struct text_info cio_textinfo;
static int lastmode=3; static int lastmode=3;
int _wscroll=1; int _wscroll=1;
int directvideo=0; int directvideo=0;
int dont_move_cursor=0; int hold_update=0;
int hold_refresh=0;
static int initialized=0; static int initialized=0;
int ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy); int ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy);
...@@ -713,8 +712,8 @@ int ciolib_cputs(char *str) ...@@ -713,8 +712,8 @@ int ciolib_cputs(char *str)
CIOLIB_INIT(); CIOLIB_INIT();
olddmc=dont_move_cursor; olddmc=hold_update;
dont_move_cursor=1; hold_update=1;
for(pos=0;str[pos];pos++) for(pos=0;str[pos];pos++)
{ {
ret=str[pos]; ret=str[pos];
...@@ -722,7 +721,7 @@ int ciolib_cputs(char *str) ...@@ -722,7 +721,7 @@ int ciolib_cputs(char *str)
ciolib_putch('\r'); ciolib_putch('\r');
ciolib_putch(str[pos]); ciolib_putch(str[pos]);
} }
dont_move_cursor=olddmc; hold_update=olddmc;
ciolib_gotoxy(ciolib_wherex(),ciolib_wherey()); ciolib_gotoxy(ciolib_wherex(),ciolib_wherey());
return(ret); return(ret);
} }
......
...@@ -201,8 +201,7 @@ typedef struct { ...@@ -201,8 +201,7 @@ typedef struct {
extern cioapi_t cio_api; extern cioapi_t cio_api;
extern int _wscroll; extern int _wscroll;
extern int directvideo; extern int directvideo;
extern int dont_move_cursor; extern int hold_update;
extern int hold_refresh;
#define _conio_kbhit() kbhit() #define _conio_kbhit() kbhit()
......
...@@ -890,8 +890,8 @@ char *cterm_write(unsigned char *buf, int buflen, char *retbuf, int retsize) ...@@ -890,8 +890,8 @@ char *cterm_write(unsigned char *buf, int buflen, char *retbuf, int retsize)
struct text_info ti; struct text_info ti;
int olddmc; int olddmc;
olddmc=dont_move_cursor; olddmc=hold_update;
dont_move_cursor=1; hold_update=1;
if(retbuf!=NULL) if(retbuf!=NULL)
retbuf[0]=0; retbuf[0]=0;
gettextinfo(&ti); gettextinfo(&ti);
...@@ -977,7 +977,7 @@ char *cterm_write(unsigned char *buf, int buflen, char *retbuf, int retsize) ...@@ -977,7 +977,7 @@ char *cterm_write(unsigned char *buf, int buflen, char *retbuf, int retsize)
textattr(ti.attribute); textattr(ti.attribute);
#endif #endif
dont_move_cursor=olddmc; hold_update=olddmc;
gotoxy(wherex(),wherey()); gotoxy(wherex(),wherey());
return(retbuf); return(retbuf);
} }
......
...@@ -133,7 +133,7 @@ int curs_puttext(int sx, int sy, int ex, int ey, void *fillbuf) ...@@ -133,7 +133,7 @@ int curs_puttext(int sx, int sy, int ex, int ey, void *fillbuf)
} }
textattr(orig_attr); textattr(orig_attr);
move(oldy, oldx); move(oldy, oldx);
if(!hold_refresh) if(!hold_update)
refresh(); refresh();
return(1); return(1);
} }
...@@ -633,7 +633,7 @@ int _putch(unsigned char ch, BOOL refresh_now) ...@@ -633,7 +633,7 @@ int _putch(unsigned char ch, BOOL refresh_now)
else else
ret=addch(cha); ret=addch(cha);
if(!hold_refresh) { if(!hold_update) {
if(refresh_now) if(refresh_now)
refresh(); refresh();
} }
...@@ -644,7 +644,7 @@ int _putch(unsigned char ch, BOOL refresh_now) ...@@ -644,7 +644,7 @@ int _putch(unsigned char ch, BOOL refresh_now)
void curs_gotoxy(int x, int y) void curs_gotoxy(int x, int y)
{ {
move(y-1,x-1); move(y-1,x-1);
if(!hold_refresh) if(!hold_update)
refresh(); refresh();
} }
...@@ -729,7 +729,7 @@ void curs_setcursortype(int type) { ...@@ -729,7 +729,7 @@ void curs_setcursortype(int type) {
break; break;
} }
if(!hold_refresh) if(!hold_update)
refresh(); refresh();
} }
......
...@@ -470,7 +470,7 @@ void win32_gotoxy(int x, int y) ...@@ -470,7 +470,7 @@ void win32_gotoxy(int x, int y)
ypos=y; ypos=y;
cp.X=x-1; cp.X=x-1;
cp.Y=y-1; cp.Y=y-1;
if(!dont_move_cursor) if(!hold_update)
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),cp); SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),cp);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment