📄 main.c
字号:
head 2.1;access;symbols;locks; strict;comment @ * @;2.1date 95.10.24.15.46.14; author tsurace; state Release;branches;next 1.1;1.1date 95.10.12.19.28.27; author tsurace; state Beta;branches;next ;desc@Main program entry point/loop.@2.1log@Roll.@text@/* main.c: Initialization and main loop */
/* $Id: main.c 1.1 1995/10/12 19:28:27 tsurace Beta tsurace $ */
#include "vt.h"
#ifdef PROTOTYPES
static void load_startup_file(int, char **);
void main_loop(void);
int io_cycle(void);
#else
static void load_startup_file();
void main_loop();
#endif
Estate *events = NULL, *gen_read = NULL, *gen_high = NULL, *gen_low = NULL;
extern Unode rmt_ring, *cur_rmt;
extern String kin;
extern int curs_loc;
extern int break_pending, console_pending, stop_pending, winresize_pending;
#define CURS_INPUT 0
#define CURS_ELSEWHERE 2
Unode file_ring;
Istr freader, wrapbuf;
static char *search_path[] = {
"~/main.vtc",
"~/vt/dist/main.vtc",
"~/vt/main.vtc",
"/usr/local/lib/vt/main.vtc",
NULL
};
#ifndef __WIN32__ /* Main is in the GUI */
main(argc, argv)
int argc;
char **argv;
{
if (argc > 2) {
puts("Usage: vt [startfile]");
exit(1);
}
main_init_all();
main_loop();
return 0;
}
#endif /* __WIN32__ */
/* main_init_all - set up everything */
void
main_init_all (argc, argv)
int argc;
char **argv;
{
file_ring.prev = file_ring.next = &file_ring;
file_ring.dummy = 1;
freader.rs = New(Rstr);
freader.rs->str = empty_string;
freader.rs->refs = 1;
freader.refs = 1;
wrapbuf.rs = New(Rstr);
wrapbuf.rs->str = empty_string;
wrapbuf.rs->refs = 1;
wrapbuf.refs = 1;
tty_mode(1); /* window.c */
init_array(); /* array.c */
init_wbufs(); /* string.c */
init_signals(); /* signal.c */
init_tables(); /* string.c */
init_const(); /* const.c */
init_term(); /* window.c */
init_unalloc(); /* unode.c */
init_key(); /* key.c */
init_rmt(); /* remote.c */
init_prmt(); /* prmtab.c */
init_bobj(); /* bobj.c */
init_interp(); /* interp.c */
init_screen(); /* window.c */
init_compile(); /* vtc.y */
load_startup_file(argc, argv);
}
static void load_startup_file(argc, argv)
int argc;
char **argv;
{
char *s, **p;
if (argc > 1) {
if (load_file(argv[1]) != -1)
return;
outputf("Warning: couldn't open file %s\n", argv[1]);
}
s = getenv("VTSTART");
if (s) {
if (load_file(s) != -1)
return;
outputf("Warning: couldn't open file %s\n", s);
}
for (p = search_path; *p && load_file(*p) == -1; p++);
if (!*p)
vtdie("Couldn't find startup file");
}
/* Never called in the GUI version */
void main_loop()
{
long sec, usec;
Dframe df;
df.type = F_NULL;
for (;;) {
break_pending = 0;
if (stop_pending)
stop();
if (winresize_pending)
winresize();
if (console_pending)
console();
sec = -1;
usec = 250000;
if (events) {
sec = events->timer - time((long *) NULL);
if (--sec < 0)
usec = sec = 0;
}
if (curs_loc != CURS_INPUT)
sec = 0;
if (io_check(sec, usec)) {
if (break_pending) {
/* Quarter-second max delay next cycle */
curs_loc = CURS_ELSEWHERE;
continue;
}
while (!io_cycle());
if (kin.c.l) {
process_incoming(kin.c.s);
s_term(&kin, 0);
}
} else
curs_input();
if (events && events->timer <= time((long *) NULL)
&& !break_pending)
resume(&events, &df);
}
}
int io_cycle()
{
Unode *rmt;
for (rmt = rmt_ring.next; !rmt->dummy; rmt = rmt->next) {
if (!process_remote_text(rmt))
return 0;
}
return 1;
}
void add_ioqueue(queue, estate)
Estate **queue, *estate;
{
estate->next = NULL;
for (; *queue; queue = &(*queue)->next);
*queue = estate;
}
@1.1log@Initial revision@text@d2 1a2 1/* $Id$ */@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -