Skip to content

Commit

Permalink
coqide: Improve find/replace UI (margins, icons)
Browse files Browse the repository at this point in the history
Fixes #11024
  • Loading branch information
Frigory33 committed Feb 20, 2024
1 parent 2a0c713 commit 014fd11
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
5 changes: 5 additions & 0 deletions doc/changelog/10-coqide/18523-coqide.rst
@@ -0,0 +1,5 @@
- **Changed:**
Find/replace UI was improved: margins, icons for found/not found
(`#18523 <https://github.com/coq/coq/pull/18523>`_,
fixes `#11024 <https://github.com/coq/coq/issues/11024>`_,
by Sylvain Chiron).
47 changes: 26 additions & 21 deletions ide/coqide/wg_Find.ml
Expand Up @@ -14,37 +14,38 @@ class finder name (view : GText.view) =

let widget = Wg_Detachable.detachable
~title:(Printf.sprintf "Find & Replace (%s)" name) () in
let replace_box = GPack.grid (* ~columns:4 ~rows:2 *) ~col_homogeneous:false ~row_homogeneous:false
~packing:widget#add () in
let hb = GPack.hbox ~packing:(replace_box#attach
~left:1 ~top:0 (*~expand:`X ~fill:`X*)) () in
let replace_box = GPack.grid ~col_homogeneous:false ~row_homogeneous:false
~row_spacings:2 ~col_spacings:2 ~packing:widget#add () in
let () = replace_box#set_margin 2 in
let hb = GPack.hbox ~packing:(replace_box#attach ~left:1 ~top:0) () in
let use_regex =
GButton.check_button ~label:"Regular expression"
~packing:(hb#pack ~expand:false ~fill:true ~padding:3) () in
let use_nocase =
GButton.check_button ~label:"Case insensitive"
~packing:(hb#pack ~expand:false ~fill:true ~padding:3) () in
let _ = GMisc.label ~text:"Find:" ~xalign:1.0
~packing:(replace_box#attach
(*~xpadding:3 ~ypadding:3*) ~left:0 ~top:1 (*~fill:`X*)) () in
let _ = GMisc.label ~text:"Replace:" ~xalign:1.0
~packing:(replace_box#attach
(* ~xpadding:3 ~ypadding:3*) ~left:0 ~top:2 (*~fill:`X*)) () in
let find_label = GMisc.label ~text:"Find:"
~packing:(replace_box#attach ~left:0 ~top:1) () in
let replace_label = GMisc.label ~text:"Replace with:"
~packing:(replace_box#attach ~left:0 ~top:2) () in
let () = List.iter (fun label ->
label#set_halign `START;
label#set_margin_left 2;
label#set_margin_right 2;
) [find_label; replace_label] in
let find_entry = GEdit.entry ~editable:true
~packing:(replace_box#attach
(*~xpadding:3 ~ypadding:3*) ~left:1 ~top:1 (*~expand:`X ~fill:`X*)) () in
~packing:(replace_box#attach ~left:1 ~top:1) () in
let replace_entry = GEdit.entry ~editable:true
~packing:(replace_box#attach
(*~xpadding:3 ~ypadding:3*) ~left:1 ~top:2 (*~expand:`X ~fill:`X*)) () in
~packing:(replace_box#attach ~left:1 ~top:2) () in
let next_button = GButton.button ~label:"_Next" ~use_mnemonic:true
~packing:(replace_box#attach (*~xpadding:3 ~ypadding:3*) ~left:2 ~top:1) () in
~packing:(replace_box#attach ~left:2 ~top:1) () in
let previous_button = GButton.button ~label:"_Previous" ~use_mnemonic:true
~packing:(replace_box#attach (*~xpadding:3 ~ypadding:3*) ~left:3 ~top:1) () in
~packing:(replace_box#attach ~left:3 ~top:1) () in
let replace_button = GButton.button ~label:"_Replace" ~use_mnemonic:true
~packing:(replace_box#attach (*~xpadding:3 ~ypadding:3*) ~left:2 ~top:2) () in
~packing:(replace_box#attach ~left:2 ~top:2) () in
let replace_all_button =
GButton.button ~label:"Replace _All" ~use_mnemonic:true
~packing:(replace_box#attach (*~xpadding:3 ~ypadding:3*) ~left:3 ~top:2) () in
~packing:(replace_box#attach ~left:3 ~top:2) () in

object (self)
val mutable last_found = None
Expand Down Expand Up @@ -137,13 +138,16 @@ class finder name (view : GText.view) =
end

method private set_not_found () =
find_entry#misc#modify_bg [`NORMAL, `NAME "#F7E6E6"];
find_entry#set_secondary_icon_stock `DELETE;
find_entry#set_secondary_icon_tooltip_text "String not found";

method private set_found () =
find_entry#misc#modify_bg [`NORMAL, `NAME "#BAF9CE"]
find_entry#set_secondary_icon_stock `FIND;
find_entry#set_secondary_icon_tooltip_text "String found";

method private set_normal () =
find_entry#misc#modify_bg [`NORMAL, `NAME "white"]
find_entry#set_secondary_icon_stock (`STOCK "");
find_entry#set_secondary_icon_tooltip_text "";

method private find_from backward ?(wrapped=false) (starti : GText.iter) =
let found =
Expand Down Expand Up @@ -176,6 +180,7 @@ class finder name (view : GText.view) =

method hide () =
widget#hide;
self#set_normal ();
view#coerce#misc#grab_focus ()

method show () =
Expand Down

0 comments on commit 014fd11

Please sign in to comment.