Compare commits

...

4 Commits

10 changed files with 292 additions and 95 deletions

View File

@ -14,14 +14,14 @@ Messages for Macintosh is built on a lot of technologies. The READMEs of each of
- [Retro68](https://github.com/autc04/Retro68) - a GCC-based cross compilation env for classic Macintosh systems
- [Nuklear Quickdraw](https://github.com/CamHenlin/nuklear-quickdraw) - a heavily modified, classic Macintosh-specific version of [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) allowing a simple way to provide GUI services
- [CoprocessorJS](https://github.com/CamHenlin/coprocessor.js) - a library that allows us to handle nodejs workloads sent over a serial port
- [CoprocessorJS](https://github.com/CamHenlin/coprocessor.js) - a library that allows us to handle nodejs workloads sent over a serial port to talk to [supporting software](https://github.com/CamHenlin/imessagegraphqlserver)
- [serialperformanceanalyzer](https://github.com/CamHenlin/serialperformanceanalyzer) - used to analyze the performance of many different parts of the application
## Limitations / areas for improvement
Messages for Macintosh is not perfect. Here are some known limitations and things that could be improved:
- 10 conversations at a time, with the ability to open a new conversation if you know the recipient's address book entry
- Up to the most 15 recent messages are displayed in your selected chat. No pagination
- 10 conversations at a time, with the ability to open a new conversation if you know the recipient's address book entry. Nuklear supports scrolling and we could likely add more to the list, but the performance may begin degrading on 68000-based systems.
- Up to the most 15 recent messages are displayed in your selected chat. No pagination. Nuklear supports scrolling so we could add more messages, but again it may be slow on 68000-based systems if we do that
- No image / emoji support (although emojis are generally translated to text)
## Pull requests and issues welcome

View File

@ -12,7 +12,7 @@
IOParam outgoingSerialPortReference;
IOParam incomingSerialPortReference;
// #define PRINT_ERRORS 1
#define DEBUGGING 1
// #define DEBUGGING 1
#define MAX_ATTEMPTS 10
#define RECEIVE_WINDOW_SIZE 32767 // receive in up to 32kb chunks
#define MAX_RECEIVE_SIZE 32767 // matching RECEIVE_WINDOW_SIZE for now

Binary file not shown.

Binary file not shown.

View File

@ -25,7 +25,7 @@
// #define MAC_APP_DEBUGGING
// #define PROFILING 1
#define DEBUG_FUNCTION_CALLS
// #define DEBUG_FUNCTION_CALLS
#ifdef PROFILING
OSErr writeSerialPortProfile(const char* str)
@ -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;

File diff suppressed because one or more lines are too long

View File

@ -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;
}
};

View File

@ -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);
}

View File

@ -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;
}

View File

@ -28,7 +28,7 @@
#define ENABLED_DOUBLE_BUFFERING
#define COMMAND_CACHING
#include "nuklear.h"
#define NK_QUICKDRAW_GRAPHICS_DEBUGGING
// #define NK_QUICKDRAW_GRAPHICS_DEBUGGING
// #define DRAW_BLIT_LOCATION
Boolean lastInputWasBackspace;
@ -495,12 +495,14 @@ void updateBounds(int top, int bottom, int left, int right) {
writeSerialPortDebug(boutRefNum, "DEBUG_FUNCTION_CALLS: runDrawCommand");
#endif
char x[255];
sprintf(x, "cmd: %d", cmd->type);
writeSerialPortDebug(boutRefNum, x);
char y[255];
sprintf(y, "lastCmd: %d", lastCmd->type);
writeSerialPortDebug(boutRefNum, y);
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
char x[255];
sprintf(x, "cmd: %d", cmd->type);
writeSerialPortDebug(boutRefNum, x);
char y[255];
sprintf(y, "lastCmd: %d", lastCmd->type);
writeSerialPortDebug(boutRefNum, y);
#endif
switch (cmd->type) {
@ -562,7 +564,6 @@ void updateBounds(int top, int bottom, int left, int right) {
// http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-102.html#MARKER-9-372
// http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-103.html#HEADING103-0
const struct nk_command_rect *r = (const struct nk_command_rect *)cmd;
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT2");
#ifdef COMMAND_CACHING
@ -575,26 +576,21 @@ void updateBounds(int top, int bottom, int left, int right) {
break;
}
#endif
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT3");
ForeColor(r->color);
PenSize(r->line_thickness, r->line_thickness);
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT4");
Rect quickDrawRectangle;
quickDrawRectangle.top = r->y;
quickDrawRectangle.left = r->x;
quickDrawRectangle.bottom = r->y + r->h;
quickDrawRectangle.right = r->x + r->w;
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT5");
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
#endif
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT6");
FrameRoundRect(&quickDrawRectangle, r->rounding, r->rounding);
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT7 (done)");
}
break;
@ -606,10 +602,8 @@ void updateBounds(int top, int bottom, int left, int right) {
#endif
const struct nk_command_rect_filled *r = (const struct nk_command_rect_filled *)cmd;
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED1");
if (r->allowCache == false) {
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED2");
Rect quickDrawRectangle;
quickDrawRectangle.top = r->y;
@ -617,17 +611,14 @@ void updateBounds(int top, int bottom, int left, int right) {
quickDrawRectangle.bottom = r->y + r->h;
quickDrawRectangle.right = r->x + r->w;
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED3");
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
#endif
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED4");
FillRoundRect(&quickDrawRectangle, r->rounding, r->rounding, &qd.white);
break;
}
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED5");
#ifdef COMMAND_CACHING
if (!lastInputWasBackspace && cmd->type == lastCmd->type && memcmp(r, lastCmd, sizeof(struct nk_command_rect_filled)) == 0) {
@ -640,7 +631,6 @@ void updateBounds(int top, int bottom, int left, int right) {
}
#endif
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED6");
// TODO: to support coloring the lines, we need to map from qd Pattern types to integer colors
// color = nk_color_to_quickdraw_bw_color(r->color);
// ForeColor(color);
@ -654,18 +644,12 @@ void updateBounds(int top, int bottom, int left, int right) {
quickDrawRectangle.bottom = r->y + r->h;
quickDrawRectangle.right = r->x + r->w;
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED7");
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
#endif
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED8");
FillRoundRect(&quickDrawRectangle, r->rounding, r->rounding, &r->color);
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED9");
FrameRoundRect(&quickDrawRectangle, r->rounding, r->rounding); // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-105.html#HEADING105-0
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED10 (done)");
}
break;
@ -1104,30 +1088,7 @@ void updateBounds(int top, int bottom, int left, int right) {
}
#ifdef COMMAND_CACHING
int lastCalls = 0;
int currentCalls;
const struct nk_command *lastCmd;
Boolean VALID_COMMANDS[18] = {
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true
};
#endif
NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
@ -1136,10 +1097,6 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
writeSerialPortDebug(boutRefNum, "DEBUG_FUNCTION_CALLS: nk_quickdraw_render");
#endif
#ifdef COMMAND_CACHING
currentCalls = 1;
#endif
#ifdef PROFILING
PROFILE_START("IN nk_quickdraw_render");
#endif
@ -1195,7 +1152,7 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
writeSerialPortDebug(boutRefNum, "COMMAND_CACHING: get next cached command");
#endif
if (currentCalls < lastCalls && lastCmd && VALID_COMMANDS[lastCmd->type]) {
if (lastCmd && lastCmd->next) {
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
writeSerialPortDebug(boutRefNum, "COMMAND_CACHING: inside conditional");
@ -1207,7 +1164,6 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
writeSerialPortDebug(boutRefNum, "COMMAND_CACHING: done getting lastCmd");
#endif
currentCalls++;
#endif
}
@ -1228,7 +1184,6 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
#endif
#ifdef COMMAND_CACHING
lastCalls = currentCalls;
lastInputWasBackspace = false;
#endif