Exemplo n.º 1
0
static void buttonDrawIt(newtComponent co, int active, int pushed) {
    struct button * bu = co->data;

    if (!co->isMapped) return;

    SLsmg_set_color(NEWT_COLORSET_BUTTON);

    if (bu->compact) {
	if (!active)
	    SLsmg_set_color(NEWT_COLORSET_COMPACTBUTTON);
	else if (SLtt_Use_Ansi_Colors)
	    SLsmg_set_color(NEWT_COLORSET_BUTTON);
	else
	    SLsmg_set_color(NEWT_COLORSET_ACTBUTTON);
	newtGotorc(co->top+ pushed, co->left + 1 + pushed);
	SLsmg_write_char('<');
	SLsmg_write_string(bu->text);
	SLsmg_write_char('>');
    } else {
	if (pushed) {
	    SLsmg_set_color(NEWT_COLORSET_BUTTON);
	    newtDrawBox(co->left + 1, co->top + 1, co->width - 1, 3, 0);

	    SLsmg_set_color(NEWT_COLORSET_WINDOW);
	    newtClearBox(co->left, co->top, co->width, 1);
	    newtClearBox(co->left, co->top, 1, co->height);
	} else {
	    newtDrawBox(co->left, co->top, co->width - 1, 3, 1);
	}

	buttonDrawText(co, active, pushed);
    }
    /* put cursor at beginning of text for better accessibility */
    newtGotorc(co->top + (bu->compact ? 0 : 1) + pushed, co->left + 1 + pushed + 1);
}
Exemplo n.º 2
0
static void ctl_panning(int ch, int val)
{
  if(ch >= 16)
    return;
  if (!ctl.trace_playing)
    return;
  SLsmg_gotorc(8+ch, SLtt_Screen_Cols-8);
  if (val==NO_PANNING)
    SLsmg_write_string("   ");
  else if (val<5)
    SLsmg_write_string(" L ");
  else if (val>123)
    SLsmg_write_string(" R ");
  else if (val>60 && val<68)
    SLsmg_write_string(" C ");
  else
    {
      /* wprintw(dftwin, "%+02d", (100*(val-64))/64); */
      val = (100*(val-64))/64; /* piss on curses */
      if (val<0)
      {
        SLsmg_write_char('-');
        val=-val;
      }
      else SLsmg_write_char('+');
      SLsmg_printf("%02d", val);
    }
}
Exemplo n.º 3
0
static void ctl_note(int status, int channel, int note, int velocity)
{
  int xl;
  if(channel >= 16)
      return;
  if (!ctl.trace_playing)
    return;
  xl=note%(SLtt_Screen_Cols-24);
  SLsmg_gotorc(8+channel,xl+3);
  switch(status)
    {
    case VOICE_DIE:
      SLsmg_write_char(',');
      break;
    case VOICE_FREE:
      SLsmg_write_char('.');
      break;
    case VOICE_ON:
        SLsmg_bold();
      SLsmg_write_char('0'+(10*velocity)/128);
      SLsmg_normal();
      break;
    case VOICE_OFF:
    case VOICE_SUSTAINED:
      SLsmg_write_char('0'+(10*velocity)/128);
      break;
    }
}
Exemplo n.º 4
0
static void write_color_chars (SLcurses_Cell_Type *p, unsigned int len)
{
   int color = -1;
   unsigned int i;
   for (i = 0; i < len; i++)
     {
	SLwchar_Type ch;
	int this_color;
	int j;
	if (p[i].main == SLCURSES_NULLATTR)
	  continue;	/* prev char was multicolumn */
	ch = SLCURSES_EXTRACT_CHAR(p[i].main);
	this_color = SLCURSES_EXTRACT_COLOR(p[i].main);
	if (this_color != color)
	  {
	     SLsmg_set_color (this_color);
	     color = this_color;
	  }
	if (p[i].is_acs)
	  SLsmg_set_char_set (1);
	SLsmg_write_char (ch);
	for (j = 0; j < SLSMG_MAX_CHARS_PER_CELL-1; j++)
	  {
	     SLwchar_Type combining = p[i].combining[j];
	     if (combining == SLCURSES_NULLCHAR)
	       break;	/* no more combining chars */
	     SLsmg_write_char (combining);
	  }
	if (p[i].is_acs)
	  SLsmg_set_char_set (0);
     }
}
Exemplo n.º 5
0
/* displays a table containing 256 characters in a single character 
   set, starting a column col.  The 'label' is displayed over the
   table, and the alternate character set is displayed iff
   isAlternate is nonzero */
static void drawCharSet(int col, int isAlternate, char * label) {
    int i, j;
    int n = 0;

    /* draw the box */
    SLsmg_draw_box(0, col, 20, 38);

    /* center the label */
    SLsmg_gotorc(0, col + 2);
    SLsmg_write_string(label);


    /* draw the horizontal legend */
    SLsmg_gotorc(2, col + 4);
    SLsmg_write_string("0 1 2 3 4 5 6 7 8 9 A B C D E F");

    /* set the character set to use */
    SLsmg_set_char_set(isAlternate);

    /* this iterates over the 4 most significant bits */
    for (i = 0; i < 16; i++) {
        SLsmg_gotorc(3 + i, 2 + col);
        SLsmg_write_char(i < 10 ? i + '0' : (i - 10) + 'A');

	/* this iterates over the 4 least significant bits */
        for (j = 0; j < 16; j++) {
            SLsmg_gotorc(3 + i, col + 4 + (j * 2));
            SLsmg_write_char(n++);
        }
    }

    SLsmg_set_char_set(0);
}
Exemplo n.º 6
0
static void ctl_sustain(int ch, int val)
{
  if(ch >= 16)
    return;
  if (!ctl.trace_playing)
    return;
  SLsmg_gotorc(8+ch, SLtt_Screen_Cols-4);
  if (val) SLsmg_write_char('S');
  else SLsmg_write_char(' ');
}
Exemplo n.º 7
0
static void ctl_pitch_bend(int ch, int val)
{
  if(ch >= 16)
    return;
  if (!ctl.trace_playing)
    return;
  SLsmg_gotorc(8+ch, SLtt_Screen_Cols-2);
  if (val==-1) SLsmg_write_char('=');
  else if (val>0x2000) SLsmg_write_char('+');
  else if (val<0x2000) SLsmg_write_char('-');
  else SLsmg_write_char(' ');
}
Exemplo n.º 8
0
/** Draws the caption of the box
  *
  * \param x the x coordonate of the box
  * \param y the y coordonate of the box
  */
void RainbruRPG::Terminal::ListBox::drawTheCaption( int x, int y){
  SLsmg_gotorc ( y, x+2);
  SLsmg_set_char_set (1);
  SLsmg_write_char( SLSMG_RTEE_CHAR );
  SLsmg_set_char_set (0);

  // cast to char* to avoid deprecating conversion warning
  SLsmg_printf( (char*)" %s ", caption.c_str() );
  SLsmg_set_char_set (1);
  SLsmg_write_char( SLSMG_LTEE_CHAR );
  SLsmg_set_char_set (0);
}
Exemplo n.º 9
0
static void buttonDrawText(newtComponent co, int active, int pushed) {
    struct button * bu = co->data;

    if (pushed) pushed = 1;

    if (active)
	SLsmg_set_color(NEWT_COLORSET_ACTBUTTON);
    else
	SLsmg_set_color(NEWT_COLORSET_BUTTON);

    newtGotorc(co->top + 1 + pushed, co->left + 1 + pushed);
    SLsmg_write_char(' ');
    SLsmg_write_string(bu->text);
    SLsmg_write_char(' ');
}
Exemplo n.º 10
0
void
tty_print_anychar (int c)
{
    char str[6 + 1];

    if (c > 255)
    {
        int res = g_unichar_to_utf8 (c, str);
        if (res == 0)
        {
            str[0] = '.';
            str[1] = '\0';
        }
        else
        {
            str[res] = '\0';
        }
        SLsmg_write_string ((char *) str_term_form (str));
    }
    else
    {
        if (!is_printable (c))
            c = '.';
        SLsmg_write_char ((SLwchar_Type) ((unsigned int) c));
    }
}
Exemplo n.º 11
0
static void ctl_reset(void)
{
  int i,j;
  if (!ctl.trace_playing)
    return;
  for (i=0; i<16; i++)
    {
      SLsmg_gotorc(8+i, 3);
      for (j=0; j<SLtt_Screen_Cols-24; j++)
	  SLsmg_write_char('.');
      if(ISDRUMCHANNEL(i))
	  ctl_program(i, channel[i].bank);
      else
	  ctl_program(i, channel[i].program);
      ctl_volume(i, channel[i].volume);
      ctl_expression(i, channel[i].expression);
      ctl_panning(i, channel[i].panning);
      ctl_sustain(i, channel[i].sustain);
      if(channel[i].pitchbend == 0x2000 && channel[i].mod.val > 0)
	  ctl_pitch_bend(i, -1);
      else
	  ctl_pitch_bend(i, channel[i].pitchbend);
    }
  _ctl_refresh();
}
Exemplo n.º 12
0
void SLsmg_draw_vline (int n)
{
   int c = This_Col, rmin, rmax;
   int final_row = This_Row + n;
   int save_color;

   if (Smg_Inited == 0) return;

   if (((c < Start_Col) || (c >= Start_Col + (int)Screen_Cols)) 
       || (0 == compute_clip (This_Row, n, Start_Row, 
			      Start_Row + (int)Screen_Rows,
			      &rmin, &rmax)))
     {
	This_Row = final_row;
	return;
     }

   save_color = This_Color;
   This_Color |= SLSMG_ACS_MASK;

   for (This_Row = rmin; This_Row < rmax; This_Row++)
     {
	This_Col = c;
	SLsmg_write_char (SLSMG_VLINE_CHAR);
     }

   This_Col = c;  This_Row = final_row;
   This_Color = save_color;
}
Exemplo n.º 13
0
void vtClearRect(VTScreenView *view, int s_col, int s_row, int e_col, int e_row) {
	int i,j;
	for(i = s_row; i <= e_row; i++) {
		SLsmg_gotorc(i, s_col);
		for(j = s_col; j < e_col; j++)
			SLsmg_write_char(' ');
		
		//SLsmg_erase_eol();
	}
	//SLsmg_refresh();
}
Exemplo n.º 14
0
/** Draws the borders of the Dialog
  *
  */
void RainbruRPG::Terminal::Dialog::drawBorder(){
  //The lightgray border
  SLsmg_set_color (8);

  SLsmg_gotorc (yPos, xPos);
  SLsmg_set_char_set (1); //Use the alt charset

  // The top line
  SLsmg_write_char(SLSMG_ULCORN_CHAR);
  SLsmg_draw_hline(width-1);

  // The left border
  for (int y=1; y<height; y++){
    SLsmg_gotorc (yPos+y, xPos);

    if (y==height-3)
      SLsmg_write_char(SLSMG_LTEE_CHAR);
    else if (y==height-1)
      SLsmg_write_char(SLSMG_LLCORN_CHAR);
    else
      SLsmg_write_char(SLSMG_VLINE_CHAR);
  }

  // The buttonbar line
  SLsmg_gotorc (yPos+height-3, xPos+1);
  SLsmg_draw_hline(width-1);

  // The gray border
  SLsmg_set_color (9);

  for (int y=0; y<height; y++){
    SLsmg_gotorc (yPos+y, xPos+width);

    if (y==0)
      SLsmg_write_char(SLSMG_URCORN_CHAR);
    else if (y==height-3)
      SLsmg_write_char(SLSMG_RTEE_CHAR);
    else if (y==height-1)
      SLsmg_write_char(SLSMG_LRCORN_CHAR);
    else
      SLsmg_write_char(SLSMG_VLINE_CHAR);
  }

  // The bottom line
  SLsmg_gotorc (yPos+height-1, xPos+1);
  SLsmg_draw_hline(width-1);

  SLsmg_set_char_set(0); //Use the normal charset
  SLsmg_set_color(0);
}
Exemplo n.º 15
0
/** Draws the title of the Dialog
  *
  */
void RainbruRPG::Terminal::Dialog::drawTitle(){
  int l=title.length();
  int x=(SLtt_Screen_Cols/2)-(l/2);

  SLsmg_set_color (8);


  SLsmg_set_char_set (1); //Use the alt charset
  SLsmg_gotorc (yPos, x-2);
  SLsmg_write_char(SLSMG_RTEE_CHAR);
  SLsmg_gotorc (yPos, x+l+1);
  SLsmg_write_char(SLSMG_LTEE_CHAR);

  //title
  SLsmg_set_color (9);
  SLsmg_gotorc (yPos, x-1);
  SLsmg_set_char_set (0); //Use the alt charset

  // cast to char* to avoid deprecating conversion warning
  SLsmg_printf( (char*)" %s ", title.c_str() );

}
Exemplo n.º 16
0
/*
 * Erase some characters
 */
static errr Term_wipe_sla(int x, int y, int n)
{
	int i;

	/* Place the cursor */
	SLsmg_gotorc(y, x);

	/* Dump spaces */
	for (i = 0; i < n; i++) SLsmg_write_char(' ');

	/* Success */
	return 0;
}
Exemplo n.º 17
0
/*
 * Erase some characters
 */
static errr Term_wipe_sla(s32b x, s32b y, s32b n)
{
	s32b i;

	/* Place the cursor */
	SLsmg_gotorc(y, x);

	/* Dump spaces */
	for (i = 0; i < n; i++) SLsmg_write_char(' ');

	/* Success */
	return 0;
}
Exemplo n.º 18
0
/** Create graphically the window
  *
  * It draws the box according to the window stateand call the
  * layout's draw() method.
  *
  * It finally the Layout::draw() method.
  */
void RainbruRPG::Terminal::Window::draw( ){
  int x, y, h, w;

  if (state==NORMAL){
    x=this->x;
    y=this->y;
    h=this->height;
    w=this->width;
  }
  else if(state==MAXIMIZED){
    x=0;
    y=1;
    h=SLtt_Screen_Rows-2;
    w=SLtt_Screen_Cols;
  }

  if (focusWindow&&selected){
    SLsmg_set_color (6);
  }

  // Border
  SLsmg_draw_box ( y, x, h, w );

  // Title
  SLsmg_gotorc ( y, x+2);
  SLsmg_set_char_set (1);
  SLsmg_write_char( SLSMG_RTEE_CHAR );
  SLsmg_set_char_set (0);

  // cast to char* to avoid deprecated converion warning
  SLsmg_printf( (char*)" %s ", caption );
  SLsmg_set_char_set (1);
  SLsmg_write_char( SLSMG_LTEE_CHAR );
  SLsmg_set_char_set (0);

  SLsmg_set_color (0);

  layout->draw();
};
Exemplo n.º 19
0
static void slang_write_utf32(uint32_t ch)
{
#ifdef HAVE_SLSMG_UTF8_ENABLE
    char buf[10];
    int bytes;
#else
    char ascii;
#endif

    if(ch == CACA_MAGIC_FULLWIDTH)
        return;

#ifdef HAVE_SLSMG_UTF8_ENABLE
    bytes = caca_utf32_to_utf8(buf, ch);
    buf[bytes] = '\0';
    SLsmg_write_string(buf);
#else
    ascii = caca_utf32_to_ascii(ch);
    SLsmg_write_char(ascii);
    if(caca_utf32_is_fullwidth(ch))
        SLsmg_write_char(ascii);
#endif
}
Exemplo n.º 20
0
void printall(int offset) {
    int n = 0;
    int i, j;

    SLsmg_gotorc(0, offset);
    SLsmg_write_string("  0 1 2 3 4 5 6 7 8 9 A B C D E F");
    for (i = 0; i < 16; i++) {
	SLsmg_gotorc(i + 1, offset);
	SLsmg_printf("%x", i);
	for (j = 0; j < 16; j++) {
	    SLsmg_gotorc(i + 1, (j + 1) * 2 + offset);
	    SLsmg_write_char(n++);
	}
    }
}
Exemplo n.º 21
0
/*
 * Handle a "special request"
 */
static errr Term_xtra_sla(int n, int v)
{
	/* Analyze the request */
	switch (n)
	{
		/* Make a noise */
		case TERM_XTRA_NOISE:
		(void)SLsmg_write_char('\007');
		return (0);

		/* Flush the ncurses buffer */
		case TERM_XTRA_FRESH:
		(void)SLsmg_refresh();
		return (0);

		/* Make the cursor invisible or visible */
		case TERM_XTRA_SHAPE:
		/* curs_set(v); */
		return (0);

		/* Handle events */
		case TERM_XTRA_EVENT:
		return (Term_xtra_sla_event(v));

		/* Handle events */
		case TERM_XTRA_FLUSH:
		while (!Term_xtra_sla_event(FALSE));
		return (0);

		/* Suspend/Resume */
		case TERM_XTRA_ALIVE:
		return (Term_xtra_sla_alive(v));

		/* Clear the screen */
		case TERM_XTRA_CLEAR:
		(void)SLsmg_cls();
		SLsmg_gotorc(0, 0);
		return (0);

		/* Delay */
		case TERM_XTRA_DELAY:
		usleep(1000 * v);
		return (0);
	}

	/* Oops */
	return (1);
}
Exemplo n.º 22
0
void SLsmg_draw_object (int r, int c, SLwchar_Type object)
{
   This_Row = r;  This_Col = c;

   if (Smg_Inited == 0) return;

   if (point_visible (1))
     {
	int color = This_Color;
	This_Color |= SLSMG_ACS_MASK;
	SLsmg_write_char (object);
	This_Color = color;
     }

   This_Col = c + 1;
}
Exemplo n.º 23
0
void
tty_print_alt_char (int c, gboolean single)
{
#define DRAW(x, y) (x == y) \
       ? SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), x) \
       : SLsmg_write_char ((unsigned int) y)
    switch (c)
    {
    case ACS_VLINE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT]);
        break;
    case ACS_HLINE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ]);
        break;
    case ACS_LTEE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTMIDDLE : MC_TTY_FRM_DLEFTMIDDLE]);
        break;
    case ACS_RTEE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTMIDDLE : MC_TTY_FRM_DRIGHTMIDDLE]);
        break;
    case ACS_TTEE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_TOPMIDDLE : MC_TTY_FRM_DTOPMIDDLE]);
        break;
    case ACS_BTEE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_BOTTOMMIDDLE : MC_TTY_FRM_DBOTTOMMIDDLE]);
        break;
    case ACS_ULCORNER:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTTOP : MC_TTY_FRM_DLEFTTOP]);
        break;
    case ACS_LLCORNER:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTBOTTOM : MC_TTY_FRM_DLEFTBOTTOM]);
        break;
    case ACS_URCORNER:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTTOP : MC_TTY_FRM_DRIGHTTOP]);
        break;
    case ACS_LRCORNER:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTBOTTOM : MC_TTY_FRM_DRIGHTBOTTOM]);
        break;
    case ACS_PLUS:
        DRAW (c, mc_tty_frm[MC_TTY_FRM_CROSS]);
        break;
    default:
        SLsmg_write_char ((unsigned int) c);
    }
#undef DRAW
}
Exemplo n.º 24
0
static void ui_browser__scrollbar_set(struct ui_browser *browser)
{
	int height = browser->height, h = 0, pct = 0,
	    col = browser->width,
	    row = 0;

	if (browser->nr_entries > 1) {
		pct = ((browser->index * (browser->height - 1)) /
		       (browser->nr_entries - 1));
	}

	SLsmg_set_char_set(1);

	while (h < height) {
	        ui_browser__gotorc(browser, row++, col);
		SLsmg_write_char(h == pct ? SLSMG_DIAMOND_CHAR : SLSMG_CKBRD_CHAR);
		++h;
	}

	SLsmg_set_char_set(0);
}
Exemplo n.º 25
0
static void cbDraw(newtComponent c) {
    struct checkbox * cb = c->data;

    if (!c->isMapped) return;

    if (cb->flags & NEWT_FLAG_DISABLED) {
	cb->inactive = NEWT_COLORSET_DISENTRY;
	cb->active = NEWT_COLORSET_DISENTRY;
    } else {
	cb->inactive = COLORSET_CHECKBOX;
	cb->active = COLORSET_ACTCHECKBOX;
    }

    SLsmg_set_color(cb->inactive);

    newtGotorc(c->top, c->left);

    switch (cb->type) {
      case RADIO:
	SLsmg_write_string("( ) ");
	break;

      case CHECK:
	SLsmg_write_string("[ ] ");
	break;

      default:
	break;
    }

    SLsmg_write_string(cb->text);

    if (cb->hasFocus)
	SLsmg_set_color(cb->active);

    newtGotorc(c->top, c->left + 1);
    SLsmg_write_char(*cb->result);
    newtGotorc(c->top, c->left + 4);
}
Exemplo n.º 26
0
void SLsmg_draw_hline (unsigned int n)
{
   static unsigned char hbuf[16];
   int cmin, cmax;
   int final_col = This_Col + (int) n;
   int save_color;

   if (Smg_Inited == 0) return;

   if ((This_Row < Start_Row) || (This_Row >= Start_Row + (int)Screen_Rows)
       || (0 == compute_clip (This_Col, n, Start_Col, Start_Col + (int)Screen_Cols,
			      &cmin, &cmax)))
     {
	This_Col = final_col;
	return;
     }

   n = (unsigned int)(cmax - cmin);

   save_color = This_Color;
   This_Color |= SLSMG_ACS_MASK;
   This_Col = cmin;

      
   if (hbuf[0] == 0)
     {
	SLMEMSET ((char *) hbuf, SLSMG_HLINE_CHAR, 16);
     }


   while (n)
     {
	SLsmg_write_char (SLSMG_HLINE_CHAR);
	n--;
     }
   This_Color = save_color;
   This_Col = final_col;
}
Exemplo n.º 27
0
void SLsmg_write_wrapped_string (SLuchar_Type *u, int r, int c,
				 unsigned int dr, unsigned int dc,
				 int fill)
{
   int maxc = (int) dc;
   unsigned char *p, *pmax;
   int utf8_mode = UTF8_Mode;
   unsigned char display_8bit = (unsigned char) SLsmg_Display_Eight_Bit;

   if (utf8_mode)
     display_8bit = 0xA0;

   if ((dr == 0) || (dc == 0)) return;
   if (u == NULL)
     u = (unsigned char *)"";

   p = u;
   pmax = u + strlen ((char *)u);
   
   dc = 0;
   while (1)
     {
	SLwchar_Type wc;
	unsigned int nconsumed;
	unsigned char ch = *p;
	unsigned int ddc;

	if ((ch == 0) || (ch == '\n'))
	  {
	     int diff;

	     diff = maxc - (int) dc;

	     SLsmg_gotorc (r, c);
	     SLsmg_write_chars (u, p);
	     if (fill && (diff > 0))
	       {
		  unsigned char *blank = (unsigned char *)" ";
		  while (diff--) SLsmg_write_chars (blank, blank+1);
	       }
	     if ((ch == 0) || (dr == 1)) break;

	     r++;
	     dc = 0;
	     dr--;
	     p++;
	     u = p;
	     continue;
	  }

	/* If the width of the characters buffered so far extend to or beyond
	 * the width of the box, then write them out and goto the
	 * next line. Note that dc > maxc if the displayable width of
	 * the last character to be written is greater than the width
	 * of the box.  This will be the case if (maxc<ddc) -- see below
	 */
	if ((int) dc >= maxc)
	  goto write_chars_and_reset;

	nconsumed = 1;
	if (ch < 0x80)
	  {
	     p++;
	     if ((ch >= 0x20) && (ch != 0x7F))
	       {
		  dc++;
		  continue;
	       }
	     /* Otherwise display as ^X */
	     dc += 2;
	     continue;
	  }

	nconsumed = 1;
	if ((utf8_mode == 0)
	    || (NULL == SLutf8_decode (p, pmax, &wc, &nconsumed)))
	  {	     
	     if ((utf8_mode == 0)
		 && (display_8bit && (*p >= display_8bit)))
	       {
		  dc++;
		  p += nconsumed;
		  continue;
	       }

	     ddc = 4*nconsumed;      /* <XX> */
	  }
	else if (wc < (SLwchar_Type)display_8bit)
	  ddc = 4;		       /* displays as <XX> */
	else
	  ddc = SLwchar_wcwidth (wc);

	dc += ddc;
	if (((int)dc > maxc) && (maxc > (int)ddc))
	  {
	     dc -= ddc;
	     goto write_chars_and_reset;
	  }
	p += nconsumed;
	continue;

	write_chars_and_reset:	
	SLsmg_gotorc (r, c);
	SLsmg_write_chars (u, p);
	while ((int)dc < maxc)
	  {
	     SLsmg_write_char (' ');
	     dc++;
	  }
	if (dr == 1) break;
	r++;
	dc = 0;
	dr--;
	u = p;
     }
}
Exemplo n.º 28
0
void
tty_print_char (int c)
{
    SLsmg_write_char ((SLwchar_Type) ((unsigned int) c));
}
Exemplo n.º 29
0
static void slang_display(caca_display_t *dp)
{
    int x, y, i;

    SLsig_block_signals();
    for(i = 0; i < caca_get_dirty_rect_count(dp->cv); i++)
    {
        uint32_t const *cvchars, *cvattrs;
        int dx, dy, dw, dh;

        caca_get_dirty_rect(dp->cv, i, &dx, &dy, &dw, &dh);

        cvchars = caca_get_canvas_chars(dp->cv) + dx + dy * dp->cv->width;
        cvattrs = caca_get_canvas_attrs(dp->cv) + dx + dy * dp->cv->width;

        for(y = dy; y < dy + dh; y++)
        {
            SLsmg_gotorc(y, dx);
            for(x = dx; x < dx + dw; x++)
            {
                uint32_t ch = *cvchars++;

#if defined(OPTIMISE_SLANG_PALETTE)
                /* If foreground == background, just don't use this colour
                 * pair, and print a space instead of the real character. */
                /* XXX: disabled, because I can't remember what it was
                 * here for, and in cases where SLang does not render
                 * bright backgrounds, it's just f****d up. */
#if 0
                uint8_t fgcolor = caca_attr_to_ansi_fg(*cvattrs);
                uint8_t bgcolor = caca_attr_to_ansi_bg(*cvattrs);

                if(fgcolor >= 0x10)
                    fgcolor = CACA_LIGHTGRAY;

                if(bgcolor >= 0x10)
                    bgcolor = CACA_BLACK; /* FIXME: handle transparency */

                if(fgcolor == bgcolor)
                {
                    if(fgcolor == CACA_BLACK)
                        fgcolor = CACA_WHITE;
                    else if(fgcolor == CACA_WHITE
                             || fgcolor <= CACA_LIGHTGRAY)
                        fgcolor = CACA_BLACK;
                    else
                        fgcolor = CACA_WHITE;
                    SLsmg_set_color(slang_assoc[fgcolor + 16 * bgcolor]);
                    SLsmg_write_char(' ');
                    cvattrs++;
                }
                else
#endif
                {
                    SLsmg_set_color(slang_assoc[caca_attr_to_ansi(*cvattrs++)]);
                    slang_write_utf32(ch);
                }
#else
                SLsmg_set_color(caca_attr_to_ansi(*cvattrs++));
                slang_write_utf32(ch);
#endif
            }

            cvchars += dp->cv->width - dw;
            cvattrs += dp->cv->width - dw;
        }
    }
    SLsmg_gotorc(caca_wherey(dp->cv), caca_wherex(dp->cv));
    SLsmg_refresh();
    SLsig_unblock_signals();
}
Exemplo n.º 30
0
/*ARGSUSED*/
static int ctl_open(int using_stdin, int using_stdout)
{
#ifdef TIOCGWINSZ
  struct winsize size;
#endif
  int i;
  int save_lines, save_cols;

  SLtt_get_terminfo();
/*
 * Save the terminfo values for lines and cols
 * then detect the real values.
 */
  save_lines = SLtt_Screen_Rows;
  save_cols = SLtt_Screen_Cols;
#ifdef TIOCGWINSZ
  if (!ioctl(0, TIOCGWINSZ, &size)) {
    SLtt_Screen_Cols=size.ws_col;
    SLtt_Screen_Rows=size.ws_row;
  } else
#endif
  {
    SLtt_Screen_Cols=atoi(getenv("COLUMNS"));
    SLtt_Screen_Rows=atoi(getenv("LINES"));
  }
  if (!SLtt_Screen_Cols || !SLtt_Screen_Rows) {
    SLtt_Screen_Rows = save_lines;
      SLtt_Screen_Cols = save_cols;
  }
  SLang_init_tty(7, 0, 0);
  SLsmg_init_smg();
  SLtt_set_color (20, "Normal", "lightgray", "black");
  SLtt_set_color (21, "HighLight", "white", "black");
  SLtt_set_color (22, "Reverse", "black", "white");
  SLtt_Use_Ansi_Colors = 1;
  SLtt_Term_Cannot_Scroll = 1;

  ctl.opened=1;

  SLsmg_cls();

  ctl_head();

  SLsmg_printfrc(3,0, "File:");
  if (ctl.trace_playing)
    {
      SLsmg_printfrc(4,0, "Time:");
      SLsmg_gotorc(4,6+6+1);
      SLsmg_write_char('/');
      SLsmg_gotorc(4,40);
      SLsmg_printf("Voices:    / %d", voices);
    }
  else
    {
      SLsmg_printfrc(4,0, "Time:");
      SLsmg_printfrc(4,13, "/");
    }
  SLsmg_printfrc(4,SLtt_Screen_Cols-20, "Master volume:");
  SLsmg_gotorc(5,0);
  for (i=0; i<SLtt_Screen_Cols; i++)
    SLsmg_write_char('_');
  if (ctl.trace_playing)
    {
      SLsmg_printfrc(6,0, "Ch");
      SLsmg_printfrc(6,SLtt_Screen_Cols-20, "Prg Vol Exp Pan S B");
      SLsmg_gotorc(7,0);
      for (i=0; i<SLtt_Screen_Cols; i++)
      SLsmg_write_char('-');
      for (i=0; i<16; i++)
      {
        SLsmg_printfrc(8+i, 0, "%02d", i+1);
      }
      set_trace_loop_hook(update_indicator);
      indicator_width=SLtt_Screen_Cols-2;
      if(indicator_width<40)
	indicator_width=40;
      lyric_row=2;
    }
  else
    msg_row = 6;
  memset(comment_indicator_buffer =
    (char *)safe_malloc(indicator_width), 0, indicator_width);
  memset(current_indicator_message =
    (char *)safe_malloc(indicator_width), 0, indicator_width);
  _ctl_refresh();

  return 0;
}