mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
- Changed the way input text field is place in dialogs - If a dialog has no title but a message with newlines, then use the first line of the message as a title (this makes dialogs look better)
git-svn-id: http://macvim.googlecode.com/svn/trunk@159 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
+16
-1
@@ -432,8 +432,23 @@ static int specialKeyToNSKey(int key);
|
||||
}
|
||||
if (title)
|
||||
message = [NSString stringWithUTF8String:title];
|
||||
if (msg)
|
||||
if (msg) {
|
||||
text = [NSString stringWithUTF8String:msg];
|
||||
if (!message) {
|
||||
// HACK! If there is a '\n\n' or '\n' sequence in the message, then
|
||||
// make the part up to there into the title. We only do this
|
||||
// because Vim has lots of dialogs without a title and they look
|
||||
// ugly that way.
|
||||
// TODO: Fix the actual dialog texts.
|
||||
NSRange eolRange = [text rangeOfString:@"\n\n"];
|
||||
if (NSNotFound == eolRange.location)
|
||||
eolRange = [text rangeOfString:@"\n"];
|
||||
if (NSNotFound != eolRange.location) {
|
||||
message = [text substringToIndex:eolRange.location];
|
||||
text = [text substringFromIndex:NSMaxRange(eolRange)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (txtfield)
|
||||
textFieldString = [NSString stringWithUTF8String:txtfield];
|
||||
|
||||
|
||||
+25
-6
@@ -18,6 +18,8 @@
|
||||
//static NSString *AttentionToolbarItemID = @"Attention";
|
||||
static NSString *DefaultToolbarImageName = @"Attention";
|
||||
|
||||
static int MMAlertTextFieldHeight = 22;
|
||||
|
||||
|
||||
@interface MMAlert : NSAlert {
|
||||
NSTextField *textField;
|
||||
@@ -251,9 +253,19 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag)
|
||||
|
||||
[alert setAlertStyle:style];
|
||||
|
||||
if (message) [alert setMessageText:message];
|
||||
else [alert setMessageText:@""];
|
||||
if (text) [alert setInformativeText:text];
|
||||
if (message) {
|
||||
[alert setMessageText:message];
|
||||
} else {
|
||||
// If no message text is specified 'Alert' is used.
|
||||
[alert setMessageText:@""];
|
||||
}
|
||||
|
||||
if (text) {
|
||||
[alert setInformativeText:text];
|
||||
} else if (textFieldString) {
|
||||
// Make sure there is always room for the input text field.
|
||||
[alert setInformativeText:@""];
|
||||
}
|
||||
|
||||
unsigned i, count = [buttonTitles count];
|
||||
for (i = 0; i < count; ++i) {
|
||||
@@ -1168,18 +1180,25 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag)
|
||||
didEndSelector:didEndSelector
|
||||
contextInfo:contextInfo];
|
||||
|
||||
// HACK! Place the input text field at the bottom of the informative text
|
||||
// (which has been made a bit larger by adding newline characters).
|
||||
NSView *contentView = [[self window] contentView];
|
||||
NSRect rect = NSZeroRect;
|
||||
NSRect rect = [contentView frame];
|
||||
rect.origin.y = rect.size.height;
|
||||
|
||||
NSArray *subviews = [contentView subviews];
|
||||
unsigned i, count = [subviews count];
|
||||
for (i = 0; i < count; ++i) {
|
||||
NSView *view = [subviews objectAtIndex:i];
|
||||
if ([view isKindOfClass:[NSTextField class]]) {
|
||||
if ([view isKindOfClass:[NSTextField class]]
|
||||
&& [view frame].origin.y < rect.origin.y) {
|
||||
// NOTE: The informative text field is the lowest NSTextField in
|
||||
// the alert dialog.
|
||||
rect = [view frame];
|
||||
}
|
||||
}
|
||||
|
||||
rect.size.height = 22;
|
||||
rect.size.height = MMAlertTextFieldHeight;
|
||||
[textField setFrame:rect];
|
||||
[contentView addSubview:textField];
|
||||
[textField becomeFirstResponder];
|
||||
|
||||
Reference in New Issue
Block a user