Beispiel #1
0
	void
so_write(register Char *cp, register int n)
{
	if (n <= 0)
		return;			/* catch bugs */

	if (n > TermH) {
		return;
	}

	do {
		if (*cp & LITERAL) {
			Char   *d;

			for (d = litptr + (*cp++ & ~LITERAL) * LIT_FACTOR; *d;
					d++)
				(void) putraw(*d);
		}
		else
			(void) putraw(*cp++);
		CursorH++;
	} while (--n);

	if (CursorH >= TermH) { /* wrap? */
		CursorH = 0;
		CursorV++;
		NT_WrapHorizontal();

	}
	else if(CursorH >= DisplayWindowHSize) {
		flush();
		NT_MoveToLineOrChar(CursorH,0);
	}
}
Beispiel #2
0
__interrupt void USCI0RX_ISR(void) {
	if (UCA0RXBUF == '\r') {
		putraw("\r\n", 2);
		setHasLine;
		if (needLine) {
			clearNeedLine;
			exitSleep();
		}
	}
	else if (UCA0RXBUF == '\b' || UCA0RXBUF == '\x7F') {
		if (uart_index > 0) {
		  uart_index--;
		  putraw("\b \b", 3);
		}
	}
	else if (uart_index < BUFFER_SIZE || !hasLine) {
		uart_buffer[uart_index++] = UCA0RXBUF;
		if (needChar) {
			clearNeedChar;
			exitSleep();
		}
		putraw(&UCA0RXBUF, 1);
	}
//	put("uart_index: [", 8);
//	printNum(uart_index);
//	put("]\r\n", 3);
//	put("input: [", 8);
//	printCharCode(UCA0RXBUF);
//	put("]\r\n", 3);
}
Beispiel #3
0
static usize_t ln(String* args) {
    String not_found = newstr("File not found", 16);
    // get src file
    String path = newstr(args->str, args->size);
    if (path.size == 0) {
        putraw("Source? ", 8);
        get(&path);
    }
    File* src = fopen(path);
    if (src == NULL) {
        println(not_found);
        return 1;
    }
    // get destination path & name
    putraw("Target? ", 8);
    String link_name;
    get(&path); // reusing previously consumed `path`
	Dir* parent;
	parsePath(&path, &link_name);
    parent = open_dir(&path, cwd);
    if (parent == NULL) {
    	println(not_found);
    	return 1;
    }

    return new_file(&link_name, src, parent, t_LINK);
}
Beispiel #4
0
static usize_t sh(String* args_) {
    String cmd, args;

	while (1) {
		putraw("> ", 2);

        get(&args);

        if (args.size == 0) {
			continue;
		}

        // tokenize args into cmd . ' ' . args
        // notice that `tokenize` puts `args` after the first delimiter
        // which is where args are supposed to begin
        tokenize(&args, ' ', &cmd);

        Exec* prog = (Exec*) fopenlocal(&cmd, &bin);

		if (prog == NULL) {
			println(newstr("Unknown Command", 15));
		}
		else {
            prog->content(&args);
			continue;
		}
	}
}
Beispiel #5
0
/* <crt_quit>:
 * On exit, clear the path-mark line, to set the cursor there.  We also
 * reset the scrolling margins to their default value (without keeping this
 * in our state) so that if this is called from a FLIST-SPAWN command, then
 * we can use 'crt_reset' to restore our scrolling margins.
 *
 * The 'erase' option causes the last line of the screen to be cleared.
 * If the last input was a newline, then VMS will echo this (scrolling up
 * one line on exit).  If not (e.g., CTRL/Z), then the program will exit
 * without scrolling.
 */
void	crt_quit(int erase)
{
	putraw ("\033>");		/* Exit alternate keypad mode */
	scr$set_scroll (1, lpp);
	if (erase)			/* Make a clean exit to command line */
		crt__ED (lpp, 1);
}
Beispiel #6
0
/* <crt_move>:
 * Set the cursor to the next position from which to manipulate text.
 * Note that the VMS screen routines do not (cannot really) do filtering
 * to reduce the number of cursor movement sequences emitted.  This
 * routine MUST be used for ALL cursor movement to permit it to do the
 * optimization.
 */
void	crt_move (
	int	y,			/* 1 <= y <= lpp	*/
	int	x)			/* 1 <= x <= width	*/
{
	x = max(1, min(width, x));
	y = max(1, min(lpp,   y));
	if (lasty != y || lastx != x)
	{
		register
		int	len,
			jumpx = lastx - x,
			jumpy = y - (lasty ? lasty : (y + 1)),
			crlfs = (NLflag + jumpy) << 1;
		char	sequence[20];

		/*
		 * The VMS-library routines are very dumb, not even
		 * defaulting parameters.  Use as my threshold an
		 * ANSI x3.64 cursor movement:
		 */
		if ((y >  end_margin && lasty >  end_margin)
		||  (y <= end_margin && lasty <= end_margin))
		{
			sprintf (sequence, "?[%d;%d?", y-1, x-1);
			len = strlen (sequence);
		}
		else	/* Disable CRLF if past scrolling margins */
			len = crlfs;

		if ((lasty == y) && (jumpx > 0) && (jumpx < len))
		{
			while (jumpx-- > 0)
				putraw ("\b");
		}
		else if ((1 == x) && (jumpy > 0) && (crlfs < len))
		{
			crt__NL0 (FALSE);
			while (jumpy-- > 0)
				putraw ("\r\n");
		}
		else
			scr$set_cursor (y, x);
	}
	lasty = y;
	lastx = x;
}
Beispiel #7
0
/* <crt_reset>:
 * Reset scrolling margins and graphics-rendition for ANSI terminals (which
 * may be left in funny modes by other programs).  This code is called on
 * entry to FLIST/BROWSE, and also on return from spawned subprocesses.
 */
void	crt_reset (void)
{
	int	new_w, new_l,
		adj_l, j;

	lastx = lasty = 999;	/* We don't really know where cursor is !! */
	termsize (0, &new_w, &new_l);	/* Interrogate current screen size */
	new_w	= min(v_width, new_w);
	new_l	= crt__lpp0 (min(new_l, CRT_LINES));
	if (new_w != width || new_l != lpp)
	{
		if (new_w < width)
			for (j = 0; j < lpp; crtvec[j++][new_w] = EOS);

		adj_l	= new_l - lpp;
		if (new_l > v_lpp)
		{
			bigvec = realloc(bigvec, new_l * (1+v_width));
			for (j = 0; j <= new_l; j++)
			{
				if (j >= lpp) sgrvec[j] = 0;
				crtvec[j] = &bigvec[(1+v_width) * j];
			}
		}
		for (j = lpp1; j < new_l; j++)
		{
			sgrvec[j] = 0;
			*crtvec[j] = EOS;
		}
		width	= new_w;
		lpp	= new_l;
		end_margin += adj_l;  end_margin = max(top_margin, end_margin);
		end_line   += adj_l;  end_line   = max(top_line, end_line);
	}

	crt_margin (top_margin, end_margin);	/* Scrolling margins	*/
	if (crt_ansi())
		putraw ("\033[0m\033[20l");	/* SGR, new line */
	if (crt_vt100())
		putraw ("\033[?4l");		/* smooth-scroll */
	putraw ("\033=");		/* Enter alternate Keypad mode */
}
Beispiel #8
0
static usize_t memtest(String* args) {
	char* stg = malloc(20);
	usize_t i = 0;
	for (i = 0; i < 19; i++) {
		stg[i] = '0';
	}
	stg[i] = '\0';
	putraw(stg, 19);
    free(stg);
	return 0;
}
Beispiel #9
0
void printNum(int x) {
	static const char zero = '0';
	char temp[6]; // int goes to 65536
	signed char index = 0;
	if (x < 0) {
		temp[index] = '-';
		index++;
		x = -x;
	}
	while (x >= 10) {
		temp[index] = zero + x % 10;
		x /= 10;
		index++;
	}
	temp[index] = zero + x;
	for (; index >= 0; index--) {
		putraw(temp + index, 1);
	}
	printline(NULL);
}
Beispiel #10
0
void printline(String* const str) {
	if (str != NULL) {
		putraw(str->str, str->size);
	}
	putraw("\r\n", 2);
}