Browse files

* code_map/view_mainmap.ml: highlight currently selected node

  • Loading branch information...
1 parent 967ca3e commit 99a4b8d83df91e2194a249cd3cada56fc7d3217f @aryx aryx committed Mar 6, 2014
Showing with 39 additions and 12 deletions.
  1. +2 −0 code_map/model2.ml
  2. +2 −0 code_map/model2.mli
  3. +24 −8 code_map/view_mainmap.ml
  4. +10 −4 code_map/view_overlays.ml
  5. +1 −0 main_codemap.ml
View
2 code_map/model2.ml
@@ -181,6 +181,8 @@ type world = {
treemap_func: Common.path list -> Treemap.treemap_rendering;
(* misc settings, not really used for now *)
settings: settings;
+
+ mutable current_node: Graph_code.node option;
}
and settings = {
mutable draw_summary: bool;
View
2 code_map/model2.mli
@@ -133,6 +133,8 @@ type world = {
treemap_func: Common.path list -> Treemap.treemap_rendering;
(* misc settings, not really used for now *)
settings: settings;
+
+ mutable current_node: Graph_code.node option;
}
and settings = {
mutable draw_summary: bool;
View
32 code_map/view_mainmap.ml
@@ -226,12 +226,16 @@ let button_action w ev =
glyph_opt >>= (fun glyph ->
M.find_use_entity_at_line_and_glyph_opt line glyph tr dw model))
in
-
+ let entity_opt =
+ match entity_use_opt, entity_def_opt with
+ | Some e, _ | _, Some e -> Some e
+ | _ -> None
+ in
let uses, users =
- match entity_def_opt, entity_use_opt with
- | None, None -> M.deps_readable_files_of_file file model
- | Some n, _ | _, Some n -> M.deps_readable_files_of_node n model
+ match entity_opt with
+ | None -> M.deps_readable_files_of_file file model
+ | Some n -> M.deps_readable_files_of_node n model
in
let paths_of_readables xs =
@@ -248,24 +252,36 @@ let button_action w ev =
+> List.filter Sys.file_exists
in
let readable = Common.readable ~root:model.root file in
+ let readable =
+ match entity_opt with
+ | None -> readable
+ | Some n ->
+ let g = Common2.some model.g in
+ try Graph_code.file_of_node n g
+ with Not_found -> readable
+ in
let entries = [
`I ("go to file", (fun () ->
!Ctl._go_dirs_or_file w (paths_of_readables [readable]);));
`I ("deps inout", (fun () ->
+ w.current_node <- entity_opt;
!Ctl._go_dirs_or_file w (paths_of_readables
(uses @ users @ [readable]))));
`I ("deps in (users)", (fun () ->
+ w.current_node <- entity_opt;
!Ctl._go_dirs_or_file w (paths_of_readables
(users @ [readable]))));
`I ("deps out (uses)", (fun () ->
+ w.current_node <- entity_opt;
!Ctl._go_dirs_or_file w (paths_of_readables
(uses @ [readable]))));
] in
let entries =
entries @
- (match entity_def_opt, entity_use_opt, model.g with
- | None, None, _ -> []
- | Some n, _, Some g | _, Some n, Some g ->
+ (match entity_opt with
+ | None -> []
+ | Some n ->
+ let g = Common2.some model.g in
[`I ("info entity", (fun () ->
let users = Graph_code.pred n (Graph_code.Use) g in
let str =
@@ -276,11 +292,11 @@ let button_action w ev =
Gui.dialog_text ~text:str ~title:"Info entity";
));
`I ("goto def", (fun () ->
+ w.current_node <- entity_opt;
let dest = Graph_code.file_of_node n g in
!Ctl._go_dirs_or_file w (paths_of_readables [dest])
));
]
- | _ -> raise Impossible
)
in
GToolbox.popup_menu ~entries ~button:3
View
14 code_map/view_overlays.ml
@@ -286,6 +286,7 @@ let motion_refresher ev w =
r_opt +> Common.do_option (fun (tr, middle, r_englobing) ->
let model = Async.async_get w.model in
+ (* coupling: similar code in right click handler in View_mainmap *)
let line_opt =
M.find_line_in_rectangle_at_user_point user tr dw in
let glyph_opt =
@@ -297,6 +298,11 @@ let motion_refresher ev w =
glyph_opt >>= (fun glyph ->
M.find_use_entity_at_line_and_glyph_opt line glyph tr dw model))
in
+ let entity_opt =
+ match entity_use_opt, entity_def_opt with
+ | Some e, _ | _, Some e -> Some e
+ | _ -> None
+ in
let statusbar_txt =
tr.T.tr_label ^
@@ -323,10 +329,10 @@ let motion_refresher ev w =
draw_englobing_rectangles_overlay ~dw (tr, middle, r_englobing);
draw_deps_files tr dw model;
- entity_def_opt +> Common.do_option (fun n ->
- draw_deps_entities n dw model);
- entity_use_opt +> Common.do_option (fun n ->
- draw_deps_entities n dw model);
+ entity_opt +> Common.do_option (fun _n -> w.current_node <- None);
+ w.current_node +> Common.do_option (fun n -> draw_deps_entities n dw model);
+ entity_def_opt +> Common.do_option (fun n -> draw_deps_entities n dw model);
+ entity_use_opt +> Common.do_option (fun n -> draw_deps_entities n dw model);
if w.settings.draw_searched_rectangles;
then draw_searched_rectangles ~dw;
View
1 main_codemap.ml
@@ -380,6 +380,7 @@ let main_action xs =
dw_stack = ref [dw];
model = async_model;
treemap_func;
+ current_node = None;
settings = { Model.
(* todo: too fuzzy for now *)
draw_summary = false;

0 comments on commit 99a4b8d

Please sign in to comment.