Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions header.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,4 @@ extern void set_parse_state(buffer_t *, point_t);
extern void set_parse_state2(buffer_t *, point_t);
extern int parse_text(buffer_t *, point_t);
extern void resize_terminal();
extern void arguments(int argc, char **argv);
47 changes: 35 additions & 12 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,11 @@ int main(int argc, char **argv)
init_pair(ID_LINE_COMMENT, COLOR_GREEN, COLOR_BLACK); /* line comments */
init_pair(ID_SINGLE_STRING, COLOR_YELLOW, COLOR_BLACK); /* single quoted strings */
init_pair(ID_DOUBLE_STRING, COLOR_YELLOW, COLOR_BLACK); /* double quoted strings */

if (1 < argc) {
curbp = find_buffer(argv[1], TRUE);
(void) insert_file(argv[1], FALSE);
/* Save filename irregardless of load() success. */
strncpy(curbp->b_fname, argv[1], NAME_MAX);
curbp->b_fname[NAME_MAX] = '\0'; /* force truncation */
} else {
curbp = find_buffer("*scratch*", TRUE);
strncpy(curbp->b_bname, "*scratch*", STRBUF_S);
}

curbp = find_buffer("*scratch*", TRUE);
strncpy(curbp->b_bname, "*scratch*", STRBUF_S);

arguments(argc, argv);

wheadp = curwp = new_window();
one_window(curwp);
Expand All @@ -66,7 +60,7 @@ int main(int argc, char **argv)
/* allow TAB and NEWLINE, otherwise any Control Char is 'Not bound' */
if (*input > 31 || *input == 10 || *input == 9)
insert();
else {
else {
flushinp(); /* discard without writing in buffer */
msg("Not bound");
}
Expand All @@ -81,6 +75,35 @@ int main(int argc, char **argv)
return 0;
}

void arguments(int argc, char **argv)
{
int i, ln = 0, opts = 1;
point_t p;

for (i=1; i < argc; i++) {
if (!strcmp(argv[i], "--")) {
opts = 0;
continue;
}
if (opts && argv[i][0] == '+') {
ln = atoi(argv[i]+1);
continue;
}

curbp = find_buffer(argv[i], TRUE);
(void) insert_file(argv[i], FALSE);
/* Save filename irregardless of load() success. */
strncpy(curbp->b_fname, argv[i], NAME_MAX);
curbp->b_fname[NAME_MAX] = '\0'; /* force truncation */

if (ln > 0) {
p = line_to_point(ln);
if (p != -1) curbp->b_point = p;
ln = 0;
}
}
}

void fatal(char *msg)
{
if (curscr != NULL) {
Expand Down