Author: rmottola
Date: Tue Mar 22 23:08:30 2016
New Revision: 39582
URL: http://svn.gna.org/viewcvs/gnustep?rev=39582&view=rev
Log:
split view to delegate
Added:
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h
Modified:
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/GNUmakefile
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebugger.m
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.h
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.m
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.h
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.m
Modified:
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/GNUmakefile
URL:
http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/GNUmakefile?rev=39582&r1=39581&r2=39582&view=diff
==============================================================================
---
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/GNUmakefile
(original)
+++
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/GNUmakefile
Tue Mar 22 23:08:30 2016
@@ -38,6 +38,7 @@
ProjectCenter_HEADERS= \
PCDebugger.h \
PCDebugggerView.h \
+ PCDebuggerViewDelegateProtocol.h \
PTYView.h
#
Modified:
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebugger.m
URL:
http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebugger.m?rev=39582&r1=39581&r2=39582&view=diff
==============================================================================
---
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebugger.m
(original)
+++
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebugger.m
Tue Mar 22 23:08:30 2016
@@ -25,6 +25,8 @@
#import "PCDebuggerView.h"
#import "Modules/Preferences/EditorFSC/PCEditorFSCPrefs.h"
+#import "PCDebuggerViewDelegateProtocol.h"
+#import "PTYView.h"
#ifndef NOTIFICATION_CENTER
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
@@ -122,6 +124,7 @@
{
if((self = [super init]) != nil)
{
+ id <PCDebuggerViewDelegateProtocol> viewDelegate;
// initialization here...
if([NSBundle loadNibNamed: @"PCDebugger" owner: self] == NO)
{
@@ -129,6 +132,10 @@
}
[(PCDebuggerView *)debuggerView setDebugger:self];
+ viewDelegate = [[PipeDelegate alloc] init];
+ [debuggerView setDelegate:viewDelegate];
+ [viewDelegate setTextView:debuggerView];
+ [viewDelegate release];
}
return self;
}
Modified:
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.h
URL:
http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.h?rev=39582&r1=39581&r2=39582&view=diff
==============================================================================
---
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.h
(original)
+++
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.h
Tue Mar 22 23:08:30 2016
@@ -1,9 +1,10 @@
/*
** PCDebuggerView
**
-** Copyright (c) 2008
+** Copyright (c) 2008-2016
**
-** Author: Gregory Casamento <[email protected]>
+** Author: Gregory Casamento <[email protected]>
+** Riccardo Mottola <[email protected]>
**
** 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
@@ -20,20 +21,32 @@
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#import "PTYView.h"
+#import <Foundation/NSString.h>
+#import <AppKit/NSTextView.h>
+
+#import "PCDebuggerViewDelegateProtocol.h"
@class PCDebugger;
-@class NSString;
-@interface PCDebuggerView : PTYView
+@interface PCDebuggerView : NSTextView
{
PCDebugger *debugger;
+ id <PCDebuggerViewDelegateProtocol> viewDelegate;
NSString *currentFile;
int subProcessId;
}
- (void) setDebugger:(PCDebugger *)theDebugger;
+- (void) setDelegate:(id <PCDebuggerViewDelegateProtocol>) vd;
- (void) setCurrentFile: (NSString *)fileName;
- (NSString *) currentFile;
- (int) subProcessId;
+
+- (void) runProgram: (NSString *)path
+ inCurrentDirectory: (NSString *)directory
+ withArguments: (NSArray *)array
+ logStandardError: (BOOL)logError;
+
+- (void) putString: (NSString *)string;
+
@end
Modified:
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.m
URL:
http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.m?rev=39582&r1=39581&r2=39582&view=diff
==============================================================================
---
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.m
(original)
+++
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerView.m
Tue Mar 22 23:08:30 2016
@@ -1,9 +1,10 @@
/*
** PCDebuggerView
**
-** Copyright (c) 2008
-**
-** Author: Gregory Casamento <[email protected]>
+** Copyright (c) 2008-2016
+**
+** Author: Gregory Casamento <[email protected]>
+** Riccardo Mottola <[email protected]>
**
** 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
@@ -39,6 +40,17 @@
{
debugger = theDebugger;
}
+
+- (void) setDelegate:(id <PCDebuggerViewDelegateProtocol>) vd
+{
+ if (viewDelegate != vd)
+ {
+ [viewDelegate release];
+ viewDelegate = vd;
+ [viewDelegate retain];
+ }
+}
+
/**
* Log string to the view.
@@ -144,7 +156,7 @@
// if the line is not filtered, print it...
if(printLine)
{
- [super logString: str newLine: newLine withColor:debuggerColor];
+ [viewDelegate logString: str newLine: newLine withColor:[viewDelegate
debuggerColor]];
}
}
@@ -157,38 +169,6 @@
{
return currentFile;
}
-
-/**
- * lookup the process id.
- */
-/*
-- (int) subProcessId
-{
- int task_pid = [task processIdentifier];
- int child_pid = 0;
- NSArray *entries = [[NSFileManager defaultManager] directoryContentsAtPath:
@"/proc"];
- NSEnumerator *en = [entries objectEnumerator];
- NSString *entry = nil;
-
- // FIXME: I'm looking for a generic way to do this, what we have here is
very /proc specific.
- // which I don't like since it ties this functionality to systems which have
/proc.
- while((entry = [en nextObject]) != nil)
- {
- int pid = [entry intValue];
- if (pid != 0)
- {
- int ppid = getppid(pid);
- if (ppid == task_pid)
- {
- child_pid = pid;
- break;
- }
- }
- }
-
- return child_pid;
-}
-*/
- (int) subProcessId
{
@@ -208,11 +188,36 @@
- (void) terminate
{
- [super terminate];
+ [viewDelegate terminate];
}
- (void) mouseDown: (NSEvent *)event
{
// do nothing...
}
+
+/**
+ * Start the program.
+ */
+- (void) runProgram: (NSString *)path
+ inCurrentDirectory: (NSString *)directory
+ withArguments: (NSArray *)array
+ logStandardError: (BOOL)logError
+{
+ [viewDelegate runProgram: path
+ inCurrentDirectory: directory
+ withArguments: array
+ logStandardError: logError];
+}
+
+- (void) putString: (NSString *)string
+{
+ [viewDelegate putString:string];
+}
+
+- (void) keyDown: (NSEvent*)theEvent
+{
+ [viewDelegate keyDown:theEvent];
+}
+
@end
Added:
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h
URL:
http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h?rev=39582&view=auto
==============================================================================
---
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h
(added)
+++
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PCDebuggerViewDelegateProtocol.h
Tue Mar 22 23:08:30 2016
@@ -0,0 +1,55 @@
+/*
+** PCDebuggerViewDelegateProtocol.h
+**
+** Copyright (c) 2016
+**
+** Author: Riccardo Mottola <[email protected]>
+**
+** 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+@class NSColor;
+@class NSTextView;
+@class NSArray;
+@class NSString;
+
+@protocol PCDebuggerViewDelegateProtocol
+
+- (NSColor *)userInputColor;
+- (NSColor *)debuggerColor;
+- (NSColor *)messageColor;
+- (NSColor *)errorColor;
+
+- (NSTextView *)textView;
+- (void)setTextView: (NSTextView *)tv;
+
+- (void) runProgram: (NSString *)path
+ inCurrentDirectory: (NSString *)directory
+ withArguments: (NSArray *)array
+ logStandardError: (BOOL)logError;
+
+- (void)logString:(NSString *)str
+ newLine:(BOOL)newLine
+ withColor:(NSColor *)color;
+
+- (void) terminate;
+
+- (void) interrupt;
+
+- (void) putString: (NSString *)string;
+
+- (void) keyDown: (NSEvent*)theEvent;
+
+@end
Modified:
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.h
URL:
http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.h?rev=39582&r1=39581&r2=39582&view=diff
==============================================================================
---
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.h
(original)
+++
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.h
Tue Mar 22 23:08:30 2016
@@ -1,9 +1,10 @@
/*
-** PTYView
+** PipeDelegate
**
-** Copyright (c) 2008
+** Copyright (c) 2008-2016
**
-** Author: Gregory Casamento <[email protected]>
+** Author: Gregory Casamento <[email protected]>
+** Riccardo Mottola <[email protected]>
**
** 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
@@ -23,8 +24,11 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
-@interface PTYView : NSTextView
+#import "PCDebuggerViewDelegateProtocol.h"
+
+@interface PipeDelegate : NSObject <PCDebuggerViewDelegateProtocol>
{
+ NSTextView *tView;
NSTask *task;
NSFileHandle *stdinHandle;
NSFileHandle *stdoutHandle;
@@ -36,10 +40,6 @@
NSColor *errorColor;
}
-- (void)logString:(NSString *)str
- newLine:(BOOL)newLine
- withColor:(NSColor *)color;
-
- (void)logStdOut:(NSNotification *)aNotif;
- (void)logErrOut:(NSNotification *)aNotif;
@@ -50,16 +50,6 @@
- (NSString *) stopMessage;
-- (void) runProgram: (NSString *)path
- inCurrentDirectory: (NSString *)directory
- withArguments: (NSArray *)array
- logStandardError: (BOOL)logError;
+- (void) putChar:(unichar)ch;
-- (void) terminate;
-
-- (void) interrupt;
-
-- (void) putString: (NSString *)string;
-
-- (void) putChar:(unichar)ch;
@end
Modified:
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.m
URL:
http://svn.gna.org/viewcvs/gnustep/apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.m?rev=39582&r1=39581&r2=39582&view=diff
==============================================================================
---
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.m
(original)
+++
apps/projectcenter/branches/ptyview_with_pipes/Modules/Debuggers/ProjectCenter/PTYView.m
Tue Mar 22 23:08:30 2016
@@ -1,5 +1,5 @@
/*
-** PTYView
+** PipeDelegate.m
**
** Copyright (c) 2008-2016 Free Software Foundation
**
@@ -42,35 +42,55 @@
#endif
-@implementation PTYView
-
-- (void)commonInitCode
-{
- userInputColor = [[NSColor blueColor] retain];
- debuggerColor = [[NSColor blackColor] retain];
- messageColor = [[NSColor brownColor] retain];
- errorColor = [[NSColor redColor] retain];
-}
-
-- (id)initWithCoder:(NSCoder *)coder
-{
- if ((self = [super initWithCoder:coder]))
- {
- [self commonInitCode];
+@implementation PipeDelegate
+
+
+- (id)init
+{
+ if ((self = [super init]))
+ {
+ userInputColor = [[NSColor blueColor] retain];
+ debuggerColor = [[NSColor blackColor] retain];
+ messageColor = [[NSColor brownColor] retain];
+ errorColor = [[NSColor redColor] retain];
}
return self;
}
-
-- (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer
*)container
-{
- if ((self = [super initWithFrame:frameRect textContainer:container]))
- {
- [self commonInitCode];
- }
- return self;
-}
-
+- (NSTextView *)textView
+{
+ return tView;
+}
+
+- (void)setTextView: (NSTextView *)tv
+{
+ if (tView != tv)
+ {
+ [tView release];
+ tView = tv;
+ [tView retain];
+ }
+}
+
+- (NSColor *)userInputColor
+{
+ return userInputColor;
+}
+
+- (NSColor *)debuggerColor
+{
+ return debuggerColor;
+}
+
+- (NSColor *)messageColor
+{
+ return messageColor;
+}
+
+- (NSColor *)errorColor
+{
+ return errorColor;
+}
/**
* Log string to the view.
@@ -98,12 +118,12 @@
attrStr = [[NSAttributedString alloc] initWithString: str
attributes: textAttributes];
- [[self textStorage] appendAttributedString: attrStr];
+ [[tView textStorage] appendAttributedString: attrStr];
[attrStr release];
- [self scrollRangeToVisible:NSMakeRange([[self string] length], 0)];
- [self setNeedsDisplay:YES];
+ [tView scrollRangeToVisible:NSMakeRange([[tView string] length], 0)];
+ [tView setNeedsDisplay:YES];
}
@@ -290,6 +310,7 @@
[debuggerColor release];
[messageColor release];
[errorColor release];
+ [tView release];
[super dealloc];
}
@@ -315,9 +336,9 @@
{
NSUInteger textLen;
- textLen = [[self string] length];
- [self setSelectedRange:NSMakeRange(textLen-1, 1)];
- [self delete:nil];
+ textLen = [[tView string] length];
+ [tView setSelectedRange:NSMakeRange(textLen-1, 1)];
+ [tView delete:nil];
return;
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs