mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 13:20:59 +00:00 
			
		
		
		
	GTextEditor: Double-clicking on a span should select the span
This makes double-clicking on a C++ token in HackStudio select the whole token, which is pretty nice. It's not perfect in all cases, but a lot nicer than just expanding until we hit whitespace. :^)
This commit is contained in:
		
							parent
							
								
									8fa466e496
								
							
						
					
					
						commit
						db5178fb8f
					
				
				
				Notes:
				
					sideshowbarker
				
				2024-07-19 11:31:26 +09:00 
				
			
			Author: https://github.com/awesomekling
Commit: db5178fb8f
			
					 1 changed files with 20 additions and 8 deletions
				
			
		|  | @ -164,16 +164,28 @@ void GTextEditor::doubleclick_event(GMouseEvent& event) | |||
|     auto start = text_position_at(event.position()); | ||||
|     auto end = start; | ||||
|     auto& line = m_lines[start.line()]; | ||||
|     while (start.column() > 0) { | ||||
|         if (isspace(line.characters()[start.column() - 1])) | ||||
|             break; | ||||
|         start.set_column(start.column() - 1); | ||||
|     } | ||||
| 
 | ||||
|     while (end.column() < line.length()) { | ||||
|         if (isspace(line.characters()[end.column()])) | ||||
|     if (m_spans.is_empty()) { | ||||
|         while (start.column() > 0) { | ||||
|             if (isspace(line.characters()[start.column() - 1])) | ||||
|                 break; | ||||
|             start.set_column(start.column() - 1); | ||||
|         } | ||||
| 
 | ||||
|         while (end.column() < line.length()) { | ||||
|             if (isspace(line.characters()[end.column()])) | ||||
|                 break; | ||||
|             end.set_column(end.column() + 1); | ||||
|         } | ||||
|     } else { | ||||
|         for (auto& span : m_spans) { | ||||
|             if (!span.range.contains(start)) | ||||
|                 continue; | ||||
|             start = span.range.start(); | ||||
|             end = span.range.end(); | ||||
|             end.set_column(end.column() + 1); | ||||
|             break; | ||||
|         end.set_column(end.column() + 1); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     m_selection.set(start, end); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling