jcs
/subtext
/amendments
/529
logger: Fix text selection and copying
jcs made amendment 529 about 1 year ago
--- logger.c Thu May 4 17:29:46 2023
+++ logger.c Wed Nov 8 22:06:14 2023
@@ -28,6 +28,7 @@ struct logger *logger = NULL;
void logger_layout(Rect *init_bounds);
void logger_key_down(struct focusable *focusable, EventRecord *event);
void logger_mouse_down(struct focusable *focusable, EventRecord *event);
+bool logger_menu(struct focusable *focusable, short menu, short item);
void logger_resize(struct focusable *focusable, EventRecord *event);
void logger_update(struct focusable *focusable, EventRecord *event);
void logger_resume(struct focusable *focusable, EventRecord *event);
@@ -78,6 +79,7 @@ logger_init(void)
focusable->win = logger->win;
focusable->cookie = logger;
focusable->mouse_down = logger_mouse_down;
+ focusable->menu = logger_menu;
focusable->resize = logger_resize;
focusable->update = logger_update;
focusable->quit = logger_quit;
@@ -246,11 +248,6 @@ logger_mouse_down(struct focusable *focusable, EventRe
if (PtInRect(p, &r)) {
TEClick(p, ((event->modifiers & shiftKey) != 0),
logger->messages_te);
- HLock(logger->messages_te);
- if ((*(logger->messages_te))->selStart !=
- (*(logger->messages_te))->selEnd)
- TESetSelect(0, 0, logger->messages_te);
- HUnlock(logger->messages_te);
return;
}
@@ -278,6 +275,31 @@ logger_mouse_down(struct focusable *focusable, EventRe
}
break;
}
+}
+
+bool
+logger_menu(struct focusable *focusable, short menu, short item)
+{
+ switch (menu) {
+ case EDIT_MENU_ID:
+ switch (item) {
+ case EDIT_MENU_COPY_ID:
+ HLock(logger->messages_te);
+ if ((*(logger->messages_te))->selStart ==
+ (*(logger->messages_te))->selEnd)
+ SysBeep(10);
+ else
+ TECopy(logger->messages_te);
+ HUnlock(logger->messages_te);
+ break;
+ default:
+ SysBeep(10);
+ break;
+ }
+ return true;
+ }
+
+ return false;
}
void