diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-04-13 01:18:56 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-04-13 01:18:56 +0000 |
commit | 61677feff7f549a48267c2c0c50a7420de6e2599 (patch) | |
tree | 1ea829e51641647a35c552e289f4482ab9f5db27 /shell | |
parent | 62dc17a3b100496a5c7433cc598d674e244cb6f8 (diff) | |
download | busybox-w32-61677feff7f549a48267c2c0c50a7420de6e2599.tar.gz busybox-w32-61677feff7f549a48267c2c0c50a7420de6e2599.tar.bz2 busybox-w32-61677feff7f549a48267c2c0c50a7420de6e2599.zip |
Upates to include copyright 2000 to everything
-Erik
Diffstat (limited to 'shell')
-rw-r--r-- | shell/cmdedit.c | 66 |
1 files changed, 8 insertions, 58 deletions
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index 9800dd1c6..1434c36f6 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -1,10 +1,12 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * Termios command line History and Editting for NetBSD sh (ash) | 3 | * Termios command line History and Editting, originally |
4 | * intended for NetBSD sh (ash) | ||
4 | * Copyright (c) 1999 | 5 | * Copyright (c) 1999 |
5 | * Main code: Adam Rogoyski <rogoyski@cs.utexas.edu> | 6 | * Main code: Adam Rogoyski <rogoyski@cs.utexas.edu> |
6 | * Etc: Dave Cinege <dcinege@psychosis.com> | 7 | * Etc: Dave Cinege <dcinege@psychosis.com> |
7 | * Adjusted for busybox: Erik Andersen <andersee@debian.org> | 8 | * Majorly adjusted/re-written for busybox: |
9 | * Erik Andersen <andersee@debian.org> | ||
8 | * | 10 | * |
9 | * You may use this code as you wish, so long as the original author(s) | 11 | * You may use this code as you wish, so long as the original author(s) |
10 | * are attributed in any redistributions of the source code. | 12 | * are attributed in any redistributions of the source code. |
@@ -69,14 +71,15 @@ struct history { | |||
69 | void | 71 | void |
70 | cmdedit_setwidth(int w) | 72 | cmdedit_setwidth(int w) |
71 | { | 73 | { |
72 | if (w > 20) { | 74 | if (w > 20) { |
73 | cmdedit_termw = w; | 75 | cmdedit_termw = w; |
74 | cmdedit_scroll = w / 3; | 76 | cmdedit_scroll = w / 3; |
75 | } else { | 77 | } else { |
76 | errorMsg("\n*** Error: minimum screen width is 21\n"); | 78 | errorMsg("\n*** Error: minimum screen width is 21\n"); |
77 | } | 79 | } |
78 | } | 80 | } |
79 | 81 | ||
82 | |||
80 | void cmdedit_reset_term(void) | 83 | void cmdedit_reset_term(void) |
81 | { | 84 | { |
82 | if (reset_term) | 85 | if (reset_term) |
@@ -339,60 +342,7 @@ void get_next_history(struct history **hp, char* command) | |||
339 | free((*hp)->s); | 342 | free((*hp)->s); |
340 | (*hp)->s = strdup(command); | 343 | (*hp)->s = strdup(command); |
341 | *hp = (*hp)->n; | 344 | *hp = (*hp)->n; |
342 | |||
343 | cmdedit_redraw( NULL, hp->s, -2, -2); | ||
344 | } | ||
345 | |||
346 | #if 0 | ||
347 | /* prompt : if !=NULL, print the prompt | ||
348 | * command: the command line to be displayed | ||
349 | * where : where to display changes from. | ||
350 | * -1 for no change, -2 for new line | ||
351 | * cursor : desired location for the cursor. | ||
352 | * -1 for Beginning of line. | ||
353 | * -2 for End of Line, | ||
354 | */ | ||
355 | static void | ||
356 | cmdedit_redraw(char* prompt, char* command, int where, int cursor) | ||
357 | { | ||
358 | static char* last_command; | ||
359 | int cmdedit_width; | ||
360 | |||
361 | if (where == -2) { | ||
362 | /* Rewrite the prompt and clean up static variables */ | ||
363 | xwrite(outputFd, "\n", 1); | ||
364 | if (prompt) { | ||
365 | strcpy(last_command, prompt); | ||
366 | xwrite(outputFd, prompt, strlen(prompt)); | ||
367 | } else { | ||
368 | last_command[0] = '\0'; | ||
369 | xwrite(outputFd, "# ", 2); | ||
370 | } | ||
371 | cmdedit_width = cmdedit_termw - cmdedit_strlen(prompt); | ||
372 | } else if (strcmp(command, last_command) != 0) { | ||
373 | strcpy(last_command, prompt); | ||
374 | } | ||
375 | |||
376 | /* erase old command from command line */ | ||
377 | len = strlen(command)-strlen(last_command); | ||
378 | while (len>0) | ||
379 | input_backspace(command, outputFd, &cursor, &len); | ||
380 | input_home(outputFd, &cursor); | ||
381 | |||
382 | /* Rewrite the command */ | ||
383 | xwrite(outputFd, command+where, len); | ||
384 | |||
385 | /* Put the where it is supposed to be */ | ||
386 | for (cursor=len; cursor > where; cursor--) | ||
387 | xwrite(outputFd, "\b", 1); | ||
388 | |||
389 | /* write new command */ | ||
390 | strcpy(command, hp->s); | ||
391 | len = strlen(hp->s); | ||
392 | xwrite(outputFd, command+where, len); | ||
393 | cursor = len; | ||
394 | } | 345 | } |
395 | #endif | ||
396 | 346 | ||
397 | /* | 347 | /* |
398 | * This function is used to grab a character buffer | 348 | * This function is used to grab a character buffer |