From: Marc <ma...@da...> - 2008-09-25 19:33:21
|
Am 25.09.2008 um 21:27 schrieb Marc: > Hi folks, > back in April I've sent an e-mail that talked about a patch but dumb > as I am I forgot to add the patch. Here it is. > > This patch adds a new cursor type that improves the visibility of > the cursor. > > Currently you have to specify the cursor color. This just doesn't > work when you have changing dark and bright backgrounds. The > solution is to do it like other terminal applications, e.g. KDE's > Konsole. The cursor background is the characters foreground color > and vice versa. Together with blinking this ensures that the cursor > is always visible. > > The attached patch does not contain the necessary GUI changes for > the preferences panel. I just couldn't find a good way (one that I > thought would be good enough for other users) to do that UI-wise and > my XCode experience is still very low. So whoever wants to > incorporate the patch needs to add the corresponding GUI stuff or > use "defaults" to set it: > > defaults write net.sourceforge.iTerm CursorType 3 > > Bye, > Marc Same as my other patch... braindead mailing list software, it seems. Here is the patch inline... if that still doesn't work I'll post it on my homepage and send the link. Index: PTYTextView.m =================================================================== RCS file: /cvsroot/iterm/iTerm/PTYTextView.m,v retrieving revision 1.307 diff -u -r1.307 PTYTextView.m --- PTYTextView.m 17 Jun 2007 01:56:31 -0000 1.307 +++ PTYTextView.m 11 Apr 2008 20:25:06 -0000 @@ -761,6 +761,7 @@ int bgstart; BOOL hasBGImage = [(PTYScrollView *)[self enclosingScrollView] backgroundImage] != nil; BOOL fillBG = NO; + unichar aChar; float trans = useTransparency ? 1.0 - transparency : 1.0; @@ -1019,12 +1020,12 @@ else { NSFrameRect(NSMakeRect(floor(x1 * charWidth + MARGIN), - (y1+[dataSource numberOfLines]-[dataSource height])*lineHeight + (lineHeight - cursorHeight), - ceil(cursorWidth), cursorHeight)); + (y1+[dataSource numberOfLines]-[dataSource height])*lineHeight + (lineHeight - cursorHeight), + ceil(cursorWidth), cursorHeight)); } // draw any character on cursor if we need to - unichar aChar = theLine[x1].ch; + aChar = theLine[x1].ch; if (aChar) { if (aChar == 0xffff && x1>0) @@ -1041,7 +1042,47 @@ Y: (y1+[dataSource numberOfLines]-[dataSource height] +1)*lineHeight doubleWidth: double_width]; } - + + break; + case CURSOR_BOXINVERS: + if([[self window] isKeyWindow]) + { + // Active window. Draw the cursor in the character foreground color. + [[self colorForCode:(theLine[x1].fg_color & 0x3ff)] set]; + NSRectFill(NSMakeRect(floor(x1 * charWidth + MARGIN), + (y1+[dataSource numberOfLines]-[dataSource height])*lineHeight + (lineHeight - cursorHeight), + ceil(cursorWidth), cursorHeight)); + } + else + { + // If the window is inactive then just draw a border around the character + // and leave. The border is of the same color as the character. + [[self colorForCode:(theLine[x1].fg_color & 0x3ff)] set]; + NSFrameRect(NSMakeRect(floor(x1 * charWidth + MARGIN), + (y1+[dataSource numberOfLines]-[dataSource height])*lineHeight + (lineHeight - cursorHeight), + ceil(cursorWidth), cursorHeight)); + break; + } + + // Draw any character on cursor if we need to. Draw it in the background color. + aChar = theLine[x1].ch; + if (aChar) + { + if (aChar == 0xffff && x1>0) + { + i--; + x1--; + aChar = theLine[x1].ch; + } + double_width = (x1 < WIDTH-1) && (theLine[x1+1].ch == 0xffff); + [self _drawCharacter: aChar + fgColor: theLine[x1].bg_color + bgColor: -1 + AtX: x1 * charWidth + MARGIN + Y: (y1+[dataSource numberOfLines]-[dataSource height] +1)*lineHeight + doubleWidth: double_width]; + } + break; case CURSOR_VERTICAL: NSRectFill(NSMakeRect(floor(x1 * charWidth + MARGIN), Index: Headers/iTerm/PreferencePanel.h =================================================================== RCS file: /cvsroot/iterm/iTerm/Headers/iTerm/PreferencePanel.h,v retrieving revision 1.56 diff -u -r1.56 PreferencePanel.h --- Headers/iTerm/PreferencePanel.h 15 Feb 2007 03:23:11 -0000 1.56 +++ Headers/iTerm/PreferencePanel.h 11 Apr 2008 20:25:26 -0000 @@ -33,7 +33,7 @@ @class iTermController; @class TreeNode; -typedef enum { CURSOR_UNDERLINE, CURSOR_VERTICAL, CURSOR_BOX } ITermCursorType; +typedef enum { CURSOR_UNDERLINE, CURSOR_VERTICAL, CURSOR_BOX, CURSOR_BOXINVERS } ITermCursorType; @interface PreferencePanel : NSWindowController { -- Marc Haisenko ma...@da... |