Permalink
Browse files

unify all document selecting, switching, splitting, tab creating, in …

…displayDocument:positioned:

when closing a document in a tab, don't close the tab, just replace the last view
this avoids an extra document switch, which messed up the alternateMark
  • Loading branch information...
1 parent e3212c4 commit 99f24bff57218badc926322da25984eee3d987ba @martinh martinh committed Oct 1, 2011
Showing with 118 additions and 127 deletions.
  1. +2 −2 app/ViDocument.m
  2. +4 −3 app/ViDocumentController.m
  3. +4 −1 app/ViTabController.h
  4. +13 −2 app/ViTabController.m
  5. +1 −4 app/ViWindowController.h
  6. +87 −109 app/ViWindowController.m
  7. +7 −6 app/vico.nu
View
@@ -272,7 +272,7 @@ - (BOOL)readFromURL:(NSURL *)absoluteURL
[self setCloseCallback:nil];
} else {
/* Make sure this document has focus, then show an alert sheet. */
- [_windowController selectDocument:self];
+ [_windowController displayDocument:self positioned:ViViewPositionDefault];
[self setFileURL:nil];
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
@@ -397,7 +397,7 @@ - (BOOL)keepBackupFile
- (void)showWindows
{
[super showWindows];
- [_windowController selectDocument:self];
+ [_windowController displayDocument:self positioned:ViViewPositionDefault];
}
- (ViWindowController *)windowController
@@ -49,7 +49,7 @@ - (void)closeNextDocumentInWindow:(NSWindow *)window
if ([[windowController documents] count] > 0) {
ViDocument *doc = [[windowController documents] anyObject];
- [windowController selectDocument:doc];
+ [windowController displayDocument:doc positioned:ViViewPositionDefault];
[doc canCloseDocumentWithDelegate:self
shouldCloseSelector:@selector(document:shouldClose:contextInfo:)
contextInfo:NULL];
@@ -139,7 +139,7 @@ - (void)closeNextDocumentInSet:(NSMutableSet *)set force:(BOOL)force
window = [[doc windowController] window];
if (force || [window attachedSheet] == nil) {
- [[doc windowController] selectDocument:doc];
+ [[doc windowController] displayDocument:doc positioned:ViViewPositionDefault];
/*
* Schedule next close sheet in the event loop right after the windowcontroller has selected the document.
*/
@@ -262,7 +262,8 @@ - (id)openDocumentWithContentsOfURL:(NSURL *)absoluteURL
if (displayDocument) {
if ([doc isKindOfClass:[ViDocument class]]) {
if ([doc windowController] == windowController)
- [[doc windowController] selectDocument:doc];
+ [[doc windowController] displayDocument:doc
+ positioned:ViViewPositionDefault];
else
[windowController addNewTab:doc];
} else if ([doc isKindOfClass:[ViProject class]]) {
@@ -7,12 +7,15 @@ typedef enum ViViewPosition ViViewPosition;
typedef enum ViViewOrderingMode ViViewOrderingMode;
enum ViViewPosition {
- ViViewPositionDefault,
+ ViViewPositionDefault = 0,
+ ViViewPositionPreferred,
ViViewPositionReplace,
ViViewPositionTab,
ViViewPositionSplitLeft,
+ ViViewPositionSplitVertical = ViViewPositionSplitLeft,
ViViewPositionSplitRight,
ViViewPositionSplitAbove,
+ ViViewPositionSplitHorizontal = ViViewPositionSplitAbove,
ViViewPositionSplitBelow
};
View
@@ -46,13 +46,19 @@ - (void)dealloc
- (void)addView:(ViViewController *)viewController
{
+ if (viewController == nil)
+ return;
+
[viewController setTabController:self];
[_views addObject:viewController];
[[ViEventManager defaultManager] emit:ViEventDidAddView for:viewController with:viewController, nil];
}
- (void)removeView:(ViViewController *)viewController
{
+ if (viewController == nil)
+ return;
+
[viewController retain];
DEBUG(@"remove view %@", viewController);
[viewController setTabController:nil];
@@ -219,15 +225,20 @@ - (ViDocumentView *)replaceView:(ViViewController *)viewController
withDocument:(ViDocument *)document
{
ViDocumentView *newDocView = [document makeView];
+ DEBUG(@"replace view %@ with view %@ = %@", [viewController view], [newDocView view], newDocView);
[self addView:newDocView];
+ if (viewController == nil) {
+ [_splitView addSubview:[newDocView view]];
+ [self setSelectedView:newDocView];
+ return newDocView;
+ }
+
[self removeView:viewController];
if (_selectedView == viewController)
[self setSelectedView:newDocView];
- DEBUG(@"replace view %@ with view %@ = %@", [viewController view], [newDocView view], newDocView);
-
/*
* Remember all subview sizes so we can restore the position
* of the dividers after replacing the view.
@@ -131,8 +131,6 @@
*/
- (ViDocumentView *)viewForDocument:(ViDocument *)document;
-- (ViDocumentView *)selectDocument:(ViDocument *)aDocument;
-
/**
* @returns The documents open in the window.
*/
@@ -201,12 +199,11 @@
- (IBAction)navigateJumplist:(id)sender;
-- (ViDocumentView *)switchToDocument:(ViDocument *)doc;
-
- (void)switchToDocumentAction:(id)sender;
/* FIXME: document -displayDocument:positioned: */
- (ViDocumentView *)displayDocument:(ViDocument *)doc positioned:(ViViewPosition)position;
+- (ViDocumentView *)displayDocument:(ViDocument *)doc;
/** Open a document and go to a specific point in the file.
* @param url The URL of the document to open. The document may already be opened.
Oops, something went wrong.

0 comments on commit 99f24bf

Please sign in to comment.