summaryrefslogtreecommitdiff
path: root/StepTalkShell/.svn/text-base
diff options
context:
space:
mode:
Diffstat (limited to 'StepTalkShell/.svn/text-base')
-rw-r--r--StepTalkShell/.svn/text-base/.cvsignore.svn-base7
-rw-r--r--StepTalkShell/.svn/text-base/AppKit.txt.svn-base40
-rw-r--r--StepTalkShell/.svn/text-base/ChangeLog.svn-base58
-rw-r--r--StepTalkShell/.svn/text-base/GNUmakefile.svn-base35
-rw-r--r--StepTalkShell/.svn/text-base/README.svn-base88
-rw-r--r--StepTalkShell/.svn/text-base/STShell+output.m.svn-base165
-rw-r--r--StepTalkShell/.svn/text-base/STShell.h.svn-base80
-rw-r--r--StepTalkShell/.svn/text-base/STShell.m.svn-base404
-rw-r--r--StepTalkShell/.svn/text-base/Unix.txt.svn-base194
-rw-r--r--StepTalkShell/.svn/text-base/stshell_tool.m.svn-base253
10 files changed, 1324 insertions, 0 deletions
diff --git a/StepTalkShell/.svn/text-base/.cvsignore.svn-base b/StepTalkShell/.svn/text-base/.cvsignore.svn-base
new file mode 100644
index 0000000..862e5dc
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/.cvsignore.svn-base
@@ -0,0 +1,7 @@
+*.app
+*.debug
+*.profile
+shared_*obj
+*.bundle
+*.stmodule
+*.stlanguage
diff --git a/StepTalkShell/.svn/text-base/AppKit.txt.svn-base b/StepTalkShell/.svn/text-base/AppKit.txt.svn-base
new file mode 100644
index 0000000..ea79ab9
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/AppKit.txt.svn-base
@@ -0,0 +1,40 @@
+Simple AppKit Examples
+----------------------
+To be able to try following examples you have to load the AppKit module:
+
+ > Environment loadModule: 'AppKit'
+
+
+How to get a filename using the Open panel
+
+ > NSOpenPanel openPanel runModal ; filename
+
+Applications and files
+----------------------
+
+> Workspace := NSWorkspace sharedWorkspace
+
+How to launch an application
+
+ > Workspace launchApplication:'application name'
+
+How to open a file
+
+ > Workspace openFile:'file name'
+
+How to open a file with specified application
+
+ > Workspace openFile:'file name' withApplication:'application name'
+
+How to open a file using the open panel
+
+ > Workspace openFile:(NSOpenPanel openPanel runModal ; filename)
+
+Text
+----
+
+How to display a RTF file
+
+ > text := NSAttributedString alloc
+ > text initWithPath: file documentAttributes:nil
+ > Transcript show: (text string)
diff --git a/StepTalkShell/.svn/text-base/ChangeLog.svn-base b/StepTalkShell/.svn/text-base/ChangeLog.svn-base
new file mode 100644
index 0000000..8653fb6
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/ChangeLog.svn-base
@@ -0,0 +1,58 @@
+2005 Aug 30
+
+ * use STLanguageManager instead of removed STLanguage
+
+2005 Aug 15
+
+ * Added distant environments
+ * Removed named objects as they were causing troubles with distant
+ environments
+ * Suspend completion for distant environments
+
+ Warning: option 'environment' has different meaning. See stshell --help.
+
+2003 Sep 21
+
+ * Added named objects FileManager, LastCommand and LastObject
+
+2003 Jun 19
+
+ * Renamed stshell.m to stshell_tool.m. MS Windows was causing problems with
+ case insensitive file system.
+ (Reported by Michael Adams <mdmkolbe@yahoo.com>)
+
+2003 Apr 04 David Ayers <d.ayers@inode.at>
+
+ * GNUmakefile: Added flags to show all warnings except for import.
+ * STShell.m: Unified name for private categories.
+
+2003 Jan 16 Stefan Urbanek <urbanek@host.sk>
+
+ * GNUmakefile: Added -lncurses
+
+2002 Jun 21 Stefan Urbanek <urbanek@host.sk>
+
+ * Added executeScriptNamed:
+
+2002 Jun 8 Stefan Urbanek <urbanek@host.sk>
+
+ * Reflect STEnvironment changes
+ * Removed loading of Foundation module as this is handleb by the
+ STEnvironment
+
+2002 Jun 7 Stefan Urbanek <urbanek@host.sk>
+
+ * Changed printing of result object (handle arrays, dictionaries and sets
+ different way)
+
+2002 Jun 6 Stefan Urbanek <urbanek@host.sk>
+
+ * Update completition list lazily (only when needed)
+
+2002 Jun 4 Stefan Urbanek <urbanek@host.sk>
+
+ * add DistributedFinder object finder to the environment
+
+2002 May 30 Stefan Urbanek <urbanek@host.sk>
+
+ * added Environment object.
diff --git a/StepTalkShell/.svn/text-base/GNUmakefile.svn-base b/StepTalkShell/.svn/text-base/GNUmakefile.svn-base
new file mode 100644
index 0000000..3f0df60
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/GNUmakefile.svn-base
@@ -0,0 +1,35 @@
+#
+# StepTalk tools
+#
+# Copyright (C) 2002 Stefan Urbanek
+#
+# This file is part of the StepTalk.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the Free
+# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
+#
+
+include $(GNUSTEP_MAKEFILES)/common.make
+
+TOOL_NAME = stshell
+
+stshell_OBJC_FILES = STShell.m STShell+output.m stshell_tool.m
+
+ADDITIONAL_TOOL_LIBS += -lStepTalk -lreadline -lncurses
+
+ADDITIONAL_OBJCFLAGS = -Wall -Wno-import
+
+-include GNUmakefile.preamble
+include $(GNUSTEP_MAKEFILES)/tool.make
+-include GNUMakefile.postamble
diff --git a/StepTalkShell/.svn/text-base/README.svn-base b/StepTalkShell/.svn/text-base/README.svn-base
new file mode 100644
index 0000000..96bd556
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/README.svn-base
@@ -0,0 +1,88 @@
+stshell
+-------
+
+Author: Stefan Urbanek <urbanek@host.sk>
+
+
+What is stshell?
+-----------------
+StepTalk Shell is an interactive tool for communicating with objects.
+
+Features
+--------
+ - GNUstep classes and objects
+ - command-line editing
+ - TAB completition of named objects and selectors
+
+For more information read included *.txt files.
+
+Installation
+------------
+Requirements: StepTalk and the readline library (development files)
+
+ > make
+ > make install
+
+Running
+-------
+To run stshell with default language, run just
+
+ > stshell
+
+If you would like to use another language, then use
+
+ > stshell -language AnotherLanguage
+
+To use AppKit
+
+ > stshell -environment AppKit
+
+To use it as a distributed objects 'glue'
+
+ > stshell -environment Distributed
+
+The shell will greet you with 'Welcome to the StepTalk shell.' message.
+
+ Welcome to the StepTalk shell.
+ StepTalk > _
+
+Now you may write statements in the language you have specified.
+
+ StepTalk > Transcript showLine:'Current date is ', ((NSDate date) description)
+
+If the line is too long, then you may use the backslash '\' character at the end
+of the line to continue on the next line.
+
+ StepTalk > Transcript showLine:'Current date is ', \
+ ... ? ((NSDate date) description)
+
+Objects history array
+---------------------
+All results from the expressions are stored in the 'Objects' array. The example
+above can be written in more steps:
+
+ StepTalk > ((NSDate date) description)
+ 0: 2002-05-29 22:41:57 +0200
+ StepTalk > 'Current date is ', (Objects @ 0)
+ 1: Current date is 2002-05-29 22:41:57 +0200
+ StepTalk > Transcript showLine: (Objects @ 1)
+ Current date is 2002-05-29 22:41:57 +0200
+
+To show all objects type:
+
+ StepTalk > Shell listObjects
+ Objects
+ 0: '2002-05-29 22:41:57 +0200' (GSCInlineString)
+ 1: 'Current date is 2002-05-29 22:41:57 +020...' (GSUnicodeString)
+
+TAB completition
+----------------
+Here is an example of TAB completition.
+ StepTalk > Tr<TAB> showL<TAB>:'Current date is ', ((NSDate date) desc<TAB>i<TAB>)
+
+Feedback
+--------
+Any questions, comments and bug reports are velcome at
+
+ urbanek@host.sk
+
diff --git a/StepTalkShell/.svn/text-base/STShell+output.m.svn-base b/StepTalkShell/.svn/text-base/STShell+output.m.svn-base
new file mode 100644
index 0000000..8f7d0ea
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/STShell+output.m.svn-base
@@ -0,0 +1,165 @@
+/**
+ STShell+output
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek <urbanek@host.sk>
+ Date: 2002 Jun 7
+
+ This file is part of the StepTalk project.
+
+ 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 02111, USA.
+
+ */
+
+#import "STShell.h"
+
+#import <StepTalk/StepTalk.h>
+
+#import <Foundation/NSArray.h>
+#import <Foundation/NSBundle.h>
+#import <Foundation/NSDebug.h>
+#import <Foundation/NSNotification.h>
+#import <Foundation/NSException.h>
+#import <Foundation/NSSet.h>
+#import <Foundation/NSString.h>
+#import <Foundation/NSValue.h>
+
+#include <readline/readline.h>
+
+@implementation STShell(STShellOutput)
+- show:(id)anObject
+{
+ printf("%s", [[anObject description] cString]);
+
+ return self;
+}
+- showLine:(id)anObject
+{
+ [self show:anObject];
+ putchar('\n');
+
+ return nil;
+}
+- (void)showError:(NSString *)errString
+{
+ fprintf(stderr, "%s\n\n", [errString cString]);
+}
+
+- showResult:(id)obj
+{
+ const char *className = [NSStringFromClass([obj class]) cString];
+ int objIndex = [objectStack count] - 1;
+ int i;
+
+ if(obj)
+ {
+ if([obj isKindOfClass:[NSArray class]])
+ {
+ printf("(%i) %s\n", objIndex, className);
+
+ for(i = 0;i<[obj count]; i++)
+ {
+ printf("%i %s\n", i,
+ [self displayCStringForObject:[obj objectAtIndex:i]]);
+ }
+
+ }
+ else if([obj isKindOfClass:[NSSet class]])
+ {
+ printf("(%i) %s\n", objIndex, className);
+
+ obj = [[obj allObjects] sortedArrayUsingSelector:@selector(compare:)];
+ for(i = 0;i<[obj count]; i++)
+ {
+ printf("%s\n",
+ [self displayCStringForObject:[obj objectAtIndex:i]]);
+ }
+
+ }
+ else if([obj isKindOfClass:[NSDictionary class]])
+ {
+ NSString *key;
+ NSArray *keys;
+
+ printf("(%i) %s\n", objIndex, className);
+
+ keys = [[obj allKeys] sortedArrayUsingSelector:@selector(compare:)];
+
+ for(i = 0;i<[keys count]; i++)
+ {
+ key = [keys objectAtIndex:i];
+ printf("%s : %s\n",
+ [self displayCStringForObject:key],
+ [self displayCStringForObject:[obj objectForKey:key]]);
+ }
+ }
+ else
+ {
+ printf("(%i) %s\n", objIndex, [self displayCStringForObject:obj]);
+ }
+ }
+
+ return self;
+}
+- (char *)displayCStringForObject:(id)object
+{
+ NSString *str = [object description];
+
+ if( [str length] > 60 )
+ {
+ str = [str substringToIndex:60];
+ str = [str stringByAppendingString:@"..."];
+ }
+
+ return [str cString];
+}
+
+- showException:(NSException *)exception
+{
+ printf("Error (%s): %s\n",
+ [[exception name] cString],
+ [[exception reason] cString]);
+
+
+ return self;
+}
+
+- (id)listObjects
+{
+ NSString *str;
+ int i;
+ id object;
+
+ printf("Objects\n");
+ for(i = 0; i < [objectStack count]; i++)
+ {
+ object = [objectStack objectAtIndex:i];
+
+ str = [object description];
+
+ if( [str length] > 60 )
+ {
+ str = [str substringToIndex:60];
+ str = [str stringByAppendingString:@"..."];
+ }
+
+ printf("%4i: '%s' (%s)\n", i,
+ [str cString],
+ [[[object class] description] cString]);
+ }
+ return nil;
+}
+@end
diff --git a/StepTalkShell/.svn/text-base/STShell.h.svn-base b/StepTalkShell/.svn/text-base/STShell.h.svn-base
new file mode 100644
index 0000000..f807aef
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/STShell.h.svn-base
@@ -0,0 +1,80 @@
+/**
+ STShell
+ StepTalk Shell
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek <urbanek@host.sk>
+ Date: 2002 May 29
+
+ This file is part of the StepTalk project.
+
+ 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 02111, USA.
+
+ */
+
+#import <Foundation/NSObject.h>
+
+@class STConversation;
+@class STEnvironment;
+@class STScriptsManager;
+@class NSMutableArray;
+@class NSException;
+
+@interface STShell:NSObject
+{
+ STScriptsManager *scriptsManager;
+ STConversation *conversation;
+
+ NSString *prompt;
+ NSString *source;
+
+ NSMutableArray *objectStack;
+
+ BOOL exitRequest;
+
+ BOOL updateCompletionList;
+ NSArray *completionList;
+ BOOL completionEnabled;
+
+}
+- initWithEnvironment:(STEnvironment *)env;
+
+- (void)setLanguage:(NSString *)langName;
+- (void)setEnvironment:(STEnvironment *)newEnv;
+- (STEnvironment *)environment;
+
+- (void)run;
+
+- show:(id)anObject;
+- showLine:(id)anObject;
+
+- (id)executeLine:(NSString *)line;
+
+- showResult:(id)obj;
+- showException:(NSException *)exception;
+- (void)showError:(NSString *)errString;
+@end
+
+@interface STShell(STShellOutput)
+
+- show:(id)anObject;
+- showLine:(id)anObject;
+- showResult:(id)obj;
+- (char *)displayCStringForObject:(id)object;
+- showException:(NSException *)exception;
+- (id)listObjects;
+
+@end
diff --git a/StepTalkShell/.svn/text-base/STShell.m.svn-base b/StepTalkShell/.svn/text-base/STShell.m.svn-base
new file mode 100644
index 0000000..57c2120
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/STShell.m.svn-base
@@ -0,0 +1,404 @@
+/**
+ STShell
+ StepTalk Shell
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek <urbanek@host.sk>
+ Date: 2002 May 29
+
+ This file is part of the StepTalk project.
+
+ 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 02111, USA.
+
+ */
+
+#import "STShell.h"
+
+#import <StepTalk/StepTalk.h>
+
+#import <Foundation/NSArray.h>
+#import <Foundation/NSBundle.h>
+#import <Foundation/NSDebug.h>
+#import <Foundation/NSNotification.h>
+#import <Foundation/NSException.h>
+#import <Foundation/NSFileManager.h>
+#import <Foundation/NSSet.h>
+#import <Foundation/NSString.h>
+#import <Foundation/NSValue.h>
+
+#include <readline/readline.h>
+
+static Class NSString_class;
+static Class NSNumber_class;
+
+NSArray *objcSelectors = nil;
+
+static STShell *sharedShell = nil;
+
+@interface STShell(STPrivateMethods)
+- (int) completion;
+- (NSString *)readLine;
+- (void)initReadline;
+@end
+
+int complete_handler(void)
+{
+ return [sharedShell completion];
+}
+
+@implementation STShell
+
++ (void)initialize
+{
+ NSString_class = [NSString class];
+ NSNumber_class = [NSNumber class];
+}
+
++ sharedShell
+{
+ return sharedShell;
+}
+
+- initWithConversation:(STConversation *)conv
+{
+ self = [super init];
+
+ [self initReadline];
+
+ objectStack = [[NSMutableArray alloc] init];
+
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(bundleLoaded:)
+ name:NSBundleDidLoadNotification
+ object:nil];
+
+ scriptsManager = RETAIN([STScriptsManager defaultManager]);
+ prompt = @"StepTalk > ";
+
+ conversation = RETAIN(conv);
+
+ /* FIXME: make this more clever for completion handler */
+ if(!sharedShell)
+ {
+ sharedShell = self;
+ }
+
+ return self;
+}
+
+- (void)updateCompletionList
+{
+ NSMutableArray *array = [[NSMutableArray alloc] init];
+ RELEASE(completionList);
+
+ [array addObjectsFromArray:STAllObjectiveCSelectors()];
+
+ completionList = [[NSArray alloc] initWithArray:array];
+
+ updateCompletionList = NO;
+}
+
+- (void)dealloc
+{
+ RELEASE(objectStack);
+ RELEASE(completionList);
+ RELEASE(scriptsManager);
+ RELEASE(conversation);
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ [super dealloc];
+}
+-(void)bundleLoaded:(NSNotification *)notif
+{
+ updateCompletionList = YES;
+}
+
+- (void)initReadline
+{
+ rl_initialize();
+ rl_bind_key('\t', complete_handler);
+}
+
+- (void)setLanguage:(NSString *)langName
+{
+ NSDebugLog(@"Setting language to %@", langName);
+
+ [conversation setLanguage:langName];
+}
+
+- (void)setEnvironment:(STEnvironment *)newEnv
+{
+ [conversation setEnvironment:newEnv];
+}
+
+- (STEnvironment *)environment
+{
+ return [conversation context];
+}
+
+- (void)run
+{
+ STEnvironment *env;
+ NSString *line;
+ id result;
+
+ [self showLine:@"Welcome to the StepTalk shell."];
+
+ // NSLog(@"Environment %@", env);
+
+ if(![conversation isKindOfClass:[STRemoteConversation class]])
+ {
+ completionEnabled = YES;
+ }
+ else
+ {
+ [self showLine:@"Note: Completion disabled for distant conversation"];
+ }
+
+ while(1)
+ {
+ line = [self readLine];
+
+ if(exitRequest)
+ break;
+
+ if(!line)
+ continue;
+
+ result = [self executeLine:line];
+
+ if(result)
+ {
+ if(result != objectStack)
+ {
+ [objectStack addObject:result];
+ }
+ [self showResult:result];
+ }
+ else
+ {
+ [self showResult:result];
+ }
+
+ }
+ printf("\n");
+}
+- (id)executeLine:(NSString *)line
+{
+ NSString *cmd;
+ id result = nil;
+
+ /* FIXME: why? */
+
+ cmd = [line stringByAppendingString:@" "];
+ NS_DURING
+ [conversation interpretScript:cmd];
+ result = [conversation result];
+ NS_HANDLER
+ [self showException:localException];
+ NS_ENDHANDLER
+
+ return result;
+}
+
+- (NSString *)readLine
+{
+ char *str;
+ NSString *actualPrompt = prompt;
+ NSString *line = @"";
+ BOOL done = NO;
+ int len;
+
+ while(!done)
+ {
+ str = readline([actualPrompt cString]);
+ done = YES;
+
+ if(!str)
+ {
+ exitRequest = YES;
+ return nil;
+ }
+
+ len = strlen(str);
+ if(!len)
+ return nil;
+
+ if(str[len-1] == '\\')
+ {
+ actualPrompt = @"... ? ";
+ str[strlen(str) - 1] = '\0';
+ done = NO;
+ }
+
+ line = [line stringByAppendingString:[NSString stringWithCString:str]];
+ }
+
+ add_history([line cString]);
+
+ return line;
+}
+
+- (int)completion
+{
+ STEnvironment *env;
+ NSEnumerator *enumerator;
+ NSMutableSet *set;
+ NSString *match;
+ NSString *tail;
+ NSString *str;
+ NSArray *array;
+ int pos = 0;
+ int c;
+
+ if(!completionEnabled)
+ {
+ return 0;
+ }
+
+ if(rl_point <= 0)
+ {
+ return 0;
+ }
+
+ pos = rl_point - 1;
+ c = rl_line_buffer[pos];
+
+ while((isalnum(c) || c == '_') && pos >= 0)
+ {
+ pos--;
+ c = rl_line_buffer[pos];
+ }
+ pos++;
+
+ match = [NSString stringWithCString:rl_line_buffer + pos
+ length:rl_point - pos];
+
+ set = [NSMutableSet set];
+
+ if(!completionList || updateCompletionList)
+ {
+ [self updateCompletionList];
+ }
+
+ enumerator = [completionList objectEnumerator];
+ while( (str = [enumerator nextObject]) )
+ {
+ if( [str hasPrefix:match] )
+ {
+ [set addObject:str];
+ }
+ }
+
+ env = [conversation context];
+ enumerator = [[env knownObjectNames] objectEnumerator];
+ while( (str = [enumerator nextObject]) )
+ {
+ if( [str hasPrefix:match] )
+ {
+ [set addObject:str];
+ }
+ }
+
+ array = [set allObjects];
+
+ if( [array count] == 0 )
+ {
+ printf("\nNo match for completion.\n");
+ rl_forced_update_display();
+ }
+ else if ( [array count] == 1 )
+ {
+ str = [array objectAtIndex:0];
+ str = [str substringFromIndex:rl_point - pos];
+ rl_insert_text([str cString]);
+ rl_insert_text(" ");
+
+ rl_redisplay();
+ }
+ else
+ {
+ enumerator = [array objectEnumerator];
+
+ tail = [enumerator nextObject];
+
+ while( (str = [enumerator nextObject]) )
+ {
+ tail = [str commonPrefixWithString:tail options:NSLiteralSearch];
+ }
+
+ tail = [tail substringFromIndex:[match length]];
+
+ if( tail && ![tail isEqualToString:@""] )
+ {
+ rl_insert_text([tail cString]);
+ rl_redisplay();
+ }
+ else
+ {
+ printf("\n");
+ enumerator = [array objectEnumerator];
+ while( (str = [enumerator nextObject]) )
+ {
+ printf("%s\n", [str cString]);
+ }
+ rl_forced_update_display();
+ }
+ }
+
+
+ return 0;
+}
+
+- (void)exit
+{
+ /* FIXME: this is not nice */
+ exit(0);
+}
+
+- (id)executeScriptNamed:(NSString *)scriptName
+{
+ STScript *script = [scriptsManager scriptWithName:scriptName];
+ id result = nil;
+
+ if(!script)
+ {
+ [self showError:[NSString stringWithFormat:
+ @"Unable to find script with name '%@'",
+ scriptName]];
+ }
+ else
+ {
+ NS_DURING
+ result = [conversation runScriptFromString:[script source]];
+ NS_HANDLER
+ [self showException:localException];
+ NS_ENDHANDLER
+ }
+
+ return result;
+}
+- (void)setPrompt:(NSString *)aString
+{
+ ASSIGN(prompt, aString);
+}
+- (NSString *)prompt
+{
+ return prompt;
+}
+@end
diff --git a/StepTalkShell/.svn/text-base/Unix.txt.svn-base b/StepTalkShell/.svn/text-base/Unix.txt.svn-base
new file mode 100644
index 0000000..94d3096
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/Unix.txt.svn-base
@@ -0,0 +1,194 @@
+Unix shell equivalents
+----------------------
+
+StepTalk is not meant to be used for tasks that can be done using ordinary Unix
+shells. But this does not mean, that it cannot be used for such tasks. In this
+file you may find list of unix commands and tasks and their Smalltalk
+equivalents.
+
+Contents:
+
+ File Manipulation
+ Output
+ Paths and filenames
+ Network
+ Math
+ Date and Time
+
+File manipulation
+-----------------
+
+> fm := NSFileManager defaultManager
+
+ls
+
+ > (fm directoryContentsAtPath: '.') sortedArrayUsingSelector:#compare:
+
+pwd
+
+ > fm currentDirectoryPath
+
+cd path
+
+ > fm changeCurrentDirectoryPath: 'path'
+
+ln -s path other
+
+ > fm createSymbolicLinkAtPath:'path' pathContent:'other'
+
+cp src dest
+
+ > fm copyPath:'src' toPath:'dest' handler: nil
+
+cp file_list dest
+
+ > file_list do: [ :file | fm copyPath:file toPath:'dest' handler: nil ]
+
+mv - as cp, movePath:toPath:handler:
+ln - as cp, linkPath:toPath:handler:
+rm - removeFileAtPath:handler:
+
+mkdir dir
+
+ > fm createDirectoryAtPath:'dir' attributes:nil
+
+df path
+
+ > fm fileSystemAttributesAtPath:'path'
+
+Output
+------
+
+echo 'string'
+
+ > Transcript show:'string'
+
+cat file
+
+ > Transcript show: (NSString stringWithContentsOfFile:'file')
+
+"write a string to a file"
+
+ > ('string' writeToFile:'file' atomically:YES)
+
+"create a string from a file"
+
+ > str := NSString stringWithContentsOfFile:'file'
+
+
+Paths and filenames
+--------------------------------
+For more information, refer to the NSString documentation.
+NSString methods for path manipulation:
+
+ - fileSystemRepresentation
+ - isAbsolutePath
+
+ - pathComponents
+ - lastPathComponent
+ - pathExtension
+
+ - stringByAbbreviatingWithTildeInPath
+ - stringByAppendingPathComponent:
+ - stringByAppendingPathExtension:
+ - stringByDeletingLastPathComponent
+ - stringByDeletingPathExtension
+ - stringByExpandingTildeInPath
+ - stringByResolvingSymlinksInPath
+ - stringByStandardizingPath
+ - stringsByAppendingPaths:
+
+Examples:
+
+ > path := '/usr/GNUstep/System/Applications/Ink.app'
+ > path pathComponents
+ (?) GSArray
+ 0 /
+ 1 usr
+ 2 GNUstep
+ 3 System
+ 4 Applications
+ 5 Ink.app
+
+ > path lastPathComponent
+ (?) Ink.app
+
+ > path pathExtension
+ (?) app
+
+In Smalltalk there is a symbolic selector '/' for NSString that is equivalent to
+the 'stringByAppendingPathComponent:'.
+
+ > path := 'somePath'
+ > filename := 'someFilename'
+ > fullPath := path / filename
+
+Network
+-------
+
+localhost
+
+ > NSHost currentHost name
+
+nslookup host_name
+
+ > (NSHost hostWithName:'host_name') addresses
+
+nslookup host_address
+
+ > (NSHost hostWithAddress:'host_address') names
+
+"download a file from the web"
+
+ > data := NSData dataWithContentsOfURL:'url'
+ > data writeToFile:'file' atomically:YES
+
+"read a file from the web"
+
+ > string := NSString stringWithContentsOfURL:'url'
+
+
+Math
+----
+Just like in:
+ > 1 + 1
+or in:
+ > a := b * c
+
+
+Date and Time
+-------------
+
+date
+ > NSDate date
+...or...
+date
+ > NSCalendarDate date
+
+
+For more information read the NSDate and NSCalendarDate documentation
+
+NSCalendarDate methods:
+
+Creating a date
+
+ + calendarDate
+ + dateWithString:calendarFormat:
+ + dateWithString:calendarFormat:locale:
+ + dateWithYear:month:day:hour:minute:second:timeZone:
+
+Retrieving date elements
+
+ - dayOfCommonEra
+ - dayOfMonth
+ - dayOfWeek
+ - dayOfYear
+ - hourOfDay
+ - minuteOfHour
+ - monthOfYear
+ - secondOfMinute
+ - yearOfCommonEra
+
+Adjusting a date
+
+ - dateByAddingYears:months:days:hours:minutes:seconds:
diff --git a/StepTalkShell/.svn/text-base/stshell_tool.m.svn-base b/StepTalkShell/.svn/text-base/stshell_tool.m.svn-base
new file mode 100644
index 0000000..220f5a0
--- /dev/null
+++ b/StepTalkShell/.svn/text-base/stshell_tool.m.svn-base
@@ -0,0 +1,253 @@
+/**
+ stshell
+ StepTalk Shell
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek <urbanek@host.sk>
+ Date: 2002 May 29
+
+ This file is part of the StepTalk project.
+
+ 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 02111, USA.
+
+ */
+
+#import <StepTalk/StepTalk.h>
+
+#import "STShell.h"
+
+#import <Foundation/NSArray.h>
+#import <Foundation/NSAutoreleasePool.h>
+#import <Foundation/NSDebug.h>
+#import <Foundation/NSException.h>
+#import <Foundation/NSProcessInfo.h>
+#import <Foundation/NSString.h>
+
+@interface STShellTool:NSObject
+{
+ STConversation *conversation;
+ NSArray *arguments;
+ unsigned int currentArg;
+
+ NSString *environmentName;
+ NSString *hostName;
+ NSString *typeName;
+ NSString *languageName;
+
+}
+- (int)parseArguments;
+- (NSString *)nextArgument;
+- (void)reuseArgument;
+- (void)run;
+- (void)printHelp;
+@end
+
+@implementation STShellTool
+- (int)parseArguments
+{
+ NSString *arg;
+ BOOL isOption = NO;
+
+ arguments = [[NSProcessInfo processInfo] arguments];
+
+ [self nextArgument];
+
+ while( (arg = [self nextArgument]) )
+ {
+ isOption = NO;
+ if( [arg hasPrefix:@"--"] )
+ {
+ arg = [arg substringFromIndex:2];
+ isOption = YES;
+ }
+ else if( [arg hasPrefix:@"-"] )
+ {
+ arg = [arg substringFromIndex:1];
+ isOption = YES;
+ }
+
+ if ([@"help" hasPrefix:arg])
+ {
+ [self printHelp];
+ return 1;
+ }
+ else if ([@"language" hasPrefix:arg])
+ {
+ RELEASE(languageName);
+ languageName = [self nextArgument];
+ if(!languageName)
+ {
+ [NSException raise:@"STShellToolException"
+ format:@"Language name expected"];
+ }
+ }
+ else if ([@"environment" hasPrefix:arg])
+ {
+ RELEASE(environmentName);
+ environmentName = [self nextArgument];
+ if(!environmentName)
+ {
+ [NSException raise:@"STShellToolException"
+ format:@"Environment name expected"];
+ }
+ }
+ else if ([@"host" hasPrefix:arg])
+ {
+ RELEASE(hostName);
+ hostName = [self nextArgument];
+ if(!hostName)
+ {
+ [NSException raise:@"STShellToolException"
+ format:@"Host name expected"];
+ }
+ }
+ else if ([@"type" hasPrefix:arg])
+ {
+ RELEASE(typeName);
+ typeName = [self nextArgument];
+ if(!typeName)
+ {
+ [NSException raise:@"STShellToolException"
+ format:@"Environment description (type) name expected"];
+ }
+ }
+ else if(!isOption)
+ {
+ break;
+ }
+ }
+
+ if(arg)
+ {
+ [self reuseArgument];
+ }
+
+ return 0;
+}
+
+- (NSString *)nextArgument
+{
+ if(currentArg < [arguments count])
+ {
+ return [arguments objectAtIndex:currentArg++];
+ }
+
+ return nil;
+}
+
+- (void)reuseArgument
+{
+ currentArg--;
+}
+/* Method taken from stexec.m - look there for updates */
+- (void)createConversation
+{
+ STEnvironmentDescription *desc;
+ STEnvironment *environment;
+
+ if(environmentName)
+ {
+ /* user wants to connect to a distant environment */
+ conversation = [[STRemoteConversation alloc]
+ initWithEnvironmentName:environmentName
+ host:hostName
+ language:languageName];
+ if(!conversation)
+ {
+ NSLog(@"Unable to connect to %@@%@", environmentName, hostName);
+ return;
+ }
+ }
+ else
+ {
+ /* User wants local temporary environment */
+ if(!typeName || [typeName isEqualToString:@""])
+ {
+ environment = [STEnvironment environmentWithDefaultDescription];
+ }
+ else
+ {
+ desc = [STEnvironmentDescription descriptionWithName:typeName];
+ environment = [STEnvironment environmentWithDescription:desc];
+ }
+
+ /* Register basic objects: Environment, Transcript */
+
+ [environment setObject:environment forName:@"Environment"];
+ [environment loadModule:@"SimpleTranscript"];
+ [environment setCreatesUnknownObjects:YES];
+
+ /* FIXME: make this an option */
+ [environment setFullScriptingEnabled:YES];
+
+ conversation = [[STConversation alloc] initWithContext:environment
+ language:languageName];
+ }
+}
+
+- (void)run
+{
+ STShell *shell;
+
+ [self parseArguments];
+ [self createConversation];
+
+ if(!languageName || [languageName isEqualToString:@""])
+ {
+ languageName = [[STLanguageManager defaultManager] defaultLanguage];
+ }
+
+ [conversation setLanguage:languageName];
+
+ shell = [[STShell alloc] initWithConversation:conversation];
+ [shell run];
+
+ NSDebugLog(@"Exiting StepTalk shell");
+}
+
+- (void)printHelp
+{
+ NSProcessInfo *info = [NSProcessInfo processInfo];
+
+ printf("%s - StepTalk shell\n"
+ "Usage: %s [options]\n\n"
+ "Options are:\n"
+ " -help this text\n"
+ " -language lang use language lang\n"
+ " -environment env use scripting environment with name env\n"
+ " -host host find environment on host\n"
+ " -type desc use environment description with name 'desc'\n",
+ [[info processName] cString],[[info processName] cString]
+ );
+}
+
+@end
+
+
+int main(int argc, const char **argv)
+{
+ NSAutoreleasePool *pool;
+ STShellTool *tool;
+
+ pool = [NSAutoreleasePool new];
+
+ tool = [[STShellTool alloc] init];
+ [tool run];
+
+ RELEASE(pool);
+
+ return 0;
+}