@@ -62,7 +62,8 @@ func _line_number_draw_callback(line: int, _gutter: int, region: Rect2) -> void:
6262 # Center vertically, align to the left of the gutter.
6363 var text_pos := Vector2 (- 5 , region .get_center ().y + font .get_ascent (font_size ) - font .get_string_size (
6464 line_number_text , HORIZONTAL_ALIGNMENT_LEFT , - 1 , font_size ).y / 2 )
65- draw_string (font , text_pos , line_number_text , HORIZONTAL_ALIGNMENT_RIGHT , _line_gutter_needed_space , font_size , ThemeUtils .dimmer_text_color )
65+ draw_string (font , text_pos , line_number_text , HORIZONTAL_ALIGNMENT_RIGHT , _line_gutter_needed_space , font_size ,
66+ ThemeUtils .dim_text_color if (get_caret_line () == line and has_focus ()) else ThemeUtils .subtle_text_color )
6667
6768
6869func _exit_tree () -> void :
@@ -201,42 +202,55 @@ func _gui_input(event: InputEvent) -> void:
201202
202203 if event is InputEventMouseMotion and event .button_mask == 0 :
203204 queue_redraw ()
204- elif event is InputEventMouseButton and event .button_index == MOUSE_BUTTON_RIGHT and event .is_pressed ():
205- grab_focus ()
206- var btn_arr : Array [ContextButton ] = []
207- var separator_arr := PackedInt32Array ()
208-
209- var is_text_empty := text .is_empty ()
210-
211- if editable :
212- var text_to_evaluate := get_selected_text () if has_selection () else text
213- var selection_evaluation := NumstringParser .evaluate (text_to_evaluate )
214- if not is_nan (selection_evaluation ) and Utils .num_simple (selection_evaluation , Utils .MAX_NUMERIC_PRECISION ) != text_to_evaluate :
215- btn_arr .append (ContextButton .create_from_action ("evaluate" ))
205+ elif event is InputEventMouseButton and event .is_pressed ():
206+ if get_gutter_count () == 1 and event .position .x < get_gutter_width (0 ):
207+ if event .button_index in [MOUSE_BUTTON_LEFT , MOUSE_BUTTON_MIDDLE , MOUSE_BUTTON_RIGHT ]:
208+ grab_focus ()
209+ var click_line := get_line_column_at_pos (event .position ).y
210+ if event .alt_pressed :
211+ add_caret (click_line , 0 )
212+ else :
213+ remove_secondary_carets ()
214+ deselect ()
215+ set_caret_line (click_line )
216+ set_caret_column (0 )
217+ accept_event ()
218+ if event .button_index == MOUSE_BUTTON_RIGHT :
219+ grab_focus ()
220+ var btn_arr : Array [ContextButton ] = []
221+ var separator_arr := PackedInt32Array ()
216222
217- if not btn_arr .is_empty ():
218- separator_arr .append (btn_arr .size ())
223+ var is_text_empty := text .is_empty ()
219224
220- btn_arr .append (ContextButton .create_from_action ("ui_undo" , not has_undo ()))
221- btn_arr .append (ContextButton .create_from_action ("ui_redo" , not has_redo ()))
222- if DisplayServer .has_feature (DisplayServer .FEATURE_CLIPBOARD ):
223- separator_arr .append (btn_arr .size ())
224- btn_arr .append (ContextButton .create_from_action ("ui_cut" , is_text_empty ))
225+ if editable :
226+ var text_to_evaluate := get_selected_text () if has_selection () else text
227+ var selection_evaluation := NumstringParser .evaluate (text_to_evaluate )
228+ if not is_nan (selection_evaluation ) and Utils .num_simple (selection_evaluation , Utils .MAX_NUMERIC_PRECISION ) != text_to_evaluate :
229+ btn_arr .append (ContextButton .create_from_action ("evaluate" ))
230+
231+ if not btn_arr .is_empty ():
232+ separator_arr .append (btn_arr .size ())
233+
234+ btn_arr .append (ContextButton .create_from_action ("ui_undo" , not has_undo ()))
235+ btn_arr .append (ContextButton .create_from_action ("ui_redo" , not has_redo ()))
236+ if DisplayServer .has_feature (DisplayServer .FEATURE_CLIPBOARD ):
237+ separator_arr .append (btn_arr .size ())
238+ btn_arr .append (ContextButton .create_from_action ("ui_cut" , is_text_empty ))
239+ btn_arr .append (ContextButton .create_from_action ("ui_copy" , is_text_empty ))
240+ btn_arr .append (ContextButton .create_from_action ("ui_paste" , not Utils .has_clipboard_web_safe ()))
241+ btn_arr .append (ContextButton .create_from_action ("select_all" , is_text_empty ))
242+ else :
225243 btn_arr .append (ContextButton .create_from_action ("ui_copy" , is_text_empty ))
226- btn_arr .append (ContextButton .create_from_action ("ui_paste" , not Utils .has_clipboard_web_safe ()))
227244 btn_arr .append (ContextButton .create_from_action ("select_all" , is_text_empty ))
228- else :
229- btn_arr .append (ContextButton .create_from_action ("ui_copy" , is_text_empty ))
230- btn_arr .append (ContextButton .create_from_action ("select_all" , is_text_empty ))
231-
232- var vp := get_viewport ()
233- HandlerGUI .popup_under_pos (ContextPopup .create (btn_arr , true , - 1 , separator_arr ), vp .get_mouse_position (), vp )
234- accept_event ()
235- var click_pos := get_line_column_at_pos (event .position )
236- if get_selection_at_line_column (click_pos .y , click_pos .x ) == - 1 :
237- deselect ()
238- set_caret_line (click_pos .y , false )
239- set_caret_column (click_pos .x , false )
245+
246+ var vp := get_viewport ()
247+ HandlerGUI .popup_under_pos (ContextPopup .create (btn_arr , true , - 1 , separator_arr ), vp .get_mouse_position (), vp )
248+ accept_event ()
249+ var click_pos := get_line_column_at_pos (event .position )
250+ if get_selection_at_line_column (click_pos .y , click_pos .x ) == - 1 :
251+ deselect ()
252+ set_caret_line (click_pos .y , false )
253+ set_caret_column (click_pos .x , false )
240254 else :
241255 # Set these inputs as handled, so the default UndoRedo doesn't eat them.
242256 if ShortcutUtils .is_action_pressed (event , "ui_undo" ):
0 commit comments