mirror of
https://github.com/CamHenlin/MessagesForMacintosh.git
synced 2025-02-19 11:31:10 +00:00
get TEST_MODE working in coprocessorjs module
This commit is contained in:
parent
c88d6037b5
commit
d806e62373
@ -299,7 +299,7 @@ const parseChatsToFriendlyNameString = (chats) => {
|
||||
|
||||
let lastMessageOutput
|
||||
|
||||
const TEST_MESSAGES = [
|
||||
let TEST_MESSAGES = [
|
||||
{chatter: `friend 1`, text: `my super fun text message`},
|
||||
{chatter: `me`, text: `some cool old thing I said earlier`},
|
||||
{chatter: `friend 2`, text: `this message is not relevant to the conversation! not at all :(`},
|
||||
@ -387,7 +387,7 @@ class iMessageClient {
|
||||
|
||||
if (TEST_MODE) {
|
||||
|
||||
TEST_MESSAGES = TEST_MESSAGES.concat({sender: `me`, text: message})
|
||||
TEST_MESSAGES = TEST_MESSAGES.concat({chatter: `me`, text: message})
|
||||
|
||||
return splitMessages(TEST_MESSAGES)
|
||||
}
|
||||
@ -465,7 +465,7 @@ class iMessageClient {
|
||||
|
||||
if (TEST_MODE) {
|
||||
|
||||
return
|
||||
return `success`
|
||||
}
|
||||
|
||||
try {
|
||||
|
47
mac_main.c
47
mac_main.c
@ -90,6 +90,8 @@ void PROFILE_COMPLETE() {
|
||||
|
||||
#include "SerialHelper.h"
|
||||
#include "Quickdraw.h"
|
||||
#include "output_js.h"
|
||||
#include "coprocessorjs.h"
|
||||
|
||||
#include "nuklear_app.c"
|
||||
|
||||
@ -104,7 +106,6 @@ Boolean gHasWaitNextEvent; /* set up by Initialize */
|
||||
/* GInBackground is maintained by our osEvent handling routines. Any part of
|
||||
the program can check it to find out if it is currently in the background. */
|
||||
Boolean gInBackground; /* maintained by Initialize and DoEvent */
|
||||
Boolean gotMouseEvent;
|
||||
|
||||
// #define MAC_APP_DEBUGGING
|
||||
/* The following globals are the state of the window. If we supported more than
|
||||
@ -153,6 +154,14 @@ void main()
|
||||
|
||||
SysBeep(1);
|
||||
|
||||
setupCoprocessor("nuklear", "modem"); // could also be "printer", modem is 0 in PCE settings - printer would be 1
|
||||
// we could build a nuklear window for selection
|
||||
|
||||
char programResult[MAX_RECEIVE_SIZE];
|
||||
sendProgramToCoprocessor(OUTPUT_JS, programResult);
|
||||
|
||||
coprocessorLoaded = 1;
|
||||
|
||||
EventLoop(ctx); /* call the main event loop */
|
||||
}
|
||||
|
||||
@ -170,8 +179,6 @@ void EventLoop(struct nk_context *ctx)
|
||||
int lastMouseHPos = 0;
|
||||
int lastMouseVPos = 0;
|
||||
int lastUpdatedTickCount = 0;
|
||||
Boolean firstOrMouseMove = true;
|
||||
gotMouseEvent = false;
|
||||
|
||||
do {
|
||||
|
||||
@ -181,6 +188,21 @@ void EventLoop(struct nk_context *ctx)
|
||||
// PROFILE_START("eventloop");
|
||||
// #endif
|
||||
|
||||
// check for new stuff every 10 sec?
|
||||
// note! this is used by some of the functionality in our nuklear_app to trigger
|
||||
// new chat lookups
|
||||
if (TickCount() - lastUpdatedTickCount > 600) {
|
||||
|
||||
// writeSerialPortDebug(boutRefNum, "update by tick count");
|
||||
lastUpdatedTickCount = TickCount();
|
||||
|
||||
if (strcmp(activeChat, "no active chat")) {
|
||||
|
||||
// writeSerialPortDebug(boutRefNum, "check chat");
|
||||
getHasNewMessagesInChat(activeChat);
|
||||
}
|
||||
}
|
||||
|
||||
Boolean beganInput = false;
|
||||
|
||||
GetGlobalMouse(&mouse);
|
||||
@ -214,6 +236,9 @@ void EventLoop(struct nk_context *ctx)
|
||||
firstOrMouseMove = true;
|
||||
beganInput = true;
|
||||
|
||||
mouse_x = tempPoint.h;
|
||||
mouse_y = tempPoint.v;
|
||||
|
||||
lastUpdatedTickCount = TickCount();
|
||||
lastMouseHPos = mouse.h;
|
||||
lastMouseVPos = mouse.v;
|
||||
@ -222,6 +247,7 @@ void EventLoop(struct nk_context *ctx)
|
||||
} else {
|
||||
|
||||
gotEvent = GetNextEvent(everyEvent, &event);
|
||||
gotMouseEvent = false;
|
||||
|
||||
// drain all events before rendering -- really this only applies to keyboard events and single mouse clicks now
|
||||
while (gotEvent) {
|
||||
@ -289,14 +315,7 @@ void EventLoop(struct nk_context *ctx)
|
||||
PROFILE_START("nk_quickdraw_render");
|
||||
#endif
|
||||
|
||||
GetGlobalMouse(&mouse);
|
||||
|
||||
// if the mouse is moving, don't try to render. we'll likely have more rendering to do when
|
||||
// the user stops moving the mouse
|
||||
if (lastMouseVPos == mouse.v || lastMouseHPos == mouse.h) {
|
||||
|
||||
nk_quickdraw_render(FrontWindow(), ctx);
|
||||
}
|
||||
nk_quickdraw_render(FrontWindow(), ctx);
|
||||
|
||||
#ifdef PROFILING
|
||||
PROFILE_END("nk_quickdraw_render");
|
||||
@ -341,6 +360,8 @@ void DoEvent(EventRecord *event, struct nk_context *ctx) {
|
||||
|
||||
case mouseUp:
|
||||
|
||||
gotMouseEvent = true;
|
||||
|
||||
#ifdef MAC_APP_DEBUGGING
|
||||
writeSerialPortDebug(boutRefNum, "mouseup");
|
||||
#endif
|
||||
@ -621,7 +642,9 @@ void DoMenuCommand(menuResult)
|
||||
handledByDA = SystemEdit(menuItem-1); /* since we donÕt do any Editing */
|
||||
break;
|
||||
case mLight:
|
||||
// example handling for menu item
|
||||
// note this was co-opted to send new chats instead of the demo functionality. do the
|
||||
// same thing for other menu items as necessary
|
||||
sendNewChat = 1;
|
||||
break;
|
||||
|
||||
case mHelp:
|
||||
|
@ -38,6 +38,7 @@ void aFailed(char *file, int line) {
|
||||
#include <Types.h>
|
||||
#include "nuklear.h"
|
||||
#include "nuklear_quickdraw.h"
|
||||
#include "coprocessorjs.h"
|
||||
|
||||
#define MAX_CHAT_MESSAGES 16
|
||||
|
||||
|
@ -1019,10 +1019,10 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
|
||||
#endif
|
||||
|
||||
if (!t->allowCache) {
|
||||
// if (!t->allowCache) {
|
||||
|
||||
EraseRect(&quickDrawRectangle);
|
||||
}
|
||||
// }
|
||||
|
||||
color = nk_color_to_quickdraw_bw_color(t->foreground);
|
||||
ForeColor(color);
|
||||
|
Loading…
x
Reference in New Issue
Block a user