📄 output.c
字号:
/* * * debugger * */#include "defs.h"#include "fns.h"int printcol = 0;int infile = STDIN;int maxpos = MAXPOS;Biobuf stdout;voidprintc(int c){ dprint("%c", c);}/* was move to next f1-sized tab stop; now just print a tab */inttconv(Fmt *f){ return fmtstrcpy(f, "\t");}voidflushbuf(void){ if (printcol != 0) printc(EOR);}voidprints(char *s){ dprint("%s",s);}voidnewline(void){ printc(EOR);}#define MAXIFD 5struct { int fd; int r9;} istack[MAXIFD];int ifiledepth;voidiclose(int stack, int err){ if (err) { if (infile) { close(infile); infile=STDIN; } while (--ifiledepth >= 0) if (istack[ifiledepth].fd) close(istack[ifiledepth].fd); ifiledepth = 0; } else if (stack == 0) { if (infile) { close(infile); infile=STDIN; } } else if (stack > 0) { if (ifiledepth >= MAXIFD) error("$<< nested too deeply"); istack[ifiledepth].fd = infile; ifiledepth++; infile = STDIN; } else { if (infile) { close(infile); infile=STDIN; } if (ifiledepth > 0) { infile = istack[--ifiledepth].fd; } }}voidoclose(void){ flushbuf(); Bterm(&stdout); Binit(&stdout, 1, OWRITE);}voidredirout(char *file){ int fd; if (file == 0){ oclose(); return; } flushbuf(); if ((fd = open(file, 1)) >= 0) seek(fd, 0L, 2); else if ((fd = create(file, 1, 0666)) < 0) error("cannot create"); Bterm(&stdout); Binit(&stdout, fd, OWRITE);}voidendline(void){ if (maxpos <= printcol) newline();}voidflush(void){ Bflush(&stdout);}intdprint(char *fmt, ...){ int n, w; char *p; char buf[4096]; Rune r; va_list arg; if(mkfault) return -1; va_start(arg, fmt); n = vseprint(buf, buf+sizeof buf, fmt, arg) - buf; va_end(arg);//Bprint(&stdout, "[%s]", fmt); Bwrite(&stdout, buf, n); for(p=buf; *p; p+=w){ w = chartorune(&r, p); if(r == '\n') printcol = 0; else printcol++; } return n;}voidoutputinit(void){ Binit(&stdout, 1, OWRITE); fmtinstall('t', tconv);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -