示例#1
0
int gui_window_line_draw(GUI_WINDOW_REC *gui, LINE_REC *line, int ypos, int skip, int max)
{
    LINE_CACHE_REC *cache;
    LINE_CACHE_SUB_REC *sub;
    char *pos, *next_pos;
    int n;

    g_return_val_if_fail(gui != NULL, -1);
    g_return_val_if_fail(line != NULL, -1);

    cache = g_hash_table_lookup(gui->line_cache, line);
    if (cache == NULL)
        cache = gui_window_line_cache(gui, line);
    else
        cache->last_access = time(NULL);

    if (max < 0) max = cache->count;

    for (n = skip; n < cache->count && max > 0; n++, ypos++, max--) {
        sub = n == 0 ? NULL : &cache->lines[n-1];
        pos = sub == NULL ? line->text : sub->start;
        next_pos = (n+1 < cache->count) ?
                   cache->lines[n].start : NULL;

        single_line_draw(gui, ypos, sub, pos, next_pos);
    }

#ifdef USE_CURSES_WINDOWS
    screen_refresh(gui->parent->curses_win);
#else
    screen_refresh(NULL);
#endif

    return cache->count;
}
示例#2
0
static void sig_printtext_finished(WINDOW_REC *window)
{
	GUI_WINDOW_REC *gui;

	gui = WINDOW_GUI(window);
	if (gui->cur_line == NULL)
                return;

	if (format->len > 0) {
                /* save format of the line */
		linebuf_add(gui, format->str, format->len);

		g_string_truncate(format, 0);
	}

	linebuf_add(gui, "\0\200", 2); /* mark EOL */
	gui->eol_marked = TRUE;

	if (is_window_visible(window)) {
#ifdef USE_CURSES_WINDOWS
		screen_refresh(gui->parent->curses_win);
#else
		screen_refresh(NULL);
#endif
	}
}
示例#3
0
static void window_clear_screen(GUI_WINDOW_REC *gui)
{
#ifdef USE_CURSES_WINDOWS
        wclear(gui->parent->curses_win);
	screen_refresh(gui->parent->curses_win);
#else
	int n;

	for (n = gui->parent->first_line; n < gui->parent->last_line; n++) {
		move(n, 0);
		clrtoeol();
	}
	screen_refresh(NULL);
#endif
}
示例#4
0
static void statusbar_topic(SBAR_ITEM_REC *item, int ypos)
{
	CHANNEL_REC *channel;
	QUERY_REC *query;
	char *str, *topic;

	if (item->size != COLS-2) {
		/* get all space for topic */
		statusbar_item_resize(item, COLS-2);
		return;
	}

	move(ypos, item->xpos);
	set_bg((1<<4)+7); clrtoeol(); set_bg(0);

	if (active_win == NULL)
		return;

	topic = NULL;
	channel = irc_item_channel(active_win->active);
	query = irc_item_query(active_win->active);
	if (channel != NULL && channel->topic != NULL) topic = channel->topic;
	if (query != NULL && query->address != NULL) topic = query->address;

	if (topic != NULL) {
		topic = strip_codes(topic);
		str = g_strdup_printf("%.*s", item->size, topic);
		set_color((1<<4)+15); addstr(str);
		g_free(str);
		g_free(topic);
	}

	screen_refresh();
}
示例#5
0
static void statusbar_topic(SBAR_ITEM_REC *item, int ypos)
{
	CHANNEL_REC *channel;
	QUERY_REC *query;
	char *str, *topic;

	if (item->size != COLS-2) {
		/* get all space for topic */
		statusbar_item_resize(item, COLS-2);
		return;
	}

	move(ypos, item->xpos);
	set_bg(stdscr, settings_get_int("statusbar_background") << 4);
	clrtoeol(); set_bg(stdscr, 0);

	if (active_win == NULL)
		return;

	topic = NULL;
	channel = CHANNEL(active_win->active);
	query = QUERY(active_win->active);
	if (channel != NULL && channel->topic != NULL) topic = channel->topic;
	if (query != NULL && query->address != NULL) topic = query->address;

	if (topic != NULL) {
		topic = strip_codes(topic);
		str = g_strdup_printf("%.*s", item->size, topic);
		set_color(stdscr, sbar_color_normal); addstr(str);
		g_free(str);
		g_free(topic);
	}

	screen_refresh(NULL);
}
示例#6
0
static void statusbar_mail(SBAR_ITEM_REC *item, int ypos)
{
	char str[MAX_INT_STRLEN];
	int size_needed, mail_count;

	mail_count = settings_get_bool("mail_counter") ? get_mail_count() : 0;

	ltoa(str, mail_count);
	if (*str == '\0' || mail_count <= 0)
		size_needed = 0;
	else
		size_needed = strlen(str) + 8;

	if (item->size != size_needed) {
		/* we need more (or less..) space! */
		statusbar_item_resize(item, size_needed);
		return;
	}

	if (size_needed == 0)
		return;

	move(ypos, item->xpos);
	set_color(stdscr, sbar_color_dim); addch('[');
	set_color(stdscr, sbar_color_normal); addstr("Mail: ");

	set_color(stdscr, sbar_color_bold); addstr(str);
	set_color(stdscr, sbar_color_dim); addch(']');

	screen_refresh(NULL);
}
示例#7
0
void gui_window_redraw(WINDOW_REC *window)
{
	GUI_WINDOW_REC *gui;
	GList *line;
	int ypos, lines, skip, max;

	g_return_if_fail(window != NULL);

	gui = WINDOW_GUI(window);

	/* clear the lines first */
	set_color(0);
	for (ypos = gui->parent->first_line; ypos <= gui->parent->last_line; ypos++) {
		move(ypos, 0);
		clrtoeol();
	}

	skip = gui->subline;
	ypos = gui->parent->first_line;
	for (line = gui->startline; line != NULL; line = line->next) {
		LINE_REC *rec = line->data;

		max = gui->parent->last_line - ypos+1;
		if (max < 0) break;

		lines = gui_window_line_draw(gui, rec, ypos, skip, max);
		ypos += lines-skip;
		skip = 0;
	}

	screen_refresh();
}
示例#8
0
文件: screen.c 项目: carrotsrc/loki
void write_screen(struct screen *screen, struct loki_state *state) {
	pthread_mutex_lock(&scrmutex);
	if(screen->left != NULL) {
		screen->left->write(state, screen->left->port);
	}

	if(screen->centre != NULL) {
		werase(screen->centre->port);
		screen->centre->write(state, screen->centre->port);
	}

	if(screen->right != NULL) {
		werase(screen->right->port);
		screen->right->write(state, screen->right->port);
	}

	move(0,15);
	printw("Total Packets: %ld | ", ((struct frame_log*)(state->log))->totalPackets);
	move(LINES-1, 1);
	clrtoeol();
	if(state->status_msg != NULL)
		printw(state->status_msg);

	screen_refresh(screen);
	pthread_mutex_unlock(&scrmutex);
}
示例#9
0
static void entry_update(void)
{
	char *p;
	int n, len;

	len = entry->len-scrstart > COLS-1-promptlen ?
		COLS-1-promptlen : entry->len-scrstart;

	set_color(stdscr, 0);
	move(LINES-1, promptlen);

	for (p = entry->str+scrstart, n = 0; n < len; n++, p++) {
		if (prompt_hidden)
                        addch(' ');
		else if ((unsigned char) *p >= 32)
			addch((unsigned char) *p);
		else {
			set_color(stdscr, ATTR_REVERSE);
			addch(*p+'A'-1);
			set_color(stdscr, 0);
		}
	}
	clrtoeol();

	move_cursor(LINES-1, scrpos+promptlen);
	screen_refresh(NULL);
}
void CLS_DlgStreamPusher::event_loop(struct_stream_info *_pstrct_streaminfo)
{
	if (NULL == _pstrct_streaminfo){
		TRACE("NULL == _pstrct_streaminfo");
		return;
	}
	
	SDL_Event event;
	double incr, pos, frac;
	for (;;) {

		double x;
		//判断退出
		if (_pstrct_streaminfo->m_abort_request){
			break;
		}

		SDL_WaitEvent(&event);
		switch (event.type) {
		case FF_AUDIO_REFRESH_EVENT:
			screen_refresh(event.user.data1);
			_pstrct_streaminfo->m_refresh = 0;
			break;
		case FF_VIDEO_REFRESH_EVENT:
			break;
		case FF_BREAK_EVENT:
			break;
		case FF_QUIT_EVENT:
			stream_stop(event.user.data1);
			break;
		default:
			break;
		}
	}
}
示例#11
0
/* redraw -- more -- */
static void statusbar_more(SBAR_ITEM_REC *item, int ypos)
{
	if (item->size != 10) return;

	move(ypos, item->xpos);
	set_color(stdscr, sbar_color_bold); addstr("-- more --");
	screen_refresh(NULL);
}
示例#12
0
/*
=======================================
    TIMER2 中断处理
=======================================
*/
CR_API void_t
TIM2_IRQHandler (void_t)
{
    if (TIM_GetITStatus(TIM2, TIM_IT_Update)) {
        TIM_ClearITPendingBit(TIM2, TIM_FLAG_Update);
        screen_refresh();
    }
}
示例#13
0
/* redraw -- more -- */
static void statusbar_more(SBAR_ITEM_REC *item, int ypos)
{
	if (item->size != 10) return;

	move(ypos, item->xpos);
	set_color((1 << 4)+15); addstr("-- more --");
	screen_refresh();
}
void highscore_show(int numb) {
    highscore_add("player name",numb);
     while(!keyboard_check(27 /*vk_escape*/)) {
    draw_highscore(20, 0, room_width-20, room_height);

         screen_refresh();
         io_handle();
     }
}
示例#15
0
static void window_clear(GUI_WINDOW_REC *gui)
{
	int n;

	for (n = gui->parent->first_line; n <= gui->parent->last_line; n++) {
		move(n, 0);
		clrtoeol();
	}
	screen_refresh();
}
示例#16
0
文件: client.c 项目: salbeira/simbs
void* client_receiver(void * params)
{
	while(running)
	{
		struct line *buf = (struct line*) malloc(sizeof(struct line));
		udp_receive((char *)buf, sizeof(struct line));
		screen_out_add(buf);
		screen_refresh();
	}
	return NULL;
}
示例#17
0
文件: client.c 项目: salbeira/simbs
void resized(int signal)
{
	if(SIGWINCH == signal)
	{
		int max_rows;
		int max_cols;
		getmaxyx(stdscr, max_rows, max_cols);
		if(g_max_rows != max_rows || g_max_cols != max_cols)
			redefine_screen(max_rows, max_cols);
		screen_refresh();
	}
}
示例#18
0
static void statusbar_lag(SBAR_ITEM_REC *item, int ypos)
{
	IRC_SERVER_REC *server;
	GString *str;
	int size_needed, lag_unknown;
	time_t now;

	now = time(NULL);
	str = g_string_new(NULL);

	server = (IRC_SERVER_REC *) (active_win == NULL ? NULL : active_win->active_server);
	if (server == NULL || server->lag_last_check == 0)
		size_needed = 0;
	else if (server->lag_sent == 0 || now-server->lag_sent < 5) {
		lag_unknown = now-server->lag_last_check >
			MAX_LAG_UNKNOWN_TIME+settings_get_int("lag_check_time");

		if (server->lag < lag_min_show && !lag_unknown)
			size_needed = 0; /* small lag, don't display */
		else {
			g_string_sprintf(str, "%d.%02d", server->lag/1000, (server->lag % 1000)/10);
			if (lag_unknown)
				g_string_append(str, " (??)");
			size_needed = str->len+7;
		}
	} else {
		/* big lag, still waiting .. */
		g_string_sprintf(str, "%ld (??)", now-server->lag_sent);
		size_needed = str->len+7;
	}

    if (item->size != size_needed)
    {
        /* we need more (or less..) space! */
        statusbar_item_resize(item, size_needed);
        g_string_free(str, TRUE);
        return;
    }

    if (item->size != 0)
    {
	lag_last_draw = now;
	move(ypos, item->xpos);
	set_color((1 << 4)+3); addch('[');
	set_color((1 << 4)+7); addstr("Lag: ");

	set_color((1 << 4)+15); addstr(str->str);
	set_color((1 << 4)+3); addch(']');

	screen_refresh();
    }
    g_string_free(str, TRUE);
}
示例#19
0
文件: client.c 项目: salbeira/simbs
void* client_input(void* params)
{
	while(running)
	{
		if(screen_in_input())
		{
			udp_send(g_input_buffer, MSG_SIZE);
			memset(g_input_buffer, 0, MSG_SIZE);
		}
		screen_refresh();	
	}
	return NULL;
}
示例#20
0
int main(int argc, char *argv[])
{
	uint32_t colorblock[60000];
	uint32_t i = 0;
	/* On veut remplir une mire avec 7 bandes de couleur de 100 pixels de
	 * large chacune, et de 600 pixels de haut
	 *  On initialise donc un écran de largeur 700, et de hauteur 600
	 */
	screen_init(700, 600, 25);

	/* On veut ensuite copier les bandes de couleur, à la bonne place dans
	 * l'image.
	 * Pour cela, on utilise la fonction screen_cpyrect. On initialise
	 * également le bloc à copier
	 */
	for (i = 0 ; i < 60000 ; i++) {
		colorblock[i] = WHITE;
	}
	screen_cpyrect(0,0,100,600, colorblock);
	for (i = 0 ; i < 60000 ; i++) {
		colorblock[i] = RED;
	}
	screen_cpyrect(100,0,100,600, colorblock);
	for (i = 0 ; i < 60000 ; i++) {
		colorblock[i] = RED | BLUE;
	}
	screen_cpyrect(200,0,100,600, colorblock);
	for (i = 0 ; i < 60000 ; i++) {
		colorblock[i] = BLUE;
	}
	screen_cpyrect (300,0,100,600, colorblock);
	for (i = 0 ; i < 60000 ; i++) {
		colorblock[i] = BLUE | GREEN;
	}
	screen_cpyrect (400,0,100,600, colorblock);
	for (i = 0 ; i < 60000 ; i++) {
		colorblock[i] = GREEN;
	}
	screen_cpyrect (500,0,100,600, colorblock);
	for (i = 0 ; i < 60000 ; i++) {
		colorblock[i] = BLACK;
	}
	screen_cpyrect (600,0,100,600, colorblock);
	// Les 7 bandes ont été copiés, on peut maintenant afficher l'image
	screen_refresh();
	/* Une fois rafraichit, on ferme l'écran. Cette fonction attend en fait
	 * que l'on ferme explicitement la fenetre
	 */
	screen_exit();
	return 0;
}
示例#21
0
文件: flash.c 项目: Someone101/aleph
// parse a hex record and write the contents to flash if appropriate
// return 1 if EOF, 0 otherwise
extern u8 flash_write_hex_record(u8* data) {
  static hexRecord_t rec;
  static u32 addrOff = 0;
  static u32 dst;
  static char hexBuf[9] = {0,0,0,0,0,0,0,0,0};
  int err;
  err = parse_raw_hex_record(data, &rec);
  if(err) {
    // print_dbg("\r\n failure parsing hex record: \r\n");
    // print_dbg((const char*)data);

    screen_line(0, 6, "WARNING:", 0xf);
    screen_line(0, 7, "error parsing hex record!", 0xf);
    screen_refresh();

  } else {
    switch(rec.type) {
    case HEX_EXT_LINEAR_ADDRESS:
      addrOff = rec.address;
      break;
    case HEX_DATA:
      /* // print_dbg("\r\n writing firmware to flash at address: "); */
      /* // print_dbg_hex(addrOff + rec.address); */
      dst = addrOff + rec.address;

      /// TEST!!
            if(dst < FIRMWARE_FLASH_ADDRESS) {
      //      if(0) {


	// don't allow writes to anything below the runtime location!
	// this is where the bootloader lives!
	// app data goes at the end of flash.
	screen_line(0, 6, "WARNING:", 0xf);
	screen_line(0, 7, "scary address! ", 0xf);
	uint_to_hex_ascii( hexBuf, dst);
	screen_line(64, 7, hexBuf, 0xf);
      } else {
	flashc_memcpy( (void*)(dst), rec.data, rec.count, 1);
      }
      break;
    default:
      ;;
    }
  }
  return 0;
}
示例#22
0
/* redraw clock */
static void statusbar_clock(SBAR_ITEM_REC *item, int ypos)
{
	struct tm *tm;
	char str[6];

	clock_last = time(NULL);
	tm = localtime(&clock_last);

	g_snprintf(str, sizeof(str), "%02d:%02d", tm->tm_hour, tm->tm_min);

	move(ypos, item->xpos);
	set_color((1 << 4)+3); addch('[');
	set_color((1 << 4)+15); addstr(str);
	set_color((1 << 4)+3); addch(']');

	screen_refresh();
}
示例#23
0
/* redraw activity */
static void statusbar_activity(SBAR_ITEM_REC *item, int ypos)
{
    WINDOW_REC *window;
    GList *tmp;
    gchar str[MAX_INT_STRLEN];
    int size_needed;
    gboolean act, det;

    size_needed = 0; act = det = FALSE;
    for (tmp = activity_list; tmp != NULL; tmp = tmp->next)
    {
	window = tmp->data;

	size_needed += 1+ltoa(str, window->refnum);

	if (!use_colors && window->new_data == NEWDATA_MSG_FORYOU)
	    det = TRUE;
	else
	    act = TRUE;
    }

    if (act) size_needed += 6; /* [Act: ], -1 */
    if (det) size_needed += 6; /* [Det: ], -1 */
    if (act && det) size_needed--;

    if (item->size != size_needed)
    {
        /* we need more (or less..) space! */
        statusbar_item_resize(item, size_needed);
        return;
    }

    if (item->size == 0)
        return;

    move(ypos, item->xpos);
    set_color((1 << 4)+3); addch('[');
    if (act) draw_activity("Act: ", TRUE, !det);
    if (act && det) addch(' ');
    if (det) draw_activity("Det: ", FALSE, TRUE);
    set_color((1 << 4)+3); addch(']');

    screen_refresh();
}
示例#24
0
void screen_redraw()
{
	float color[4];
	
	int clearcolor = ((int)background_color) & 0x00FFFFFF;
	// Setup the color to clear the buffer to.
	color[0] = __GETR(clearcolor);
	color[1] = __GETG(clearcolor);
	color[2] = __GETB(clearcolor);
	color[3] = 1;

	// Clear the back buffer.
	m_deviceContext->ClearRenderTargetView(m_renderTargetView, color);
    
	// Clear the depth buffer.
	m_deviceContext->ClearDepthStencilView(m_depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
	
	screen_refresh();
}
示例#25
0
void screen_redraw()
{
  //d3dmgr->EndShapesBatching(); //If called inside bound surface we need to finish drawing
  d3dmgr->BeginScene();
  // Clean up any textures that ENIGMA may still think are binded but actually are not
  d3d_set_zwriteenable(true);
  if (!view_enabled)
  {
    screen_set_viewport(0, 0, window_get_region_width_scaled(), window_get_region_height_scaled());
    
    clear_view(0, 0, room_width, room_height, 0, background_showcolor);
    draw_back();
    draw_insts();
    draw_tiles();
  }
  else
  {
    //TODO: Possibly implement view option from Stupido to control which view clears the background
    // Only clear the background on the first visible view by checking if it hasn't been cleared yet
    bool draw_backs = true;
    bool background_allviews = true; // FIXME: Create a setting for this.
    for (view_current = 0; view_current < 8; view_current++)
    {
      int vc = (int)view_current;
      if (!view_visible[vc])
        continue;
      
      int vob = (int)view_object[vc];
      if (vob != -1)
        follow_object(vob, vc);

      screen_set_viewport(view_xport[vc], view_yport[vc], view_wport[vc], view_hport[vc]);
	  
      clear_view(view_xview[vc], view_yview[vc], view_wview[vc], view_hview[vc], view_angle[vc], background_showcolor && draw_backs);

      if (draw_backs)
        draw_back();
      
      draw_insts();
      
      if (draw_tiles())
        break;
      draw_backs = background_allviews;
    }
    view_current = 0;
  }

  // Now process the sub event of draw called draw gui
  // It is for drawing GUI elements without view scaling and transformation
  if (enigma::gui_used)
  {
    screen_set_viewport(0, 0, window_get_region_width_scaled(), window_get_region_height_scaled());
    d3d_set_projection_ortho(0, 0, enigma::gui_width, enigma::gui_height, 0);
	
    // Clear the depth buffer if hidden surface removal is on at the beginning of the draw step.
    if (enigma::d3dMode)
      d3dmgr->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

    draw_gui();
  }

  d3dmgr->EndScene();

  ///TODO: screen_refresh() shouldn't be in screen_redraw(). They are separate functions for a reason.
  screen_refresh();
}
示例#26
0
/* get to handle.   Matthias */ 
int handle_X_event(XEvent event, unsigned char qt_c)
{
  /* no longer needed. Matthias */ 
/*   XEvent event; */
  unsigned char *s;
  int count;
  Window root, child;
  int root_x, root_y, x, y;
  unsigned int mods;
  static Time buttonpress_time=0;
  static unsigned int clicks=1;

  /* this was set in get_com_char originally. Matthias */ 
  refreshed = 0;

  /* no longer needed. Matthias */ 
/*   XNextEvent(display,&event); */
  switch(event.type)
    {
    case KeyPress:
      s = lookup_key(&event,&count, qt_c);
      send_string(s,count);
      return 0;
    case ClientMessage:
      if (event.xclient.format == 32 && event.xclient.data.l[0] == wm_del_win)
	clean_exit(0);
      return 0;
    case MappingNotify:
      XRefreshKeyboardMapping(&event.xmapping);
      return 0;
    case GraphicsExpose:
    case Expose:
      if (!size_set) 
	{	      
	  /*  Force a window resize if an exposure event
	   *  arrives before the first resize event.
	   */
	  resize_window(0,0);
	  size_set = 1;
	}
      if(event.xany.window==vt_win)
	{
	  scr_refresh(event.xexpose.x,event.xexpose.y,
		      event.xexpose.width,event.xexpose.height);
	  return 0;
	}
      /* no longer needed */
/*       else  */
/* 	{ */
/* 	  while(XCheckTypedWindowEvent (display, event.xany.window, Expose, */
/* 					&dummy)); */
/* 	  while(XCheckTypedWindowEvent (display, event.xany.window,  */
/* 					GraphicsExpose, &dummy)); */

/* 	} */
      return 0;
    case VisibilityNotify:
      /* Here's my conclusiion:
       * If the window is completely onobscured, use bitblt's
       * to scroll. Even then, they're only used when doing partial
       * screen scrolling. When partially obscured, we have to fill
       * in the GraphicsExpose parts, which means that after each refresh,
       * we need to wait for the graphics expose or Noexpose events, 
       * which ought to make things real slow! */
      if(event.xvisibility.state == VisibilityUnobscured)
	{
  	  scr_refresh(0,0,MyWinInfo.cwidth,MyWinInfo.cheight); 
/* 	  refresh_type = FAST; */
	  /* use slow here. FAST seems to be buggy sometimes. (Matthias) */ 
	  refresh_type = SLOW;
	}
      else if(event.xvisibility.state == VisibilityPartiallyObscured)
	{
	  refresh_type = SLOW;
  	  scr_refresh(0,0,MyWinInfo.cwidth,MyWinInfo.cheight);  
	}
      else
	{
	  refresh_type = DONT_BOTHER;
	}
      break;

    case FocusIn:
      scr_focus(1);
      return 0;
    case FocusOut:
      scr_focus(0);
      return 0;
    case ConfigureNotify:
      resize_window(0,0);
      size_set = 1;
      return 0;
    case ButtonPress:
      if (event.xany.window == vt_win)
	{
	    if (mouse_rep && ((event.xbutton.state & ShiftMask) == 0)
		&& !mouse_block) {
		mouse_report (&(event.xbutton), 0);
		return 1;
	    } else {
	      switch (event.xbutton.button)
		{
		case Button1 :
		  /* recognize multiclick. bmg */
		    if (event.xbutton.time-buttonpress_time < MULTICLICK_TIME) {
		    clicks++;
		  } else {
		    clicks = 1;
		  }

		    /* don't react two times on the same event */
		    /* Matthias */
		    if (event.xbutton.time == buttonpress_time)
			clicks--;
		  buttonpress_time = event.xbutton.time;

		  scr_start_selection(clicks, event.xbutton.x,event.xbutton.y);
		  return 0;
		  /* deactivated since Button3 is for popupmenu. Matthias */ 
		  /* case Button3 : */
		  /* scr_extend_selection(event.xbutton.x,event.xbutton.y); */

		  /* Scroll up */
		case Button4:
		    MyWinInfo.offset += 3;
		    
		    /* check to make sure we aren't at the top already */
		    if (MyWinInfo.offset > MyWinInfo.sline_top)
			{
			    MyWinInfo.offset = MyWinInfo.sline_top;
			}
		    screen_refresh();
		    return 0;

		    /* Scroll down */
		case Button5:
		    MyWinInfo.offset -= 3;

		    /* check to make sure we aren't at the bottom already */
		    if (MyWinInfo.offset < 0)
			{
			    MyWinInfo.offset = 0;
			}
		    screen_refresh();
		    return 0;
		default:
		  return 0;
		}
	    }
	}
      return 0;
    case ButtonRelease:
      if (event.xany.window == vt_win)
	{
	    if (mouse_rep && ((event.xbutton.state & ShiftMask) == 0)
		&& !mouse_block) {
		mouse_report (&(event.xbutton), 1);
		return 1;
	    } else {
	      switch (event.xbutton.button)
		{
		case Button1:
		  /* no longer needed bmg */
		  /* case Button3: */

		  scr_make_selection(event.xbutton.time);
		  return 0;
		case Button2:
		    if ((event.xbutton.state & Mod1Mask) == 0)
			scr_paste_selection();
		  return 0;
		}
	    }
	}
      return 0;
    case MotionNotify:

      if (event.xany.window == vt_win && 
	  ((event.xbutton.state & Button1Mask) == Button1Mask)
	   && !(event.xbutton.state & Button2Mask))
	{
	  while(XCheckTypedWindowEvent(display, vt_win, MotionNotify, &event));
	  XQueryPointer(display,vt_win,&root,&child,
			&root_x,&root_y,&x,&y,&mods);
	  scr_extend_selection(x,y);
	  return 0;
	}
      return 0;
    default:
      return 0;
    }

    return 0;
}
示例#27
0
static unsigned int get_com_char(int flags)
{
  fd_set in_fdset;
  int count,retval;
  unsigned char val;
  struct itimerval value;
/*   static int refreshed = 0; */
  int total;

  /* If there have been a lot of new lines, then update the screen */
  /* What the heck I'll cheat and only refresh less than every page-full.
   * the number of pages between refreshes is refresh_nl_limit, which
   * is incremented here because we must be doing flat-out scrolling. */
  /* refreshing should be correct for small scrolls, because of the 
   * time-out */
  if(refresh_nl_count > refresh_nl_limit*MyWinInfo.cheight)
    {
      if(refresh_nl_limit < MAX_REFRESH_PERIOD)
	refresh_nl_limit++;
      refresh_nl_count = 0;
      refreshed = 1;
      screen_refresh();
    }

  /* If we have characters already read in. return one */
  if (com_buf_next < com_buf_top)
    {
      refreshed = 0;
      return((unsigned int) (*com_buf_next++ & mask) );
    }
  /* Nothing to read, either return now or continue and wait */

  if (flags & BUF_ONLY) {
    refresh_nl_count = 0;
    refresh_nl_limit = 1; 
    if(!refreshed)
      screen_refresh();
    refreshed = 1;
    /* scrollbar movements are done in screen_refresh now (Matthias) */
    /*	  sbar_show(MyWinInfo.cheight+MyWinInfo.sline_top-1,MyWinInfo.offset,
	  MyWinInfo.offset + MyWinInfo.cheight -1); */
    XFlush(display);
    return ((unsigned int) GCC_NULL); 
  }

/*   for (;;)  */
/*     { */
       /* process any X events that are pending */ 
/*       while(XPending(display)) */
/* 	{ */
 /* 	  refreshed = 0;	   */
/* 	  get_X_event(); */
/* 	} */

       /* Nothing to do! */ 
       FD_ZERO(&in_fdset); 
       FD_SET(comm_fd,&in_fdset); 


       /* select handling slightly changed. Yet the "main" select (with blocking)
	  is inside the Qt event loop. Important. Matthias */

/*         value.it_value.tv_usec = 1000;   */
/*         value.it_value.tv_sec = 0;   */
/*         if(!refreshed)   */
/* 	  retval = select(fd_width,&in_fdset,NULL,NULL,&value.it_value);  */
/*         else   */
/* 	  retval = select(fd_width,&in_fdset,NULL,NULL,NULL);  */


/*        if (!refreshed){ */
/* 	 value.it_value.tv_usec = 1000;   */
/* 	 value.it_value.tv_sec = 0;   */
/*        } */
/*        else { */
/* 	 value.it_value.tv_usec = 0;   */
/* 	 value.it_value.tv_sec = 0;   */
/*        } */
       if (!refreshed){
	 value.it_value.tv_usec = 0;  
	 value.it_value.tv_sec = 1;  
       }
       else {
	 value.it_value.tv_usec = 0;  
	 value.it_value.tv_sec = 1;  
       }
       retval = select(fd_width,&in_fdset,NULL,NULL,&value.it_value); 


     /* See if we can read from the application */
       if(FD_ISSET(comm_fd,&in_fdset)) 
	{
	  count = 1;
	  com_buf_next = com_buf;
	  com_buf_top = com_buf;
	  total = COM_BUF_SIZE;
	  while((count > 0)&&(total>COM_BUF_SIZE/2))
	    {
	      count = read(comm_fd,com_buf_top,total);
	      if(count > 0)
		{
		  com_buf_top += count;
		  total -= count;
		}
	    }
	  if (com_buf_top > com_buf_next)
	    {
	      val = *com_buf_next++;
	      refreshed = 0;
	      return((unsigned int) (val & mask));	  
	    }
	}
      /* If the select statement timed out, we better update the screen */
       if(retval == 0 ) 
	 {
	  refresh_nl_count = 0;
	  refresh_nl_limit = 1; 
	  if(!refreshed)
	    screen_refresh();
	  refreshed = 1;
/* scrollbar movements are done in screen_refresh now (Matthias) */
/*	  sbar_show(MyWinInfo.cheight+MyWinInfo.sline_top-1,MyWinInfo.offset,
		    MyWinInfo.offset + MyWinInfo.cheight -1); */
	  XFlush(display);
	}

      return (unsigned int) GCC_NULL;
}
示例#28
0
void screen_redraw()
{
	// Should implement extended lost device checking
	//if (d3ddev == NULL ) return;
	
	// Clean up any textures that ENIGMA may still think are binded but actually are not
	texture_reset();

    d3ddev->BeginScene();    // begins the 3D scene
	dsprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_DO_NOT_ADDREF_TEXTURE);
		
	if (!view_enabled)
    {
		D3DVIEWPORT9 pViewport = { 0, 0, (DWORD)window_get_region_width_scaled(), (DWORD)window_get_region_height_scaled(), 0, 1.0f };
		d3ddev->SetViewport(&pViewport);
		
		D3DXMATRIX matTrans, matScale;

		// Calculate a translation matrix
		D3DXMatrixTranslation(&matTrans, -0.5, -room_height - 0.5, 0);
		D3DXMatrixScaling(&matScale, 1, -1, 1);
		
		// Calculate our world matrix by multiplying the above (in the correct order)
		D3DXMATRIX matWorld = matTrans * matScale;

		// Set the matrix to be applied to anything we render from now on
		d3ddev->SetTransform( D3DTS_VIEW, &matWorld);
	
		D3DXMATRIX matProjection;    // the projection transform matrix
		D3DXMatrixOrthoOffCenterLH(&matProjection,
							0,
							(FLOAT)room_width,   
							0, 
							(FLOAT)room_height,   
							0.0f,    // the near view-plane
							1.0f);    // the far view-plane
		d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);    // set the projection transform
		
		if (background_showcolor)
		{
			int clearcolor = ((int)background_color) & 0x00FFFFFF;
			// clear the window to the background color
			d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(__GETR(clearcolor), __GETG(clearcolor), __GETB(clearcolor)), 1.0f, 0);
			// clear the depth buffer
		}

		// Clear the depth buffer if 3d mode is on at the beginning of the draw step.
        if (enigma::d3dMode)
			d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
		
        draw_back();

	
        // Apply and clear stored depth changes.
        for (map<int,pair<double,double> >::iterator it = id_to_currentnextdepth.begin(); it != id_to_currentnextdepth.end(); it++)
        {
            enigma::object_graphics* inst_depth = (enigma::object_graphics*)enigma::fetch_instance_by_id((*it).first);
            if (inst_depth != NULL) {
                drawing_depths[(*it).second.first].draw_events->unlink(inst_depth->depth.myiter);
                inst_iter* mynewiter = drawing_depths[(*it).second.second].draw_events->add_inst(inst_depth->depth.myiter->inst);
                if (instance_event_iterator == inst_depth->depth.myiter) {
                    instance_event_iterator = inst_depth->depth.myiter->prev;
                }
                inst_depth->depth.myiter = mynewiter;
            }
        }
        id_to_currentnextdepth.clear();

        if (enigma::particles_impl != NULL) {
            const double high = numeric_limits<double>::max();
            const double low = drawing_depths.rbegin() != drawing_depths.rend() ? drawing_depths.rbegin()->first : -numeric_limits<double>::max();
            (enigma::particles_impl->draw_particlesystems)(high, low);
        }
        bool stop_loop = false;
        for (enigma::diter dit = drawing_depths.rbegin(); dit != drawing_depths.rend(); dit++)
        {
            if (dit->second.tiles.size())
                //glCallList(drawing_depths[dit->second.tiles[0].depth].tilelist);

            texture_reset();
            enigma::inst_iter* push_it = enigma::instance_event_iterator;
            //loop instances
            for (enigma::instance_event_iterator = dit->second.draw_events->next; enigma::instance_event_iterator != NULL; enigma::instance_event_iterator = enigma::instance_event_iterator->next) {
                enigma::instance_event_iterator->inst->myevent_draw();
                if (enigma::room_switching_id != -1) {
                    stop_loop = true;
                    break;
                }
            }
            enigma::instance_event_iterator = push_it;
            if (stop_loop) break;
            //particles
            if (enigma::particles_impl != NULL) {
                const double high = dit->first;
                dit++;
                const double low = dit != drawing_depths.rend() ? dit->first : -numeric_limits<double>::max();
                dit--;
                (enigma::particles_impl->draw_particlesystems)(high, low);
            }
        }
		//return;
    }
    else
    {
        bool stop_loop = false;
        for (view_current = 0; view_current < 7; view_current++)
        {
            if (view_visible[(int)view_current])
            {
                int vc = (int)view_current;
                int vob = (int)view_object[vc];

                if (vob != -1)
                {
                    object_basic *instanceexists = fetch_instance_by_int(vob);

                    if (instanceexists)
                    {
                        object_planar* vobr = (object_planar*)instanceexists;

                        double vobx = vobr->x, voby = vobr->y;

                        //int bbl=*vobr.x+*vobr.bbox_left,bbr=*vobr.x+*vobr.bbox_right,bbt=*vobr.y+*vobr.bbox_top,bbb=*vobr.y+*vobr.bbox_bottom;
                        //if (bbl<view_xview[vc]+view_hbor[vc]) view_xview[vc]=bbl-view_hbor[vc];

                        double vbc_h, vbc_v;
                        (view_hborder[vc] > view_wview[vc]/2) ? vbc_h = view_wview[vc]/2 : vbc_h = view_hborder[vc];
                        (view_vborder[vc] > view_hview[vc]/2) ? vbc_v = view_hview[vc]/2 : vbc_v = view_vborder[vc];

                        if (view_hspeed[vc] == -1)
                        {
                            if (vobx < view_xview[vc] + vbc_h)
                                view_xview[vc] = vobx - vbc_h;
                            else if (vobx > view_xview[vc] + view_wview[vc] - vbc_h)
                                view_xview[vc] = vobx + vbc_h - view_wview[vc];
                        }
                        else
                        {
                            if (vobx < view_xview[vc] + vbc_h)
                            {
                                view_xview[vc] -= view_hspeed[vc];
                                if (view_xview[vc] < vobx - vbc_h)
                                    view_xview[vc] = vobx - vbc_h;
                            }
                            else if (vobx > view_xview[vc] + view_wview[vc] - vbc_h)
                            {
                                view_xview[vc] += view_hspeed[vc];
                                if (view_xview[vc] > vobx + vbc_h - view_wview[vc])
                                    view_xview[vc] = vobx + vbc_h - view_wview[vc];
                            }
                        }

                        if (view_vspeed[vc] == -1)
                        {
                            if (voby < view_yview[vc] + vbc_v)
                                view_yview[vc] = voby - vbc_v;
                            else if (voby > view_yview[vc] + view_hview[vc] - vbc_v)
                                view_yview[vc] = voby + vbc_v - view_hview[vc];
                        }
                        else
                        {
                            if (voby < view_yview[vc] + vbc_v)
                            {
                                view_yview[vc] -= view_vspeed[vc];
                                if (view_yview[vc] < voby - vbc_v)
                                    view_yview[vc] = voby - vbc_v;
                            }
                            if (voby > view_yview[vc] + view_hview[vc] - vbc_v)
                            {
                                view_yview[vc] += view_vspeed[vc];
                                if (view_yview[vc] > voby + vbc_v - view_hview[vc])
                                    view_yview[vc] = voby + vbc_v - view_hview[vc];
                            }
                        }

                        if (view_xview[vc] < 0)
                            view_xview[vc] = 0;
                        else if (view_xview[vc] > room_width - view_wview[vc])
                            view_xview[vc] = room_width - view_wview[vc];

                        if (view_yview[vc] < 0)
                            view_yview[vc] = 0;
                        else if (view_yview[vc] > room_height - view_hview[vc])
                            view_yview[vc] = room_height - view_hview[vc];
                    }
                }
				
				D3DVIEWPORT9 pViewport = { (DWORD)view_xport[vc], (DWORD)view_yport[vc], 
					(DWORD)(window_get_region_width_scaled() - view_xport[vc]), (DWORD)(window_get_region_height_scaled() - view_yport[vc]), 0, 1.0f };
				d3ddev->SetViewport(&pViewport);
		
				D3DXMATRIX matTrans, matScale;

				// Calculate a translation matrix
				D3DXMatrixTranslation(&matTrans, -view_xview[vc] - 0.5, -view_yview[vc] - room_height - 0.5, 0);
				D3DXMatrixScaling(&matScale, 1, -1, 1);
		
				// Calculate our world matrix by multiplying the above (in the correct order)
				D3DXMATRIX matWorld = matTrans * matScale;

				// Set the matrix to be applied to anything we render from now on
				d3ddev->SetTransform( D3DTS_VIEW, &matWorld);
	
				D3DXMATRIX matProjection;    // the projection transform matrix
				D3DXMatrixOrthoOffCenterLH(&matProjection,
							0,
							(FLOAT)view_wview[vc],   
							0, 
							(FLOAT)view_hview[vc],   
							0.0f,    // the near view-plane
							1.0f);    // the far view-plane
				d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);    // set the projection transform
				
				if (background_showcolor && view_current == 0)
				{
					int clearcolor = ((int)background_color) & 0x00FFFFFF;
					// clear the window to the background color
					d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(__GETR(clearcolor), __GETG(clearcolor), __GETB(clearcolor)), 1.0f, 0);
				}
				
				// Clear the depth buffer if 3d mode is on at the beginning of the draw step.
                if (enigma::d3dMode)
                    d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

                if (view_current == 0) {
					draw_back();
				}

                // Apply and clear stored depth changes.
                for (map<int,pair<double,double> >::iterator it = id_to_currentnextdepth.begin(); it != id_to_currentnextdepth.end(); it++)
                {
                    enigma::object_graphics* inst_depth = (enigma::object_graphics*)enigma::fetch_instance_by_id((*it).first);
                    if (inst_depth != NULL) {
                        drawing_depths[(*it).second.first].draw_events->unlink(inst_depth->depth.myiter);
                        inst_iter* mynewiter = drawing_depths[(*it).second.second].draw_events->add_inst(inst_depth->depth.myiter->inst);
                        if (instance_event_iterator == inst_depth->depth.myiter) {
                            instance_event_iterator = inst_depth->depth.myiter->prev;
                        }
                        inst_depth->depth.myiter = mynewiter;
                    }
                }
                id_to_currentnextdepth.clear();

                if (enigma::particles_impl != NULL) {
                    const double high = numeric_limits<double>::max();
                    const double low = drawing_depths.rbegin() != drawing_depths.rend() ? drawing_depths.rbegin()->first : -numeric_limits<double>::max();
                    (enigma::particles_impl->draw_particlesystems)(high, low);
                }
                for (enigma::diter dit = drawing_depths.rbegin(); dit != drawing_depths.rend(); dit++)
                {
                    if (dit->second.tiles.size())
                        //glCallList(drawing_depths[dit->second.tiles[0].depth].tilelist);

                    texture_reset();
                    enigma::inst_iter* push_it = enigma::instance_event_iterator;
                    //loop instances
                    for (enigma::instance_event_iterator = dit->second.draw_events->next; enigma::instance_event_iterator != NULL; enigma::instance_event_iterator = enigma::instance_event_iterator->next) {
                        enigma::instance_event_iterator->inst->myevent_draw();
                        if (enigma::room_switching_id != -1) {
                            stop_loop = true;
                            break;
                        }
                    }
                    enigma::instance_event_iterator = push_it;
                    if (stop_loop) break;
                    //particles
                    if (enigma::particles_impl != NULL) {
                        const double high = dit->first;
                        dit++;
                        const double low = dit != drawing_depths.rend() ? dit->first : -numeric_limits<double>::max();
                        dit--;
                        (enigma::particles_impl->draw_particlesystems)(high, low);
                    }
                }
                if (stop_loop) break;
            }
        }
        view_current = 0;
    }
	
	int culling = d3d_get_culling();
	d3d_set_culling(rs_none);

	// Now process the sub event of draw called draw gui
	// It is for drawing GUI elements without view scaling and transformation
    if (enigma::gui_used)
    {
		// Now process the sub event of draw called draw gui 
		// It is for drawing GUI elements without view scaling and transformation
		D3DVIEWPORT9 pViewport = { 0, 0, window_get_region_width_scaled(), window_get_region_height_scaled(), 0, 1.0f };
		d3ddev->SetViewport(&pViewport);
		
		D3DXMATRIX matTrans, matScale;

		// Calculate a translation matrix
		D3DXMatrixTranslation(&matTrans, -0.5, -room_height - 0.5, 0);
		D3DXMatrixScaling(&matScale, 1, -1, 1);
		
		// Calculate our world matrix by multiplying the above (in the correct order)
		D3DXMATRIX matWorld = matTrans * matScale;

		// Set the matrix to be applied to anything we render from now on
		d3ddev->SetTransform( D3DTS_VIEW, &matWorld);
	
		D3DXMATRIX matProjection;    // the projection transform matrix
		D3DXMatrixOrthoOffCenterLH(&matProjection,
							0,
							(FLOAT)enigma::gui_width,   
							0, 
							(FLOAT)enigma::gui_height,   
							0.0f,    // the near view-plane
							1.0f);    // the far view-plane
		d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);    // set the projection transform

		//dsprite->SetWorldViewRH(NULL, &matWorld);

		// Clear the depth buffer if hidden surface removal is on at the beginning of the draw step.
        if (enigma::d3dMode)
			d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
			
		d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
			
        bool stop_loop = false;
        for (enigma::diter dit = drawing_depths.rbegin(); dit != drawing_depths.rend(); dit++)
        {
            enigma::inst_iter* push_it = enigma::instance_event_iterator;
            //loop instances
            for (enigma::instance_event_iterator = dit->second.draw_events->next; enigma::instance_event_iterator != NULL; enigma::instance_event_iterator = enigma::instance_event_iterator->next) {
				enigma::instance_event_iterator->inst->myevent_drawgui();
                if (enigma::room_switching_id != -1) {
                    stop_loop = true;
                    break;
                }
            }
            enigma::instance_event_iterator = push_it;
            if (stop_loop) break;
        }
		
	}
	
	// Textures should be clamped when rendering 2D sprites and stuff, so memorize it.
	DWORD wrapu, wrapv, wrapw;
	d3ddev->GetSamplerState( 0, D3DSAMP_ADDRESSU, &wrapu );
	d3ddev->GetSamplerState( 0, D3DSAMP_ADDRESSV, &wrapv );
	d3ddev->GetSamplerState( 0, D3DSAMP_ADDRESSW, &wrapw );
	
	d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
	d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
	d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP );
	// The D3D sprite batcher uses clockwise face culling which is default but can't tell if 
	// this here should memorize it and force it to CW all the time and then reset what the user had
	// or not.
	//d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
	dsprite->End();
	// And now reset the texture repetition.
	d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSU, wrapu );
	d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSV, wrapv );
	d3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSW, wrapw );
	
	// reset the culling
	d3d_set_culling(culling);
    d3ddev->EndScene();    // ends the 3D scene
		
	screen_refresh();
}
示例#29
0
/* redraw nick */
static void statusbar_nick(SBAR_ITEM_REC *item, int ypos)
{
    CHANNEL_REC *channel;
    IRC_SERVER_REC *server;
    NICK_REC *nickrec;
    int size_needed;
    int umode_size;
    gchar nick[10];

    server = (IRC_SERVER_REC *) (active_win == NULL ? NULL : active_win->active_server);

    umode_size = server == NULL || server->usermode == NULL ? 0 : strlen(server->usermode)+3;

    /* nick */
    if (server == NULL || server->nick == NULL)
    {
        nick[0] = '\0';
        nickrec = NULL;
    }
    else
    {
        strncpy(nick, server->nick, 9);
	nick[9] = '\0';

        channel = irc_item_channel(active_win->active);
	nickrec = channel == NULL ? NULL : nicklist_find(channel, server->nick);
    }

    size_needed = 2 + strlen(nick) + umode_size +
        (server != NULL && server->usermode_away ? 7 : 0) +
        (nickrec != NULL && (nickrec->op || nickrec->voice) ? 1 : 0); /* @ + */

    if (item->size != size_needed)
    {
        /* we need more (or less..) space! */
        statusbar_item_resize(item, size_needed);
        return;
    }

    /* size ok, draw the nick */
    move(ypos, item->xpos);

    set_color((1 << 4)+3); addch('[');
    if (nickrec != NULL && (nickrec->op || nickrec->voice))
    {
        set_color((1 << 4)+15); addch(nickrec->op ? '@' : '+');
    }
    set_color((1 << 4)+7); addstr(nick);
    if (umode_size)
    {
        set_color((1 << 4)+15); addch('(');
        set_color((1 << 4)+3); addch('+');
        set_color((1 << 4)+7); addstr(server->usermode);
        set_color((1 << 4)+15); addch(')');
        if (server->usermode_away)
        {
            set_color((1 << 4)+7); addstr(" (");
            set_color((1 << 4)+10); addstr("zZzZ");
            set_color((1 << 4)+7); addch(')');
        }
    }
    set_color((1 << 4)+3); addch(']');
    screen_refresh();
}
示例#30
0
/* redraw channel */
static void statusbar_channel(SBAR_ITEM_REC *item, int ypos)
{
    WINDOW_REC *window;
    WI_ITEM_REC *witem;
    CHANNEL_REC *channel;
    SERVER_REC *server;
    gchar channame[21], winnum[MAX_INT_STRLEN], *mode;
    int size_needed;
    int mode_size;

    window = item->bar->pos != STATUSBAR_POS_MIDDLE ? active_win :
            mainwindow_find_sbar(item);
    server = window == NULL ? NULL : window->active_server;

    ltoa(winnum, window == NULL ? 0 : window->refnum);

    witem = window != NULL && irc_item_check(window->active) ?
	    window->active : NULL;
    if (witem == NULL)
    {
	/* display server tag */
        channame[0] = '\0';
        mode = NULL;
	mode_size = 0;

	size_needed = 3 + strlen(winnum) + (server == NULL ? 0 : strlen(server->tag));
    }
    else
    {
	/* display channel + mode */
        strncpy(channame, witem->name, 20); channame[20] = '\0';

	channel = irc_item_channel(witem);
	if (channel == NULL) {
                mode_size = 0;
		mode = NULL;
	} else {
		mode = channel_get_mode(channel);
		mode_size = strlen(mode);
		if (mode_size > 0) mode_size += 3; /* (+) */
	}

	size_needed = 3 + strlen(winnum) + strlen(channame) + mode_size;
    }

    if (item->size != size_needed)
    {
        /* we need more (or less..) space! */
        statusbar_item_resize(item, size_needed);
        if (mode != NULL) g_free(mode);
        return;
    }

    move(ypos, item->xpos);
    set_color((1 << 4)+3); addch('[');

    /* window number */
    set_color((1 << 4)+7); addstr(winnum);
    set_color((1 << 4)+3); addch(':');

    if (channame[0] == '\0' && server != NULL)
    {
	/* server tag */
	set_color((1 << 4)+7); addstr(server->tag);
    }
    else if (channame[0] != '\0')
    {
	/* channel + mode */
	set_color((1 << 4)+7); addstr(channame);
	if (mode_size)
	{
	    set_color((1 << 4)+15); addch('(');
	    set_color((1 << 4)+3); addch('+');
	    set_color((1 << 4)+7); addstr(mode);
	    set_color((1 << 4)+15); addch(')');
	}
    }
    set_color((1 << 4)+3); addch(']');
    screen_refresh();

    if (mode != NULL) g_free(mode);
}