📄 sc.c
字号:
(void) sprintf(line,"define [string range] \""); linelim = strlen(line); startshow(); insert_mode(); modflg++; break; case 'u': (void) sprintf(line,"undefine [range] "); linelim = strlen(line); insert_mode(); modflg++; break; case 's': if(are_ranges()) { FILE *f; int pid; char px[MAXCMD] ; char *pager; (void) strcpy(px, "| sort | "); if(!(pager = getenv("PAGER"))) pager = DFLT_PAGER; (void) strcat(px,pager); f = openout(px, &pid); if (!f) { error("Can't open pipe to sort"); break; } list_range(f); closeout(f, pid); } else error("No ranges defined"); break; case ESC: case ctl('g'): break; default: error("Invalid region command"); break; } break; /* * Row/column commands: */ case 'i': case 'a': case 'd': case 'p': case 'v': case 'z': case 's': { register rcqual; if (! (rcqual = get_rcqual (c))) { error ("Invalid row/column command"); break; } error (""); /* clear line */ if ( rcqual == ESC || rcqual == ctl('g')) break; switch (c) { case 'i': if (rcqual == 'r') insertrow(arg); else opencol(curcol, arg); break; case 'a': if (rcqual == 'r') while (arg--) duprow(); else while (arg--) dupcol(); break; case 'd': if (rcqual == 'r') deleterow(arg); else closecol(curcol, arg); break; case 'p': while (arg--) pullcells(rcqual); break; case 'v': if (rcqual == 'r') rowvalueize(arg); else colvalueize(arg); modflg = 1; break; case 'z': if (rcqual == 'r') hiderow(arg); else hidecol(arg); break; case 's': /* special case; no repeat count */ if (rcqual == 'r') rowshow_op(); else colshow_op(); break; } break; } case '$': { register struct ent *p; curcol = maxcols - 1; while (!VALID_CELL(p, currow, curcol) && curcol > 0) curcol--; break; } case '#': { register struct ent *p; currow = maxrows - 1; while (!VALID_CELL(p, currow, curcol) && currow > 0) currow--; break; } case 'w': { register struct ent *p; while (--arg>=0) { do { if (curcol < maxcols - 1) curcol++; else { if (currow < maxrows - 1) { while(++currow < maxrows - 1 && row_hidden[currow]) /* */; curcol = 0; } else { error("At end of table"); break; } } } while(col_hidden[curcol] || !VALID_CELL(p, currow, curcol)); } break; } case 'b': { register struct ent *p; while (--arg>=0) { do { if (curcol) curcol--; else { if (currow) { while(--currow && row_hidden[currow]) /* */; curcol = maxcols - 1; } else { error ("At start of table"); break; } } } while(col_hidden[curcol] || !VALID_CELL(p, currow, curcol)); } break; } case '^': currow = 0; break; case '?': help(); break; case '"': (void) sprintf (line, "label %s = \"", v_name(currow, curcol)); linelim = strlen (line); insert_mode(); break; case '<': (void) sprintf (line, "leftstring %s = \"", v_name(currow, curcol)); linelim = strlen (line); insert_mode(); break; case '>': (void) sprintf (line, "rightstring %s = \"", v_name(currow, curcol)); linelim = strlen (line); insert_mode(); break; case 'e': editv (currow, curcol); edit_mode(); break; case 'E': edits (currow, curcol); edit_mode(); break; case 'f': if (arg == 1) (void) sprintf (line, "format [for column] %s ", coltoa(curcol)); else { (void) sprintf(line, "format [for columns] %s:", coltoa(curcol)); (void) sprintf(line+strlen(line), "%s ", coltoa(curcol+arg-1)); } error("Current format is %d %d", fwidth[curcol],precision[curcol]); linelim = strlen (line); insert_mode(); break; case 'g': (void) sprintf (line, "goto [v] "); linelim = strlen (line); insert_mode(); break; case 'P': (void) sprintf (line, "put [\"dest\" range] \""); if (*curfile) error ("Default path is \"%s\"",curfile); linelim = strlen (line); insert_mode(); break; case 'M': (void) sprintf (line, "merge [\"source\"] \""); linelim = strlen (line); insert_mode(); break; case 'R': if (mdir) (void) sprintf (line,"merge [\"macro_file\"] \"%s/", mdir); else (void) sprintf (line,"merge [\"macro_file\"] \""); linelim = strlen (line); insert_mode(); break; case 'D': (void) sprintf (line, "mdir [\"macro_directory\"] \""); linelim = strlen (line); insert_mode(); break; case 'G': (void) sprintf (line, "get [\"source\"] \""); if (*curfile) error ("Default file is \"%s\"",curfile); linelim = strlen (line); insert_mode(); break; case 'W': (void) sprintf (line, "write [\"dest\" range] \""); linelim = strlen (line); insert_mode(); break; case 'S': /* set options */ (void) sprintf (line, "set "); error("Options: byrows, bycols, iterations=n, tblstyle=(0|tbl|latex|tex)"); linelim = strlen (line); insert_mode(); break; case 'T': /* tbl output */ (void) sprintf (line, "tbl [\"dest\" range] \""); linelim = strlen (line); insert_mode(); break; case 'x': { register struct ent **pp; register int c1; flush_saved(); if(calc_order == BYROWS) { for (c1 = curcol; arg-- && c1 < maxcols; c1++) { pp = ATBL(tbl, currow, c1); if (*pp) { free_ent(*pp); *pp = (struct ent *)0; } } } else { for (c1 = currow; arg-- && c1 < maxrows; c1++) { pp = ATBL(tbl, c1, curcol); if (*pp) { free_ent(*pp); *pp = (struct ent *)0; } } } sync_refs(); modflg++; FullUpdate++; } break; case 'Q': case 'q': running = 0; break; case 'h': backcol(arg); break; case 'j': forwrow(arg); break; case 'k': backrow(arg); break; case ' ': case 'l': forwcol(arg); break; case 'm': savedrow = currow; savedcol = curcol; break; case 'c': { register struct ent *p = *ATBL(tbl, savedrow, savedcol); register c1; register struct ent *n; if (!p) break; FullUpdate++; modflg++; for (c1 = curcol; arg-- && c1 < maxcols; c1++) { n = lookat (currow, c1); (void) clearent(n); copyent( n, p, currow - savedrow, c1 - savedcol); } break; } default: if ((toascii(c)) != c) error ("Weird character, decimal %d\n", (int) c); else error ("No such command (%c)", c); break; } edistate = nedistate; arg = narg; } /* while (running) */ inloop = modcheck(" before exiting"); } /* while (inloop) */ deraw(); endwin();#ifdef VMS /* Unit VMS "fixes" exit we should say 1 here */ exit(1);#else exit(0);#endif /*NOTREACHED*/}voidstartshow(){ showrange = 1; showsr = currow; showsc = curcol;}voidshowdr(){ int minsr, minsc, maxsr, maxsc; minsr = showsr < currow ? showsr : currow; minsc = showsc < curcol ? showsc : curcol; maxsr = showsr > currow ? showsr : currow; maxsc = showsc > curcol ? showsc : curcol; (void) sprintf (line+linelim,"%s", r_name(minsr, minsc, maxsr, maxsc));}voidsetorder(i)int i;{ if((i == BYROWS)||(i == BYCOLS)) calc_order = i; else error("Not yet implemented");}voidsetauto(i)int i;{ autocalc = i;}#ifdef VMSgoraw(){ VMS_read_raw = 1; FullUpdate++;}deraw(){ (void) move (LINES - 1, 0); (void) clrtoeol(); (void) refresh(); VMS_read_raw = 0;}#else /* VMS */voidgoraw(){#if SYSV2 || SYSV3 fixterm();#else /* SYSV2 || SYSV3 */ cbreak(); nonl(); noecho ();#endif /* SYSV2 || SYSV3 */ kbd_again(); (void) clear(); FullUpdate++;}voidderaw(){ (void) move (LINES - 1, 0); (void) clrtoeol(); (void) refresh();#if SYSV2 || SYSV3 resetterm();#else nocbreak(); nl(); echo();#endif resetkbd();}#endif /* VMS */voidsignals(){#ifdef SIGVOID void quit(); void time_out(); void dump_me();#else int quit(); int time_out(); int dump_me();#endif (void) signal(SIGINT, SIG_IGN); (void) signal(SIGQUIT, dump_me); (void) signal(SIGPIPE, quit); (void) signal(SIGTERM, quit); (void) signal(SIGALRM, time_out); (void) signal(SIGFPE, quit); (void) signal(SIGBUS, quit);}#ifdef SIGVOIDvoid#endifquit(){ diesave(); deraw(); resetkbd(); endwin(); exit(1);}#ifdef SIGVOIDvoid#endifdump_me(){ diesave(); deraw(); abort();}/* try to save the current spreadsheet if we can */diesave(){ char path[PATHLEN]; if (modcheck(" before Spreadsheet dies") == 1) { sprintf(path, "~/SC.SAVE"); if (writefile(path, 0, 0, maxrow, maxcol) < 0) if (writefile("/tmp/SC.SAVE", 0, 0, maxrow, maxcol) < 0) error("Couldn't save current spreadsheet, Sorry"); }}intmodcheck(endstr)char *endstr;{ if (modflg && curfile[0]) { int yn_ans; char lin[100]; (void) sprintf (lin,"File \"%s\" is modified, save%s? ",curfile,endstr); if ((yn_ans = yn_ask(lin)) < 0) return(1); else if (yn_ans == 1) { if (writefile(curfile, 0, 0, maxrow, maxcol) < 0) return (1); } } else if (modflg) { int yn_ans; if ((yn_ans = yn_ask("Do you want a chance to save the data? ")) < 0) return(1); else return(yn_ans); } return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -