PRIVATE int cmd_edit(struct comal_line *line) { char buf[MAX_LINELEN]; char *buf2; int result = 0; long nr = line->lc.twonum.num1; long to = line->lc.twonum.num2; struct comal_line *work; struct comal_line *aline; while (result == 0) { if (nr > to || nr < 0) return 0; /* nr<0 after nr++ at MAXINT */ work = search_line(nr, 0); if (!work) return 0; nr = work->ld->lineno + 1; buf2 = buf; line_list(&buf2, work); if (sys_edit(MSG_DIALOG, buf, MAX_LINELEN, 10)) return 0; aline = crunch_line(buf); result = process_comal_line(aline); } return result; }
PRIVATE int cmd_auto(struct comal_line *line) { char buf[MAX_LINELEN]; char *buf2; int result = 0; int direct_cmd = 0; long nr = line->lc.twonum.num1; long step = line->lc.twonum.num2; struct comal_line *work; struct comal_line *aline; while (!direct_cmd) { if (nr < 0) return 0; /* nr<0 after nr+=step past MAXINT */ work = search_line(nr, 1); if (work) { buf2 = buf; line_list(&buf2, work); } else sprintf(buf, "%9ld ", nr); if (sys_edit(MSG_DIALOG, buf, MAX_LINELEN, 11)) return 0; aline = crunch_line(buf); direct_cmd = !aline->ld; result = process_comal_line(aline); nr += step; } return result; }
RichTextLineList combine_lines (std::wstring &str, const RichTextLineC *linec, size_t nlines) { str.clear (); RichTextLineList line_list (nlines); RichTextLineList::iterator it = line_list.begin (); for (; nlines; --nlines) { it->id = linec->id; size_t len = wcslen (linec->text); it->offset = str.length (); it->len = len; it->screen_wid = ucs_width (linec->text, len); str.append (linec->text, len); ++linec; ++it; } return line_list; }
PRIVATE void cmd_list_horse(struct string *filename, long from, long to) { char buf[MAX_LINELEN]; char *buf2; FILE *listfile; struct comal_line *work = curenv->progroot; if (filename) { listfile = fopen(filename->s, "wt"); if (!listfile) run_error(OPEN_ERR, "File open error %s", sys_errlist[errno]); setvbuf(listfile, NULL, _IOFBF, TEXT_BUFSIZE); } else { listfile = NULL; sys_setpaged(1); } while (work && work->ld->lineno < from) work = work->ld->next; while (work && work->ld->lineno <= to) { if (sys_escape()) { my_printf(MSG_DIALOG, 1, "Escape"); break; } buf2 = buf; line_list(&buf2, work); if (listfile) fprintf(listfile, "%s\n", buf); else my_printf(MSG_DIALOG, 1, "%s", buf); work = work->ld->next; } if (listfile) fclose(listfile); else sys_setpaged(0); }
PRIVATE void cmd_env_list() { struct env_list *walk = env_root; char buf[MAX_LINELEN]; char *buf2; while (walk) { if (walk->env->progroot) { buf2 = buf; line_list(&buf2, walk->env->progroot); } else strcpy(buf, " <No program>"); my_printf(MSG_DIALOG, 1, "Environment %s%s:", walk->env->envname, walk->env == curenv ? " [current]" : ""); my_printf(MSG_DIALOG, 1, buf); walk = walk->next; } }