Loading ...
Sorry, an error occurred while loading the content.

[PATCH] vimview wip

Expand Messages
  • Nicolas Weber
    ... src/MacVim/MMVimView.h | 9 +++--- src/MacVim/MMVimView.m | 36 ++++++++++++++++++++----- src/MacVim/MMWindowController.m | 57
    Message 1 of 1 , Oct 30, 2007
    • 0 Attachment
      ---
      src/MacVim/MMVimView.h | 9 +++---
      src/MacVim/MMVimView.m | 36 ++++++++++++++++++++-----
      src/MacVim/MMWindowController.m | 57 +++++++-------------------------------
      3 files changed, 45 insertions(+), 57 deletions(-)

      diff --git a/src/MacVim/MMVimView.h b/src/MacVim/MMVimView.h
      index be00667..d61f9f5 100644
      --- a/src/MacVim/MMVimView.h
      +++ b/src/MacVim/MMVimView.h
      @@ -29,6 +29,9 @@
      MMTextStorage *textStorage;
      NSMutableArray *scrollbars;

      + NSSize actualSize; // will become bounds or frame (?)
      + NSSize desiredSize;
      +
      // This is temporary to make the refactoring easier
      BOOL shouldUpdateWindowSize;
      }
      @@ -41,6 +44,8 @@
      - (BOOL)inLiveResize;
      - (void)cleanup;

      +- (NSSize)actualSize;
      +- (NSSize)desiredSize;

      - (PSMTabBarControl *)tabBarControl;
      - (NSTabView *)tabView;
      @@ -50,10 +55,6 @@
      - (int)representedIndexOfTabViewItem:(NSTabViewItem *)tvi;
      - (NSTabViewItem *)addNewTabViewItem;

      -- (BOOL)bottomScrollbarVisible;
      -- (BOOL)leftScrollbarVisible;
      -- (BOOL)rightScrollbarVisible;
      -- (void)placeScrollbars;
      - (void)createScrollbarWithIdentifier:(long)ident type:(int)type;
      - (void)destroyScrollbarWithIdentifier:(long)ident;
      - (void)showScrollbarWithIdentifier:(long)ident state:(BOOL)visible;
      diff --git a/src/MacVim/MMVimView.m b/src/MacVim/MMVimView.m
      index a175f89..21a5953 100644
      --- a/src/MacVim/MMVimView.m
      +++ b/src/MacVim/MMVimView.m
      @@ -195,6 +195,17 @@ enum {
      [tabView removeAllTabViewItems];
      }

      +- (NSSize)actualSize
      +{
      + // XXX: read about difference between frame and bounds
      + return [self frame].size;
      +}
      +
      +- (NSSize)desiredSize
      +{
      + return [self contentSizeForTextStorageSize:[[self textStorage] size]];
      +}
      +
      - (IBAction)addNewTab:(id)sender
      {
      // NOTE! This can get called a lot if the user holds down the key
      @@ -547,6 +558,24 @@ enum {
      return nil;
      }

      +- (NSPoint)textViewOrigin
      +{
      + return NSMakePoint([self leftScrollbarVisible] ?
      + [NSScroller scrollerWidth] : 0,
      + [self bottomScrollbarVisible] ?
      + [NSScroller scrollerWidth] : 0);
      +}
      +
      +- (void)placeViews
      +{
      + NSRect textViewRect;
      + textViewRect.origin = [self textViewOrigin];
      + textViewRect.size = [[self textStorage] size];
      + [[self textView] setFrame:textViewRect];
      +
      + [self placeScrollbars];
      +}
      +
      - (void)setDefaultColorsBackground:(NSColor *)back foreground:(NSColor *)fore
      {
      [textStorage setDefaultColorsBackground:back foreground:fore];
      @@ -567,13 +596,6 @@ enum {
      {
      NSSize size = textViewSize;

      - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
      - int right = [ud integerForKey:MMTextInsetRightKey];
      - int bot = [ud integerForKey:MMTextInsetBottomKey];
      -
      - size.width += [[self textView] textContainerOrigin].x + right;
      - size.height += [[self textView] textContainerOrigin].y + bot;
      -
      if (![[self tabBarControl] isHidden])
      size.height += [[self tabBarControl] frame].size.height;

      diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m
      index 96f2090..8da8b28 100644
      --- a/src/MacVim/MMWindowController.m
      +++ b/src/MacVim/MMWindowController.m
      @@ -125,7 +125,10 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)

      - (NSString *)description
      {
      - return [NSString stringWithFormat:@"%@ : setupDone=%d windowAutosaveKey=%@ vimController=%@", [self className], setupDone, windowAutosaveKey, vimController];
      + NSString *format =
      + @"%@ : setupDone=%d windowAutosaveKey=%@ vimController=%@";
      + return [NSString stringWithFormat:format,
      + [self className], setupDone, windowAutosaveKey, vimController];
      }

      - (MMVimController *)vimController
      @@ -241,8 +244,8 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)
      [scroller setRange:range];
      // TODO! Should only do this once per update.

      - if (setupDone) // TODO: probably not necessary
      - [vimView placeScrollbars];
      + //if (setupDone) // TODO: probably not necessary
      + // [vimView placeScrollbars];
      }
      }

      @@ -374,6 +377,7 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)

      - (void)liveResizeDidEnd
      {
      +NSLog(@"res done");
      // TODO: Don't duplicate code from placeViews.

      if (!setupDone) return;
      @@ -427,52 +431,12 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)
      {
      if (!setupDone) return;

      - // NOTE! It is assumed that the window has been resized so that it will
      - // exactly fit the text storage (possibly after resizing it). If this is
      - // not the case the display might be messed up.
      - NSWindow *win = [self window];
      - NSRect contentRect = [win contentRectForFrameRect:[win frame]];
      - NSRect textViewRect = [self textViewRectForContentSize:contentRect.size];
      - NSSize tsSize = [self textStorageSizeForTextViewSize:textViewRect.size];
      -
      - // If our optimal (rows,cols) do not match our current (rows,cols), resize
      - // ourselves and tell the Vim process to sync up.
      - int dim[2], rows, cols;
      - [[vimView textStorage] getMaxRows:&rows columns:&cols];
      - [[vimView textStorage] fitToSize:tsSize rows:&dim[0] columns:&dim[1]];
      + [vimView placeViews];

      - if (dim[0] != rows || dim[1] != cols) {
      - //NSLog(@"Notify Vim that text storage dimensions changed "
      - // @"from %dx%d to %dx%d", cols, rows, dim[1], dim[0]);
      - NSData *data = [NSData dataWithBytes:dim length:2*sizeof(int)];
      -
      - [vimController sendMessage:SetTextDimensionsMsgID data:data];
      -
      - // We only want to set the window title if this resize came from
      - // a live-resize, not (for example) setting 'columns' or 'lines'.
      - if ([[self textView] inLiveResize]) {
      - [win setTitle:[NSString stringWithFormat:@"%dx%d",
      - dim[1], dim[0]]];
      - }
      - }
      -
      - // XXX: put vimView resizing logic in vimView
      - [[vimView textView] setFrame:textViewRect];
      -
      - NSRect vimViewRect = textViewRect;
      + NSRect vimViewRect;
      vimViewRect.origin = NSMakePoint(0, 0);
      - if (![[vimView tabBarControl] isHidden])
      - vimViewRect.size.height += [[vimView tabBarControl] frame].size.height;
      - if ([vimView bottomScrollbarVisible])
      - vimViewRect.size.height += [NSScroller scrollerWidth];
      - if ([vimView leftScrollbarVisible])
      - vimViewRect.size.width += [NSScroller scrollerWidth];
      - if ([vimView rightScrollbarVisible])
      - vimViewRect.size.width += [NSScroller scrollerWidth];
      -
      + vimViewRect.size = [vimView desiredSize];
      [vimView setFrame:vimViewRect];
      -
      - [vimView placeScrollbars];
      }

      - (void)enterFullscreen
      @@ -545,6 +509,7 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)

      - (void)windowDidResize:(id)sender
      {
      +NSLog(@"resize\n");
      if (!setupDone) return;
      [self placeViews];
      }
      --
      1.5.3.4


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.