예제 #1
0
void				autocomplete(t_cmd_path *cmds)
{
	int				count;
	char			*word;
	char			*res;

	count = 0;
	if ((word = get_current_word()) == NULL)
		return ;
	while (cmds)
	{
		if (!ft_strncmp(cmds->name, word, ft_strlen(word)))
		{
			res = ft_strdup(cmds->name);
			count++;
		}
		cmds = cmds->next;
	}
	if (count == 1)
		complete_word(res, ft_strlen(word));
}
예제 #2
0
파일: sumdesc.cpp 프로젝트: songhtdo/vespa
/* Move backwards/forwards from ptr (no longer than to start) in an
 * UTF8 text until the beginning of an extended token or (if space,
 * until beginning of the next/last word)
 * A token in this function means some combination of words linked
 * together with a single character of any of the configured set of
 * legal connector characters.
 * @return The number of bytes moved
 */
int SummaryDesc::complete_extended_token(unsigned char* start, ssize_t length,
        const unsigned char*& ptr, off_t increment)
{
    int moved = 0;
    const unsigned char *old_ptr = NULL;
    for (;;) {
        // Start by moving to the start/end of the word..
        moved += complete_word(start, length, ptr, increment);

        // Ensure that there is a quick way out of this at the end:
        if (start >= ptr || start + length <= ptr || ptr == old_ptr)
            return moved;

        // If we end up at the same place as last iteration, we need
        // to bail (done above) to avoid an infinite loop.
        old_ptr = ptr;

        // Store a pointer to the found break:
        const unsigned char* preptr = ptr;

        int prelen;
        // Position to previous/next character to check if this is a
        // "real" break:
        if (increment < 0) {
            prelen = Fast_UnicodeUtil::UTF8move(start, length,
                                                preptr, increment);
            if (!prelen)
                return moved;
        } else {
            prelen = 0;
        }

        // Handle default case ("ordinary" space)
        if (!word_connector(preptr)) {
            LOG(spam, "Not a word connector case (%c)", *preptr);
            return moved;
        }
        char wconn = *preptr;
        (void) wconn;
        LOG(spam, "Found word connector case candidate (%c)", wconn);

        // Read the character before/after the connector character:
        int addlen = Fast_UnicodeUtil::UTF8move(start, length,
                                                preptr, increment);
        if (!addlen)
            return moved; // Not possible to extend anything here

        // Only a single connector character that connects word
        // characters should lead us to include more words in the
        // normal sense:
        if (!wordchar(preptr))
            return moved;

	// If a block of chinese data does not contain any spaces we have to return
	// here in order to avoid searching all the way to the start/end.
	return moved;

        // Ok, found a separator case, include another word..

        moved += prelen + addlen;
        // If going forward, the word completer will look at the
        // previous char to see if we are at the start of a word, so
        // we have to move forward once here:
        if (increment > 0) {
            addlen = Fast_UnicodeUtil::UTF8move(start, length,
                                                preptr, increment);
            if (!addlen)
                return moved;
            moved += addlen;
        }
        ptr = preptr;

        LOG(spam, "Found proper word connector case (%c,%c) yet moved %d",
            wconn, *preptr, moved);
    }
}
예제 #3
0
파일: main.c 프로젝트: AstoniaDev/openMerc
LRESULT FAR PASCAL _export MainWndProc(HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	int keys;
	extern int ser_ver,xmove;

	keys=0;
	if (GetAsyncKeyState(VK_SHIFT)&0x8000) keys|=1;
	if (GetAsyncKeyState(VK_CONTROL)&0x8000) keys|=2;

	switch (message) {
		case    WM_SYSKEYDOWN:
		case WM_KEYDOWN:
			switch ((int)wParam) {
				case    27:         cmd(CL_CMD_RESET,0,0); show_shop=0; noshop=QSIZE*12; xmove=0; break;	//ESC
				case    'p':            if (keys) button_command(16);
					else cmd(CL_CMD_MODE,2,0); break;		//F1
				case    'q':            if (keys) button_command(17);
					else cmd(CL_CMD_MODE,1,0); break;		//F2
				case    'r':            if (keys) button_command(18);
					else cmd(CL_CMD_MODE,0,0); break;		//F3
				case    's':            if (keys) button_command(19);
					else pdata.show_proz=1-pdata.show_proz; break;	//F4
				case    't':            if (keys) button_command(20);			//F5
					else do_alpha++; if (do_alpha==3) do_alpha=0; dd_invalidate_alpha(); break;
				case    'u':            if (keys) button_command(21);
					else pdata.hide=1-pdata.hide; break;		//F6
				case    'v':            if (keys) button_command(22);
					else pdata.show_names=1-pdata.show_names; break;//F7
				case    'w':            if (keys) button_command(23);break;			   //F8
				case    'x':            if (keys) button_command(24);
					else dd_savescreen(); break;						   //F9
				case  'y':        if (keys)	button_command(25);
					else {
						gamma+=250;
						if (gamma>6000)	gamma=5000;
						xlog(2,"Set gamma correction to %1.2f",gamma/5000.0);
						dd_invalidate_cache();
					}
					break;		// F10
				case    'z':        if (keys) button_command(26);
					else {
						xlog(2," ");											//F11
						xlog(2,"Client Version %d.%02d.%02d",VERSION>>16,(VERSION>>8)&255,VERSION&255);
						xlog(2,"Server Version %d.%02d.%02d",ser_ver>>16,(ser_ver>>8)&255,ser_ver&255);
						xlog(2,"MAXX=%d, MAXY=%d, MAXXO=%d",MAXX,MAXY,MAXXOVER);
						xlog(2,"R=%04X, G=%04X, B=%04X",RED,GREEN,BLUE);
						xlog(2,"RGBM=%d",RGBM);
						xlog(2,"MAXCACHE=%d",MAXCACHE);
						xlog(2,"Hit=%d, Miss=%d, Invis=%d",dd_cache_hit,dd_cache_miss,invisible);
						xlog(2,"Ratio=%.2f%%",100.0/(dd_cache_hit+dd_cache_miss)*dd_cache_hit);
						xlog(2,"Skip=%d%% Idle=%d%%",pskip,pidle);
						xlog(2,"MaxMem=%dK, UsedMem=%dK",maxmem>>10,usedmem>>10);
						xlog(2,"MemBlocks=%d (T=%d,GC=%d)",blockcnt,blocktot,blockgc);
						xlog(2,"MaxVid=%dK, UsedVid=%dK",(maxvid*32*32*2)>>10,(usedvid*32*32*2)>>10);
						xlog(2,"cachex=%d, cachey=%d, MAXXOVER=%d",cachex,cachey,MAXXOVER);
						xlog(2,"usedvidmemflag=%d",usedvidmem);
						xlog(2,"alphapix=%d, fullpix=%d, ratio=%.2f",alphapix,fullpix,100.0/(alphapix+fullpix+1)*alphapix);

//                                do_ticker=1-do_ticker;
					}
					break;

				case    '{':            if (keys) button_command(27);
					else cmd_exit();
					break;		   //F12


					// text editor
				case  9:          complete_word();
					break;

				case    8:              if (cur_pos && in_len) { //BACKSPACE
						if (tabmode) {
							in_len=cur_pos; tabmode=0; tabstart=0;
						}
						if (cur_pos>in_len)	cur_pos=in_len;
						memmove(input+cur_pos-1,input+cur_pos,120-cur_pos);
						in_len--;
						cur_pos--;
					}
					break;
				case 46:             if (in_len) { // DEL
						if (tabmode) {
							in_len=cur_pos; tabmode=0; tabstart=0;
						} else {
							memmove(input+cur_pos,input+cur_pos+1,120-cur_pos);
							in_len--;
						}
					}
					break;
				case 33:          if (logstart<22*8) {
						logstart+=11; logtimer=TICKS*30;
					}
					break;
				case 34:          if (logstart>0) {
						logstart-=11; logtimer=TICKS*30;
					}
					break;
				case 36:          cur_pos=0; tabmode=0; tabstart=0; break; // HOME
				case 35:          cur_pos=in_len; tabmode=0; tabstart=0; break;	// END
				case 37:          if (cur_pos) cur_pos--;
					tabmode=0; tabstart=0;
					break;
				case 39:          if (cur_pos<115) cur_pos++;
					tabmode=0; tabstart=0;
					break;
				case 38:          if (hist_nr<19) {
						memcpy(history[hist_nr],input,128);
						hist_len[hist_nr]=in_len;
						hist_nr++;

						memcpy(input,history[hist_nr],128);
						in_len=cur_pos=hist_len[hist_nr];

						tabmode=0; tabstart=0;
					}
					break;
				case 40:          if (hist_nr>0) {
						memcpy(history[hist_nr],input,128);
						hist_len[hist_nr]=in_len;

						hist_nr--;

						memcpy(input,history[hist_nr],128);
						in_len=cur_pos=hist_len[hist_nr];

						tabmode=0; tabstart=0;
					}
					break;
/*           default:          xlog(3,"key=%d",(int)wParam);
							 break;*/

			}
			break;

		case WM_CHAR:
			switch ((int)wParam) {
				case    13:            if (in_len==0) break;

					if (tabmode) {
						tabmode=0; tabstart=0;
						in_len--;
					}

					memmove(history[2],history[1],18*128);
					memmove(&hist_len[2],&hist_len[1],sizeof(int)*18);

					memcpy(history[1],input,128);
					hist_len[1]=in_len;

					input[in_len]=0;
					in_len=0;
					cur_pos=0;
					view_pos=0;
					hist_nr=0;

					add_words();

					say(input);

					break;

				default:                if ((int)wParam>31 && (int)wParam<128 && in_len<115) {
						if (tabmode) {
							if (!isalnum((char)wParam))	in_len--;
							cur_pos=in_len;
							tabmode=0;
							tabstart=0;
						}
						if (cur_pos>in_len)	cur_pos=in_len;
						memmove(input+cur_pos+1,input+cur_pos,120-cur_pos);
						input[cur_pos]=(char)wParam;
						in_len++;
						cur_pos++;
					}
					break;
			}
			break;

		case WM_PAINT:
			BeginPaint(hWnd,&ps);
			EndPaint(hWnd,&ps);
			break;

		case WM_DESTROY:
			PostQuitMessage(0);
			break;

		case WM_MOUSEMOVE:
			mouse(LOWORD(lParam),HIWORD(lParam),MS_MOVE);
			mx=LOWORD(lParam);
			my=HIWORD(lParam);
			break;

		case WM_LBUTTONDOWN:
			mouse(LOWORD(lParam),HIWORD(lParam),MS_LB_DOWN);
			break;

		case WM_LBUTTONUP:
			mouse(LOWORD(lParam),HIWORD(lParam),MS_LB_UP);
			break;

		case WM_RBUTTONDOWN:
			mouse(LOWORD(lParam),HIWORD(lParam),MS_RB_DOWN);
			break;

		case WM_RBUTTONUP:
			mouse(LOWORD(lParam),HIWORD(lParam),MS_RB_UP);
			break;

		default:
			return(DefWindowProc(hWnd, message, wParam, lParam));
	}
	return 0;
}