Example #1
0
static void selSelect(rfbSelectData* m,int _index)
{
  int delta;

  if(_index==m->selected || _index<0 || _index>=m->listSize)
    return;

  if(m->selected>=0)
    selPaintLine(m,m->selected-m->displayStart,FALSE);

  if(_index<m->displayStart || _index>=m->displayStart+m->pageH) {
    /* targetLine is the screen line in which the selected line will
       be displayed.
       targetLine = m->pageH/2 doesn't look so nice */
    int targetLine = m->selected-m->displayStart;
    int lineStart,lineEnd;

    /* scroll */
    if(_index<targetLine)
      targetLine = _index;
    else if(_index+m->pageH-targetLine>=m->listSize)
      targetLine = _index+m->pageH-m->listSize;
    delta = _index-(m->displayStart+targetLine);

    if(delta>-m->pageH && delta<m->pageH) {
      if(delta>0) {
	lineStart = m->pageH-delta;
	lineEnd = m->pageH;
	rfbDoCopyRect(m->screen,m->x1,m->y1,m->x2,m->y1+lineStart*m->textH,
		      0,-delta*m->textH);
      } else {
	lineStart = 0;
	lineEnd = -delta;
	rfbDoCopyRect(m->screen,
		      m->x1,m->y1+lineEnd*m->textH,m->x2,m->y2,
		      0,-delta*m->textH);
      }
    } else {
      lineStart = 0;
      lineEnd = m->pageH;
    }
    m->displayStart += delta;
    for(delta=lineStart;delta<lineEnd;delta++)
      if(delta!=_index)
	selPaintLine(m,delta,FALSE);
  }

  m->selected = _index;
  selPaintLine(m,m->selected-m->displayStart,TRUE);

  if(m->selChangedHook)
    m->selChangedHook(_index);

  /* todo: scrollbars */
}
Example #2
0
/* before using this function, hide the cursor */
void vcScroll(vncConsolePtr c,int lineCount)
{
  int y1,y2;
  rfbScreenInfoPtr s=c->screen;

  if(lineCount==0)
    return;

  /* rfbLog("begin scroll\n"); */
  vcHideCursor(c);
  c->dontDrawCursor=TRUE;

  if(lineCount>=c->height || lineCount<=-c->height) {
    y1=0; y2=s->height;
  } else if(lineCount>0) {
    y1=s->height-lineCount*c->cHeight; y2=s->height;
    rfbDoCopyRect(s,0,0,s->width,y1,0,-lineCount*c->cHeight);
    memmove(c->screenBuffer,
	    c->screenBuffer+(c->height-lineCount)*c->width,
	    (c->height-lineCount)*c->width);
#ifdef USE_ATTRIBUTE_BUFFER
    if(c->attributeBuffer)
	    memmove(c->attributeBuffer,
		    c->attributeBuffer+(c->height-lineCount)*c->width,
		    (c->height-lineCount)*c->width);
#endif
  } else {
    y1=0; y2=-lineCount*c->cHeight;
    rfbDoCopyRect(s,0,y2,s->width,s->height,0,-lineCount*c->cHeight);
    memmove(c->screenBuffer-lineCount*c->width,
	    c->screenBuffer,
	    (c->height+lineCount)*c->width);
#ifdef USE_ATTRIBUTE_BUFFER
    if(c->attributeBuffer)
	    memmove(c->attributeBuffer-lineCount*c->width,
		    c->attributeBuffer,
		    (c->height+lineCount)*c->width);
#endif
  }

  c->dontDrawCursor=FALSE;
  memset(s->frameBuffer+y1*s->width,c->backColour,(y2-y1)*s->width);
  rfbMarkRectAsModified(s,0,y1-c->cHeight,s->width,y2);
  memset(c->screenBuffer+y1/c->cHeight*c->width,' ',
	 (y2-y1)/c->cHeight*c->width);
#ifdef USE_ATTRIBUTE_BUFFER
  if(c->attributeBuffer)
	  memset(c->attributeBuffer+y1/c->cHeight*c->width,0x07,
		 (y2-y1)/c->cHeight*c->width);
#endif
  /* rfbLog("end scroll\n"); */
}  
int main(int argc,char** argv)
{             
  int width=400,height=300,w=20,x,y;
  double r,phi=0;
  
  rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,width,height,8,3,4);
  server->frameBuffer=(char*)malloc(width*height*4);
  initBackground(server);
  server->deferUpdateTime=0;
  rfbInitServer(server);

  r=0;
  while(1) {
    if(r<=0) {
      initBackground(server);
      rfbMarkRectAsModified(server,0,0,width,height);
      r=0.43;
      phi=0;
    } else {
      r-=0.0001;
      phi+=0.02;
      if(phi>2*M_PI)
	phi-=2*M_PI;
    }
    x=width*(0.5+cos(phi)*r);
    y=height*(0.5+sin(phi)*r);
    if(x>=0 && y>=0 && x+w<=width && y+w<=height) {
      unsigned int dx=width*0.5*(1-cos(phi)*r)-x,
      		dy=height*0.5*(1-sin(phi)*r)-y;
      rfbDoCopyRect(server,x,y,x+w,y+w,-dx,-dy);
    }
    rfbProcessEvents(server,50000);
  }
  return(0);
}
Example #4
0
void vcInsertCharacters(vncConsolePtr c, int f)
{
	int g, x, y;

	g = c->width - c->x - f;
	if( g > 0 )
	{
		vcHideCursor(c);
		memmove(c->screenBuffer + c->y * c->width + c->x + f,
				c->screenBuffer + c->y * c->width + c->x,
				g);
#ifdef USE_ATTRIBUTE_BUFFER
		if( c->attributeBuffer )
			memmove(c->attributeBuffer + c->y * c->width + c->x + f,
					c->attributeBuffer + c->y * c->width + c->x,
					g);
#endif
		x = c->x * c->cWidth;
		y = c->y * c->cHeight;
		rfbDoCopyRect( c->screen,
					   x + f * c->cWidth, y,
					   c->screen->width,
					   y + c->cHeight,
					   f * c->cWidth, 0);
	}
	// TODO: Should we put f*' ' here or rely on the fact that client will provide
	// proper ones after insert request?
}
Example #5
0
void vcDeleteCharacters(vncConsolePtr c, int f)
{
	int g, x, y;
	g = c->width - c->x - f;
	x = c->x * c->cWidth;
	y = c->y * c->cHeight;
	vcHideCursor(c);
	if (g > 0)
	{
		memcpy(c->screenBuffer + c->y * c->width + c->x,
			   c->screenBuffer + c->y * c->width + c->x + f,
			   g);
#ifdef USE_ATTRIBUTE_BUFFER
		if( c->attributeBuffer )
			memcpy(c->attributeBuffer + c->y * c->width + c->x,
				   c->attributeBuffer + c->y * c->width + c->x + f,
				   g);
#endif
		rfbDoCopyRect( c->screen,
					   x, y,
					   c->screen->width - f * c->cWidth, y + c->cHeight,
					   - f * c->cWidth, 0);
	}
	memset( c->screenBuffer + c->y * c->width + g, ' ', f );
#ifdef USE_ATTRIBUTE_BUFFER
	if( c->attributeBuffer )
		memset( c->attributeBuffer + c->y * c->width + g, 0x07, f );
#endif
	rfbFillRect( c->screen,
				 x + g * c->cWidth, y,
				 c->screen->width, y + c->cHeight,
				 c->backColour);
}
Example #6
0
void vcDeleteLines(vncConsolePtr c, int from, int f)
{
	int g, y;
	g = c->sheight - from - f;
	y = from * c->cHeight;
	vcHideCursor(c);
	if( g > 0 )
	{
		memcpy(c->screenBuffer + from * c->width,
				c->screenBuffer + (from + f) * c->width,
				g * c->width);
#ifdef USE_ATTRIBUTE_BUFFER
		if( c->attributeBuffer )
			memcpy(c->attributeBuffer + from * c->width,
					c->attributeBuffer + (from + f) * c->width,
					g * c->width);
#endif
		rfbDoCopyRect( c->screen,
					   0, from * c->cHeight,
					   c->screen->width,
					   (c->sheight - f) * c->cHeight,
					   0, - f * c->cHeight);
	}
	// Fill inserted line(s) with spaces
	memset(c->screenBuffer + (from + g) * c->width,
		   ' ',
		   f * c->width);
#ifdef USE_ATTRIBUTE_BUFFER
	if(c->attributeBuffer)
		memset(c->screenBuffer + (from + g) * c->width,
			   0x07,
			   f * c->width);
#endif
	rfbFillRect( c->screen,
				 0, y + g * c->cHeight,
				 c->screen->width, c->sheight * c->cHeight,
				 c->backColour);
}
Example #7
0
static void output(rfbScreenInfoPtr s,char* line)
{
    rfbDoCopyRect(s,0,0,width,height-lineHeight,0,-lineHeight);
    rfbDrawString(s,&default8x16Font,10,lineY,line,0x01);
    rfbLog("%s\n",line);
}
Example #8
0
void output(rfbScreenInfoPtr s,char* line)
{
   rfbDoCopyRect(s,0,0,640,480-lineHeight,0,-lineHeight);
   rfbDrawString(s,&default8x16Font,10,lineY,line,0x01);
   fprintf(stderr,"%s\n",line);
}