From: Alex M. <ale...@us...> - 2004-12-22 20:25:48
|
Update of /cvsroot/win32forth/win32forth-extsrc/extsrc/w32fConsole In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22808/extsrc/w32fConsole Added Files: Console.cpp Console.def Console.dsp Console.dsw Console.rc HAND.CUR Keyboard.cpp MAGNIFY.CUR SPLITH.CUR SPLITV.CUR StdAfx.cpp StdAfx.h Term.cpp Term.h harrow.cur resource.h Log Message: Commit of base Win32Forth-extsrc --- NEW FILE: Keyboard.cpp --- // $Id: Keyboard.cpp,v 1.1 2004/12/22 20:25:25 alex_mcdonald Exp $ // Window Keyboard IO // Andrew McKewan -- March 1994 // 07-18-95 SMuB fixed window resizing. #include "stdafx.h" //################################################################################################# //################################################################################################# // Global Variables //################################################################################################# //################################################################################################# static long *g_byefunc = NULL; // pointer to callback for bye static long *g_msgfunc = NULL; // pointer to callback static HWND g_hWndMain = NULL; // handle to the main window, initially zero //################################################################################################# //################################################################################################# //################################################################################################# //################################################################################################# extern int APIENTRY c_emit (char c); //################################################################################################# //################################################################################################# //################################################################################################# //################################################################################################# //************************************************************************************************* // Bye() - close console window and exit forth //************************************************************************************************* static void Bye( void ) { // execute bye in the kernel if( g_byefunc != NULL && *g_byefunc != NULL ) { BYEFUNC func = (BYEFUNC)*g_byefunc; (*func)(); } else { ExitProcess( 0 ); } } //################################################################################################# //################################################################################################# // Keyboard Input //################################################################################################# //################################################################################################# #define kblength 256 unsigned long keybuf[kblength]; // circular keypad buffer unsigned long head = 0, tail = 0; #define next(x) ((x + 1) % kblength) //************************************************************************************************* //************************************************************************************************* int APIENTRY k_key( void ) { long c; MSG msg; while (head == tail) { if( !GetMessage (&msg, NULL, 0, 0) ) Bye(); if( g_msgfunc != NULL && *g_msgfunc != NULL ) { // call forth message handler MSGFUNC msgfunc = (MSGFUNC)*g_msgfunc; (*msgfunc)(&msg); } else { // default handler TranslateMessage( &msg ); DispatchMessage( &msg ); } } c = keybuf[tail]; tail = next (tail); return c; } //************************************************************************************************* //************************************************************************************************* int APIENTRY k_keyq( void ) { long c; MSG msg; while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT ) Bye(); if( g_msgfunc != NULL && *g_msgfunc != 0 ) { // call forth message handler MSGFUNC msgfunc = (MSGFUNC)*g_msgfunc; (*msgfunc)(&msg); } else { // default handler TranslateMessage (&msg); DispatchMessage (&msg); } } if( head != tail ) { c = keybuf[tail]; return c; } return 0; } //************************************************************************************************* // push a character into the keyboard typeahead buffer //************************************************************************************************* void pushkey( long thekey ) { if (next(head) == tail) Beep(500, 100); // buffer full else { if( (GetKeyState (VK_SHIFT) & 0x8000) && (thekey < 32) ) // if shift is down thekey |= shift_mask; // then include the shift bit keybuf[head] = thekey; head = next(head); } } //************************************************************************************************* // push a character into the keyboard typeahead buffer //************************************************************************************************* int APIENTRY k_fpushkey( long thekey ) { if( next(head) == tail ) Beep(500, 100); // buffer full else { keybuf[head] = thekey; head = next(head); } PostMessage( g_hWndMain, WM_NULL, thekey, 0 ); return 0; } //************************************************************************************************* // push a character with shift mask into the keyboard buffer //************************************************************************************************* void spushkey( long thekey ) { if( next(head) == tail ) Beep(500, 100); // buffer full else { if (GetKeyState (VK_CONTROL) & 0x8000) // if control is down thekey |= control_mask; // then include control bit if (GetKeyState (VK_SHIFT) & 0x8000) // if shift is down thekey |= shift_mask; // then include the shift bit keybuf[head] = thekey; head = next(head); } } //************************************************************************************************* // test and push function and special keys //************************************************************************************************* void pushfunctionkey( long thekey ) { switch (thekey) { case VK_F1: spushkey(function_mask | 0x01); break; case VK_F2: spushkey(function_mask | 0x02); break; case VK_F3: spushkey(function_mask | 0x03); break; case VK_F4: spushkey(function_mask | 0x04); break; case VK_F5: spushkey(function_mask | 0x05); break; case VK_F6: spushkey(function_mask | 0x06); break; case VK_F7: spushkey(function_mask | 0x07); break; case VK_F8: spushkey(function_mask | 0x08); break; case VK_F9: spushkey(function_mask | 0x09); break; case VK_F10: spushkey(function_mask | 0x10); break; case VK_F11: spushkey(function_mask | 0x11); break; case VK_F12: spushkey(function_mask | 0x12); break; case VK_HOME: spushkey(special_mask | 0x00); break; case VK_END: spushkey(special_mask | 0x01); break; case VK_INSERT: spushkey(special_mask | 0x02); break; case VK_DELETE: spushkey(special_mask | 0x03); break; case VK_LEFT: spushkey(special_mask | 0x04); break; case VK_RIGHT: spushkey(special_mask | 0x05); break; case VK_UP: spushkey(special_mask | 0x06); break; case VK_DOWN: spushkey(special_mask | 0x07); break; case VK_SCROLL: spushkey(special_mask | 0x08); break; case VK_PAUSE: spushkey(special_mask | 0x09); break; case VK_PRIOR: spushkey(special_mask | 0x10); break; case VK_NEXT: spushkey(special_mask | 0x11); break; default : ; } } //################################################################################################# //################################################################################################# // Line Input //################################################################################################# //################################################################################################# //************************************************************************************************* //************************************************************************************************* int APIENTRY k_accept( char *addr, int len ) { int c; int n = 0; while( (c = k_key()) != CR ) { if( c == BS ) { if( n ) { c_emit(BS); c_emit(BL); c_emit(BS); --n; } else { Beep(500, 100); } } else { if( n < len && c >= BL ) { c_emit( (char)c ); *(addr + n) = (char)c; ++n; } else { Beep(500, 100); } } } c_emit(BL); return n; } //################################################################################################# //################################################################################################# // Initialization //################################################################################################# //################################################################################################# //************************************************************************************************* // init Keyboard I/O //************************************************************************************************* int APIENTRY k_initkeyboard( HWND hWndMain, long *msgfunc, long *bye ) { g_hWndMain = hWndMain; g_msgfunc = msgfunc; g_byefunc = bye; return 1; } --- NEW FILE: Term.cpp --- // $Id: Term.cpp,v 1.1 2004/12/22 20:25:25 alex_mcdonald Exp $ // Window Terminal Output // Andrew McKewan -- March 1994 // 07-18-95 SMuB fixed window resizing. #include "stdafx.h" //################################################################################################# //################################################################################################# //################################################################################################# //################################################################################################# //################################################################################################# //################################################################################################# // Global Variables //################################################################################################# //################################################################################################# char MainClassName[] = "Win32Forth"; [...1185 lines suppressed...] wndclass.lpszClassName = ConsoleClassName; iRet = RegisterClass( &wndclass ); if( iRet == 0 ) return 0; // create console window hWndMain = CreateWindow( MainClassName, // window class name WindowTitle, // window caption WS_OVERLAPPEDWINDOW, // window style pos.left, pos.top, (pos.right - pos.left), (pos.bottom - pos.top), NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL) ; // creation parameters return (int)hWndMain; } --- NEW FILE: SPLITV.CUR --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Console.rc --- //Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // Deutsch (Deutschland) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) #ifdef _WIN32 LANGUAGE LANG_GERMAN, SUBLANG_GERMAN #pragma code_page(1252) #endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 6,9,0,15 PRODUCTVERSION 6,9,0,15 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x40004L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "000004e4" BEGIN VALUE "Comments", "\0" VALUE "CompanyName", "Win32Forth developer team\0" VALUE "FileDescription", "Win32Forth console\0" VALUE "FileVersion", "6, 9, 0, 15\0" VALUE "InternalName", "CONSOLE\0" VALUE "LegalCopyright", "\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "w32fConsole.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "Win32Forth\0" VALUE "ProductVersion", "6, 9, 0, 15\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0, 1252 END END #endif // !_MAC ///////////////////////////////////////////////////////////////////////////// // // Cursor // IDC_HAND_CURSOR CURSOR DISCARDABLE "HAND.CUR" IDC_HARROW CURSOR DISCARDABLE "harrow.cur" IDC_MAGNIFY CURSOR DISCARDABLE "MAGNIFY.CUR" IDC_SPLITH CURSOR DISCARDABLE "SPLITH.CUR" IDC_SPLITV CURSOR DISCARDABLE "SPLITV.CUR" ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. ICON_FORTH ICON DISCARDABLE "..\\..\\res\\Win32For.ico" #endif // Deutsch (Deutschland) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED --- NEW FILE: SPLITH.CUR --- (This appears to be a binary file; contents omitted.) --- NEW FILE: HAND.CUR --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Console.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Console.def --- LIBRARY W32FCONSOLE EXPORTS c_initconsole k_initkeyboard k_key k_keyq k_accept k_fpushkey c_emit c_type c_cr c_qcr c_cls c_gotoxy c_getxy c_getcolrow c_setfgbg c_thescreen c_charwh c_resize c_setcursorheight c_getcursorheight c_wscroll c_rowoffset c_maxcolrow c_setmaxcolrow c_setcharwh c_mark c_getfg c_getbg c_sizestate --- NEW FILE: Console.dsw --- (This appears to be a binary file; contents omitted.) --- NEW FILE: MAGNIFY.CUR --- (This appears to be a binary file; contents omitted.) --- NEW FILE: harrow.cur --- (This appears to be a binary file; contents omitted.) --- NEW FILE: StdAfx.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: StdAfx.cpp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Term.h --- // $Id: Term.h,v 1.1 2004/12/22 20:25:26 alex_mcdonald Exp $ #define BL 32 #define BELL 7 #define BS 8 #define CR 13 #define LF 10 #define function_mask 0x10000 #define special_mask 0x20000 #define control_mask 0x40000 #define shift_mask 0x80000 #define alt_mask 0x100000 #define mouse_mask 0x200000 #define menu_mask 0x400000 #define proc_mask 0x800000 #define double_mask 0x1000000 #define down_mask 0x2000000 #define up_mask 0x4000000 typedef void (__stdcall *MSGFUNC) (MSG*); typedef int (__stdcall *WINMSGFUNC) (HWND, UINT, UINT, LONG); typedef void (__stdcall *BYEFUNC) (); --- NEW FILE: Console.dsp --- # Microsoft Developer Studio Project File - Name="Console" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** NICHT BEARBEITEN ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=Console - Win32 Debug !MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE !MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl !MESSAGE !MESSAGE NMAKE /f "Console.mak". !MESSAGE !MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben !MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: !MESSAGE !MESSAGE NMAKE /f "Console.mak" CFG="Console - Win32 Debug" !MESSAGE !MESSAGE Für die Konfiguration stehen zur Auswahl: !MESSAGE !MESSAGE "Console - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") !MESSAGE "Console - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "Console - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CONSOLE_EXPORTS" /Yu"stdafx.h" /FD /c # ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CONSOLE_EXPORTS" /FR /Yu"stdafx.h" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "NDEBUG" # ADD RSC /l 0x407 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\w32fConsole.dll" !ELSEIF "$(CFG)" == "Console - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CONSOLE_EXPORTS" /Yu"stdafx.h" /FD /GZ /c # ADD CPP /nologo /MT /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CONSOLE_EXPORTS" /FR /Yu"stdafx.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x407 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\w32fConsole.dll" /pdbtype:sept !ENDIF # Begin Target # Name "Console - Win32 Release" # Name "Console - Win32 Debug" # Begin Group "Quellcodedateien" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\Console.cpp # End Source File # Begin Source File SOURCE=.\Console.def # End Source File # Begin Source File SOURCE=.\Keyboard.cpp # End Source File # Begin Source File SOURCE=.\StdAfx.cpp # ADD CPP /Yc"stdafx.h" # End Source File # Begin Source File SOURCE=.\Term.cpp # End Source File # End Group # Begin Group "Header-Dateien" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\StdAfx.h # End Source File # Begin Source File SOURCE=.\Term.h # End Source File # End Group # Begin Group "Ressourcendateien" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # Begin Source File SOURCE=.\Console.rc # End Source File # Begin Source File SOURCE=.\HAND.CUR # End Source File # Begin Source File SOURCE=.\harrow.cur # End Source File # Begin Source File SOURCE=.\icon1.ico # End Source File # Begin Source File SOURCE=.\MAGNIFY.CUR # End Source File # Begin Source File SOURCE=.\SPLITH.CUR # End Source File # Begin Source File SOURCE=.\SPLITV.CUR # End Source File # Begin Source File SOURCE=.\WIN32FOR.ICO # End Source File # Begin Source File SOURCE=..\..\res\Win32For.ico # End Source File # End Group # End Target # End Project --- NEW FILE: resource.h --- //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by Console.rc // #define ICON_FORTH 100 #define IDI_ICON1 101 #define IDC_SPLITV 114 #define IDC_SPLITH 115 #define IDC_MAGNIFY 116 #define IDC_HAND_CURSOR 119 #define IDC_HARROW 120 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 104 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif |