├── .gitignore ├── .hgignore ├── Classes ├── BundlePrincipal.h ├── BundlePrincipal.m ├── Commands.h ├── Commands.m ├── Commands_implementation.h ├── Commands_implementation.m ├── Commands_operators.h ├── Commands_operators.m ├── Commands_private.h ├── Commands_table.h ├── Logger.h ├── Logger.m ├── NSTextView_vImputManager.h └── NSTextView_vImputManager.m ├── Resources ├── English.lproj │ └── InfoPlist.strings ├── Info.plist └── Whitelist.plist ├── TestApplication-Info.plist ├── TestApplication ├── English.lproj │ ├── InfoPlist.strings │ └── MainMenu.xib ├── PseudoController.h ├── PseudoController.m └── main.m ├── Testing-Info.plist ├── Testing ├── ViCommandsTests.h └── ViCommandsTests.m ├── doc ├── Info.template ├── commands │ ├── Makefile │ └── main.m ├── ex-vi │ ├── CVS │ │ ├── Entries │ │ ├── Entries.Log │ │ ├── Repository │ │ └── Root │ ├── Changes │ ├── LICENSE │ ├── Makefile │ ├── README │ ├── TODO │ ├── catd │ │ ├── CVS │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ │ └── en_US │ ├── config.h │ ├── ex.1 │ ├── ex.c │ ├── ex.h │ ├── ex.spec │ ├── ex_addr.c │ ├── ex_argv.h │ ├── ex_cmds.c │ ├── ex_cmds2.c │ ├── ex_cmdsub.c │ ├── ex_data.c │ ├── ex_extern.c │ ├── ex_get.c │ ├── ex_io.c │ ├── ex_proto.h │ ├── ex_put.c │ ├── ex_re.c │ ├── ex_re.h │ ├── ex_set.c │ ├── ex_subr.c │ ├── ex_tagio.c │ ├── ex_temp.c │ ├── ex_temp.h │ ├── ex_tty.c │ ├── ex_tty.h │ ├── ex_tune.h │ ├── ex_unix.c │ ├── ex_v.c │ ├── ex_vadj.c │ ├── ex_vars.h │ ├── ex_version.c │ ├── ex_vget.c │ ├── ex_vis.h │ ├── ex_vmain.c │ ├── ex_voper.c │ ├── ex_vops.c │ ├── ex_vops2.c │ ├── ex_vops3.c │ ├── ex_vput.c │ ├── ex_vwind.c │ ├── expreserve.c │ ├── exrecover.c │ ├── libterm │ │ ├── CVS │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ │ ├── Makefile │ │ ├── libterm.h │ │ ├── termcap.c │ │ ├── tgoto.c │ │ └── tputs.c │ ├── makeoptions │ ├── malloc.c │ ├── mapmalloc.c │ ├── output.ps │ ├── pkginfo │ ├── printf.c │ └── vi.1 ├── ex_vi_1.pdf ├── inputmanager.txt ├── ipc.txt ├── list-of-vi-commands.txt ├── properties-with-prefix.m ├── statusbar.txt └── vi-intro.pdf ├── vImputManager.xcodeproj ├── TemplateIcon.icns └── project.pbxproj ├── vImputManager_Prefix.pch └── version.plist /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *~.nib 4 | 5 | build/ 6 | 7 | *.pbxuser 8 | *.perspective 9 | *.perspectivev3 10 | 11 | -------------------------------------------------------------------------------- /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: regexp 2 | 3 | # die Builds gehoeren nicht ins Repo 4 | ^build/.*$ 5 | 6 | # alle dusseligen Swap-Dateien des vim ignorieren 7 | \.swp$ 8 | 9 | # no object files in the repo 10 | \.o$ 11 | 12 | # documentation stuff 13 | ex(-|_)vi 14 | vi-intro 15 | 16 | # der Mac- und Xcode-Dreck 17 | .DS_Store$ 18 | ^vImputManager.xcodeproj/schluete.* 19 | Rakefile 20 | -------------------------------------------------------------------------------- /Classes/BundlePrincipal.h: -------------------------------------------------------------------------------- 1 | // Created by Axel on 13.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import 5 | 6 | @interface BundlePrincipal: NSObject { 7 | } 8 | 9 | // called by the runtime after the input manager was loaded 10 | + (void)load; 11 | 12 | // swap implementations for all methods used by our class 13 | + (void)renameMethods; 14 | 15 | // exchange two method implementation on NSTextView 16 | + (BOOL)swizzleTextViewMethodFrom:(SEL)originalSel to:(SEL)newSel; 17 | 18 | // exchange two method implementation on the given class 19 | + (BOOL)swizzleMethodsOfClass:(Class)clazz from:(SEL)originalSel to:(SEL)newSel; 20 | 21 | // check if the given application is whitelisted 22 | + (BOOL)isHostApplicationAllowed:(NSString *)appId; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Classes/BundlePrincipal.m: -------------------------------------------------------------------------------- 1 | // Created by Axel on 13.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import "BundlePrincipal.h" 5 | #import 6 | #import "Logger.h" 7 | 8 | @implementation BundlePrincipal 9 | 10 | /** 11 | * called by the runtime after the input manager was loaded. 12 | */ 13 | + (void)load { 14 | // let's get some informations about our current host app 15 | NSBundle *hostApp=[NSBundle mainBundle]; 16 | NSString *bundleId=[hostApp bundleIdentifier]; 17 | NSDictionary *infoDict=[hostApp infoDictionary]; 18 | float version=[[infoDict valueForKey:@"CFBundleVersion"] floatValue]; 19 | [Logger log:@"we were loaded for <%@>, version <%f>",bundleId,version]; 20 | 21 | // if the current application is blacklisted let's do nothing 22 | if(![self isHostApplicationAllowed:bundleId]) { 23 | [Logger log:@"application is blacklisted, ignore it!"]; 24 | return; 25 | } 26 | 27 | // install our own handlers by exchanging the NSTextView 28 | // keyDown: method implementation with our own version 29 | [self renameMethods]; 30 | [Logger log:@"vi input mode successfully installed"]; 31 | } 32 | 33 | /** 34 | * swap implementations for all methods used by our class 35 | */ 36 | + (void)renameMethods { 37 | // the keyDown event handler 38 | [self swizzleTextViewMethodFrom:@selector(keyDown:) 39 | to:@selector(vImputManager_originalKeyDown:)]; 40 | [self swizzleTextViewMethodFrom:@selector(vImputManager_keyDown:) 41 | to:@selector(keyDown:)]; 42 | 43 | // the memory dealloction call (with garbage collector) 44 | [self swizzleTextViewMethodFrom:@selector(finalize) 45 | to:@selector(vImputManager_originalFinalize)]; 46 | [self swizzleTextViewMethodFrom:@selector(vImputManager_finalize) 47 | to:@selector(finalize)]; 48 | 49 | // the memory dealloction call (without garbage collector) 50 | [self swizzleTextViewMethodFrom:@selector(dealloc) 51 | to:@selector(vImputManager_originalDealloc)]; 52 | [self swizzleTextViewMethodFrom:@selector(vImputManager_dealloc) 53 | to:@selector(dealloc)]; 54 | } 55 | 56 | /** 57 | * exchange two method implementation on NSTextView 58 | */ 59 | + (BOOL)swizzleTextViewMethodFrom:(SEL)originalSel to:(SEL)newSel { 60 | return [self swizzleMethodsOfClass:[NSTextView class] 61 | from:originalSel 62 | to:newSel]; 63 | } 64 | 65 | /** 66 | * exchange two method implementation on the given class 67 | */ 68 | + (BOOL)swizzleMethodsOfClass:(Class)clazz from:(SEL)originalSel to:(SEL)newSel { 69 | Method method=class_getInstanceMethod(clazz,originalSel); 70 | if(method==nil) 71 | return FALSE; 72 | method->method_name=newSel; 73 | return TRUE; 74 | } 75 | 76 | /** 77 | * read the whitelist property list and validate the given 78 | * host application name against the list. If the application 79 | * appears on the list the methods returns TRUE, otherwise 80 | * FALSE will be returned. 81 | */ 82 | + (BOOL)isHostApplicationAllowed:(NSString *)appId { 83 | // find the blacklist file and read its raw data 84 | NSBundle *bundle=[NSBundle bundleWithIdentifier:@"de.pqrs.vImputManager"]; 85 | NSString *plistPath=[bundle pathForResource:@"Whitelist" ofType:@"plist"]; 86 | NSData *plistXML=[[NSFileManager defaultManager] contentsAtPath:plistPath]; 87 | 88 | // then parse the blacklist file as a plist and 89 | // return the entries 90 | NSString *errorDesc=nil; 91 | NSPropertyListFormat format; 92 | NSDictionary *plist=(NSDictionary *)[NSPropertyListSerialization 93 | propertyListFromData:plistXML 94 | mutabilityOption:NSPropertyListMutableContainersAndLeaves 95 | format:&format 96 | errorDescription:&errorDesc]; 97 | if(!plist) 98 | return false; 99 | NSArray *entries=[plist objectForKey:@"Entries"]; 100 | if(!entries) 101 | return false; 102 | 103 | // finally check the given app name against the list entries 104 | for(NSString *entry in entries) 105 | if([entry isEqualToString:appId]) 106 | return true; 107 | return false; 108 | } 109 | 110 | @end 111 | -------------------------------------------------------------------------------- /Classes/Commands.h: -------------------------------------------------------------------------------- 1 | // Created by Axel on 20.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import 5 | 6 | // the possible vi modes the processor is in 7 | typedef enum _ViMode { 8 | Insert=0, 9 | Command=1, 10 | Replace=2, 11 | } ViMode; 12 | 13 | // the constants for the search direction when lookup up chars 14 | typedef enum _SearchDirection { 15 | Forward=1, 16 | Backward=-1 17 | } SearchDirection; 18 | 19 | // what is the current operator state 20 | typedef enum _OperatorState { 21 | NoOperator=0, 22 | FirstTime=1, 23 | SecondTime=2, 24 | AfterCommand=3, 25 | } OperatorState; 26 | 27 | 28 | /** 29 | * the command processor class 30 | */ 31 | @interface Commands: NSObject { 32 | NSTextView *_textView; 33 | ViMode _viMode; 34 | BOOL _lastKeyWasEscape; 35 | unichar _currentInput; 36 | BOOL _waitingForFurtherInput; 37 | SEL _furtherInputHandler; 38 | 39 | BOOL _isReadingCount; 40 | NSMutableString *_countBuffer; 41 | int _currentCount; 42 | 43 | BOOL _isReadingNamedRegister; 44 | unichar _currentNamedRegister; 45 | 46 | OperatorState _operatorState; 47 | SEL _currentOperator; 48 | int _operatorCount; 49 | int _operatorStartPos; 50 | 51 | NSMutableString *_temporaryBuffer; 52 | NSMutableDictionary *_registers; 53 | } 54 | 55 | // constructor, called to set the view we're working on 56 | - (id)initWithTextView:(NSTextView *)aTextView; 57 | 58 | // return the current mode we're in 59 | - (ViMode)viMode; 60 | 61 | // cancel current command 62 | - (void)escape; 63 | 64 | // return true if the last pressed key was an ESCAPE, false otherwise. 65 | - (BOOL)lastKeyWasEscape; 66 | 67 | // clear the ESCAPE key status 68 | - (void)clearLastKeyWasEscape; 69 | 70 | // process a single input character from the keyboard 71 | - (void)processInput:(unichar)input; 72 | 73 | // process a single input character from the keyboard 74 | - (void)processInput:(unichar)input withControl:(BOOL)isControl; 75 | 76 | // try to process the input as a command 77 | - (BOOL)processInputAsCommand:(unichar)input withControl:(BOOL)isControl; 78 | 79 | // call the given command handler 80 | - (void)callCommandHandler:(SEL)action; 81 | 82 | // try to process the input as an operator 83 | - (BOOL)processInputAsOperator:(unichar)input; 84 | 85 | // called after a command was executed with an active operator. 86 | - (void)processOperatorAfterCommand; 87 | 88 | // process as named register identifier 89 | - (BOOL)processInputAsNamedRegister:(unichar)input; 90 | 91 | // try to process the input as an additional count 92 | - (BOOL)processInputAsCount:(unichar)input; 93 | 94 | @end 95 | 96 | -------------------------------------------------------------------------------- /Classes/Commands.m: -------------------------------------------------------------------------------- 1 | // Created by Axel on 20.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import "Commands.h" 5 | #import "Logger.h" 6 | #import "Commands_table.h" 7 | #import "Commands_implementation.h" 8 | #import "Commands_private.h" 9 | 10 | @implementation Commands 11 | 12 | /** 13 | * constructor, called to initialize the view we're working on 14 | */ 15 | - (id)initWithTextView:(NSTextView *)aTextView { 16 | if(![super init]) 17 | return nil; 18 | 19 | [aTextView retain]; 20 | _textView=aTextView; 21 | 22 | [self initializeCommandsTable]; 23 | _countBuffer=[[NSMutableString alloc] initWithCapacity:10]; 24 | _temporaryBuffer=[[NSMutableString alloc] initWithCapacity:10]; 25 | _registers=[[NSMutableDictionary alloc] initWithCapacity:40]; 26 | [self escape]; 27 | 28 | _viMode=Insert; 29 | return self; 30 | } 31 | 32 | /** 33 | * destructor, gibt alle Resources frei. Da wir sowohl in GC- 34 | * als auch in non-GC-Programmen laufen koennen fangen wir hier 35 | * beide Moeglichkeiten ab 36 | */ 37 | - (void)dealloc { [self destructor]; [super dealloc]; } 38 | - (void)finalize { [self destructor]; [super finalize]; } 39 | - (void)destructor { 40 | [_countBuffer release]; 41 | [_temporaryBuffer release]; 42 | [_registers release]; 43 | [_textView release]; 44 | } 45 | 46 | /** 47 | * we need to determine the selectors for all possible actions 48 | * at runtime because if we're trying to insert them into the 49 | * list of commands array at compile time we get a nasty error 50 | * message 51 | */ 52 | - (void)initializeCommandsTable { 53 | if(ListOfCommands[0].selector!=nil) 54 | return; 55 | 56 | // zuerst die Liste mit den Operators 57 | for(int pos=0;ListOfOperators[pos].key!=0;pos++) { 58 | NSString *selectorName=ListOfOperators[pos].selectorName; 59 | ListOfOperators[pos].selector=NSSelectorFromString(selectorName); 60 | } 61 | 62 | // dann die Liste mit den Commands 63 | for(int pos=0;ListOfCommands[pos].key!=0;pos++) { 64 | NSString *selectorName=ListOfCommands[pos].selectorName; 65 | ListOfCommands[pos].selector=NSSelectorFromString(selectorName); 66 | } 67 | } 68 | 69 | /** 70 | * return the current mode we're in 71 | */ 72 | - (ViMode)viMode { 73 | return _viMode; 74 | } 75 | 76 | /** 77 | * cancel current command and (re)initialize back to basic command mode 78 | */ 79 | - (void)escape { 80 | _isReadingCount=FALSE; 81 | [_countBuffer setString:@""]; 82 | _currentCount=0; 83 | 84 | _isReadingNamedRegister=FALSE; 85 | _currentNamedRegister=0; 86 | 87 | _operatorState=NoOperator; 88 | _currentOperator=nil; 89 | _operatorCount=0; 90 | 91 | _viMode=Command; 92 | _currentInput=0; 93 | _waitingForFurtherInput=FALSE; 94 | _furtherInputHandler=nil; 95 | _lastKeyWasEscape=NO; 96 | } 97 | 98 | /** 99 | * return true if the last pressed key was an ESCAPE, false otherwise. 100 | */ 101 | - (BOOL)lastKeyWasEscape { 102 | return _lastKeyWasEscape; 103 | } 104 | 105 | /** 106 | * clear the ESCAPE key status. This is needed if the user pressed ESC 107 | * twice to lets the second press bubble up to the caller. 108 | */ 109 | - (void)clearLastKeyWasEscape { 110 | _lastKeyWasEscape=NO; 111 | } 112 | 113 | /** 114 | * process a single input character from the keyboard. 115 | */ 116 | - (void)processInput:(unichar)input { 117 | [self processInput:input withControl:FALSE]; 118 | } 119 | 120 | /** 121 | * process a single input character from the keyboard. 122 | */ 123 | - (void)processInput:(unichar)input withControl:(BOOL)isControl { 124 | _currentInput=input; 125 | //[Logger log:@"processing <%c> (%x) (control <%d>)",input,input,isControl]; 126 | 127 | // wenn wir ein Escape gefunden haben brechen wir die aktuelle 128 | // Eingabe ab und initialisieren den Command Mode neu 129 | if(!isControl && input==0x1b) { 130 | [self escape]; 131 | _lastKeyWasEscape=YES; 132 | return; 133 | } 134 | else 135 | _lastKeyWasEscape=NO; 136 | 137 | // wenn wir nicht im Command-Mode sind brauchen wir den Rest gar nicht 138 | // erst auszuprobieren, da wir nur mit einem Escape in Selbigen kommen koennen. 139 | if(_viMode!=Command) 140 | return; 141 | 142 | // if we have pending command waiting for further input let's call 143 | // that command first before handing the input over to other commands 144 | if(_waitingForFurtherInput) { 145 | [self callCommandHandler:_furtherInputHandler]; 146 | return; 147 | } 148 | 149 | // dann gucken wir, ob wir vielleicht gerade in einem Count 150 | // sind. Wenn ja handeln wir den zuerst ab. 151 | if(!isControl && [self processInputAsCount:input]) 152 | return; 153 | 154 | // dann ueberpruefen wir, ob wir vielleich ein named register 155 | // fuer den folgenden Befehl haben 156 | if(!isControl && [self processInputAsNamedRegister:input]) 157 | return; 158 | 159 | // nun gucken wir doch mal, ob wir einen Operator gefunden haben 160 | if(!isControl && [self processInputAsOperator:input]) 161 | return; 162 | 163 | // jetzt bleibt nur noch die die Liste der moeglichen Kommandos, 164 | // die wir nun durchsuchen ob irgendwas passt. 165 | if([self processInputAsCommand:input withControl:isControl]) { 166 | return; 167 | } 168 | 169 | // keinen passenden Commandhandler gefunden, schade. 170 | [Logger log:@"invalid input, no command or operator found for <%c> (control <%d>)",input,isControl]; 171 | return; 172 | } 173 | 174 | /** 175 | * loops throught the list of command handlers and searches the matching 176 | * one. If a handler was found the method will return TRUE, otherwise FALSE 177 | * will be returned 178 | */ 179 | - (BOOL)processInputAsCommand:(unichar)input withControl:(BOOL)isControl { 180 | for(int pos=0;ListOfCommands[pos].key!=0;pos++) 181 | if(ListOfCommands[pos].key==input && ListOfCommands[pos].control==isControl) { 182 | // if we're in an operator and if we got an operator count we want to 183 | // execute the movement operatorCount * commandCount times. 184 | if(_operatorState!=NoOperator && _operatorCount>0) 185 | _currentCount=(_currentCount>0 ? _currentCount:1)*_operatorCount; 186 | 187 | // let's call the command handler 188 | SEL action=ListOfCommands[pos].selector; 189 | [self callCommandHandler:action]; 190 | return TRUE; 191 | } 192 | 193 | // no valid command handler found for this input 194 | return FALSE; 195 | } 196 | 197 | /** 198 | * call the given command handler and clean up afterwards 199 | */ 200 | - (void)callCommandHandler:(SEL)action { 201 | int cursorPos=[self cursorPosition]; 202 | [self performSelector:action]; 203 | if(!_waitingForFurtherInput) { 204 | // let's clean up after the command 205 | if(cursorPos!=[self cursorPosition]) 206 | [_textView scrollRangeToVisible:[_textView selectedRange]]; 207 | _currentCount=0; 208 | _furtherInputHandler=nil; 209 | 210 | // do we still have a pending operator? 211 | if(_operatorState!=NoOperator) 212 | [self processOperatorAfterCommand]; 213 | _currentNamedRegister=0; 214 | } 215 | else 216 | _furtherInputHandler=action; 217 | } 218 | 219 | /** 220 | * versucht die aktuelle Eingabe als Operator zu verarbeiten 221 | */ 222 | - (BOOL)processInputAsOperator:(unichar)input { 223 | for(int pos=0;ListOfOperators[pos].key!=0;pos++) 224 | if(ListOfOperators[pos].key==input) { 225 | SEL action=ListOfOperators[pos].selector; 226 | 227 | // sind wir bereits im Operator-Mode und rufen diesen Operator zum zweiten Mal auf? 228 | if(_currentOperator) { 229 | if(_currentOperator==action) { 230 | _operatorState=SecondTime; 231 | [self performSelector:action]; 232 | _operatorState=NoOperator; 233 | _currentOperator=nil; 234 | _operatorCount=0; 235 | } 236 | else 237 | [self escape]; // fehlerhafter Operator-Call 238 | } 239 | 240 | // nein, zum ersten Mal, dann einfach aufrufen 241 | else { 242 | _currentOperator=action; 243 | _operatorState=FirstTime; 244 | _operatorCount=_currentCount; 245 | _currentCount=0; 246 | [self performSelector:action]; 247 | } 248 | 249 | // nach einem Operator machen wir nix mehr 250 | return TRUE; 251 | } 252 | 253 | // die Eingabe war wohl eher kein Operator 254 | return FALSE; 255 | } 256 | 257 | /** 258 | * called after a command was executed with an active operator. 259 | * Executes the operator action a second time, then clear the 260 | * current operator 261 | */ 262 | - (void)processOperatorAfterCommand { 263 | _operatorState=AfterCommand; 264 | [self performSelector:_currentOperator]; 265 | _operatorState=NoOperator; 266 | _currentOperator=nil; 267 | _operatorCount=0; 268 | } 269 | 270 | /** 271 | * ueberprueft, ob die aktuelle Eingabe die Bezeichnung fuer ein named 272 | * register darstellt. 273 | */ 274 | - (BOOL)processInputAsNamedRegister:(unichar)input { 275 | if(_isReadingNamedRegister) { 276 | if((input>='a' && input<='z') || (input>='A' && input<='Z') || 277 | (input>='0' && input<='9') || 278 | input=='.' || input=='%' || input=='#' || input==':' || input=='-') 279 | _currentNamedRegister=input; 280 | else { 281 | _currentNamedRegister=0; 282 | } 283 | _isReadingNamedRegister=FALSE; 284 | } 285 | else if(input=='"') 286 | _isReadingNamedRegister=TRUE; 287 | else 288 | return FALSE; 289 | return TRUE; 290 | } 291 | 292 | /** 293 | * liest einen Zahlenwert als zusaetzliche Stelle fuer den Count 294 | * ein. Wenn die Eingabe zum Count gehoerte wird TRUE zurueckgegeben, 295 | * ansonsten wird FALSE geliefert. 296 | */ 297 | - (BOOL)processInputAsCount:(unichar)input { 298 | // wenn die Eingabe keine Zahl ist oder wir eine fuehrende 0 haben 299 | // (die es im VI als count nicht geben kann) ignorieren wir die Eingabe 300 | if(![[NSCharacterSet decimalDigitCharacterSet] characterIsMember:input]) { 301 | if(_isReadingCount) { 302 | _currentCount=[_countBuffer intValue]; 303 | [_countBuffer setString:@""]; 304 | _isReadingCount=FALSE; 305 | } 306 | return FALSE; 307 | } 308 | if(!_isReadingCount && input=='0') 309 | return FALSE; 310 | 311 | // wenn es die erste Ziffer des count ist eine neue Zahl anfangen 312 | if(!_isReadingCount) { 313 | _isReadingCount=TRUE; 314 | [_countBuffer setString:@""]; 315 | } 316 | 317 | // und dann die Ziffer an die Zahl anfuegen 318 | [_countBuffer appendFormat:@"%c",input]; 319 | return TRUE; 320 | } 321 | 322 | @end 323 | -------------------------------------------------------------------------------- /Classes/Commands_implementation.h: -------------------------------------------------------------------------------- 1 | // Created by Axel on 20.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import "Commands.h" 5 | 6 | @interface Commands (utilities) 7 | 8 | // true if the given text is a multiline text, false otherwise 9 | - (BOOL)hasMultipleLines:(NSString *)text inRange:(NSRange)range; 10 | 11 | // store the given text into a register 12 | - (void)storeText:(NSString *)text intoRegister:(unichar)namedRegister; 13 | 14 | // return the text from the current register 15 | - (NSString *)textForCurrentRegister; 16 | 17 | // return the current cursor position 18 | - (NSUInteger)cursorPosition; 19 | 20 | // move the cursor to the given position. 21 | - (void)moveCursorTo:(NSUInteger)pos; 22 | 23 | // find the first character in the current line 24 | - (NSUInteger)findStartOfLine:(NSUInteger)currentPos; 25 | 26 | // find the last character in the current line 27 | - (NSUInteger)findEndOfLine:(NSUInteger)currentPos; 28 | 29 | // return the real end of line position 30 | - (NSUInteger)findRealEndOfLine:(NSUInteger)currentPos; 31 | 32 | @end 33 | 34 | @interface Commands (implementation) 35 | 36 | // move cursor left 37 | - (void)cursorLeft; 38 | 39 | // move cursor right 40 | - (void)cursorRight; 41 | 42 | // move cursor up 43 | - (void)cursorUp; 44 | 45 | // move cursor down 46 | - (void)cursorDown; 47 | 48 | // places the cursor on the character in the column specified by the count (7.1, 7.2). 49 | - (void)cursorToColumn; 50 | 51 | // move to the beginning of the current line 52 | - (void)beginningOfLine; 53 | 54 | // move to the first non-whitespace character of the current line 55 | - (void)beginningOfLineNonWhitespace; 56 | 57 | // moves to the end of the current line 58 | - (void)endOfLine; 59 | 60 | // go to a specific line or to the end of the file 61 | - (void)goToLine; 62 | 63 | // go to a specific line or to the end of the file with the "gg" command 64 | - (void)goToLineVim; 65 | 66 | // move a word forward in the current line 67 | - (void)wordForward; 68 | 69 | // move a word forward in the current line 70 | - (void)WORDForward; 71 | 72 | // Used internally, advances to the beginning of the next word 73 | - (void)wordForwardWithWordCharacters:(NSCharacterSet *)wordChars; 74 | 75 | // move a word bacward in the current line 76 | - (void)wordBackward; 77 | 78 | // move a word bacward in the current line 79 | - (void)WORDBackward; 80 | 81 | // Used internally, advances to the beginning of the next word 82 | - (void)wordBackwardWithWordCharacters:(NSCharacterSet *)wordChars; 83 | 84 | // go to insert mode at current cursor position. 85 | - (void)insertMode; 86 | 87 | // Appends arbitrary text after the current cursor position 88 | - (void)insertModeAfterCursor; 89 | 90 | // Inserts at the beginning of a line; a synonym for ^i. 91 | - (void)insertModeAtBeginningOfLine; 92 | 93 | // Appends at the end of line, a synonym for $a (7.2). 94 | - (void)insertModeAtEndOfLine; 95 | 96 | // Changes the rest of the text on the current line; a synonym for c$. 97 | - (void)changeToEndOfLine; 98 | 99 | // Changes the single character under the cursor 100 | - (void)changeSingleCharacter; 101 | 102 | // Deletes the rest of the text on the current line; a synonym for d$. 103 | - (void)deleteEndOfLine; 104 | 105 | // Finds the first instance of the next character following the cursor on the current line 106 | - (void)findCharacter; 107 | 108 | // Finds a single character, backwards in the current line. A count repeats this search that many times (4.1). 109 | - (void)findCharacterBackward; 110 | 111 | // Advances the cursor up to the character before the next character typed 112 | - (void)findAndStopBeforeCharacter; 113 | 114 | // Deletes the single character under the cursor 115 | - (void)deleteCharacter; 116 | 117 | // Replaces the single character at the cursor 118 | - (void)replaceCharacter; 119 | 120 | // determine the range to modify for single character operations 121 | - (NSRange)rangeForSingleCharacterOperations; 122 | 123 | // opens new lines below the current line; otherwise like (3.1). 124 | - (void)openNewLine; 125 | 126 | // opens a newline above the current line 127 | - (void)openNewLineAbove; 128 | 129 | // joins together lines 130 | - (void)joinLines; 131 | 132 | // paste the content of a buffer before/ above the current cursor position 133 | - (void)pasteBefore; 134 | 135 | // paste the content of a buffer after/ below the current cursor position 136 | - (void)pasteAfter; 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /Classes/Commands_operators.h: -------------------------------------------------------------------------------- 1 | // Created by Axel on 26.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import "Commands.h" 5 | 6 | @interface Commands (operators) 7 | 8 | // change the following object 9 | - (void)operatorChange; 10 | 11 | // delete the following object 12 | - (void)operatorDelete; 13 | 14 | // yank the following object into a register 15 | - (void)operatorYank; 16 | 17 | // determine the range an operator should work on 18 | - (NSRange)determineOperatorRange; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Classes/Commands_operators.m: -------------------------------------------------------------------------------- 1 | // Created by Axel on 26.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import "Commands_operators.h" 5 | #import "Commands_implementation.h" 6 | #import "Logger.h" 7 | 8 | @implementation Commands (operators) 9 | 10 | /** 11 | * An operator which changes the following object, replacing it with the following input text up to an . If 12 | * more than part of a single line is affected, the text which is changed away is saved in the numeric named buffers. 13 | * If only part of the current line is affected, then the last character to be changed away is marked with a$. A 14 | * count causes that many objects to be affected, thus both 3c) and c3) change the following three sentences (7.4). 15 | */ 16 | - (void)operatorChange { 17 | // let's see if we should do something this time 18 | NSRange changeRange=[self determineOperatorRange]; 19 | if(changeRange.location==NSNotFound || changeRange.length<=0) 20 | return; 21 | 22 | // we store the changed text into the unnamed register 23 | [self storeText:_temporaryBuffer intoRegister:'"']; 24 | 25 | // ok, delete the range and go to insert mode 26 | [_textView setSelectedRange:changeRange]; 27 | [_textView delete:self]; 28 | _viMode=Insert; 29 | } 30 | 31 | /** 32 | * An operator which deletes the following object. If more than part of a line is affected, the text is saved in 33 | * the numeric buffers. A count causes that many objects to be affected; thus 3dw is the same as d3w (3.3,3.4,4.1,7.4). 34 | */ 35 | - (void)operatorDelete { 36 | // let's see if we should do something this time 37 | NSRange deleteRange=[self determineOperatorRange]; 38 | if(deleteRange.location==NSNotFound || deleteRange.length<=0) 39 | return; 40 | 41 | // we store the changed text into the unnamed register 42 | [self storeText:_temporaryBuffer intoRegister:'"']; 43 | 44 | // ok, we got a text range to delete 45 | [_textView setSelectedRange:deleteRange]; 46 | [_textView delete:self]; 47 | } 48 | 49 | /** 50 | * (yank into register, does not change the text) An operator, yanks the following object into the unnamed temporary 51 | * buffer. If preceded by a named buffer specification, "x, the text is placed in that buffer also. Text can be 52 | * recovered by a later

or

(7.4). 53 | */ 54 | - (void)operatorYank { 55 | // let's see if we should do something this time 56 | NSRange yankRange=[self determineOperatorRange]; 57 | if(yankRange.location==NSNotFound || yankRange.length<=0) 58 | return; 59 | 60 | // we store the changed text into the unnamed register 61 | [self storeText:_temporaryBuffer intoRegister:'"']; 62 | 63 | // ok, we've got a range to yank into the buffer, but the yanking 64 | // was done by the determineOperatorRange method. So only the move 65 | // to the originating cursor position is left for us to do. 66 | [self moveCursorTo:_operatorStartPos]; 67 | } 68 | 69 | /** 70 | * determine the range the operator should work on 71 | */ 72 | - (NSRange)determineOperatorRange { 73 | NSString *text=[[_textView textStorage] string]; 74 | int count=(_operatorCount>0 ? _operatorCount:1); 75 | NSRange range={NSNotFound,0}; 76 | 77 | // if we're called the second time let's operate on some lines 78 | if(_operatorState==SecondTime) { 79 | NSInteger startPos=[self findStartOfLine:[self cursorPosition]], 80 | endPos=startPos; 81 | for(int i=0;i0 ? _operatorStartPos:0), 96 | endPos=[self cursorPosition]; 97 | if(startPos>endPos) { 98 | int buffer=startPos; 99 | startPos=endPos; 100 | endPos=buffer; 101 | } 102 | 103 | // if the range is multiline we're deleting the whole lines 104 | if([self hasMultipleLines:text inRange:NSMakeRange(startPos,endPos-startPos)]) { 105 | startPos=[self findStartOfLine:startPos]; 106 | endPos=[self findRealEndOfLine:endPos]; 107 | } 108 | 109 | // set the range to operate on 110 | range=NSMakeRange(startPos,endPos-startPos); 111 | } 112 | 113 | // if we got a valid range copy the range into the temporary buffer and 114 | // possibly into a named register, too. 115 | if(range.location!=NSNotFound) { 116 | [_temporaryBuffer setString:[text substringWithRange:range]]; 117 | [self storeText:_temporaryBuffer intoRegister:_currentNamedRegister]; 118 | return range; 119 | } 120 | else 121 | return NSMakeRange(NSNotFound,0); 122 | } 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /Classes/Commands_private.h: -------------------------------------------------------------------------------- 1 | // Created by Axel on 20.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | 5 | @interface Commands (private) 6 | 7 | // destructor 8 | - (void)destructor; 9 | 10 | // determine the selectors for the actions at runtime 11 | - (void)initializeCommandsTable; 12 | 13 | // process the given input as a digit for the count 14 | - (BOOL)processInputAsCount:(unichar)input; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Classes/Logger.h: -------------------------------------------------------------------------------- 1 | // Created by Axel on 13.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import 5 | 6 | @interface Logger: NSObject { 7 | } 8 | 9 | // write a log message into the system log 10 | + (void)log:(NSString *)format,...; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /Classes/Logger.m: -------------------------------------------------------------------------------- 1 | // Created by Axel on 13.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import "Logger.h" 5 | #import 6 | 7 | 8 | @implementation Logger 9 | 10 | /** 11 | * write a log message into the system log 12 | */ 13 | + (void)log:(NSString *)format,... { 14 | va_list args; 15 | va_start(args,format); 16 | 17 | NSString *msg=[[NSString alloc] initWithFormat:format arguments:args]; 18 | #ifdef BUILD_FOR_TEST_APPLICATION 19 | NSLog(@"%@", msg); 20 | #else 21 | openlog("vImputManager",LOG_CONS|LOG_PID,LOG_USER); 22 | syslog(LOG_NOTICE,[msg UTF8String]); 23 | closelog(); 24 | #endif 25 | 26 | va_end(args); 27 | [msg release]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Classes/NSTextView_vImputManager.h: -------------------------------------------------------------------------------- 1 | // Created by Axel on 13.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import 5 | 6 | 7 | @interface NSTextView (vImputManager) 8 | 9 | // intercept key events to handle vi input mode 10 | - (void)vImputManager_keyDown:(NSEvent *)event; 11 | 12 | // the garbage collector invokes this method before disposing of the memory it uses 13 | - (void)vImputManager_finalize; 14 | 15 | // deallocates the memory occupied by the receiver 16 | - (void)vImputManager_dealloc; 17 | 18 | @end 19 | 20 | 21 | -------------------------------------------------------------------------------- /Classes/NSTextView_vImputManager.m: -------------------------------------------------------------------------------- 1 | // Created by Axel on 13.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import "NSTextView_vImputManager.h" 5 | #import "Commands.h" 6 | #import "Logger.h" 7 | #import 8 | 9 | // the global list of currently allocated command processors. 10 | static NSMutableDictionary *ViCommandProcessors=nil; 11 | 12 | @implementation NSTextView (vImputManager) 13 | 14 | /** 15 | * overload the destructor to release the command 16 | * processor instance associated with this text view. 17 | */ 18 | - (void)dealloc { 19 | [super dealloc]; 20 | [ViCommandProcessors removeObjectForKey:[NSNumber numberWithInt:(int)self]]; 21 | } 22 | 23 | /** 24 | * intercept key events to handle vi input mode. 25 | */ 26 | - (void)vImputManager_keyDown:(NSEvent *)event { 27 | // first we need to get the characters to process 28 | NSString *chars=[event charactersIgnoringModifiers]; 29 | unichar charCode=[chars characterAtIndex:0]; 30 | NSUInteger modifiers=[event modifierFlags]; 31 | 32 | // every key combination containing the Command key is ignored 33 | // by the plugin so that the host application can handle this 34 | if((modifiers & NSCommandKeyMask)>0) { 35 | [self vImputManager_originalKeyDown:event]; 36 | return; 37 | } 38 | 39 | // get the command processor for this text view, allocate 40 | // a new one if none is currently present for the view. 41 | if(!ViCommandProcessors) 42 | ViCommandProcessors=[[NSMutableDictionary alloc] init]; 43 | NSNumber *myId=[NSNumber numberWithInt:(int)self]; 44 | Commands *processor=[ViCommandProcessors objectForKey:myId]; 45 | if(processor==nil) { 46 | processor=[[Commands alloc] initWithTextView:self]; 47 | [ViCommandProcessors setObject:processor forKey:myId]; 48 | [Logger log:@"allocated a new processor <%@> for id <%x>",processor,[myId intValue]]; 49 | } 50 | 51 | // if we got two consequetive ESC keypresses we'll let 52 | // the second one bubble up to the original handler. This 53 | // way we're able to escape from ie. the find inputline 54 | // or the code sense popup 55 | if(charCode==0x1b && [processor lastKeyWasEscape]) { 56 | [processor clearLastKeyWasEscape]; 57 | [self vImputManager_originalKeyDown:event]; 58 | return; 59 | } 60 | 61 | // if we're not in command mode and the current input isn't 62 | // an ESC we're not going to handle this input by ourself 63 | if([processor viMode]==Command || charCode==0x1b) { 64 | BOOL isControl=(modifiers & NSControlKeyMask)>0; 65 | [processor processInput:charCode withControl:isControl]; 66 | } 67 | 68 | // otherwise let the event bubble up the handler hierarchie 69 | else 70 | [self vImputManager_originalKeyDown:event]; 71 | } 72 | 73 | /** 74 | * the garbage collector invokes this method before disposing 75 | * of the memory it uses. We're overriding this method from 76 | * NSTextView to ensure that the corresponding command processor 77 | * gets disposed. 78 | */ 79 | - (void)vImputManager_finalize { 80 | if(ViCommandProcessors) { 81 | NSNumber *myId=[NSNumber numberWithInt:(int)self]; 82 | [Logger log:@"finalized a processor <%@> for id <%x>",[ViCommandProcessors objectForKey:myId],[myId intValue]]; 83 | [ViCommandProcessors removeObjectForKey:myId]; 84 | } 85 | else NSLog(@"trying to finalize processor but no list of processors found?!"); 86 | 87 | [self vImputManager_originalFinalize]; 88 | } 89 | 90 | /** 91 | * deallocates the memory occupied by the receiver. We're overriding 92 | * this method from NSTextView to ensure that the corresponding 93 | * key handler gets disposed. 94 | */ 95 | - (void)vImputManager_dealloc { 96 | if(ViCommandProcessors) { 97 | NSNumber *myId=[NSNumber numberWithInt:(int)self]; 98 | [Logger log:@"deallocated a processor <%@> for id <%x>",[ViCommandProcessors objectForKey:myId],[myId intValue]]; 99 | [ViCommandProcessors removeObjectForKey:myId]; 100 | } 101 | else NSLog(@"trying to deallocate processor but no list of processors found?!"); 102 | 103 | [self vImputManager_originalDealloc]; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /Resources/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluete/vImputManager/42c09de824f85da3ffa68dcc11c36cbc9a502998/Resources/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | de.pqrs.vImputManager 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSPrincipalClass 24 | BundlePrincipal 25 | InstallationBlacklist 26 | 27 | xcode 28 | macvim 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Resources/Whitelist.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Entries 6 | 7 | com.apple.Xcode 8 | com.apple.TextEdit 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /TestApplication-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | de.pqrs.vImputManager.TestApplication 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | NSMainNibFile 20 | MainMenu 21 | NSPrincipalClass 22 | NSApplication 23 | InstallationBlacklist 24 | 25 | xcode 26 | macvim 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /TestApplication/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluete/vImputManager/42c09de824f85da3ffa68dcc11c36cbc9a502998/TestApplication/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /TestApplication/PseudoController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PseudoController.h 3 | // vImputManager 4 | // 5 | // Created by Axel on 13.08.09. 6 | // Copyright 2009 pqrs.de, All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface PseudoController : NSObject { 13 | IBOutlet NSTextView *textView; 14 | } 15 | 16 | - (void)awakeFromNib; 17 | 18 | // exchange two method implementation on NSTextView 19 | + (BOOL)swizzleTextViewMethodFrom:(SEL)originalSel to:(SEL)newSel; 20 | 21 | // exchange two method implementation on the given class 22 | + (BOOL)swizzleMethodsOfClass:(Class)clazz from:(SEL)originalSel to:(SEL)newSel; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /TestApplication/PseudoController.m: -------------------------------------------------------------------------------- 1 | // Created by Axel on 13.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import "PseudoController.h" 5 | #import "Logger.h" 6 | #import 7 | 8 | 9 | @implementation PseudoController 10 | 11 | - (void)awakeFromNib { 12 | [PseudoController swizzleMethodsOfClass:[NSTextView class] 13 | from:@selector(keyDown:) 14 | to:@selector(vImputManager_originalKeyDown:)]; 15 | [PseudoController swizzleMethodsOfClass:[NSTextView class] 16 | from:@selector(vImputManager_keyDown:) 17 | to:@selector(keyDown:)]; 18 | [Logger log:@"vi input mode successfully installed for test application"]; 19 | 20 | NSString *plistPath=[[NSBundle mainBundle] pathForResource:@"Blacklist" ofType:@"plist"]; 21 | NSData *plistXML=[[NSFileManager defaultManager] contentsAtPath:plistPath]; 22 | NSString *errorDesc=nil; 23 | NSPropertyListFormat format; 24 | NSDictionary *plist=(NSDictionary *)[NSPropertyListSerialization 25 | propertyListFromData:plistXML 26 | mutabilityOption:NSPropertyListMutableContainersAndLeaves 27 | format:&format 28 | errorDescription:&errorDesc]; 29 | NSArray *entries=[plist objectForKey:@"Entries"]; 30 | [Logger log:@"the blacklist data is <%@>",entries]; 31 | } 32 | 33 | /** 34 | * exchange two method implementation on NSTextView 35 | */ 36 | + (BOOL)swizzleTextViewMethodFrom:(SEL)originalSel to:(SEL)newSel { 37 | return [self swizzleMethodsOfClass:[NSTextView class] 38 | from:originalSel 39 | to:newSel]; 40 | } 41 | 42 | /** 43 | * exchange two method implementation on the given class 44 | */ 45 | + (BOOL)swizzleMethodsOfClass:(Class)clazz from:(SEL)originalSel to:(SEL)newSel { 46 | Method method=class_getInstanceMethod(clazz,originalSel); 47 | if(method==nil) 48 | return FALSE; 49 | method->method_name=newSel; 50 | return TRUE; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /TestApplication/main.m: -------------------------------------------------------------------------------- 1 | // Created by Axel on 13.08.09. 2 | // Copyright 2009 pqrs.de, All rights reserved. 3 | 4 | #import 5 | 6 | int main(int argc,char **argv) { 7 | return NSApplicationMain(argc,(const char **)argv); 8 | } 9 | -------------------------------------------------------------------------------- /Testing-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.${PRODUCT_NAME:identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Testing/ViCommandsTests.h: -------------------------------------------------------------------------------- 1 | // Created by Axel on 24.08.09. 2 | // Copyright 2009 pqrs.de. All rights reserved. 3 | 4 | #import 5 | #import 6 | 7 | @class Commands; 8 | 9 | @interface ViCommandsTests: SenTestCase { 10 | NSTextView *_textView; 11 | Commands *_cmds; 12 | } 13 | 14 | // move the cursor to a specific position in the text 15 | - (void)moveCursorTo:(NSUInteger)pos; 16 | 17 | // move the cursor to the beginning of the text 18 | - (void)moveCursorToStart; 19 | 20 | // move the cursor to the end of the text 21 | - (void)moveCursorToEnd; 22 | 23 | // replace the content of the text view 24 | - (void)replaceText:(NSString *)text; 25 | 26 | // return the current cursor position 27 | - (NSUInteger)cursorPosition; 28 | 29 | // return the content of the given line 30 | - (NSString *)line:(int)lineNo; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /doc/Info.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BundleName 6 | vImputManager.bundle 7 | LoadBundleOnLaunch 8 | YES 9 | LocalizedNames 10 | 11 | English 12 | IncrementalSearch 13 | 14 | NoMenuEntry 15 | YES 16 | 17 | 18 | -------------------------------------------------------------------------------- /doc/commands/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CC= gcc 3 | CCFLAGS= -ObjC -Wall -DBUILD_FOR_TEST_APPLICATION 4 | 5 | LD= gcc 6 | LDFLAGS= -framework Foundation 7 | 8 | PROGRAM= main 9 | 10 | SOURCES= main.m Commands.m Commands_implementation.m Logger.m 11 | OBJECTS= $(SOURCES:%.m=%.o) 12 | 13 | all: $(PROGRAM) 14 | 15 | $(PROGRAM): $(OBJECTS) 16 | $(LD) $(LDFLAGS) $(OBJECTS) -o $(PROGRAM) 17 | 18 | .m.o: 19 | $(CC) $(CCFLAGS) -c $< -o $@ 20 | 21 | clean: 22 | rm -f $(OBJECTS) $(PROGRAM) 23 | 24 | main.o: Commands.h Logger.h 25 | Commands.o: Commands.h Commands_private.h Commands_implementation.h Logger.h 26 | Commands_implementation.o: Commands.h Commands_implementation.h Logger.h 27 | Logger.o: Logger.h 28 | -------------------------------------------------------------------------------- /doc/commands/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Commands.h" 3 | 4 | int main(int argc,const char **argv) { 5 | NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init]; 6 | 7 | Commands *cmds=[[Commands alloc] init]; 8 | 9 | [cmds processInput:'3' withControl:FALSE]; 10 | [cmds processInput:'G' withControl:FALSE]; // goto third line 11 | 12 | [cmds processInput:'0' withControl:FALSE]; // at the beginning of the line 13 | 14 | [cmds processInput:'1' withControl:FALSE]; 15 | [cmds processInput:'0' withControl:FALSE]; 16 | [cmds processInput:'l' withControl:FALSE]; // then move ten chars to the right 17 | 18 | // [cmds processInput:'c' withControl:FALSE]; 19 | // [cmds processInput:'f' withControl:FALSE]; 20 | 21 | [pool drain]; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /doc/ex-vi/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Changes/1.50/Thu Aug 18 20:54:54 2005// 2 | /LICENSE/1.2/Fri Feb 18 02:24:40 2005// 3 | /Makefile/1.6/Sat Feb 24 23:47:28 2007// 4 | /README/1.17/Fri Jan 12 17:43:22 2007// 5 | /TODO/1.3/Sat Feb 19 18:01:26 2005// 6 | /config.h/1.3/Thu Aug 4 12:09:59 2005// 7 | /ex.1/1.1.1.1/Sat Dec 4 13:17:06 2004// 8 | /ex.c/1.4/Thu Aug 4 15:23:39 2005// 9 | /ex.h/1.10/Sat Aug 6 11:41:15 2005// 10 | /ex.spec/1.4/Thu Aug 4 12:10:00 2005// 11 | /ex_addr.c/1.3/Thu Aug 4 15:23:40 2005// 12 | /ex_argv.h/1.2/Thu Aug 4 12:10:00 2005// 13 | /ex_cmds.c/1.5/Fri Feb 18 17:54:25 2005// 14 | /ex_cmds2.c/1.2/Thu Feb 17 17:00:56 2005// 15 | /ex_cmdsub.c/1.6/Fri Aug 5 23:15:04 2005// 16 | /ex_data.c/1.1.1.1/Sat Dec 4 13:17:13 2004// 17 | /ex_extern.c/1.1.1.1/Sat Dec 4 13:17:11 2004// 18 | /ex_get.c/1.3/Thu Aug 4 15:23:40 2005// 19 | /ex_io.c/1.6/Thu Aug 4 17:03:27 2005// 20 | /ex_proto.h/1.9/Sat Aug 6 11:41:15 2005// 21 | /ex_put.c/1.10/Mon Dec 25 19:31:50 2006// 22 | /ex_re.c/1.19/Fri Aug 5 23:15:04 2005// 23 | /ex_re.h/1.7/Thu Aug 4 15:23:41 2005// 24 | /ex_set.c/1.1.1.1/Sat Dec 4 13:17:14 2004// 25 | /ex_subr.c/1.8/Mon Dec 25 19:31:50 2006// 26 | /ex_tagio.c/1.2/Thu Aug 4 15:23:41 2005// 27 | /ex_temp.c/1.3/Mon Dec 25 19:31:50 2006// 28 | /ex_temp.h/1.3/Thu Aug 4 15:23:41 2005// 29 | /ex_tty.c/1.4/Thu Aug 4 12:10:00 2005// 30 | /ex_tty.h/1.2/Thu Aug 4 12:10:00 2005// 31 | /ex_tune.h/1.3/Thu Aug 4 15:23:41 2005// 32 | /ex_unix.c/1.2/Thu Aug 4 15:23:41 2005// 33 | /ex_v.c/1.3/Thu Aug 4 15:23:41 2005// 34 | /ex_vadj.c/1.5/Sat Aug 6 11:41:15 2005// 35 | /ex_vars.h/1.1.1.1/Sat Dec 4 13:17:16 2004// 36 | /ex_version.c/1.36/Mon Dec 25 19:31:50 2006// 37 | /ex_vget.c/1.6/Sat Aug 6 11:41:15 2005// 38 | /ex_vis.h/1.6/Sat Aug 6 11:41:15 2005// 39 | /ex_vmain.c/1.6/Sat Aug 6 12:06:49 2005// 40 | /ex_voper.c/1.5/Sat Aug 6 11:41:15 2005// 41 | /ex_vops.c/1.6/Thu Aug 4 15:23:42 2005// 42 | /ex_vops2.c/1.4/Mon Dec 25 19:31:50 2006// 43 | /ex_vops3.c/1.3/Thu Aug 4 15:23:44 2005// 44 | /ex_vput.c/1.18/Mon Dec 25 19:31:50 2006// 45 | /ex_vwind.c/1.1.1.1/Sat Dec 4 13:17:12 2004// 46 | /expreserve.c/1.1.1.1/Sat Dec 4 13:17:13 2004// 47 | /exrecover.c/1.3/Mon Dec 25 19:31:50 2006// 48 | /makeoptions/1.1.1.1/Sat Dec 4 13:17:08 2004// 49 | /malloc.c/1.3/Sun Feb 20 22:20:58 2005// 50 | /mapmalloc.c/1.10/Thu Aug 18 20:54:54 2005// 51 | /pkginfo/1.1/Sat Feb 24 23:47:28 2007// 52 | /printf.c/1.1.1.1/Sat Dec 4 13:17:14 2004// 53 | /vi.1/1.1.1.1/Sat Dec 4 13:17:07 2004// 54 | D 55 | -------------------------------------------------------------------------------- /doc/ex-vi/CVS/Entries.Log: -------------------------------------------------------------------------------- 1 | A D/catd//// 2 | A D/libterm//// 3 | -------------------------------------------------------------------------------- /doc/ex-vi/CVS/Repository: -------------------------------------------------------------------------------- 1 | ex-vi 2 | -------------------------------------------------------------------------------- /doc/ex-vi/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:anonymous@ex-vi.cvs.sourceforge.net:/cvsroot/ex-vi 2 | -------------------------------------------------------------------------------- /doc/ex-vi/LICENSE: -------------------------------------------------------------------------------- 1 | This code contains changes by 2 | Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 3 | 4 | Conditions 1, 2, and 4 and the no-warranty notice below apply 5 | to these changes. 6 | 7 | Copyright (c) 1980, 1993 8 | The Regents of the University of California. All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions 12 | are met: 13 | 1. Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | 2. Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 3. All advertising materials mentioning features or use of this software 19 | must display the following acknowledgement: 20 | This product includes software developed by the University of 21 | California, Berkeley and its contributors. 22 | 4. Neither the name of the University nor the names of its contributors 23 | may be used to endorse or promote products derived from this software 24 | without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 | SUCH DAMAGE. 37 | 38 | 39 | Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 40 | 41 | Redistribution and use in source and binary forms, with or without 42 | modification, are permitted provided that the following conditions 43 | are met: 44 | Redistributions of source code and documentation must retain the 45 | above copyright notice, this list of conditions and the following 46 | disclaimer. 47 | Redistributions in binary form must reproduce the above copyright 48 | notice, this list of conditions and the following disclaimer in the 49 | documentation and/or other materials provided with the distribution. 50 | All advertising materials mentioning features or use of this software 51 | must display the following acknowledgement: 52 | This product includes software developed or owned by Caldera 53 | International, Inc. 54 | Neither the name of Caldera International, Inc. nor the names of 55 | other contributors may be used to endorse or promote products 56 | derived from this software without specific prior written permission. 57 | 58 | USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 59 | INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 60 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 61 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 62 | ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 63 | LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 64 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 65 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 66 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 67 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 68 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 69 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 70 | -------------------------------------------------------------------------------- /doc/ex-vi/README: -------------------------------------------------------------------------------- 1 | Welcome to the ex/vi port! 2 | ========================== 3 | 4 | This implementation is derived from ex/vi 3.7 of 6/7/85 and the BSD 5 | termcap library, originally from the 2.11BSD distribution. All of them 6 | were changed to compile and run on newer POSIX compatible Unix systems. 7 | Support for international character sets was added, including support 8 | for multibyte locales (based on UTF-8 or East Asian encodings), and some 9 | changes were made to get closer to the POSIX.2 guidelines for ex and 10 | vi. Some issues that were clearly bugs and not features have also been 11 | resolved; see the Changes file for details. 12 | 13 | New releases are announced on Freshmeat. If you want to get 14 | notified by email on each release, use their subscription service at 15 | . 16 | 17 | The project homepage is currently at . 18 | 19 | 20 | How to build 21 | ============ 22 | 23 | First look at the Makefile and change the settings there to match your 24 | build environment. Explanations are provided directly in this file. 25 | 26 | You can tune the sizes of some internal buffers by editing config.h. 27 | 28 | Then type 'make' and 'make install'. 29 | 30 | It is possible to build a RPM file directly from the source distribution 31 | by executing 32 | 33 | rpmbuild -tb ex-.tar.bz2 34 | 35 | Note that the RPM spec installs the binary in /usr/5bin by default to 36 | avoid conflicts with vendor files in /usr/bin. The default locations 37 | match those of the Heirloom Toolchest . 38 | 39 | The following systems have been reported to compile this code: 40 | 41 | Linux Kernel 2.0 and above; libc4, libc5, glibc 2.2 and above, 42 | diet libc, uClibc 43 | Sun Solaris 2.5.1 and above 44 | Caldera Open UNIX 8.0.0 45 | SCO UnixWare 7.1.1, 7.0.1, 2.1.2 46 | HP HP-UX B.11.23, B.11.11, B.11.00, B.10.20 47 | HP Tru64 UNIX 4.0G, 5.1B 48 | IBM AIX 5.1, 4.3 49 | NEC SUPER-UX 10.2 50 | NEC UX/4800 Release11.5 Rev.A 51 | Control Data EP/IX 2.2.1AA 52 | FreeBSD 3.1, 4.5, 5.x, 6.1 53 | NetBSD 1.6, 2.0 54 | DragonFlyBSD 1.3.7-DEVELOPMENT 55 | Mac OS X 10.4.3 56 | 57 | Reports about other Unix systems are welcome, whether successful or not 58 | (in the latter case add a detailed description). This port of vi is only 59 | aimed at Unix, though, so I am not interested about results from running 60 | this software on Windows etc. 61 | 62 | Prerequisites for ports to other systems are: 63 | 64 | - The system must provide an ANSI C-89 compiler and POSIX.1-1990 functions. 65 | 66 | - The system must provide an sbrk() call to increase the memory heap size. 67 | If only a fake sbrk() call is provided that works by pre-allocating 68 | several MB, vi will probably work too. 69 | 70 | - The system library must allow replacement of malloc() and printf() by the 71 | versions provided by vi. For malloc(), it also must make its own internal 72 | memory requests using the vi malloc(). Otherwise, vi will likely die with 73 | a segmentation fault because the storage allocated by sbrk() interferes 74 | with usual Unix library implementations of malloc(). 75 | 76 | The last two requirements could probably be eliminated with some effort, but 77 | it would not result in any real improvements for usual the Unix platforms vi 78 | is targeted at, so it has not be done yet. 79 | 80 | 81 | Terminal capabilities 82 | ===================== 83 | 84 | vi normally uses the termcap library to gather information about the 85 | capabilities of the terminal it is using. A BSD-derived termcap library 86 | is included with the vi distribution, and is usually the preferred choice. 87 | On some platforms, though, either no /etc/termcap file exists, or the file 88 | lacks up-to-date entries. In these cases, two workarounds are possible. 89 | First, vi can be linked against libcurses, libncurses, or libtermcap, if 90 | these provide access to a proper terminal information database. Second, it 91 | is possible to use the included termcap library with a TERMCAP environment 92 | variable that contains a complete termcap entry. Most terminals in current 93 | use provide a superset of DEC VT102 capabilities, so the following will 94 | normally work: 95 | 96 | TERMCAP="vt102|$TERM|dec vt102:"'\ 97 | :do=^J:co#80:li#24:cl=50\E[;H\E[2J:\ 98 | :le=^H:bs:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\ 99 | :ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\ 100 | :md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:is=\E[1;24r\E[24;1H:\ 101 | :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\ 102 | :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\ 103 | :ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=5\EM:vt#3:\ 104 | :sc=\E7:rc=\E8:cs=\E[%i%d;%dr:vs=\E[?7l:ve=\E[?7h:\ 105 | :mi:al=\E[L:dc=\E[P:dl=\E[M:ei=\E[4l:im=\E[4h:' 106 | export TERMCAP 107 | 108 | 109 | Multibyte locale support 110 | ======================== 111 | 112 | Support for multibyte locales has been added to vi. It requires a number of 113 | functions that, while specified in XPG6, are not present on all systems that 114 | provide basic multibyte support. In particular, vi needs wcwidth() to 115 | determine the visual width of a character, and mbrtowc() to detect when a 116 | byte sequence that is entered at the terminal has been completed. 117 | 118 | The multibyte code is known to work on the following systems: 119 | 120 | Linux glibc 2.2.2 and later 121 | Sun Solaris 9 and later 122 | HP HP-UX B.11.11 and later 123 | FreeBSD 5.3 124 | NetBSD 2.0 125 | 126 | It has been tested on xterm patch #192, rxvt-unicode 4.2, mlterm 2.9.1, 127 | xiterm 0.5, and gnome-terminal 2.10.0. 128 | 129 | Successful operation is known for the following encodings: UTF-8, EUC-JP, 130 | EUC-KR, Big5, Big5-HKSCS, GB 2312, GBK. vi does not support locking-shift 131 | encodings like those that use ISO 2022 escape sequences. It also requires 132 | that the first byte of any multibyte character has the highest bit set. 133 | This excludes 7-bit encodings like UTF-7, and encodings whose sequences 134 | start with ASCII characters like TCVN 5712. 135 | 136 | To use UTF-8 locales in ex mode, the terminal should be put in 'stty iutf8' 137 | mode on Linux if it does not perform this automatically. Otherwise, typing 138 | the erase key once after entering a multibyte character will result in an 139 | incomplete byte sequence. 140 | 141 | 142 | Gunnar Ritter 01/12/07 143 | Freiburg i. Br. 144 | Germany 145 | 146 | -------------------------------------------------------------------------------- /doc/ex-vi/TODO: -------------------------------------------------------------------------------- 1 | TODO list for ex 2 | 3 | - Some support for UTF-8 combining characters should probably be added. 4 | 5 | - Since the POSIX standard developers did not include a method to 6 | determine whether something is a valid collation symbol or an 7 | equivalence class, and since there is no access to the basic 8 | collation sequence, LC_COLLATE locales are completely ignored. 9 | 10 | - SVr4 ex probably has some silent features that this one should have too. 11 | 12 | Gunnar Ritter 2/19/05 13 | -------------------------------------------------------------------------------- /doc/ex-vi/catd/CVS/Entries: -------------------------------------------------------------------------------- 1 | /en_US/1.1.1.1/Sat Dec 4 13:17:18 2004// 2 | D 3 | -------------------------------------------------------------------------------- /doc/ex-vi/catd/CVS/Repository: -------------------------------------------------------------------------------- 1 | ex-vi/catd 2 | -------------------------------------------------------------------------------- /doc/ex-vi/catd/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:anonymous@ex-vi.cvs.sourceforge.net:/cvsroot/ex-vi 2 | -------------------------------------------------------------------------------- /doc/ex-vi/catd/en_US: -------------------------------------------------------------------------------- 1 | $ Message catalogue for ex/vi 2 | $ Sccsid @(#)en_US 1.4 (gritter) 3/18/03 3 | $quote " 4 | $set 1 5 | 1 "Usage: %s [- | -s] [-l] [-L] [-R] [-r [file]] [-t tag]\n\ 6 | [-v] [-V] [-w size] [+cmd | -c cmd] file...\n" 7 | 2 "%s: option requires an argument -- %c\n" 8 | 3 "%s: illegal option -- %c\n" 9 | 4 "Trace create error\n" 10 | 5 "Unknown option %s\n" 11 | 6 "Addr1 > addr2|First address exceeds second" 12 | 7 "Bad count|Nonzero count required" 13 | 8 "No address allowed@on this command" 14 | 9 "Badly formed address" 15 | 10 "No match to BOTTOM|Address search hit BOTTOM without matching pattern" 16 | 11 "No match to TOP|Address search hit TOP without matching pattern" 17 | 12 "Fail|Pattern not found" 18 | 13 "Marks are ' and a-z" 19 | 14 "Undefined mark@referenced" 20 | 15 "Negative address@- first buffer line is 1" 21 | 16 "Not that many lines@in buffer" 22 | 17 "Offset out-of-bounds|Offset after command too large" 23 | 18 "Home directory unknown" 24 | 19 "Mark what?|%s requires following letter" 25 | 20 "Bad mark|Mark must specify a letter" 26 | 21 "Preserve failed!" 27 | 22 "File preserved." 28 | 23 "No write@since last change (:rewind! overrides)" 29 | 24 "Old tty driver|Not using new tty driver/shell" 30 | 25 "Bad register" 31 | 26 "At EOF|At end-of-file" 32 | 27 "What?|Unknown command character '%c'" 33 | 28 "Extra chars|Extra characters at end of command" 34 | 29 " [Warning - %s is incomplete]" 35 | 30 "%d files@to edit" 36 | 31 "No more files@to edit" 37 | $quote 38 | 32 Extra chars|Extra characters at end of "%s" command 39 | $quote " 40 | 33 "%d more file" 41 | 34 "%s@to edit" 42 | 35 "No write@since last change (:%s! overrides)" 43 | 36 "What?|%s: No such command from open/visual" 44 | 37 "What?|%s: Not an editor command" 45 | 38 "[Hit return to continue] " 46 | 39 "Out of memory@- too many lines in file" 47 | 40 "Line overflow|Result line of join would be too long" 48 | 41 "That move would do nothing!" 49 | 42 "Move to a moved line" 50 | 43 "%s where?|%s requires a trailing address" 51 | 44 "Cannot put inside global/macro" 52 | 45 "Line too long|Result line after shift would be too long" 53 | 46 "Bad tag|Give one tag per line" 54 | 47 "No previous tag" 55 | 48 "%s: Bad tags file entry" 56 | 49 "No write@since last change (:tag! overrides)" 57 | 50 "No tags file" 58 | 51 "%s: No such tag@in tags file" 59 | 52 "Can't yank inside global/macro" 60 | 53 "\nAt EOF" 61 | 54 "At EOF" 62 | 55 "Hit BOTTOM" 63 | 56 "Hit TOP" 64 | 57 "Nothing to undo" 65 | 58 "Nothing changed|Last undoable command didn't change anything" 66 | 59 "Can't undo in global@commands" 67 | 60 "Missing lhs" 68 | 61 "Missing rhs" 69 | 62 "Missing rhs" 70 | 63 "No tail recursion" 71 | 64 "Too dangerous to map that" 72 | 65 "No tail recursion" 73 | 66 "Missing lhs" 74 | 67 "Not mapped|That macro wasn't mapped" 75 | 68 "Too many macros" 76 | 69 "Too much macro text" 77 | 70 "^H discarded\n" 78 | 71 "Input line too long" 79 | 72 "No file|No current filename" 80 | 73 " [Read only]" 81 | 74 " [Not edited]" 82 | 75 " [Modified]" 83 | 76 "No file " 84 | 77 " line %d of %d --%ld%%--" 85 | 78 "Pattern too long" 86 | 79 "Argument buffer overflow" 87 | 80 "No alternate filename@to substitute for #" 88 | 81 "No current filename@to substitute for %%" 89 | 82 "Can't make pipe to glob" 90 | 83 "Can't fork to do glob" 91 | 84 "Arg list too long" 92 | 85 "Arg list too long" 93 | 86 "No match" 94 | 87 "Missing filename" 95 | 88 "Ambiguous|Too many file names" 96 | 89 "Filename too long" 97 | 90 " [New file]" 98 | 91 " Block special file" 99 | 92 " Teletype" 100 | 93 " Character special file" 101 | 94 " Directory" 102 | 95 " Socket" 103 | 96 " Named pipe" 104 | 97 " Executable" 105 | 98 " Compressed Data" 106 | 99 " ELF object" 107 | 100 " Archive" 108 | 101 " Non-ascii file" 109 | 102 " [Read only]" 110 | 103 " %d/%d" 111 | 104 " %d line%s, %d character%s" 112 | 105 " (" 113 | 106 "%d null" 114 | 107 ", " 115 | 108 "%d non-ASCII" 116 | 109 "Write forms are 'w' and 'w>>'" 117 | 110 "No file|No current filename" 118 | $quote # 119 | 111 # File exists| File exists - use "w! %s" to overwrite# 120 | $quote " 121 | 112 " File is read only" 122 | 113 " File is read only" 123 | $quote # 124 | 114 # Use "w!" to write partial buffer# 125 | $quote " 126 | 115 " [New file]" 127 | 116 " [Existing file]" 128 | 117 " [Incomplete last line]" 129 | 118 " Line too long" 130 | 119 "Too many nested sources" 131 | 120 "Open and visual must be used interactively" 132 | 121 "Global within global@not allowed" 133 | 122 "Global needs re|Missing regular expression for global" 134 | 123 "Global command too long" 135 | 124 "substitution loop" 136 | 125 "Fail|Substitute pattern match failed" 137 | 126 "Substitute needs re|Missing regular expression for substitute" 138 | 127 "No previous re|No previous regular expression" 139 | 128 "No previous substitute re|No previous substitute to repeat" 140 | 129 "Replacement pattern too long@- limit 256 characters" 141 | 130 "Line overflow@in substitute" 142 | 131 "%d subs|%d substitutions" 143 | 132 " on %d lines" 144 | 133 "Regular expressions cannot be delimited by letters or digits" 145 | 134 "No previous scan re|No previous scanning regular expression" 146 | 135 "No previous substitute re|No previous substitute regular expression" 147 | 136 "Badly formed re|Regular expression \\ must be followed by / or ?" 148 | 137 "No previous re|No previous regular expression" 149 | 138 "Missing closing delimiter@for regular expression" 150 | 139 "Re too complex|Regular expression too complicated" 151 | 140 "Unmatched \\(|More \\('s than \\)'s in regular expression" 152 | 141 "Awash in \\('s!|Too many \\('d subexressions in a regular expression" 153 | 142 "Extra \\)|More \\)'s than \\('s in regular expression" 154 | 143 "Bad number|Bad number in regular expression" 155 | 144 "Range endpoint too large|Range endpoint too large in regular expression" 156 | 145 "More than 2 numbers given in \\{~\\}" 157 | 146 "} expected after \\" 158 | 147 "First number exceeds second in \\{~\\}" 159 | $quote 160 | 148 "\\digit" out of range 161 | $quote " 162 | 149 "Replacement pattern contains &@- cannot use in re" 163 | 150 "Replacement pattern contains \\d@- cannot use in re" 164 | 151 "Illegal *|Can't * a \\( ... \\) in regular expression") 165 | 152 "Illegal *|Can't * a \\n in regular expression" 166 | 153 "Bad character class|Empty character class '[]' or '[^]' cannot match" 167 | 154 "Missing ]" 168 | 155 "No newlines in re's|Can't escape newlines into regular expressions" 169 | 156 "Bad \\n|\\n in regular expression with n greater than the number of \\('s" 170 | 157 "Badly formed re|Missing closing delimiter for regular expression" 171 | 158 "Re internal error" 172 | 159 "%s: No such option@- 'set all' gives all option values" 173 | 160 "Option %s is not a toggle" 174 | 161 "Missing =@in assignment to option %s" 175 | 162 "Digits required@after =" 176 | 163 "String too long@in option assignment" 177 | 164 "Can't change type of terminal from within open/visual" 178 | 165 "%s%s" 179 | 166 "" 180 | 167 "no" 181 | 168 "%s=%d" 182 | 169 "%s=%s" 183 | 170 "%d lines" 184 | 171 " %c%s" 185 | 172 "Nonzero address required@on this command" 186 | 173 "No lines@in the buffer" 187 | 174 "more " 188 | 175 "fewer " 189 | 176 "" 190 | 177 "%d %slines@in file after %s" 191 | 178 "" 192 | 179 "s" 193 | 180 "Out of memory@saving lines for undo - try using ed" 194 | 181 "emt trap, _ovno is %d @ - try again" 195 | 182 "\nInterrupt" 196 | 183 " Tmp file too large" 197 | 184 " Tmp file too large" 198 | 185 " Tmp file too large" 199 | 186 "Out of register space (ugh)" 200 | 187 "Nothing in register %c" 201 | 188 "Can't put partial line inside macro" 202 | 189 "Nothing in register %c" 203 | 190 "Register too long@to fit in memory" 204 | 191 "%s: Unknown terminal type" 205 | 192 "Incomplete shell escape command@- use 'shell' to get a shell" 206 | 193 "Command too long" 207 | 194 "No previous command@to substitute for !" 208 | 195 "No alternate filename@to substitute for #" 209 | 196 "No filename@to substitute for %%" 210 | 197 "[No write]|[No write since last change]" 211 | 198 "No previous command@to repeat" 212 | 199 "Can't make pipe for filter" 213 | 200 "No more processes" 214 | 201 "No %s!\n" 215 | 202 "Can't make pipe" 216 | 203 "No more processes" 217 | 204 " Can't make pipe for recovery" 218 | 205 " Can't fork to execute recovery" 219 | 206 " No recovery routine" 220 | 207 "Fail|Pattern not found on addressed line" 221 | 208 "Can't use open/visual unless open option is set" 222 | 209 "Recursive open/visual not allowed" 223 | 210 "[Using open mode]" 224 | 211 "Visual needs addressible cursor or upline capability" 225 | 212 Can't use visual on a terminal which overstrikes" 226 | 213 "Visual requires clear screen capability" 227 | 214 "Visual requires scrolling" 228 | 215 "Screen too large for internal buffer" 229 | 216 "Don't know enough about your terminal to use %s" 230 | 217 "Terminal too wide" 231 | 218 "Screen too large" 232 | 219 "Internal error: vscroll" 233 | 220 "No lines in buffer" 234 | 221 "Internal error: vredraw" 235 | 222 "Input read error" 236 | 223 "%d %sline" 237 | 224 "Macro too long@ - maybe recursive?" 238 | 225 "Infinite macro loop" 239 | 226 "Q gets ex command mode, :q leaves vi" 240 | 227 " " 241 | 228 "AAPPEND MODE" 242 | 229 "CCHANGE MODE" 243 | 230 "OOPEN MODE" 244 | 231 "RREPLACE MODE" 245 | 232 "rREPLACE 1 CHAR" 246 | 233 "IINSERT MODE" 247 | 234 "Infinite macro loop" 248 | 235 "Line too long" 249 | 236 "Line too long" 250 | 237 "Internal error: vclreol" 251 | 238 "Internal error: vgoto" 252 | 239 "Line too long for open" 253 | 240 "Line too long" 254 | 241 "No memory pool" 255 | 242 "Memory pool exhausted" 256 | 243 "failed to memory map anonymous area" 257 | 244 "failed to open /dev/zero" 258 | 245 "failed to memory map /dev/zero" 259 | 246 "chunk of memory already in free list" 260 | 247 "out of memory" 261 | 248 "(null pointer)" 262 | 249 "y" 263 | $ exrecover 264 | $set 2 265 | 1 " Wrong number of arguments to exrecover" 266 | 2 " [Dated: %s" 267 | 3 ", newest of %d saved]" 268 | 4 "]" 269 | 5 " Not enough core for lines" 270 | 6 "No files saved.\n" 271 | 7 "On %s at " 272 | $quote # 273 | 8 # saved %d lines of file "%s"\n# 274 | $quote " 275 | 9 " File not found" 276 | 10 " [Lost line(s):" 277 | 11 " %d" 278 | 12 "-%d" 279 | 13 " [Lost line(s):" 280 | 14 " %d" 281 | 15 "-%d" 282 | 16 "]" 283 | 17 " Tmp file too large" 284 | $ expreserve 285 | $set 3 286 | 1 "NOT super user\n" 287 | 2 "the system went down" 288 | 3 "the editor was killed" 289 | 4 "Subject: editor saved ``LOST''\n" 290 | 5 "You were editing a file without a name\n" 291 | 6 "at <%s> on the machine ``%s'' when %s.\n" 292 | $quote # 293 | 7 #Since the file had no name, it has been named "LOST".\n# 294 | $quote " 295 | 8 "Subject: editor saved ``%s''\n" 296 | $quote # 297 | 9 #You were editing the file "%s"\n# 298 | $quote " 299 | 10 "at <%s> on the machine ``%s''\n" 300 | 11 "when %s.\n" 301 | 12 "\nYou can retrieve most of your changes to this file\n" 302 | $quote # 303 | 13 #using the "recover" command of the editor.\n# 304 | 14 #An easy way to do this is to give the command "vi -r %s".\n# 305 | 15 #This method also works using "ex" and "edit".\n# 306 | $quote " 307 | 16 "Buffer format error\t" 308 | 17 "Buffer read error" 309 | 18 "Can't find a name\t" 310 | -------------------------------------------------------------------------------- /doc/ex-vi/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | * 73 | * @(#)config.h 1.13 (gritter) 8/4/05 74 | */ 75 | 76 | /* 77 | * Configurable settings for the ex editor. 78 | */ 79 | 80 | /* 81 | * Various buffer sizes. 82 | */ 83 | #ifndef VMUNIX 84 | #define ESIZE 128 /* Regular expression buffer size */ 85 | #define RHSSIZE 256 /* Size of rhs of substitute */ 86 | #define TAGSIZE 128 /* Tag length */ 87 | #define ONMSZ 64 /* Option name size */ 88 | #else /* VMUNIX */ 89 | #define ESIZE 1024 90 | #define RHSSIZE 512 91 | #define TAGSIZE 256 92 | #define ONMSZ 256 93 | #endif /* VMUNIX */ 94 | 95 | /* 96 | * The following types are usually predefined on modern platforms; it 97 | * is only necessary to define them manually if compilation errors occur. 98 | */ 99 | 100 | /* 101 | * The intptr_t type was introduced by SUSv2 and C99. It is a signed 102 | * integer type capable of holding pointers: 103 | * 104 | * sizeof(intptr_t) == sizeof(void *). 105 | * 106 | * Type Environment Typical systems 107 | * int IP16 PDP11, 80286 108 | * int ILP32 Most VAX, M68k, IA32, SPARC 109 | * long LP32 Some IA32 and M68k 110 | * long LP64 64 bit mode of IA64, SPARC v9, and Alpha 111 | * 112 | * The argument to the sbrk() system call has this type. 113 | */ 114 | #ifdef notdef 115 | typedef int intptr_t; 116 | #endif 117 | 118 | /* 119 | * The ssize_t type should be the same as the return type of read() 120 | * and write(). 121 | */ 122 | #ifdef notdef 123 | typedef int ssize_t; 124 | #endif 125 | -------------------------------------------------------------------------------- /doc/ex-vi/ex.spec: -------------------------------------------------------------------------------- 1 | # 2 | # Sccsid @(#)ex.spec 1.8 (gritter) 7/12/05 3 | # 4 | Summary: A port of the traditional ex/vi editors 5 | Name: ex 6 | Version: 040420 7 | Release: 1 8 | License: BSD 9 | Source: %{name}-%{version}.tar.bz2 10 | Group: System Environment/Base 11 | Vendor: Gunnar Ritter 12 | URL: 13 | BuildRoot: %{_tmppath}/%{name}-root 14 | 15 | Requires: /etc/termcap 16 | 17 | # prefix applies to bindir, libexecdir, and mandir. 18 | %define prefix /usr 19 | %define bindir %{prefix}/5bin 20 | %define libexecdir %{prefix}/5lib 21 | %define mandir %{prefix}/share/man/5man 22 | 23 | %define preservedir /var/preserve 24 | 25 | # install command 26 | %define ucbinstall install 27 | 28 | %define cflags -Os -fomit-frame-pointer 29 | 30 | %define makeflags PREFIX=%{prefix} BINDIR=%{bindir} LIBEXECDIR=%{libexecdir} MANDIR=%{mandir} PRESERVEDIR=%{preservedir} INSTALL=%{ucbinstall} RPMCFLAGS="%{cflags}" 31 | 32 | %description 33 | This is a port of the traditional ex and vi editor implementation as 34 | found on 2BSD and 4BSD. It was enhanced to support most of the additions 35 | in System V and POSIX.2, and international character sets like UTF-8 and 36 | many East Asian encodings. 37 | 38 | %prep 39 | rm -rf %{buildroot} 40 | %setup 41 | 42 | %build 43 | make %{makeflags} 44 | 45 | %install 46 | make DESTDIR=%{buildroot} %{makeflags} install 47 | 48 | %clean 49 | cd ..; rm -rf %{_builddir}/%{name}-%{version} 50 | rm -rf %{buildroot} 51 | 52 | %files 53 | %defattr(-,root,root) 54 | %doc Changes LICENSE README TODO 55 | %{bindir}/* 56 | %{libexecdir}/* 57 | %{mandir}/man1/* 58 | %{preservedir} 59 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | */ 73 | 74 | #ifndef lint 75 | #ifdef DOSCCS 76 | static char sccsid[] = "@(#)ex_addr.c 1.11 (gritter) 8/4/05"; 77 | #endif 78 | #endif /* not lint */ 79 | 80 | /* from ex_addr.c 7.3 (Berkeley) 6/7/85 */ 81 | 82 | #include "ex.h" 83 | #include "ex_re.h" 84 | 85 | /* 86 | * Routines for address parsing and assignment and checking of address bounds 87 | * in command mode. The routine address is called from ex_cmds.c 88 | * to parse each component of a command (terminated by , ; or the beginning 89 | * of the command itself. It is also called by the scanning routine 90 | * in ex_voperate.c from within open/visual. 91 | * 92 | * Other routines here manipulate the externals addr1 and addr2. 93 | * These are the first and last lines for the current command. 94 | * 95 | * The variable bigmove remembers whether a non-local glitch of . was 96 | * involved in an address expression, so we can set the previous context 97 | * mark '' when such a motion occurs. 98 | */ 99 | 100 | static bool bigmove; 101 | 102 | /* 103 | * Set up addr1 and addr2 for commands whose default address is dot. 104 | */ 105 | void 106 | setdot(void) 107 | { 108 | 109 | setdot1(); 110 | if (bigmove) 111 | markDOT(); 112 | } 113 | 114 | /* 115 | * Call setdot1 to set up default addresses without ever 116 | * setting the previous context mark. 117 | */ 118 | void 119 | setdot1(void) 120 | { 121 | 122 | if (addr2 == 0) 123 | addr1 = addr2 = dot; 124 | if (addr1 > addr2) { 125 | notempty(); 126 | failed = 1; 127 | error(catgets(catd, 1, 6, 128 | "Addr1 > addr2|First address exceeds second")); 129 | } 130 | } 131 | 132 | /* 133 | * Ex allows you to say 134 | * delete 5 135 | * to delete 5 lines, etc. 136 | * Such nonsense is implemented by setcount. 137 | */ 138 | void 139 | setcount(void) 140 | { 141 | register int cnt; 142 | 143 | pastwh(); 144 | if (!isdigit(peekchar())) { 145 | setdot(); 146 | return; 147 | } 148 | addr1 = addr2; 149 | setdot(); 150 | cnt = getnum(); 151 | if (cnt <= 0) 152 | error(catgets(catd, 1, 7, "Bad count|Nonzero count required")); 153 | addr2 += cnt - 1; 154 | if (addr2 > dol) 155 | addr2 = dol; 156 | nonzero(); 157 | } 158 | 159 | /* 160 | * Parse a number out of the command input stream. 161 | */ 162 | int 163 | getnum(void) 164 | { 165 | register int cnt; 166 | 167 | for (cnt = 0; isdigit(peekcd());) 168 | cnt = cnt * 10 + getchar() - '0'; 169 | return (cnt); 170 | } 171 | 172 | /* 173 | * Set the default addresses for commands which use the whole 174 | * buffer as default, notably write. 175 | */ 176 | void 177 | setall(void) 178 | { 179 | 180 | if (addr2 == 0) { 181 | addr1 = one; 182 | addr2 = dol; 183 | if (dol == zero) { 184 | dot = zero; 185 | return; 186 | } 187 | } 188 | /* 189 | * Don't want to set previous context mark so use setdot1(). 190 | */ 191 | setdot1(); 192 | } 193 | 194 | /* 195 | * No address allowed on, e.g. the file command. 196 | */ 197 | void 198 | setnoaddr(void) 199 | { 200 | 201 | if (addr2 != 0) { 202 | failed = 1; 203 | error(catgets(catd, 1, 8, 204 | "No address allowed@on this command")); 205 | } 206 | } 207 | 208 | /* 209 | * Parse an address. 210 | * Just about any sequence of address characters is legal. 211 | * 212 | * If you are tricky you can use this routine and the = command 213 | * to do simple addition and subtraction of cardinals less 214 | * than the number of lines in the file. 215 | */ 216 | line * 217 | address(char *in_line) 218 | { 219 | register line *addr; 220 | register int offset, c; 221 | short lastsign; 222 | 223 | bigmove = 0; 224 | lastsign = 0; 225 | offset = 0; 226 | addr = 0; 227 | for (;;) { 228 | if (isdigit(peekcd())) { 229 | if (addr == 0) { 230 | addr = zero; 231 | bigmove = 1; 232 | } 233 | loc1 = 0; 234 | addr += offset; 235 | offset = getnum(); 236 | if (lastsign >= 0) 237 | addr += offset; 238 | else 239 | addr -= offset; 240 | lastsign = 0; 241 | offset = 0; 242 | } 243 | switch (c = getcd()) { 244 | 245 | case '?': 246 | case '/': 247 | case '$': 248 | case '\'': 249 | case '\\': 250 | bigmove++; 251 | case '.': 252 | if (addr || offset) 253 | error(catgets(catd, 1, 9, 254 | "Badly formed address")); 255 | } 256 | offset += lastsign; 257 | lastsign = 0; 258 | switch (c) { 259 | 260 | case ' ': 261 | case '\t': 262 | continue; 263 | 264 | case '+': 265 | lastsign = 1; 266 | if (addr == 0) 267 | addr = dot; 268 | continue; 269 | 270 | case '^': 271 | case '-': 272 | lastsign = -1; 273 | if (addr == 0) 274 | addr = dot; 275 | continue; 276 | 277 | case '\\': 278 | case '?': 279 | case '/': 280 | c = compile(c, 1); 281 | notempty(); 282 | savere(&scanre); 283 | addr = dot; 284 | if (in_line && execute(0, dot)) { 285 | if (c == '/') { 286 | while (loc1 <= in_line) { 287 | if (loc1 == loc2) 288 | loc2++; 289 | if (!execute(1, NULL)) 290 | goto nope; 291 | } 292 | break; 293 | } else if (loc1 < in_line) { 294 | char *last; 295 | doques: 296 | 297 | do { 298 | last = loc1; 299 | if (loc1 == loc2) 300 | loc2++; 301 | if (!execute(1, NULL)) 302 | break; 303 | } while (loc1 < in_line); 304 | loc1 = last; 305 | break; 306 | } 307 | } 308 | nope: 309 | for (;;) { 310 | if (c == '/') { 311 | addr++; 312 | if (addr > dol) { 313 | if (value(WRAPSCAN) == 0) 314 | error(catgets(catd, 1, 10, "No match to BOTTOM|Address search hit BOTTOM without matching pattern")); 315 | addr = zero; 316 | } 317 | } else { 318 | addr--; 319 | if (addr < zero) { 320 | if (value(WRAPSCAN) == 0) 321 | error(catgets(catd, 1, 11, "No match to TOP|Address search hit TOP without matching pattern")); 322 | addr = dol; 323 | } 324 | } 325 | if (execute(0, addr)) { 326 | if (in_line && c == '?') { 327 | in_line = &linebuf[LBSIZE]; 328 | goto doques; 329 | } 330 | break; 331 | } 332 | if (addr == dot) 333 | error(catgets(catd, 1, 12, 334 | "Fail|Pattern not found")); 335 | } 336 | continue; 337 | 338 | case '$': 339 | addr = dol; 340 | continue; 341 | 342 | case '.': 343 | addr = dot; 344 | continue; 345 | 346 | case '\'': 347 | c = markreg(getchar()); 348 | if (c == 0) 349 | error(catgets(catd, 1, 13, 350 | "Marks are ' and a-z")); 351 | addr = getmark(c); 352 | if (addr == 0) 353 | error(catgets(catd, 1, 14, 354 | "Undefined mark@referenced")); 355 | break; 356 | 357 | default: 358 | ungetchar(c); 359 | if (offset) { 360 | if (addr == 0) 361 | addr = dot; 362 | addr += offset; 363 | loc1 = 0; 364 | } 365 | if (addr == 0) { 366 | bigmove = 0; 367 | return (0); 368 | } 369 | if (addr != zero) 370 | notempty(); 371 | addr += lastsign; 372 | if (addr < zero) { 373 | failed = 1; 374 | error(catgets(catd, 1, 15, 375 | "Negative address@- first buffer line is 1")); 376 | } 377 | if (addr > dol) { 378 | failed = 1; 379 | error(catgets(catd, 1, 16, 380 | "Not that many lines@in buffer")); 381 | } 382 | return (addr); 383 | } 384 | } 385 | } 386 | 387 | /* 388 | * Abbreviations to make code smaller 389 | * Left over from squashing ex version 1.1 into 390 | * 11/34's and 11/40's. 391 | */ 392 | void 393 | setCNL(void) 394 | { 395 | 396 | setcount(); 397 | newline(); 398 | } 399 | 400 | void 401 | setNAEOL(void) 402 | { 403 | 404 | setnoaddr(); 405 | eol(); 406 | } 407 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_argv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | * 73 | * from ex_argv.h 7.3 (Berkeley) 5/31/85 74 | * 75 | * Sccsid @(#)ex_argv.h 1.9 (gritter) 8/4/05 76 | */ 77 | 78 | /* 79 | * The current implementation of the argument list is poor, 80 | * using an argv even for internally done "next" commands. 81 | * It is not hard to see that this is restrictive and a waste of 82 | * space. The statically allocated glob structure could be replaced 83 | * by a dynamically allocated argument area space. 84 | */ 85 | var char **argv; 86 | var char **argv0; 87 | var char *args; 88 | var char *args0; 89 | var short argc; 90 | var short argc0; 91 | var short morargc; /* Used with "More files to edit..." */ 92 | 93 | var int firstln; /* From +lineno */ 94 | var char *firstpat; /* From +/pat */ 95 | 96 | /* Yech... */ 97 | struct glob { 98 | short argc; /* Index of current file in argv */ 99 | short argc0; /* Number of arguments in argv */ 100 | char *argv[NARGS + 1]; /* WHAT A WASTE! */ 101 | char argspac[NCARGS + sizeof (int)]; 102 | }; 103 | var struct glob frob; 104 | 105 | extern void gglob(struct glob *); 106 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_data.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | */ 73 | 74 | #ifndef lint 75 | #ifdef DOSCCS 76 | static char sccsid[] = "@(#)ex_data.c 1.14 (gritter) 11/23/04"; 77 | #endif 78 | #endif 79 | 80 | /* from ex_data.c 7.5 (Berkeley) 8/29/85 */ 81 | 82 | #include "ex.h" 83 | #include "ex_tty.h" 84 | 85 | /* 86 | * Initialization of option values. 87 | * The option #defines in ex_vars.h are made 88 | * from this file by the script makeoptions. 89 | * 90 | * These initializations are done char by char instead of as strings 91 | * to confuse xstr so it will leave them alone. 92 | */ 93 | #ifdef notdef 94 | char direct[ONMSZ] = 95 | {'/', 't', 'm', 'p'}; 96 | #else 97 | char direct[ONMSZ] = 98 | {'/', 'v', 'a', 'r', '/', 't', 'm', 'p' }; 99 | #endif 100 | char paragraphs[ONMSZ] = { 101 | 'I', 'P', 'L', 'P', 'P', 'P', 'Q', 'P', /* -ms macros */ 102 | 'P', ' ', 'L', 'I', /* -mm macros */ 103 | 'p', 'p', 'l', 'p', 'i', 'p', /* -me macros */ 104 | 'b', 'p' /* bare nroff */ 105 | }; 106 | char sections[ONMSZ] = { 107 | 'N', 'H', 'S', 'H', /* -ms macros */ 108 | 'H', ' ', 'H', 'U', /* -mm macros */ 109 | 'n', 'h', 's', 'h' /* -me macros */ 110 | }; 111 | char shell[ONMSZ] = 112 | { '/', 'b', 'i', 'n', '/', 's', 'h' }; 113 | char tags[ONMSZ] = { 114 | 't', 'a', 'g', 's', ' ', 115 | '/', 'u', 's', 'r', '/', 'l', 'i', 'b', '/', 't', 'a', 'g', 's' 116 | }; 117 | char ttylongname[ONMSZ] = 118 | { 'd', 'u', 'm', 'b' }; 119 | 120 | short TCOLUMNS = 80; 121 | short TLINES = 24; 122 | 123 | struct option options[NOPTS + 1] = { 124 | { "autoindent", "ai", ONOFF, 0, 0, 0, }, 125 | { "autoprint", "ap", ONOFF, 1, 1, 0, }, 126 | { "autowrite", "aw", ONOFF, 0, 0, 0, }, 127 | { "beautify", "bf", ONOFF, 0, 0, 0, }, 128 | { "directory", "dir", STRING, 0, 0, direct, }, 129 | { "edcompatible","ed", ONOFF, 0, 0, 0, }, 130 | { "errorbells", "eb", ONOFF, 0, 0, 0, }, 131 | { "exrc", "ex", ONOFF, 0, 0, 0, }, 132 | { "flash", "fl", ONOFF, 1, 1, 0, }, 133 | { "hardtabs", "ht", NUMERIC, 8, 8, 0, }, 134 | { "ignorecase", "ic", ONOFF, 0, 0, 0, }, 135 | { "lisp", 0, ONOFF, 0, 0, 0, }, 136 | { "list", 0, ONOFF, 0, 0, 0, }, 137 | { "magic", 0, ONOFF, 1, 1, 0, }, 138 | { "mesg", 0, ONOFF, 1, 1, 0, }, 139 | { "modelines", "ml", ONOFF, 0, 0, 0, }, 140 | { "number", "nu", ONOFF, 0, 0, 0, }, 141 | { "open", 0, ONOFF, 1, 1, 0, }, 142 | { "optimize", "opt", ONOFF, 0, 0, 0, }, 143 | { "paragraphs", "para", STRING, 0, 0, paragraphs, }, 144 | { "prompt", 0, ONOFF, 1, 1, 0, }, 145 | { "readonly", "ro", ONOFF, 0, 0, 0, }, 146 | { "redraw", 0, ONOFF, 0, 0, 0, }, 147 | { "remap", 0, ONOFF, 1, 1, 0, }, 148 | { "report", 0, NUMERIC, 5, 5, 0, }, 149 | { "scroll", "scr", NUMERIC, 12, 12, 0, }, 150 | { "sections", "sect", STRING, 0, 0, sections, }, 151 | { "shell", "sh", STRING, 0, 0, shell, }, 152 | { "shiftwidth", "sw", NUMERIC, TABS, TABS, 0, }, 153 | { "showmatch", "sm", ONOFF, 0, 0, 0, }, 154 | { "showmode", "smd", ONOFF, 0, 0, 0, }, 155 | { "slowopen", "slow", ONOFF, 0, 0, 0, }, 156 | { "sourceany", 0, ONOFF, 0, 0, 0, }, 157 | { "tabstop", "ts", NUMERIC, TABS, TABS, 0, }, 158 | { "taglength", "tl", NUMERIC, 0, 0, 0, }, 159 | { "tags", "tag", STRING, 0, 0, tags, }, 160 | { "term", 0, OTERM, 0, 0, ttylongname, }, 161 | { "terse", 0, ONOFF, 0, 0, 0, }, 162 | { "timeout", "to", ONOFF, 1, 1, 0, }, 163 | { "ttytype", "tty", OTERM, 0, 0, ttylongname, }, 164 | { "warn", 0, ONOFF, 1, 1, 0, }, 165 | { "window", "wi", NUMERIC, 23, 23, 0, }, 166 | { "wrapscan", "ws", ONOFF, 1, 1, 0, }, 167 | { "wrapmargin", "wm", NUMERIC, 0, 0, 0, }, 168 | { "writeany", "wa", ONOFF, 0, 0, 0, }, 169 | { 0, 0, 0, 0, 0, 0, } 170 | }; 171 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_extern.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | */ 73 | 74 | #ifndef lint 75 | #ifdef DOSCCS 76 | static char sccsid[] = "@(#)ex_extern.c 1.6 (gritter) 11/23/04"; 77 | #endif 78 | #endif 79 | 80 | /* from ex_extern.c 7.4 (Berkeley) 6/7/85 */ 81 | 82 | /* 83 | * Provide defs of the global variables. 84 | * This crock is brought to you by the turkeys 85 | * who broke Unix on the Bell Labs 3B machine, 86 | * all in the name of "but that's what the C 87 | * book says!" 88 | */ 89 | 90 | # define var /* nothing */ 91 | # include "ex.h" 92 | # include "ex_argv.h" 93 | # include "ex_re.h" 94 | # include "ex_temp.h" 95 | # include "ex_tty.h" 96 | /* # include "ex_tune.h" */ 97 | # include "ex_vars.h" 98 | # include "ex_vis.h" 99 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_get.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | */ 73 | 74 | #ifndef lint 75 | #ifdef DOSCCS 76 | static char sccsid[] = "@(#)ex_get.c 1.18 (gritter) 8/4/05"; 77 | #endif 78 | #endif 79 | 80 | /* from ex_get.c 7.6 (Berkeley) 6/7/85 */ 81 | 82 | #include "ex.h" 83 | #include "ex_tty.h" 84 | 85 | /* 86 | * Input routines for command mode. 87 | * Since we translate the end of reads into the implied ^D's 88 | * we have different flavors of routines which do/don't return such. 89 | */ 90 | static bool junkbs; 91 | int lastc = '\n'; 92 | 93 | void 94 | ignchar(void) 95 | { 96 | ignore(getchar()); 97 | } 98 | 99 | int 100 | getach(void) 101 | { 102 | register int c; 103 | static char in_line[BUFSIZ]; 104 | /* struct stat statb; */ 105 | 106 | c = peekc; 107 | if (c != 0) { 108 | peekc = 0; 109 | return (c); 110 | } 111 | if (globp) { 112 | if (*globp) 113 | return (*globp++&0377); 114 | globp = 0; 115 | return (lastc = EOF); 116 | } 117 | top: 118 | if (input) { 119 | if (c = *input++&0377) { 120 | if (verbose && !intty) 121 | write(2, &input[-1], 1); 122 | if (c &= TRIM) 123 | return (lastc = c); 124 | goto top; 125 | } 126 | input = 0; 127 | } 128 | flush(); 129 | if (intty) { 130 | c = read(0, in_line, sizeof in_line - 4); 131 | if (c < 0) 132 | return (lastc = EOF); 133 | if (c == 0 || in_line[c-1] != '\n') 134 | in_line[c++] = CTRL('d'); 135 | if (in_line[c-1] == '\n') 136 | noteinp(); 137 | in_line[c] = 0; 138 | for (c--; c >= 0; c--) 139 | if (in_line[c] == 0) 140 | #ifndef BIT8 141 | in_line[c] = QUOTE; 142 | #else 143 | in_line[c] = '\200'; 144 | #endif 145 | input = in_line; 146 | goto top; 147 | } 148 | c = read(0, in_line, sizeof in_line - 1); 149 | if(c <= 0) 150 | return(lastc = EOF); 151 | in_line[c] = '\0'; 152 | input = in_line; 153 | goto top; 154 | } 155 | 156 | int 157 | getchar(void) 158 | { 159 | register int c; 160 | 161 | do 162 | c = getcd(); 163 | while (!globp && c == CTRL('d')); 164 | return (c); 165 | } 166 | 167 | void 168 | checkjunk(int c) 169 | { 170 | 171 | if (junkbs == 0 && c == '\b') { 172 | write(2, cntrlhm, 13); 173 | junkbs = 1; 174 | } 175 | } 176 | 177 | int 178 | getcd(void) 179 | { 180 | register int c; 181 | 182 | again: 183 | c = getach(); 184 | if (c == EOF) 185 | return (c); 186 | c &= TRIM; 187 | if (!inopen) 188 | if (!globp && c == CTRL('d')) 189 | setlastchar('\n'); 190 | else if (junk(c)) { 191 | checkjunk(c); 192 | goto again; 193 | } 194 | return (c); 195 | } 196 | 197 | int 198 | peekchar(void) 199 | { 200 | 201 | if (peekc == 0) 202 | peekc = getchar(); 203 | return (peekc); 204 | } 205 | 206 | int 207 | peekcd(void) 208 | { 209 | if (peekc == 0) 210 | peekc = getcd(); 211 | return (peekc); 212 | } 213 | 214 | /* 215 | * Crunch the indent. 216 | * Hard thing here is that in command mode some of the indent 217 | * is only implicit, so we must seed the column counter. 218 | * This should really be done differently so as to use the whitecnt routine 219 | * and also to hack indenting for LISP. 220 | */ 221 | int 222 | smunch(register int col, char *ocp) 223 | { 224 | register char *cp; 225 | 226 | cp = ocp; 227 | for (;;) 228 | switch (*cp++) { 229 | 230 | case ' ': 231 | col++; 232 | continue; 233 | 234 | case '\t': 235 | col += value(TABSTOP) - (col % value(TABSTOP)); 236 | continue; 237 | 238 | default: 239 | cp--; 240 | CP(ocp, cp); 241 | return (col); 242 | } 243 | } 244 | 245 | /* 246 | * Input routine for insert/append/change in command mode. 247 | * Most work here is in handling autoindent. 248 | */ 249 | static short lastin; 250 | 251 | int 252 | gettty(void) 253 | { 254 | register int c = 0; 255 | register char *cp = genbuf; 256 | char hadup = 0; 257 | int offset = Pline == numbline ? 8 : 0; 258 | int ch; 259 | 260 | if (intty && !inglobal) { 261 | if (offset) { 262 | holdcm = 1; 263 | printf(" %4d ", lineDOT() + 1); 264 | flush(); 265 | holdcm = 0; 266 | } 267 | if (value(AUTOINDENT) ^ aiflag) { 268 | holdcm = 1; 269 | #ifdef LISPCODE 270 | if (value(LISP)) 271 | lastin = lindent(dot + 1); 272 | #endif 273 | tab(lastin + offset); 274 | while ((c = getcd()) == CTRL('d')) { 275 | if (lastin == 0 && isatty(0) == -1) { 276 | holdcm = 0; 277 | return (EOF); 278 | } 279 | lastin = backtab(lastin); 280 | tab(lastin + offset); 281 | } 282 | switch (c) { 283 | 284 | case '^': 285 | case '0': 286 | ch = getcd(); 287 | if (ch == CTRL('d')) { 288 | if (c == '0') 289 | lastin = 0; 290 | if (!OS) { 291 | putchar('\b' | QUOTE); 292 | putchar(' ' | QUOTE); 293 | putchar('\b' | QUOTE); 294 | } 295 | tab(offset); 296 | hadup = 1; 297 | c = getchar(); 298 | } else 299 | ungetchar(ch); 300 | break; 301 | 302 | case '.': 303 | if (peekchar() == '\n') { 304 | ignchar(); 305 | noteinp(); 306 | holdcm = 0; 307 | return (EOF); 308 | } 309 | break; 310 | 311 | case '\n': 312 | hadup = 1; 313 | break; 314 | } 315 | } 316 | flush(); 317 | holdcm = 0; 318 | } 319 | if (c == 0) 320 | c = getchar(); 321 | while (c != EOF && c != '\n') { 322 | if (cp > &genbuf[LBSIZE - 2]) 323 | error(catgets(catd, 1, 71, "Input line too long")); 324 | *cp++ = c; 325 | c = getchar(); 326 | } 327 | if (c == EOF) { 328 | if (inglobal) 329 | ungetchar(EOF); 330 | return (EOF); 331 | } 332 | *cp = 0; 333 | cp = linebuf; 334 | if ((value(AUTOINDENT) ^ aiflag) && hadup == 0 && intty && !inglobal) { 335 | lastin = c = smunch(lastin, genbuf); 336 | for (c = lastin; c >= value(TABSTOP); c -= value(TABSTOP)) 337 | *cp++ = '\t'; 338 | for (; c > 0; c--) 339 | *cp++ = ' '; 340 | } 341 | CP(cp, genbuf); 342 | if (linebuf[0] == '.' && linebuf[1] == 0) 343 | return (EOF); 344 | return (0); 345 | } 346 | 347 | void 348 | setin(line *addr) 349 | { 350 | 351 | if (addr == zero) 352 | lastin = 0; 353 | else 354 | getline(*addr), lastin = smunch(0, linebuf); 355 | } 356 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_re.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | * 73 | * from ex_re.h 7.3 (Berkeley) 5/31/85 74 | * 75 | * Sccsid @(#)ex_re.h 1.24 (gritter) 8/4/05 76 | */ 77 | 78 | /* 79 | * Regular expression definitions. 80 | * The regular expressions in ex are similar to those in ed, 81 | * with the addition of the word boundaries from Toronto ed 82 | * and allowing character classes to have [a-b] as in the shell. 83 | * The numbers for the nodes below are spaced further apart then 84 | * necessary because I at one time partially put in + and | (one or 85 | * more and alternation.) 86 | */ 87 | struct regexp { 88 | char *Patbuf; 89 | long Re_ident; 90 | void *Expbuf; 91 | bool Circfl; 92 | short Nbra; 93 | int Flags; 94 | int Length; 95 | }; 96 | 97 | /* 98 | * There are three regular expressions here, the previous (in re), 99 | * the previous substitute (in subre) and the previous scanning (in scanre). 100 | * It would be possible to get rid of "re" by making it a stack parameter 101 | * to the appropriate routines. 102 | */ 103 | var struct regexp re; /* Last re */ 104 | var struct regexp scanre; /* Last scanning re */ 105 | var struct regexp subre; /* Last substitute re */ 106 | 107 | extern char *loc1; /* Where re began to match (in linebuf) */ 108 | extern char *loc2; /* First char after re match (") */ 109 | 110 | /* 111 | * Since the phototypesetter v7-epsilon 112 | * C compiler doesn't have structure assignment... 113 | */ 114 | extern struct regexp *savere(struct regexp *); 115 | extern struct regexp *resre(struct regexp *); 116 | 117 | /* 118 | * Definitions for substitute 119 | */ 120 | extern char *braslist[NBRA]; /* Starts of \(\)'ed text in lhs */ 121 | extern char *braelist[NBRA]; /* Ends... */ 122 | var char rhsbuf[RHSSIZE]; /* Rhs of last substitute */ 123 | #ifdef BIT8 124 | var char rhsquo[RHSSIZE]; /* Quote indicator for rhsbuf */ 125 | #endif 126 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_set.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | */ 73 | 74 | #ifndef lint 75 | #ifdef DOSCCS 76 | static char sccsid[] = "@(#)ex_set.c 1.11 (gritter) 11/24/04"; 77 | #endif 78 | #endif 79 | 80 | /* from ex_set.c 7.4 (Berkeley) 6/7/85 */ 81 | 82 | #include "ex.h" 83 | #include "ex_temp.h" 84 | #include "ex_tty.h" 85 | 86 | /* 87 | * Set command. 88 | */ 89 | char optname[ONMSZ]; 90 | 91 | void 92 | set(void) 93 | { 94 | register char *cp; 95 | register struct option *op; 96 | register int c; 97 | bool no; 98 | 99 | setnoaddr(); 100 | if (skipend()) { 101 | if (peekchar() != EOF) 102 | ignchar(); 103 | propts(); 104 | return; 105 | } 106 | do { 107 | cp = optname; 108 | do { 109 | if (cp < &optname[ONMSZ - 2]) 110 | *cp++ = getchar(); 111 | } while (isalnum(peekchar())); 112 | *cp = 0; 113 | cp = optname; 114 | if (eq("all", cp)) { 115 | if (inopen) 116 | pofix(); 117 | prall(); 118 | goto setnext; 119 | } 120 | no = 0; 121 | if (cp[0] == 'n' && cp[1] == 'o') { 122 | cp += 2; 123 | no++; 124 | } 125 | /* Implement w300, w1200, and w9600 specially */ 126 | if (eq(cp, "w300")) { 127 | if (ospeed >= B1200) { 128 | dontset: 129 | ignore(getchar()); /* = */ 130 | ignore(getnum()); /* value */ 131 | continue; 132 | } 133 | cp = "window"; 134 | } else if (eq(cp, "w1200")) { 135 | if (ospeed < B1200 || ospeed >= B2400) 136 | goto dontset; 137 | cp = "window"; 138 | } else if (eq(cp, "w9600")) { 139 | if (ospeed < B2400) 140 | goto dontset; 141 | cp = "window"; 142 | } 143 | for (op = options; op < &options[NOPTS]; op++) 144 | if (eq(op->oname, cp) || op->oabbrev && eq(op->oabbrev, cp)) 145 | break; 146 | if (op->oname == 0) 147 | serror(catgets(catd, 1, 159, 148 | "%s: No such option@- 'set all' gives all option values"), cp); 149 | c = skipwh(); 150 | if (peekchar() == '?') { 151 | ignchar(); 152 | printone: 153 | propt(op); 154 | noonl(); 155 | goto setnext; 156 | } 157 | if (op->otype == ONOFF) { 158 | op->ovalue = 1 - no; 159 | if (op == &options[PROMPT]) 160 | oprompt = 1 - no; 161 | goto setnext; 162 | } 163 | if (no) 164 | serror(catgets(catd, 1, 160, 165 | "Option %s is not a toggle"), op->oname); 166 | if (c != 0 || setend()) 167 | goto printone; 168 | if (getchar() != '=') 169 | serror(catgets(catd, 1, 161, 170 | "Missing =@in assignment to option %s"), op->oname); 171 | switch (op->otype) { 172 | 173 | case NUMERIC: 174 | if (!isdigit(peekchar())) 175 | error(catgets(catd, 1, 162, 176 | "Digits required@after =")); 177 | op->ovalue = getnum(); 178 | if (value(TABSTOP) <= 0) 179 | value(TABSTOP) = TABS; 180 | if (value(HARDTABS) <= 0) 181 | value(HARDTABS) = TABS; 182 | if (op == &options[WINDOW]) { 183 | if (value(WINDOW) >= TLINES) 184 | value(WINDOW) = TLINES-1; 185 | vsetsiz(value(WINDOW)); 186 | } 187 | break; 188 | 189 | case STRING: 190 | case OTERM: 191 | cp = optname; 192 | while (!setend()) { 193 | if (cp >= &optname[ONMSZ]) 194 | error(catgets(catd, 1, 163, 195 | "String too long@in option assignment")); 196 | /* adb change: allow whitepace in strings */ 197 | if( (*cp = getchar()) == '\\') 198 | if( peekchar() != EOF) 199 | *cp = getchar(); 200 | cp++; 201 | } 202 | *cp = 0; 203 | if (op->otype == OTERM) { 204 | /* 205 | * At first glance it seems like we shouldn't care if the terminal type 206 | * is changed inside visual mode, as long as we assume the screen is 207 | * a mess and redraw it. However, it's a much harder problem than that. 208 | * If you happen to change from 1 crt to another that both have the same 209 | * size screen, it's OK. But if the screen size if different, the stuff 210 | * that gets initialized in vop() will be wrong. This could be overcome 211 | * by redoing the initialization, e.g. making the first 90% of vop into 212 | * a subroutine. However, the most useful case is where you forgot to do 213 | * a setenv before you went into the editor and it thinks you're on a dumb 214 | * terminal. Ex treats this like hardcopy and goes into HARDOPEN mode. 215 | * This loses because the first part of vop calls oop in this case. 216 | * The problem is so hard I gave up. I'm not saying it can't be done, 217 | * but I am saying it probably isn't worth the effort. 218 | */ 219 | if (inopen) 220 | error(catgets(catd, 1, 164, 221 | "Can't change type of terminal from within open/visual")); 222 | setterm(optname); 223 | } else { 224 | CP(op->osvalue, optname); 225 | op->odefault = 1; 226 | } 227 | break; 228 | } 229 | setnext: 230 | flush(); 231 | } while (!skipend()); 232 | eol(); 233 | } 234 | 235 | int 236 | setend(void) 237 | { 238 | 239 | return (is_white(peekchar()) || endcmd(peekchar())); 240 | } 241 | 242 | void 243 | prall(void) 244 | { 245 | register int incr = (NOPTS + 2) / 3; 246 | register int rows = incr; 247 | register struct option *op = options; 248 | 249 | for (; rows; rows--, op++) { 250 | propt(op); 251 | tab(24); 252 | propt(&op[incr]); 253 | if (&op[2*incr] < &options[NOPTS]) { 254 | tab(56); 255 | propt(&op[2 * incr]); 256 | } 257 | putNFL(); 258 | } 259 | } 260 | 261 | void 262 | propts(void) 263 | { 264 | register struct option *op; 265 | 266 | for (op = options; op < &options[NOPTS]; op++) { 267 | if (op == &options[TTYTYPE]) 268 | continue; 269 | switch (op->otype) { 270 | 271 | case ONOFF: 272 | case NUMERIC: 273 | if (op->ovalue == op->odefault) 274 | continue; 275 | break; 276 | 277 | case STRING: 278 | if (op->odefault == 0) 279 | continue; 280 | break; 281 | } 282 | propt(op); 283 | putchar(' '); 284 | } 285 | noonl(); 286 | flush(); 287 | } 288 | 289 | void 290 | propt(register struct option *op) 291 | { 292 | register char *name; 293 | 294 | name = op->oname; 295 | 296 | switch (op->otype) { 297 | 298 | case ONOFF: 299 | printf(catgets(catd, 1, 165, "%s%s"), 300 | op->ovalue ? catgets(catd, 1, 166, "") 301 | : catgets(catd, 1, 167, "no"), name); 302 | break; 303 | 304 | case NUMERIC: 305 | printf(catgets(catd, 1, 168, "%s=%d"), name, op->ovalue); 306 | break; 307 | 308 | case STRING: 309 | case OTERM: 310 | printf(catgets(catd, 1, 169, "%s=%s"), name, op->osvalue); 311 | break; 312 | } 313 | } 314 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_tagio.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1985 Regents of the University of California */ 2 | 3 | /* 4 | * These routines are for faster tag lookup. They support the binary 5 | * search used in tagfind() instead of the linear search. The speedup 6 | * is quite noticable looking for a tag at the end of a long tags 7 | * file. Define FASTTAG in the Makefile to use these routines. 8 | * 9 | * This code contains changes by 10 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 11 | * 12 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 13 | * to these changes. 14 | * 15 | * 16 | * Copyright (c) 1980, 1993 17 | * The Regents of the University of California. All rights reserved. 18 | * 19 | * Redistribution and use in source and binary forms, with or without 20 | * modification, are permitted provided that the following conditions 21 | * are met: 22 | * 1. Redistributions of source code must retain the above copyright 23 | * notice, this list of conditions and the following disclaimer. 24 | * 2. Redistributions in binary form must reproduce the above copyright 25 | * notice, this list of conditions and the following disclaimer in the 26 | * documentation and/or other materials provided with the distribution. 27 | * 3. All advertising materials mentioning features or use of this software 28 | * must display the following acknowledgement: 29 | * This product includes software developed by the University of 30 | * California, Berkeley and its contributors. 31 | * 4. Neither the name of the University nor the names of its contributors 32 | * may be used to endorse or promote products derived from this software 33 | * without specific prior written permission. 34 | * 35 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 36 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 38 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 39 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 40 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 41 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 42 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 43 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 44 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 45 | * SUCH DAMAGE. 46 | * 47 | * 48 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 49 | * 50 | * Redistribution and use in source and binary forms, with or without 51 | * modification, are permitted provided that the following conditions 52 | * are met: 53 | * Redistributions of source code and documentation must retain the 54 | * above copyright notice, this list of conditions and the following 55 | * disclaimer. 56 | * Redistributions in binary form must reproduce the above copyright 57 | * notice, this list of conditions and the following disclaimer in the 58 | * documentation and/or other materials provided with the distribution. 59 | * All advertising materials mentioning features or use of this software 60 | * must display the following acknowledgement: 61 | * This product includes software developed or owned by Caldera 62 | * International, Inc. 63 | * Neither the name of Caldera International, Inc. nor the names of 64 | * other contributors may be used to endorse or promote products 65 | * derived from this software without specific prior written permission. 66 | * 67 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 68 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 69 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 70 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 71 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 72 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 73 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 74 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 75 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 76 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 77 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 78 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 79 | */ 80 | 81 | #ifdef FASTTAG 82 | #ifndef lint 83 | #ifdef DOSCCS 84 | static char sccsid[] = "@(#)ex_tagio.c 1.12 (gritter) 8/4/05"; 85 | #endif 86 | #endif 87 | 88 | /* from ex_tagio.c 7.3 (Berkeley) 1/31/86 */ 89 | 90 | #include "ex.h" 91 | 92 | static long offset = -1; 93 | static long block = -1; 94 | static int bcnt = 0; 95 | static int b_size; 96 | static char *ibuf; 97 | 98 | int 99 | topen(char *file, char *buf) 100 | { 101 | int fd; 102 | struct stat statb; 103 | 104 | b_size = MAXBSIZE; 105 | offset = -1; 106 | block = -1; 107 | if ((fd = open(file, O_RDONLY, 0)) < 0) 108 | return(-1); 109 | if (fstat(fd, &statb) < 0) { 110 | close(fd); 111 | return(-1); 112 | } 113 | ibuf = buf; 114 | if (statb.st_blksize <= MAXBSIZE) 115 | b_size = statb.st_blksize; 116 | return(fd); 117 | } 118 | 119 | int 120 | tseek(int fd, off_t off) 121 | { 122 | off_t nblock; 123 | 124 | nblock = off / b_size * b_size; 125 | offset = off % b_size; 126 | if (nblock == block) 127 | return(0); 128 | block = nblock; 129 | if (lseek(fd, (off_t) nblock, SEEK_SET) < 0) 130 | return(-1); 131 | if ((bcnt = read(fd, ibuf, b_size)) < 0) 132 | return(-1); 133 | return(0); 134 | } 135 | 136 | int 137 | tgets(register char *buf, int cnt, int fd) 138 | { 139 | register char *cp; 140 | register int cc; 141 | 142 | cc = offset; 143 | if (cc == -1) { 144 | if ((bcnt = read(fd, ibuf, b_size)) <= 0) 145 | return 0; 146 | cc = 0; 147 | block = 0; 148 | } 149 | if (bcnt == 0) /* EOF */ 150 | return 0; 151 | cp = ibuf + cc; 152 | while (--cnt > 0) { 153 | if (++cc > bcnt) { 154 | block += b_size; 155 | if ((bcnt = read(fd, ibuf, b_size)) <= 0) { 156 | offset = cc; 157 | return 0; 158 | } 159 | cp = ibuf; 160 | cc = 1; 161 | } 162 | if ((*buf++ = *cp++) == '\n') 163 | break; 164 | } 165 | *--buf = 0; 166 | offset = cc; 167 | return(1); 168 | } 169 | 170 | void 171 | tclose(int fd) 172 | { 173 | close(fd); 174 | offset = -1; 175 | block = -1; 176 | bcnt = 0; 177 | } 178 | #endif 179 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_temp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | * 73 | * from ex_temp.h 7.4 (Berkeley) 5/31/85 74 | * 75 | * Sccsid @(#)ex_temp.h 1.10 (gritter) 8/4/05 76 | */ 77 | 78 | /* 79 | * The editor uses a temporary file for files being edited, in a structure 80 | * similar to that of ed. The first block of the file is used for a header 81 | * block which guides recovery after editor/system crashes. 82 | * Lines are represented in core by a pointer into the temporary file which 83 | * is packed into 16 bits (32 on VMUNIX). All but the low bit index the temp 84 | * file; the last is used by global commands. The parameters below control 85 | * how much the other bits are shifted left before they index the temp file. 86 | * Larger shifts give more slop in the temp file but allow larger files 87 | * to be edited. 88 | * 89 | * The editor does not garbage collect the temporary file. When a new 90 | * file is edited, the temporary file is rather discarded and a new one 91 | * created for the new file. Garbage collection would be rather complicated 92 | * in ex because of the general undo, and in any case would require more 93 | * work when throwing lines away because marks would have be carefully 94 | * checked before reallocating temporary file space. Said another way, 95 | * each time you create a new line in the temporary file you get a unique 96 | * number back, and this is a property used by marks. 97 | * 98 | * The following temp file parameters allow 256k bytes in the temporary 99 | * file. By changing to the numbers in comments you can get 512k. 100 | * For VMUNIX you get more than you could ever want. 101 | * VMUNIX uses long (32 bit) integers giving much more 102 | * space in the temp file and no waste. This doubles core 103 | * requirements but allows files of essentially unlimited size to be edited. 104 | */ 105 | #ifndef VMUNIX 106 | #define BLKMSK 0777 /* 01777 */ 107 | #define BNDRY 8 /* 16 */ 108 | #define INCRMT 0200 /* 0100 */ 109 | #define LBTMSK 0770 /* 0760 */ 110 | #define NMBLKS 506 /* 1018 */ 111 | #define OFFBTS 7 /* 6 */ 112 | #define OFFMSK 0177 /* 077 */ 113 | #define SHFT 2 /* 3 */ 114 | #define TLNMSK 077776 115 | #else /* VMUNIX */ 116 | #ifdef LARGEF 117 | #define BLKMSK 017777777777 118 | #else 119 | #define BLKMSK 077777 120 | #endif 121 | #define BNDRY 2 122 | #define INCRMT 02000 123 | #define LBTMSK 01776 124 | #ifdef LARGEF 125 | #define NMBLKS 017777777770 126 | #else 127 | #define NMBLKS 077770 128 | #endif 129 | #define OFFBTS 10 130 | #define OFFMSK 01777 131 | #define SHFT 0 132 | #define TLNMSK 017777777776 133 | #endif /* VMUNIX */ 134 | 135 | /* 136 | * The editor uses three buffers into the temporary file (ed uses two 137 | * and is very similar). These are two read buffers and one write buffer. 138 | * Basically, the editor deals with the file as a sequence of BUFSIZ character 139 | * blocks. Each block contains some number of lines (and lines 140 | * can run across block boundaries. 141 | * 142 | * New lines are written into the last block in the temporary file 143 | * which is in core as obuf. When a line is needed which isn't in obuf, 144 | * then it is brought into an input buffer. As there are two, the choice 145 | * is to take the buffer into which the last read (of the two) didn't go. 146 | * Thus this is a 2 buffer LRU replacement strategy. Measurement 147 | * shows that this saves roughly 25% of the buffer reads over a one 148 | * input buffer strategy. Since the editor (on our VAX over 1 week) 149 | * spends (spent) roughly 30% of its time in the system read routine, 150 | * this can be a big help. 151 | */ 152 | var bool hitin2; /* Last read hit was ibuff2 not ibuff */ 153 | var bool ichang2; /* Have actually changed ibuff2 */ 154 | var bool ichanged; /* Have actually changed ibuff */ 155 | var bloc iblock; /* Temp file block number of ibuff (or -1) */ 156 | var bloc iblock2; /* Temp file block number of ibuff2 (or -1) */ 157 | var bloc ninbuf; /* Number useful chars left in input buffer */ 158 | var bloc nleft; /* Number usable chars left in output buffer */ 159 | var bloc oblock; /* Temp file block number of obuff (or -1) */ 160 | var bbloc tline; /* Current temp file ptr */ 161 | 162 | var char ibuff[BUFSIZ]; 163 | var char ibuff2[BUFSIZ]; 164 | var char obuff[BUFSIZ]; 165 | 166 | /* 167 | * Structure of the descriptor block which resides 168 | * in the first block of the temporary file and is 169 | * the guiding light for crash recovery. 170 | * 171 | * As the Blocks field below implies, there are temporary file blocks 172 | * devoted to (some) image of the incore array of pointers into the temp 173 | * file. Thus, to recover from a crash we use these indices to get the 174 | * line pointers back, and then use the line pointers to get the text back. 175 | * Except for possible lost lines due to sandbagged I/O, the entire 176 | * file (at the time of the last editor "sync") can be recovered from 177 | * the temp file. 178 | */ 179 | 180 | /* This definition also appears in expreserve.c... beware */ 181 | struct header { 182 | time_t Time; /* Time temp file last updated */ 183 | uid_t Uid; 184 | bbloc Flines; /* Number of lines in file */ 185 | char Savedfile[FNSIZE]; /* The current file name */ 186 | bloc Blocks[LBLKS]; /* Blocks where line pointers stashed */ 187 | }; 188 | var struct header H; 189 | 190 | #define uid H.Uid 191 | #define flines H.Flines 192 | #define savedfile H.Savedfile 193 | #define blocks H.Blocks 194 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_tune.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | * 73 | * from ex_tune.h 7.8.1 (2.11BSD) 1996/10/23 74 | * 75 | * Sccsid @(#)ex_tune.h 1.14 (gritter) 8/4/05 76 | */ 77 | 78 | /* 79 | * Note: the parameters that are actually tuneable have been moved to 80 | * config.h. Do not make changes here unless you know what you are 81 | * doing! GR 82 | */ 83 | 84 | /* 85 | * Definitions of editor parameters and limits 86 | */ 87 | 88 | /* 89 | * Pathnames (will be predefined in Makefile). 90 | */ 91 | #ifndef EXRECOVER 92 | #define EXRECOVER "/usr/sbin/exrecover" 93 | #endif 94 | #ifndef EXPRESERVE 95 | #define EXPRESERVE "/usr/sbin/expreserve" 96 | #endif 97 | #ifndef VMUNIX 98 | #ifndef EXSTRINGS 99 | #define EXSTRINGS "/usr/share/misc/exstrings" 100 | #endif 101 | #endif 102 | 103 | /* 104 | * If your system believes that tabs expand to a width other than 105 | * 8 then your makefile should cc with -DTABS=whatever, otherwise we use 8. 106 | */ 107 | #ifndef TABS 108 | #define TABS 8 109 | #endif 110 | 111 | /* 112 | * Maximums 113 | * 114 | * Most definitions are quite generous. 115 | */ 116 | /* FNSIZE is also defined in expreserve.c */ 117 | #ifdef _POSIX_PATH_MAX 118 | #define FNSIZE _POSIX_PATH_MAX 119 | #else 120 | #define FNSIZE 128 /* File name size */ 121 | #endif 122 | #ifdef VMUNIX 123 | #ifndef ESIZE /* see config.h */ 124 | #define ESIZE 512 /* Regular expression buffer size */ 125 | #endif 126 | #define CRSIZE BUFSIZ /* Crypt buffer size */ 127 | #else /* !VMUNIX */ 128 | #ifdef u370 129 | #ifndef ESIZE /* see config.h */ 130 | #define ESIZE 512 131 | #endif 132 | #define CRSIZE 4096 133 | #else 134 | #ifndef ESIZE /* see config.h */ 135 | #define ESIZE 128 /* Size of compiled re */ 136 | #endif 137 | #define CRSIZE 512 138 | #endif 139 | #endif 140 | #define NBRA 9 /* Number of re \( \) pairs */ 141 | #define GBSIZE 256 /* Buffer size */ 142 | #define UXBSIZE 128 /* Unix command buffer size */ 143 | #define VBSIZE 128 /* Partial line max size in visual */ 144 | /* LBLKS is also defined in expreserve.c */ 145 | #ifndef VMUNIX 146 | #define LBLKS 125 /* Line pointer blocks in temp file */ 147 | #define HBLKS 1 /* struct header fits in BUFSIZ*HBLKS */ 148 | #else /* VMUNIX */ 149 | #ifdef LARGEF 150 | #define LBLKS 20000 151 | #else /* !LARGEF */ 152 | #define LBLKS 900 153 | #endif /* !LARGEF */ 154 | #define HBLKS (1 + (FNSIZE + LBLKS * sizeof(bloc)) / BUFSIZ) 155 | #endif /* VMUNIX */ 156 | #define MAXDIRT 12 /* Max dirtcnt before sync tfile */ 157 | 158 | /* 159 | * Size of in-core buffers for temporary file. Since this is 160 | * sizeof (char) * (INCORB + 1) * BUFSIZ, it should not be too 161 | * large. 162 | * 163 | * If not defined, no in-core buffers are used. 164 | */ 165 | #ifdef VMUNIX 166 | #if (BUFSIZ - 0) <= 16384 167 | #define INCORB (65536/BUFSIZ) 168 | #else /* Huge-memory systems. */ 169 | #define INCORB 4 170 | #endif /* Huge-memory systems. */ 171 | #endif /* VMUNIX */ 172 | 173 | /* 174 | * Except on VMUNIX, these are a ridiculously small due to the 175 | * lousy arglist processing implementation which fixes core 176 | * proportional to them. Argv (and hence NARGS) is really unnecessary, 177 | * and argument character space not needed except when 178 | * arguments exist. Argument lists should be saved before the "zero" 179 | * of the incore line information and could then 180 | * be reasonably large. 181 | */ 182 | #undef NCARGS 183 | #ifndef VMUNIX 184 | #define NARGS 100 /* Maximum number of names in "next" */ 185 | #define NCARGS 512 /* Maximum arglist chars in "next" */ 186 | #else 187 | #define NCARGS 5120 188 | #define NARGS (NCARGS/6) 189 | #endif 190 | 191 | /* 192 | * Output column (and line) are set to this value on cursor addressible 193 | * terminals when we lose track of the cursor to force cursor 194 | * addressing to occur. 195 | */ 196 | #define UKCOL -20 /* Prototype unknown column */ 197 | 198 | /* 199 | * Attention is the interrupt character (normally 0177 -- delete). 200 | * Quit is the quit signal (normally FS -- control-\) and quits open/visual. 201 | */ 202 | extern int ATTN; 203 | #define QUIT ('\\' & 037) 204 | 205 | #define LRGINT INT_MAX /* largest normal length positive integer */ 206 | 207 | #ifdef LONG_BIT 208 | #if (LONG_BIT > 32) 209 | #define MAXOCT 22 /* Maximum octal digits in a long */ 210 | #define BIG 10000000000000000000UL /* largest power of 10 < uns. long */ 211 | #define MAXDIGS 20 /* number of digits in BIG */ 212 | #else /* LONG_BIT <= 32 */ 213 | #define MAXOCT 11 /* Maximum octal digits in a long */ 214 | #define BIG 1000000000UL /* largest power of 10 < unsigned long */ 215 | #define MAXDIGS 10 /* number of digits in BIG */ 216 | #endif /* LONG_BIT <= 32 */ 217 | #else /* !LONG_BIT */ 218 | #define MAXOCT 11 /* Maximum octal digits in a long */ 219 | #define BIG 1000000000 /* largest power of 10 < unsigned long */ 220 | #define MAXDIGS 10 /* number of digits in BIG */ 221 | #endif /* !LONG_BIT */ 222 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_vars.h: -------------------------------------------------------------------------------- 1 | /* sccs id @(#)ex_vars.h makeoptions 1.8 (gritter) 7/1/02 */ 2 | #define AUTOINDENT 0 3 | #define AUTOPRINT 1 4 | #define AUTOWRITE 2 5 | #define BEAUTIFY 3 6 | #define DIRECTORY 4 7 | #define EDCOMPATIBLE 5 8 | #define ERRORBELLS 6 9 | #define EXRC 7 10 | #define FLASH 8 11 | #define HARDTABS 9 12 | #define IGNORECASE 10 13 | #define LISP 11 14 | #define LIST 12 15 | #define MAGIC 13 16 | #define MESG 14 17 | #define MODELINES 15 18 | #define NUMBER 16 19 | #define OPEN 17 20 | #define OPTIMIZE 18 21 | #define PARAGRAPHS 19 22 | #define PROMPT 20 23 | #define READONLY 21 24 | #define REDRAW 22 25 | #define REMAP 23 26 | #define REPORT 24 27 | #define SCROLL 25 28 | #define SECTIONS 26 29 | #define SHELL 27 30 | #define SHIFTWIDTH 28 31 | #define SHOWMATCH 29 32 | #define SHOWMODE 30 33 | #define SLOWOPEN 31 34 | #define SOURCEANY 32 35 | #define TABSTOP 33 36 | #define TAGLENGTH 34 37 | #define TAGS 35 38 | #define TERM 36 39 | #define TERSE 37 40 | #define TIMEOUT 38 41 | #define TTYTYPE 39 42 | #define WARN 40 43 | #define WINDOW 41 44 | #define WRAPSCAN 42 45 | #define WRAPMARGIN 43 46 | #define WRITEANY 44 47 | 48 | #define NOPTS 45 49 | -------------------------------------------------------------------------------- /doc/ex-vi/ex_version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 42 | * 43 | * Redistribution and use in source and binary forms, with or without 44 | * modification, are permitted provided that the following conditions 45 | * are met: 46 | * Redistributions of source code and documentation must retain the 47 | * above copyright notice, this list of conditions and the following 48 | * disclaimer. 49 | * Redistributions in binary form must reproduce the above copyright 50 | * notice, this list of conditions and the following disclaimer in the 51 | * documentation and/or other materials provided with the distribution. 52 | * All advertising materials mentioning features or use of this software 53 | * must display the following acknowledgement: 54 | * This product includes software developed or owned by Caldera 55 | * International, Inc. 56 | * Neither the name of Caldera International, Inc. nor the names of 57 | * other contributors may be used to endorse or promote products 58 | * derived from this software without specific prior written permission. 59 | * 60 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 61 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 62 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 64 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 65 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 66 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 67 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 68 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 69 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 70 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 71 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 72 | * 73 | * Sccsid @(#)ex_version.c 1.146 (gritter) 12/25/06 74 | */ 75 | 76 | #include "ex.h" 77 | 78 | static char *versionstring = "@(#)Version 4.0 (gritter) 12/25/06"; 79 | 80 | void 81 | printver(void) 82 | { 83 | printf("%s%s%s", versionstring + 4, 84 | #ifdef BIT8 85 | "", "" 86 | #else 87 | ",", "@(#) 7bit" + 4 88 | #endif 89 | ); 90 | } 91 | /* SLIST */ 92 | /* 93 | ex.c:static char sccsid[] = "@(#)ex.c 1.37 (gritter) 8/4/05"; 94 | ex.h: * Sccsid @(#)ex.h 1.57 (gritter) 8/6/05 95 | ex_addr.c:static char sccsid[] = "@(#)ex_addr.c 1.11 (gritter) 8/4/05"; 96 | ex_argv.h: * Sccsid @(#)ex_argv.h 1.9 (gritter) 8/4/05 97 | ex_cmds.c:static char sccsid[] = "@(#)ex_cmds.c 1.22 (gritter) 2/18/05"; 98 | ex_cmds2.c:static char sccsid[] = "@(#)ex_cmds2.c 1.18 (gritter) 2/17/05"; 99 | ex_cmdsub.c:static char sccsid[] = "@(#)ex_cmdsub.c 1.32 (gritter) 8/6/05"; 100 | ex_data.c:static char sccsid[] = "@(#)ex_data.c 1.14 (gritter) 11/23/04"; 101 | ex_extern.c:static char sccsid[] = "@(#)ex_extern.c 1.6 (gritter) 11/23/04"; 102 | ex_get.c:static char sccsid[] = "@(#)ex_get.c 1.18 (gritter) 8/4/05"; 103 | ex_io.c:static char sccsid[] = "@(#)ex_io.c 1.42 (gritter) 8/4/05"; 104 | ex_proto.h: * Sccsid @(#)ex_proto.h 1.33 (gritter) 8/6/05 105 | ex_put.c:static char sccsid[] = "@(#)ex_put.c 1.35 (gritter) 12/25/06"; 106 | ex_re.c:static char sccsid[] = "@(#)ex_re.c 1.60 (gritter) 8/6/05"; 107 | ex_re.h: * Sccsid @(#)ex_re.h 1.24 (gritter) 8/4/05 108 | ex_set.c:static char sccsid[] = "@(#)ex_set.c 1.11 (gritter) 11/24/04"; 109 | ex_subr.c:static char sccsid[] = "@(#)ex_subr.c 1.41 (gritter) 12/25/06"; 110 | ex_tagio.c:static char sccsid[] = "@(#)ex_tagio.c 1.12 (gritter) 8/4/05"; 111 | ex_temp.c:static char sccsid[] = "@(#)ex_temp.c 1.27 (gritter) 12/25/06"; 112 | ex_temp.h: * Sccsid @(#)ex_temp.h 1.10 (gritter) 8/4/05 113 | ex_tty.c:static char sccsid[] = "@(#)ex_tty.c 1.30 (gritter) 8/4/05"; 114 | ex_tty.h: * Sccsid @(#)ex_tty.h 1.14 (gritter) 8/4/05 115 | ex_tune.h: * Sccsid @(#)ex_tune.h 1.14 (gritter) 8/4/05 116 | ex_unix.c:static char sccsid[] = "@(#)ex_unix.c 1.17 (gritter) 8/4/05"; 117 | ex_v.c:static char sccsid[] = "@(#)ex_v.c 1.19 (gritter) 8/4/05"; 118 | ex_vadj.c:static char sccsid[] = "@(#)ex_vadj.c 1.16 (gritter) 8/6/05"; 119 | ex_vget.c:static char sccsid[] = "@(#)ex_vget.c 1.31 (gritter) 8/6/05"; 120 | ex_vis.h: * Sccsid @(#)ex_vis.h 1.22 (gritter) 8/6/05 121 | ex_vmain.c:static char sccsid[] = "@(#)ex_vmain.c 1.34 (gritter) 8/6/05"; 122 | ex_voper.c:static char sccsid[] = "@(#)ex_voper.c 1.28 (gritter) 8/6/05"; 123 | ex_vops.c:static char sccsid[] = "@(#)ex_vops.c 1.28 (gritter) 8/4/05"; 124 | ex_vops2.c:static char sccsid[] = "@(#)ex_vops2.c 1.36 (gritter) 12/25/06"; 125 | ex_vops3.c:static char sccsid[] = "@(#)ex_vops3.c 1.21 (gritter) 8/4/05"; 126 | ex_vput.c:static char sccsid[] = "@(#)ex_vput.c 1.52 (gritter) 12/25/06"; 127 | ex_vwind.c:static char sccsid[] = "@(#)ex_vwind.c 1.9 (gritter) 11/23/04"; 128 | expreserve.c:static char sccsid[] UNUSED = "@(#)expreserve.c 1.23 (gritter) 11/27/04"; 129 | exrecover.c:static char sccsid[] UNUSED = "@(#)exrecover.c 1.23 (gritter) 12/25/06"; 130 | mapmalloc.c: * Sccsid @(#)mapmalloc.c 1.7 (gritter) 8/18/05 131 | printf.c:static char sccsid[] = "@(#)printf.c 1.15 (gritter) 12/1/04"; 132 | */ 133 | -------------------------------------------------------------------------------- /doc/ex-vi/libterm/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Makefile/1.1.1.1/Sat Dec 4 13:17:18 2004// 2 | /libterm.h/1.1.1.1/Sat Dec 4 13:17:18 2004// 3 | /termcap.c/1.1.1.1/Sat Dec 4 13:17:18 2004// 4 | /tgoto.c/1.1.1.1/Sat Dec 4 13:17:18 2004// 5 | /tputs.c/1.1.1.1/Sat Dec 4 13:17:18 2004// 6 | D 7 | -------------------------------------------------------------------------------- /doc/ex-vi/libterm/CVS/Repository: -------------------------------------------------------------------------------- 1 | ex-vi/libterm 2 | -------------------------------------------------------------------------------- /doc/ex-vi/libterm/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:anonymous@ex-vi.cvs.sourceforge.net:/cvsroot/ex-vi 2 | -------------------------------------------------------------------------------- /doc/ex-vi/libterm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This code contains changes by 3 | # Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | # 5 | # Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | # to these changes. 7 | # 8 | # 9 | # Copyright (c) 1980, 1993 10 | # The Regents of the University of California. All rights reserved. 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 1. Redistributions of source code must retain the above copyright 16 | # notice, this list of conditions and the following disclaimer. 17 | # 2. Redistributions in binary form must reproduce the above copyright 18 | # notice, this list of conditions and the following disclaimer in the 19 | # documentation and/or other materials provided with the distribution. 20 | # 3. All advertising materials mentioning features or use of this software 21 | # must display the following acknowledgement: 22 | # This product includes software developed by the University of 23 | # California, Berkeley and its contributors. 24 | # 4. Neither the name of the University nor the names of its contributors 25 | # may be used to endorse or promote products derived from this software 26 | # without specific prior written permission. 27 | # 28 | # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | # SUCH DAMAGE. 39 | # 40 | # from Makefile 5.1 (Berkeley) 6/5/85 41 | # 42 | # Sccsid @(#)Makefile 1.2 (gritter) 2/4/02 43 | # 44 | DEFS = -DCM_N -DCM_GT -DCM_B -DCM_D 45 | # COPT comes from ex. 46 | CFLAGS = $(DEFS) $(COPT) 47 | SRCS = termcap.c tgoto.c tputs.c 48 | OBJS = termcap.o tgoto.o tputs.o 49 | 50 | .c.o: ; $(CC) $(CFLAGS) -c $< 51 | 52 | all: libtermlib.a 53 | 54 | libtermlib.a: $(OBJS) 55 | ar cr libtermlib.a $(OBJS) 56 | 57 | clean: 58 | rm -f libtermlib.a $(OBJS) core 59 | 60 | # DO NOT DELETE 61 | 62 | termcap.o: libterm.h 63 | tgoto.o: libterm.h 64 | tputs.o: libterm.h 65 | -------------------------------------------------------------------------------- /doc/ex-vi/libterm/libterm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * 41 | * Header for termcap routines derived from 2.11 BSD. 42 | * 43 | * Sccsid @(#)libterm.h 1.4 (gritter) 11/23/04 44 | */ 45 | 46 | /* 47 | * Size of the capability buffer string. 48 | */ 49 | #define TCBUFSIZE 2048 50 | 51 | int tgetent(char *, const char *); 52 | int tgetnum(char *); 53 | int tgetflag(char *); 54 | char *tgetstr(char *, char **); 55 | char *tgoto(char *, int, int); 56 | int tputs(const char *, int, int (*)(int)); 57 | -------------------------------------------------------------------------------- /doc/ex-vi/libterm/termcap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | */ 40 | 41 | #ifndef lint 42 | #ifdef DOSCCS 43 | static char *sccsid = "@(#)termcap.c 1.7 (gritter) 11/23/04"; 44 | #endif 45 | #endif 46 | 47 | /* from termcap.c 5.1 (Berkeley) 6/5/85 */ 48 | 49 | #if 0 /* GR */ 50 | #define TCBUFSIZE 1024 51 | #else 52 | #include "libterm.h" 53 | #endif 54 | #define E_TERMCAP "/etc/termcap" 55 | #define MAXHOP 32 /* max number of tc= indirections */ 56 | 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | 65 | /* 66 | * termcap - routines for dealing with the terminal capability data base 67 | * 68 | * BUG: Should use a "last" pointer in tbuf, so that searching 69 | * for capabilities alphabetically would not be a n**2/2 70 | * process when large numbers of capabilities are given. 71 | * Note: If we add a last pointer now we will screw up the 72 | * tc capability. We really should compile termcap. 73 | * 74 | * Essentially all the work here is scanning and decoding escapes 75 | * in string capabilities. We don't use stdio because the editor 76 | * doesn't, and because living w/o it is not hard. 77 | */ 78 | 79 | static char *tbuf; 80 | static int hopcount; /* detect infinite loops in termcap, init 0 */ 81 | 82 | static int tnamatch(const char *); 83 | static int tnchktc(void); 84 | static char *tskip(register const char *); 85 | static char *tdecode(register char *, char **); 86 | 87 | /* 88 | * Tnamatch deals with name matching. The first field of the termcap 89 | * entry is a sequence of names separated by |'s, so we compare 90 | * against each such name. The normal : terminator after the last 91 | * name (before the first field) stops us. 92 | */ 93 | static int 94 | tnamatch(const char *np) 95 | { 96 | register const char *Np; 97 | register char *Bp; 98 | 99 | Bp = tbuf; 100 | if (*Bp == '#') 101 | return(0); 102 | for (;;) { 103 | for (Np = np; *Np && *Bp == *Np; Bp++, Np++) 104 | continue; 105 | if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0)) 106 | return (1); 107 | while (*Bp && *Bp != ':' && *Bp != '|') 108 | Bp++; 109 | if (*Bp == 0 || *Bp == ':') 110 | return (0); 111 | Bp++; 112 | } 113 | } 114 | 115 | /* 116 | * tnchktc: check the last entry, see if it's tc=xxx. If so, 117 | * recursively find xxx and append that entry (minus the names) 118 | * to take the place of the tc=xxx entry. This allows termcap 119 | * entries to say "like an HP2621 but doesn't turn on the labels". 120 | * Note that this works because of the left to right scan. 121 | */ 122 | static int 123 | tnchktc(void) 124 | { 125 | register char *p, *q; 126 | char tcname[16]; /* name of similar terminal */ 127 | char tcbuf[TCBUFSIZE]; 128 | char rmbuf[TCBUFSIZE]; 129 | char *holdtbuf = tbuf, *holdtc; 130 | int l; 131 | 132 | p = tbuf; 133 | while (*p) { 134 | holdtc = p = tskip(p); 135 | if (!*p) 136 | break; 137 | if (*p++ != 't' || *p == 0 || *p++ != 'c') 138 | continue; 139 | if (*p++ != '=') { 140 | bad: write(2, "Bad termcap entry\n", 18); 141 | return (0); 142 | } 143 | for (q = tcname; *p && *p != ':'; p++) { 144 | if (q >= &tcname[sizeof tcname - 1]) 145 | goto bad; 146 | *q++ = *p; 147 | } 148 | *q = '\0'; 149 | if (++hopcount > MAXHOP) { 150 | write(2, "Infinite tc= loop\n", 18); 151 | return (0); 152 | } 153 | if (tgetent(tcbuf, tcname) != 1) { 154 | hopcount = 0; /* unwind recursion */ 155 | return(0); 156 | } 157 | hopcount--; 158 | tbuf = holdtbuf; 159 | strcpy(rmbuf, &p[1]); 160 | for (q=tcbuf; *q != ':'; q++) 161 | ; 162 | l = holdtc - holdtbuf + strlen(rmbuf) + strlen(q); 163 | if (l > TCBUFSIZE) { 164 | write(2, "Termcap entry too long\n", 23); 165 | break; 166 | } 167 | q++; 168 | for (p = holdtc; *q; q++) 169 | *p++ = *q; 170 | strcpy(p, rmbuf); 171 | p = holdtc; 172 | } 173 | return(1); 174 | } 175 | 176 | /* 177 | * Get an entry for terminal name in buffer bp, 178 | * from the termcap file. Parse is very rudimentary; 179 | * we just notice escaped newlines. 180 | */ 181 | int 182 | tgetent(char *bp, const char *name) 183 | { 184 | register char *cp; 185 | register int c; 186 | register int i = 0, cnt = 0; 187 | char ibuf[TCBUFSIZE]; 188 | int tf; 189 | 190 | tbuf = bp; 191 | tf = -1; 192 | #ifndef V6 193 | cp = getenv("TERMCAP"); 194 | /* 195 | * TERMCAP can have one of two things in it. It can be the 196 | * name of a file to use instead of /etc/termcap. In this 197 | * case it better start with a "/". Or it can be an entry to 198 | * use so we don't have to read the file. In this case it 199 | * has to already have the newlines crunched out. 200 | */ 201 | if (cp && *cp) { 202 | if (*cp == '/') { 203 | tf = open(cp, 0); 204 | } else { 205 | tbuf = cp; 206 | c = tnamatch(name); 207 | tbuf = bp; 208 | if (c) { 209 | strcpy(bp,cp); 210 | return(tnchktc()); 211 | } 212 | } 213 | } 214 | if (tf < 0) 215 | tf = open(E_TERMCAP, 0); 216 | #else 217 | tf = open(E_TERMCAP, 0); 218 | #endif 219 | if (tf < 0) 220 | return (-1); 221 | for (;;) { 222 | cp = bp; 223 | for (;;) { 224 | if (i == cnt) { 225 | cnt = read(tf, ibuf, TCBUFSIZE); 226 | if (cnt <= 0) { 227 | close(tf); 228 | return (0); 229 | } 230 | i = 0; 231 | } 232 | c = ibuf[i++]; 233 | if (c == '\n') { 234 | if (cp > bp && cp[-1] == '\\'){ 235 | cp--; 236 | continue; 237 | } 238 | break; 239 | } 240 | if (cp >= bp+TCBUFSIZE) { 241 | write(2,"Termcap entry too long\n", 23); 242 | break; 243 | } else 244 | *cp++ = c; 245 | } 246 | *cp = 0; 247 | 248 | /* 249 | * The real work for the match. 250 | */ 251 | if (tnamatch(name)) { 252 | close(tf); 253 | return(tnchktc()); 254 | } 255 | } 256 | } 257 | 258 | /* 259 | * Skip to the next field. Notice that this is very dumb, not 260 | * knowing about \: escapes or any such. If necessary, :'s can be put 261 | * into the termcap file in octal. 262 | */ 263 | static char * 264 | tskip(register const char *bp) 265 | { 266 | 267 | while (*bp && *bp != ':') 268 | bp++; 269 | if (*bp == ':') 270 | bp++; 271 | return (char *)bp; 272 | } 273 | 274 | /* 275 | * Return the (numeric) option id. 276 | * Numeric options look like 277 | * li#80 278 | * i.e. the option string is separated from the numeric value by 279 | * a # character. If the option is not found we return -1. 280 | * Note that we handle octal numbers beginning with 0. 281 | */ 282 | int 283 | tgetnum(char *id) 284 | { 285 | register int i, base; 286 | register char *bp = tbuf; 287 | 288 | for (;;) { 289 | bp = tskip(bp); 290 | if (*bp == 0) 291 | return (-1); 292 | if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) 293 | continue; 294 | if (*bp == '@') 295 | return(-1); 296 | if (*bp != '#') 297 | continue; 298 | bp++; 299 | base = 10; 300 | if (*bp == '0') 301 | base = 8; 302 | i = 0; 303 | while (isdigit((*bp & 0377))) 304 | i *= base, i += *bp++ - '0'; 305 | return (i); 306 | } 307 | } 308 | 309 | /* 310 | * Handle a flag option. 311 | * Flag options are given "naked", i.e. followed by a : or the end 312 | * of the buffer. Return 1 if we find the option, or 0 if it is 313 | * not given. 314 | */ 315 | int 316 | tgetflag(char *id) 317 | { 318 | register char *bp = tbuf; 319 | 320 | for (;;) { 321 | bp = tskip(bp); 322 | if (!*bp) 323 | return (0); 324 | if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) { 325 | if (!*bp || *bp == ':') 326 | return (1); 327 | else if (*bp == '@') 328 | return(0); 329 | } 330 | } 331 | } 332 | 333 | /* 334 | * Get a string valued option. 335 | * These are given as 336 | * cl=^Z 337 | * Much decoding is done on the strings, and the strings are 338 | * placed in area, which is a ref parameter which is updated. 339 | * No checking on area overflow. 340 | */ 341 | char * 342 | tgetstr(char *id, char **area) 343 | { 344 | register char *bp = tbuf; 345 | 346 | for (;;) { 347 | bp = tskip(bp); 348 | if (!*bp) 349 | return (0); 350 | if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) 351 | continue; 352 | if (*bp == '@') 353 | return(0); 354 | if (*bp != '=') 355 | continue; 356 | bp++; 357 | return (tdecode(bp, area)); 358 | } 359 | } 360 | 361 | /* 362 | * Tdecode does the grung work to decode the 363 | * string capability escapes. 364 | */ 365 | static char * 366 | tdecode(register char *str, char **area) 367 | { 368 | register char *cp; 369 | register int c; 370 | register char *dp; 371 | int i; 372 | 373 | cp = *area; 374 | while ((c = *str++) && c != ':') { 375 | switch (c) { 376 | 377 | case '^': 378 | c = *str++ & 037; 379 | break; 380 | 381 | case '\\': 382 | dp = "E\033^^\\\\::n\nr\rt\tb\bf\f"; 383 | c = *str++; 384 | nextc: 385 | if (*dp++ == c) { 386 | c = *dp++; 387 | break; 388 | } 389 | dp++; 390 | if (*dp) 391 | goto nextc; 392 | if (isdigit(c)) { 393 | c -= '0', i = 2; 394 | do 395 | c <<= 3, c |= *str++ - '0'; 396 | while (--i && isdigit(*str & 0377)); 397 | } 398 | break; 399 | } 400 | *cp++ = c; 401 | } 402 | *cp++ = 0; 403 | str = *area; 404 | *area = cp; 405 | return (str); 406 | } 407 | 408 | /* 409 | */ 410 | static const char sccssl[] = "@(#)libterm.sl 1.7 (gritter) 11/23/04"; 411 | -------------------------------------------------------------------------------- /doc/ex-vi/libterm/tgoto.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | */ 40 | 41 | #ifndef lint 42 | #ifdef DOSCCS 43 | static char *sccsid = "@(#)tgoto.c 1.3 (gritter) 11/23/04"; 44 | #endif 45 | #endif 46 | 47 | /* from tgoto.c 5.1 (Berkeley) 6/5/85 */ 48 | 49 | #include "libterm.h" 50 | 51 | #define CTRL(c) (c & 037) 52 | 53 | #define MAXRETURNSIZE 64 54 | 55 | #ifdef __STDC__ 56 | #include 57 | #endif 58 | 59 | char *UP; 60 | char *BC; 61 | 62 | /* 63 | * Routine to perform cursor addressing. 64 | * CM is a string containing printf type escapes to allow 65 | * cursor addressing. We start out ready to print the destination 66 | * line, and switch each time we print row or column. 67 | * The following escapes are defined for substituting row/column: 68 | * 69 | * %d as in printf 70 | * %2 like %2d 71 | * %3 like %3d 72 | * %. gives %c hacking special case characters 73 | * %+x like %c but adding x first 74 | * 75 | * The codes below affect the state but don't use up a value. 76 | * 77 | * %>xy if value > x add y 78 | * %r reverses row/column 79 | * %i increments row/column (for one origin indexing) 80 | * %% gives % 81 | * %B BCD (2 decimal digits encoded in one byte) 82 | * %D Delta Data (backwards bcd) 83 | * 84 | * all other characters are ``self-inserting''. 85 | */ 86 | char * 87 | tgoto(char *CM, int destcol, int destline) 88 | { 89 | static char result[MAXRETURNSIZE]; 90 | static char added[10]; 91 | char *cp = CM; 92 | register char *dp = result; 93 | register int c; 94 | int oncol = 0; 95 | register int which = destline; 96 | 97 | if (cp == 0) { 98 | toohard: 99 | /* 100 | * ``We don't do that under BOZO's big top'' 101 | */ 102 | return ("OOPS"); 103 | } 104 | added[0] = 0; 105 | while (c = *cp++) { 106 | if (c != '%') { 107 | *dp++ = c; 108 | continue; 109 | } 110 | switch (c = *cp++) { 111 | 112 | #ifdef CM_N 113 | case 'n': 114 | destcol ^= 0140; 115 | destline ^= 0140; 116 | goto setwhich; 117 | #endif 118 | 119 | case 'd': 120 | if (which < 10) 121 | goto one; 122 | if (which < 100) 123 | goto two; 124 | /* fall into... */ 125 | 126 | case '3': 127 | *dp++ = (which / 100) | '0'; 128 | which %= 100; 129 | /* fall into... */ 130 | 131 | case '2': 132 | two: 133 | *dp++ = which / 10 | '0'; 134 | one: 135 | *dp++ = which % 10 | '0'; 136 | swap: 137 | oncol = 1 - oncol; 138 | setwhich: 139 | which = oncol ? destcol : destline; 140 | continue; 141 | 142 | #ifdef CM_GT 143 | case '>': 144 | if (which > *cp++) 145 | which += *cp++; 146 | else 147 | cp++; 148 | continue; 149 | #endif 150 | 151 | case '+': 152 | which += *cp++; 153 | /* fall into... */ 154 | 155 | case '.': 156 | /* casedot: */ 157 | /* 158 | * This code is worth scratching your head at for a 159 | * while. The idea is that various weird things can 160 | * happen to nulls, EOT's, tabs, and newlines by the 161 | * tty driver, arpanet, and so on, so we don't send 162 | * them if we can help it. 163 | * 164 | * Tab is taken out to get Ann Arbors to work, otherwise 165 | * when they go to column 9 we increment which is wrong 166 | * because bcd isn't continuous. We should take out 167 | * the rest too, or run the thing through more than 168 | * once until it doesn't make any of these, but that 169 | * would make termlib (and hence pdp-11 ex) bigger, 170 | * and also somewhat slower. This requires all 171 | * programs which use termlib to stty tabs so they 172 | * don't get expanded. They should do this anyway 173 | * because some terminals use ^I for other things, 174 | * like nondestructive space. 175 | */ 176 | if (which == 0 || which == CTRL('d') || /* which == '\t' || */ which == '\n') { 177 | if (oncol || UP) /* Assumption: backspace works */ 178 | /* 179 | * Loop needed because newline happens 180 | * to be the successor of tab. 181 | */ 182 | do { 183 | strcat(added, oncol ? (BC ? BC : "\b") : UP); 184 | which++; 185 | } while (which == '\n'); 186 | } 187 | *dp++ = which; 188 | goto swap; 189 | 190 | case 'r': 191 | oncol = 1; 192 | goto setwhich; 193 | 194 | case 'i': 195 | destcol++; 196 | destline++; 197 | which++; 198 | continue; 199 | 200 | case '%': 201 | *dp++ = c; 202 | continue; 203 | 204 | #ifdef CM_B 205 | case 'B': 206 | which = (which/10 << 4) + which%10; 207 | continue; 208 | #endif 209 | 210 | #ifdef CM_D 211 | case 'D': 212 | which = which - 2 * (which%16); 213 | continue; 214 | #endif 215 | 216 | default: 217 | goto toohard; 218 | } 219 | } 220 | strcpy(dp, added); 221 | return (result); 222 | } 223 | -------------------------------------------------------------------------------- /doc/ex-vi/libterm/tputs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code contains changes by 3 | * Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 4 | * 5 | * Conditions 1, 2, and 4 and the no-warranty notice below apply 6 | * to these changes. 7 | * 8 | * 9 | * Copyright (c) 1980, 1993 10 | * The Regents of the University of California. All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | */ 40 | 41 | #ifndef lint 42 | #ifdef DOSCCS 43 | static char *sccsid = "@(#)tputs.c 1.4 (gritter) 11/23/04"; 44 | #endif 45 | #endif 46 | 47 | /* from tputs.c 5.1 (Berkeley) 6/5/85 */ 48 | 49 | #include 50 | 51 | #include "libterm.h" 52 | 53 | /* 54 | * The following array gives the number of tens of milliseconds per 55 | * character for each speed as returned by gtty. Thus since 300 56 | * baud returns a 7, there are 33.3 milliseconds per char at 300 baud. 57 | */ 58 | static 59 | short tmspc10[] = { 60 | 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5 61 | }; 62 | 63 | short ospeed; 64 | char PC; 65 | 66 | /* 67 | * Put the character string cp out, with padding. 68 | * The number of affected lines is affcnt, and the routine 69 | * used to output one character is outc. 70 | */ 71 | int 72 | tputs(const char *cp, int affcnt, int (*outc)(int)) 73 | { 74 | register int i = 0; 75 | register int mspc10; 76 | 77 | if (cp == 0) 78 | return 1; 79 | 80 | /* 81 | * Convert the number representing the delay. 82 | */ 83 | if (isdigit(*cp & 0377)) { 84 | do 85 | i = i * 10 + *cp++ - '0'; 86 | while (isdigit(*cp & 0377)); 87 | } 88 | i *= 10; 89 | if (*cp == '.') { 90 | cp++; 91 | if (isdigit(*cp & 0377)) 92 | i += *cp - '0'; 93 | /* 94 | * Only one digit to the right of the decimal point. 95 | */ 96 | while (isdigit(*cp & 0377)) 97 | cp++; 98 | } 99 | 100 | /* 101 | * If the delay is followed by a `*', then 102 | * multiply by the affected lines count. 103 | */ 104 | if (*cp == '*') 105 | cp++, i *= affcnt; 106 | 107 | /* 108 | * The guts of the string. 109 | */ 110 | while (*cp) 111 | (*outc)(*cp++); 112 | 113 | /* 114 | * If no delay needed, or output speed is 115 | * not comprehensible, then don't try to delay. 116 | */ 117 | if (i == 0) 118 | return 1; 119 | if (ospeed <= 0 || ospeed >= (sizeof tmspc10 / sizeof tmspc10[0])) 120 | return 1; 121 | 122 | /* 123 | * Round up by a half a character frame, 124 | * and then do the delay. 125 | * Too bad there are no user program accessible programmed delays. 126 | * Transmitting pad characters slows many 127 | * terminals down and also loads the system. 128 | */ 129 | mspc10 = tmspc10[ospeed]; 130 | i += mspc10 / 2; 131 | for (i /= mspc10; i > 0; i--) 132 | (*outc)(PC); 133 | return 1; 134 | } 135 | -------------------------------------------------------------------------------- /doc/ex-vi/makeoptions: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This code contains changes by 4 | # Gunnar Ritter, Freiburg i. Br., Germany, 2002. All rights reserved. 5 | # 6 | # Conditions 1, 2, and 4 and the no-warranty notice below apply 7 | # to these changes. 8 | # 9 | # 10 | # Copyright (c) 1980, 1993 11 | # The Regents of the University of California. All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 1. Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # 2. Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in the 20 | # documentation and/or other materials provided with the distribution. 21 | # 3. All advertising materials mentioning features or use of this software 22 | # must display the following acknowledgement: 23 | # This product includes software developed by the University of 24 | # California, Berkeley and its contributors. 25 | # 4. Neither the name of the University nor the names of its contributors 26 | # may be used to endorse or promote products derived from this software 27 | # without specific prior written permission. 28 | # 29 | # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 30 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 | # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 33 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 | # SUCH DAMAGE. 40 | # 41 | # 42 | # Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 43 | # 44 | # Redistribution and use in source and binary forms, with or without 45 | # modification, are permitted provided that the following conditions 46 | # are met: 47 | # Redistributions of source code and documentation must retain the 48 | # above copyright notice, this list of conditions and the following 49 | # disclaimer. 50 | # Redistributions in binary form must reproduce the above copyright 51 | # notice, this list of conditions and the following disclaimer in the 52 | # documentation and/or other materials provided with the distribution. 53 | # All advertising materials mentioning features or use of this software 54 | # must display the following acknowledgement: 55 | # This product includes software developed or owned by Caldera 56 | # International, Inc. 57 | # Neither the name of Caldera International, Inc. nor the names of 58 | # other contributors may be used to endorse or promote products 59 | # derived from this software without specific prior written permission. 60 | # 61 | # USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 62 | # INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 63 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 64 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 65 | # ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 66 | # LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 67 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 68 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 69 | # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 70 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 71 | # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 72 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 73 | # 74 | # from makeoptions 6.4 (Berkeley) 5/31/85 75 | # 76 | # @(#)makeoptions 1.8 (gritter) 7/1/02 77 | # 78 | 79 | # 80 | # remake options -- this isn't necessary unless you add/delete options 81 | # 82 | trap "rm -f /tmp/ex_foo$$.c /tmp/ex_bar$$.c" 0 83 | trap '' 2 84 | cat < ex_data.c > /tmp/ex_bar$$.c 85 | ex -s /tmp/ex_bar$$.c <<\! 86 | g/^#include/d 87 | w 88 | q 89 | ! 90 | cc -E ${@+"$@"} /tmp/ex_bar$$.c >/tmp/ex_foo$$.c 91 | ex -s /tmp/ex_foo$$.c <<\! 92 | " delete all preprocessor output (# line, etc) 93 | g/^# /d 94 | set sh=/bin/sh 95 | " delete junk (all but data lines) 96 | g/^[ ]*$/d 97 | 1,/option options/d 98 | /};/-1,$d 99 | " get rid of all of line but option name 100 | 1,$s/[ ]*{[ ]*"// 101 | 1,$s/".*// 102 | " begin kludge since options start at 0 but nl starts at 1 103 | " move first to end and later move it back and renumber 104 | 1m$ 105 | %!nl 106 | $t0 107 | 1s/[0-9][0-9]*/0/ 108 | " end kludge 109 | " make #define lines 110 | 1,$s/[ ]*\([0-9][0-9]*\)[ ]*\(.*\)/#define \U\2\L \1/ 111 | " filter through expand to make it line up nice 112 | %!expand -8\,24 113 | " blank line and number of options. 114 | $i 115 | 116 | . 117 | $s/e[ ].*[ ]/e NOPTS / 118 | 0a 119 | /* sccs id @(#)ex_vars.h makeoptions 1.8 (gritter) 7/1/02 */ 120 | . 121 | w! ex_vars.h 122 | q 123 | ! 124 | -------------------------------------------------------------------------------- /doc/ex-vi/malloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AT&T Unix 7th Edition memory allocation routines. 3 | * 4 | * Modified for ex by Gunnar Ritter, Freiburg i. Br., Germany, 5 | * July 2000. 6 | * 7 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * Redistributions of source code and documentation must retain the 13 | * above copyright notice, this list of conditions and the following 14 | * disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * All advertising materials mentioning features or use of this software 19 | * must display the following acknowledgement: 20 | * This product includes software developed or owned by Caldera 21 | * International, Inc. 22 | * Neither the name of Caldera International, Inc. nor the names of 23 | * other contributors may be used to endorse or promote products 24 | * derived from this software without specific prior written permission. 25 | * 26 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 27 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 29 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 34 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 35 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 36 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 37 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | * @(#)malloc.c 1.19 (gritter) 2/20/05 40 | */ 41 | 42 | #ifdef VMUNIX 43 | 44 | #include 45 | #include 46 | #include 47 | 48 | #include "config.h" 49 | 50 | #ifdef LANGMSG 51 | #include 52 | extern nl_catd catd; 53 | #else 54 | #define catgets(a, b, c, d) (d) 55 | #endif 56 | 57 | /* 58 | * Since ex makes use of sbrk(), the C library's version of malloc() 59 | * must be avoided. 60 | * 61 | * In ex, malloc() calls sbrk() only one time with an argument of 62 | * POOL. Ex itselves never uses malloc() internally, so POOL 63 | * must be sufficient for library calls like setlocale() only. 64 | * 65 | * Known problem: If linking against ncurses, changing the terminal 66 | * type repeatedly outruns the pool. Even that is not really a 67 | * problem since the work continues with the old terminal type, so 68 | * there is no need for a large pool here. 69 | */ 70 | #define POOL 32768 71 | 72 | #ifdef debug 73 | #define ASSERT(p) if(!(p))botch("p");else 74 | #include 75 | #include 76 | #include 77 | int 78 | botch(char *s) 79 | { 80 | const char msg[] = "assertion botched\n"; 81 | write(2, msg, sizeof msg - 1); 82 | /*printf("assertion botched: %s\n",s);*/ 83 | abort(); 84 | } 85 | static int allock(void); 86 | #else 87 | #define ASSERT(p) 88 | #endif 89 | 90 | /* avoid break bug */ 91 | #ifdef pdp11 92 | #define GRANULE 64 93 | #else 94 | #define GRANULE 0 95 | #endif 96 | /* C storage allocator 97 | * circular first-fit strategy 98 | * works with noncontiguous, but monotonically linked, arena 99 | * each block is preceded by a ptr to the (pointer of) 100 | * the next following block 101 | * blocks are exact number of words long 102 | * aligned to the data type requirements of ALIGN 103 | * pointers to blocks must have BUSY bit 0 104 | * bit in ptr is 1 for busy, 0 for idle 105 | * gaps in arena are merely noted as busy blocks 106 | * last block of arena (pointed to by alloct) is empty and 107 | * has a pointer to first 108 | * idle blocks are coalesced during space search 109 | * 110 | * a different implementation may need to redefine 111 | * ALIGN, NALIGN, BLOCK, BUSY, INT 112 | * where INT is integer type to which a pointer can be cast 113 | */ 114 | #define INT intptr_t 115 | #define ALIGN intptr_t 116 | #define NALIGN 1 117 | #define WORD sizeof (union store) 118 | #define BLOCK 1024 /* a multiple of WORD*/ 119 | #define BUSY ((intptr_t)1) 120 | #ifdef NULL 121 | #undef NULL 122 | #endif 123 | #define NULL 0 124 | #define testbusy(p) ((INT)(p)&BUSY) 125 | #define setbusy(p) (union store *)((INT)(p)|BUSY) 126 | #define clearbusy(p) (union store *)((INT)(p)&~BUSY) 127 | 128 | union store { union store *ptr; 129 | ALIGN dummy[NALIGN]; 130 | INT callocsp; /*calloc clears an array of integers*/ 131 | }; 132 | 133 | static union store allocs[2]; /*initial arena*/ 134 | static union store *allocp; /*search ptr*/ 135 | static union store *alloct; /*arena top*/ 136 | static union store *allocx; /*for benefit of realloc*/ 137 | extern int error(char *, ...); 138 | 139 | char * 140 | poolsbrk(intptr_t inc) 141 | { 142 | static char *pool; 143 | static intptr_t ps; 144 | intptr_t os, ns; 145 | 146 | if (pool == NULL) 147 | if ((pool = sbrk(POOL)) == (char *)-1) 148 | error(catgets(catd, 1, 241, 149 | "No memory pool")); 150 | if (inc == 0) 151 | return pool + ps; 152 | os = ps; 153 | ns = ps + inc; 154 | if (ns >= POOL) 155 | error(catgets(catd, 1, 242, 156 | "Memory pool exhausted")); 157 | ps = ns; 158 | return pool + os; 159 | } 160 | 161 | void * 162 | malloc(size_t nbytes) 163 | { 164 | register union store *p, *q; 165 | register int nw; 166 | static int temp; /*coroutines assume no auto*/ 167 | 168 | if(allocs[0].ptr==0) { /*first time*/ 169 | allocs[0].ptr = setbusy(&allocs[1]); 170 | allocs[1].ptr = setbusy(&allocs[0]); 171 | alloct = &allocs[1]; 172 | allocp = &allocs[0]; 173 | } 174 | nw = (nbytes+WORD+WORD-1)/WORD; 175 | ASSERT(allocp>=allocs && allocp<=alloct); 176 | ASSERT(allock()); 177 | for(p=allocp; ; ) { 178 | for(temp=0; ; ) { 179 | if(!testbusy(p->ptr)) { 180 | while(!testbusy((q=p->ptr)->ptr)) { 181 | int ua = p->ptr==allocp; 182 | ASSERT(q>p&&qptr = q->ptr; 184 | if (ua) 185 | allocp = p->ptr; 186 | } 187 | if(q>=p+nw && p+nw>=p) 188 | goto found; 189 | } 190 | q = p; 191 | p = clearbusy(p->ptr); 192 | if(p>q) 193 | ASSERT(p<=alloct); 194 | else if(q!=alloct || p!=allocs) { 195 | ASSERT(q==alloct&&p==allocs); 196 | errno = ENOMEM; 197 | return(NULL); 198 | } else if(++temp>1) 199 | break; 200 | } 201 | temp = ((nw+BLOCK/WORD)/(BLOCK/WORD))*(BLOCK/WORD); 202 | q = (union store *)poolsbrk(0); 203 | if(q+temp+GRANULE < q) { 204 | errno = ENOMEM; 205 | return(NULL); 206 | } 207 | q = (union store *)poolsbrk(temp*WORD); 208 | if((INT)q == -1) { 209 | errno = ENOMEM; 210 | return(NULL); 211 | } 212 | ASSERT(q>alloct); 213 | alloct->ptr = q; 214 | if(q!=alloct+1) 215 | alloct->ptr = setbusy(alloct->ptr); 216 | alloct = q->ptr = q+temp-1; 217 | alloct->ptr = setbusy(allocs); 218 | } 219 | found: 220 | allocp = p + nw; 221 | ASSERT(allocp<=alloct); 222 | if(q>allocp) { 223 | allocx = allocp->ptr; 224 | allocp->ptr = p->ptr; 225 | } 226 | p->ptr = setbusy(allocp); 227 | return((char *)(p+1)); 228 | } 229 | 230 | /* freeing strategy tuned for LIFO allocation 231 | */ 232 | void 233 | free(register void *ap) 234 | { 235 | register union store *p = ap; 236 | 237 | if (ap == NULL) 238 | return; 239 | ASSERT(p>clearbusy(allocs[1].ptr)&&p<=alloct); 240 | ASSERT(allock()); 241 | allocp = --p; 242 | ASSERT(testbusy(p->ptr)); 243 | p->ptr = clearbusy(p->ptr); 244 | ASSERT(p->ptr > allocp && p->ptr <= alloct); 245 | } 246 | 247 | /* realloc(p, nbytes) reallocates a block obtained from malloc() 248 | * and freed since last call of malloc() 249 | * to have new size nbytes, and old content 250 | * returns new location, or 0 on failure 251 | */ 252 | 253 | void * 254 | realloc(void *ap, size_t nbytes) 255 | { 256 | register union store *p = ap; 257 | register union store *q; 258 | union store *s, *t; 259 | register size_t nw; 260 | size_t onw; 261 | 262 | if (p == NULL) 263 | return malloc(nbytes); 264 | if (nbytes == 0) { 265 | free(p); 266 | return NULL; 267 | } 268 | if(testbusy(p[-1].ptr)) 269 | free(p); 270 | onw = p[-1].ptr - p; 271 | q = malloc(nbytes); 272 | if(q==NULL || q==p) 273 | return(q); 274 | s = p; 275 | t = q; 276 | nw = (nbytes+WORD-1)/WORD; 277 | if(nw=p) 282 | (q+(q+nw-p))->ptr = allocx; 283 | return(q); 284 | } 285 | 286 | #ifdef debug 287 | int 288 | allock(void) 289 | { 290 | #ifdef longdebug 291 | register union store *p; 292 | int x; 293 | x = 0; 294 | for(p= &allocs[0]; clearbusy(p->ptr) > p; p=clearbusy(p->ptr)) { 295 | if(p==allocp) 296 | x++; 297 | } 298 | ASSERT(p==alloct); 299 | return(x==1|p==allocp); 300 | #else 301 | return(1); 302 | #endif 303 | } 304 | #endif 305 | 306 | /* calloc - allocate and clear memory block 307 | */ 308 | #define CHARPERINT (sizeof(INT)/sizeof(char)) 309 | 310 | void * 311 | calloc(size_t num, size_t size) 312 | { 313 | register char *mp; 314 | register INT *q; 315 | register int m; 316 | 317 | num *= size; 318 | mp = malloc(num); 319 | if(mp == NULL) 320 | return(NULL); 321 | q = (INT *) mp; 322 | m = (num+CHARPERINT-1)/CHARPERINT; 323 | while(--m >= 0) 324 | *q++ = 0; 325 | return(mp); 326 | } 327 | 328 | #ifdef notdef 329 | /*ARGSUSED*/ 330 | void 331 | cfree(char *p, size_t num, size_t size) 332 | { 333 | free(p); 334 | } 335 | 336 | /* 337 | * Just in case ... 338 | */ 339 | char * 340 | memalign(size_t alignment, size_t size) 341 | { 342 | return NULL; 343 | } 344 | 345 | char * 346 | valloc(size_t size) 347 | { 348 | return NULL; 349 | } 350 | 351 | char * 352 | mallinfo(void) 353 | { 354 | return NULL; 355 | } 356 | 357 | int 358 | mallopt(void) 359 | { 360 | return -1; 361 | } 362 | #endif /* notdef */ 363 | 364 | #endif /* VMUNIX */ 365 | -------------------------------------------------------------------------------- /doc/ex-vi/pkginfo: -------------------------------------------------------------------------------- 1 | # Sccsid @(#)pkginfo 1.1 (gritter) 2/25/07 2 | PKG=ex 3 | NAME=The ex/vi editor 4 | DESC=The ex/vi editor. 5 | VENDOR=Gunnar Ritter 6 | HOTLINE=http://ex-vi.sourceforge.net 7 | EMAIL=gunnarr@acm.org 8 | VERSION=070225 9 | ARCH=IA32,i386 10 | CATEGORY=utilities 11 | BASEDIR=/ 12 | -------------------------------------------------------------------------------- /doc/ex_vi_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluete/vImputManager/42c09de824f85da3ffa68dcc11c36cbc9a502998/doc/ex_vi_1.pdf -------------------------------------------------------------------------------- /doc/inputmanager.txt: -------------------------------------------------------------------------------- 1 | 2 | Was ist ein InputManager? 3 | 4 | - liegt als Directory in /Library/InputManagers/vImputManager/, alle Dateien 5 | und Dirs dort muessen root:admin gehoeren 6 | 7 | 8 | - zwei Bestandteile, eine Property-Datei ".../vImputManager/Info" 9 | und dann das eigentliche Cocoa Bundle ".../vImputManager/vImputManager.bundle" 10 | 11 | 12 | - die Property-Datei ist XML: 13 | 14 | 15 | 16 | 17 | BundleName 18 | vImputManager.bundle 19 | LoadBundleOnLaunch 20 | YES 21 | LocalizedNames 22 | 23 | English 24 | IncrementalSearch 25 | 26 | NoMenuEntry 27 | YES 28 | 29 | 30 | 31 | 32 | - das Bundle ist ein normales Cocoa-Bundle, es sollte "+(void)load" 33 | implementieren. Um an Infos ueber die aktuelle Host-App zu kommen 34 | koennen wir folgendes benutzen: 35 | 36 | [[NSBundle mainBundle] bundleIdentifier] => "com.apple.Safari" 37 | [[NSBundle mainBundle] infoDictionary] => other information 38 | 39 | 40 | - Beispiel-Bundle: 41 | + (void)load { 42 | NSBundle *hostApp=[NSBundle mainBundle]; 43 | 44 | // check the host app is Safari 45 | NSString *bundleID=[hostApp bundleIdentifier]; 46 | if(![bundleID isEqualToString:@"com.apple.Safari"]) 47 | return; 48 | 49 | // check this version of Safari is supported 50 | NSDictionary *infoDict=[hostApp infoDictionary]; 51 | float v=[[infoDict valueForKey:@"CFBundleVersion"] floatValue]; 52 | if(v<5528.16) { 53 | // TODO: Tell the user why the plugin hasn't loaded 54 | return; 55 | } 56 | 57 | // Initialise your plugin here... 58 | } 59 | 60 | -------------------------------------------------------------------------------- /doc/ipc.txt: -------------------------------------------------------------------------------- 1 | 2 | This is a typical "syslog.conf" problem: you must direct "syslog" information 3 | for the relevant "facility" and "level" to a destination. Unfortunately, the 4 | "facility" name that Apple gives for "launchd" in Tech Note TN2124 is wrong. 5 | Instead, I appended a "*.debug" line to my "syslog.conf" file and sent the 6 | output to /var/log/debug.log instead. 7 | 8 | http://cocoawithlove.com/2009/02/interprocess-communication-snooping.html 9 | 10 | - Moeglichkeit 1: NSDistributedNotificationCenter 11 | 12 | - Moeglichkeit 2: NSPortNameServer bzw. NSNetService 13 | 14 | - Remoteaufrufe auf Objects: 15 | id rootObject= 16 | [NSConnection rootProxyForConnectionWithRegisteredName: 17 | @"PBXProjectWatcherServerConnection-3.1.2" host:nil]; 18 | 19 | -------------------------------------------------------------------------------- /doc/properties-with-prefix.m: -------------------------------------------------------------------------------- 1 | 2 | // There is no reason that the property's name need match 3 | // the instance variable's name exactly: 4 | 5 | @interface MyObject: NSObject { 6 | id _ivar; 7 | } 8 | 9 | @property ivar; 10 | 11 | @end 12 | 13 | 14 | @implementation MyObject 15 | 16 | @synthesize ivar=_ivar; 17 | 18 | @end 19 | 20 | -------------------------------------------------------------------------------- /doc/statusbar.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | - (void)awakeFromNib { 4 | NSStatusBar *statusBar=[NSStatusBar systemStatusBar]; 5 | 6 | NSStatusItem *statusItem=[statusBar statusItemWithLength:NSVariableStatusItemLength]; 7 | [statusItem retain]; 8 | 9 | NSImage *itemImage = [[NSImage alloc] 10 | initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png"]]; 11 | [statusItem setImage:itemImage]; 12 | [statusItem setHighlightMode:YES]; 13 | [statusItem setMenu:tunesMenu]; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /doc/vi-intro.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluete/vImputManager/42c09de824f85da3ffa68dcc11c36cbc9a502998/doc/vi-intro.pdf -------------------------------------------------------------------------------- /vImputManager.xcodeproj/TemplateIcon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schluete/vImputManager/42c09de824f85da3ffa68dcc11c36cbc9a502998/vImputManager.xcodeproj/TemplateIcon.icns -------------------------------------------------------------------------------- /vImputManager_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'vImputManager' target in the 'vImputManager' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /version.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildVersion 6 | 3 7 | CFBundleVersion 8 | 1.0 9 | ProductBuildVersion 10 | 9M2729 11 | ProjectName 12 | DevToolsWizardTemplates 13 | SourceVersion 14 | 11600000 15 | 16 | 17 | --------------------------------------------------------------------------------