void parse_condition (const unichar* condition, pattern* patterns)
{
  // parses condition for derivation and composition
  int j = 0;
  for (int i = 0; condition[i] != '\0'; i++) {
    if (condition[i]=='<') {
      // begin of "abstract" pattern
      i++;
      unichar type = 'g';
      bool YesNo = 1;
      unichar pattern[MAX_COMPOSITION_RULE_LENGTH];
      pattern[0] = '\0';
      int k = 0;
      while (condition[i] != '>' && condition[i] != '\0') {
	if (condition[i] == '+') { // grammatical code positive
	  pattern[k] = '\0';
	  save_pattern(&patterns[j++],YesNo,type,pattern);
	  YesNo = 1;
	  type = 'g';
	  i++;
	  k = 0;
	}
	else if (condition[i] == '-') { // grammatical code negative
	  pattern[k] = '\0';
	  save_pattern(&patterns[j++],YesNo,type,pattern);
	  YesNo = 0;
	  type = 'g';
	  i++;
	  k = 0;
	}
	else if (condition[i] == ':') { // flexional code
	  pattern[k] = '\0';
	  save_pattern(&patterns[j++],YesNo,type,pattern);
	  YesNo = 1;
	  type = 'f';
	  i++;
	  k = 0;
	}
	pattern[k++] = condition[i];
        i++;
      }
      if (pattern[0] != '\0')
	pattern[k] = '\0';
	save_pattern(&patterns[j++],YesNo,type,pattern);
    }
    else { // don't know if it is necessary to have concrete words or something else
    }
  }
  // last pattern in array must be empty
  unichar pattern[MAX_COMPOSITION_RULE_LENGTH];
  pattern[0] = '\0';
  save_pattern(&patterns[j],0,'\0',pattern);
}
示例#2
0
LRESULT CALLBACK App::subclass_wndproc_new(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
	//odnalezienie kontrolki
    Control* kontrolka = NULL;
	for(unsigned int i=0; i<Controls::geti()->controls.size(); i++){
        if(Controls::geti()->controls.at(i)->handle == hwnd){
            kontrolka = Controls::geti()->controls.at(i);
            break;
        }
	}
    if(kontrolka==NULL){
        IO::geti()->error("Subclassing: Nie znaleziono kontrolki o podanym uchwycie");
        return 0;
    }
    string nazwa = kontrolka->name;
    //globalne skróty klawiszowe
    if(message == WM_KEYDOWN){
        if(wParam==VK_F1||wParam==VK_F2||wParam==VK_F3||wParam==VK_F5||wParam==VK_F6||wParam==VK_F7||wParam==VK_F8||wParam==VK_F9||wParam==VK_F10||wParam==VK_F11){
            CallWindowProc(windowProc, hwnd, message, wParam, lParam); //przekazanie wy¿ej do mainwindow
            return 0; //przechwycenie
        }
        //wyjœcie z fullscreena
        if(wParam==VK_ESCAPE && Config::geti()->fullscreen_on){
            CallWindowProc(windowProc, hwnd, message, wParam, lParam); //przekazanie wy¿ej do mainwindow
            return 0; //przechwycenie
        }
        //ctrl
        if(is_control_pressed()){
            if(wParam=='S'||wParam=='F'||wParam=='N'||wParam=='B'||wParam==VK_ADD||wParam==VK_SUBTRACT||wParam==VK_LEFT||wParam==VK_RIGHT||wParam=='0'||wParam==VK_NUMPAD0||wParam==VK_OEM_3){
                CallWindowProc(windowProc, hwnd, message, wParam, lParam); //przekazanie wy¿ej do mainwindow
                return 0; //przechwycenie
            }
        }
    }
    if(message == WM_SYSKEYDOWN){
        if(wParam==VK_F10){
            //zamiana WM_SYSKEYDOWN na WM_KEYDOWN
            subclass_wndproc_new(hwnd, WM_KEYDOWN, wParam, lParam);
            return 0;
        }
    }
    //globalne przechwycenie wygaszacza
    if(message == WM_SYSCOMMAND){
        if(wParam == SC_SCREENSAVE){
            CallWindowProc(windowProc, hwnd, message, wParam, lParam); //przekazanie wy¿ej do mainwindow
            return 0; //przechwycenie
        }
    }
	//nowe procedury kontrolek
    if(nazwa=="filename_edit"){
		switch(message){
			case WM_CHAR:{
				if(wParam==VK_ESCAPE){
					Controls::geti()->set_focus("editor");
					return 0;
				}else if(wParam==VK_RETURN){
                    if(!Config::geti()->cmd_show){
                        cmd_switch(1);
                    }
                    Controls::geti()->set_focus("cmd");
                    Controls::geti()->select_all("cmd");
                    return 0;
                }
			}break;
		}
	}
    if(nazwa=="cmd"){
		switch(message){
			case WM_CHAR:{
				if(wParam==VK_ESCAPE){
					Controls::geti()->set_focus("editor");
					return 0;
				}else if(wParam==VK_RETURN){
					exec_cmd();
					return 0; //przechwycenie
				}
			}break;
			case WM_KEYDOWN:{
				if(wParam==VK_UP){
                    Controls::geti()->set_text("cmd", last_cmd);
					SendMessage(Controls::geti()->find("cmd"), EM_SETSEL, last_cmd.length(), last_cmd.length());
					return 0;
				}
				if(wParam==VK_DOWN){
					Controls::geti()->set_text("cmd", "");
					return 0;
				}
			}break;
		}
	}
	if(nazwa=="editor"){ //edytor
		switch(message){
			case WM_SYSKEYDOWN:{
                if(wParam>='1' && wParam<='9'){
                    //zamiana WM_SYSKEYDOWN na WM_KEYDOWN
                    subclass_wndproc_new(hwnd, WM_KEYDOWN, wParam, lParam);
                    return 0;
				}
			}break;
			case WM_KEYDOWN:{
				if(is_control_pressed()){ //ctrl
					if(wParam=='C'){
						copy_text();
						return 0;
					}else if(wParam=='A'){
                        select_all();
                        return 0;
					}else if(wParam=='Z'){
                        undo->revert();
                        return 0;
					}else if(wParam=='R'){
                        refresh_text();
                        return 0;
					}else if(wParam=='T'){
						quick_replace();
						return 0;
					}else if(wParam=='Q'){
						usun_akordy();
						return 0;
					}else if(wParam=='W'){
						save_pattern();
						return 0;
					}else if(wParam=='E'){
                        insert_pattern();
						return 0;
					}else if(wParam=='D'){
                        dodaj_nawias();
						return 0;
					}else if(wParam>='1' && wParam<='9'){
						zapisz_tekst(wParam-'1'+1);
						return 0;
					}
				}else if(is_alt_pressed()){ //alt
					if(wParam>='1' && wParam<='9'){
						wstaw_tekst(wParam-'1'+1);
						return 0;
					}
				}
			}break;
			case WM_CHAR:{
                //dla ka¿dego znaku (bez controla)
                if(!is_control_pressed()){
                    undo->save();
                }
                //undo->save();
				if(wParam == ']'){
					string add_text = "]";
					SendMessage(Controls::geti()->find("editor"), EM_REPLACESEL, 0, (LPARAM)add_text.c_str()); //wstawienie znaku
					refresh_text(); //odœwie¿enie tekstu
                    //zmiana koloru po nawiasie na kolor tekstu
                    CHARFORMAT cf_text;
                    cf_text.cbSize = sizeof(cf_text);
                    SendMessage(Controls::geti()->find("editor"), EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf_text);
                    //kolor tekstu + brak pogrubienia
                    cf_text.dwMask = CFM_COLOR | CFM_BOLD;
                    cf_text.crTextColor = RGB(Config::i()->color_text[0], Config::i()->color_text[1], Config::i()->color_text[2]);
                    cf_text.dwEffects = 0;
                    SendMessage(Controls::geti()->find("editor"), EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf_text);
                    return 0;
				}
			}break;
			case WM_MOUSEWHEEL:{
                int zdelta = GET_WHEEL_DELTA_WPARAM(wParam);
				if(LOWORD(wParam)==MK_CONTROL){ //z controlem
                    //zmiana czcionki
					if(zdelta>=0){
						change_font_size(+1);
					}else{
						change_font_size(-1);
					}
                    return 0;
				}else{
                    //scrollowanie edytora
                    int scroll_step = Config::geti()->editor_fontsize + 2;
                    if(zdelta>=0){
						change_scroll(-scroll_step);
					}else{
						change_scroll(+scroll_step);
					}
                    return 0;
                }
			}break;
		}
	}
	if(nazwa=="find_edit"){ //szukany ci¹g znaków
		switch(message){
			case WM_SETFOCUS:{
                if(Controls::i()->get_text("find_edit")==Config::i()->find_edit_placeholder){
                    Controls::i()->set_text("find_edit", "");
                }
				IO::geti()->echo("(Wpisz szukany ci¹g znaków, Enter - szukaj)");
			}break;
            case WM_KILLFOCUS:{
                if(Controls::i()->get_text("find_edit").length()==0){
                    Controls::i()->set_text("find_edit", Config::i()->find_edit_placeholder);
                }
            }break;
			case WM_CHAR:{
				if(wParam==VK_RETURN){
					znajdz();
					return 0;
				}
				if(wParam==VK_TAB){
					Controls::geti()->set_focus("replace_edit");
					return 0;
				}
			}break;
		}
	}
	if(nazwa=="replace_edit"){ //tekst do zamiany
		switch(message){
			case WM_SETFOCUS:{
                if(Controls::i()->get_text("replace_edit")==Config::i()->replace_edit_placeholder){
                    Controls::i()->set_text("replace_edit", "");
                }
                    IO::geti()->echo("(Wpisz tekst do zamiany, Enter - zamieñ w zaznaczeniu lub ca³ym pliku)");
                }break;
            case WM_KILLFOCUS:{
                if(Controls::i()->get_text("replace_edit").length()==0){
                    Controls::i()->set_text("replace_edit", Config::i()->replace_edit_placeholder);
                }
            }break;
			case WM_CHAR:{
				if(wParam==VK_RETURN){
					zamien();
					return 0;
				}
				if(wParam==VK_TAB){
					Controls::geti()->set_focus("find_edit");
					return 0;
				}
			}break;
		}
	}
	if(nazwa=="autoscroll_interval"){ //autoscroll_interval
		switch(message){
			case WM_SETFOCUS:{
				IO::geti()->echo("(Czas miêdzy kolejnymi przebiegami autoscrolla - wyra¿ony w milisekundach)");
			}break;
			case WM_CHAR:{
				if(wParam==VK_RETURN){
					autoscroll_nowait(0);
					return 0;
				}
			}break;
		}
	}
	if(nazwa=="autoscroll_wait"){ //autoscroll_wait
		switch(message){
			case WM_SETFOCUS:{
				IO::geti()->echo("(Czas opóŸnienia przed autoscrollem - wyra¿ony w sekundach)");
			}break;
			case WM_CHAR:{
				if(wParam==VK_RETURN){
					autoscroll_on();
					return 0;
				}
			}break;
		}
	}
	return CallWindowProc(kontrolka->wndproc_old, hwnd, message, wParam, lParam);
}
示例#3
0
void KfindTabWidget::saveHistory()
{
  save_pattern(nameBox, "History", "Patterns");
  save_pattern(dirBox, "History", "Directories");
}
示例#4
0
void App::event_button(WPARAM wParam){
    string name = "";
    if(wParam>=1 && wParam<=Controls::geti()->controls.size()){
        name = Controls::geti()->get_button_name(wParam);
    }else{
        name = Controls::geti()->get_menu_name(wParam);
    }
    if(name.length()==0) return;
	if(name == "new"){ //nowy
		new_file();
	}else if(name == "load"){ //wczytaj
        if(!Config::geti()->toolbar_show){
            toolbar_switch(1);
        }
        string str2 = Controls::geti()->get_text("filename_edit");
		if(str2.length()==0){
			IO::geti()->echo("Podaj nazwê pliku.");
		}else{
			open_chords_file(str2);
		}
	}else if(name == "save"){ //zapisz
		save_chords_file();
	}else if(name == "analyze"){ //analizuj
		analyze();
	}else if(name == "replace"){ //zamieñ
        if(!Config::geti()->toolbar_show){
            toolbar_switch(1);
            return;
        }
		zamien();
	}else if(name == "find"){ //znajdŸ
        if(!Config::geti()->toolbar_show){
            toolbar_switch(1);
            return;
        }
		znajdz();
	}else if(name == "undo"){
        undo->revert();
	}else if(name == "base"){ //baza akordów
        chordsbase_start();
	}else if(name == "autoscroll"){ //autoscroll
		autoscroll_switch();
	}else if(name == "reload"){
        open_chords_file(Config::geti()->opened_file);
    }else if(name == "config"){
        ShellExecute(0,"open",Config::geti()->config_filename.c_str(),"",0,SW_SHOW);
    }else if(name == "quick_replace"){
        quick_replace();
    }else if(name == "remove_chords"){
        usun_akordy();
    }else if(name == "remove_alt"){
        usun_wersje();
    }else if(name == "add_chord"){
        dodaj_nawias();
    }else if(name == "font++"){
        change_font_size(+1);
    }else if(name == "font--"){
        change_font_size(-1);
    }else if(name == "format_text"){
        refresh_text();
    }else if(name == "fullscreen"){
        fullscreen_toggle();
    }else if(name == "autoscroll_wait"){
        autoscroll_on();
    }else if(name == "autoscroll_nowait"){
        autoscroll_nowait();
    }else if(name == "autoscroll_off"){
        autoscroll_off();
        IO::geti()->echo("Autoscroll wy³¹czony");
    }else if(name == "autoscroll_slower"){
        autoscroll_nowait(+Config::geti()->autoscroll_interval*0.25);
    }else if(name == "autoscroll_faster"){
        autoscroll_nowait(-Config::geti()->autoscroll_interval*0.2);
    }else if(name == "transpose+5"){
        transpose(+5);
    }else if(name == "transpose++"){
        transpose(+1);
    }else if(name == "transpose--"){
        transpose(-1);
    }else if(name == "transpose-5"){
        transpose(-5);
    }else if(name == "transpose0"){
        transpose(-Config::geti()->transposed);
    }else if(name == "alt"){
        dodaj_alternatywne();
    }else if(name == "log"){
        ShellExecute(0, "open", Config::geti()->log_filename.c_str(), "", 0, SW_SHOW);
    }else if(name == "associate_files"){
        associate_files();
    }else if(name == "help"){
        show_help();
    }else if(name == "info"){
        stringstream ss;
        ss<<Config::geti()->program_name<<endl;
        ss<<"wersja "<<version<<endl;
        IO::geti()->message_box("O programie",ss.str());
    }else if(name == "cmd_toggle"){
        cmd_switch();
    }else if(name == "toolbar_toggle"){
        toolbar_switch();
    }else if(name == "scroll_to_begin"){
        set_scroll(0);
    }else if(name == "scroll_to_end"){
        SendMessage(Controls::geti()->find("editor"), WM_VSCROLL, SB_BOTTOM, 0);
    }else if(name == "save_pattern"){
        save_pattern();
    }else if(name == "insert_pattern"){
        insert_pattern();
    }else if(name == "exit"){
        DestroyWindow(main_window);
    }else{
        IO::geti()->error("Zdarzenie nie zosta³o obs³u¿one: "+name);
    }
}
示例#5
0
void KfindTabWidget::saveHistory()
{
  save_pattern(nameBox, QLatin1String("History"), QLatin1String("Patterns"));
  save_pattern(dirBox, QLatin1String("History"), QLatin1String("Directories"));
}
示例#6
0
 NODE *lshowturtle(NODE *args) {
-    prepare_to_draw;
+    prepare_to_draw2(UNBOUND);
     if (!turtle_shown) {
 	turtle_shown = TRUE;
 	draw_turtle();
@@ -545,7 +545,7 @@ NODE *lshowturtle(NODE *args) {
 }
 
 NODE *lhideturtle(NODE *args) {
-    prepare_to_draw;
+    prepare_to_draw2(UNBOUND);
     if (turtle_shown) {
 	draw_turtle();
 	turtle_shown = FALSE;
@@ -874,7 +874,7 @@ NODE *llabel(NODE *arg) {
     *print_stringptr = '\0';
 	
     if (NOT_THROWING) {
-	prepare_to_draw;
+	prepare_to_draw2(UNBOUND);
 	draw_turtle();
 	theLength = strlen(textbuf);
 #ifdef mac
@@ -983,7 +983,7 @@ NODE *lsetpencolor(NODE *arg) {
     NODE *val = pos_int_arg(arg);
 
     if (NOT_THROWING) {
-	prepare_to_draw;
+	prepare_to_draw2(UNBOUND);
 	set_pen_color(getint(val));
 	save_color();
 	done_drawing;
@@ -995,7 +995,7 @@ NODE *lsetbackground(NODE *arg) {
     NODE *val = pos_int_arg(arg);
 
     if (NOT_THROWING) {
-	prepare_to_draw;
+	prepare_to_draw2(UNBOUND);
 	set_back_ground(getint(val));
 	done_drawing;
     }
@@ -1008,7 +1008,7 @@ NODE *lsetpalette(NODE *args) {
 	int slotnum = (int)getint(slot);
 
 	if (NOT_THROWING && (slotnum > 7)) {
-		prepare_to_draw;
+		prepare_to_draw2(UNBOUND);
 		set_palette(slotnum,
 			    (unsigned int)getint(car(arg)),
 			    (unsigned int)getint(cadr(arg)),
@@ -1057,7 +1057,7 @@ NODE *lsetpensize(NODE *args) {
     NODE *arg = pos_int_vector_arg(args);
 
     if (NOT_THROWING) {
-	prepare_to_draw;
+	prepare_to_draw2(UNBOUND);
 	set_pen_width((int)getint(car(arg)));
 	set_pen_height((int)getint(cadr(arg)));
 	save_size();
@@ -1074,7 +1074,7 @@ NODE *lsetpenpattern(NODE *args) {    
 	arg = err_logo(BAD_DATA, arg);
 	
     if (NOT_THROWING) {
-	prepare_to_draw;
+	prepare_to_draw2(UNBOUND);
 	set_list_pen_pattern(arg);
 	save_pattern();
 	done_drawing;
@@ -1090,7 +1090,7 @@ NODE *lsetscrunch(NODE *args) {
     ynode = numeric_arg(cdr(args));
 
     if (NOT_THROWING) {
-	prepare_to_draw;
+	prepare_to_draw2(UNBOUND);
 	draw_turtle();
 	x_scale = (nodetype(xnode) == FLOATT) ? getfloat(xnode) :
 			       (FLONUM)getint(xnode);
@@ -1227,7 +1227,7 @@ NODE *larc(NODE *arg) {
 	else
 	    radius = getfloat(val2);
 
-	prepare_to_draw;
+	prepare_to_draw2(UNBOUND);
 	draw_turtle();
 
 	/* save and force turtle state */
@@ -1582,7 +1582,7 @@ NODE *lloadpict(NODE *args) {
     lopenread(args);
 #endif
     if (NOT_THROWING) {
-	prepare_to_draw;
+	prepare_to_draw2(UNBOUND);
 	fp = (FILE *)file_list->n_obj;
 	restore_palette(fp);
 	fread(&record_index, sizeof(FIXNUM), 1, fp);