From 99c9ad7ef1f1d77b713577df72eae32d3f479cf6 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Fri, 23 Oct 2015 23:19:42 +1100 Subject: Add a menu command to ScintillaTest to add or remove an extra Scintilla view on the right of the window to allow testing deletion of a ScintillaView. --- cocoa/ScintillaTest/AppController.mm | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'cocoa/ScintillaTest/AppController.mm') diff --git a/cocoa/ScintillaTest/AppController.mm b/cocoa/ScintillaTest/AppController.mm index 44cd6e97f..189e7b0ea 100644 --- a/cocoa/ScintillaTest/AppController.mm +++ b/cocoa/ScintillaTest/AppController.mm @@ -77,15 +77,20 @@ const char user_keywords[] = // Definition of own keywords, not used by MySQL. NSString* path = [[NSBundle mainBundle] pathForResource: @"TestData" ofType: @"sql" inDirectory: nil]; - NSString* sql = [NSString stringWithContentsOfFile: path + sql = [NSString stringWithContentsOfFile: path encoding: NSUTF8StringEncoding error: &error]; + + [sql retain]; + if (error && [[error domain] isEqual: NSCocoaErrorDomain]) NSLog(@"%@", error); [mEditor setString: sql]; [self setupEditor]; + + sciExtra = nil; } //-------------------------------------------------------------------------------------------------- @@ -271,6 +276,25 @@ static const char * box_xpm[] = { [self showAutocompletion]; } +- (IBAction) addRemoveExtra: (id) sender +{ + if (sciExtra) { + [sciExtra removeFromSuperview]; + sciExtra = nil; + } else { + NSRect newFrame = mEditHost.frame; + newFrame.origin.x += newFrame.size.width + 5; + newFrame.origin.y += 46; + newFrame.size.width = 96; + newFrame.size.height -= 60; + + sciExtra = [[[ScintillaView alloc] initWithFrame: newFrame] autorelease]; + [[[mEditHost window]contentView] addSubview: sciExtra]; + [sciExtra setGeneralProperty: SCI_SETWRAPMODE parameter: SC_WRAP_WORD value: 1]; + [sciExtra setString: sql]; + } +} + -(IBAction) setFontQuality: (id) sender { [ScintillaView directCall:mEditor message:SCI_SETFONTQUALITY wParam:[sender tag] lParam:0]; -- cgit v1.2.3