Skip to content
Snippets Groups Projects
Commit 0322d0ff authored by George Nachman's avatar George Nachman
Browse files

Merge branch 'master' of github.com:gnachman/iTerm2

parents ba7056f5 7ead4bcd
No related branches found
No related tags found
No related merge requests found
Showing
with 3898 additions and 1275 deletions
Loading
Loading
@@ -148,8 +148,6 @@
- (void)onDoubleClick:(id)sender;
- (void)eraseQuery;
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize;
- (id)retain;
- (oneway void)release;
- (void)turnOnDebug;
- (NSTableView*)tableView;
- (id)delegate;
Loading
Loading
Loading
Loading
@@ -910,19 +910,6 @@ typedef enum { IsDefault = 1, IsNotDefault = 2 } BookmarkRowIsDefault;
[tableView_ setFrame:tableViewFrame];
}
 
- (id)retain
{
if (debug)
NSLog(@"Object at %x retain. Count is now %d", (void*)self, [self retainCount]+1);
return [super retain];
}
- (oneway void)release
{
if (debug)
NSLog(@"Object at %x release. Count is now %d", (void*)self, [self retainCount]-1);
[super release];
}
- (void)turnOnDebug
{
NSLog(@"Debugging object at %x. Current count is %d", (void*)self, [self retainCount]);
Loading
Loading
Loading
Loading
@@ -58,7 +58,7 @@ typedef enum {
 
// Maps a frame key number to DVRIndexEntry*.
NSMutableDictionary* index_;
// First key in index.
long long firstKey_;
 
Loading
Loading
@@ -76,6 +76,9 @@ typedef enum {
 
// Non-inclusive end of circular buffer's used regino.
long long end_;
// this must always equal index_.
id sanityCheck; // TODO(georgen): remove this after the source of corruption of index_ is found
}
 
- (id)initWithBufferCapacity:(long long)capacity;
Loading
Loading
Loading
Loading
@@ -39,6 +39,7 @@
capacity_ = maxsize;
store_ = malloc(maxsize);
index_ = [[NSMutableDictionary alloc] init];
sanityCheck = index_;
firstKey_ = 0;
nextKey_ = 0;
begin_ = 0;
Loading
Loading
@@ -49,14 +50,17 @@
 
- (void)dealloc
{
assert(index_ == sanityCheck);
[index_ release];
index_ = nil;
sanityCheck = nil;
free(store_);
[super dealloc];
}
 
- (BOOL)reserve:(long long)length
{
assert(index_ == sanityCheck);
BOOL hadToFree = NO;
while (![self hasSpaceAvailable:length]) {
assert(nextKey_ > firstKey_);
Loading
Loading
@@ -72,11 +76,13 @@
} else {
scratch_ = store_ + end_;
}
assert(index_ == sanityCheck);
return hadToFree;
}
 
- (long long)allocateBlock:(long long)length
{
assert(index_ == sanityCheck);
assert([self hasSpaceAvailable:length]);
DVRIndexEntry* entry = [[DVRIndexEntry alloc] init];
entry->position = scratch_ - store_;
Loading
Loading
@@ -87,27 +93,33 @@
long long key = nextKey_++;
[index_ setObject:entry forKey:[NSNumber numberWithLongLong:key]];
[entry release];
assert(index_ == sanityCheck);
 
return key;
}
 
- (void)deallocateBlock
{
assert(index_ == sanityCheck);
long long key = firstKey_++;
DVRIndexEntry* entry = [self entryForKey:key];
begin_ = entry->position + entry->frameLength;
[index_ removeObjectForKey:[NSNumber numberWithLongLong:key]];
assert(index_ == sanityCheck);
}
 
- (void*)blockForKey:(long long)key
{
assert(index_ == sanityCheck);
DVRIndexEntry* entry = [self entryForKey:key];
assert(entry);
assert(index_ == sanityCheck);
return store_ + entry->position;
}
 
- (BOOL)hasSpaceAvailable:(long long)length
{
assert(index_ == sanityCheck);
if (begin_ <= end_) {
// ---begin*******end-----
if (capacity_ - end_ > length) {
Loading
Loading
@@ -129,32 +141,38 @@
 
- (long long)firstKey
{
assert(index_ == sanityCheck);
return firstKey_;
}
 
- (long long)lastKey
{
assert(index_ == sanityCheck);
return nextKey_ - 1;
}
 
- (DVRIndexEntry*)entryForKey:(long long)key
{
assert(index_ == sanityCheck);
assert(index_);
return [index_ objectForKey:[NSNumber numberWithLongLong:key]];
}
 
- (char*)scratch
{
assert(index_ == sanityCheck);
return scratch_;
}
 
- (long long)capacity
{
assert(index_ == sanityCheck);
return capacity_;
}
 
- (BOOL)isEmpty
{
assert(index_ == sanityCheck);
return [index_ count] == 0;
}
 
Loading
Loading
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
No preview for this file type
Loading
Loading
@@ -22,8 +22,6 @@
NOTE: WORK IN PROGRESS
USE WITH CAUTION AND TEST WITH ABANDON */
 
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
Loading
Loading
@@ -108,6 +106,7 @@ pre, code, kbd, samp { font-family: monospace, sans-serif; }
* should be in multiples of 18px.
*/
 
body {
background-color: #000;
color: #eee;
Loading
Loading
@@ -508,7 +507,7 @@ html.no-js .back-to-top { float: right; }
 
<p>If you hold shift while clicking the existing selection is extended.</p>
 
<p>If you hold cmd and click on a URL it will be opened.</p>
<p>If you hold cmd and click on a URL it will be opened. If you hold cmd and click on a filename, it will be opened. There is special support for Macvim, Textmate, and BBEdit when you cmd-click on a text file's name: if it is followed by a colon and line number, the file will be opened at that line number. The current directory is tracked if you have your shell prompt set the window title, <a href="http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#toc4">as described here</a>. </p>
 
<p>If you hold cmd you can drag and drop selected text.</p>
 
Loading
Loading
@@ -610,7 +609,7 @@ html.no-js .back-to-top { float: right; }
 
<h4>Regular Expression Search</h4>
 
<p>When you open the find field (cmd-f) there is a down arrow on the left of the field by the magnifying glass. Clicking it opens a menu of options in which you can enable regular expression search. The <a href="http://userguide.icu-project.org/strings/regexp#TOC-Regular-Expression-Metacharacters">ICU syntax</a> is used.</p>
<p>When you open the find field (cmd-f) there is a down-arrow on the left of the field by the magnifying glass. Clicking it opens a menu of options in which you can enable regular expression search. The <a href="http://userguide.icu-project.org/strings/regexp#TOC-Regular-Expression-Metacharacters">ICU syntax</a> is used.</p>
 
<p><br/>
<br/></p>
Loading
Loading
@@ -631,7 +630,7 @@ html.no-js .back-to-top { float: right; }
 
<h4>Instant Replay</h4>
 
<p>Sometimes interactive programs will overwrite something of interest on the screen (for example, top(1) does this all the time). Normally, this would be lost forever. With Instant Replay, you can step back in time to see exactly what was on your screen at some point in the recent past. To enable, press cmd-opt-B. Once you are in instant replay mode, you can use the left and right arrow keys to navigate back and forward through time. Holding down shift while pressing the arrow keys moves through time at 15x speed. Esc exits instant replay mode. By default, each session uses up to 4MB to save its instant replay history, and this can be adjusted under Preferences &gt; General &gt; Instant Replay uses __ MB per session.</p>
<p>Sometimes interactive programs will overwrite something of interest on the screen (for example, top(1) does this all the time). Normally, this would be lost forever. With Instant Replay, you can step back in time to see exactly what was on your screen at some point in the recent past. To enable, press cmd-opt-B. Once you are in instant replay mode, you can use the left and right arrow keys to navigate back and forward through time. Esc exits instant replay mode. By default, each session uses up to 4MB to save its instant replay history, and this can be adjusted under Preferences &gt; General &gt; Instant Replay uses __ MB per session.</p>
 
<p>Another benefit of Instant Replay is that it shows you the exact time that something appeared on your screen down to the second. This is useful when trying to figure out when an error occurred, for example.</p>
 
Loading
Loading
@@ -1039,6 +1038,7 @@ set t_Co=256
<li>$$PASSWORD$$ The password portion of a url like scheme://user:password@host/</li>
<li>$$PORT$$ The port number of a url like scheme://host:port/</li>
<li>$$PATH$$ The path portion of a url like scheme://host/path</li>
<li>$$RES$$ The portion of a url following the scheme.</li>
</ul>
 
<p><br/></p>
Loading
Loading
@@ -1171,6 +1171,82 @@ set t_Co=256
 
<p><br/></p>
 
<h3>Profiles &gt; Terminal</h3>
<p><br/><br/></p>
<h4>Automatically close a session when it ends</h4>
<p>If selected, a session's pane, tab, or window will automatically close when the session ends.</p>
<p><br/><br/></p>
<h4>Silence bell</h4>
<p>If selected, the bell (control-G) will not make an audible sound.</p>
<p><br/><br/></p>
<h4>Bell icon in tabs</h4>
<p>If selected, tabs will indicate that a bell has rung by displaying a bell graphic.</p>
<p><br/><br/></p>
<h4>Visual bell</h4>
<p>If selected, a bell graphic will be flashed when the bell character is received.</p>
<p><br/><br/></p>
<h4>Character encoding</h4>
<p>The encoding to send and receive in. For most people, "Unicode (UTF-8)" is the right choice.</p>
<p><br/><br/></p>
<h4>Scrollback lines</h4>
<p>The number of lines of scrollback buffer to keep above the visible part of the screen.</p>
<p><br/><br/></p>
<h4>Save lines to scrollback when an app status bar is present</h4>
<p>Some programs (such as vim or tmux) keep a status bar at the bottom of the screen. For some applications (like vim) it is undesirable to save lines to the scrollback buffer when the application scrolls. For others (like tmux) you may want to save scrolled-off lines into the scrollback buffer. When this setting is enabled, lines scrolled off the top of the screen in the presence of a status bar are added to the scrollback buffer. The screen is considered to have a status bar if it has a scroll region whose top is the first line of the screen and whose bottom is above the bottom of the screen.</p>
<p><br/><br/></p>
<h4>Report terminal type</h4>
<p>The TERM variable will be set to this value by default. If xterm-256color is selected and your system is missing the terminfo file, you will be prompted to install it when you open a new session.</p>
<p><br/><br/></p>
<h4>Enable xterm mouse reporting</h4>
<p>If selected, applications may choose to receive information about the mouse. This can be temporarily disabled by holding down Option.</p>
<p><br/><br/></p>
<h4>Disable save/restore alternate screen</h4>
<p>Some programs (such as vim, tmux, and less) switch into a so-called "alternate screen". A characteristic of this behavior is that when these programs terminate the screen's contents are restored to their state from before the program was run. If this option is selected, alternate screen mode is disabled and the screen cannot be restored by an application.</p>
<p><br/><br/></p>
<h4>When idle, send ASCII code</h4>
<p>If selected, the specified ASCII code will be transmitted every 30 seconds while nothing is happening. Don't use this unless you know what you're doing as it can have unexpected consequences.</p>
<p><br/><br/></p>
<h4>Enable Growl notifications</h4>
<p>If selected and Growl is installed, iTerm2 will post a Growl notification when sessions receive output, become idle, ring the bell, or close. </p>
<p><br/></p>
<h3>Profiles &gt; Keys</h3>
 
<p>This panel shows key mappings. You can double-click on a mapping to edit it. When the "Keyboard Shortcut" field has focus, you should press the keystroke that you want to modify (even if it involves modifiers like Cmd). The following actions are available:</p>
Loading
Loading
@@ -1259,7 +1335,7 @@ set t_Co=256
 
<p>This action allows you to enter the name of an iTerm2 menu item. It must be entered exactly the same as it appears in the menu. Ellipses can be typed with option-semicolon.</p>
 
<p>You can add a new keymapping by pressing "+". You can remove an existing mapping by selecting it and pressing "-". Two presets are provided: "Xterm defaults" is the normal key mappings, while "Xterm defaults with numeric keypad" disables the "application keypad" in favor of the numbers and symbols that the numeric keypad typically emits.</p>
<p>You can add a new keymapping by pressing "+". You can remove an existing mapping by selecting it and pressing "-". Three presets are provided: "Xterm defaults" is the normal key mappings, while "Xterm defaults with numeric keypad" disables the "application keypad" in favor of the numbers and symbols that the numeric keypad typically emits. "Terminal.app Compatability" tries to emulate the way that Terminal.app sends keys by default.</p>
 
<p><br/><br/></p>
 
Loading
Loading
@@ -1355,6 +1431,28 @@ The default is to use google. You can set it to anything you want.</p>
-float 0.25
</pre>
 
<p>You can adjust the amount of dimming of split panes. Set the value to a floating-point number between 0 (no dimming) and 1 (complete dimming). The default is 0.15:</p>
<pre>
defaults write com.googlecode.iterm2 SplitPaneDimmingAmount \
-float 0.25
</pre>
<p>If you don't mind <strong>extreme slowness</strong> you can turn on adjustable font width:</p>
<pre>
defaults write com.googlecode.iterm2 HiddenAdvancedFontRendering -bool true
defaults write com.googlecode.iterm2 HiddenAFRStrokeThickness -float -0.1
</pre>
<p>The second parameter is a negative number, where values close to 0 are thin and very negative values are thick.</p>
<p>If you'd like to receive Growl notifications for foreground tabs, which is useful as an accessibility feature, use this command:</p>
<pre>
defaults write com.googlecode.iterm2 GrowlOnForegroundTabs -bool true
</pre>
<p><br/>
<br/>
<br/>
Loading
Loading
@@ -1564,16 +1662,14 @@ you input mult-bytes characters to tcsh, this patch may help you to edit the cha
<p>There are people with hints on ways to customize the title bar and tabs, a
much simpler way when using zsh is to do the following:</p>
 
<pre><code>precmd () {
echo -n "\033]1;$USERNAME@$HOST^G\033]2;$PWD&gt; - $USERNAME@$HOST
($status)^G"
<pre><code>bell=`tput bel`
precmd () {
echo -n "\033]1;$USERNAME@$HOST$bell\033]2;$PWD&gt; - $USERNAME@$HOST ($status)$bell"
}
PROMPT='%m %B%3c%(#.#.&gt;)%b '
RPROMPT=''
</code></pre>
 
<p>(NOTE: <code>^G</code> is CTRL-G, you need to enter it using <code>^V^G</code>)</p>
<p>Much simpler and does not require anything special. (apart from zsh)</p>
 
<p>Also in zsh, the command line completion I have expanded to be
Loading
Loading
@@ -1622,8 +1718,8 @@ application... (added an alias run as well)</p>
<p>Add this to your .vimrc to change cursor shape in insert mode:</p>
 
<pre>
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
let &t_SI = "\&lt;Esc&gt;]50;CursorShape=1\x7"
let &t_EI = "\&lt;Esc&gt;]50;CursorShape=0\x7"
</pre>
 
<p>This is derived from <a href="http://vim.wikia.com/wiki/Change_cursor_shape_in_different_modes">Konsole</a>.</p>
Loading
Loading
Loading
Loading
@@ -17,6 +17,7 @@
 
// Saved state from old window.
BOOL isFullScreen;
BOOL isLionFullScreen;
BOOL isMiniaturized;
NSRect frame;
NSScreen* screen;
Loading
Loading
@@ -25,6 +26,7 @@
// Changes the session has initiated that will be delayed and performed
// in -[rejoin:].
BOOL hasPendingBlurChange;
double pendingBlurRadius;
BOOL pendingBlur;
BOOL hasPendingClose;
BOOL hasPendingFitWindowToTab;
Loading
Loading
@@ -46,6 +48,7 @@
 
- (void)sessionInitiatedResize:(PTYSession*)session width:(int)width height:(int)height;
- (BOOL)fullScreen;
- (BOOL)anyFullScreen;
- (BOOL)sendInputToAllSessions;
- (void)closeSession:(PTYSession*)aSession;
- (IBAction)nextTab:(id)sender;
Loading
Loading
@@ -53,7 +56,7 @@
- (void)setLabelColor:(NSColor *)color forTabViewItem:tabViewItem;
- (void)setTabColor:(NSColor *)color forTabViewItem:tabViewItem;
- (NSColor*)tabColorForTabViewItem:(NSTabViewItem*)tabViewItem;
- (void)enableBlur;
- (void)enableBlur:(double)radius;
- (void)disableBlur;
- (BOOL)tempTitle;
- (PTYTabView *)tabView;
Loading
Loading
Loading
Loading
@@ -38,8 +38,9 @@
if (!self) {
return nil;
}
isFullScreen = [aTerm fullScreen];
isLionFullScreen = [[aTerm ptyWindow] isFullScreen];
isMiniaturized = [[aTerm window] isMiniaturized];
frame = [[aTerm window] frame];
screen = [[aTerm window] screen];
Loading
Loading
@@ -64,13 +65,17 @@
{
[session release];
if (hasPendingClose) {
[aTerm closeSession:session];
// TODO(georgen): We don't honor pending closes. It's not safe to close right now because
// this may release aTerm, but aTerm may exist in the calling stack (in many places!).
// It might work to start a timer to close it, but that would have some serious unexpected
// side effects.
// [aTerm closeSession:session];
return;
}
if (hasPendingBlurChange) {
if (pendingBlur) {
[aTerm enableBlur];
[aTerm enableBlur:pendingBlurRadius];
} else {
[aTerm disableBlur];
}
Loading
Loading
@@ -107,6 +112,11 @@
return isFullScreen;
}
 
- (BOOL)anyFullScreen
{
return isLionFullScreen || isFullScreen;
}
// TODO(georgen): disable send input to all sessions when you transition to
// dvr mode; or else make it work.
- (BOOL)sendInputToAllSessions
Loading
Loading
@@ -160,9 +170,10 @@
}
}
 
- (void)enableBlur
- (void)enableBlur:(double)radius
{
hasPendingBlurChange = YES;
pendingBlurRadius = radius;
pendingBlur = YES;
}
 
Loading
Loading
Loading
Loading
@@ -104,5 +104,6 @@
- (void)findString:(NSString*)string;
 
- (void)setDelegate:(id<FindViewControllerDelegate>)delegate;
- (id<FindViewControllerDelegate>)delegate;
 
@end
Loading
Loading
@@ -376,4 +376,9 @@ static const float FINDVIEW_DURATION = 0.075;
delegate_ = delegate;
}
 
- (id<FindViewControllerDelegate>)delegate
{
return delegate_;
}
@end
// -*- mode:objc -*-
/*
** FontSizeEstimator.h
**
** Copyright (c) 2011
**
** Author: George Nachman
**
** Project: iTerm2
**
** Description: Attempts to measure font metrics because the OS's metrics
** are sometimes unreliable.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import <Cocoa/Cocoa.h>
@interface FontSizeEstimator : NSObject {
NSSize osBound;
NSSize size;
double baseline;
}
@property (nonatomic, assign) NSSize size;
@property (nonatomic, assign) double baseline;
+ (id)fontSizeEstimatorForFont:(NSFont *)aFont;
@end
// -*- mode:objc -*-
/*
** FontSizeEstimator.h
**
** Copyright (c) 2011
**
** Author: George Nachman
**
** Project: iTerm2
**
** Description: Attempts to measure font metrics because the OS's metrics
** are sometimes unreliable.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import "FontSizeEstimator.h"
// Constants for converting RGB to luma.
#define RED_COEFFICIENT 0.30
#define GREEN_COEFFICIENT 0.59
#define BLUE_COEFFICIENT 0.11
static const double kBrightnessThreshold = 0.95;
@implementation FontSizeEstimator
@synthesize size;
@synthesize baseline;
static double Brightness(NSColor* c) {
const double r = [c redComponent];
const double g = [c greenComponent];
const double b = [c blueComponent];
return (RED_COEFFICIENT * r) + (GREEN_COEFFICIENT * g) + (BLUE_COEFFICIENT * b);
}
- (NSSize)osEstimate:(NSFont *)aFont
{
if (!osBound.width) {
osBound = NSZeroSize;
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
[dic setObject:aFont forKey:NSFontAttributeName];
for (unichar i = 'A'; i <= 'Z'; i++) {
NSString* s = [NSString stringWithCharacters:&i length:1];
NSSize charSize = [s sizeWithAttributes:dic];
osBound.width = MAX(size.width, charSize.width);
osBound.height = MAX(size.height, charSize.height);
}
}
return osBound;
}
- (NSImage *)imageForString:(NSString*)s withFont:(NSFont*)aFont
{
NSSize osSize = [self osEstimate:aFont];
NSSize estimate = osSize;
estimate.width *= 4;
estimate.height *= 4;
NSImage *image = [[[NSImage alloc] initWithSize:NSMakeSize(estimate.width, estimate.height)] autorelease];
[image lockFocus];
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
assert(ctx);
CGContextSetShouldAntialias(ctx, YES);
[[NSColor whiteColor] set];
NSRectFill(NSMakeRect(0, 0, estimate.width, estimate.height));
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
aFont, NSFontAttributeName,
[NSColor blackColor], NSForegroundColorAttributeName,
nil];
for (int i = 0; i < [s length]; i++) {
unichar c = [s characterAtIndex:i];
NSAttributedString *str = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%C", c]
attributes:attrs];
[str drawWithRect:NSMakeRect(0,
osSize.height * 2,
osSize.width * 2,
osSize.height * 2)
options:0];
}
[image unlockFocus];
return image;
}
+ (double)xBoundOfImage:(NSImage *)i startingAt:(int)startAt dir:(int)dir
{
int maxX = [i size].width;
int maxY = [i size].height;
int x;
[i lockFocus];
for (x = startAt; x >= 0 && x < maxX; x += dir) {
for (int y = 0; y < maxY; y++) {
NSColor *c = NSReadPixel(NSMakePoint(x, maxY - y - 1));
if (Brightness(c) < kBrightnessThreshold) {
[i unlockFocus];
return x;
}
}
}
[i unlockFocus];
return x;
}
+ (double)yBoundOfImage:(NSImage *)i startingAt:(int)startAt dir:(int)dir
{
int maxX = [i size].width;
int maxY = [i size].height;
int y;
[i lockFocus];
for (y = startAt; y >= 0 && y < maxY; y += dir) {
for (int x = 0; x < maxX; x++) {
NSColor *c = NSReadPixel(NSMakePoint(x, maxY - y - 1));
if (Brightness(c) < kBrightnessThreshold) {
[i unlockFocus];
return y;
}
}
}
[i unlockFocus];
return y;
}
+ (void)dumpImage:(NSImage *)i
{
[i lockFocus];
for (int y = [i size].height - 1; y >= 0; y--) {
unichar temp[1000];
int x;
for (x = 0; x < [i size].width; x++) {
NSColor *c = NSReadPixel(NSMakePoint(x, y));
//NSLog(@"%@ %lf", c, Brightness(c));
if (Brightness(c) < kBrightnessThreshold) {
temp[x] = '#';
} else {
temp[x] = ' ';
}
}
int n = [i size].height - 1 - y;
NSLog(@"%04d %@", n, [NSString stringWithCharacters:temp length:x]);
}
[i unlockFocus];
}
- (NSRect)boundsOfImage:(NSImage *)i
{
// [FontSizeEstimator dumpImage:i];
NSRect result = NSZeroRect;
result.origin.x = [FontSizeEstimator xBoundOfImage:i startingAt:0 dir:1];
result.size.width = [FontSizeEstimator xBoundOfImage:i startingAt:[i size].width-1 dir:-1] - result.origin.x + 1;
result.origin.y = [FontSizeEstimator yBoundOfImage:i startingAt:0 dir:1];
result.size.height = [FontSizeEstimator yBoundOfImage:i startingAt:[i size].height-1 dir:-1] - result.origin.y + 1;
return result;
}
- (id)initWithSize:(NSSize)s baseline:(double)b
{
self = [super init];
if (self) {
size = s;
baseline = b;
}
return self;
}
+ (id)fontSizeEstimatorForFont:(NSFont *)aFont
{
FontSizeEstimator* fse = [[[FontSizeEstimator alloc] init] autorelease];
if (fse) {
NSMutableString *allAscii = [NSMutableString stringWithCapacity:128-32];
for (int i = 32; i < 128; i++) {
[allAscii appendFormat:@"%c", (char)i];
}
// We get the upper bound of a character from the top of X
// We get the rightmost bound as the max of right(X) and right(x)
// We get the descender's height from bottom(y) - bottom(X)
NSImage *capXImage = [fse imageForString:@"X" withFont:aFont];
NSRect capXBounds = [fse boundsOfImage:capXImage];
NSImage *lowXImage = [fse imageForString:@"x" withFont:aFont];
NSRect lowXBounds = [fse boundsOfImage:lowXImage];
NSImage *lowYImage = [fse imageForString:allAscii withFont:aFont];
NSRect lowYBounds = [fse boundsOfImage:lowYImage];
NSSize s;
double b;
double capXMaxX = capXBounds.origin.x + capXBounds.size.width;
double lowXMaxX = lowXBounds.origin.x + lowXBounds.size.width;
s.width = MAX(capXMaxX, lowXMaxX);
s.height = lowYBounds.origin.y + lowYBounds.size.height - capXBounds.origin.y;
double lowYMaxY = lowYBounds.origin.y + lowYBounds.size.height;
double capXmaxY = capXBounds.origin.y + capXBounds.size.height;
b = capXmaxY - lowYMaxY;
// If the OS reports a larger size, use it.
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
[dic setObject:aFont forKey:NSFontAttributeName];
s.height = MAX(s.height, ([aFont ascender] - [aFont descender]));
s.width = MAX(s.width, [@"X" sizeWithAttributes:dic].width);
[fse setSize:s];
[fse setBaseline:b];
}
return fse;
}
@end
Loading
Loading
@@ -32,7 +32,11 @@
@interface PTYScroller : NSScroller
{
BOOL userScroll;
BOOL hasDarkBackground;
}
@property (nonatomic, assign) BOOL hasDarkBackground;
+ (BOOL)isCompatibleWithOverlayScrollers;
- (id)init;
- (void) mouseDown: (NSEvent *)theEvent;
Loading
Loading
Loading
Loading
@@ -250,6 +250,12 @@ typedef struct PTYFontInfo PTYFontInfo;
NSMutableArray* lineBreakIndexOffsets_;
// For accessibility. This is the actual indices at which newlines occcur in allText_.
NSMutableArray* lineBreakCharOffsets_;
// Brightness of background color
double backgroundBrightness_;
// Dim everything but the default background color.
BOOL dimOnlyText_;
}
 
+ (NSCursor *)textViewCursor;
Loading
Loading
@@ -312,12 +318,13 @@ typedef struct PTYFontInfo PTYFontInfo;
- (void)setBlinkingCursor:(BOOL)bFlag;
- (void)setBlinkAllowed:(BOOL)value;
- (void)setCursorType:(ITermCursorType)value;
- (void)setDimOnlyText:(BOOL)value;
 
//color stuff
- (NSColor*)defaultFGColor;
- (NSColor*)defaultBGColor;
- (NSColor*)defaultBoldColor;
- (NSColor*)colorForCode:(int)theIndex alternateSemantics:(BOOL)alt bold:(BOOL)isBold;
- (NSColor*)colorForCode:(int)theIndex alternateSemantics:(BOOL)alt bold:(BOOL)isBold isBackground:(BOOL)isBackground;
- (NSColor*)selectionColor;
- (NSColor*)defaultCursorColor;
- (NSColor*)selectedTextColor;
Loading
Loading
@@ -478,7 +485,7 @@ typedef enum {
CHARTYPE_OTHER, // Symbols, etc. Anything that doesn't fall into the other categories.
} PTYCharType;
 
- (void)modifyFont:(NSFont*)font info:(PTYFontInfo*)fontInfo;
- (void)modifyFont:(NSFont*)font baseline:(double)baseline info:(PTYFontInfo*)fontInfo;
- (void)releaseFontInfo:(PTYFontInfo*)fontInfo;
 
- (unsigned int) _checkForSupportedDragTypes:(id <NSDraggingInfo>) sender;
Loading
Loading
@@ -521,7 +528,7 @@ typedef enum {
- (void)_dragText:(NSString *)aString forEvent:(NSEvent *)theEvent;
- (BOOL)_isCharSelectedInRow:(int)row col:(int)col checkOld:(BOOL)old;
- (void)_settingsChanged:(NSNotification *)notification;
- (void)_modifyFont:(NSFont*)font into:(PTYFontInfo*)fontInfo;
- (void)_modifyFont:(NSFont*)font baseline:(double)baseline into:(PTYFontInfo*)fontInfo;
- (PTYFontInfo*)getFontForChar:(UniChar)ch
isComplex:(BOOL)complex
fgColor:(int)fgColor
Loading
Loading
@@ -559,5 +566,6 @@ typedef enum {
// Returns true if any onscreen char is blinking.
- (BOOL)_markChangedSelectionAndBlinkDirty:(BOOL)redrawBlink width:(int)width;
 
- (double)_perceivedBrightness:(NSColor*)c;
@end
 
Loading
Loading
@@ -7,7 +7,7 @@
** Copyright (c) 2002, 2003
**
** Author: Fabian, Ujwal S. Setlur
** Initial code by Kiichi Kusama
** Initial code by Kiichi Kusama
**
** Project: iTerm
**
Loading
Loading
@@ -46,24 +46,33 @@
 
@interface PTYWindow : NSWindow
{
int blurFilter;
BOOL layoutDone;
int blurFilter;
double blurRadius_;
BOOL layoutDone;
// True if in OS 10.7 fullscreen mode.
BOOL isFullScreen_;
// True while in -[NSWindow toggleFullScreen:].
BOOL isTogglingLionFullScreen_;
}
 
- initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)aStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag;
- initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)aStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag;
 
- (void)toggleToolbarShown:(id)sender;
 
- (void)smartLayout;
- (void)setLayoutDone;
 
- (void)enableBlur;
- (void)enableBlur:(double)radius;
- (void)disableBlur;
 
- (int)screenNumber;
- (BOOL)isFullScreen;
- (BOOL)isTogglingLionFullScreen;
 
@end
 
Loading
Loading
@@ -176,10 +176,26 @@ typedef enum { CURSOR_UNDERLINE, CURSOR_VERTICAL, CURSOR_BOX } ITermCursorType;
IBOutlet NSButton* dimInactiveSplitPanes;
BOOL defaultDimInactiveSplitPanes;
 
// Dim background windows
IBOutlet NSButton* dimBackgroundWindows;
BOOL defaultDimBackgroundWindows;
// Dim text (and non-default background colors)
IBOutlet NSButton* dimOnlyText;
BOOL defaultDimOnlyText;
// Dimming amount
IBOutlet NSSlider* dimmingAmount;
float defaultDimmingAmount;
// Window border
IBOutlet NSButton* showWindowBorder;
BOOL defaultShowWindowBorder;
 
// Lion-style fullscreen
IBOutlet NSButton* lionStyleFullscreen;
BOOL defaultLionStyleFullscreen;
// hide scrollbar and resize
IBOutlet NSButton *hideScrollbar;
BOOL defaultHideScrollbar;
Loading
Loading
@@ -188,10 +204,6 @@ typedef enum { CURSOR_UNDERLINE, CURSOR_VERTICAL, CURSOR_BOX } ITermCursorType;
IBOutlet NSButton *smartPlacement;
BOOL defaultSmartPlacement;
 
// Delay before showing tabs in fullscreen mode
IBOutlet NSSlider* fsTabDelay;
float defaultFsTabDelay;
// Window/tab title customization
IBOutlet NSButton* windowNumber;
BOOL defaultWindowNumber;
Loading
Loading
@@ -335,6 +347,7 @@ typedef enum { CURSOR_UNDERLINE, CURSOR_VERTICAL, CURSOR_BOX } ITermCursorType;
IBOutlet NSButton* useBrightBold;
IBOutlet NSSlider *transparency;
IBOutlet NSButton* blur;
IBOutlet NSSlider *blurRadius;
IBOutlet NSButton* asciiAntiAliased;
IBOutlet NSButton* nonasciiAntiAliased;
IBOutlet NSButton* backgroundImage;
Loading
Loading
@@ -456,7 +469,6 @@ typedef enum { BulkCopyColors, BulkCopyDisplay, BulkCopyWindow, BulkCopyTerminal
- (IBAction)settingChanged:(id)sender;
- (BOOL)advancedFontRendering;
- (float)strokeThickness;
- (float)fsTabDelay;
- (int)modifierTagToMask:(int)tag;
- (void)windowWillLoad;
- (void)windowWillClose:(NSNotification *)aNotification;
Loading
Loading
@@ -501,7 +513,11 @@ typedef enum { BulkCopyColors, BulkCopyDisplay, BulkCopyWindow, BulkCopyTerminal
- (NSTextField*)hotkeyField;
 
- (BOOL)showWindowBorder;
- (BOOL)lionStyleFullscreen;
- (BOOL)dimInactiveSplitPanes;
- (BOOL)dimBackgroundWindows;
- (BOOL)dimOnlyText;
- (float)dimmingAmount;
- (BOOL)checkTestRelease;
- (BOOL)legacySmartCursorColor;
- (float)legacyMinimumContrast;
Loading
Loading
Loading
Loading
@@ -185,12 +185,14 @@
// True if this window was created by dragging a tab from another window.
// Affects how its size is set when the number of tabview items changes.
BOOL wasDraggedFromAnotherWindow_;
BOOL fullscreenTabs_;
}
 
// Initialize a new PseudoTerminal.
// smartLayout: If true then position windows using the "smart layout"
// algorithm.
// windowType: WINDOW_TYPE_NORMAL, WINDOW_TYPE_FULL_SCREEN, or WINDOW_TYPE_TOP.
// windowType: WINDOW_TYPE_NORMAL, WINDOW_TYPE_FULL_SCREEN, WINDOW_TYPE_TOP, or
// WINDOW_TYPE_LION_FULL_SCREEN.
// screen: An index into [NSScreen screens], or -1 to let the system pick a
// screen.
- (id)initWithSmartLayout:(BOOL)smartLayout
Loading
Loading
@@ -200,6 +202,9 @@
// The window's original screen.
- (NSScreen*)screen;
 
// The PTYWindow for this controller.
- (PTYWindow*)ptyWindow;
// Called on object deallocation.
- (void)dealloc;
 
Loading
Loading
@@ -212,6 +217,12 @@
// Get term number
- (int)number;
 
// Returns true if the window is fullscreen in either Lion-style or pre-Lion-style fullscreen.
- (BOOL)anyFullScreen;
// Returns true if the window is in 10.7-style fullscreen.
- (BOOL)lionFullScreen;
// Make the tab at [sender tag] the foreground tab.
- (void)selectSessionAtIndexAction:(id)sender;
 
Loading
Loading
@@ -231,6 +242,8 @@
// Close a session (TODO: currently just closes the tab the session is in).
- (void)closeSession:(PTYSession *)aSession;
 
- (void)toggleFullScreenTabBar;
// Close the active session.
- (IBAction)closeCurrentSession:(id)sender;
- (void)closeSessionWithConfirmation:(PTYSession *)aSession;
Loading
Loading
@@ -298,8 +311,19 @@
// one's state into it.
- (IBAction)toggleFullScreenMode:(id)sender;
 
// Enter full screen mode in the next mainloop.
- (void)delayedEnterFullscreen;
// Toggle non-Lion fullscreen mode.
- (void)toggleTraditionalFullScreenMode;
// accessor
- (BOOL)fullScreen;
- (BOOL)fullScreenTabControl;
- (BOOL)tabBarShouldBeVisible;
- (BOOL)tabBarShouldBeVisibleWithAdditionalTabs:(int)n;
- (BOOL)scrollbarShouldBeVisible;
 
// Called by VT100Screen when it wants to resize a window for a
// session-initiated resize. It resizes the session, then the window, then all
Loading
Loading
@@ -314,7 +338,7 @@
- (void)menuForEvent:(NSEvent *)theEvent menu:(NSMenu *)theMenu;
 
// setters
- (void)enableBlur;
- (void)enableBlur:(double)radius;
- (void)disableBlur;
 
// Set the text color for a tab control's name.
Loading
Loading
@@ -635,6 +659,7 @@
- (void)_drawFullScreenBlackBackground;
 
- (void)hideMenuBar;
- (void)showMenuBar;
 
// This is a half-baked function that tries to parse a command line into a
// command (returned in *cmd) and an array of arguments (returned in *path).
Loading
Loading
@@ -785,10 +810,6 @@
// Return all sessions in all tabs.
- (NSArray*)allSessions;
 
// Change visiblity of tabBarControl in fullscreen mode.
- (void)showFullScreenTabControl;
- (void)hideFullScreenTabControl;
- (void)_loadFindStringFromSharedPasteboard;
 
- (BOOL)_haveLeftBorder;
Loading
Loading
/* staight from linux/drivers/char/consolemap.c, GNU GPL:ed */
/* straight from linux/drivers/char/consolemap.c, GNU GPL:ed */
static const unichar charmap[256]={
/* VT100 graphics mapped to Unicode */
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment