| @@ -38,7 +38,6 @@ · 37 unmodified lines |
| 38 | 38 | extern void flushmemscreen(Rectangle); |
| 39 | 39 | |
| 40 | 40 | Memimage *gscreen; |
| 41 | | −//Screeninfo screen; |
| 42 | 41 | |
| 43 | 42 | static int readybit; |
| 44 | 43 | static Rendez rend; |
| @@ -74,7 +73,7 @@ isready(void*a) · 29 unmodified lines |
| 74 | 73 | |
| 75 | 74 | CGContextRef QuartzContext; |
| 76 | 75 | |
| 77 | | −void winproc(void *a); |
| 76 | +static void winproc(void *a); |
| 78 | 77 | |
| 79 | 78 | void |
| 80 | 79 | screeninit(void) |
| @@ -115,16 +114,16 @@ screeninit(void) · 34 unmodified lines |
| 115 | 114 | static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); |
| 116 | 115 | static OSStatus MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); |
| 117 | 116 | |
| 118 | | −void |
| 117 | +void |
| 119 | 118 | window_resized(void) |
| 120 | 119 | { |
| 121 | | − GetWindowBounds(theWindow, kWindowContentRgn, &winRect ); |
| 120 | + GetWindowBounds(theWindow, kWindowContentRgn, &winRect); |
| 122 | 121 | |
| 123 | 122 | bounds = CGRectMake(0, 0, winRect.right-winRect.left, winRect.bottom - winRect.top); |
| 124 | 123 | } |
| 125 | 124 | |
| 126 | 125 | |
| 127 | | −void |
| 126 | +static void |
| 128 | 127 | winproc(void *a) |
| 129 | 128 | { |
| 130 | 129 | MenuItemIndex index; |
| @@ -152,7 +151,7 @@ winproc(void *a) · 21 unmodified lines |
| 152 | 151 | AppendMenuItemTextWithCFString(viewMenu, CFSTR("Full Screen"), 0, |
| 153 | 152 | kFullScreenCmd, &index); |
| 154 | 153 | SetMenuItemCommandKey(viewMenu, index, 0, 'F'); |
| 155 | | − AppendMenuItemTextWithCFString(viewMenu, CFSTR("ctrl-opt to return"), |
| 154 | + AppendMenuItemTextWithCFString(viewMenu, CFSTR("ctrl-opt to return"), |
| 156 | 155 | kMenuItemAttrDisabled, |
| 157 | 156 | kFullScreenCmd, &index); |
| 158 | 157 | InsertMenu(viewMenu, GetMenuID(windMenu)); |
| @@ -221,53 +220,53 @@ static int · 62 unmodified lines |
| 221 | 220 | convert_key(UInt32 key, UInt32 charcode) |
| 222 | 221 | { |
| 223 | 222 | switch(key) { |
| 224 | | − case QZ_IBOOK_ENTER: |
| 225 | | − case QZ_RETURN: return '\n'; |
| 226 | | − case QZ_ESCAPE: return 27; |
| 227 | | − case QZ_BACKSPACE: return '\b'; |
| 228 | | − case QZ_LALT: return Kalt; |
| 229 | | − case QZ_LCTRL: return Kctl; |
| 230 | | − case QZ_LSHIFT: return Kshift; |
| 231 | | − case QZ_F1: return KF+1; |
| 232 | | − case QZ_F2: return KF+2; |
| 233 | | − case QZ_F3: return KF+3; |
| 234 | | − case QZ_F4: return KF+4; |
| 235 | | − case QZ_F5: return KF+5; |
| 236 | | − case QZ_F6: return KF+6; |
| 237 | | − case QZ_F7: return KF+7; |
| 238 | | − case QZ_F8: return KF+8; |
| 239 | | − case QZ_F9: return KF+9; |
| 240 | | − case QZ_F10: return KF+10; |
| 241 | | − case QZ_F11: return KF+11; |
| 242 | | − case QZ_F12: return KF+12; |
| 243 | | − case QZ_INSERT: return Kins; |
| 244 | | − case QZ_DELETE: return '0'; |
| 245 | | − case QZ_HOME: return Khome; |
| 246 | | − case QZ_END: return Kend; |
| 247 | | − case QZ_KP_PLUS: return '+'; |
| 248 | | − case QZ_KP_MINUS: return '-'; |
| 249 | | − case QZ_TAB: return '\t'; |
| 250 | | − case QZ_PAGEUP: return Kpgup; |
| 251 | | − case QZ_PAGEDOWN: return Kpgdown; |
| 252 | | − case QZ_UP: return Kup; |
| 253 | | − case QZ_DOWN: return Kdown; |
| 254 | | − case QZ_LEFT: return Kleft; |
| 255 | | − case QZ_RIGHT: return Kright; |
| 256 | | − case QZ_KP_MULTIPLY: return '*'; |
| 257 | | − case QZ_KP_DIVIDE: return '/'; |
| 258 | | − case QZ_KP_ENTER: return '\b'; |
| 259 | | − case QZ_KP_PERIOD: return '.'; |
| 260 | | − case QZ_KP0: return '0'; |
| 261 | | − case QZ_KP1: return '1'; |
| 262 | | − case QZ_KP2: return '2'; |
| 263 | | − case QZ_KP3: return '3'; |
| 264 | | − case QZ_KP4: return '4'; |
| 265 | | − case QZ_KP5: return '5'; |
| 266 | | − case QZ_KP6: return '6'; |
| 267 | | − case QZ_KP7: return '7'; |
| 268 | | − case QZ_KP8: return '8'; |
| 269 | | − case QZ_KP9: return '9'; |
| 270 | | − default: return charcode; |
| 223 | + case QZ_IBOOK_ENTER: |
| 224 | + case QZ_RETURN: return '\n'; |
| 225 | + case QZ_ESCAPE: return 27; |
| 226 | + case QZ_BACKSPACE: return '\b'; |
| 227 | + case QZ_LALT: return Kalt; |
| 228 | + case QZ_LCTRL: return Kctl; |
| 229 | + case QZ_LSHIFT: return Kshift; |
| 230 | + case QZ_F1: return KF+1; |
| 231 | + case QZ_F2: return KF+2; |
| 232 | + case QZ_F3: return KF+3; |
| 233 | + case QZ_F4: return KF+4; |
| 234 | + case QZ_F5: return KF+5; |
| 235 | + case QZ_F6: return KF+6; |
| 236 | + case QZ_F7: return KF+7; |
| 237 | + case QZ_F8: return KF+8; |
| 238 | + case QZ_F9: return KF+9; |
| 239 | + case QZ_F10: return KF+10; |
| 240 | + case QZ_F11: return KF+11; |
| 241 | + case QZ_F12: return KF+12; |
| 242 | + case QZ_INSERT: return Kins; |
| 243 | + case QZ_DELETE: return 0x7F; |
| 244 | + case QZ_HOME: return Khome; |
| 245 | + case QZ_END: return Kend; |
| 246 | + case QZ_KP_PLUS: return '+'; |
| 247 | + case QZ_KP_MINUS: return '-'; |
| 248 | + case QZ_TAB: return '\t'; |
| 249 | + case QZ_PAGEUP: return Kpgup; |
| 250 | + case QZ_PAGEDOWN: return Kpgdown; |
| 251 | + case QZ_UP: return Kup; |
| 252 | + case QZ_DOWN: return Kdown; |
| 253 | + case QZ_LEFT: return Kleft; |
| 254 | + case QZ_RIGHT: return Kright; |
| 255 | + case QZ_KP_MULTIPLY: return '*'; |
| 256 | + case QZ_KP_DIVIDE: return '/'; |
| 257 | + case QZ_KP_ENTER: return '\n'; |
| 258 | + case QZ_KP_PERIOD: return '.'; |
| 259 | + case QZ_KP0: return '0'; |
| 260 | + case QZ_KP1: return '1'; |
| 261 | + case QZ_KP2: return '2'; |
| 262 | + case QZ_KP3: return '3'; |
| 263 | + case QZ_KP4: return '4'; |
| 264 | + case QZ_KP5: return '5'; |
| 265 | + case QZ_KP6: return '6'; |
| 266 | + case QZ_KP7: return '7'; |
| 267 | + case QZ_KP8: return '8'; |
| 268 | + case QZ_KP9: return '9'; |
| 269 | + default: return charcode; |
| 271 | 270 | } |
| 272 | 271 | } |
| 273 | 272 | |
| @@ -334,7 +333,7 @@ MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *us · 60 unmodified lines |
| 334 | 333 | sizeof(macKeyModifiers), NULL, &macKeyModifiers); |
| 335 | 334 | switch(kind) { |
| 336 | 335 | case kEventRawKeyModifiersChanged: |
| 337 | | − if ( macKeyModifiers == 0x1800 ) leave_full_screen(); |
| 336 | + if (macKeyModifiers == 0x1800) leave_full_screen(); |
| 338 | 337 | break; |
| 339 | 338 | case kEventRawKeyDown: |
| 340 | 339 | case kEventRawKeyRepeat: { |
| @@ -363,33 +362,35 @@ if(0 && key != -1)fprint(2, "[%C]", key); · 22 unmodified lines |
| 363 | 362 | static uint32_t mousebuttons = 0; // bitmask of buttons currently down |
| 364 | 363 | |
| 365 | 364 | switch (kind) { |
| 366 | | − case kEventMouseWheelMoved: { |
| 367 | | − int32_t wheeldelta; |
| 368 | | − GetEventParameter(event,kEventParamMouseWheelDelta,typeLongInteger, |
| 369 | | − 0,sizeof(EventMouseButton), 0, &wheeldelta); |
| 370 | | − sendbuttons((int16_t)wheeldelta>0 ? 8 : 16, |
| 371 | | − mousePos.h - winRect.left, |
| 372 | | − mousePos.v - winRect.top); |
| 373 | | − break; |
| 374 | | − } |
| 375 | | − case kEventMouseUp: |
| 376 | | − case kEventMouseDown: { |
| 377 | | − uint32_t buttons; |
| 378 | | − GetEventParameter(event, kEventParamMouseChord, |
| 379 | | − typeUInt32, 0, sizeof buttons, 0, &buttons); |
| 380 | | − mousebuttons = (buttons & 1) |
| 381 | | − | ((buttons & 2)<<1) |
| 382 | | − | ((buttons & 4)>>1); |
| 383 | | − } /* Fallthrough */ |
| 384 | | − case kEventMouseMoved: |
| 385 | | − case kEventMouseDragged: { |
| 386 | | − sendbuttons(mousebuttons, |
| 387 | | − mousePos.h - winRect.left, |
| 388 | | − mousePos.v - winRect.top); |
| 389 | | − } |
| 365 | + case kEventMouseWheelMoved: { |
| 366 | + int32_t wheeldelta; |
| 367 | + GetEventParameter(event,kEventParamMouseWheelDelta,typeLongInteger, |
| 368 | + 0,sizeof(EventMouseButton), 0, &wheeldelta); |
| 369 | + sendbuttons((int16_t)wheeldelta>0 ? 8 : 16, |
| 370 | + mousePos.h - winRect.left, |
| 371 | + mousePos.v - winRect.top); |
| 390 | 372 | break; |
| 373 | + } |
| 374 | + case kEventMouseUp: |
| 375 | + case kEventMouseDown: { |
| 376 | + uint32_t buttons; |
| 377 | + GetEventParameter(event, kEventParamMouseChord, |
| 378 | + typeUInt32, 0, sizeof buttons, 0, &buttons); |
| 379 | + mousebuttons = (buttons & 1) |
| 380 | + | ((buttons & 2)<<1) |
| 381 | + | ((buttons & 4)>>1); |
| 382 | + } /* Fallthrough */ |
| 383 | + case kEventMouseMoved: |
| 384 | + case kEventMouseDragged: { |
| 385 | + sendbuttons(mousebuttons, |
| 386 | + mousePos.h - winRect.left, |
| 387 | + mousePos.v - winRect.top); |
| 388 | + } |
| 389 | + break; |
| 391 | 390 | |
| 392 | | − default:result = eventNotHandledErr;break; |
| 391 | + default: |
| 392 | + result = eventNotHandledErr; |
| 393 | + break; |
| 393 | 394 | } |
| 394 | 395 | } |
| 395 | 396 | return result; |
| @@ -407,24 +408,23 @@ MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void * · 11 unmodified lines |
| 407 | 408 | |
| 408 | 409 | if(class == kEventClassCommand){ |
| 409 | 410 | HICommand theHICommand; |
| 410 | | − GetEventParameter( event, kEventParamDirectObject, typeHICommand, |
| 411 | | − NULL, sizeof( HICommand ), NULL, &theHICommand ); |
| 411 | + GetEventParameter(event, kEventParamDirectObject, typeHICommand, |
| 412 | + NULL, sizeof(HICommand), NULL, &theHICommand); |
| 412 | 413 | |
| 413 | | − switch ( theHICommand.commandID ){ |
| 414 | | − case kHICommandQuit: |
| 415 | | − cleanexit(0); |
| 416 | | − break; |
| 414 | + switch(theHICommand.commandID){ |
| 415 | + case kHICommandQuit: |
| 416 | + cleanexit(0); |
| 417 | + break; |
| 417 | 418 | |
| 418 | | − case kFullScreenCmd: |
| 419 | | − full_screen(); |
| 420 | | − break; |
| 419 | + case kFullScreenCmd: |
| 420 | + full_screen(); |
| 421 | + break; |
| 421 | 422 | |
| 422 | | − default: |
| 423 | | − result = eventNotHandledErr; |
| 424 | | − break; |
| 423 | + default: |
| 424 | + result = eventNotHandledErr; |
| 425 | + break; |
| 425 | 426 | } |
| 426 | | − } |
| 427 | | − else if(class == kEventClassWindow){ |
| 427 | + } else if(class == kEventClassWindow){ |
| 428 | 428 | WindowRef window; |
| 429 | 429 | _Rect rectPort = {0,0,0,0}; |
| 430 | 430 | |
| @@ -435,25 +435,25 @@ MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void * · 4 unmodified lines |
| 435 | 435 | GetPortBounds(GetWindowPort(window), &rectPort); |
| 436 | 436 | |
| 437 | 437 | switch (kind){ |
| 438 | | − case kEventWindowClosed: |
| 439 | | − theWindow = NULL; |
| 440 | | − cleanexit(0); // only one window |
| 441 | | − break; |
| 442 | | − |
| 443 | | − //resize window |
| 444 | | − case kEventWindowBoundsChanged: |
| 445 | | − window_resized(); |
| 446 | | − Rectangle rect = { { 0, 0 }, |
| 438 | + case kEventWindowClosed: |
| 439 | + theWindow = NULL; |
| 440 | + cleanexit(0); // only one window |
| 441 | + break; |
| 442 | + |
| 443 | + //resize window |
| 444 | + case kEventWindowBoundsChanged: |
| 445 | + window_resized(); |
| 446 | + Rectangle rect = { { 0, 0 }, |
| 447 | 447 | { bounds.size.width, |
| 448 | 448 | bounds.size.height} }; |
| 449 | | − drawqlock(); |
| 450 | | − flushmemscreen(rect); |
| 451 | | − drawqunlock(); |
| 452 | | − break; |
| 449 | + drawqlock(); |
| 450 | + flushmemscreen(rect); |
| 451 | + drawqunlock(); |
| 452 | + break; |
| 453 | 453 | |
| 454 | | − default: |
| 455 | | − result = eventNotHandledErr; |
| 456 | | − break; |
| 454 | + default: |
| 455 | + result = eventNotHandledErr; |
| 456 | + break; |
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | |
| @@ -477,7 +477,7 @@ flushmemscreen(Rectangle r) · 17 unmodified lines |
| 477 | 477 | if(rbounds.size.width <= 0 || rbounds.size.height <= 0) |
| 478 | 478 | return; |
| 479 | 479 | |
| 480 | | − QDBeginCGContext( GetWindowPort(theWindow), &context); |
| 480 | + QDBeginCGContext(GetWindowPort(theWindow), &context); |
| 481 | 481 | |
| 482 | 482 | // The sub-image is relative to our whole screen image. |
| 483 | 483 | CGImageRef subimg = CGImageCreateWithImageInRect(fullScreenImage, rbounds); |
| @@ -487,7 +487,7 @@ flushmemscreen(Rectangle r) · 3 unmodified lines |
| 487 | 487 | CGContextDrawImage(context, rbounds, subimg); |
| 488 | 488 | CGContextFlush(context); |
| 489 | 489 | CGImageRelease(subimg); |
| 490 | | − QDEndCGContext( GetWindowPort(theWindow), &context); |
| 490 | + QDEndCGContext(GetWindowPort(theWindow), &context); |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | uchar* |
| @@ -536,19 +536,19 @@ clipread(void) · 42 unmodified lines |
| 536 | 536 | { |
| 537 | 537 | CFDataRef cfdata; |
| 538 | 538 | OSStatus err = noErr; |
| 539 | | − ItemCount nItems; |
| 539 | + ItemCount nitems; |
| 540 | 540 | int i; |
| 541 | 541 | char *s; |
| 542 | 542 | |
| 543 | 543 | // Wow. This is ridiculously complicated. |
| 544 | 544 | PasteboardSynchronize(appleclip); |
| 545 | | − if((err = PasteboardGetItemCount(appleclip, &nItems)) != noErr) { |
| 545 | + if((err = PasteboardGetItemCount(appleclip, &nitems)) != noErr) { |
| 546 | 546 | fprint(2, "apple pasteboard GetItemCount failed - Error %d\n", err); |
| 547 | 547 | return 0; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | // Yes, based at 1. Silly API. |
| 551 | | − for(i = 1; i <= nItems; i++) { |
| 551 | + for(i = 1; i <= nitems; i++) { |
| 552 | 552 | PasteboardItemID itemID; |
| 553 | 553 | CFArrayRef flavorTypeArray; |
| 554 | 554 | CFIndex flavorCount; |
| @@ -577,7 +577,7 @@ clipread(void) · 22 unmodified lines |
| 577 | 577 | CFIndex length = CFDataGetLength(cfdata); |
| 578 | 578 | if (length > sizeof rsnarf) length = sizeof rsnarf; |
| 579 | 579 | CFDataGetBytes(cfdata, CFRangeMake(0, length), (uint8_t *)rsnarf); |
| 580 | | − snprint(snarf, sizeof snarf, "%S", rsnarf); |
| 580 | + snprint(snarf, sizeof snarf, "%.*S", length/sizeof(Rune), rsnarf); |
| 581 | 581 | for(s = snarf; *s; s++) |
| 582 | 582 | if(*s == '\r') |
| 583 | 583 | *s = '\n'; |
| @@ -589,7 +589,6 @@ clipread(void) · 5 unmodified lines |
| 589 | 589 | return 0; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | | −// TO DO: check that the return value is correct |
| 593 | 592 | int |
| 594 | 593 | clipwrite(char *snarf) |
| 595 | 594 | { |