Esempio n. 1
0
void shutdown( void )
{
	checksum_all();
	setuptty( 1 );
	save_statefile();
	exit( 0 );
}
Esempio n. 2
0
/*
 * Get initial state of terminal, set ospeed (for termcap routines)
 * and switch off tab expansion if necessary.
 * Called by startup() in termcap.c and after returning from ! or ^Z
 */
gettty()
{
	if (GTTY(&inittyb) == -1) 
		perror("gettty");
	if (GTTY2(&inittyb2) == -1)
		perror("gettty 2");

	curttyb = inittyb;
	curttyb2 = inittyb2;
	ospeed = O_SPEED(inittyb);

	setuptty();

	/* do not expand tabs */
	if(curttyb.tabflgs & EXTABS) {
		curttyb.tabflgs &= ~EXTABS;
		setctty();
	}
}
Esempio n. 3
0
/*
 *  Main loop
 */
int main(int argc, char *argv[]) {
	int c, n = 0;
	int warm = 0;

	xeq_init_contexts();
	load_statefile();
	if (argc > 1) {
		if (argc == 2) {
			if (strcmp(argv[1], "commands") == 0) {
				dump_commands(0);
				return 0;
			}
			if (strcmp(argv[1], "reg") == 0) {
				dump_registers();
				return 0;
			}
			if (strcmp(argv[1], "wake") == 0) {
				warm = 1;
				goto skipargs;
			}
			if (strcmp(argv[1], "opcodes") == 0) {
				dump_opcodes(stdout, 0);
				return 0;
			}
			if (strcmp(argv[1], "xref") == 0) {
				dump_opcodes(stdout, 1);
				return 0;
			}
			if (strcmp(argv[1], "constants") == 0) {
				dump_constants();
				return 0;
			}
			dump_menu("statistics", "", CATALOGUE_STATS);
			dump_menu("probability", "", CATALOGUE_PROB);
			dump_menu("clear", "", CATALOGUE_CLEAR);
			dump_menu("displ", "", CATALOGUE_DISPL);
			dump_menu("more", "", CATALOGUE_MORE);
			dump_menu("modes", "", CATALOGUE_MODE);
			dump_menu("conversions", "", CATALOGUE_CONV);
			dump_menu("constants", "# ", CATALOGUE_CONST);
		}
		for (c=0; c<65536; c++) {
			if (isDBL(c) && (c & 0xff))	/* Don't show all multi-word instructions */
				continue;
			n += dumpop(c, argc > 2);
		}
		printf("total number of opcodes %d\n", n);
		printf("\tniladic commands %d\n", NUM_NILADIC);

		for (n=c=0; c<NUM_MONADIC; c++) {
			if (monfuncs[c].mondreal != NULL) n++;
			if (monfuncs[c].mondcmplx != NULL) n++;
			if (monfuncs[c].monint != NULL) n++;
		}
		printf("\tmonadic commands %d with %d functions\n", NUM_MONADIC, n);

		for (n=c=0; c<NUM_DYADIC; c++) {
			if (dyfuncs[c].dydreal != NULL) n++;
			if (dyfuncs[c].dydcmplx != NULL) n++;
			if (dyfuncs[c].dydint != NULL) n++;
		}
		printf("\tdyadic commands %d with %d functions\n", NUM_DYADIC, n);

		for (n=c=0; c<NUM_TRIADIC; c++) {
			if (trifuncs[c].trireal != NULL) n++;
			if (trifuncs[c].triint != NULL) n++;
		}
		printf("\ttriadic commands %d with %d functions\n", NUM_TRIADIC, n);

		printf("\targument commands %d\n", NUM_RARG);
		printf("\tmultiword commands %d\n", NUM_MULTI);
		printf("\tspecial commands %d\n", NUM_SPECIAL);

		printf("\ttotal commands %u\n", dump_commands(1));
		return 0;
	}
skipargs:
	if (!warm)
		init_34s();
	State2.flags = 1;
	if (setuptty(0) == 0) {
		display();
		JustDisplayed = 0;
		while ((c = GETCHAR()) != GETCHAR_ERR && c != CH_QUIT) {
#ifdef USECURSES
			if (c == CH_TRACE) {
				State2.trace = 1 - State2.trace;
				display();
			} else if (c == CH_FLAGS) {
				State2.flags = 1 - State2.flags;
				display();
			} else if (c == CH_REFRESH) {
				clear();
				display();
			} else if (c == CH_ICOUNT) {
				instruction_count = 0;
				view_instruction_counter = 1 - view_instruction_counter;
				display();
			} else if (c == CH_PASTE) {
				paste_raw_x("123.14159265358979323846264338327950");
				c = K_UNKNOWN;
				clear();
				display();
			} else if (c == CH_COPY) {
				char buffer[66];
				const char *p = fill_buffer_from_raw_x(buffer);
				printf("%s\n", p);
				fflush(NULL);
				sleep(1);
				c = K_UNKNOWN;
			} else
#endif
			c=remap(c);
			if(c != K_UNKNOWN) {
				process_keycode(c);
				process_keycode(K_RELEASE);
			}
		}
		setuptty(1);
	}
	shutdown();
	return 0;
}