diff --git a/internal/c/common.h b/internal/c/common.h index 9d57a868e..8280dd0d2 100644 --- a/internal/c/common.h +++ b/internal/c/common.h @@ -28,8 +28,6 @@ #define QB64_GUI #endif -#define NO_S_D_L - //core #ifdef QB64_GUI #ifdef QB64_GLUT diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 4b119ceac..725e959a3 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -1518,31 +1518,6 @@ int32 *fontheight=(int32*)calloc(4*(48+1),1); int32 *fontwidth=(int32*)calloc(4*(48+1),1); int32 *fontflags=(int32*)calloc(4*(48+1),1); - - - -#ifdef QB64_WINDOWS -//NO_S_D_L// #define QB64_IME -#endif - -//keyboard input upgrade - -//global IME related variables -#ifdef QB64_IME -int32 ime_DrawMessageBlock_lastpixeloffset=0; -SDL_Surface *ime_back; -static qbs *imefontname; -static qbs *imefontname2; -static qbs *imefontname3; -static qbs *imefontname4; -static int32 ime_font=NULL; -#endif -int32 qb64_ime_reading=0; - - - - - //keyhit cyclic buffer int64 keyhit[8192]; // keyhit specific internal flags: (stored in high 32-bits) @@ -2253,1483 +2228,6 @@ void keyup_vk(uint32 x){ } - -#ifndef NO_S_D_L - -#ifdef QB64_IME - -#include //Microsoft specific include QB64 IME support is dependent on - -//---------------------------------------------start of SDL_inputmethod.h-------------------------------------------------------------------- -/* - SDL_inputmethod - Copyright (C) 2004 Kazunori Itoyanagi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - ITOYANAGI Kazunori - itkz@users.sourceforge.jp -*/ - -#ifndef _SDL_ime_H_ -#define _SDL_ime_H_ - -/* - #include - #include "SDL_version.h" - #include "SDL.h" -*/ -#include "begin_code.h" - -#define INPUT_METHOD_MAJOR_VERSION 0 -#define INPUT_METHOD_MINOR_VERSION 1 -#define INPUT_METHOD_PATCHLEVEL 0 - -/* This macro can be used to fill a version structure with the compile-time - * version of the SDL_inputmethod library. - */ -#define INPUTMETHOD_VERSION(X) \ - { \ - (X)->major = INPUT_METHOD_MAJOR_VERSION; \ - (X)->minor = INPUT_METHOD_MINOR_VERSION; \ - (X)->patch = INPUT_METHOD_PATCHLEVEL; \ - } - - -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - - - - - /* public ... for Applications */ - - typedef enum - { - INPUT_METHOD_MESSAGE_ON, - INPUT_METHOD_MESSAGE_CHANGE, - INPUT_METHOD_MESSAGE_RESULT, - INPUT_METHOD_MESSAGE_OFF, - INPUT_METHOD_MESSAGE_CHAR, - INPUT_METHOD_MESSAGE_NO_EXIST - } InputMethod_Message; - - typedef enum - { - INPUT_METHOD_SUCCESS = 0, - INPUT_METHOD_ERROR_ALREADY_INIT, - INPUT_METHOD_ERROR_ALLOCATED_MEMORY, - INPUT_METHOD_ERROR_NO_STRING, - INPUT_METHOD_ERROR_UNKNOWN_MESSAGE, - INPUT_METHOD_ERROR_SDL_NO_INIT, - INPUT_METHOD_ERROR_NO_INIT, - INPUT_METHOD_ERROR_SYSTEM_SPECIFIC, - INPUT_METHOD_ERROR_ALREADY_VALIDATED, - INPUT_METHOD_ERROR_ALREADY_INVALIDATED, - INPUT_METHOD_ERROR_NOT_AVAILABLE, - INPUT_METHOD_ERROR_INVALID_BOOTSTRAP - } InputMethod_Result; - - /* - typedef enum - { - INPUT_METHOD_STATUS_ON, - INPUT_METHOD_STATUS_OFF - } InputMethod_Status; - */ - - extern DECLSPEC InputMethod_Result SDLCALL InputMethod_Init(void); - - extern DECLSPEC int SDLCALL InputMethod_GetEventNumber(void); - extern DECLSPEC void SDLCALL InputMethod_MoveNextEvent(void); - extern DECLSPEC InputMethod_Message SDLCALL InputMethod_GetCurrentMessage(void); - extern DECLSPEC Uint16 * SDLCALL InputMethod_GetCurrentEditingString(void); - extern DECLSPEC Uint16 SDLCALL InputMethod_GetCurrentChar(void); - extern DECLSPEC int SDLCALL InputMethod_GetCurrentCursorPosition(void); - extern DECLSPEC int SDLCALL InputMethod_GetCurrentCompositionPosition(void); - extern DECLSPEC int SDLCALL InputMethod_GetCurrentCompositionLength(void); - extern DECLSPEC void SDLCALL InputMethod_Reset(void); - extern DECLSPEC InputMethod_Result SDLCALL InputMethod_Validate(void); - extern DECLSPEC InputMethod_Result SDLCALL InputMethod_Invalidate(void); - extern DECLSPEC Uint16 * SDLCALL InputMethod_GetInputMethodName(void); - extern DECLSPEC void SDLCALL InputMethod_Quit(void); - - - - - - /* protected? ... for add other Input Methods */ - -#define INPUT_METHOD_NAME_STRING_LENGTH 256 - - typedef struct _SDL_InputMethod - { - SDL_bool (*available)(void); - InputMethod_Result (*init)(void); - void (*quit)(void); - void (*reset)(void); - InputMethod_Result (*validate)(void); - InputMethod_Result (*invalidate)(void); - - /* - Return value is Input Method name in Unicode. - You have to set string to `InputMethodName' and - return this in get_name(), - because get_name() is a possible - to call without init() and quit(), - and so even if use malloc() to string, no time to free(). - */ - Uint16 *(*get_name)(void); - Uint16 InputMethodName[INPUT_METHOD_NAME_STRING_LENGTH]; - /* - InputMethod_Status (*get_status)(void); - void (*set_status)(InputMethod_Status status); - */ - } SDL_InputMethod; - - extern DECLSPEC InputMethod_Result SDLCALL InputMethod_PostEvent( - InputMethod_Message message, - Uint16 *editingString, - int cursorPosition, - int compositionPosition, - int compositionLength); - extern DECLSPEC InputMethod_Result SDLCALL InputMethod_InitFromOther( - SDL_InputMethod inputMethod); - - - - - - /* private */ - -#ifdef ENABLE_WIN32 - extern SDL_InputMethod InputMethod_win32; -#endif -#ifdef ENABLE_XIM - extern SDL_InputMethod InputMethod_xim; -#endif - /* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" -#endif -//---------------------------------------------end of SDL_inputmethod.h-------------------------------------------------------------------- - -//---------------------------------------------start of SDL_inputmethod.c-------------------------------------------------------------------- -/* - SDL_inputmethod - Copyright (C) 2004 Kazunori Itoyanagi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - ITOYANAGI Kazunori - itkz@users.sourceforge.jp -*/ - -static SDL_InputMethod *InputMethod_BootStrap[] = - { -#ifdef ENABLE_WIN32 - &InputMethod_win32, -#endif -#ifdef ENABLE_XIM - &InputMethod_xim, -#endif - NULL - }; - - -typedef struct _InputMethod_Event -{ - InputMethod_Message message; - Uint16 *editingString; - int cursorPosition; - struct _InputMethod_Event *next; - int compositionPosition; - int compositionLength; - Uint16 character; -} InputMethod_Event; - - -static SDL_InputMethod *InputMethod_Use = NULL; -SDL_EventFilter OriginalFilterSDL = NULL; - -static InputMethod_Event *InputMethod_EventQue = NULL; -static int InputMethod_EventQueNumber = 0; -static int32 IsOriginalInputMethod = SDL_FALSE; -static int32 IsInited = SDL_FALSE; -static int32 IsValid; -static int32 IsEnableUNICODEOld; - -static int InputMethod_GetUnicodeStringLength(Uint16 *unicodeString); -static int InputMethod_SDLEventFilter(const SDL_Event *e); -static void InputMethod_SetEventFilter(void); -static void InputMethod_RestoreEventFilter(void); -static InputMethod_Result InputMethod_PostCharEvent(Uint16 unicode); - - -void InputMethod_SetEventFilter(void) -{ - IsEnableUNICODEOld = SDL_EnableUNICODE(1); - //OriginalFilterSDL = SDL_GetEventFilter(); - //SDL_SetEventFilter(InputMethod_SDLEventFilter); -} - - -void InputMethod_RestoreEventFilter(void) -{ - SDL_EnableUNICODE(IsEnableUNICODEOld); - //SDL_SetEventFilter(OriginalFilterSDL); - //OriginalFilterSDL = NULL; -} - - -InputMethod_Result InputMethod_Init(void) -{ - int i; - InputMethod_Result result; - - if (IsInited == 1) { - return INPUT_METHOD_ERROR_ALREADY_INIT; - } - - - - for (i = 0; InputMethod_BootStrap[i]; i++) { - if (InputMethod_BootStrap[i]->available()) { - - - InputMethod_Use = InputMethod_BootStrap[i]; - break; - - - - } - } - - - - InputMethod_SetEventFilter(); - if (InputMethod_Use != NULL) { - result = InputMethod_Use->init(); - if (result != INPUT_METHOD_SUCCESS) { - InputMethod_Use->quit(); - InputMethod_Use = NULL; - InputMethod_RestoreEventFilter(); - return result; - } - } - InputMethod_EventQue = NULL; - InputMethod_EventQueNumber = 0; - IsOriginalInputMethod = SDL_FALSE; - IsValid = 1; - IsInited = 1; - - return INPUT_METHOD_SUCCESS; -} - - -void InputMethod_Quit(void) -{ - InputMethod_Event *event; - InputMethod_Event *next; - - if (InputMethod_Use != NULL) { - if (InputMethod_Use->quit != NULL) { - InputMethod_Use->quit(); - } - if (IsOriginalInputMethod) { - free(InputMethod_Use); - } - InputMethod_Use = NULL; - } - - event = InputMethod_EventQue; - while (event != NULL) { - next = event->next; - if (event->editingString != NULL) { - free(event->editingString); - } - free(event); - event = next; - } - InputMethod_EventQue = NULL; - InputMethod_EventQueNumber = 0; - IsOriginalInputMethod = SDL_FALSE; - IsInited = SDL_FALSE; - InputMethod_RestoreEventFilter(); -} - - -int InputMethod_BootstrapNum(void) -{ - int count; - - count = 0; - while (InputMethod_BootStrap[count]) { - count++; - } - - return count; -} - - -int32 InputMethod_BootstrapIsAvailable(int num) { - if (0 <= num && num < InputMethod_BootstrapNum()) { - return InputMethod_BootStrap[num]->available(); - } else { - return SDL_FALSE; - } -} - - -Uint16 *InputMethod_BootstrapGetInputMethodName(int num) { - if (0 <= num && num < InputMethod_BootstrapNum()) { - if (InputMethod_BootStrap[num]->available()) { - return InputMethod_BootStrap[num]->get_name(); - } - } - return NULL; -} - - -InputMethod_Result InputMethod_InitFromBootstrap(int num) -{ - InputMethod_Result result; - - if (IsInited == 1) { - return INPUT_METHOD_ERROR_ALREADY_INIT; - } - - if (0 <= num && num < InputMethod_BootstrapNum()) { - if (InputMethod_BootStrap[num]->available()) { - InputMethod_Use = InputMethod_BootStrap[num]; - } else { - return INPUT_METHOD_ERROR_NOT_AVAILABLE; - } - } else { - return INPUT_METHOD_ERROR_INVALID_BOOTSTRAP; - } - - result = InputMethod_Use->init(); - if (result != INPUT_METHOD_SUCCESS) { - InputMethod_Use->quit(); - InputMethod_Use = NULL; - return result; - } - InputMethod_EventQue = NULL; - InputMethod_EventQueNumber = 0; - IsOriginalInputMethod = SDL_FALSE; - IsValid = 1; - IsInited = 1; - - return INPUT_METHOD_SUCCESS; -} - - -void InputMethod_Reset(void) -{ - InputMethod_Event *event; - InputMethod_Event *next; - - event = InputMethod_EventQue; - while (event != NULL) { - next = event->next; - if (event->editingString != NULL) { - free(event->editingString); - } - free(event); - event = next; - } - InputMethod_EventQue = NULL; - InputMethod_EventQueNumber = 0; - - if (InputMethod_Use != NULL) { - if (InputMethod_Use->reset != NULL) { - InputMethod_Use->reset(); - } - } -} - - -InputMethod_Result InputMethod_Validate(void) -{ - InputMethod_Result result; - - if (InputMethod_Use == NULL) { - SDL_SetError("Input method is no init"); - return INPUT_METHOD_ERROR_NO_INIT; - } - - if (IsValid == 1) { - return INPUT_METHOD_ERROR_ALREADY_VALIDATED; - } - - if (InputMethod_Use != NULL) { - if (InputMethod_Use->validate != NULL) { - result = InputMethod_Use->validate(); - - if (result == INPUT_METHOD_SUCCESS) { - IsValid = 1; - } - return result; - } - } - - SDL_SetError("Input method is no init"); - return INPUT_METHOD_ERROR_NO_INIT; -} - - -InputMethod_Result InputMethod_Invalidate(void) -{ - InputMethod_Result result; - - if (InputMethod_Use == NULL) { - SDL_SetError("Input method is no init"); - return INPUT_METHOD_ERROR_NO_INIT; - } - - if (IsValid == SDL_FALSE) { - return INPUT_METHOD_ERROR_ALREADY_INVALIDATED; - } - - if (InputMethod_Use != NULL) { - if (InputMethod_Use->invalidate !=NULL) { - result = InputMethod_Use->invalidate(); - if (result == INPUT_METHOD_SUCCESS) { - IsValid = SDL_FALSE; - } - return result; - } - } - - SDL_SetError("Input method is no init"); - return INPUT_METHOD_ERROR_NO_INIT; -} - - -int InputMethod_GetEventNumber(void) -{ - return InputMethod_EventQueNumber; -} - - -void InputMethod_MoveNextEvent(void) -{ - InputMethod_Event *next; - - if (InputMethod_EventQueNumber > 0) { - if (InputMethod_EventQue->editingString != NULL) { - free(InputMethod_EventQue->editingString); - } - - if (InputMethod_EventQue != NULL) { - next = InputMethod_EventQue->next; - free(InputMethod_EventQue); - InputMethod_EventQue = next; - } - - InputMethod_EventQueNumber--; - } -} - - -InputMethod_Message InputMethod_GetCurrentMessage(void) -{ - if (InputMethod_EventQue == NULL) { - SDL_SetError("Message is not found"); - return INPUT_METHOD_MESSAGE_NO_EXIST; - } else { - return InputMethod_EventQue->message; - } -} - - -Uint16 *InputMethod_GetCurrentEditingString(void) -{ - if (InputMethod_EventQue == NULL) { - return NULL; - } - - return InputMethod_EventQue->editingString; -} - - -Uint16 InputMethod_GetCurrentChar(void) -{ - if (InputMethod_EventQue == NULL) { - return 0x0000; - } - - return InputMethod_EventQue->character; -} - - -int InputMethod_GetCurrentCursorPosition(void) -{ - if (InputMethod_EventQue == NULL) { - return 0; - } - - return InputMethod_EventQue->cursorPosition; -} - - -int InputMethod_GetCurrentCompositionPosition(void) -{ - if (InputMethod_EventQue == NULL) { - return 0; - } - - return InputMethod_EventQue->compositionPosition; -} - - -int InputMethod_GetCurrentCompositionLength(void) -{ - if (InputMethod_EventQue == NULL) { - return 0; - } - - return InputMethod_EventQue->compositionLength; -} - - -Uint16 *InputMethod_GetInputMethodName(void) -{ - if (InputMethod_Use != NULL) { - if (InputMethod_Use->get_name != NULL) { - return InputMethod_Use->get_name(); - } - } - return NULL; -} - - -int InputMethod_GetUnicodeStringLength(Uint16 *unicodeString) -{ - int i; - - if (unicodeString == NULL) { - return 0; - } - - i = 0; - while (unicodeString[i]) { - i++; - } - - return i; -} - - -InputMethod_Result InputMethod_PostEvent( - InputMethod_Message message, - Uint16 *editingString, - int cursorPosition, - int compositionPosition, - int compositionLength) -{ - - //showvalue(99998); - InputMethod_Event *event; - InputMethod_Event *lastEvent; - int size; - - event = (InputMethod_Event*)malloc(sizeof(InputMethod_Event)); - if (event == NULL) { - SDL_SetError("Allocate memory failed"); - return INPUT_METHOD_ERROR_ALLOCATED_MEMORY; - } - event->next = NULL; - - switch (message) { - case INPUT_METHOD_MESSAGE_ON: - case INPUT_METHOD_MESSAGE_OFF: - event->message = message; - event->editingString = NULL; - event->cursorPosition = 0; - event->compositionPosition = 0; - event->compositionLength = 0; - event->character = 0x0000; - break; - case INPUT_METHOD_MESSAGE_RESULT: - if (editingString == NULL) { - free(event); - SDL_SetError( - "post INPUT_METHOD_MESSAGE_RESULT: " - "Editing string is NULL"); - return INPUT_METHOD_ERROR_NO_STRING; - } - size = - InputMethod_GetUnicodeStringLength(editingString) * sizeof(Uint16) + - sizeof(Uint16); - event->editingString = (Uint16*)malloc(size); - if (event->editingString == NULL) { - free(event); - SDL_SetError("Allocate memory failed"); - return INPUT_METHOD_ERROR_ALLOCATED_MEMORY; - } - memcpy(event->editingString, editingString, size); - event->message = message; - event->cursorPosition = 0; - event->compositionPosition = 0; - event->compositionLength = 0; - event->character = 0x0000; - break; - case INPUT_METHOD_MESSAGE_CHANGE: - if (editingString == NULL) { - free(event); - SDL_SetError( - "post INPUT_METHOD_MESSAGE_CHANGE: " - "Editing string is NULL"); - return INPUT_METHOD_ERROR_NO_STRING; - } - size = - InputMethod_GetUnicodeStringLength(editingString) * sizeof(Uint16) + - sizeof(Uint16); - event->editingString = (Uint16*)malloc(size); - if (event->editingString == NULL) { - free(event); - return INPUT_METHOD_ERROR_ALLOCATED_MEMORY; - } - memcpy(event->editingString, editingString, size); - event->message = message; - event->cursorPosition = cursorPosition; - event->compositionPosition = compositionPosition; - event->compositionLength = compositionLength; - event->character = 0x0000; - break; - default: - free(event); - SDL_SetError("post message: unknown message"); - return INPUT_METHOD_ERROR_UNKNOWN_MESSAGE; - } - - if (InputMethod_EventQue == NULL) { - InputMethod_EventQue = event; - } else { - lastEvent = InputMethod_EventQue; - while (lastEvent->next != NULL) { - lastEvent = lastEvent->next; - } - lastEvent->next = event; - } - - //showvalue(99999); - InputMethod_EventQueNumber++; - - return INPUT_METHOD_SUCCESS; -} - -//IMPORTANT: THIS FUNCTION IS NOT USED BUT HAS BEEN KEPT FOR REFERENCE PURPOSES -InputMethod_Result InputMethod_PostCharEvent(Uint16 unicode) -{ - //IMPORTANT: THIS FUNCTION IS NOT USED BUT HAS BEEN KEPT FOR REFERENCE PURPOSES - - InputMethod_Event *event; - InputMethod_Event *lastEvent; - - event = (InputMethod_Event*)malloc(sizeof(InputMethod_Event)); - if (event == NULL) { - SDL_SetError("Allocate memory failed"); - return INPUT_METHOD_ERROR_ALLOCATED_MEMORY; - } - event->next = NULL; - - event->message = INPUT_METHOD_MESSAGE_CHAR; - - //exit(unicode); - event->character = unicode; - event->editingString = NULL; - event->cursorPosition = 0; - event->compositionPosition = 0; - event->compositionLength = 0; - - if (InputMethod_EventQue == NULL) { - InputMethod_EventQue = event; - } else { - lastEvent = InputMethod_EventQue; - while (lastEvent->next != NULL) { - lastEvent = lastEvent->next; - } - lastEvent->next = event; - } - InputMethod_EventQueNumber++; - - return INPUT_METHOD_SUCCESS; -} - - -InputMethod_Result InputMethod_InitFromOther( - SDL_InputMethod inputMethod) -{ - InputMethod_Result result; - - if (IsInited == 1) { - SDL_SetError("Input method is already inited"); - return INPUT_METHOD_ERROR_ALREADY_INIT; - } - - if (inputMethod.available() == SDL_FALSE) { - SDL_SetError("Bootstrap is invalid"); - return INPUT_METHOD_ERROR_INVALID_BOOTSTRAP; - } else { - InputMethod_SetEventFilter(); - result = inputMethod.init(); - if (result != INPUT_METHOD_SUCCESS) { - InputMethod_RestoreEventFilter(); - return result; - } - } - - InputMethod_Use = (SDL_InputMethod*)malloc(sizeof(SDL_InputMethod)); - if (InputMethod_Use == NULL) { - inputMethod.quit(); - SDL_SetError("Allocate memory failed"); - return INPUT_METHOD_ERROR_ALLOCATED_MEMORY; - } - - memcpy(InputMethod_Use, &inputMethod, sizeof(SDL_InputMethod)); - - InputMethod_EventQue = NULL; - InputMethod_EventQueNumber = 0; - IsOriginalInputMethod = 1; - IsValid = 1; - IsInited = 1; - - return INPUT_METHOD_SUCCESS; -} - - -//IMPORTANT: THIS FUNCTION IS NOT USED BUT HAS BEEN KEPT FOR REFERENCE PURPOSES -int InputMethod_SDLEventFilter(const SDL_Event *e) -{ - - //IMPORTANT: THIS FUNCTION IS NOT USED BUT HAS BEEN KEPT FOR REFERENCE PURPOSES - - Uint8 *keys; - SDL_keysym keysym; - char ch; - - if (IsValid == 1) { - keys = SDL_GetKeyState(NULL); - keys[QBVK_UNKNOWN] = SDL_RELEASED; - - switch (e->type) { - case SDL_KEYDOWN: - keysym = ((SDL_KeyboardEvent*)e)->keysym; - if ( (keysym.unicode & 0xFF80) == 0 ) { - ch = keysym.unicode & 0x007F; - if (isprint(ch)) { - InputMethod_PostCharEvent(keysym.unicode); - keys[keysym.sym] = SDL_RELEASED; - return 0; - } - } - break; - default: - break; - } - } - - if (OriginalFilterSDL != NULL) { - return (*OriginalFilterSDL)(e); - } - return 1; -} -//---------------------------------------------end of SDL_inputmethod.c-------------------------------------------------------------------- - -//---------------------------------------------start of SDL_inputmethod for Windows-------------------------------------------------------------------- -/* - SDL_inputmethod - Copyright (C) 2004 Kazunori Itoyanagi - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - ITOYANAGI Kazunori - itkz@users.sourceforge.jp -*/ - -/* - #include - #include - #include "SDL.h" -*/ -#include "SDL_syswm.h" -/* - #include "SDL_inputmethod.h" -*/ - -static SDL_bool InputMethod_AvailableWin32(void); -static InputMethod_Result InputMethod_InitWin32(void); -static void InputMethod_QuitWin32(void); -static void InputMethod_ResetWin32(void); -static InputMethod_Result InputMethod_ValidateWin32(void); -static InputMethod_Result InputMethod_InvalidateWin32(void); -static Uint16 *InputMethod_GetNameWin32(void); - - -SDL_InputMethod InputMethod_win32 = - { - InputMethod_AvailableWin32, - InputMethod_InitWin32, - InputMethod_QuitWin32, - InputMethod_ResetWin32, - InputMethod_ValidateWin32, - InputMethod_InvalidateWin32, - InputMethod_GetNameWin32 - }; - - -static WNDPROC OrigEditProc; -//static int32 IsValid; -static BOOL SaveOpenStatus; - -#define SYSTEM_SPECIFIC_NAME_STRING " on IMM" - -static LRESULT CALLBACK WrapProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -static int CompositionProcessing(HWND hWnd, LPARAM lParam); -static int ResultProcessing(HWND hWnd); -static int SetOpenStatusProcessing(HWND hWnd); -static int EndCompositionProcessing(HWND hWnd); -static int GetUnicodePosition(char *orgString, int cursorPosition); - - - -int GetUnicodePosition(char *orgString, int cursorPosition) -{ - char *splitString; - int unicodePosition; - - splitString = (char *)malloc(cursorPosition + 1); - if (splitString == NULL) { - return 0; - } - strncpy(splitString, orgString, cursorPosition); - splitString[cursorPosition] = '\0'; - - /* (char_num - 0x0000) * char_size */ - unicodePosition = - MultiByteToWideChar(CP_ACP, 0, splitString, -1, NULL, 0) - 1; - - free(splitString); - - return unicodePosition; -} - - -int CompositionProcessing(HWND hWnd, LPARAM lParam) -{ - char *string; - Uint16 *unicodeString; - HIMC hImc; - int needSize; - int orgCursorPosition; - int cursorPosition; - int orgCompositionPosition; - int compositionPosition; - int orgCompositionLength; - int compositionLength; - DWORD *clauses; - BYTE *attrs; - int i; - int clausesNum; - - //exit(898); - - - - hImc = ImmGetContext(hWnd); - //InputMethod_PostEvent - //note: ImmGetCompositionString changed to ImmGetCompositionStringW to ensure UNICODE compatible method is used - needSize = ImmGetCompositionStringW(hImc, GCS_COMPSTR, NULL, 0) + 1; - string = (char*)calloc(needSize+2,1); - if (string == NULL){ - ImmReleaseContext(hWnd, hImc); - return -1; - } - ImmGetCompositionStringW(hImc, GCS_COMPSTR, string, needSize); - //string[needSize - 1] = '\0'; - // fwrite(string, strlen(string), 1, stdout); - // fputc('\n', stdout); - - /* - needSize = - MultiByteToWideChar(CP_ACP, 0, string, -1, NULL, 0) - * sizeof(Uint16); - unicodeString = (Uint16*)calloc(needSize, 1); - if (unicodeString == NULL) { - ImmReleaseContext(hWnd, hImc); - free(string); - return -1; - } - MultiByteToWideChar(CP_ACP, 0, string, -1, (LPWSTR)unicodeString, needSize); - */ - unicodeString=(Uint16*)string; - - orgCompositionPosition = 0; - orgCompositionLength = 0; - compositionPosition = 0; - compositionLength = 0; - if ( (lParam & GCS_COMPCLAUSE) && (lParam & GCS_COMPATTR) ) { - - needSize = ImmGetCompositionStringW(hImc, GCS_COMPCLAUSE, NULL, 0); - clauses = (DWORD*)calloc(needSize+4,1); - ImmGetCompositionStringW(hImc, GCS_COMPCLAUSE, clauses, needSize); - /* (clauses list - total) - 1 */ - clausesNum = needSize / sizeof(DWORD) - 1; - - needSize = ImmGetCompositionStringW(hImc, GCS_COMPATTR, NULL, 0); - attrs = (BYTE*)calloc(needSize+2,1); - ImmGetCompositionStringW(hImc, GCS_COMPATTR, attrs, needSize); - - for (i = 0; i < clausesNum; i++) { - if ( - attrs[clauses[i]] == ATTR_TARGET_CONVERTED || - attrs[clauses[i]] == ATTR_TARGET_NOTCONVERTED - ) { - orgCompositionPosition = clauses[i]; - orgCompositionLength = clauses[i + 1] - clauses[i]; - break; - } - } - - free(clauses); - free(attrs); - } - - orgCursorPosition = - ImmGetCompositionStringW(hImc, GCS_CURSORPOS, NULL, 0); - cursorPosition = 0; - if (orgCursorPosition > 0) { - cursorPosition = GetUnicodePosition(string, orgCursorPosition); - } - if (orgCompositionPosition > 0) { - compositionPosition = GetUnicodePosition(string, orgCompositionPosition); - } - if (orgCompositionLength > 0) { - compositionLength = - GetUnicodePosition( - string, orgCompositionPosition + orgCompositionLength) - - compositionPosition; - } - InputMethod_PostEvent( - INPUT_METHOD_MESSAGE_CHANGE, - unicodeString, - cursorPosition, compositionPosition, compositionLength); - //free(unicodeString); - free(string); - - ImmReleaseContext(hWnd, hImc); - - return 0; -} - - -int ResultProcessing(HWND hWnd) -{ - char *string; - Uint16 *unicodeString; - int needSize; - HIMC hImc; - - hImc = ImmGetContext(hWnd); - - //note: ImmGetCompositionString changed to ImmGetCompositionStringW to ensure UNICODE compatible method is used - needSize = ImmGetCompositionStringW(hImc, GCS_RESULTSTR, NULL, 0) + 1; - string = (char*)calloc(needSize+2,1); - if (string == NULL) { - ImmReleaseContext(hWnd, hImc); - return -1; - } - ImmGetCompositionStringW(hImc, GCS_RESULTSTR, string, needSize); - - //note: commented to avoid garbling UNICODE16 string returned by ImmGetCompositionStringW - /* - needSize = - MultiByteToWideChar(CP_ACP, 0, string, -1, NULL, 0) - * sizeof(Uint16); - unicodeString = (Uint16*)malloc(needSize); - if (unicodeString == NULL) { - ImmReleaseContext(hWnd, hImc); - free(string); - return -1; - } - - MultiByteToWideChar(CP_ACP, 0, string, -1, (LPWSTR)unicodeString, needSize); - - */ - - InputMethod_PostEvent( - INPUT_METHOD_MESSAGE_RESULT, - (Uint16*)string, - 0, 0, 0); - //free(unicodeString); - free(string); - - ImmReleaseContext(hWnd, hImc); - - return 0; -} - - -int EndCompositionProcessing(HWND hWnd) -{ - HIMC hImc; - Uint16 dummy; - - hImc = ImmGetContext(hWnd); - - if (ImmGetCompositionString(hImc, GCS_RESULTSTR, NULL, 0) == 0) { - dummy = 0x0000; - InputMethod_PostEvent( - INPUT_METHOD_MESSAGE_CHANGE, - &dummy, - 0, 0, 0); - } - - ImmReleaseContext(hWnd, hImc); - - return 0; -} - - -int SetOpenStatusProcessing(HWND hWnd) -{ - HIMC hImc; - - hImc = ImmGetContext(hWnd); - - if (ImmGetOpenStatus(hImc)) { - InputMethod_PostEvent(INPUT_METHOD_MESSAGE_ON, NULL, 0, 0, 0); - } else { - InputMethod_PostEvent(INPUT_METHOD_MESSAGE_OFF, NULL, 0, 0, 0); - } - - ImmReleaseContext(hWnd, hImc); - - return 0; -} - - -static int32 deadchar_use=0; -static int32 deadchar_code=0; -static int32 ignore=0; - -LRESULT CALLBACK WrapProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - - MSG m; - HIMC hImc; - - if (IsValid == SDL_FALSE) { - switch (msg) { - case WM_IME_NOTIFY: - if (wParam == IMN_SETOPENSTATUS) { - hImc = ImmGetContext(hWnd); - ImmSetOpenStatus(hImc, FALSE); - ImmReleaseContext(hWnd, hImc); - } - break; - case WM_SYSKEYDOWN: - case WM_KEYDOWN: - - - m.hwnd = hWnd; - m.message = msg; - m.wParam = wParam; - m.lParam = lParam; - m.time = 0; - TranslateMessage(&m); - break; - default: - break; - } - return CallWindowProc(OrigEditProc, hWnd, msg, wParam, lParam); - } - - - - - switch (msg) { - case WM_IME_COMPOSITION: - if (lParam & GCS_RESULTSTR) { - ResultProcessing(hWnd); - } - if ( - (lParam & GCS_COMPSTR) || - ((lParam & GCS_COMPCLAUSE) && (lParam & GCS_COMPATTR)) - ) { - CompositionProcessing(hWnd, lParam); - } - return 0; - case WM_IME_STARTCOMPOSITION: - qb64_ime_reading=1; - return 0; - case WM_IME_ENDCOMPOSITION: - EndCompositionProcessing(hWnd); - qb64_ime_reading=2; - return 0; - case WM_IME_NOTIFY: - switch (wParam) { - case IMN_SETOPENSTATUS: - SetOpenStatusProcessing(hWnd); - break; - case IMN_OPENSTATUSWINDOW: - case IMN_CLOSESTATUSWINDOW: - case IMN_OPENCANDIDATE: - case IMN_CHANGECANDIDATE: - case IMN_CLOSECANDIDATE: - return 0; - default: - break; - } - break; - case WM_IME_SETCONTEXT: - lParam &= ~ISC_SHOWUIALL; - break; - case WM_SYSKEYDOWN: - /* - //note: translating SYSKEYDOWN messages cause windows to beep on ALT+? combinations - m.hwnd = hWnd; - m.message = msg; - m.wParam = wParam; - m.lParam = lParam; - m.time = 0; - TranslateMessage(&m); - */ - break; - - case WM_KEYUP: - /* - MEDIA_PLAY_PAUSE 0x2200 - MEDIA_STOP 0x2400 - MEDIA_NEXT_TRACK 0x1900 - MEDIA_PREV_TRACK 0x1000 - */ - if (wParam==VK_MEDIA_PLAY_PAUSE){keyup_vk(0x2200);return 0;} - if (wParam==VK_MEDIA_STOP){keyup_vk(0x2400);return 0;} - if (wParam==VK_MEDIA_NEXT_TRACK){keyup_vk(0x1900);return 0;} - if (wParam==VK_MEDIA_PREV_TRACK){keyup_vk(0x1000);return 0;} - //note: volume keys are ignored by QB64 - if (wParam==VK_VOLUME_MUTE) return 0; - if (wParam==VK_VOLUME_DOWN) return 0; - if (wParam==VK_VOLUME_UP) return 0; - //note: On early keyboards without a Pause key (before the introduction of 101-key keyboards) the Pause function was assigned to Ctrl+NumLock, and the Break function to Ctrl+ScrLock; these key-combinations still work with most programs, even on modern PCs with modern keyboards. - if (wParam==VK_PAUSE){keyup_vk(VK+QBVK_PAUSE);return 0;} - if (wParam==VK_CANCEL){keyup_vk(VK+QBVK_BREAK);return 0;} - /* - m.hwnd = hWnd; - m.message = msg; - m.wParam = wParam; - m.lParam = lParam; - m.time = 1000; - TranslateMessage(&m); - */ - break; - - case WM_CHAR: - if (deadchar_use){ - deadchar_use=0; - if (wParam==32){ - keydown_unicode(deadchar_code); - keyup_unicode(deadchar_code); - return 0;//don't allow message to be sent on to SDL - } - static long i,d,a,r; - i=0; - while (d=deadchar_lookup[i++]){ - a=deadchar_lookup[i++]; - r=deadchar_lookup[i++]; - if (deadchar_code==d){ if (wParam==a){ - keydown_unicode(r); - keyup_unicode(r); - return 0;//don't allow message to be sent on to SDL - }} - }//while - keydown_unicode(deadchar_code); - keyup_unicode(deadchar_code); - keydown_unicode(wParam); - keyup_unicode(wParam); - return 0;//don't allow message to be sent on to SDL - }//dead_char - break; - - case WM_DEADCHAR: - //showvalue(wParam); - if (deadchar_use){//double dead-char press - deadchar_use=0; - keydown_unicode(deadchar_code); - keyup_unicode(deadchar_code); - keydown_unicode(wParam); - keyup_unicode(wParam); - return 0;//don't allow message to be sent on to SDL - } - deadchar_use=1; - deadchar_code=wParam; - return 0;//don't allow message to be sent on to SDL - break; - - case WM_KEYDOWN: - - - ignore=0; - if (deadchar_use) ignore=1; - - //showvalue(wParam); - - /* - MEDIA_PLAY_PAUSE 0x2200 - MEDIA_STOP 0x2400 - MEDIA_NEXT_TRACK 0x1900 - MEDIA_PREV_TRACK 0x1000 - */ - if (wParam==VK_MEDIA_PLAY_PAUSE){keydown_vk(0x2200);return 0;} - if (wParam==VK_MEDIA_STOP){keydown_vk(0x2400);return 0;} - if (wParam==VK_MEDIA_NEXT_TRACK){keydown_vk(0x1900);return 0;} - if (wParam==VK_MEDIA_PREV_TRACK){keydown_vk(0x1000);return 0;} - //note: volume keys are ignored by QB64 - if (wParam==VK_VOLUME_MUTE) return 0; - if (wParam==VK_VOLUME_DOWN) return 0; - if (wParam==VK_VOLUME_UP) return 0; - //note: On early keyboards without a Pause key (before the introduction of 101-key keyboards) the Pause function was assigned to Ctrl+NumLock, and the Break function to Ctrl+ScrLock; these key-combinations still work with most programs, even on modern PCs with modern keyboards. - if (wParam==VK_PAUSE){keydown_vk(VK+QBVK_PAUSE);return 0;} - if (wParam==VK_CANCEL){keydown_vk(VK+QBVK_BREAK);return 0;} - - //note: IME input (eg. hiragana) will not work correctly without calling TranslateMessage - m.hwnd = hWnd; - m.message = msg; - m.wParam = wParam; - m.lParam = lParam; - m.time = 1000; - TranslateMessage(&m); - - if (ignore) return 0;//don't allow message to be sent on to SDL - - break; - - default: - break; - } - - return CallWindowProc(OrigEditProc, hWnd, msg, wParam, lParam); -} - - -SDL_bool InputMethod_AvailableWin32(void) -{ - SDL_SysWMinfo info; - HWND hWnd; - HIMC hImc; - - SDL_VERSION(&info.version); - SDL_GetWMInfo(&info); - hWnd = info.window; - hImc = ImmGetContext(hWnd); - if (hImc) { - ImmReleaseContext(hWnd, hImc); - return SDL_TRUE; - } else { - return SDL_FALSE; - } -} - - -InputMethod_Result InputMethod_InitWin32(void) -{ - - SDL_SysWMinfo info; - HWND hWnd; - - SDL_VERSION(&info.version); - SDL_GetWMInfo(&info); - hWnd = info.window; - OrigEditProc = (WNDPROC)GetWindowLong(hWnd, GWL_WNDPROC); - SetWindowLong(hWnd, GWL_WNDPROC, (LONG)WrapProc); - IsValid = 1; - - return INPUT_METHOD_SUCCESS; -} - - -void InputMethod_QuitWin32(void) -{ - SDL_SysWMinfo info; - HWND hWnd; - - SDL_VERSION(&info.version); - SDL_GetWMInfo(&info); - hWnd = info.window; - SetWindowLong(hWnd, GWL_WNDPROC, (LONG)WrapProc); -} - - -void InputMethod_ResetWin32(void) -{ - SDL_SysWMinfo info; - HWND hWnd; - HIMC hImc; - Uint16 dummy; - - SDL_VERSION(&info.version); - SDL_GetWMInfo(&info); - hWnd = info.window; - - hImc = ImmGetContext(hWnd); - - ImmNotifyIME(hImc, NI_COMPOSITIONSTR, CPS_CANCEL, 0); - - ImmReleaseContext(hWnd, hImc); - - dummy = 0x0000; - InputMethod_PostEvent(INPUT_METHOD_MESSAGE_CHANGE, &dummy, 0, 0, 0); -} - - -InputMethod_Result InputMethod_ValidateWin32(void) -{ - SDL_SysWMinfo info; - HWND hWnd; - HIMC hImc; - - IsValid = 1; - - SDL_VERSION(&info.version); - SDL_GetWMInfo(&info); - hWnd = info.window; - hImc = ImmGetContext(hWnd); - - ImmSetOpenStatus(hImc, SaveOpenStatus); - - ImmReleaseContext(hWnd, hImc); - - InputMethod_ResetWin32(); - - if (SaveOpenStatus == TRUE) { - InputMethod_PostEvent(INPUT_METHOD_MESSAGE_ON, NULL, 0, 0, 0); - } - - return INPUT_METHOD_SUCCESS; -} - - -InputMethod_Result InputMethod_InvalidateWin32(void) -{ - SDL_SysWMinfo info; - HWND hWnd; - HIMC hImc; - - SDL_VERSION(&info.version); - SDL_GetWMInfo(&info); - hWnd = info.window; - hImc = ImmGetContext(hWnd); - - SaveOpenStatus = ImmGetOpenStatus(hImc); - ImmSetOpenStatus(hImc, FALSE); - - ImmReleaseContext(hWnd, hImc); - - IsValid = SDL_FALSE; - InputMethod_ResetWin32(); - - if (SaveOpenStatus == TRUE) { - InputMethod_PostEvent(INPUT_METHOD_MESSAGE_OFF, NULL, 0, 0, 0); - } - - return INPUT_METHOD_SUCCESS; -} - - -Uint16 *InputMethod_GetNameWin32(void) -{ - SDL_SysWMinfo info; - HWND hWnd; - HIMC hImc; - HKL hKl; - char *tempString; - int length; - int needSize; - - SDL_VERSION(&info.version); - SDL_GetWMInfo(&info); - hWnd = info.window; - hImc = ImmGetContext(hWnd); - if (hImc) { - hKl = GetKeyboardLayout(0); - - length = ImmGetDescription(hKl, NULL, 0); - needSize = - length - + strlen("\"\"") - + strlen(SYSTEM_SPECIFIC_NAME_STRING) - + 1; /* '\0' */ - tempString = (char*)malloc(needSize); - strcpy(tempString, "\""); - /* get string after '\"' */ - ImmGetDescription(hKl, tempString + 1, length); - strcat(tempString, "\""); - strcat(tempString, SYSTEM_SPECIFIC_NAME_STRING); - - MultiByteToWideChar( - CP_ACP, 0, tempString, -1, - (LPWSTR)InputMethod_win32.InputMethodName, INPUT_METHOD_NAME_STRING_LENGTH); - - free(tempString); - ImmReleaseContext(hWnd, hImc); - - return InputMethod_win32.InputMethodName; - } else { - return NULL; - } - -} -//---------------------------------------------end of SDL_inputmethod for Windows-------------------------------------------------------------------- -#endif - - -#endif //NO_S_D_L - int32 exit_ok=0; //substitute Windows functionality @@ -4305,10 +2803,6 @@ uint32 palette_64[64]; //QB64 2D PROTOTYPE 1.0 -//NO_S_D_L//SDL_Surface *ts,*ts2; -//NO_S_D_L//SDL_PixelFormat pixelformat32; -//NO_S_D_L//SDL_PixelFormat pixelformat8; - int32 pages=1; int32 *page=(int32*)calloc(1,4); @@ -4378,7 +2872,6 @@ uint32 read_page_index=0; img_struct *write_page=NULL; img_struct *read_page=NULL; img_struct *display_page=NULL; -//NO_S_D_L//SDL_Surface *display_surface=NULL; uint32 *display_surface_offset=0; void restorepalette(img_struct* im){ @@ -4815,265 +3308,6 @@ int32 imgnew(int32 x,int32 y,int32 bpp){ void sub__font(int32 f,int32 i,int32 passed);//foward def -#ifndef NO_S_D_L -int32 imgload(char *filename,int32 bpp){ - static int32 i,i2,x,y,i3,z2,z3,v,v2,v3,r,g,b,a,t,needt,t2; - static uint8 *cp,*cp2; - static uint32 c; - static uint32 *lp; - - static uint8 *sr=(uint8*)malloc(256); - static uint8 *sg=(uint8*)malloc(256); - static uint8 *sb=(uint8*)malloc(256); - static uint8 *dr=(uint8*)malloc(256); - static uint8 *dg=(uint8*)malloc(256); - static uint8 *db=(uint8*)malloc(256); - static uint8 *link=(uint8*)malloc(256); - static int32 *usedcolor=(int32*)malloc(1024); - - ts=IMG_Load(filename); - if (!ts) return 0; - - if (bpp==-1){ - - if (write_page->bytes_per_pixel==1){ - if (ts->format->BytesPerPixel==1) goto compatible; - - //32-->8 bit (best possible color selection) - ts2=SDL_ConvertSurface(ts,&pixelformat32,NULL); - if (!ts2){SDL_FreeSurface(ts); return 0;} - i=imgnew(ts2->w,ts2->h,write_page->compatible_mode); - if (!i){SDL_FreeSurface(ts); return 0;} - //copy write_page's palette - memcpy(img[i].pal,write_page->pal,1024); - //find number of colors - z3=write_page->mask+1; - //build color value table - for (i3=0;i3pal[i3]; - db[i3]=c&0xFF; dg[i3]=c>>8&0xFF; dr[i3]=c>>16&0xFF; - } - - //reset color used flags - memset(usedcolor,0,1024); - needt=0; - //copy/change colors - cp=(uint8*)ts2->pixels; cp2=img[i].offset; - for (y=0;ypitch+x*4)); - a=c>>24; - if (a==0){ - needt=1; - }else{ - b=c&0xFF; g=c>>8&0xFF; r=c>>16&0xFF; v=1000; v3=0; - for (i3=0;i3pixels; cp2=img[i].offset; - for (y=0;ypitch+x*4)); - a=c>>24; if (a==0){cp2[y*img[i].width+x]=t; goto usedtranscol;} - b=c&0xFF; g=c>>8&0xFF; r=c>>16&0xFF; v=1000; v3=0; - for (i3=0;i3font,-i,1); - //adopt colors - img[i].color=write_page->color; - img[i].background_color=write_page->background_color; - //adopt print mode - img[i].print_mode=write_page->print_mode; - SDL_FreeSurface(ts2); - SDL_FreeSurface(ts); - return i; - }//write_page->bytes_per_pixel==1 - }//-1 - - if (bpp==256){ - if (ts->format->BytesPerPixel!=1){SDL_FreeSurface(ts); return 0;} - compatible: - ts2=ts; - //check for transparent color in palette - ts=SDL_ConvertSurface(ts2,&pixelformat32,NULL); - if (!ts){SDL_FreeSurface(ts2); return 0;} - //prepare image to write to - if (bpp==-1){ - i=imgnew(ts2->w,ts2->h,write_page->compatible_mode); - }else{ - i=imgnew(ts2->w,ts2->h,256); - } - if (!i){SDL_FreeSurface(ts2); SDL_FreeSurface(ts); return 0;} - //does a transparent pixel exist? - t=-1; - for (y=0;ypixels)+ts->pitch*y); - for (x=0;xpixels)+ts2->pitch*y+x); - if (cformat->palette->ncolors){ - img[i].transparent_color=c; - t=c; - goto found_transparent_color; - } - } - }} - found_transparent_color: - - //8-->8 bit (best color match) - if (bpp==-1){ - img[i].transparent_color=-1;//this will be set later if necessary - //copy write_page's palette - memcpy(img[i].pal,write_page->pal,1024); - //map image's palette to actual palette - //reset color used flags - memset(usedcolor,0,1024); - //find number of colors - z2=ts2->format->palette->ncolors; - z3=write_page->mask+1; - //build color value tables - for (i2=0;i2format->palette->colors[i2]; - sr[i2]=c&0xFF; sg[i2]=c>>8&0xFF; sb[i2]=c>>16&0xFF; - } - for (i3=0;i3pal[i3]; - db[i3]=c&0xFF; dg[i3]=c>>8&0xFF; dr[i3]=c>>16&0xFF; - } - //link colors to best matching color - for (i2=0;i2pixels; cp2=img[i].offset; - for (y=0;ypitch+x]; - if (c==t){ - needt=1; - }else{ - c=link[c]; - cp2[y*img[i].width+x]=c; - usedcolor[c]++; - } - }} - //add transparency - if (needt){ - t2=t;//backup - //find best transparent color - v=0x7FFFFFFF; - for (x=0;xpixels; cp2=img[i].offset; - for (y=0;ypitch+x]; - if (c==t2){ - cp2[y*img[i].width+x]=t; - }else{ - cp2[y*img[i].width+x]=link[c]; - } - }} - }//needt - //adopt font - sub__font(write_page->font,-i,1); - //adopt colors - img[i].color=write_page->color; - img[i].background_color=write_page->background_color; - //adopt print mode - img[i].print_mode=write_page->print_mode; - SDL_FreeSurface(ts2); - SDL_FreeSurface(ts); - return i; - }//bpp==-1 - - //copy pixel data - cp=(uint8*)ts2->pixels; cp2=img[i].offset; - for (i2=0;i2w); - cp+=ts2->pitch; - cp2+=img[i].width; - } - //update palette - for (i2=ts2->format->palette->ncolors;i2<256;i2++){img[i].pal[i2]=0xFF000000;} - for (i2=0;i2format->palette->ncolors;i2++){ - c=*(uint32*)&ts2->format->palette->colors[i2]; - c=0xFF000000+((c>>16)&255)+(c&0xFF00)+((c&255)<<16); - img[i].pal[i2]=c; - } - SDL_FreeSurface(ts2); - SDL_FreeSurface(ts); - return i; - } - - ts2=SDL_ConvertSurface(ts,&pixelformat32,NULL); - if (!ts2){SDL_FreeSurface(ts); return 0;} - i=imgnew(ts2->w,ts2->h,32); - if (!i){SDL_FreeSurface(ts2); SDL_FreeSurface(ts); return 0;} - memcpy(img[i].offset,ts2->pixels,ts2->w*ts2->h*4); - SDL_FreeSurface(ts2); SDL_FreeSurface(ts); - return i; -} - -#endif //NO_S_D_L - - - - void flush_old_hardware_commands(){ static int32 old_command; static int32 command_to_remove; @@ -6293,21 +4527,6 @@ int32 selectfont(int32 f,img_struct *im){ } - - - - - - - - - - - - - -//NO_S_D_L//SDL_Rect *modes=NULL; -//NO_S_D_L//SDL_Rect **sdl_modes; int32 nmodes=0; int32 anymode=0; @@ -6332,10 +4551,6 @@ int32 sndqueue_first=0; int32 sndqueue_wait=-1; int32 sndqueue_played=0; -//NO_S_D_L//uint32 func__sndraw(uint8* data,uint32 bytes);//called by sndsetup - - - void call_int(int32 i); @@ -7104,9 +5319,6 @@ int32 asciicode_reading=0; int32 lock_display=0; int32 lock_display_required=0; -//NO_S_D_L//SDL_Thread *thread; -//NO_S_D_L//SDL_Thread *thread2; - //cost delay, made obselete by managing thread priorities (consider removal) #define cost_limit 10000 #define cost_delay 0 @@ -7159,8 +5371,6 @@ uint32 clock_firsttimervalue;//based on program launch time uint8 wait_needed=1; -//NO_S_D_L//SDL_Surface * screen; - int32 full_screen=0;//0,1(stretched/closest),2(1:1) int32 full_screen_toggle=0;//increments each time ALT+ENTER is pressed int32 full_screen_set=-1;//0(windowed),1(stretched/closest),2(1:1) @@ -7216,43 +5426,6 @@ static const char *arrow[] = { "0,0" }; -#ifndef NO_S_D_L - -static SDL_Cursor *init_system_cursor(const char *image[]) -{ - int32 i, row, col; - Uint8 data[4*32]; - Uint8 mask[4*32]; - int32 hot_x, hot_y; - - i = -1; - for ( row=0; row<32; ++row ) { - for ( col=0; col<32; ++col ) { - if ( col % 8 ) { - data[i] <<= 1; - mask[i] <<= 1; - } else { - ++i; - data[i] = mask[i] = 0; - } - switch (image[4+row][col]) { - case 'X': - data[i] |= 0x01; - mask[i] |= 0x01;//? - break; - case '.': - mask[i] |= 0x01; - break; - case ' ': - break; - } - } - } - sscanf(image[4+row], "%d,%d", &hot_x, &hot_y); - return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y); -} - -#endif //NO_S_D_L uint8 lock_subsystem=0; @@ -7265,13 +5438,7 @@ extern uint8 stop_program; int32 global_counter=0; extern double last_line; - - - void end(void); - - - extern uint32 new_error; extern uint32 error_err; //=0; extern double error_erl; //=0; @@ -7393,21 +5560,6 @@ void fix_error(){ v=MessageBox2(NULL,errmess,errtitle,MB_YESNO|MB_SYSTEMMODAL); } -#ifndef NO_S_D_L -#ifdef QB64_WINDOWS - if (v==IDYES){ - if (full_screen){ - static SDL_SysWMinfo info; - static HWND hwnd; - SDL_VERSION(&info.version); - SDL_GetWMInfo(&info); - hwnd = info.window; - ShowWindow(hwnd,SW_SHOWMAXIMIZED); - } - } -#endif -#endif //NO_S_D_L - if ((v==IDNO)||(v==IDOK)){close_program=1; end();} new_error=0; return; @@ -7480,7 +5632,6 @@ void end(){ dont_call_sub_gl=1; exit_ok|=1; while(!stop_program) Sleep(16); - //NO_S_D_L//SDL_KillThread(thread); while(1) Sleep(16); } @@ -14888,11 +13039,6 @@ int32 file_input_chr(int32 i){ //returns -1 if eof reached (error to be externally handled) //returns -2 for other errors (internally handled), the calling function should abort - if (i<0){//TCP/IP feed buffer - //NO_S_D_L//if (tcp_feed_offset>=tcp_feed_ucbufsiz) return -1; - //NO_S_D_L//return tcp_feed_ucbuf[tcp_feed_offset++]; - } - static uint8 c; static int32 e; if (e=gfs_read(i,-1,&c,1)){ @@ -14967,44 +13113,8 @@ void sub_file_print(int32 i,qbs *str,int32 extraspace,int32 tab,int32 newline){ //note: spacing considerations such as 'extraspace' & 'tab' are ignored if (i<0){ -#ifndef NO_S_D_L - x=-(i+1); - if (x>=special_handle_max){error(52); return;} - if ((special_handle[x].type!=2)&&(special_handle[x].type!=3)){error(52); return;} - //valid tcp/ip connection - if (net_tcp[x].error) return; - //obselete message check - if ((newline==0)&&(str->len==0)) return; - //send formatted data - static uint8 header_byte; - x2=str->len; if (extraspace) x2++; - if (x2<=4){header_byte=x2; x3=0;} - if ((x2>4)&&(x2<=255)){header_byte=5; x3=1;} - if ((x2>255)&&(x2<=65535)){header_byte=6; x3=2;} - if (x2>65535){header_byte=7; x3=4;} - if (!newline){ - if (!tab){ - header_byte|=128; - } - } - //build message - static uint8 *cp; - cp=(uint8*)malloc(1+4+x2+16);//***fix - *cp=header_byte; - *((uint32*)(&cp[1]))=x2; - memcpy(&cp[1+x3],str->chr,str->len); - if (extraspace) cp[1+x3+x2-1]=32; - - x4=SDLNet_TCP_Send(net_tcp[x].socket,cp,1+x3+x2); - free(cp); - //Returns: the number of bytes sent. If the number returned is less than len, then an error occured, such as the client disconnecting. - if (x4!=(1+x3+x2)) net_tcp[x].error=1; -#endif //NO_S_D_L - return; } - - if (gfs_fileno_valid(i)!=1){error(52); return;}//Bad file name or number i=gfs_fileno[i];//convert fileno to gfs index static gfs_file_struct *gfs; @@ -15534,78 +13644,6 @@ int32 n_inputnumberfromfile(int32 fileno){ static uint32 ucbufsiz; static int32 info; - //tcp/ip? - if (fileno<0){ - -#ifndef NO_S_D_L - x=-(fileno+1); - if (x>=special_handle_max){error(52); return 3;} - if ((special_handle[x].type!=2)&&(special_handle[x].type!=3)){error(52); return 3;} - //valid tcp/ip connection - revert_input_x=x; - if (net_tcp[x].eof==2) return 3; - if (net_tcp[x].error){net_tcp[x].eof=2; return 3;} - net_tcp_updatebuffer(x); - x2=net_tcp[x].buffer_size; if (!x2){net_tcp[x].eof=2; return 3;} - i=0; - ucbuf=NULL; - ucbufsiz=0; - append_message: - x3=net_tcp[x].buffer[i]; - info=x3; - i++; - if (x3&120){ - if (ucbufsiz) free(ucbuf); - //deststr->len=0; - net_tcp[x].eof=2; - return 3; - }//invalid bits set [01111000] - x3&=7; - /* - 0 0 byte message - 1 1 byte message - 2 2 byte message - 3 3 byte message - 4 4 byte message - 5 1 byte length descriptor + ? byte message - 6 2 byte length descriptor + ? byte message - 7 4 byte length descriptor + ? byte message - */ - if (x3<=4) x4=0; - if (x3==5) x4=1; - if (x3==6) x4=2; - if (x3==7) x4=4; - if (x4){ - if (x2<(i+x4)){ - if (ucbufsiz) free(ucbuf); - net_tcp[x].eof=2; - return 3; - }//not enough data (for length descriptor) - if (x4==1) x3=*((uint8*)(net_tcp[x].buffer+i)); - if (x4==2) x3=*((uint16*)(net_tcp[x].buffer+i)); - if (x4==4) x3=*((uint32*)(net_tcp[x].buffer+i)); - i+=x4; - } - if (x2<(i+x3)){ - if (ucbufsiz) free(ucbuf); - net_tcp[x].eof=2; - return 3; - }//not enough data (for message) - //add message to buffer ucbuf - if (!ucbufsiz) ucbuf=(uint8*)malloc(x3); else ucbuf=(uint8*)realloc(ucbuf,ucbufsiz+x3); - memcpy(ucbuf+ucbufsiz,net_tcp[x].buffer+i,x3); - ucbufsiz+=x3; - i+=x3; - if (info&128) goto append_message; //append another message? - //share the 'feed' buffer - tcp_feed_ucbuf=ucbuf; - tcp_feed_ucbufsiz=ucbufsiz; - tcp_feed_offset=0; - x4=i; -#endif //NO_S_D_L - - } - if (fileno>=0){ if (gfs_fileno_valid(fileno)!=1){error(52); return 3;}//Bad file name or number fileno=gfs_fileno[fileno];//convert fileno to gfs index @@ -15730,82 +13768,18 @@ int32 n_inputnumberfromfile(int32 fileno){ if (negate_exponent) n_exp-=exponent_value; else n_exp+=exponent_value;//complete exponent if (n_digits==0) {n_exp=0; n_neg=0;}//clarify number file_input_nextitem(fileno,c); - if (fileno<0){ - -#ifndef NO_S_D_L - //adjust tcp[].buffer - //revert_input_check (tag) add data that might need to be reverted to the buffer - if (revert_input_bufsize==0){ - revert_input_buffer=(uint8*)malloc(x4); - }else{ - revert_input_buffer=(uint8*)realloc(revert_input_buffer,revert_input_bufsize+x4); - } - memmove(revert_input_buffer+revert_input_bufsize,net_tcp[x].buffer,x4); - revert_input_bufsize+=x4; - if (x2-x4) memmove(net_tcp[x].buffer,net_tcp[x].buffer+x4,x2-x4); - net_tcp[x].buffer_size-=x4; - //free ucbuf - free(ucbuf); - //set eof to 0 if previous input has not failed (success) - net_tcp[x].eof=0; -#endif //NO_S_D_L - - } return 0;//success error: file_input_nextitem(fileno,c); if (fileno<0){ -#ifndef NO_S_D_L - //free ucbuf - free(ucbuf); - //set eof - net_tcp[x].eof=2; - return 3; -#endif //NO_S_D_L - } return return_value; } void revert_input_check(){ - static uint32 x; - -#ifndef NO_S_D_L - - x=revert_input_x; - if (x==-1) return; - revert_input_x=-1;//reset for next time - - if (net_tcp[x].eof==2){ - //assign correct eof value - net_tcp[x].eof=1; - //revert tcp[x] buffer - if (revert_input_bufsize){ - //expand buffer? - if ((net_tcp[x].buffer_size+revert_input_bufsize)>net_tcp[x].buffer_space){ - if (net_tcp[x].buffer==NULL){ - net_tcp[x].buffer=(uint8*)malloc(net_tcp[x].buffer_size+revert_input_bufsize); - }else{ - net_tcp[x].buffer=(uint8*)realloc(net_tcp[x].buffer,net_tcp[x].buffer_size+revert_input_bufsize); - } - net_tcp[x].buffer_space=net_tcp[x].buffer_size+revert_input_bufsize; - } - if (net_tcp[x].buffer_size){ - memmove(net_tcp[x].buffer+revert_input_bufsize,net_tcp[x].buffer,net_tcp[x].buffer_size); - } - memcpy(net_tcp[x].buffer,revert_input_buffer,revert_input_bufsize); - net_tcp[x].buffer_size+=revert_input_bufsize; - }//bufsize>0 - }//eof==2 - - //free the buffer - if (revert_input_bufsize){revert_input_bufsize=0; free(revert_input_buffer);} - -#endif //NO_S_D_L - } void sub_file_input_string(int32 fileno,qbs *deststr){ @@ -15821,96 +13795,6 @@ void sub_file_input_string(int32 fileno,qbs *deststr){ //tcp/ip? //note: spacing considerations are ignored if (fileno<0){ - -#ifndef NO_S_D_L - - x=-(fileno+1); - if (x>=special_handle_max){error(52); return;} - if ((special_handle[x].type!=2)&&(special_handle[x].type!=3)){error(52); return;} - //valid tcp/ip connection - revert_input_x=x; - if (net_tcp[x].eof==2) return; - if (net_tcp[x].error){net_tcp[x].eof=2; return;} - - net_tcp_updatebuffer(x); - - - x2=net_tcp[x].buffer_size; - if (!x2){deststr->len=0; net_tcp[x].eof=2; return;} - - i=0; - ucbuf=NULL; - ucbufsiz=0; - append_message: - x3=net_tcp[x].buffer[i]; - info=x3; - i++; - if (x3&120){ - if (ucbufsiz) free(ucbuf); - deststr->len=0; - net_tcp[x].eof=2; - return; - }//invalid bits set [01111000] - x3&=7; - /* - 0 0 byte message - 1 1 byte message - 2 2 byte message - 3 3 byte message - 4 4 byte message - 5 1 byte length descriptor + ? byte message - 6 2 byte length descriptor + ? byte message - 7 4 byte length descriptor + ? byte message - */ - if (x3<=4) x4=0; - if (x3==5) x4=1; - if (x3==6) x4=2; - if (x3==7) x4=4; - if (x4){ - if (x2<(i+x4)){ - if (ucbufsiz) free(ucbuf); - deststr->len=0; - net_tcp[x].eof=2; - return; - }//not enough data (for length descriptor) - if (x4==1) x3=*((uint8*)(net_tcp[x].buffer+i)); - if (x4==2) x3=*((uint16*)(net_tcp[x].buffer+i)); - if (x4==4) x3=*((uint32*)(net_tcp[x].buffer+i)); - i+=x4; - } - if (x2<(i+x3)){ - if (ucbufsiz) free(ucbuf); - deststr->len=0; - net_tcp[x].eof=2; - return; - }//not enough data (for message) - //add message to buffer ucbuf - if (!ucbufsiz) ucbuf=(uint8*)malloc(x3); else ucbuf=(uint8*)realloc(ucbuf,ucbufsiz+x3); - memcpy(ucbuf+ucbufsiz,net_tcp[x].buffer+i,x3); - ucbufsiz+=x3; - i+=x3; - if (info&128) goto append_message; //append another message? - //adjust tcp[].buffer - //revert_input_check (tag) add data that might need to be reverted to the buffer - if (revert_input_bufsize==0){ - revert_input_buffer=(uint8*)malloc(i); - }else{ - revert_input_buffer=(uint8*)realloc(revert_input_buffer,revert_input_bufsize+i); - } - memmove(revert_input_buffer+revert_input_bufsize,net_tcp[x].buffer,i); - revert_input_bufsize+=i; - if (x2-i) memmove(net_tcp[x].buffer,net_tcp[x].buffer+i,x2-i); - net_tcp[x].buffer_size-=i; - - //set return string - str=qbs_new(ucbufsiz,0); - memcpy(str->chr,ucbuf,ucbufsiz); - qbs_set(deststr,str); - free(ucbuf); //free ucbuf - net_tcp[x].eof=0; - -#endif //NO_S_D_L - return; } @@ -23929,289 +21813,6 @@ int32 func__loadfont(qbs *f,int32 size,qbs *requirements,int32 passed){ } - - - - - /* 2012 - - uint8 net_tcp_init_done=0; - void net_tcp_init(){ - if (!net_tcp_init_done){ - net_tcp_init_done=1; - //NO_S_D_L//if(SDLNet_Init()==-1){ - //NO_S_D_L////assume success - //NO_S_D_L//} - } - } - - int32 func__connected(int32 i){ - if (new_error) return 0; - - #ifndef NO_S_D_L - - //validate - if (i>=0){error(52); return 0;}//Bad file name or number - i=-(i+1); - if (i>=special_handle_max){error(52); return 0;} - if ((special_handle[i].type<1)||(special_handle[i].type>3)){error(52); return 0;} - if (net_tcp[i].error) return 0; - if ((special_handle[i].type==2)||(special_handle[i].type==3)){ - net_tcp_updatebuffer(i);//attempt to trigger error state by updating buffer - if (net_tcp[i].error) return 0; - } - - #endif //NO_S_D_L - - return -1; - } - - qbs *func__connectionaddress(int32 i){ - static qbs *tqbs,*tqbs2,*str=NULL,*str2=NULL; - if (new_error) goto error; - if (!str) str=qbs_new(0,0); - if (!str2) str2=qbs_new(0,0); - - #ifndef NO_S_D_L - - //validate - if (i>=0){error(52); goto error;}//Bad file name or number - i=-(i+1); - if (i>=special_handle_max){error(52); goto error;} - if ((special_handle[i].type<1)||(special_handle[i].type>3)){error(52); goto error;} - - if (special_handle[i].type==1){//host (1) returns its own address - qbs_set(str,qbs_new_txt("TCP/IP:"));//network type - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str(net_tcp[i].portused))));//port - qbs_set(str,qbs_add(str,qbs_new_txt(":"))); - tqbs2=WHATISMYIP(); - if (tqbs2->len){ - qbs_set(str,qbs_add(str,tqbs2)); - }else{ - //global IP unavailable, use local IP - //IP4 - static IPaddress ip; - if(SDLNet_ResolveHost(&ip,"localhost",0)==-1) goto error; - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str((int32)(ip.host)&255)))); - qbs_set(str,qbs_add(str,qbs_new_txt("."))); - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str((int32)((ip.host)>>8)&255)))); - qbs_set(str,qbs_add(str,qbs_new_txt("."))); - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str((int32)((ip.host)>>16)&255)))); - qbs_set(str,qbs_add(str,qbs_new_txt("."))); - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str((int32)((ip.host)>>24)&255)))); - } - tqbs=qbs_new(str->len,1); - memmove(tqbs->chr,str->chr,str->len); - return tqbs; - } - - //assume connection/client socket (2/3) - static IPaddress *pip; - pip=SDLNet_TCP_GetPeerAddress(net_tcp[i].socket); - qbs_set(str,qbs_new_txt("TCP/IP:"));//network type - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str(net_tcp[i].portused))));//port - qbs_set(str,qbs_add(str,qbs_new_txt(":"))); - //IP4 - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str((int32)(pip->host)&255)))); - qbs_set(str,qbs_add(str,qbs_new_txt("."))); - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str((int32)((pip->host)>>8)&255)))); - qbs_set(str,qbs_add(str,qbs_new_txt("."))); - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str((int32)((pip->host)>>16)&255)))); - qbs_set(str,qbs_add(str,qbs_new_txt("."))); - qbs_set(str,qbs_add(str,qbs_ltrim(qbs_str((int32)((pip->host)>>24)&255)))); - tqbs=qbs_new(str->len,1); - memmove(tqbs->chr,str->chr,str->len); - return tqbs; - - #endif //NO_S_D_L - - error: - tqbs=qbs_new(0,1); - return tqbs; - } - - #ifndef NO_S_D_L - - - int32 func__openhost(qbs* method){ - if (new_error) return 0; - - //generic data - static qbs *s=NULL; if (!s){s=qbs_new(0,0);} - static qbs *s2=NULL; if (!s2){s2=qbs_new(0,0);} - static qbs *s3=NULL; if (!s3){s3=qbs_new(0,0);} - static double d; - static int32 i,i2,portused; - - qbs_set(s,method); - qbs_set(s2,qbs_ucase(s)); - - //TCP/IP Network - qbs_set(s3,qbs_new_txt("TCP/IP:")); - if (func_instr(NULL,s2,s3,NULL)==1){ - qbs_set(s,func_mid(s,8,NULL,NULL)); - net_tcp_init(); - //***assume*** string s contains an integer port number - static IPaddress ip; - static TCPsocket socket; - d=func_val(s); - i=qbr_double_to_long(d); - - if (cloud_app){ - if (i==cloud_port[1]) goto gotcloudport; - if (i==cloud_port[2]) goto gotcloudport; - if ((i>=1)&&(i<=2)){i=cloud_port[i]; goto gotcloudport;} - cloud_port_redirect=i; - i=cloud_port[1];//unknown values default to primary hosting port - } - gotcloudport: - - //***assume*** port number is within valid range - portused=i; - if(SDLNet_ResolveHost(&ip,NULL,i)==-1) return 0; - socket=SDLNet_TCP_Open(&ip); - if(!socket) return 0; - - i2=special_handle_new(); - special_handle[i2].type=1;//TCPIP host - if (i2>=net_tcp_bufsize) net_tcp=(net_tcp_struct*)realloc(net_tcp,sizeof(net_tcp_struct)*(++net_tcp_bufsize)); - net_tcp[i2].ip=ip; - net_tcp[i2].socket=socket; - net_tcp[i2].error=0; - net_tcp[i2].buffer=NULL; net_tcp[i2].buffer_size=0; net_tcp[i2].buffer_space=0; - net_tcp[i2].portused=i; - - return -1-i2; - - }//TCP/IP - - error(5); return 0; - - } - - int32 func__openconnection(int32 host){ - - - - static int32 i2; - - //validate host handle - host=-(host+1); - if ((host<0)||(host>=special_handle_max)){error(258); return 0;}//invalid handle - if (special_handle[host].type!=1){error(258); return 0;}//invalid handle - static TCPsocket socket; - socket=SDLNet_TCP_Accept(net_tcp[host].socket); - if (!socket) return 0; - - //create socket set for watching - static SDLNet_SocketSet set; - set=SDLNet_AllocSocketSet(1); - if (!set){ - SDLNet_TCP_Close(socket); - return 0; - } - //add socket to set - if (SDLNet_TCP_AddSocket(set,socket)!=1){ - SDLNet_FreeSocketSet(set); - SDLNet_TCP_Close(socket); - return 0; - } - - i2=special_handle_new(); - special_handle[i2].type=3;//TCPIP connection - if (i2>=net_tcp_bufsize) net_tcp=(net_tcp_struct*)realloc(net_tcp,sizeof(net_tcp_struct)*(++net_tcp_bufsize)); - net_tcp[i2].socket=socket; - net_tcp[i2].set=set; - net_tcp[i2].error=0; - net_tcp[i2].buffer=NULL; net_tcp[i2].buffer_size=0; net_tcp[i2].buffer_space=0; - net_tcp[i2].eof=0; - net_tcp[i2].portused=net_tcp[host].portused; - - return -1-i2; - - } - - int32 func__openclient(qbs* method){ - if (new_error) return 0; - - //generic data - static qbs *z=NULL; if (!z){z=qbs_new(1,0); z->chr[0]=0;} - static qbs *s=NULL; if (!s){s=qbs_new(0,0);} - static qbs *s2=NULL; if (!s2){s2=qbs_new(0,0);} - static qbs *s3=NULL; if (!s3){s3=qbs_new(0,0);} - static double d; - static int32 i,i2,portused; - - qbs_set(s,method); - qbs_set(s2,qbs_ucase(s)); - - //TCP/IP Network - qbs_set(s3,qbs_new_txt("TCP/IP:")); - if (func_instr(NULL,s2,s3,NULL)==1){ - qbs_set(s,func_mid(s,8,NULL,NULL)); - net_tcp_init(); - - //read port number - qbs_set(s3,qbs_new_txt(":")); - i=func_instr(NULL,s,s3,NULL); - if (!i){error(5); return 0;} - qbs_set(s3,func_mid(s,1,i-1,1)); qbs_set(s,func_mid(s,i+1,NULL,NULL)); - d=func_val(s3); - i2=qbr_double_to_long(d); - //***assume*** port number is within valid range - portused=i2; - - if (cloud_app){ - if (i2==cloud_port_redirect) i2=cloud_port[1]; - } - - //read address - if (!s->len){error(5); return 0;} - //null terminate address - qbs_set(s3,qbs_add(s,z)); - static IPaddress ip; - static TCPsocket socket; - if(SDLNet_ResolveHost(&ip,(char*)s3->chr,i2)==-1) return 0; - socket=SDLNet_TCP_Open(&ip); - if (!socket) return 0; - - //create socket set for watching - static SDLNet_SocketSet set; - set=SDLNet_AllocSocketSet(1); - if (!set){ - SDLNet_TCP_Close(socket); - return 0; - } - //add socket to set - if (SDLNet_TCP_AddSocket(set,socket)!=1){ - SDLNet_FreeSocketSet(set); - SDLNet_TCP_Close(socket); - return 0; - } - - i2=special_handle_new(); - special_handle[i2].type=2;//TCPIP client - if (i2>=net_tcp_bufsize) net_tcp=(net_tcp_struct*)realloc(net_tcp,sizeof(net_tcp_struct)*(++net_tcp_bufsize)); - net_tcp[i2].ip=ip; - net_tcp[i2].socket=socket; - net_tcp[i2].set=set; - net_tcp[i2].error=0; - net_tcp[i2].buffer=NULL; net_tcp[i2].buffer_size=0; net_tcp[i2].buffer_space=0; - net_tcp[i2].eof=0; - net_tcp[i2].portused=portused; - return -1-i2; - - }//TCP/IP - - error(5); return 0; - - } - - #endif //NO_S_D_L - - - 2012 */ - int32 func__exit(){ exit_blocked=1; static int32 x; @@ -26858,444 +24459,6 @@ return -1; } - - - - - - - - - - - - - - - - - - - - - - -#ifdef QB64_IME - - static int message_loop( - SDL_Event event, - SDL_Surface *screen, - SDL_Surface *back, - int *inputedWidth, - Uint16 *inputedString, - TTF_Font *font); - - static int GetUnicodeStringLength(Uint16 *unicodeString); - static Uint16 *CatUnicodeString(Uint16 *dest, Uint16 *src); - /* - static Uint16 *CopyUnicodeString(Uint16 *dest, Uint16 *src); - */ - static Uint16 *CopyNumUnicodeString(Uint16 *dest, Uint16 *src, int num); - static int DrawCursor(SDL_Surface *back, TTF_Font *font, int cursorPosition); - static int MessageChange(SDL_Surface *back, TTF_Font *font, int inputedWidth); - - - int GetUnicodeStringLength(Uint16 *unicodeString) - { - int i; - - if (unicodeString == NULL) { - return 0; - } - - i = 0; - while (unicodeString[i]) { - i++; - } - - return i; - } - - - /* - Uint16 *CopyUnicodeString(Uint16 *dest, Uint16 *src) - { - int i; - - i = 0; - while (src[i]) { - dest[i] = src[i]; - i++; - } - dest[i] = 0x0000; - - return dest; - } - */ - - - Uint16 *CopyNumUnicodeString(Uint16 *dest, Uint16 *src, int num) - { - int i; - - i = 0; - while (src[i] && i < num) { - dest[i] = src[i]; - i++; - } - dest[i] = 0x0000; - - return dest; - } - - - Uint16 *CatUnicodeString(Uint16 *dest, Uint16 *src) - { - int destCount; - int srcCount; - - destCount = 0; - srcCount = 0; - while (dest[destCount]) { - destCount++; - } - - while (src[srcCount]) { - dest[destCount] = src[srcCount]; - destCount++; - srcCount++; - } - dest[destCount] = 0x0000; - - return dest; - } - - - int DrawCursor(SDL_Surface *back, TTF_Font *font, int cursorPosition) - { - SDL_Rect rect; - ///SDL_Color bg = {0x00, 0x00, 0x00}; - ///SDL_Color cfg = {0x66, 0xFF, 0x66}; - - SDL_Color bg = {0xFF, 0xFF, 0xFF, 0xFF}; - SDL_Color cfg = {0x00, 0x00, 0x00, 0x00}; - - int cursorWidth; - SDL_Surface *surface; - - rect.x = cursorPosition; - rect.y = 0; - rect.w = 640 - cursorPosition; - rect.h = 100; - surface = TTF_RenderUTF8_Shaded(font, "|", cfg, bg); - SDL_BlitSurface(surface, NULL, back, &rect); - cursorWidth = surface->w; - SDL_FreeSurface(surface); - - return cursorWidth; - } - - - int DrawMessageBlock( - SDL_Surface *back, TTF_Font *font, Uint16 *string, - int drawStartWidth, SDL_Color fg, SDL_Color bg, int cursorPosition) - { - SDL_Rect rect; - SDL_Surface *surface; - Uint16 *splitString; - int needSize; - int stringLength; - int nowWidth; - - /* No cursor */ - if (cursorPosition == -1) { - rect.x = drawStartWidth; - rect.y = 0; - rect.w = 640 - drawStartWidth; - rect.h = 100; - surface = TTF_RenderUNICODE_Shaded(font, string, fg, bg); - - SDL_BlitSurface(surface, NULL, back, &rect); - nowWidth = surface->w; - SDL_FreeSurface(surface); - - ime_DrawMessageBlock_lastpixeloffset=drawStartWidth+nowWidth; - return nowWidth; - } - - /* Split string along cursorPosition */ - if (cursorPosition == 0) { - nowWidth = 0; - } else { - nowWidth = 0; - needSize = (cursorPosition + 1) * sizeof(Uint16); - splitString = (Uint16*)calloc(needSize, 1); - if (splitString == NULL) { - return -1; - } - memcpy(splitString, string, cursorPosition * sizeof(Uint16)); - rect.x = drawStartWidth + nowWidth; - rect.y = 0; - rect.w = 640 - (drawStartWidth + nowWidth); - rect.h = 100; - surface = TTF_RenderUNICODE_Shaded(font, splitString, fg, bg); - free(splitString); - - SDL_BlitSurface(surface, NULL, back, &rect); - nowWidth += surface->w; - SDL_FreeSurface(surface); - } - - nowWidth += DrawCursor(back, font, drawStartWidth + nowWidth); - - stringLength = - GetUnicodeStringLength(string) - cursorPosition; - if (stringLength > 0) { - needSize = (stringLength + 1) * sizeof(Uint16); - splitString = (Uint16*)calloc(needSize, 1); - if (splitString == NULL) { - return -1; - } - splitString = string + cursorPosition; - rect.x = drawStartWidth + nowWidth; - rect.y = 0; - rect.w = 640 - drawStartWidth + nowWidth; - rect.h = 100; - surface = TTF_RenderUNICODE_Shaded(font, splitString, fg, bg); - SDL_BlitSurface(surface, NULL, back, &rect); - nowWidth += surface->w; - SDL_FreeSurface(surface); - } - - - ime_DrawMessageBlock_lastpixeloffset=drawStartWidth+nowWidth; - return nowWidth; - } - - - int MessageChange(SDL_Surface *back, TTF_Font *font, int inputedWidth) - { - ///SDL_Color fg = {0x66, 0x66, 0xFF}; - ///SDL_Color bg = {0x00, 0x00, 0x00}; - - /*ref - int DrawMessageBlock( - SDL_Surface *back, TTF_Font *font, Uint16 *string, - int drawStartWidth, SDL_Color fg, SDL_Color bg, int cursorPosition) - */ - - - SDL_Color fg = {0x00, 0x00, 0x00, 0x00}; - SDL_Color bg = {0xFF, 0xFF, 0xFF, 0xFF}; - - - int compositionLastPosition; - Uint16 *firstString; - Uint16 *middleString; - Uint16 *lastString; - int firstStringCursorPosition; - int middleStringCursorPosition; - int lastStringCursorPosition; - int needSize; - int stringLength; - int width; - - compositionLastPosition = - InputMethod_GetCurrentCompositionPosition() + - InputMethod_GetCurrentCompositionLength(); - - stringLength = - GetUnicodeStringLength(InputMethod_GetCurrentEditingString()); - - if (InputMethod_GetCurrentCompositionLength() == 0) { - DrawMessageBlock( - back, font, InputMethod_GetCurrentEditingString(), - inputedWidth, fg, bg, InputMethod_GetCurrentCursorPosition()); - - - - } else if ( - InputMethod_GetCurrentCompositionPosition() == 0 && - compositionLastPosition >= stringLength - ) { - DrawMessageBlock( - back, font, InputMethod_GetCurrentEditingString(), - inputedWidth, bg, fg, InputMethod_GetCurrentCursorPosition()); - - } else if (InputMethod_GetCurrentCompositionPosition() == 0) { - needSize = - (InputMethod_GetCurrentCompositionLength() + 1) - * sizeof(Uint16); - firstString = (Uint16*)malloc(needSize); - if (firstString == NULL) { - return 0; - } - needSize = - (stringLength - InputMethod_GetCurrentCompositionLength() + 1) - * sizeof(Uint16); - lastString = (Uint16*)malloc(needSize); - if (lastString == NULL) { - free(firstString); - return 0; - } - CopyNumUnicodeString( - firstString, - InputMethod_GetCurrentEditingString(), - InputMethod_GetCurrentCompositionLength()); - CopyNumUnicodeString( - lastString, - InputMethod_GetCurrentEditingString() + - InputMethod_GetCurrentCompositionLength(), - stringLength - InputMethod_GetCurrentCompositionLength()); - if ( - InputMethod_GetCurrentCursorPosition() <= - InputMethod_GetCurrentCompositionLength() - ) { - firstStringCursorPosition = - InputMethod_GetCurrentCursorPosition(); - lastStringCursorPosition = -1; - } else { - firstStringCursorPosition = -1; - lastStringCursorPosition = - InputMethod_GetCurrentCursorPosition() - - InputMethod_GetCurrentCompositionPosition(); - } - width = DrawMessageBlock( - back, font, firstString, - inputedWidth, bg, fg, firstStringCursorPosition); - DrawMessageBlock( - back, font, lastString, - inputedWidth + width, fg, bg, lastStringCursorPosition); - free(firstString); - free(lastString); - } else if (compositionLastPosition >= stringLength) { - needSize = - (InputMethod_GetCurrentCompositionPosition() + 1) - * sizeof(Uint16); - firstString = (Uint16*)malloc(needSize); - if (firstString == NULL) { - return 0; - } - needSize = - (InputMethod_GetCurrentCompositionLength() + 1) - * sizeof(Uint16); - lastString = (Uint16*)malloc(needSize); - if (lastString == NULL) { - free(firstString); - return 0; - } - CopyNumUnicodeString( - firstString, - InputMethod_GetCurrentEditingString(), - InputMethod_GetCurrentCompositionPosition()); - CopyNumUnicodeString( - lastString, - InputMethod_GetCurrentEditingString() + - InputMethod_GetCurrentCompositionPosition(), - InputMethod_GetCurrentCompositionLength()); - if ( - InputMethod_GetCurrentCursorPosition() <= - InputMethod_GetCurrentCompositionPosition() - ) { - firstStringCursorPosition = - InputMethod_GetCurrentCursorPosition(); - lastStringCursorPosition = -1; - } else { - firstStringCursorPosition = -1; - lastStringCursorPosition = - InputMethod_GetCurrentCursorPosition() - - InputMethod_GetCurrentCompositionPosition(); - } - width = DrawMessageBlock( - back, font, firstString, - inputedWidth, fg, bg, firstStringCursorPosition); - DrawMessageBlock( - back, font, lastString, - inputedWidth + width, bg, fg, lastStringCursorPosition); - free(firstString); - free(lastString); - } else { - needSize = - (InputMethod_GetCurrentCompositionPosition() + 1) - * sizeof(Uint16); - firstString = (Uint16*)malloc(needSize); - if (firstString == NULL) { - return 0; - } - needSize = - (InputMethod_GetCurrentCompositionLength() + 1) - * sizeof(Uint16); - middleString = (Uint16*)malloc(needSize); - if (middleString == NULL) { - free(firstString); - return 0; - } - needSize = - (stringLength - compositionLastPosition + 1) - * sizeof(Uint16); - lastString = (Uint16*)malloc(needSize); - if (lastString == NULL) { - free(firstString); - free(middleString); - return 0; - } - CopyNumUnicodeString( - firstString, - InputMethod_GetCurrentEditingString(), - InputMethod_GetCurrentCompositionPosition()); - CopyNumUnicodeString( - middleString, - InputMethod_GetCurrentEditingString() + - InputMethod_GetCurrentCompositionPosition(), - InputMethod_GetCurrentCompositionLength()); - CopyNumUnicodeString( - lastString, - InputMethod_GetCurrentEditingString() + - compositionLastPosition, - stringLength - compositionLastPosition); - if ( - InputMethod_GetCurrentCursorPosition() <= - InputMethod_GetCurrentCompositionPosition() - ) { - firstStringCursorPosition = - InputMethod_GetCurrentCursorPosition(); - middleStringCursorPosition = -1; - lastStringCursorPosition = -1; - } else if ( - InputMethod_GetCurrentCursorPosition() <= - InputMethod_GetCurrentCompositionPosition() + - InputMethod_GetCurrentCompositionLength() - ) { - firstStringCursorPosition = -1; - middleStringCursorPosition = - InputMethod_GetCurrentCursorPosition(); - lastStringCursorPosition = -1; - } else { - firstStringCursorPosition = -1; - middleStringCursorPosition = -1; - lastStringCursorPosition = - InputMethod_GetCurrentCursorPosition() - - (InputMethod_GetCurrentCompositionPosition() + - InputMethod_GetCurrentCompositionLength()); - } - width = DrawMessageBlock( - back, font, firstString, - inputedWidth, fg, bg, firstStringCursorPosition); - width += DrawMessageBlock( - back, font, middleString, - inputedWidth + width, bg, fg, middleStringCursorPosition); - DrawMessageBlock( - back, font, lastString, - inputedWidth + width, fg, bg, lastStringCursorPosition); - free(firstString); - free(lastString); - } - - return 0; - } -#endif - - int32 func__keyhit(){ /* //keyhit cyclic buffer @@ -27962,150 +25125,6 @@ return -1; } -#ifndef NO_S_D_L - - //#include -#define CHUNKSIZE 1024 -#define SAMPLE_RATE 22050.0 -#define SAMP_BYTES 2 -#define CHANNELS 2 - - static bool raw_playing = 0; - static char *raw_data; - static int raw_size = 0; //size of raw_data buffer (bytes) - static int raw_reader, raw_writer; - static bool raw_dontfree = 0; - - //SDL_Mixer callback function - //must populate 'stream' with the next chunk of sound - static void raw_fill(void *dummy, Uint8 *stream, int len) - { - //assert(len == CHUNKSIZE * CHANNELS); - if (raw_reader < raw_writer && raw_reader + len > raw_writer) { - //partial chunk, zero the rest - memcpy(stream, raw_data + raw_reader, raw_writer - raw_reader); - memset(stream + (raw_writer - raw_reader), 0, len - (raw_writer - raw_reader)); - } else { - memcpy(stream, raw_data + raw_reader, len); - } - if ((raw_reader < raw_writer && raw_reader + len >= raw_writer) || (raw_writer == 0 && raw_reader + len == raw_size)) { - //out of data - Mix_HookMusic(NULL, NULL); - raw_playing = 0; - raw_reader = raw_writer = 0; - if (raw_dontfree == 0) { - free(raw_data); - raw_size = 0; - } - return; - } - raw_reader += len; - if (raw_reader >= raw_size) { - raw_reader = 0; - } - } - - //double the space of the raw sound buffer - static void raw_grow() - { - char *newptr; - raw_dontfree = 1; - SDL_UnlockAudio(); - newptr = (char *)malloc(raw_size * 2); - if (!newptr){error(257); return;} - memcpy(newptr, raw_data, raw_size); - memcpy(newptr + raw_size, raw_data, raw_size); - SDL_LockAudio(); - if (raw_writer <= raw_reader) { - raw_writer += raw_size; - } - free(raw_data); - raw_data = newptr; - raw_size *= 2; - raw_dontfree = 0; - } - - //returns the amount of sound data queued, in bytes - //assumes that raw_size is a power of 2! - static inline int raw_bytes() - { - return (raw_writer - raw_reader) & (raw_size - 1); - } - - //queue a sample - void sub__sndraw(double left,double right,int32 passed) - { - - if (!raw_size) { - sndsetup(); - raw_size = CHUNKSIZE*SAMP_BYTES*CHANNELS * 8; - raw_data = (char *) malloc(raw_size); - if (!raw_data){error(257); return;} - raw_writer = raw_reader = 0; - } - - static double sample; - static int16 clipped; - - sample = left; - if (sample >= 1.0) - clipped = 32767; - else if (sample <= -1.0) - clipped = -32768; - else - clipped = floor(sample * 32767.99999); - - //left - *(Sint16 *)&raw_data[raw_writer] = clipped; - raw_writer += SAMP_BYTES; - - if (passed){ - sample = right; - if (sample >= 1.0) - clipped = 32767; - else if (sample <= -1.0) - clipped = -32768; - else - clipped = floor(sample * 32767.99999); - } - - //right - *(Sint16 *)&raw_data[raw_writer] = clipped; - raw_writer += SAMP_BYTES; - - if (raw_writer % (CHUNKSIZE * CHANNELS) == 0) { - SDL_LockAudio(); - if (raw_writer >= raw_size) - raw_writer = 0; - if (raw_bytes() == 0) - raw_grow(); - - //ensure a reasonable amount is queued before commencing - if (!raw_playing && raw_bytes() >= CHUNKSIZE * SAMP_BYTES * CHANNELS * 4) { - raw_playing = 1; - Mix_HookMusic(raw_fill, NULL); - } - SDL_UnlockAudio(); - } - } - - //returns the length of sound queued, in seconds - double func__sndrawlen() - { - int bytes; - //This trick ensures that programs queue enough sound to trigger play - if (!raw_playing) - return 0; - SDL_LockAudio(); - bytes = raw_bytes(); - SDL_UnlockAudio(); - return bytes / (SAMP_BYTES * CHANNELS * SAMPLE_RATE); - } - - -#endif //NO_S_D_L - - void sub__depthbuffer(int32 options,int32 dst,int32 passed){ // {ON|OFF|LOCK|_CLEAR} @@ -29808,8 +26827,6 @@ render_state.cull_mode=CULL_MODE__UNKNOWN; environ_count = p - envp; } - //NO_S_D_L//memset(font,0,sizeof(font)); - fontwidth[8]=8; fontwidth[14]=8; fontwidth[16]=8; fontheight[8]=8; fontheight[14]=14; fontheight[16]=16; fontflags[8]=16; fontflags[14]=16; fontflags[16]=16;//monospace flag @@ -30053,8 +27070,6 @@ qbs_set(rootDir,func__cwd()); */ //init truetype .ttf/.fon font library - //NO_S_D_L//if (TTF_Init()==-1) exit(7000); - //NO_S_D_L//atexit(TTF_Quit); #ifdef QB64_WINDOWS //for caps lock, use the state of the lock (=1) @@ -30073,37 +27088,6 @@ qbs_set(rootDir,func__cwd()); keyhit_next=keyhit_nextfree;//skip hitkey events generated by above code #endif -#ifdef QB64_IME - //setup - SDL_Event eventExpose; - SDL_Rect rect; - int inputedWidth; - Uint16 *inputedString; - int needSize; - int stringLength; - ime_back=SDL_CreateRGBSurface(SDL_SWSURFACE,2048,32,32,0,0,0,0); if (!ime_back) exit(601); - if (InputMethod_Init()!=INPUT_METHOD_SUCCESS) exit(602); - InputMethod_InitWin32(); - imefontname=qbs_new(0,0); - qbs_set(imefontname,qbs_new_txt_len("cyberbit.ttf\0",13)); - imefontname2=qbs_new(0,0); - qbs_set(imefontname2,qbs_add(qbs_new_txt(getenv("WinDir")),qbs_new_txt_len("\\fonts\\cyberbit.ttf\0",20))); - imefontname3=qbs_new(0,0); - qbs_set(imefontname3,qbs_add(qbs_new_txt(getenv("WinDir")),qbs_new_txt_len("\\fonts\\arialuni.ttf\0",20))); - imefontname4=qbs_new(0,0); - qbs_set(imefontname4,qbs_add(qbs_new_txt(getenv("WinDir")),qbs_new_txt_len("\\fonts\\msmincho.ttf\0",20))); - inputedString = (Uint16*)malloc(sizeof(Uint16)); - inputedString[0] = 0x0000; - inputedWidth = 0; - /* possible exit options - free(inputedString); - TTF_CloseFont(ime_font); - InputMethod_Quit(); - SDL_Quit(); - */ -#endif - - //NO_S_D_L//memset(snd,0,sizeof(snd)); //init fake keyb. cyclic buffer cmem[0x41a]=30; cmem[0x41b]=0; //head @@ -30146,18 +27130,6 @@ qbs_set(rootDir,func__cwd()); //8x16 character set memcpy(&charset8x16,&file_chrset16_raw[0],file_chrset16_raw_len); -#ifndef NO_S_D_L - - //get 32bit argb pixel format - ts=SDL_CreateRGBSurface(NULL,8,8,32,0x00FF0000,0x0000FF00,0x000000FF,0xFF000000); - pixelformat32=*ts->format; - SDL_FreeSurface(ts); - ts=SDL_CreateRGBSurface(NULL,8,8,8,NULL,NULL,NULL,NULL); - pixelformat8=*ts->format; - SDL_FreeSurface(ts); - -#endif //NO_S_D_L - qbg_screen(0,NULL,NULL,NULL,NULL,1); width8050switch=1;//reaffirm switch reset by above command @@ -30514,7 +27486,6 @@ QB64_GAMEPAD_INIT(); if (shell_call_in_progress){ if (shell_call_in_progress!=-1){ shell_call_in_progress=-1; - //NO_S_D_L//if (key_repeat_on){SDL_EnableKeyRepeat(0,0); key_repeat_on=0;} goto update_display_only; } Sleep(64); @@ -30651,30 +27622,6 @@ QB64_GAMEPAD_INIT(); update^=1;//toggle update -#ifndef NO_S_D_L - - //buffered sound/play notes - //(safe even if sndsetup not called) - if (sndqueue_first!=sndqueue_next){ - if (sndqueue_played==0){ - //note: this only happens the first time a sound is ever played (through this queue) - sndqueue_played=1; - if (sndqueue_first==sndqueue_wait){suspend_program^=2; sndqueue_wait=-1;} - sub__sndplay(sndqueue[sndqueue_first]); - sndqueue_first++; - }else{ - i=sndqueue_first-1; if (i==-1) i=sndqueue_lastindex; - if (!func__sndplaying(sndqueue[i])){ - sub__sndclose(sndqueue[i]); - if (sndqueue_first==sndqueue_wait){suspend_program^=2; sndqueue_wait=-1;} - sub__sndplay(sndqueue[sndqueue_first]); - sndqueue_first++; if (sndqueue_first>sndqueue_lastindex) sndqueue_first=0; - } - } - } - -#endif //NO_S_D_L - if (!lprint){//not currently performing an LPRINT operation lprint_locked=1; if (lprint_buffered){ @@ -30707,168 +27654,6 @@ QB64_GAMEPAD_INIT(); if (update==0){ - -#ifndef NO_S_D_L - - //correct SDL key repeat error after losing input focus while a key is held - //occurs when switching to another window, SHELL-ing, etc. - //SDL_APPMOUSEFOCUS The application has mouse focus. - //SDL_APPINPUTFOCUS The application has keyboard focus - //SDL_APPACTIVE The application is visible - static int32 state; - state=SDL_GetAppState(); - if ( (!(state&SDL_APPINPUTFOCUS)) || (!(state&SDL_APPACTIVE)) ){//lost focus - if (key_repeat_on){SDL_EnableKeyRepeat(0,0); key_repeat_on=0;} - }else{ - //active - if (!key_repeat_on){SDL_EnableKeyRepeat(500,30); key_repeat_on=1;} - } - -#endif //NO_S_D_L - - -#ifdef QB64_IME - //main loop - - if (qb64_ime_reading){//load font when required - if (ime_font==NULL){ - static int32 x,failed=0; - if (!failed){ - x=fontopen(imefontname,29,0); - if (x==-1){ - x=fontopen(imefontname2,29,0); - } - if (x==-1){ - x=fontopen(imefontname3,29,0); - } - if (x==-1){ - x=fontopen(imefontname4,29,0); - } - if (x!=-1) ime_font=font[x]; else failed=1; - } - } - } - - if (InputMethod_GetEventNumber() > 0) { - rect.x = 0; - rect.y = 0; - rect.w = 2048; - rect.h = 32; - SDL_FillRect(ime_back, &rect, 0xFFFFFFFF); - - static int32 len; - static uint32 *buf=(uint32*)malloc(2); - static int32 bufsize=1; - - switch (InputMethod_GetCurrentMessage()) { - case INPUT_METHOD_MESSAGE_ON: - /* - rect.x = 0; - rect.y = 100; - rect.w = 640; - rect.h = 100; - SDL_FillRect(ime_back, &rect, 0x00000000); - surface = TTF_RenderUTF8_Shaded( - ime_font, "IME: ON", fg, bg); - SDL_BlitSurface(surface, NULL, ime_back, &rect); - SDL_FreeSurface(surface); - DrawCursor(ime_back, ime_font, inputedWidth); - */ - break; - case INPUT_METHOD_MESSAGE_CHANGE: - if (ime_font){ - MessageChange(ime_back, ime_font, inputedWidth); - } - break; - case INPUT_METHOD_MESSAGE_RESULT: - - //send UNICODE string to qb64 key handler - len=GetUnicodeStringLength(InputMethod_GetCurrentEditingString())*2; - if (len>bufsize){free(buf); buf=(uint32*)malloc(len*4+4);} - len=convert_unicode(16,InputMethod_GetCurrentEditingString(),len,32,buf); - len/=4; - for (i=0;iw; - SDL_BlitSurface(surface, NULL, ime_back, NULL); - SDL_FreeSurface(surface); - DrawCursor(ime_back, font, inputedWidth); - */ - - - break; - case INPUT_METHOD_MESSAGE_CHAR: - /* - stringLength = - GetUnicodeStringLength(inputedString) + 1; - needSize = stringLength * sizeof(Uint16) + sizeof(Uint16); - inputedString = (Uint16*)realloc(inputedString, needSize); - inputedString[stringLength - 1] = - InputMethod_GetCurrentChar(); - inputedString[stringLength] = 0x0000; - - surface = TTF_RenderUNICODE_Shaded( - ime_font, inputedString, rfg, bg); - inputedWidth = surface->w; - SDL_BlitSurface(surface, NULL, ime_back, NULL); - SDL_FreeSurface(surface); - DrawCursor(ime_back, ime_font, inputedWidth); - */ - break; - case INPUT_METHOD_MESSAGE_OFF: - /* - rect.x = 0; - rect.y = 100; - rect.w = 640; - rect.h = 100; - SDL_FillRect(ime_back, &rect, 0x00000000); - surface = TTF_RenderUTF8_Shaded( - ime_font, "IME: OFF", fg, bg); - SDL_BlitSurface(surface, NULL, ime_back, &rect); - SDL_FreeSurface(surface); - */ - break; - default: - break; - } - InputMethod_MoveNextEvent(); - eventExpose.type = SDL_VIDEOEXPOSE; - SDL_PushEvent(&eventExpose); - } -#endif - static int32 scancode; static const uint8 QBVK_2_scancode[] = { 0,0,0,0,0,0,0,0,14,15,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,57,0,0,0,0,0,0,40,0,0,0,0,51,12,52,53,11,2,3,4,5,6,7,8,9,10,0,39,0,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,43,27,0,0,41,30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,19,31,20,22,47,17,45,21,44,0,0,0,0,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,82,79,80,81,75,76,77,71,72,73,83,53,55,74,78,28,0,72,80,77,75,82,71,79,73,81,59,60,61,62,63,64,65,66,67,68,133,134,0,0,0,0,0,0,69,58,70,54,42,29,29,56,56,0,0,91,92,0,0,0,0,55,197,93,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -30913,9 +27698,6 @@ QB64_GAMEPAD_INIT(); end_program: stop_program=1; qbevent=1; -#ifndef QB64_MACOSX - //NO_S_D_L//SDL_WaitThread(thread, NULL); -#endif while (exit_ok!=3) Sleep(16); if (lprint_buffered){ @@ -31068,30 +27850,6 @@ QB64_GAMEPAD_INIT(); mode_square=-1; mode_stretch=-1; -#ifndef NO_S_D_L - - z2=0x7FFFFFFF; z3=0x7FFFFFFF; - for (i=0;i=640){ - if (modes[i].w>=x&&modes[i].h>=y){ - z=modes[i].w-x+modes[i].h-y; - //square - if (z<=z2){ - //is it square? - if (modes[i].w/4==modes[i].h/3){ - mode_square=i; z2=z; - }//square - }//z2<=z - //stretch - if (z<=z3){ - mode_stretch=i; z3=z; - }//z<=z3 - }//>x,>y - }//ignore? - }//i - -#endif //NO_S_D_L - x=display_page->width; y=display_page->height; if (display_page->compatible_mode==0){ x=display_page->width*fontwidth[display_page->font]; y=display_page->height*fontheight[display_page->font]; @@ -31101,36 +27859,8 @@ QB64_GAMEPAD_INIT(); z=0; //? conversion_required=0; -#ifndef NO_S_D_L - if ((display_surface->format->Bmask!=255)||(display_surface->format->Gmask!=65280)||(display_surface->format->Rmask!=16711680)){ - //non-BGR(A) format! - //create conversion layer - conversion_required=1; - conversion_layer=(uint32*)realloc(conversion_layer,x_monitor*y_monitor*4); - memset(conversion_layer,0,x_monitor*y_monitor*4); - display_surface_offset=conversion_layer;//redirect to conversion layer - } -#endif //NO_S_D_L - pixel=display_surface_offset;//<-will be made obselete - - - - - - - - - - - - - - - - - if (!display_page->compatible_mode){//text static int32 show_flashing_last=0; @@ -31547,7 +28277,6 @@ QB64_GAMEPAD_INIT(); } if (memcmp(display_frame[i2].bgra,display_page->offset,i)) goto update_display32b; - if (qb64_ime_reading==1) goto screen_refreshed; goto no_new_frame;//no need to update display } update_display32b:; @@ -31570,7 +28299,6 @@ QB64_GAMEPAD_INIT(); if (memcmp(pixeldata,display_page->offset,i)) goto update_display32; if (!screen_last_valid) goto update_display32; //force update because of mode change? - if (qb64_ime_reading==1) goto screen_refreshed; goto no_new_frame;//no need to update display update_display32: memcpy(pixeldata,display_page->offset,i); @@ -31656,7 +28384,6 @@ QB64_GAMEPAD_INIT(); if (memcmp(paldata,display_page->pal,i2*4)) goto update_display; //force update because of mode change? if (!screen_last_valid) goto update_display; - if (qb64_ime_reading==1) goto screen_refreshed; goto no_new_frame;//no need to update display @@ -31708,30 +28435,7 @@ QB64_GAMEPAD_INIT(); force_display_update=0; - -#ifndef NO_S_D_L -#ifdef QB64_IME - //display - if (qb64_ime_reading==1){ - static SDL_Rect drect; - drect.x = display_surface->w-ime_DrawMessageBlock_lastpixeloffset; - drect.y = 0; - drect.w = ime_DrawMessageBlock_lastpixeloffset; - drect.h = 32; - static SDL_Rect srect; - srect.x = 0; - srect.y = 0; - srect.w = ime_DrawMessageBlock_lastpixeloffset; - srect.h = 32; - SDL_BlitSurface(ime_back, &srect, display_surface, &drect); - } -#endif -#endif //NO_S_D_L - - //NO_S_D_L//SDL_UpdateRect(display_surface,0,0,0,0); - screen_last_valid=1; - if (qb64_ime_reading==1) screen_last_valid=0; //Set new display frame as ready //display_frame_end=frame_i; diff --git a/internal/c/parts/video/image/src.c b/internal/c/parts/video/image/src.c index f7d605463..b82910408 100644 --- a/internal/c/parts/video/image/src.c +++ b/internal/c/parts/video/image/src.c @@ -105,29 +105,6 @@ if (isHardware){ } return i; - - -#ifndef NO_S_D_L -static qbs *tqbs=NULL,*nullt=NULL; -static int32 i; -if (new_error) return 0; -//validate bpp -if (passed){ -if ((bpp!=32)&&(bpp!=256)){error(5); return 0;} -}else{ -if (write_page->text){error(5); return 0;} -bpp=-1; -} -if (!f->len) return -1;//return invalid handle if null length string -if (!tqbs) tqbs=qbs_new(0,0); -if (!nullt){nullt=qbs_new(1,0); nullt->chr[0]=0;} -qbs_set(tqbs,qbs_add(f,nullt)); -i=imgload(fixdir(tqbs),bpp); -if (!i) return -1;//failed -return -i; -return -1; -#endif //NO_S_D_L - } #endif diff --git a/internal/c/qbx.cpp b/internal/c/qbx.cpp index 04b772fa7..cf6205fbc 100644 --- a/internal/c/qbx.cpp +++ b/internal/c/qbx.cpp @@ -1021,7 +1021,6 @@ sub_close(NULL,NULL);//closes all open files //free images freeallimages(); //stop & free sounds (note: QB also stops any sound from the PLAY command) -//NO_S_D_L//sndcloseall(); //invalidate RETURN location(s) next_return_point=0; //reset error goto location to 'unhandled' diff --git a/source/qb64.bas b/source/qb64.bas index e52b8d702..df9f4e47e 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -9515,7 +9515,6 @@ DO IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$ NEXT PRINT #12, "skip" + u$ + ":" - PRINT #12, "revert_input_check();" IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);" layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ GOTO finishedline