Exemplo n.º 1
0
void scroll( short n )
{
	register row, col;

	if (!OPEN) return;

	col = 0;
	for ( row = 0; row < (HEIGHT-1); row++ )
		copy_row( WIDTH, (short *)&XCHAR(row+1,col), (short *)&CHAR(row,col), (short *)&XCHAR(row,col) );

//		for ( col = 0; col < WIDTH; col++ )
//		{
//			CHAR( row, col ) = XCHAR( row+1, col );
//			ATTR( row, col ) = XATTR( row+1, col );
//			XCHAR( row, col ) = XCHAR( row+1, col );
//			XATTR( row, col ) = XATTR( row+1, col );
//		}

	for ( col = 0; col < WIDTH; col++ )
	{
		CHAR( HEIGHT-1, col ) = ' ';
		ATTR( HEIGHT-1, col ) = XATTR( HEIGHT-1, col );
		XCHAR( HEIGHT-1, col ) = ' ';
	}

}
Exemplo n.º 2
0
void drawbox(short n)
{
	short row, col;

	if (!OPEN) return;

	for (row=0; row <HEIGHT; row++ )    {
		CHAR( row, -1 ) = 179;
		CHAR( row, WIDTH ) = 179;
		XCHAR( row, -1 ) = 179;
		XCHAR( row, WIDTH ) = 179;
	}

	for (col=0; col < WIDTH; col++ )  {
		CHAR( -1, col ) = 196;
		CHAR( HEIGHT, col ) = 196;
		XCHAR( -1, col ) = 196;
		XCHAR( HEIGHT, col ) = 196;
	}

	CHAR( -1,-1 ) = 218;
	CHAR( -1, WIDTH ) = 191;
	CHAR( HEIGHT, -1 ) = 192;
	CHAR( HEIGHT, WIDTH ) = 217;
	XCHAR( -1,-1 ) = 218;
	XCHAR( -1, WIDTH ) = 191;
	XCHAR( HEIGHT, -1 ) = 192;
	XCHAR( HEIGHT, WIDTH ) = 217;

}
Exemplo n.º 3
0
void mputc( short n, char c )
{
	if (!OPEN) return;

//	if (keyd_pressed[KEY_BACKSP]) 
//		mono_int_3();

	switch (c)
	{
	case 8:
		if (CCOL > 0) CCOL--;
		break;
	case 9:
		CHAR( CROW, CCOL ) = ' ';
		ATTR( CROW, CCOL ) = XATTR( CROW, CCOL );
		XCHAR( CROW, CCOL ) = ' ';
		CCOL++;
		while (CCOL % 4) {
			CHAR( CROW, CCOL ) = ' ';
			ATTR( CROW, CCOL ) = XATTR( CROW, CCOL );
			XCHAR( CROW, CCOL ) = ' ';
			CCOL++;
		}
		break;
	case 10:
	case 13:
		CCOL = 0;
		CROW++;
		break;
	default:
		CHAR( CROW, CCOL ) = c;
		ATTR( CROW, CCOL ) = XATTR( CROW, CCOL );
		XCHAR( CROW, CCOL ) = c;
		CCOL++;
	}

	if ( CCOL >= WIDTH )    {
		CCOL = 0;
		CROW++;
	}
	if ( CROW >= HEIGHT )   {
		CROW--;
		scroll(n);
	}

	msetcursor( ROW+CROW, COL+CCOL );

}
Exemplo n.º 4
0
void mopen( short n, short row, short col, short width, short height, char * title )
{
//	if (n==0) return;

	if (! mono_present()) return;	//error! no mono card

	if (OPEN) mclose(n);

	OPEN = 1;
	ROW = row;
	COL = col;
	WIDTH = width;
	HEIGHT = height;

	for (row=-1; row<HEIGHT+1; row++ )
		for (col=-1; col<WIDTH+1; col++ )  {
			CHAR(row,col) = 32;
			ATTR(row,col) = 7;
			XCHAR(row,col) = 32;
			XATTR(row,col) = 7;
		}

	drawbox(n);
	CROW=-1; CCOL=0;
	mprintf( n, title );
	CROW=0; CCOL=0;
	msetcursor( ROW+CROW, COL+CCOL );

}
Exemplo n.º 5
0
/*
	FUNCTION: InitNewFont(LOGFONT, COLORREF)

	PURPOSE: Prepares a new font for use in the terminal screen

	PARAMETERS:
		LogFont		- New logical font for the screen
		rgbColour	- New colour for screen painting

*/
void InitNewFont(LOGFONT LogFont, COLORREF rgbColour) {
	TEXTMETRIC	tm;
	HDC			hDC;

	// If an old font exits, delete it
	if (HSCREENFONT(TermInfo)) {
		DeleteObject(HSCREENFONT(TermInfo));
	}

	LFSCREENFONT(TermInfo) = LogFont;
	HSCREENFONT(TermInfo) = CreateFontIndirect(&(LFSCREENFONT(TermInfo)));
	FGCOLOUR(TermInfo) = rgbColour;

	hDC = GetDC(ghWndMain);
	SelectObject(hDC, HSCREENFONT(TermInfo));
	GetTextMetrics(hDC, &tm);
	ReleaseDC(ghWndMain, hDC);

	// Character width and height
	XCHAR(TermInfo) = tm.tmAveCharWidth;
	YCHAR(TermInfo) = tm.tmHeight + tm.tmExternalLeading;

	// Set the terminal height and width based on the current font
	XSIZE(TermInfo) = tm.tmAveCharWidth * MAXCOLS;
	YSIZE(TermInfo) = (tm.tmHeight + tm.tmExternalLeading) * MAXROWS;

}
Exemplo n.º 6
0
void mrefresh(short n)
{
	short row, col;

	if (!OPEN) return;

	for (row=-1; row<HEIGHT+1; row++ )
		for (col=-1; col<WIDTH+1; col++ )  {
			CHAR(row,col) = XCHAR(row,col);
			ATTR(row,col) = XATTR(row,col);
		}

	msetcursor( ROW+CROW, COL+CCOL );

}
Exemplo n.º 7
0
void mclear( short n )
{
	short row, col;

	if (!OPEN) return;

	for (row=0; row<HEIGHT; row++ )
		for (col=0; col<WIDTH; col++ )  {
			CHAR(row,col) = 32;
			ATTR(row,col) = 7;
			XCHAR(row,col) = 32;
			XATTR(row,col) = 7;
		}
	CCOL = 0;
	CROW = 0;
}
Exemplo n.º 8
0
/*-----------------------------------------------------------------------------*/
void InitFont() {
	TEXTMETRIC	tm;
	HDC			hdc;

	hdc = GetDC(ghwndMain);
	
	// set the font to be the default fixed-pitch font
	SelectObject(hdc, CreateFont(0, 0, 0, 0, 0, 0, 0, 0,
		DEFAULT_CHARSET, 0, 0, 0, FIXED_PITCH, NULL));

	GetTextMetrics(hdc, &tm);
	ReleaseDC(ghwndMain, hdc);

	// get text width & height
	XCHAR(TTYInfo) = tm.tmAveCharWidth;
	YCHAR(TTYInfo) = tm.tmHeight + tm.tmExternalLeading;
}
Exemplo n.º 9
0
static void
find_context (struct buffer *buf, Bufpos pt)
{
  /* This function can GC */
#ifndef emacs
#ifdef UTF2000
  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->syntax_table);
#else
  Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
#endif
  Lisp_Object syntaxtab = buf->syntax_table;
#endif
  Emchar prev_c, c;
  int prev_syncode, syncode;
  Bufpos target = pt;
  setup_context_cache (buf, pt);
  pt = context_cache.cur_point;

  SCS_STATISTICS_SET_FUNCTION (scs_find_context);
  SETUP_SYNTAX_CACHE (pt - 1, 1);
  if (pt > BUF_BEGV (buf))
    {
      c = BUF_FETCH_CHAR (buf, pt - 1);
      syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);
    }
  else
    {
      c = '\n'; /* to get bol_context_cache at point-min */
      syncode = Swhitespace;
    }

  for (; pt < target; pt++, context_cache.cur_point = pt)
    {
      if (context_cache.needs_its_head_reexamined)
	{
	  if (context_cache.depth == 0
	      && context_cache.context == context_none)
	    {
	      /* We've found an anchor spot.
		 Try to put the start of defun within 6000 chars of
		 the target, and the end of defun as close as possible.
		 6000 is also arbitrary but tries to strike a balance
		 between two conflicting pulls when dealing with a
		 file that has lots of stuff sitting outside of a top-
		 level form:

		 a) If you move past the start of defun, you will
		    have to recompute defun, which in this case
		    means that start of defun goes all the way back
		    to the beginning of the file; so you want
		    to set start of defun a ways back from the
		    current point.
		 b) If you move a line backwards but within start of
		    defun, you have to move back to start of defun;
		    so you don't want start of defun too far from
		    the current point.
		 */
	      if (target - context_cache.start_point > 6000)
		context_cache.start_point = pt;
	      context_cache.end_point = pt;
	      bol_context_cache = context_cache;
	    }
	}

      UPDATE_SYNTAX_CACHE_FORWARD (pt);
      prev_c = c;
      prev_syncode = syncode;
      c = BUF_FETCH_CHAR (buf, pt);
      syncode = SYNTAX_CODE_FROM_CACHE (mirrortab, c);

      if (prev_c == '\n')
	bol_context_cache = context_cache;

      if (context_cache.backslash_p)
	{
	  context_cache.backslash_p = 0;
	  continue;
	}

      switch (SYNTAX_FROM_CACHE (mirrortab, c))
	{
	case Sescape:
	  context_cache.backslash_p = 1;
	  break;

	case Sopen:
	  if (context_cache.context == context_none)
	    context_cache.depth++;
	  break;

	case Sclose:
	  if (context_cache.context == context_none)
	    context_cache.depth--;
	  break;

	case Scomment:
	  if (context_cache.context == context_none)
	    {
	      context_cache.context = context_comment;
	      context_cache.ccontext = ccontext_none;
	      context_cache.style = SINGLE_SYNTAX_STYLE (syncode);
	      if (context_cache.style == comment_style_none) ABORT ();
	    }
	  break;

	case Sendcomment:
	  if (context_cache.style != SINGLE_SYNTAX_STYLE (syncode))
	    ;
	  else if (context_cache.context == context_comment)
	    {
	      context_cache.context = context_none;
	      context_cache.style = comment_style_none;
	    }
	  else if (context_cache.context == context_block_comment &&
		   (context_cache.ccontext == ccontext_start2 ||
		    context_cache.ccontext == ccontext_end1))
	    {
	      context_cache.context = context_none;
	      context_cache.ccontext = ccontext_none;
	      context_cache.style = comment_style_none;
	    }
	  break;

	case Sstring:
          {
            if (context_cache.context == context_string &&
                context_cache.scontext == c)
	      {
		context_cache.context = context_none;
		context_cache.scontext = '\000';
	      }
            else if (context_cache.context == context_none)
	      {
		Lisp_Object stringtermobj =
		  syntax_match (syntax_cache.current_syntax_table, c);
		Emchar stringterm;

		if (CHARP (stringtermobj))
		  stringterm = XCHAR (stringtermobj);
		else
		  stringterm = c;
		context_cache.context = context_string;
		context_cache.scontext = stringterm;
		context_cache.ccontext = ccontext_none;
	      }
            break;
          }

	case Scomment_fence:
	  {
	    if (context_cache.context == context_generic_comment)
	      {
		context_cache.context = context_none;
	      }
	    else if (context_cache.context == context_none)
	      {
		context_cache.context = context_generic_comment;
		context_cache.ccontext = ccontext_none;
	      }
	    break;
	  }

	case Sstring_fence:
	  {
	    if (context_cache.context == context_generic_string)
	      {
		context_cache.context = context_none;
	      }
	    else if (context_cache.context == context_none)
	      {
		context_cache.context = context_generic_string;
		context_cache.ccontext = ccontext_none;
	      }
	    break;
	  }

	default:
	  ;
	}

      /* That takes care of the characters with manifest syntax.
	 Now we've got to hack multi-char sequences that start
	 and end block comments.
       */
      if ((SYNTAX_CODE_COMMENT_BITS (syncode) &
	   SYNTAX_SECOND_CHAR_START) &&
	  context_cache.context == context_none &&
	  context_cache.ccontext == ccontext_start1 &&
	  SYNTAX_CODES_START_P (prev_syncode, syncode) /* the two chars match */
	  )
	{
	  context_cache.ccontext = ccontext_start2;
	  context_cache.style = SYNTAX_START_STYLE (prev_syncode, syncode);
	  if (context_cache.style == comment_style_none) ABORT ();
	}
      else if ((SYNTAX_CODE_COMMENT_BITS (syncode) &
		SYNTAX_FIRST_CHAR_START) &&
	       context_cache.context == context_none &&
	       (context_cache.ccontext == ccontext_none ||
		context_cache.ccontext == ccontext_start1))
	{
	  context_cache.ccontext = ccontext_start1;
	  context_cache.style = comment_style_none; /* should be this already*/
	}
      else if ((SYNTAX_CODE_COMMENT_BITS (syncode) &
		SYNTAX_SECOND_CHAR_END) &&
	       context_cache.context == context_block_comment &&
	       context_cache.ccontext == ccontext_end1 &&
	       SYNTAX_CODES_END_P (prev_syncode, syncode) &&
	       /* the two chars match */
	       context_cache.style ==
	       SYNTAX_END_STYLE (prev_syncode, syncode)
	       )
	{
	  context_cache.context = context_none;
	  context_cache.ccontext = ccontext_none;
	  context_cache.style = comment_style_none;
	}
      else if ((SYNTAX_CODE_COMMENT_BITS (syncode) &
		SYNTAX_FIRST_CHAR_END) &&
	       context_cache.context == context_block_comment &&
#if 0
	       /* #### pre-Matt code had: */
	       (context_cache.style ==
		SYNTAX_END_STYLE (c, BUF_FETCH_CHAR (buf, pt+1))) &&
	       /* why do these differ here?! */
#endif
	       context_cache.style == SINGLE_SYNTAX_STYLE (syncode) &&
	       (context_cache.ccontext == ccontext_start2 ||
		context_cache.ccontext == ccontext_end1))
	/* check end1, to detect a repetition of the first char of a
	   comment-end sequence. ie, '/xxx foo xxx/' or '/xxx foo x/',
	   where 'x' = '*' -- mct */
	{
	  if (context_cache.style == comment_style_none) ABORT ();
	  context_cache.ccontext = ccontext_end1;
	}

      else if (context_cache.ccontext == ccontext_start1)
	{
	  if (context_cache.context != context_none) ABORT ();
	  context_cache.ccontext = ccontext_none;
	}
      else if (context_cache.ccontext == ccontext_end1)
	{
	  if (context_cache.context != context_block_comment) ABORT ();
	  context_cache.context = context_none;
	  context_cache.ccontext = ccontext_start2;
	}

      if (context_cache.ccontext == ccontext_start2 &&
	  context_cache.context == context_none)
	{
	  context_cache.context = context_block_comment;
	  if (context_cache.style == comment_style_none) ABORT ();
	}
      else if (context_cache.ccontext == ccontext_none &&
	       context_cache.context == context_block_comment)
	{
	  context_cache.context = context_none;
	}
    }

  context_cache.needs_its_head_reexamined = 0;
}
Exemplo n.º 10
0
static Lisp_Object
casify_object (enum case_action flag, Lisp_Object string_or_char,
	       Lisp_Object buffer)
{
  struct buffer *buf = decode_buffer (buffer, 0);

 retry:

  if (CHAR_OR_CHAR_INTP (string_or_char))
    {
      Ichar c;
      CHECK_CHAR_COERCE_INT (string_or_char);
      c = XCHAR (string_or_char);
      if (flag == CASE_DOWN)
	{
	  c = DOWNCASE (buf, c);
	}
      else if (flag == CASE_UP)
	{
	  c = UPCASE (buf, c);
	}
      else
	{
	  c = CANONCASE (buf, c);
	}

      return make_char (c);
    }

  if (STRINGP (string_or_char))
    {
      Lisp_Object syntax_table = buf->mirror_syntax_table;
      Ibyte *storage =
	alloca_ibytes (XSTRING_LENGTH (string_or_char) * MAX_ICHAR_LEN);
      Ibyte *newp = storage;
      Ibyte *oldp = XSTRING_DATA (string_or_char);
      Ibyte *endp = oldp + XSTRING_LENGTH (string_or_char);
      int wordp = 0, wordp_prev;

      while (oldp < endp)
	{
	  Ichar c = itext_ichar (oldp);
	  switch (flag)
	    {
	    case CASE_UP:
	      c = UPCASE (buf, c);
	      break;
	    case CASE_DOWN:
	      c = DOWNCASE (buf, c);
	      break;
	    case CASE_CANONICALIZE:
	      c = CANONCASE (buf, c);
	      break;
	    case CASE_CAPITALIZE:
	    case CASE_CAPITALIZE_UP:
	      wordp_prev = wordp;
	      wordp = WORD_SYNTAX_P (syntax_table, c);
	      if (!wordp) break;
	      if (wordp_prev)
		{
		  if (flag == CASE_CAPITALIZE)
		    c = DOWNCASE (buf, c);
		}
	      else
		c = UPCASE (buf, c);
	      break;
	    }

	  newp += set_itext_ichar (newp, c);
	  INC_IBYTEPTR (oldp);
	}

      return make_string (storage, newp - storage);
    }

  string_or_char = wrong_type_argument (Qchar_or_string_p, string_or_char);
  goto retry;
}
Exemplo n.º 11
0
/* Lisp functions definition */

DEFUN ("canna-key-proc", Fcanna_key_proc, 1, 1, 0, /*
Translate a key input to a set of strings.  The strings contain both
well-formed string and intermediate result to show the translation
information to a user.  Converted strings are stored in specific
variables.
*/
       (ch))
{
  jrKanjiStatus ks;
  int len;

  CHECK_CHAR_COERCE_INT (ch);
  len = jrKanjiString (0, XCHAR (ch), key_buffer, KEYTOSTRSIZE, &ks);
  return storeResults (key_buffer, len, &ks);
}

static Lisp_Object
storeResults (unsigned char *buf, int len, jrKanjiStatus *ks)
{
  Lisp_Object val = Qnil;

  if (len < 0)
    { /* Error detected */
      val = make_string ((unsigned char*) jrKanjiError, strlen (jrKanjiError));
    }
  else
    {
      /* 確定した文字列 (the confirmed string) */
Exemplo n.º 12
0
/*-----------------------------------------------------------------------------

FUNCTION: OutputABufferToWindow(HWND, char *, DWORD)

PURPOSE: Updates TTY Buffer with characters just received.

PARAMETERS:
    hTTY     - handle to the TTY child window
    lpBuf    - address of data buffer
    dwBufLen - size of data buffer

HISTORY:   Date       Author      Comment
            5/ 8/91   BryanW      Wrote it
           10/27/95   AllenD      Modified for MTTTY Sample

-----------------------------------------------------------------------------*/
void OutputABufferToWindow(HWND hTTY, char * lpBuf, DWORD dwBufLen)
{
    RECT rect;

    /*
        update screen buffer with new buffer
        need to do a character by character check
        for special characters
    */
    int i;

    for ( i = 0 ; i < (int) dwBufLen; i++) {
        switch (lpBuf[ i ]) {
            case ASCII_BEL:                // BELL CHAR
                MessageBeep( 0 ) ;
                break ;

            case ASCII_BS:                 // Backspace CHAR
                if (COLUMN( TTYInfo ) > 0)
                   COLUMN( TTYInfo ) -- ;
                break ;

            case ASCII_CR:                 // Carriage Return
                COLUMN( TTYInfo ) = 0 ;
                if (!NEWLINE( TTYInfo ))
                    break;

                //
                // FALL THROUGH
                //

            case ASCII_LF:                 // Line Feed
                if (ROW( TTYInfo )++ == MAXROWS - 1)
                {
                    MoveMemory( (LPSTR) (SCREEN( TTYInfo )),
                                  (LPSTR) (SCREEN( TTYInfo ) + MAXCOLS),
                                  (MAXROWS - 1) * MAXCOLS ) ;
                    FillMemory((LPSTR) (SCREEN( TTYInfo ) + (MAXROWS - 1) * MAXCOLS),
                                  MAXCOLS,  ' ' ) ;
                    InvalidateRect( hTTY, NULL, FALSE ) ;
                    ROW( TTYInfo )-- ;
                }
                break ;

            default:                       // standard character
                SCREENCHAR(TTYInfo, COLUMN(TTYInfo), ROW(TTYInfo)) = lpBuf[ i ];

                rect.left = (COLUMN( TTYInfo ) * XCHAR( TTYInfo )) -
                            XOFFSET( TTYInfo ) ;
                rect.right = rect.left + XCHAR( TTYInfo ) ;
                rect.top = (ROW( TTYInfo ) * YCHAR( TTYInfo )) -
                           YOFFSET( TTYInfo ) ;
                rect.bottom = rect.top + YCHAR( TTYInfo ) ;
                InvalidateRect( hTTY, &rect, FALSE ) ;

                // 
                // Line wrap
                //
                if (COLUMN( TTYInfo ) < MAXCOLS-1 )
                    COLUMN( TTYInfo )++ ;
                else if (AUTOWRAP( TTYInfo ))
                    OutputABufferToWindow(hTTY, "\r\n", 2 ) ;
                
                break;
        }
    }

    MoveTTYCursor(hTTY);
    return;
}
Exemplo n.º 13
0
static Lisp_Object
casify_object(enum case_action flag, Lisp_Object string_or_char,
	      Lisp_Object buffer)
{
	struct buffer *buf = decode_buffer(buffer, 0);

      retry:

	if (CHAR_OR_CHAR_INTP(string_or_char)) {
		Emchar c;
		CHECK_CHAR_COERCE_INT(string_or_char);
		c = XCHAR(string_or_char);
		c = (flag == CASE_DOWN) ? DOWNCASE(buf, c) : UPCASE(buf, c);
		return make_char(c);
	}

	if (STRINGP(string_or_char)) {
		Lisp_Char_Table *syntax_table =
		    XCHAR_TABLE(buf->mirror_syntax_table);
		Bufbyte *storage =
		    alloca_array(Bufbyte,
				 XSTRING_LENGTH(string_or_char) *
				 MAX_EMCHAR_LEN);
		Bufbyte *newp = storage;
		Bufbyte *oldp = XSTRING_DATA(string_or_char);
		int wordp = 0, wordp_prev;

		while (*oldp) {
			Emchar c = charptr_emchar(oldp);
			switch (flag) {
			case CASE_UP:
				c = UPCASE(buf, c);
				break;
			case CASE_DOWN:
				c = DOWNCASE(buf, c);
				break;
			case CASE_CAPITALIZE:
			case CASE_CAPITALIZE_UP:
				wordp_prev = wordp;
				wordp = WORD_SYNTAX_P(syntax_table, c);
				if (!wordp)
					break;
				if (wordp_prev) {
					if (flag == CASE_CAPITALIZE)
						c = DOWNCASE(buf, c);
				} else
					c = UPCASE(buf, c);
				break;

				/* can't happen */
			default:
				/* abort()? */
				break;
			}

			newp += set_charptr_emchar(newp, c);
			INC_CHARPTR(oldp);
		}

		return make_string(storage, newp - storage);
	}

	string_or_char = wrong_type_argument(Qchar_or_string_p, string_or_char);
	goto retry;
}