* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-char *vi_Version =
- "$Id: vi.c,v 1.9 2001/06/23 13:49:14 andersen Exp $";
+static const char vi_Version[] =
+ "$Id: vi.c,v 1.15 2001/08/02 05:26:41 andersen Exp $";
/*
* To compile for standalone use:
//case 'h': // help -- just use default
default:
show_help();
- break;
+ return 1;
}
}
// read after current line- unless user said ":0r foo"
if (b != 0)
q = next_line(q);
+#ifdef BB_FEATURE_VI_READONLY
l= readonly; // remember current files' status
+#endif
ch = file_insert(fn, q, file_size(fn));
+#ifdef BB_FEATURE_VI_READONLY
readonly= l;
+#endif
if (ch < 0)
goto vc1; // nothing was inserted
// how many lines in text[]?
cmdcnt = 0;
end_cmd_q(); // stop adding to q
strcpy((char *) status_buffer, " "); // clear the status buffer
- if (p[-1] != '\n') {
+ if ((p[-1] != '\n') && (dot>text)) {
p--;
}
} else if (c == erase_char) { // Is this a BS
// 123456789
- if (p[-1] != '\n') {
+ if ((p[-1] != '\n') && (dot>text)) {
p--;
p = text_hole_delete(p, p); // shrink buffer 1 char
#ifdef BB_FEATURE_VI_DOT_CMD
static void show_help(void)
{
- printf("These features are available:\n");
+ puts("These features are available:"
#ifdef BB_FEATURE_VI_SEARCH
- printf("\tPattern searches with / and ?\n");
+ "\n\tPattern searches with / and ?"
#endif /* BB_FEATURE_VI_SEARCH */
#ifdef BB_FEATURE_VI_DOT_CMD
- printf("\tLast command repeat with \'.\'\n");
+ "\n\tLast command repeat with \'.\'"
#endif /* BB_FEATURE_VI_DOT_CMD */
#ifdef BB_FEATURE_VI_YANKMARK
- printf("\tLine marking with 'x\n");
- printf("\tNamed buffers with \"x\n");
+ "\n\tLine marking with 'x"
+ "\n\tNamed buffers with \"x"
#endif /* BB_FEATURE_VI_YANKMARK */
#ifdef BB_FEATURE_VI_READONLY
- printf("\tReadonly if vi is called as \"view\"\n");
- printf("\tReadonly with -R command line arg\n");
+ "\n\tReadonly if vi is called as \"view\""
+ "\n\tReadonly with -R command line arg"
#endif /* BB_FEATURE_VI_READONLY */
#ifdef BB_FEATURE_VI_SET
- printf("\tSome colon mode commands with \':\'\n");
+ "\n\tSome colon mode commands with \':\'"
#endif /* BB_FEATURE_VI_SET */
#ifdef BB_FEATURE_VI_SETOPTS
- printf("\tSettable options with \":set\"\n");
+ "\n\tSettable options with \":set\""
#endif /* BB_FEATURE_VI_SETOPTS */
#ifdef BB_FEATURE_VI_USE_SIGNALS
- printf("\tSignal catching- ^C\n");
- printf("\tJob suspend and resume with ^Z\n");
+ "\n\tSignal catching- ^C"
+ "\n\tJob suspend and resume with ^Z"
#endif /* BB_FEATURE_VI_USE_SIGNALS */
#ifdef BB_FEATURE_VI_WIN_RESIZE
- printf("\tAdapt to window re-sizes\n");
+ "\n\tAdapt to window re-sizes"
#endif /* BB_FEATURE_VI_WIN_RESIZE */
+ );
}
static void print_literal(Byte * buf, Byte * s) // copy s to buf, convert unprintable
term_vi.c_lflag &= (~ICANON & ~ECHO); // leave ISIG ON- allow intr's
term_vi.c_iflag &= (~IXON & ~ICRNL);
term_vi.c_oflag &= (~ONLCR);
+#ifndef linux
term_vi.c_cc[VMIN] = 1;
term_vi.c_cc[VTIME] = 0;
+#endif
erase_char = term_vi.c_cc[VERASE];
tcsetattr(0, TCSANOW, &term_vi);
}
}
charcnt = 0;
// FIXIT- use the correct umask()
- fd = open((char *) fn, (O_RDWR | O_CREAT | O_TRUNC), 0664);
+ fd = open((char *) fn, (O_WRONLY | O_CREAT | O_TRUNC), 0664);
if (fd < 0)
return (-1);
cnt = last - first + 1;