mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-30 21:42:59 +00:00 
			
		
		
		
	string editor now may restrict the available keys
This commit is contained in:
		
							
								
								
									
										16
									
								
								dialogs.cpp
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								dialogs.cpp
									
									
									
									
									
								
							| @@ -990,8 +990,14 @@ namespace dialog { | |||||||
|     editpos = isize(s); |     editpos = isize(s); | ||||||
|     } |     } | ||||||
|    |    | ||||||
|   bool handle_edit_string(int sym, int uni) { |   string editchecker(int sym, int uni) { | ||||||
|  |     if(uni >= 32 && uni < 127) return string("") + char(uni); | ||||||
|  |     return ""; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |   bool handle_edit_string(int sym, int uni, function<string(int, int)> checker) { | ||||||
|     auto& es = *edited_string; |     auto& es = *edited_string; | ||||||
|  |     string u2; | ||||||
|     if(sym == SDLK_LEFT) editpos--; |     if(sym == SDLK_LEFT) editpos--; | ||||||
|     else if(sym == SDLK_RIGHT) editpos++; |     else if(sym == SDLK_RIGHT) editpos++; | ||||||
|     else if(uni == 8) { |     else if(uni == 8) { | ||||||
| @@ -999,9 +1005,11 @@ namespace dialog { | |||||||
|       es.replace(editpos-1, 1, ""); |       es.replace(editpos-1, 1, ""); | ||||||
|       editpos--; |       editpos--; | ||||||
|       } |       } | ||||||
|     else if(uni >= 32 && uni < 128) { |     else if((u2 = checker(sym, uni)) != "") { | ||||||
|       es.insert(editpos, 1, uni); |       for(char c: u2) { | ||||||
|       editpos++; |         es.insert(editpos, 1, c); | ||||||
|  |         editpos ++; | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|     else return false; |     else return false; | ||||||
|     return true; |     return true; | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								hyper.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								hyper.h
									
									
									
									
									
								
							| @@ -1842,7 +1842,8 @@ namespace dialog { | |||||||
|    |    | ||||||
|   string view_edited_string(); |   string view_edited_string(); | ||||||
|   void start_editing(string& s); |   void start_editing(string& s); | ||||||
|   bool handle_edit_string(int sym, int uni); |   string editchecker(int sym, int uni); | ||||||
|  |   bool handle_edit_string(int sym, int uni, function<string(int, int)> checker = editchecker); | ||||||
|   void edit_string(string& s, string title, string help); |   void edit_string(string& s, string title, string help); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue