Exemple #1
0
gcache::GCache::Params::Params (gu::Config& cfg, const std::string& data_dir)
    throw (gu::Exception)
    :
    rb_name   (name_value (cfg, data_dir)),
    dir_name  (cfg.get(GCACHE_PARAMS_DIR)),
    mem_size  (size_value (cfg,
                           GCACHE_PARAMS_MEM_SIZE, GCACHE_DEFAULT_MEM_SIZE)),
    rb_size   (size_value (cfg,
                           GCACHE_PARAMS_RB_SIZE, GCACHE_DEFAULT_RB_SIZE)),
    page_size (size_value (cfg,
                           GCACHE_PARAMS_PAGE_SIZE, GCACHE_DEFAULT_PAGE_SIZE)),
    keep_pages_size (size_value (cfg, GCACHE_PARAMS_KEEP_PAGES_SIZE,
                                      GCACHE_DEFAULT_KEEP_PAGES_SIZE))
{}
Exemple #2
0
	  void THRESHOLDOBJ::incoming_data(int port, float value)
      {
		int i;
		input=value;
		i = (int)size_value(in_ports[0].in_min,in_ports[0].in_max,value,-512.0f,512.0f,0);
		if (i < -512) i=-512;
		if (i > 512) i=512;
		// if ((i >= -512) && (i <= 512))
		buckets[i+512]++;
		adapt_num++;
      }
Exemple #3
0
void PORTOBJ::work(void)
{
	
	if ((triggermode==1)&&(old_trigger!=trigger))
	{
		if (trigger!=INVALID_VALUE) portval=val1;
	    else portval=val0;
		outportb(portaddress,portval);
		old_trigger=trigger; 
	}
	else if (triggermode == 2)
	{
		outportb(portaddress,portval);
	}
	else if (triggermode ==3)
	{
		int s_trigger;

		if (trigger!=INVALID_VALUE)
		{
		  s_trigger= (int) size_value(in_ports[0].in_min,in_ports[0].in_max,trigger,0.0f,255.0f,1);
		  portval=0;

		  if (s_trigger>0)    portval+=1;
		  if (s_trigger>=32)  portval+=2;
		  if (s_trigger>=64)  portval+=4;
		  if (s_trigger>=96)  portval+=8;
		  if (s_trigger>=128) portval+=16;
		  if (s_trigger>=160) portval+=32;
		  if (s_trigger>=192) portval+=64;
		  if (s_trigger>=224) portval+=128;
		} 
		else portval=val0;
		
		outportb(portaddress,portval);

	}

	if ((!TIMING.dialog_update) && (hDlg==ghWndToolbox)) 
	{
		if (triggermode!=0)
			update_bitpositions(hDlg, portval);
			
	}

	
	// pass_values(0, value);
}
Exemple #4
0
	  void THRESHOLDOBJ::work(void) 
	  {
		float l,x,sum;
		int t,i;

		x=(float)((input)*signal_gain/100.0);
		l=accu[accupos];
		avgsum+=x; // (float)input;
		
		if ((accupos>=999)||(accupos<0)) accupos=0; 
		else accupos++;

		accu[accupos]=x;
		sum=0;
		for (t=0;t<interval_len;t++)
		{
			i=accupos-t; if (i<0) i+=1000;
			sum+=accu[i];
		}
		gained_value=sum/interval_len;

		long interval=adapt_interval;

		if ((baseline) && (!usemedian)) { 
			interval*=PACKETSPERSECOND;
		}

        if (adapt_num >= interval)
        {
			if (usemedian) {
        		int numtrue, i, sum;
        		if (bigadapt != 0)
				{
            		numtrue = (int)(adapt_num * bigadapt / 100.0f);
					for (i = 1024, sum = 0; (i >= 0) && (sum < numtrue); i--)
					{
                		sum += buckets[i];
					}
					from_input = size_value(0.0f,1024.0f,(float)i,in_ports[0].in_min,in_ports[0].in_max,0);
					redraw=1;
				}
        		if (smalladapt != 0)
				{
            		numtrue = (int)(adapt_num * smalladapt / 100.0f);
					for (i = 0, sum = 0; (i <= 1024) && (sum < numtrue); i++)
					{
                		sum += buckets[i];
					}
					to_input = size_value(0.0f,1024.0f,(float)i,in_ports[0].in_min,in_ports[0].in_max,0);
					redraw=1;
				}
				empty_buckets();
			}
			else {
				if ((!baseline) || (firstadapt)) {
        			if (bigadapt != 0)
					{
						from_input = avgsum/interval*bigadapt/100.0f;
						redraw=1;
					}
        			if (smalladapt != 0)
					{
						to_input = avgsum/interval*smalladapt/100.0f;
						redraw=1;
					}
					firstadapt=0;
				}
			}
			adapt_num=0;
			avgsum=0;
		}
		
	
		x=gained_value;
		if (rising&&(l>=accu[accupos])) x=INVALID_VALUE;
		if (falling&&(l<=accu[accupos])) x=INVALID_VALUE;
		if (op&&((gained_value<from_input)||(gained_value>to_input)))  x=INVALID_VALUE;
		if ((!op)&&((gained_value<from_input)&&(gained_value>to_input)))  x=INVALID_VALUE;

		if (baseline && firstadapt) x=INVALID_VALUE;
		pass_values(0,x);
		
		if ((hDlg==ghWndToolbox)&&(!TIMING.dialog_update))
		{ 
			  char temp[100];

			  sprintf(temp,"%.2f",from_input);
			  SetDlgItemText(hDlg, IDC_AVGFROM, temp);
			  sprintf(temp,"%.2f",to_input);
			  SetDlgItemText(hDlg, IDC_AVGTO, temp);

			  if (smalladapt) SetScrollPos(GetDlgItem(hDlg,IDC_AVGTOBAR), SB_CTL,(int) size_value(in_ports[0].in_min,in_ports[0].in_max, to_input,0.0f,1000.0f,0),TRUE);
			  if (bigadapt) SetScrollPos(GetDlgItem(hDlg,IDC_AVGFROMBAR), SB_CTL,(int) size_value(in_ports[0].in_min,in_ports[0].in_max, from_input ,0.0f,1000.0f,0),TRUE);
			  
		}

		if ((displayWnd)&&(!TIMING.draw_update)&&(!GLOBAL.fly))  InvalidateRect(displayWnd,NULL,FALSE);
	  
	  }
Exemple #5
0
void draw_meter(THRESHOLDOBJ * st)
{
	PAINTSTRUCT ps;
	HDC hdc;
	char szdata[20];
	RECT rect;
	int  act,width,mid,height,bottom,y1,y2;
	HBRUSH actbrush,bkbrush;
	HPEN bkpen;
	float min, max;

	
	GetClientRect(st->displayWnd, &rect);
	//width=rect.right>>1;
	width=(int)((float)rect.right/200.0f*st->barsize);
	mid=rect.right>>1;
    	
	min=st->in_ports[0].in_min;
	max=st->in_ports[0].in_max;

	hdc = BeginPaint (st->displayWnd, &ps);
	bottom=rect.bottom-15;
	height=(bottom-rect.top-20);

    act=bottom-(int)(size_value(min,max,st->gained_value,0.0f,(float)height,0));
	y1 =bottom-(int)(size_value(min,max,(float)st->from_input,0.0f,(float)height,0));
	y2 =bottom-(int)(size_value(min,max,(float)st->to_input,0.0f,(float)height,0));

	if (act>bottom) act=bottom;
	if (act<bottom-height) act=bottom-height;

	actbrush=CreateSolidBrush(st->color);
    bkbrush=CreateSolidBrush(st->bkcolor);
	bkpen =CreatePen (PS_SOLID,1,st->bkcolor);
	if (st->redraw) FillRect(hdc, &rect,bkbrush);
    
   	SelectObject (hdc, bkpen);		
   	SelectObject (hdc, bkbrush);
	if (st->bigadapt)
	{
		Rectangle(hdc,15,st->old_y1,50,st->old_y1+15);
		MoveToEx(hdc,5, st->old_y1,NULL);	
		LineTo(hdc,rect.right, st->old_y1);
	}

	if (st->smalladapt)
	{
		Rectangle(hdc,15,st->old_y2,50,st->old_y2+15);
		MoveToEx(hdc,5, st->old_y2,NULL);	
		LineTo(hdc,rect.right, st->old_y2);
	}

	if ((st->last_value<act)&&(!st->redraw)) 
	{
			SelectObject (hdc, bkbrush);		
			Rectangle(hdc,mid-width,st->last_value,mid+width,act);
	}
	else
	{
			SelectObject (hdc, actbrush);
			Rectangle(hdc,mid-width,bottom,mid+width,act);
	}

	if ((st->fontsize>0))
	{
		RECT txtpos;int x;
		SelectObject(hdc, st->font);
		SetBkMode(hdc, OPAQUE);
		SetBkColor(hdc, st->fontbkcolor);
		SetTextColor(hdc,st->fontcolor);

		//wsprintf(szdata, "%d   ",(int)(st->gained_value+0.5f));
		//ExtTextOut( hdc, rect.right-40,10, 0, &rect,szdata, strlen(szdata), NULL ) ;

		txtpos.left=5;txtpos.right=50;
		txtpos.top=0;txtpos.bottom=0;
		if ((st->baseline) && (st->firstadapt)) 
			sprintf(szdata, "  ");
		else sprintf(szdata, " %.2f ",st->from_input);
		DrawText(hdc, szdata, -1, &txtpos, DT_CALCRECT);
		x=txtpos.bottom;
		txtpos.top=y1-x;txtpos.bottom=txtpos.top+x;
		DrawText(hdc, szdata, -1, &txtpos, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
	

		txtpos.left=5;txtpos.right=50;
		txtpos.top=0;txtpos.bottom=0;
		if ((st->baseline) && (st->firstadapt)) 
			sprintf(szdata, " get baseline ");
		else sprintf(szdata, " %.2f ",st->to_input);
		DrawText(hdc, szdata, -1, &txtpos, DT_CALCRECT);
//		txtpos.top=y2+1;txtpos.bottom+=y2+1;

		x=txtpos.bottom;
		txtpos.top=y2-x;txtpos.bottom=txtpos.top+x;


		DrawText(hdc, szdata, -1, &txtpos, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
		
	}
	
	SelectObject (hdc, DRAW.pen_ltblue);		
	MoveToEx(hdc,5, y1,NULL);	
	LineTo(hdc,rect.right, y1);
	st->old_y1=y1;

	MoveToEx(hdc,5, y2,NULL);	
	LineTo(hdc,rect.right, y2);
	st->old_y2=y2;

	DeleteObject(actbrush);
	DeleteObject(bkbrush);
	DeleteObject(bkpen);
	st->last_value=act;
	st->redraw=0;
	EndPaint( st->displayWnd, &ps );
}
Exemple #6
0
LRESULT CALLBACK ThresholdDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	static int init;
	char temp[100];
	THRESHOLDOBJ * st;
	int x;
	
	st = (THRESHOLDOBJ *) actobject;
    if ((st==NULL)||(st->type!=OB_THRESHOLD)) return(FALSE);

	for (x=0;x<GLOBAL.objects;x++) if (objects[x]==actobject) 
	{ char tmp[10]; wsprintf(tmp,"%d",x); 
	  //SendDlgItemMessage(ghWndStatusbox,IDC_LISTE,LB_ADDSTRING, 0, (LPARAM)(tmp)); 
	}
					

	switch( message )
	{
		case WM_INITDIALOG:
			{
				SCROLLINFO lpsi;
				
				
				lpsi.cbSize=sizeof(SCROLLINFO);
				lpsi.fMask=SIF_RANGE; // |SIF_POS;
				
				lpsi.nMin=1; lpsi.nMax=1000;
				SetScrollInfo(GetDlgItem(hDlg,IDC_AVGINTERVALBAR),SB_CTL,&lpsi,TRUE);
				SetScrollInfo(GetDlgItem(hDlg,IDC_ADAPTINTERVALBAR),SB_CTL,&lpsi,TRUE);

				lpsi.nMin=-1000; lpsi.nMax=1000;
				SetScrollInfo(GetDlgItem(hDlg,IDC_AVGGAINBAR),SB_CTL,&lpsi,TRUE);

				lpsi.nMin=0; lpsi.nMax=1000;
				SetScrollInfo(GetDlgItem(hDlg,IDC_AVGFROMBAR),SB_CTL,&lpsi,TRUE);
				SetScrollInfo(GetDlgItem(hDlg,IDC_AVGTOBAR),SB_CTL,&lpsi,TRUE);

				lpsi.nMin=0; lpsi.nMax=100;
				SetScrollInfo(GetDlgItem(hDlg,IDC_BARSIZEBAR),SB_CTL,&lpsi,TRUE);
				SetScrollInfo(GetDlgItem(hDlg,IDC_FONTSIZEBAR),SB_CTL,&lpsi,TRUE);

				init=TRUE;
				SetDlgItemInt(hDlg, IDC_AVGINTERVAL, st->interval_len,TRUE);
				SetDlgItemInt(hDlg, IDC_ADAPTINTERVAL, st->adapt_interval,TRUE);
				SetScrollPos(GetDlgItem(hDlg,IDC_AVGINTERVALBAR), SB_CTL,st->interval_len,TRUE);
				SetScrollPos(GetDlgItem(hDlg,IDC_ADAPTINTERVALBAR), SB_CTL,st->adapt_interval,TRUE);

				SetDlgItemInt(hDlg, IDC_AVGGAIN, st->signal_gain,1);
				SetScrollPos(GetDlgItem(hDlg,IDC_AVGGAINBAR), SB_CTL,st->signal_gain,TRUE);

				SetDlgItemInt(hDlg, IDC_BARSIZE, st->barsize,0);
				SetScrollPos(GetDlgItem(hDlg,IDC_BARSIZEBAR), SB_CTL,st->barsize,TRUE);
				SetDlgItemInt(hDlg, IDC_FONTSIZE, st->fontsize,0);
				SetScrollPos(GetDlgItem(hDlg,IDC_FONTSIZEBAR), SB_CTL,st->fontsize,TRUE);

				sprintf(temp,"%.2f",st->from_input);
				SetDlgItemText(hDlg, IDC_AVGFROM, temp);
				SetScrollPos(GetDlgItem(hDlg,IDC_AVGFROMBAR), SB_CTL,(int) size_value(st->in_ports[0].in_min,st->in_ports[0].in_max, st->from_input ,0.0f,1000.0f,0),TRUE);

				sprintf(temp,"%.2f",st->to_input);
				SetDlgItemText(hDlg, IDC_AVGTO, temp);
				SetScrollPos(GetDlgItem(hDlg,IDC_AVGTOBAR), SB_CTL,(int) size_value(st->in_ports[0].in_min,st->in_ports[0].in_max, st->to_input ,0.0f,1000.0f,0),TRUE);

				SetDlgItemInt(hDlg, IDC_BIGADAPT, st->bigadapt,TRUE);
				SetDlgItemInt(hDlg, IDC_SMALLADAPT, st->smalladapt,TRUE);

				SetDlgItemText(hDlg, IDC_METERCAPTION, st->wndcaption);

				CheckDlgButton(hDlg, IDC_AND,st->op);
				CheckDlgButton(hDlg, IDC_OR,!st->op);
				CheckDlgButton(hDlg, IDC_SHOWMETER,st->showmeter);
				CheckDlgButton(hDlg, IDC_RISING,st->rising);
				CheckDlgButton(hDlg, IDC_FALLING,st->falling);
				CheckDlgButton(hDlg, IDC_USE_MEDIAN,st->usemedian);
				CheckDlgButton(hDlg, IDC_BASELINE,st->baseline);
				if (st->baseline) SetDlgItemText(hDlg,IDC_INTERVALUNIT,"Seconds");
				else SetDlgItemText(hDlg,IDC_INTERVALUNIT,"Samples");

				init=FALSE;
			}
			return TRUE;
	
		case WM_CLOSE:
				EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			break;
		case WM_COMMAND:
			switch (LOWORD(wParam)) 
			{
			case IDC_AND: st->op=TRUE; break;
			case IDC_OR:  st->op=FALSE; break;
			case IDC_RISING: st->rising=IsDlgButtonChecked(hDlg,IDC_RISING); break;
			case IDC_FALLING: st->falling=IsDlgButtonChecked(hDlg,IDC_FALLING); break;
			case IDC_USE_MEDIAN: st->usemedian=IsDlgButtonChecked(hDlg,IDC_USE_MEDIAN); break;
			case IDC_BASELINE: st->baseline=IsDlgButtonChecked(hDlg,IDC_BASELINE); 
				if (st->baseline) SetDlgItemText(hDlg,IDC_INTERVALUNIT,"Seconds");
				else SetDlgItemText(hDlg,IDC_INTERVALUNIT,"Samples");
				break;
			case IDC_SELECTCOLOR:
				st->color=select_color(hDlg,st->color);
				st->redraw=1;
				InvalidateRect(hDlg,NULL,FALSE);
				break;
			case IDC_BKCOLOR:
				st->bkcolor=select_color(hDlg,st->bkcolor);
				st->redraw=1;
				InvalidateRect(hDlg,NULL,FALSE);
				break;
			case IDC_FONTCOL:
				st->fontcolor=select_color(hDlg,st->fontcolor);
				st->redraw=1;
				InvalidateRect(hDlg,NULL,FALSE);
				break;
			case IDC_FONTBKCOL:
				st->fontbkcolor=select_color(hDlg,st->fontbkcolor);
				st->redraw=1;
				InvalidateRect(hDlg,NULL,FALSE);
				break;

			case IDC_AVGFROM:
				GetDlgItemText(hDlg, IDC_AVGFROM,temp,sizeof(temp));
				if (!init)	
					 st->from_input=(float)atof(temp);
				break;
			case IDC_AVGTO:
				GetDlgItemText(hDlg, IDC_AVGTO,temp,sizeof(temp));
				if (!init) 
					st->to_input=(float)atof(temp);
				break;
			case IDC_AVGINTERVAL:
			case IDC_ADAPTINTERVAL:
			case IDC_AVGGAIN:
			case IDC_BIGADAPT:
			case IDC_SMALLADAPT:
			case IDC_METERCAPTION:
				 if (!init) 
					 apply_threshold(hDlg, st);
					break;

			
			case IDC_SHOWMETER:
				{  int i;
				   i=IsDlgButtonChecked(hDlg,IDC_SHOWMETER);
				   if ((st->showmeter)&&(!i)&&(st->displayWnd))  { DestroyWindow(st->displayWnd); st->displayWnd=NULL; }
				   if ((!st->showmeter)&&(i)) 
				   {  
					   if(!(st->displayWnd=CreateWindow("Meter_Class", st->wndcaption, WS_CLIPSIBLINGS| WS_CHILD | WS_CAPTION | WS_THICKFRAME ,st->left, st->top, st->right-st->left, st->bottom-st->top, ghWndMain, NULL, hInst, NULL)))
							report_error("can't create Meter Window");
					   else { st->last_value=0; ShowWindow( st->displayWnd, TRUE ); UpdateWindow( st->displayWnd ); }
				   }
				   st->showmeter=i;
				}
				break;

			}
			return TRUE;
			
		case WM_HSCROLL:
		{
			int nNewPos; float x;

			nNewPos=get_scrollpos(wParam,lParam);

			if (lParam == (long) GetDlgItem(hDlg,IDC_AVGINTERVALBAR))  SetDlgItemInt(hDlg, IDC_AVGINTERVAL,nNewPos,0);
			if (lParam == (long) GetDlgItem(hDlg,IDC_ADAPTINTERVALBAR))  SetDlgItemInt(hDlg, IDC_ADAPTINTERVAL,nNewPos,0);
			if (lParam == (long) GetDlgItem(hDlg,IDC_AVGGAINBAR))  SetDlgItemInt(hDlg, IDC_AVGGAIN,nNewPos,TRUE);
			if (lParam == (long) GetDlgItem(hDlg,IDC_BARSIZEBAR))  SetDlgItemInt(hDlg, IDC_BARSIZE,nNewPos,TRUE);
			if (lParam == (long) GetDlgItem(hDlg,IDC_FONTSIZEBAR))  SetDlgItemInt(hDlg, IDC_FONTSIZE,nNewPos,TRUE);
			if (lParam == (long) GetDlgItem(hDlg,IDC_AVGFROMBAR))
			{  
				  x=size_value(0.0f,1000.0f,(float)nNewPos,st->in_ports[0].in_min,st->in_ports[0].in_max,0);
				  sprintf(temp,"%.2f",x);
				  SetDlgItemText(hDlg, IDC_AVGFROM, temp);

			}
			if (lParam == (long) GetDlgItem(hDlg,IDC_AVGTOBAR))  
			{  
				  x=size_value(0.0f,1000.0f,(float)nNewPos,st->in_ports[0].in_min,st->in_ports[0].in_max,0);
			   	  sprintf(temp,"%.2f",x);
				  SetDlgItemText(hDlg, IDC_AVGTO, temp);
			}
			apply_threshold(hDlg,st);
			if (st->displayWnd) {st->last_value=INVALID_VALUE; st->redraw=1; InvalidateRect(st->displayWnd,NULL,TRUE);}
		
		}	break;
		case WM_SIZE:
		case WM_MOVE:  update_toolbox_position(hDlg);
		case WM_PAINT:
			color_button(GetDlgItem(hDlg,IDC_SELECTCOLOR),st->color);
			color_button(GetDlgItem(hDlg,IDC_BKCOLOR),st->bkcolor);
			color_button(GetDlgItem(hDlg,IDC_FONTCOL),st->fontcolor);
			color_button(GetDlgItem(hDlg,IDC_FONTBKCOL),st->fontbkcolor);
		break;
	}
    return FALSE;
}
Exemple #7
0
	  void BALLGAMEOBJ::incoming_data(int port, float value)
      {
        input = size_value(in_ports[0].in_min,in_ports[0].in_max,value,0.0f,100.0f,0);
      }
Exemple #8
0
	  void SPELLEROBJ::work(void) 
	  {
	    int i;


		if (mode==0)
		{
  		  enter=0;
		  if (((input!=63) && (oldinput==63)) || (input!=INVALID_VALUE) && (oldinput==INVALID_VALUE))
		  {
			enter=1;
			switchtime=0;
		  }
		  oldinput=input;

		  if (switchtime++> speed)
		  {

			switchtime=0;
			select++; 
			if (select>=selections) 
			{
			   select=0; 
			   selstart=0; selbegin=0; 
			   selections=entries; selend=selections; 
			   delchars=0; 

			   //selstart+=selections; 
			   //if (selstart>selend) selstart=0;
			}
			if (displayWnd) InvalidateRect(displayWnd,NULL,FALSE);

		  }
		}

		if (mode==1)
		{
			enter=0;
			
			if (waitres) 
			{
				if (input!=(int)oldinput)  waitres=0;
			}
			else
			{


				oldpaddle=paddle;
				paddle = ((int) size_value(in_ports[1].in_min,in_ports[1].in_max,input2, 16.0f ,0.0f,0));

				
				if (paddle!= oldpaddle)
				{ 
					select = paddle  % (selections+1) -1 ; 
					presstime=0;
				}
		
				if (select==-1) idletime++;
				else { idletime=0; presstime++;}
				

				if (idletime>idle)
				{
					idletime=0; select=-1; 
					oldpaddle=paddle+1;
					if (selstart+selections<selend) selstart+=selections;
					
					// if (selstart>selend)
					else                      
					{ selstart=0; selbegin=0; selections=entries; selend=selections; 
					  delchars=0; }
					InvalidateRect(displayWnd,NULL,FALSE);
				}

				if (input!=15)  { get_suggestions(); waitres=1; oldinput=input; idletime=0; presstime=0; select=-1; }

				if (presstime>press) {presstime=0; enter=1; idletime=0; }

				if (displayWnd && (select!=os)) InvalidateRect(displayWnd,NULL,FALSE);
				os=select;
			
			}

		}

		if (mode==2)
		{
			if (waitres) 
			{
				if (input==15)  waitres=0;
			}
			else
			{
				if (input==15) idletime++; else idletime=0;

				if (idletime>idle)
				{
					idletime=0; select=-1; 
					if (selstart+selections<selend) selstart+=selections;
					
					// if (selstart>selend)
					else                      
					{ selstart=0; selbegin=0; selections=entries; selend=selections; 
					  delchars=0; }
					InvalidateRect(displayWnd,NULL,FALSE);
				}

				if ((input!=oldinput) || (input==15)) presstime=0;
				else
				{ 
					if (++presstime>press)
					{

						if (input==14) 	{ selstart=0; selbegin=0; selections=entries; selend=selections; }

						if (input==13)  get_suggestions();

						if (input==7) {  select--; if (select<0) select=selections-1; enter=2; }
						if (input==11)  {  select++; if (select==selections) select=-1; enter=2; }
			
						presstime=1;
					}
				}

				if ((enter==2) && (idletime>180) && (select>=0)) {enter=1; waitres=1;}

				if (displayWnd && (select!=os)) InvalidateRect(displayWnd,NULL,FALSE);
				os=select;
			}
		    oldinput=input;

		}



		if (enter==1)
		{
			enter=0;

			switch( dict[selstart+select].type)
			{
			  
			  case FINAL_CHARACTERS:
				{
				 
 				  char c;
				  int u,keep=0;

				  c=dict[selstart+select].data[0];
				
				  switch (c)
				  {

					case '<': if (strlen(word)>0) word[strlen(word)-1]=0; 
							  if (directsend)  send_key(8);
								break;
					case 1:   if (!directsend)  send_word(word);
							  if (autolearn) learn_words();
							  strcpy(word,"");
							break;

					case 2:   for (u=0;u<entries;u++) 
							  {
								  if (dict[u].data[0]>20)   // not a command 
								  {
									up_chars(dict[u].data,dict[u].data);
									up_chars(dict[u].tag,dict[u].tag);
								  }
							  }
							  upchar=1; break;

					case 3:  get_suggestions(); 
							 InvalidateRect(displayWnd,NULL,FALSE);
							 keep=1;
							 //waitres=1; oldinput=input; 
							 idletime=0; presstime=0; switchtime=0;
							 //select=-1; 
							 break;
					
					case 4:  get_dictionary(); 
							 InvalidateRect(displayWnd,NULL,FALSE);
							 keep=1;
							 idletime=0; presstime=0; switchtime=0;
							 break;

					default:  
						if (delchars)
						{ 
						  word[strlen(word)-delchars]=0;
						  strcat(word,dict[selstart+select].data);
						  strcat(word," ");
						  if (directsend)
						  {
							send_word(dict[selstart+select].data);
							send_key(' ');
						  }
						  delchars=0;
						}
						else 
						{
							strcat(word,dict[selstart+select].data);
							if (directsend) send_word(dict[selstart+select].data);
							if (strlen(dict[selstart+select].data)>1)
							{
								strcat(word," ");
								if (directsend)  send_key(' ');
							}

							if ((dict[selstart+select].data[0]>20)&&(upchar))
							{
								upchar=0;
								for (u=0;u<entries;u++) 
								{
									if (dict[u].data[0]>20)
									{
									  low_chars(dict[u].data,dict[u].data);
									  low_chars(dict[u].tag,dict[u].tag);
									}
								}

							}
						}
				  }
				
				  if (!keep)
				  {
				    select=-1;
				    selstart=0;selbegin=0;selections=entries;selend=selections;

					make_suggestions();
				    
				  }
				}
			    break;

			case EXTEND_CHARACTERS:
				i=0;
				while (dict[selstart+select].data[i])
				{
					dict[START_DYNAMIC+i].data[0]=dict[selstart+select].data[i];
					dict[START_DYNAMIC+i].data[1]=0;

					dict[START_DYNAMIC+i].tag[0]=dict[selstart+select].tag[i];
					dict[START_DYNAMIC+i].tag[1]=0;

					dict[START_DYNAMIC+i].type=FINAL_CHARACTERS;
					i++;
				}
				selstart=START_DYNAMIC;selbegin=START_DYNAMIC;
				selend=START_DYNAMIC+i-1;
				selections=i;
				select=-1;
				break;


			case DICTIONARY:
					strcpy(fn,GLOBAL.resourcepath);
 					strcat(fn,"dictionary\\");
					strcat(fn,dict[selstart+select].data);
					load_dictionary(fn);
					make_suggestions();
					select=-1;
				    selstart=0;selbegin=0;selections=entries;selend=selections;
				    
				break;

			}

			if (displayWnd) InvalidateRect(displayWnd,NULL,FALSE);
		}
		
		

	  }