Fri, 04 Apr 2014 11:29:17 +0200
textarea automatically sets selection group (Cocoa)
ui/cocoa/menu.m | file | annotate | diff | comparison | revisions | |
ui/cocoa/stock.m | file | annotate | diff | comparison | revisions | |
ui/cocoa/text.h | file | annotate | diff | comparison | revisions | |
ui/cocoa/text.m | file | annotate | diff | comparison | revisions | |
ui/cocoa/toolbar.m | file | annotate | diff | comparison | revisions | |
ui/cocoa/toolkit.m | file | annotate | diff | comparison | revisions | |
ui/cocoa/window.m | file | annotate | diff | comparison | revisions |
--- a/ui/cocoa/menu.m Thu Apr 03 14:16:41 2014 +0200 +++ b/ui/cocoa/menu.m Fri Apr 04 11:29:17 2014 +0200 @@ -105,7 +105,6 @@ } } } - free(groups); for(int j=0;j<c;j++) { if(check[j] == 0) {
--- a/ui/cocoa/stock.m Thu Apr 03 14:16:41 2014 +0200 +++ b/ui/cocoa/stock.m Fri Apr 04 11:29:17 2014 +0200 @@ -43,6 +43,10 @@ ui_add_stock_item(UI_STOCK_CLOSE, @"Close", @"w", nil); ui_add_stock_item(UI_STOCK_UNDO, @"Undo", @"z", nil); ui_add_stock_item(UI_STOCK_REDO, @"Redo", @"", nil); + ui_add_stock_item(UI_STOCK_CUT, @"Cut", @"x", nil); + ui_add_stock_item(UI_STOCK_COPY, @"Copy", @"c", nil); + ui_add_stock_item(UI_STOCK_PASTE, @"Paste", @"v", nil); + ui_add_stock_item(UI_STOCK_DELETE, @"Delete", @"", nil); ui_add_stock_item(UI_STOCK_GO_BACK, @"Back", @"", [NSImage imageNamed: NSImageNameGoLeftTemplate]); ui_add_stock_item(UI_STOCK_GO_FORWARD, @"Forward", @"", [NSImage imageNamed: NSImageNameGoRightTemplate]);
--- a/ui/cocoa/text.h Thu Apr 03 14:16:41 2014 +0200 +++ b/ui/cocoa/text.h Fri Apr 04 11:29:17 2014 +0200 @@ -31,10 +31,12 @@ #import "../../ucx/list.h" @interface TextChangeMgr : NSObject<NSTextViewDelegate> { - UiText* value; + UiContext *context; + UiText *value; + int last_length; } -- (TextChangeMgr*)initWithValue:(UiText*)text; +- (TextChangeMgr*)initWithValue:(UiText*)text context:(UiContext*)ctx; - (NSUndoManager*)undoManagerForTextView:(NSTextView*)textview;
--- a/ui/cocoa/text.m Thu Apr 03 14:16:41 2014 +0200 +++ b/ui/cocoa/text.m Fri Apr 04 11:29:17 2014 +0200 @@ -35,8 +35,10 @@ @implementation TextChangeMgr -- (TextChangeMgr*)initWithValue:(UiText*)text { +- (TextChangeMgr*)initWithValue:(UiText*)text context:(UiContext*)ctx { value = text; + context = ctx; + last_length = 0; return self; } @@ -44,6 +46,22 @@ return (NSUndoManager*)value->undomgr; } +- (NSRange)textView:(NSTextView *)textview + willChangeSelectionFromCharacterRange:(NSRange)oldrange + toCharacterRange:(NSRange)newrange +{ + if(newrange.length != last_length) { + if(newrange.length == 0) { + ui_unset_group(context, UI_GROUP_SELECTION); + } else { + ui_set_group(context, UI_GROUP_SELECTION); + } + } + + last_length = newrange.length; + return newrange; +} + @end @@ -76,7 +94,7 @@ value->value = NULL; value->obj = textview; - TextChangeMgr *delegate = [[TextChangeMgr alloc]initWithValue:value]; + TextChangeMgr *delegate = [[TextChangeMgr alloc]initWithValue:value context:obj->ctx]; [textview setDelegate:delegate]; NSUndoManager *undomgr = [[NSUndoManager alloc]init];
--- a/ui/cocoa/toolbar.m Thu Apr 03 14:16:41 2014 +0200 +++ b/ui/cocoa/toolbar.m Fri Apr 04 11:29:17 2014 +0200 @@ -139,6 +139,9 @@ [i addObject: NSToolbarFlexibleSpaceItemIdentifier]; [i addObject: NSToolbarSpaceItemIdentifier]; [i addObject: NSToolbarSeparatorItemIdentifier]; + for(id item in allowedItems) { + [i addObject: item]; + } return i; } @@ -147,7 +150,7 @@ return defaultItems; } -- (NSToolbarItem *) toolbar:(NSToolbar*)toolbar +- (NSToolbarItem *) toolbar:(NSToolbar*)toolbar itemForItemIdentifier:(NSString*)identifier willBeInsertedIntoToolbar:(BOOL)flag {