diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/acme/text.c | 26 | ||||
-rw-r--r-- | src/cmd/devdraw/osx-screen.c | 103 | ||||
-rw-r--r-- | src/cmd/samterm/main.c | 19 |
3 files changed, 116 insertions, 32 deletions
diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c index 729e4303..30f5804d 100644 --- a/src/cmd/acme/text.c +++ b/src/cmd/acme/text.c @@ -734,6 +734,11 @@ texttype(Text *t, Rune r) q0++; textshow(t, q0, q0, TRUE); return; + case Kcmd+'c': /* %C: copy */ + typecommit(t); + cut(t, t, nil, TRUE, FALSE, nil, 0); + return; + Tagdown: /* expand tag to show all text */ if(!t->w->tagexpand){ @@ -755,6 +760,27 @@ texttype(Text *t, Rune r) seq++; filemark(t->file); } + /* cut/paste must be done after the seq++/filemark */ + switch(r){ + case Kcmd+'x': /* %X: cut */ + typecommit(t); + if(t->what == Body){ + seq++; + filemark(t->file); + } + cut(t, t, nil, TRUE, TRUE, nil, 0); + textshow(t, t->q0, t->q0, 1); + return; + case Kcmd+'v': /* %V: paste */ + typecommit(t); + if(t->what == Body){ + seq++; + filemark(t->file); + } + paste(t, t, nil, TRUE, FALSE, nil, 0); + textshow(t, t->q0, t->q1, 1); + return; + } if(t->q1 > t->q0){ if(t->ncache != 0) error("text.type"); diff --git a/src/cmd/devdraw/osx-screen.c b/src/cmd/devdraw/osx-screen.c index 4b1f6ede..76416cba 100644 --- a/src/cmd/devdraw/osx-screen.c +++ b/src/cmd/devdraw/osx-screen.c @@ -2,7 +2,6 @@ #define Rect OSXRect #define Cursor OSXCursor #include <Carbon/Carbon.h> -#include <QuickTime/QuickTime.h> // for full screen #undef Rect #undef Point #undef Cursor @@ -23,7 +22,6 @@ #include "glendapng.h" AUTOFRAMEWORK(Carbon) -AUTOFRAMEWORK(QuickTime) #define panic sysfatal @@ -52,6 +50,8 @@ struct { PasteboardRef snarf; int needflush; QLock flushlock; + int active; + int infullscreen; } osx; enum @@ -66,8 +66,9 @@ enum static void screenproc(void*); static void eresized(int); -static void fullscreen(void); +static void fullscreen(int); static void seticon(void); +static void activated(int); static OSStatus quithandler(EventHandlerCallRef, EventRef, void*); static OSStatus eventhandler(EventHandlerCallRef, EventRef, void*); @@ -159,7 +160,9 @@ _screeninit(void) const EventTypeSpec cmds[] = { { kEventClassWindow, kEventWindowClosed }, { kEventClassWindow, kEventWindowBoundsChanged }, - { kEventClassCommand, kEventCommandProcess } + { kEventClassCommand, kEventCommandProcess }, + { kEventClassWindow, kEventWindowActivated }, + { kEventClassWindow, kEventWindowDeactivated }, }; const EventTypeSpec events[] = { { kEventClassKeyboard, kEventRawKeyDown }, @@ -256,7 +259,7 @@ eventhandler(EventHandlerCallRef next, EventRef event, void *arg) exit(0); case CmdFullScreen: - fullscreen(); + fullscreen(1); break; default: @@ -273,6 +276,14 @@ eventhandler(EventHandlerCallRef next, EventRef event, void *arg) eresized(1); break; + case kEventWindowActivated: + activated(1); + return eventNotHandledErr; + + case kEventWindowDeactivated: + activated(0); + return eventNotHandledErr; + default: return eventNotHandledErr; } @@ -419,7 +430,22 @@ kbdevent(EventRef event) if(mod == cmdKey){ if(ch == 'F' || ch == 'f'){ if(osx.isfullscreen && msec() - osx.fullscreentime > 500) - fullscreen(); + fullscreen(0); + return noErr; + } + + // Pass most Cmd keys through as Kcmd + ch. + // OS X interprets a few no matter what we do, + // so it is useless to pass them through as keystrokes too. + switch(ch) { + case 'm': // minimize window + case 'h': // hide window + case 'H': // hide others + case 'q': // quit + return eventNotHandledErr; + } + if(' ' <= ch && ch <= '~') { + keystroke(Kcmd + ch); return noErr; } return eventNotHandledErr; @@ -472,7 +498,7 @@ eresized(int new) CGDataProviderRef provider; CGImageRef image; CGColorSpaceRef cspace; - + GetWindowBounds(osx.window, kWindowContentRgn, &or); r = Rect(or.left, or.top, or.right, or.bottom); if(Dx(r) == Dx(osx.screenr) && Dy(r) == Dy(osx.screenr)){ @@ -561,38 +587,51 @@ _flushmemscreen(Rectangle r) } void -fullscreen(void) +activated(int active) +{ + osx.active = active; +} + +void +fullscreen(int wascmd) { - static Ptr restore; - static WindowRef oldwindow; + static OSXRect oldrect; GDHandle device; + OSXRect dr; - qlock(&osx.flushlock); - if(osx.isfullscreen){ - if(osx.windowctx){ - QDEndCGContext(GetWindowPort(osx.window), &osx.windowctx); - osx.windowctx = nil; - } - EndFullScreen(restore, 0); - osx.window = oldwindow; - ShowWindow(osx.window); - osx.isfullscreen = 0; - }else{ - if(osx.windowctx){ - QDEndCGContext(GetWindowPort(osx.window), &osx.windowctx); - osx.windowctx = nil; - } - HideWindow(osx.window); - oldwindow = osx.window; - GetWindowGreatestAreaDevice(osx.window, kWindowTitleBarRgn, &device, nil); - BeginFullScreen(&restore, device, 0, 0, &osx.window, 0, 0); + if(!wascmd) + return; + + if(!osx.isfullscreen){ + GetWindowGreatestAreaDevice(osx.window, + kWindowTitleBarRgn, &device, nil); + dr = (*device)->gdRect; + if(dr.top == 0 && dr.left == 0) + HideMenuBar(); + GetWindowBounds(osx.window, kWindowContentRgn, &oldrect); + ChangeWindowAttributes(osx.window, + kWindowNoTitleBarAttribute, + kWindowResizableAttribute); + MoveWindow(osx.window, 0, 0, 1); + MoveWindow(osx.window, dr.left, dr.top, 0); + SizeWindow(osx.window, + dr.right - dr.left, + dr.bottom - dr.top, 0); osx.isfullscreen = 1; - osx.fullscreentime = msec(); + }else{ + ShowMenuBar(); + ChangeWindowAttributes(osx.window, + kWindowResizableAttribute, + kWindowNoTitleBarAttribute); + SizeWindow(osx.window, + oldrect.right - oldrect.left, + oldrect.bottom - oldrect.top, 0); + MoveWindow(osx.window, oldrect.left, oldrect.top, 0); + osx.isfullscreen = 0; } - qunlock(&osx.flushlock); eresized(1); } - + void setmouse(Point p) { diff --git a/src/cmd/samterm/main.c b/src/cmd/samterm/main.c index bf0d9a55..5b645e84 100644 --- a/src/cmd/samterm/main.c +++ b/src/cmd/samterm/main.c @@ -494,6 +494,9 @@ flushtyping(int clearesc) #define PAGEUP Kpgup #define RIGHTARROW Kright #define SCROLLKEY Kdown +#define CUT (Kcmd+'x') +#define COPY (Kcmd+'c') +#define PASTE (Kcmd+'v') int nontypingkey(int c) @@ -511,6 +514,8 @@ nontypingkey(int c) case SCROLLKEY: return 1; } + if(c >= Kcmd) + return 1; return 0; } @@ -673,6 +678,20 @@ type(Flayer *l, int res) /* what a bloody mess this is */ for(l=t->l; l<&t->l[NL]; l++) if(l->textfn) flsetselect(l, l->p0, l->p1); + switch(c) { + case CUT: + flushtyping(0); + cut(t, t->front, 1, 1); + break; + case COPY: + flushtyping(0); + snarf(t, t->front); + break; + case PASTE: + flushtyping(0); + paste(t, t->front); + break; + } } } |