mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-08 21:55:13 +00:00
Fixed ASCII tool colors to match QB64 IDE, and added in EXIT dupport with the red X on top.
Pushed changes introduced by LUKE (Johny B on the QB64 forums) as follows : Fixed setup_lnx.sh, added _CWD$, fixed handling of errno. Converted setup_lnx.sh to Linux line endings (was preventing the script from running). We now include <errno.h>, so the errno variable actually works - before it was just a regular variable that wasn't being set on error. Added a _CWD$ function that returns the current working directory. Should work on all 3 systems, but testing is needed on Win/Mac. Can cause the following runtime errors: 7 (Out of memory), 51 (Internal error).
This commit is contained in:
parent
9d2c936189
commit
ef083bb4af
Binary file not shown.
|
@ -4,4 +4,5 @@
|
||||||
//**
|
//**
|
||||||
//***********************************************
|
//***********************************************
|
||||||
|
|
||||||
|
#include "luke_mods.cpp"
|
||||||
#include "Steves_Main-List.cpp"
|
#include "Steves_Main-List.cpp"
|
53
internal/c/User Mods/luke_mods.cpp
Normal file
53
internal/c/User Mods/luke_mods.cpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
//Get Current Working Directory
|
||||||
|
qbs *func__cwd(){
|
||||||
|
qbs *final, *tqbs;
|
||||||
|
int length;
|
||||||
|
char *buf, *ret;
|
||||||
|
|
||||||
|
#if defined QB64_WINDOWS
|
||||||
|
length = GetCurrentDirectoryA(0, NULL);
|
||||||
|
buf = (char *)malloc(length);
|
||||||
|
if (!buf) {
|
||||||
|
error(7); //"Out of memory"
|
||||||
|
return tqbs;
|
||||||
|
}
|
||||||
|
if (GetCurrentDirectoryA(length, buf) != --length) { //Sanity check
|
||||||
|
free(buf); //It's good practice
|
||||||
|
tqbs = qbs_new(0, 1);
|
||||||
|
error(51); //"Internal error"
|
||||||
|
return tqbs;
|
||||||
|
}
|
||||||
|
#elif defined QB64_LINUX
|
||||||
|
length = 512;
|
||||||
|
while(1) {
|
||||||
|
buf = (char *)malloc(length);
|
||||||
|
if (!buf) {
|
||||||
|
tqbs = qbs_new(0, 1);
|
||||||
|
error(7);
|
||||||
|
return tqbs;
|
||||||
|
}
|
||||||
|
ret = getcwd(buf, length);
|
||||||
|
if (ret) break;
|
||||||
|
if (errno != ERANGE) {
|
||||||
|
tqbs = qbs_new(0, 1);
|
||||||
|
error(51);
|
||||||
|
return tqbs;
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
|
length += 512;
|
||||||
|
}
|
||||||
|
length = strlen(ret);
|
||||||
|
ret = (char *)realloc(ret, length); //Chops off the null byte
|
||||||
|
if (!ret) {
|
||||||
|
tqbs = qbs_new(0, 1);
|
||||||
|
error(7);
|
||||||
|
return tqbs;
|
||||||
|
}
|
||||||
|
buf = ret;
|
||||||
|
#endif
|
||||||
|
final = qbs_new(length, 1);
|
||||||
|
memcpy(final->chr, buf, length);
|
||||||
|
free(buf);
|
||||||
|
return final;
|
||||||
|
}
|
||||||
|
|
5
internal/c/User Mods/luke_mods.h
Normal file
5
internal/c/User Mods/luke_mods.h
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
/* Routines by Luke
|
||||||
|
* The actual code is in Luke_Main-List.cpp
|
||||||
|
* Write me at <flukiluke@gmail.com> if I broke something
|
||||||
|
*/
|
||||||
|
qbs *func__cwd();
|
|
@ -9,4 +9,5 @@
|
||||||
//**
|
//**
|
||||||
//*************************************************************
|
//*************************************************************
|
||||||
|
|
||||||
|
#include "luke_mods.h"
|
||||||
#include "steve_mods.h"
|
#include "steve_mods.h"
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
//OS/compiler specific includes
|
//OS/compiler specific includes
|
||||||
#ifdef QB64_WINDOWS
|
#ifdef QB64_WINDOWS
|
||||||
|
|
|
@ -3484,10 +3484,6 @@ void AllocConsole(){
|
||||||
void FreeConsole(){
|
void FreeConsole(){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32 errno;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int MessageBox2(int ignore,char* message,char* title,int type){
|
int MessageBox2(int ignore,char* message,char* title,int type){
|
||||||
|
|
8
internal/source/User Mods/Luke Stuff-ID_Includes.bi
Normal file
8
internal/source/User Mods/Luke Stuff-ID_Includes.bi
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
'Get Current Working Directory
|
||||||
|
clearid
|
||||||
|
id.n = "_CWD"
|
||||||
|
id.musthave = "$"
|
||||||
|
id.subfunc = 1
|
||||||
|
id.callname = "func__cwd"
|
||||||
|
id.ret = STRINGTYPE - ISPOINTER
|
||||||
|
regid
|
|
@ -1 +1,2 @@
|
||||||
|
'$INCLUDE:'internal/source/User Mods/Luke Stuff-ID_Includes.bi'
|
||||||
'$INCLUDE:'internal/source/User Mods/Steve Stuff-ID_Includes.bi'
|
'$INCLUDE:'internal/source/User Mods/Steve Stuff-ID_Includes.bi'
|
||||||
|
|
|
@ -43,19 +43,19 @@ if(_SUB_IDEASCIIBOX_INTEGER_CURRENTONE==NULL){
|
||||||
_SUB_IDEASCIIBOX_INTEGER_CURRENTONE=(int16*)mem_static_malloc(2);
|
_SUB_IDEASCIIBOX_INTEGER_CURRENTONE=(int16*)mem_static_malloc(2);
|
||||||
*_SUB_IDEASCIIBOX_INTEGER_CURRENTONE=0;
|
*_SUB_IDEASCIIBOX_INTEGER_CURRENTONE=0;
|
||||||
}
|
}
|
||||||
int32 *_SUB_IDEASCIIBOX_LONG_X=NULL;
|
int32 *_SUB_IDEASCIIBOX_LONG_Y=NULL;
|
||||||
if(_SUB_IDEASCIIBOX_LONG_X==NULL){
|
if(_SUB_IDEASCIIBOX_LONG_Y==NULL){
|
||||||
_SUB_IDEASCIIBOX_LONG_X=(int32*)mem_static_malloc(4);
|
_SUB_IDEASCIIBOX_LONG_Y=(int32*)mem_static_malloc(4);
|
||||||
*_SUB_IDEASCIIBOX_LONG_X=0;
|
*_SUB_IDEASCIIBOX_LONG_Y=0;
|
||||||
}
|
}
|
||||||
int64 fornext_value1863;
|
int64 fornext_value1863;
|
||||||
int64 fornext_finalvalue1863;
|
int64 fornext_finalvalue1863;
|
||||||
int64 fornext_step1863;
|
int64 fornext_step1863;
|
||||||
uint8 fornext_step_negative1863;
|
uint8 fornext_step_negative1863;
|
||||||
int32 *_SUB_IDEASCIIBOX_LONG_Y=NULL;
|
int32 *_SUB_IDEASCIIBOX_LONG_X=NULL;
|
||||||
if(_SUB_IDEASCIIBOX_LONG_Y==NULL){
|
if(_SUB_IDEASCIIBOX_LONG_X==NULL){
|
||||||
_SUB_IDEASCIIBOX_LONG_Y=(int32*)mem_static_malloc(4);
|
_SUB_IDEASCIIBOX_LONG_X=(int32*)mem_static_malloc(4);
|
||||||
*_SUB_IDEASCIIBOX_LONG_Y=0;
|
*_SUB_IDEASCIIBOX_LONG_X=0;
|
||||||
}
|
}
|
||||||
int64 fornext_value1865;
|
int64 fornext_value1865;
|
||||||
int64 fornext_finalvalue1865;
|
int64 fornext_finalvalue1865;
|
||||||
|
@ -128,6 +128,11 @@ if(_SUB_IDEASCIIBOX_LONG_ATALL==NULL){
|
||||||
_SUB_IDEASCIIBOX_LONG_ATALL=(int32*)mem_static_malloc(4);
|
_SUB_IDEASCIIBOX_LONG_ATALL=(int32*)mem_static_malloc(4);
|
||||||
*_SUB_IDEASCIIBOX_LONG_ATALL=0;
|
*_SUB_IDEASCIIBOX_LONG_ATALL=0;
|
||||||
}
|
}
|
||||||
|
int32 *_SUB_IDEASCIIBOX_LONG_EX=NULL;
|
||||||
|
if(_SUB_IDEASCIIBOX_LONG_EX==NULL){
|
||||||
|
_SUB_IDEASCIIBOX_LONG_EX=(int32*)mem_static_malloc(4);
|
||||||
|
*_SUB_IDEASCIIBOX_LONG_EX=0;
|
||||||
|
}
|
||||||
int16 *_SUB_IDEASCIIBOX_INTEGER_RET=NULL;
|
int16 *_SUB_IDEASCIIBOX_INTEGER_RET=NULL;
|
||||||
if(_SUB_IDEASCIIBOX_INTEGER_RET==NULL){
|
if(_SUB_IDEASCIIBOX_INTEGER_RET==NULL){
|
||||||
_SUB_IDEASCIIBOX_INTEGER_RET=(int16*)mem_static_malloc(2);
|
_SUB_IDEASCIIBOX_INTEGER_RET=(int16*)mem_static_malloc(2);
|
||||||
|
|
70869
internal/source/main.txt
70869
internal/source/main.txt
File diff suppressed because it is too large
Load diff
Binary file not shown.
27
qb64.bas
27
qb64.bas
|
@ -11966,10 +11966,10 @@ ws = _NEWIMAGE(640, 480, 32)
|
||||||
SCREEN temp
|
SCREEN temp
|
||||||
DIM CurrentASC(1 TO 16, 1 TO 16)
|
DIM CurrentASC(1 TO 16, 1 TO 16)
|
||||||
DIM CurrentOne AS INTEGER
|
DIM CurrentOne AS INTEGER
|
||||||
CLS , _RGB(100, 0, 200)
|
CLS , _RGB(0, 0, 170)
|
||||||
COLOR , _RGB(100, 0, 200)
|
COLOR , _RGB(0, 0, 170)
|
||||||
FOR x = 1 TO 16
|
|
||||||
FOR y = 1 TO 16
|
FOR y = 1 TO 16
|
||||||
|
FOR x = 1 TO 16
|
||||||
LINE (x * 40, 0)-(x * 40, 480), _RGB32(255, 255, 0)
|
LINE (x * 40, 0)-(x * 40, 480), _RGB32(255, 255, 0)
|
||||||
LINE (0, y * 30)-(640, y * 30), _RGB32(255, 255, 0)
|
LINE (0, y * 30)-(640, y * 30), _RGB32(255, 255, 0)
|
||||||
IF counter THEN _PRINTSTRING (x * 40 - 28, y * 30 - 23), CHR$(counter)
|
IF counter THEN _PRINTSTRING (x * 40 - 28, y * 30 - 23), CHR$(counter)
|
||||||
|
@ -11978,11 +11978,11 @@ FOR x = 1 TO 16
|
||||||
NEXT
|
NEXT
|
||||||
|
|
||||||
_DEST temp1
|
_DEST temp1
|
||||||
CLS , _RGB(100, 0, 200)
|
CLS , _RGB(0, 0, 170)
|
||||||
COLOR , _RGB(100, 0, 200)
|
COLOR , _RGB(0, 0, 170)
|
||||||
counter = 0
|
counter = 0
|
||||||
FOR x = 1 TO 16
|
|
||||||
FOR y = 1 TO 16
|
FOR y = 1 TO 16
|
||||||
|
FOR x = 1 TO 16
|
||||||
LINE (x * 40, 0)-(x * 40, 480), _RGB32(255, 255, 0)
|
LINE (x * 40, 0)-(x * 40, 480), _RGB32(255, 255, 0)
|
||||||
LINE (0, y * 30)-(640, y * 30), _RGB32(255, 255, 0)
|
LINE (0, y * 30)-(640, y * 30), _RGB32(255, 255, 0)
|
||||||
text$ = LTRIM$(STR$(counter))
|
text$ = LTRIM$(STR$(counter))
|
||||||
|
@ -12003,17 +12003,17 @@ DO
|
||||||
|
|
||||||
x = _MOUSEX \ 40 + 1 'If mouse moved, where are we now?
|
x = _MOUSEX \ 40 + 1 'If mouse moved, where are we now?
|
||||||
y = _MOUSEY \ 30 + 1
|
y = _MOUSEY \ 30 + 1
|
||||||
num = (x - 1) * 16 + y - 1
|
num = (y - 1) * 16 + x - 1
|
||||||
IF num = 0 THEN
|
IF num = 0 THEN
|
||||||
text$ = ""
|
text$ = ""
|
||||||
ELSE
|
ELSE
|
||||||
flashcounter = flashcounter + 1
|
flashcounter = flashcounter + 1
|
||||||
IF flashcounter > 30 THEN
|
IF flashcounter > 30 THEN
|
||||||
COLOR _RGB32(255, 255, 255), _RGB(100, 0, 200)
|
COLOR _RGB32(255, 255, 255), _RGB(0, 0, 170)
|
||||||
text$ = CHR$(num)
|
text$ = CHR$(num)
|
||||||
IF LEN(text$) = 1 THEN text$ = " " + text$ + " "
|
IF LEN(text$) = 1 THEN text$ = " " + text$ + " "
|
||||||
ELSE
|
ELSE
|
||||||
COLOR _RGB32(255, 0, 0), _RGB(100, 0, 200)
|
COLOR _RGB32(255, 255, 255), _RGB(0, 0, 170)
|
||||||
text$ = RTRIM$(LTRIM$(STR$(num)))
|
text$ = RTRIM$(LTRIM$(STR$(num)))
|
||||||
END IF
|
END IF
|
||||||
END IF
|
END IF
|
||||||
|
@ -12043,9 +12043,16 @@ DO
|
||||||
IF y < 1 THEN y = 1
|
IF y < 1 THEN y = 1
|
||||||
IF y > 16 THEN y = 16
|
IF y > 16 THEN y = 16
|
||||||
_DISPLAY
|
_DISPLAY
|
||||||
|
Ex = _EXIT
|
||||||
|
IF Ex THEN
|
||||||
|
_AUTODISPLAY
|
||||||
|
SCREEN 0: WIDTH w, h: _DEST 0: _DELAY .2
|
||||||
|
IF _RESIZE THEN donothing = atall
|
||||||
|
EXIT FUNCTION
|
||||||
|
END IF
|
||||||
LOOP UNTIL _MOUSEBUTTON(1)
|
LOOP UNTIL _MOUSEBUTTON(1)
|
||||||
|
|
||||||
ret% = (x - 1) * 16 + y - 1
|
ret% = (y - 1) * 16 + x - 1
|
||||||
IF ret% > 0 AND ret% < 255 THEN
|
IF ret% > 0 AND ret% < 255 THEN
|
||||||
l = idecy
|
l = idecy
|
||||||
a$ = idegetline(l)
|
a$ = idegetline(l)
|
||||||
|
|
Loading…
Reference in a new issue