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

[PATCH] Add -drawInsertionPointAtRow:column:fraction:color: support.

Expand Messages
  • Jjgod Jiang
    Hi all MacVim developers, Sorry for not being able to continue my unfinished MMAtsuiTextView work earlier, a lot of stuff remains to be done, but I think Nico
    Message 1 of 1 , Feb 11, 2008
    View Source
    • 0 Attachment
      Hi all MacVim developers,

      Sorry for not being able to continue my unfinished MMAtsuiTextView work
      earlier, a lot of stuff remains to be done, but I think Nico is right,
      I should start sending patches one by one, simpler one come first.

      Here is a patch to add cursor drawing. I haven't verify all the shape/
      fraction combinations yet, hopefully it's right.

      ---
      src/MacVim/MMAtsuiTextView.m | 29 ++++++++++++++++++++++++++++-
      1 files changed, 28 insertions(+), 1 deletions(-)

      diff --git a/src/MacVim/MMAtsuiTextView.m b/src/MacVim/MMAtsuiTextView.m
      index 3e4b73a..c81e265 100644
      --- a/src/MacVim/MMAtsuiTextView.m
      +++ b/src/MacVim/MMAtsuiTextView.m
      @@ -70,6 +70,7 @@ enum {


      @interface MMAtsuiTextView (Drawing)
      +- (NSPoint)originForRow:(int)row column:(int)column;
      - (NSRect)rectFromRow:(int)row1 column:(int)col1
      toRow:(int)row2 column:(int)col2;
      - (NSSize)textAreaSize;
      @@ -864,10 +865,16 @@ enum {

      @implementation MMAtsuiTextView (Drawing)

      +- (NSPoint)originForRow:(int)row column:(int)col
      +{
      + return NSMakePoint(col * cellSize.width, row * cellSize.height);
      +}
      +
      - (NSRect)rectFromRow:(int)row1 column:(int)col1
      toRow:(int)row2 column:(int)col2
      {
      - return NSMakeRect(col1 * cellSize.width, row1 * cellSize.height,
      + NSPoint origin = [self originForRow: row1 column: col1];
      + return NSMakeRect(origin.x, origin.y,
      (col2 + 1 - col1) * cellSize.width,
      (row2 + 1 - row1) * cellSize.height);
      }
      @@ -1003,6 +1010,26 @@ enum {
      - (void)drawInsertionPointAtRow:(int)row column:(int)col shape:(int)shape
      fraction:(int)percent color:(NSColor *)color
      {
      + NSPoint origin = [self originForRow:row column:col];
      + NSRect rect = NSMakeRect(origin.x, origin.y, cellSize.width, cellSize.height);
      +
      + // NSLog(@"shape = %d, fraction: %d", shape, percent);
      +
      + if (MMInsertionPointHorizontal == shape) {
      + int frac = (cellSize.height * percent + 99)/100;
      + rect.origin.y += rect.size.height - frac;
      + rect.size.height = frac;
      + } else if (MMInsertionPointVertical == shape) {
      + int frac = (cellSize.width * percent + 99)/100;
      + rect.size.width = frac;
      + }
      +
      + [color set];
      + if (MMInsertionPointHollow == shape) {
      + NSFrameRect(rect);
      + } else {
      + NSRectFill(rect);
      + }
      }

      @end // MMAtsuiTextView (Drawing)
      --
      1.5.3.2


      --~--~---------~--~----~------------~-------~--~----~
      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.