diff --git a/dist/MessagesForMacintosh.dsk b/dist/MessagesForMacintosh.dsk index 4392d5e..33548c7 100644 Binary files a/dist/MessagesForMacintosh.dsk and b/dist/MessagesForMacintosh.dsk differ diff --git a/dist/MessagesForMacintosh.zip b/dist/MessagesForMacintosh.zip index 72d9f5a..d9bf129 100644 Binary files a/dist/MessagesForMacintosh.zip and b/dist/MessagesForMacintosh.zip differ diff --git a/mac_main.c b/mac_main.c index ab0e0d1..c632472 100644 --- a/mac_main.c +++ b/mac_main.c @@ -147,8 +147,10 @@ int main() { Initialize(); /* initialize the program */ UnloadSeg((Ptr) Initialize); /* note that Initialize must not be in Main! */ - setupDebugSerialPort(boutRefNum); - writeSerialPortDebug(boutRefNum, "initializing messages for macintosh"); + #ifdef MAC_APP_DEBUGGING + setupDebugSerialPort(boutRefNum); + writeSerialPortDebug(boutRefNum, "initializing messages for macintosh"); + #endif // run our nuklear app one time to render the window telling us to be patient for the coprocessor // app to load up @@ -161,7 +163,10 @@ int main() char programResult[MAX_RECEIVE_SIZE]; sendProgramToCoprocessor((char *)OUTPUT_JS, programResult); - writeSerialPortDebug(boutRefNum, "coprocessor loaded"); + + #ifdef MAC_APP_DEBUGGING + writeSerialPortDebug(boutRefNum, "coprocessor loaded"); + #endif coprocessorLoaded = 1; @@ -198,7 +203,7 @@ void EventLoop(struct nk_context *ctx) ShowCursor(); } - // check for new stuff every 10 sec? + // check for new stuff every x sec? // note! this is used by some of the functionality in our nuklear_app to trigger // new chat lookups if (TickCount() - lastUpdatedTickCountMessagesInChat > 300) { @@ -597,7 +602,7 @@ void AdjustMenus() if ( IsDAWindow(window) ) /* we can allow desk accessories to be closed from the menu */ EnableItem(menu, iClose); else - DisableItem(menu, iClose); /* but not our traffic light window */ + DisableItem(menu, iClose); /* but not our messages window */ menu = GetMenuHandle(mEdit); if ( IsDAWindow(window) ) { /* a desk accessory might need the edit menuÉ */ @@ -615,12 +620,16 @@ void AdjustMenus() } menu = GetMenuHandle(mLight); - if ( IsAppWindow(window) ) { /* we know that it must be the traffic light */ - EnableItem(menu, iStop); - EnableItem(menu, iGo); + if ( IsAppWindow(window) ) { /* this is the messages menu */ + EnableItem(menu, NEW_MESSAGE); + EnableItem(menu, RESET_CHAT_LIST); + EnableItem(menu, REFRESH_MESSAGES); + EnableItem(menu, CLEAR_CHAT_INPUT); } else { - DisableItem(menu, iStop); - DisableItem(menu, iGo); + DisableItem(menu, NEW_MESSAGE); + DisableItem(menu, RESET_CHAT_LIST); + DisableItem(menu, REFRESH_MESSAGES); + DisableItem(menu, CLEAR_CHAT_INPUT); } } /*AdjustMenus*/ @@ -680,6 +689,14 @@ void DoMenuCommand(menuResult) case 2: getChats(); break; + case 3: + getMessages(activeChat, 0); + break; + case 4: + memset(box_input_buffer, '\0', 2048); + box_input_len = 0; + forceRedrawMessages = 3; + break; default: sendNewChat = 1; break; diff --git a/mac_main.h b/mac_main.h index df9137a..eafcea2 100644 --- a/mac_main.h +++ b/mac_main.h @@ -1 +1,213 @@ -/*------------------------------------------------------------------------------ # # Apple Macintosh Developer Technical Support # # MultiFinder-Aware Simple Sample Application # # Sample # # Sample.h - Rez and C Include Source # # Copyright © 1989 Apple Computer, Inc. # All rights reserved. # # Versions: # 1.00 08/88 # 1.01 11/88 # 1.02 04/89 MPW 3.1 # # Components: # Sample.p April 1, 1989 # Sample.c April 1, 1989 # Sample.a April 1, 1989 # Sample.inc1.a April 1, 1989 # SampleMisc.a April 1, 1989 # Sample.r April 1, 1989 # Sample.h April 1, 1989 # [P]Sample.make April 1, 1989 # [C]Sample.make April 1, 1989 # [A]Sample.make April 1, 1989 # # Sample is an example application that demonstrates how to # initialize the commonly used toolbox managers, operate # successfully under MultiFinder, handle desk accessories, # and create, grow, and zoom windows. # # It does not by any means demonstrate all the techniques # you need for a large application. In particular, Sample # does not cover exception handling, multiple windows/documents, # sophisticated memory management, printing, or undo. All of # these are vital parts of a normal full-sized application. # # This application is an example of the form of a Macintosh # application; it is NOT a template. It is NOT intended to be # used as a foundation for the next world-class, best-selling, # 600K application. A stick figure drawing of the human body may # be a good example of the form for a painting, but that does not # mean it should be used as the basis for the next Mona Lisa. # # We recommend that you review this program or TESample before # beginning a new application. ------------------------------------------------------------------------------*/ /* These #defines correspond to values defined in the Pascal source code. Sample.c and Sample.r include this file. */ /* Determining an application's minimum size to request from MultiFinder depends on many things, each of which can be unique to an application's function, the anticipated environment, the developer's attitude of what constitutes reasonable functionality and performance, etc. Here is a list of some things to consider when determining the minimum size (and preferred size) for your application. The list is pretty much in order of importance, but by no means complete. 1. What is the minimum size needed to give almost 100 percent assurance that the application won't crash because it ran out of memory? This includes not only things that you do have direct control over such as checking for NIL handles and pointers, but also things that some feel are not so much under their control such as QuickDraw and the Segment Loader. 2. What kind of performance can a user expect from the application when it is running in the minimum memory configuration? Performance includes not only speed in handling data, but also things like how many documents can be opened, etc. 3. What are the typical sizes of scraps [is a boy dog] that a user might wish to work with when lauching or switching to your application? If the amount of memory is too small, the scrap may get lost [will have to be shot]. This can be quite frustrating to the user. 4. The previous items have concentrated on topics that tend to cause an increase in the minimum size to request from MultiFinder. On the flip side, however, should be the consideration of what environments the application may be running in. There may be a high probability that many users with relatively small memory configurations will want to avail themselves of your application. Or, many users might want to use it while several other, possibly related/complementary applications are running. If that is the case, it would be helpful to have a fairly small minimum size. So, what did we decide on Sample? First, Sample has little risk of running out of memory once it starts. Second, performance isn't much of an issue since it doesn't do much and multiple windows are not allowed. Third, there are no edit operations in Sample itself, so we just want to provide enough space for a reasonable scrap to survive between desk accessory launches. Lastly, Sample should intrude as little as possible, so the effort should be towards making it as small as possible. We looked at some heap dumps while the application was running under various partition sizes. With a size of 23K, there was approximately 8-9K free, which is a good 'slop' factor in an application like this which doesn't do much, but where we'd still like the scrap to survive most of the time. */ #define MAXLONG 2147483648 #define kMinSize 88 /* application's minimum size (in K) */ /* We made the preferred size bigger than the minimum size by 12K, so that there would be even more room for the scrap, FKEYs, etc. */ #define kPrefSize 100 /* application's preferred size (in K) */ #define rMenuBar 128 /* application's menu bar */ #define rAboutAlert 128 /* about alert */ #define rUserAlert 129 /* error user alert */ #define rWindow 128 /* application's window */ #define rStopRect 128 /* rectangle for Stop light */ #define rGoRect 130 /* rectangle for Go light */ #define rXRect 129 /* rectangle for X light */ /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the SysEnvRec we understand. */ #define kSysEnvironsVersion 1 /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent by MultiFinder. Once we determine that an event is an osEvent, we look at the high byte of the message sent to determine which kind it is. To differentiate suspend and resume events we check the resumeMask bit. */ #define kOSEvent app4Evt /* event used by MultiFinder */ #define kSuspendResumeMessage 1 /* high byte of suspend/resume event message */ #define kResumeMask 1 /* bit of message field for resume vs. suspend */ #define kMouseMovedMessage 0xFA /* high byte of mouse-moved event message */ #define kNoEvents 0 /* no events mask */ /* The following constants are used to identify menus and their items. The menu IDs have an "m" prefix and the item numbers within each menu have an "i" prefix. */ #define mApple 128 /* Apple menu */ #define iAbout 1 #define mFile 129 /* File menu */ #define iNew 1 #define iClose 4 #define iQuit 12 #define mEdit 130 /* Edit menu */ #define iUndo 1 #define iCut 3 #define iCopy 4 #define iPaste 5 #define iClear 6 #define mLight 131 /* Light menu */ #define mHelp 132 /* Light menu */ #define iQuickHelp 1 #define iUserGuide 2 #define iStop 1 #define iGo 2 /* 1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */ #define kDITop 0x0050 #define kDILeft 0x0070 /* 1.01 - kMinHeap - This is the minimum result from the following equation: ORD(GetApplLimit) - ORD(ApplicZone) for the application to run. It will insure that enough memory will be around for reasonable-sized scraps, FKEYs, etc. to exist with the application, and still give the application some 'breathing room'. To derive this number, we ran under a MultiFinder partition that was our requested minimum size, as given in the 'SIZE' resource. */ #define kMinHeap 21 * 1024 /* 1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called at initialization time, for the application to run. This number acts as a double-check to insure that there really is enough memory for the application to run, including what has been taken up already by pre-loaded resources, the scrap, code, and other sundry memory blocks. */ #define kMinSpace 8 * 1024 /* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */ #define kExtremeNeg -32768 #define kExtremePos 32767 - 1 /* required to address an old region bug */ /* these #defines are used to set enable/disable flags of a menu */ #define AllItems 0b1111111111111111111111111111111 /* 31 flags */ #define NoItems 0b0000000000000000000000000000000 #define MenuItem1 0b0000000000000000000000000000001 #define MenuItem2 0b0000000000000000000000000000010 #define MenuItem3 0b0000000000000000000000000000100 #define MenuItem4 0b0000000000000000000000000001000 #define MenuItem5 0b0000000000000000000000000010000 #define MenuItem6 0b0000000000000000000000000100000 #define MenuItem7 0b0000000000000000000000001000000 #define MenuItem8 0b0000000000000000000000010000000 #define MenuItem9 0b0000000000000000000000100000000 #define MenuItem10 0b0000000000000000000001000000000 #define MenuItem11 0b0000000000000000000010000000000 #define MenuItem12 0b0000000000000000000100000000000 \ No newline at end of file +/*------------------------------------------------------------------------------ +# +# Apple Macintosh Developer Technical Support +# +# MultiFinder-Aware Simple Sample Application +# +# Sample +# +# Sample.h - Rez and C Include Source +# +# Copyright © 1989 Apple Computer, Inc. +# All rights reserved. +# +# Versions: +# 1.00 08/88 +# 1.01 11/88 +# 1.02 04/89 MPW 3.1 +# +# Components: +# Sample.p April 1, 1989 +# Sample.c April 1, 1989 +# Sample.a April 1, 1989 +# Sample.inc1.a April 1, 1989 +# SampleMisc.a April 1, 1989 +# Sample.r April 1, 1989 +# Sample.h April 1, 1989 +# [P]Sample.make April 1, 1989 +# [C]Sample.make April 1, 1989 +# [A]Sample.make April 1, 1989 +# +# Sample is an example application that demonstrates how to +# initialize the commonly used toolbox managers, operate +# successfully under MultiFinder, handle desk accessories, +# and create, grow, and zoom windows. +# +# It does not by any means demonstrate all the techniques +# you need for a large application. In particular, Sample +# does not cover exception handling, multiple windows/documents, +# sophisticated memory management, printing, or undo. All of +# these are vital parts of a normal full-sized application. +# +# This application is an example of the form of a Macintosh +# application; it is NOT a template. It is NOT intended to be +# used as a foundation for the next world-class, best-selling, +# 600K application. A stick figure drawing of the human body may +# be a good example of the form for a painting, but that does not +# mean it should be used as the basis for the next Mona Lisa. +# +# We recommend that you review this program or TESample before +# beginning a new application. +------------------------------------------------------------------------------*/ + +/* These #defines correspond to values defined in the Pascal source code. + Sample.c and Sample.r include this file. */ + +/* Determining an application's minimum size to request from MultiFinder depends + on many things, each of which can be unique to an application's function, + the anticipated environment, the developer's attitude of what constitutes + reasonable functionality and performance, etc. Here is a list of some things to + consider when determining the minimum size (and preferred size) for your + application. The list is pretty much in order of importance, but by no means + complete. + + 1. What is the minimum size needed to give almost 100 percent assurance + that the application won't crash because it ran out of memory? This + includes not only things that you do have direct control over such as + checking for NIL handles and pointers, but also things that some + feel are not so much under their control such as QuickDraw and the + Segment Loader. + + 2. What kind of performance can a user expect from the application when + it is running in the minimum memory configuration? Performance includes + not only speed in handling data, but also things like how many documents + can be opened, etc. + + 3. What are the typical sizes of scraps [is a boy dog] that a user might + wish to work with when lauching or switching to your application? If + the amount of memory is too small, the scrap may get lost [will have + to be shot]. This can be quite frustrating to the user. + + 4. The previous items have concentrated on topics that tend to cause an + increase in the minimum size to request from MultiFinder. On the flip + side, however, should be the consideration of what environments the + application may be running in. There may be a high probability that + many users with relatively small memory configurations will want to + avail themselves of your application. Or, many users might want to use it + while several other, possibly related/complementary applications are + running. If that is the case, it would be helpful to have a fairly + small minimum size. + + So, what did we decide on Sample? First, Sample has little risk of + running out of memory once it starts. Second, performance isn't much + of an issue since it doesn't do much and multiple windows are not + allowed. Third, there are no edit operations in Sample itself, so we + just want to provide enough space for a reasonable scrap to survive + between desk accessory launches. Lastly, Sample should intrude as little + as possible, so the effort should be towards making it as small as possible. + We looked at some heap dumps while the application was running under + various partition sizes. With a size of 23K, there was approximately + 8-9K free, which is a good 'slop' factor in an application like this + which doesn't do much, but where we'd still like the scrap to survive + most of the time. */ + +#define MAXLONG 2147483648 + +#define kMinSize 88 /* application's minimum size (in K) */ + +/* We made the preferred size bigger than the minimum size by 12K, so that + there would be even more room for the scrap, FKEYs, etc. */ + +#define kPrefSize 100 /* application's preferred size (in K) */ + +#define rMenuBar 128 /* application's menu bar */ +#define rAboutAlert 128 /* about alert */ +#define rUserAlert 129 /* error user alert */ +#define rWindow 128 /* application's window */ +#define rStopRect 128 /* rectangle for Stop light */ +#define rGoRect 130 /* rectangle for Go light */ +#define rXRect 129 /* rectangle for X light */ + +/* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the + SysEnvRec we understand. */ + +#define kSysEnvironsVersion 1 + +/* kOSEvent is the event number of the suspend/resume and mouse-moved events sent + by MultiFinder. Once we determine that an event is an osEvent, we look at the + high byte of the message sent to determine which kind it is. To differentiate + suspend and resume events we check the resumeMask bit. */ + +#define kOSEvent app4Evt /* event used by MultiFinder */ +#define kSuspendResumeMessage 1 /* high byte of suspend/resume event message */ +#define kResumeMask 1 /* bit of message field for resume vs. suspend */ +#define kMouseMovedMessage 0xFA /* high byte of mouse-moved event message */ +#define kNoEvents 0 /* no events mask */ + +/* The following constants are used to identify menus and their items. The menu IDs + have an "m" prefix and the item numbers within each menu have an "i" prefix. */ + +#define mApple 128 /* Apple menu */ +#define iAbout 1 + +#define mFile 129 /* File menu */ +#define iNew 1 +#define iClose 4 +#define iQuit 12 + +#define mEdit 130 /* Edit menu */ +#define iUndo 1 +#define iCut 3 +#define iCopy 4 +#define iPaste 5 +#define iClear 6 + +#define mLight 131 /* Light menu */ + +#define mHelp 132 /* Light menu */ + +#define iQuickHelp 1 +#define iUserGuide 2 + +#define NEW_MESSAGE 1 +#define RESET_CHAT_LIST 2 +#define REFRESH_MESSAGES 3 +#define CLEAR_CHAT_INPUT 4 + +/* 1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */ + +#define kDITop 0x0050 +#define kDILeft 0x0070 + +/* 1.01 - kMinHeap - This is the minimum result from the following + equation: + + ORD(GetApplLimit) - ORD(ApplicZone) + + for the application to run. It will insure that enough memory will + be around for reasonable-sized scraps, FKEYs, etc. to exist with the + application, and still give the application some 'breathing room'. + To derive this number, we ran under a MultiFinder partition that was + our requested minimum size, as given in the 'SIZE' resource. */ + +#define kMinHeap 21 * 1024 + +/* 1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called + at initialization time, for the application to run. This number acts + as a double-check to insure that there really is enough memory for the + application to run, including what has been taken up already by + pre-loaded resources, the scrap, code, and other sundry memory blocks. */ + +#define kMinSpace 8 * 1024 + +/* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */ + +#define kExtremeNeg -32768 +#define kExtremePos 32767 - 1 /* required to address an old region bug */ + +/* these #defines are used to set enable/disable flags of a menu */ + +#define AllItems 0b1111111111111111111111111111111 /* 31 flags */ +#define NoItems 0b0000000000000000000000000000000 +#define MenuItem1 0b0000000000000000000000000000001 +#define MenuItem2 0b0000000000000000000000000000010 +#define MenuItem3 0b0000000000000000000000000000100 +#define MenuItem4 0b0000000000000000000000000001000 +#define MenuItem5 0b0000000000000000000000000010000 +#define MenuItem6 0b0000000000000000000000000100000 +#define MenuItem7 0b0000000000000000000000001000000 +#define MenuItem8 0b0000000000000000000000010000000 +#define MenuItem9 0b0000000000000000000000100000000 +#define MenuItem10 0b0000000000000000000001000000000 +#define MenuItem11 0b0000000000000000000010000000000 +#define MenuItem12 0b0000000000000000000100000000000 diff --git a/mac_main.r b/mac_main.r index 5818583..748820e 100644 --- a/mac_main.r +++ b/mac_main.r @@ -139,6 +139,10 @@ resource 'MENU' (mLight, preload) { noicon, nokey, nomark, plain; "Refresh Chat List", noicon, nokey, nomark, plain; + "Refresh Messages", + noicon, nokey, nomark, plain; + "Clear Chat Input", + noicon, nokey, nomark, plain; } }; diff --git a/nuklear.h b/nuklear.h index 727a4fb..6b03e7f 100644 --- a/nuklear.h +++ b/nuklear.h @@ -17111,14 +17111,14 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out, cursor.y -= edit->scrollbar.y; nk_fill_rect(out, cursor, 0, cursor_color, true); - // #ifdef COMMAND_CACHING - // struct nk_rect whiteTextarea2; - // whiteTextarea2.x = cursor.x + cursor.w; - // whiteTextarea2.y = cursor.y - 2; - // whiteTextarea2.h = cursor.h + 6; - // whiteTextarea2.w = 9; //cursor.w * 2; // this was previously used when cursor.w = 4, doesn't work well at = 1 - // nk_fill_rect(out, whiteTextarea2, 0, qd.black, false); - // #endif + #ifdef COMMAND_CACHING + struct nk_rect whiteTextarea2; + whiteTextarea2.x = cursor.x + cursor.w; + whiteTextarea2.y = cursor.y - 2; + whiteTextarea2.h = cursor.h + 6; + whiteTextarea2.w = 9; //cursor.w * 2; // this was previously used when cursor.w = 4, doesn't work well at = 1 + nk_fill_rect(out, whiteTextarea2, 0, qd.black, false); + #endif } else { /* draw cursor inside text */ // short glyph_len; @@ -17175,14 +17175,14 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out, // background_color = whiteColor; // else // background_color = background; - // #ifdef COMMAND_CACHING - // struct nk_rect whiteTextarea; - // whiteTextarea.x = area.x; - // whiteTextarea.y = area.y; - // whiteTextarea.h = area.h; - // whiteTextarea.w = area.w; - // nk_fill_rect(out, whiteTextarea, 0, qd.black, false); - // #endif + #ifdef COMMAND_CACHING + struct nk_rect whiteTextarea; + whiteTextarea.x = area.x; + whiteTextarea.y = area.y; + whiteTextarea.h = area.h; + whiteTextarea.w = area.w; + nk_fill_rect(out, whiteTextarea, 0, qd.black, false); + #endif nk_edit_draw_text(out, style, area.x - edit->scrollbar.x, area.y - edit->scrollbar.y, 0, begin, l, row_height, font, style->normal, style->text_normal, nk_false, true); } diff --git a/nuklear_app.c b/nuklear_app.c index c17633d..6972ec8 100644 --- a/nuklear_app.c +++ b/nuklear_app.c @@ -189,7 +189,9 @@ void getChats() { while (token != NULL) { - writeSerialPortDebug(boutRefNum, token); + #ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING + writeSerialPortDebug(boutRefNum, token); + #endif sprintf(&chatFriendlyNames[chatFriendlyNamesCounter++ * MAX_FRIENDLY_NAME_LENGTH], "%s", token); token = (char *)strtokm(NULL, ","); } @@ -249,8 +251,6 @@ void getChatCounts() { writeSerialPortDebug(boutRefNum, "DEBUG_FUNCTION_CALLS: getChatCounts"); #endif - writeSerialPortDebug(boutRefNum, "getChatCounts!"); - callFunctionOnCoprocessor("getChatCounts", "", chatCountFunctionResponse); #ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING @@ -261,7 +261,10 @@ void getChatCounts() { // bail out if the responses ARE equal if (!strcmp(chatCountFunctionResponse, previousChatCountFunctionResponse)) { - writeSerialPortDebug(boutRefNum, "no need to update current chat count"); + #ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING + writeSerialPortDebug(boutRefNum, "no need to update current chat count"); + #endif + return; } @@ -415,13 +418,19 @@ void getHasNewMessagesInChat(char *thread) { if (!strcmp(jsFunctionResponse, "true")) { - writeSerialPortDebug(boutRefNum, "update current chat"); + #ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING + writeSerialPortDebug(boutRefNum, "update current chat"); + #endif + SysBeep(1); getMessages(thread, 0); - } else { - - writeSerialPortDebug(boutRefNum, "do not update current chat"); } + #ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING + else { + + writeSerialPortDebug(boutRefNum, "do not update current chat"); + } + #endif return; }