Skip to content

Commit

Permalink
* Fixed a bug in VT100Screen's removeOverLine
Browse files Browse the repository at this point in the history
    * Implemented custom setting of scrollback buffer size
    * a little bit code cleanup in MainMenu and PseudoTerminal.
  • Loading branch information
Fabian committed Apr 29, 2003
1 parent 45d480d commit efdfa23
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 60 deletions.
6 changes: 6 additions & 0 deletions Changelog
@@ -1,3 +1,9 @@
2003-04-29 fabian
* Fixed a bug in VT100Screen's removeOverLine
* Implemented custom setting of scrollback buffer size
* a little bit code cleanup in MainMenu and PseudoTerminal.


2003-04-29 ujwal

* Added Applescript support for "write text <text>"
Expand Down
1 change: 1 addition & 0 deletions English.lproj/PreferencePanel.nib/classes.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion English.lproj/PreferencePanel.nib/info.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified English.lproj/PreferencePanel.nib/objects.nib
Binary file not shown.
32 changes: 2 additions & 30 deletions MainMenu.m
@@ -1,5 +1,5 @@
// -*- mode:objc -*-
// $Id: MainMenu.m,v 1.55 2003-04-29 00:24:06 ujwal Exp $
// $Id: MainMenu.m,v 1.56 2003-04-29 17:11:03 yfabian Exp $
/*
** MainMenu.m
**
Expand Down Expand Up @@ -179,10 +179,6 @@ - (void) dealloc
- (IBAction)newWindow:(id)sender
{
PseudoTerminal *term;
PTYSession *aSession;
NSString *cmd;
NSArray *arg;
int i;

#if DEBUG_METHOD_TRACE
NSLog(@"%s(%d):-[MainMenu newWindow]",
Expand All @@ -194,31 +190,7 @@ - (IBAction)newWindow:(id)sender
[term release];

[term setPreference:PREF_PANEL];
[MainMenu breakDown:[PREF_PANEL shell] cmdPath:&cmd cmdArgs:&arg];
// NSLog(@"%s(%d):-[PseudoTerminal ready to run:%@ arguments:%@]", __FILE__, __LINE__, cmd, arg );
aSession = [[PTYSession alloc] init];
// Add this session to our term and make it current
[term addInSessions: aSession];
[aSession release];

[aSession setForegroundColor: [PREF_PANEL foreground]];
[aSession setBackgroundColor: [[PREF_PANEL background] colorWithAlphaComponent: (1.0-[PREF_PANEL transparency]/100.0)]];
[aSession setSelectionColor: [PREF_PANEL selectionColor]];
[aSession setBoldColor: [PREF_PANEL boldColor]];
[aSession setEncoding: [PREF_PANEL encoding]];
// term value
[aSession setTERM_VALUE: [PREF_PANEL terminalType]];


[term startProgram:cmd arguments:arg];
[term setCurrentSessionName:nil];
[[term currentSession] setAutoClose:[PREF_PANEL autoclose]];
[[term currentSession] setDoubleWidth:[PREF_PANEL doubleWidth]];
for(i=0;i<8;i++) {
[[term currentSession] setColorTable:i highLight:NO color:[PREF_PANEL colorFromTable:i highLight:NO]];
[[term currentSession] setColorTable:i highLight:YES color:[PREF_PANEL colorFromTable:i highLight:YES]];
}

[term newSession:nil];
}

- (IBAction)newSession:(id)sender
Expand Down
3 changes: 3 additions & 0 deletions PreferencePanel.h
Expand Up @@ -67,6 +67,7 @@
IBOutlet id promptOnClose;
IBOutlet id remapDeleteKey;
IBOutlet id row;
IBOutlet id scrollbackLines;
IBOutlet id selectionColor;
IBOutlet id shell;
IBOutlet id silenceBell;
Expand All @@ -88,6 +89,7 @@

int defaultCol;
int defaultRow;
unsigned int defaultScrollback;

NSStringEncoding defaultEncoding;
NSString* defaultShell;
Expand Down Expand Up @@ -137,6 +139,7 @@
- (NSColor*) foreground;
- (int) col;
- (int) row;
- (unsigned int) scrollbackLines;
- (NSStringEncoding) encoding;
- (NSString*) shell;
- (NSString*) terminalType;
Expand Down
13 changes: 12 additions & 1 deletion PreferencePanel.m
@@ -1,4 +1,4 @@
// $Id: PreferencePanel.m,v 1.40 2003-04-28 02:03:58 yfabian Exp $
// $Id: PreferencePanel.m,v 1.41 2003-04-29 17:11:04 yfabian Exp $
/*
** PreferencePanel.m
**
Expand Down Expand Up @@ -47,6 +47,7 @@

static int COL = 80;
static int ROW = 25;
static unsigned int SCROLLBACK = 100000;

static NSString* TERM =@"xterm";
static NSString* SHELL =@"/bin/bash --login";
Expand Down Expand Up @@ -225,6 +226,7 @@ - (void) readPreferences

defaultCol=([prefs integerForKey:@"Col"]?[prefs integerForKey:@"Col"]:COL);
defaultRow=([prefs integerForKey:@"Row"]?[prefs integerForKey:@"Row"]:ROW);
defaultScrollback=([prefs integerForKey:@"Scrollback"]?[prefs integerForKey:@"Scrollback"]:SCROLLBACK);
defaultTransparency=([prefs stringForKey:@"Transparency"]!=nil?[prefs integerForKey:@"Transparency"]:TRANSPARENCY);
defaultAntiAlias=[prefs objectForKey:@"AntiAlias"]?[[prefs objectForKey:@"AntiAlias"] boolValue]: YES;

Expand Down Expand Up @@ -372,6 +374,7 @@ - (void)run

[row setIntValue:defaultRow];
[col setIntValue:defaultCol];
[scrollbackLines setIntValue:defaultScrollback];
[transparency setIntValue:defaultTransparency];
[transparency_control setIntValue:defaultTransparency];
[antiAlias setState:defaultAntiAlias?NSOnState:NSOffState];
Expand Down Expand Up @@ -500,6 +503,7 @@ - (IBAction)ok:(id)sender

defaultCol=[col intValue];
defaultRow=[row intValue];
defaultScrollback=[scrollbackLines intValue];

defaultEncoding=encodingList[[encoding indexOfSelectedItem]];
defaultShell=[shell stringValue];
Expand Down Expand Up @@ -619,6 +623,7 @@ - (IBAction)restore:(id)sender

defaultCol=COL;
defaultRow=ROW;
defaultScrollback=SCROLLBACK;

defaultEncoding=CFStringConvertEncodingToNSStringEncoding(CFStringGetSystemEncoding());
defaultShell=[SHELL copy];
Expand Down Expand Up @@ -671,6 +676,7 @@ - (IBAction)restore:(id)sender

[row setIntValue:defaultRow];
[col setIntValue:defaultCol];
[scrollbackLines setIntValue:defaultScrollback];
[transparency setIntValue:defaultTransparency];

[fontExample setTextColor:defaultForeground];
Expand Down Expand Up @@ -712,6 +718,11 @@ - (int) row
return defaultRow;
}

- (unsigned int) scrollbackLines
{
return defaultScrollback;
}

- (NSStringEncoding) encoding
{
return defaultEncoding;
Expand Down
10 changes: 2 additions & 8 deletions PseudoTerminal.m
@@ -1,5 +1,5 @@
// -*- mode:objc -*-
// $Id: PseudoTerminal.m,v 1.164 2003-04-29 15:18:17 ujwal Exp $
// $Id: PseudoTerminal.m,v 1.165 2003-04-29 17:11:04 yfabian Exp $
//
/*
** PseudoTerminal.m
Expand Down Expand Up @@ -219,6 +219,7 @@ - (void)setupSession: (PTYSession *) aSession
[[aSession SCREEN] setTextStorage:[[aSession TEXTVIEW] textStorage]];
#endif
[[aSession SCREEN] setWidth:WIDTH height:HEIGHT];
[[aSession SCREEN] setScrollback:[pref scrollbackLines]];
// NSLog(@"%d,%d",WIDTH,HEIGHT);

// set up default encoding and terminal type
Expand Down Expand Up @@ -1747,13 +1748,6 @@ -(void)insertInSessions:(PTYSession *)object atIndex:(unsigned)index
{
// NSLog(@"PseudoTerminal: -insertInSessions: 0x%x atIndex: %d", object, index);
[self setupSession: object title: nil];
[object setForegroundColor: [pref foreground]];
[object setBackgroundColor: [[pref background] colorWithAlphaComponent: (1.0-[pref transparency]/100.0)]];
[object setSelectionColor: [pref selectionColor]];
[object setBoldColor: [pref boldColor]];
[object setEncoding: [pref encoding]];
// term value
[object setTERM_VALUE: [pref terminalType]];
[self insertSession: object atIndex: index];
}

Expand Down
7 changes: 4 additions & 3 deletions VT100Screen.h
@@ -1,5 +1,5 @@
// -*- mode:objc -*-
// $Id: VT100Screen.h,v 1.29 2003-04-29 00:24:06 ujwal Exp $
// $Id: VT100Screen.h,v 1.30 2003-04-29 17:11:05 yfabian Exp $
/*
** VT100Screen.h
**
Expand Down Expand Up @@ -62,7 +62,7 @@
NSMutableArray *screenLines;

unsigned int TOP_LINE;
unsigned int LINE_LIMIT;
unsigned int scrollbackLines;
int OLD_CURSOR_INDEX;
int screenLock;

Expand All @@ -87,6 +87,8 @@
- (void)resizeWidth:(int)width height:(int)height;
- (int)width;
- (int)height;
- (unsigned int)scrollbackLines;
- (void)setScrollback:(unsigned int)lines;

- (void)setTerminal:(VT100Terminal *)terminal;
- (VT100Terminal *)terminal;
Expand All @@ -100,7 +102,6 @@
- (NSFont *)font;
- (NSFont *)nafont;
- (NSFont *)tallerFont;
- (void)setLineLimit:(unsigned int)maxline;
- (NSSize) characterSize;

- (NSView *) display;
Expand Down
40 changes: 23 additions & 17 deletions VT100Screen.m
@@ -1,5 +1,5 @@
// -*- mode:objc -*-
// $Id: VT100Screen.m,v 1.88 2003-04-29 00:24:06 ujwal Exp $
// $Id: VT100Screen.m,v 1.89 2003-04-29 17:11:05 yfabian Exp $
//
/*
** VT100Screen.m
Expand Down Expand Up @@ -46,7 +46,7 @@ @implementation VT100Screen
#define DEFAULT_HEIGHT 25
#define DEFAULT_FONTNAME @"Osaka-Mono"
#define DEFAULT_FONTSIZE 14
#define DEFAULT_LINELIMIT 1000000
#define DEFAULT_SCROLLBACK 1000

#define MIN_WIDTH 10
#define MIN_HEIGHT 3
Expand Down Expand Up @@ -175,7 +175,7 @@ - (id)init
SHELL = nil;

TOP_LINE = 0;
LINE_LIMIT = DEFAULT_LINELIMIT;
scrollbackLines = DEFAULT_SCROLLBACK;
OLD_CURSOR_INDEX=-1;
[self clearTabStop];

Expand Down Expand Up @@ -325,6 +325,16 @@ - (int)height
return HEIGHT;
}

- (unsigned int)scrollbackLines
{
return scrollbackLines;
}

- (void)setScrollback:(unsigned int)lines;
{
scrollbackLines=lines;
}

- (void)setSession:(PTYSession *)session
{
SESSION=session;
Expand Down Expand Up @@ -496,15 +506,6 @@ - (NSSize) characterSize
return [VT100Screen requireSizeWithFont: [self tallerFont]];
}

- (void)setLineLimit:(unsigned int)maxline
{
#if DEBUG_METHOD_TRACE
NSLog(@"%s(%d):-[VT100Screen setLineLimit:%d]",
__FILE__, __LINE__, maxline);
#endif
LINE_LIMIT = maxline;
}

- (void)putToken:(VT100TCC)token
{

Expand Down Expand Up @@ -1253,7 +1254,6 @@ - (void)setNewLine
[aLine release];
#endif
TOP_LINE++;
[self removeOverLine];

}
else {
Expand Down Expand Up @@ -2078,18 +2078,23 @@ - (void)removeOverLine
NSLog(@"%s(%d):-[VT100Screen removeOverLine]", __FILE__, __LINE__);
#endif

if (TOP_LINE + HEIGHT > LINE_LIMIT) {
if (TOP_LINE > scrollbackLines) {
#if DEBUG_USE_BUFFER
int idx;
NSString *s=[BUFFER string];
NSString *s=[STORAGE string];
#endif
int over = TOP_LINE + HEIGHT - LINE_LIMIT;
int over = TOP_LINE - scrollbackLines;
int i;

#if DEBUG_USE_BUFFER
for(i=0,idx=0;i<over;idx++)
if ([s characterAtIndex:idx]=='\n') i++;
[BUFFER deleteCharactersInRange:NSMakeRange(0, idx+1)];
[STORAGE deleteCharactersInRange:NSMakeRange(0, idx)];
if (idx<updateIndex) updateIndex-=idx;
else {
[BUFFER deleteCharactersInRange:NSMakeRange(0,idx-updateIndex)];
updateIndex=0;
}
#endif


Expand Down Expand Up @@ -2391,6 +2396,7 @@ - (void) updateScreen
//NSLog(@"updated: %d, %d, %d, %d",updateIndex,minIndex,[STORAGE length],[BUFFER length]);
//if ([BUFFER length]>[STORAGE length]) NSLog(@"%@",BUFFER);
[self renewBuffer];
[self removeOverLine];
//NSLog(@"renewed: %d, %d, %d, %d",updateIndex,minIndex,[STORAGE length],[BUFFER length]);
[[SESSION TEXTVIEW] setCursorIndex:[self getTVIndex:CURSOR_X y:CURSOR_Y]];
//NSLog(@"showCursor");
Expand Down

0 comments on commit efdfa23

Please sign in to comment.