1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-04 04:50:22 +00:00

Fix glut-calling commands, make IDE use _BLINEINPUT for '$includes (for Steve).

Glut commands _SCREENX, _SCREENY, _SCREENMOVE, _DESKTOPHEIGHT, _DESKTOPWIDTH,
_SCREENICON now wait for the screen to be created before trying to work.
Change to QB64.bas source to use _BLINEINPUT instead of LINE INPUT for INCLUDE$.
This should make the IDE much more responsive when Includes are used from now on.
This commit is contained in:
Luke Ceddia 2014-07-24 19:24:00 +10:00
parent 83681345b2
commit c460dbb808
7 changed files with 98 additions and 34 deletions

View file

@ -14,28 +14,90 @@ void sub__getinput(int32 filehandle, qbs *deststr) {
eol = qbs_new_txt_len("\n", 1);
int64 start_byte = func_seek(filehandle);
if (start_byte + filebuf_size > func_lof(filehandle)) filebuf_size = func_lof(filehandle) - start_byte;
if (start_byte > func_lof(filehandle)) {
int64 filelength = func_lof(filehandle);
if (start_byte > filelength) {
error(62);//input past end of file
return;
}
qbs *buffer = qbs_new(filebuf_size, 0);
qbs_set(deststr, qbs_new_txt_len("", 0));
do {
sub_get2(filehandle, start_byte, buffer, 1);
if (start_byte + filebuf_size > filelength) filebuf_size = filelength - start_byte + 1;
qbs_set(buffer,func_space(qbr(filebuf_size)));
sub_get2(filehandle, start_byte, buffer, 1);
int32 eol_pos = func_instr(0, buffer, eol, 0);
if (eol_pos == 0) {
start_byte += filebuf_size;
qbs_set(deststr, qbs_add(deststr, buffer));
}
if ((start_byte + filebuf_size)>=filelength) {
qbs_set(deststr, buffer);
gfs_setpos(fileno,filelength); //set the position right before the EOF marker
gfs_file[fileno].eof_passed=1;//also set EOF flag;
qbs_free(buffer);
return;
}
filebuf_size += 512;
}
else {
start_byte += eol_pos - 1;
qbs_set(deststr, qbs_add(deststr, qbs_left(buffer, eol_pos - 1)));
break;
qbs_set(deststr, qbs_add(deststr, qbs_left(buffer, eol_pos - 1)));
break;
}
} while (!func_eof(filehandle));
if (deststr->chr[deststr->len - 1] == '\r') qbs_set(deststr, qbs_left(deststr, deststr->len-1));
sub_seek(filehandle, start_byte + eol->len);
qbs_free(buffer);
}
if (start_byte + deststr->len + 2 >= filelength) { //if we've read to the end of the line
gfs_setpos(fileno,filelength); //set the position right before the EOF marker
gfs_file[fileno].eof_passed=1;//also set EOF flag;
if (deststr->chr[deststr->len - 1] == '\r') qbs_set(deststr, qbs_left(deststr, deststr->len-1));
return;
}
gfs_setpos(fileno,start_byte + deststr->len); //set the position at the end of the text
if (deststr->chr[deststr->len - 1] == '\r') qbs_set(deststr, qbs_left(deststr, deststr->len-1));
}
/*
OPEN "test.txt" FOR OUTPUT AS #1
FOR i = 0 TO 9
t$ = t$ + "This is a test #" + STR$(i)
PRINT #1, t$;
NEXT
CLOSE
OPEN "test.txt" FOR BINARY AS #1
DO
z = z + 1
_BLINEINPUT 1, x$
'GetInput 1, x$ <-- This should be the BASIC equivelant of our routine. (I hope.)
PRINT x$, LEN(x$), ASC(x$, LEN(x$))
LOOP UNTIL EOF(1)
CLOSE
SUB GetInput (filehandle AS LONG, text AS STRING)
FileBuffer = 512 ' Set this number to match the sector size of your hard drive.
' Then we can read as much data as possible each spin of the disk head,
' and not need extra reads in the future.
DIM CRLF AS STRING
CRLF = CHR$(10)
StartByte = SEEK(filehandle)
DO
IF StartByte + FileBuffer >= LOF(filehandle) THEN FileBuffer = LOF(filehandle) - StartByte + 1
temp$ = SPACE$(FileBuffer)
GET #filehandle, StartByte, temp$
x = INSTR(temp$, CRLF)
IF x = 0 THEN
IF StartByte + FileBuffer = LOF(1) THEN text = temp$: EXIT DO 'Our while file is one line with NO CRLF
FileBuffer = FileBuffer + 512
ELSE
text = LEFT$(temp$, x - 1)
EXIT DO
END IF
PRINT StartByte, FileBuffer, LEN(text), LOF(1)
SLEEP
LOOP UNTIL EOF(filehandle)
SEEK filehandle, StartByte + LEN(text) + 1
IF StartByte + LEN(text) + 1 >= LOF(1) THEN GET #1, , temp$ 'if we're at the eol be certain to trigger the eol flag
IF RIGHT$(text, 1) = CHR$(13) THEN text = LEFT$(text$, LEN(text$) - 1)
END SUB
*/

View file

@ -1,7 +1,15 @@
int32 func_screenwidth () {
while (!window_exists){Sleep(100);}
return glutGet(GLUT_SCREEN_WIDTH);
}
int32 func_screenheight () {
while (!window_exists){Sleep(100);}
return glutGet(GLUT_SCREEN_HEIGHT);
}
void sub_screenicon () {
while (!window_exists){Sleep(100);}
glutIconifyWindow;
return;
}

View file

@ -26889,6 +26889,7 @@ int32 func__printwidth(qbs* text, int32 screenhandle, int32 passed){
int32 func__screenx(){
#ifdef QB64_WINDOWS
while (!window_exists){Sleep(100);} //Wait for window to be created before checking position
return glutGet(GLUT_WINDOW_X) - glutGet(GLUT_WINDOW_BORDER_WIDTH);
#endif
return 0; //if not windows then return 0
@ -26896,6 +26897,7 @@ int32 func__printwidth(qbs* text, int32 screenhandle, int32 passed){
int32 func__screeny(){
#ifdef QB64_WINDOWS
while (!window_exists){Sleep(100);} //Wait for window to be created before checking position
return glutGet(GLUT_WINDOW_Y) - glutGet(GLUT_WINDOW_BORDER_WIDTH) - glutGet(GLUT_WINDOW_HEADER_HEIGHT);
#endif
return 0; //if not windows then return 0
@ -26907,6 +26909,7 @@ int32 func__printwidth(qbs* text, int32 screenhandle, int32 passed){
if (passed==3) goto error;
if (full_screen) return;
while (!window_exists){Sleep(100);} //wait for window to be created before moving it.
if (passed==2){
glutPositionWindow (x,y);}
else{

View file

@ -6210,14 +6210,15 @@ FOR y = 0 TO (idewy - 9)
CASE CHR$(34)
inquote = NOT inquote
CASE "'"
IF inquote = 0 AND MID$(a$, k, 2) = "'$" THEN metacommand = -1 ELSE comment = -1
IF inquote = 0 AND MID$(a$, k, 2) = "'$" THEN comment = -1
END SELECT
NEXT k
FOR m = 1 TO LEN(a2$) 'continue checking, while printing to the screen
SELECT CASE MID$(a$, m + idesx - 1, 1)
CASE CHR$(34): inquote = NOT inquote
CASE "'": IF inquote = 0 AND metacommand = 0 THEN comment = -1
CASE "'": IF inquote = 0 THEN comment = -1
END SELECT
IF left$(ltrim$(a$),2) = "'$" THEN metacommand = -1 : comment = 0
COLOR 15
IF comment THEN
COLOR 11

View file

@ -2488,7 +2488,11 @@ DO
IF try = 2 THEN f$ = a$
IF _FILEEXISTS(f$) THEN
qberrorhappened = -3
OPEN f$ FOR INPUT AS #fh
'EDIT on 07-23-2014 to take advantage of the speed difference between _BLINEINPUT and LINEINPUT
'This should reduce the lag generated by using INCLUDE files considerably
'OPEN f$ FOR INPUT AS #fh
OPEN f$ FOR BINARY AS #fh
'And another line below edited
qberrorhappened3:
IF qberrorhappened = -3 THEN EXIT FOR
END IF
@ -2503,7 +2507,8 @@ DO
fh = 99 + inclevel
'2. Feed next line
IF EOF(fh) = 0 THEN
LINE INPUT #fh, x$
'LINE INPUT #fh, x$
_BLINEINPUT #fh, x$
wholeline$ = x$
inclinenumber(inclevel) = inclinenumber(inclevel) + 1
'create extended error string 'incerror$'

View file

@ -175,24 +175,10 @@ id.args = 0
id.ret = LONGTYPE - ISPOINTER
regid
'Removed for command redundancy. Galleon has these already as _SCREENSHOW and _SCREENHIDE
'I just forgot about them. :P At least they're easy to remove! ;)
'clearid
'id.n = "_SHOWWINDOW"
'id.subfunc = 2
'id.callname = "glutShowWindow"
'regid
'clearid
'id.n = "_HIDEWINDOW"
'id.subfunc = 2
'id.callname = "glutHideWindow"
'regid
clearid
id.n = "_SCREENICON" 'name change to from _ICONIFYWINDOW to _SCREENICON to match the screenshow and screenhide
id.subfunc = 2
id.callname = "glutIconifyWindow"
id.callname = "sub_screenicon"
regid
clearid

View file

@ -2446,8 +2446,7 @@ id.n = "LINE"
id.subfunc = 2
id.callname = "sub_line"
id.args = 7
id.arg = MKL$(FLOATTYPE - ISPOINTER) + MKL$(FLOATTYPE - ISPOINTER) + MKL$(FLOATTYPE - ISPOINTER) + MKL$(FLOATTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$ _
(LONGTYPE - ISPOINTER)
id.arg = MKL$(FLOATTYPE - ISPOINTER) + MKL$(FLOATTYPE - ISPOINTER) + MKL$(FLOATTYPE - ISPOINTER) + MKL$(FLOATTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER)
id.specialformat = "[[{STEP}](?,?)]-[{STEP}](?,?)[,[?][,[{B|BF}][,?]]]"
regid