mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-24 05:45:59 +08:00
answers to Jeremy's requests
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/ocamlrun /usr/bin/ocaml
|
||||
#load "unix.cma";;
|
||||
let (//) = Filename.concat
|
||||
let dirname = Filename.dirname Sys.argv.(0)
|
||||
let env =
|
||||
Array.map (fun var ->
|
||||
let value = try Sys.getenv var with _ -> dirname in
|
||||
Printf.sprintf "%s=%s" var value)
|
||||
[|"PAPARAZZI_SRC"; "PAPARAZZI_HOME"|]
|
||||
let com = dirname // "sw/supervision/paparazzicenter";;
|
||||
Sys.argv.(0) <- com;;
|
||||
let env = Array.append env (Unix.environment ());;
|
||||
Unix.execve com Sys.argv env
|
||||
@@ -1895,6 +1895,42 @@
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTextView" id="console_cp">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="overwrite">False</property>
|
||||
<property name="accepts_tab">True</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_NONE</property>
|
||||
<property name="cursor_visible">True</property>
|
||||
<property name="pixels_above_lines">0</property>
|
||||
<property name="pixels_below_lines">0</property>
|
||||
<property name="pixels_inside_wrap">0</property>
|
||||
<property name="left_margin">0</property>
|
||||
<property name="right_margin">0</property>
|
||||
<property name="indent">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
||||
@@ -38,6 +38,9 @@ let () =
|
||||
|
||||
gui#window#set_icon (Some (GdkPixbuf.from_file Env.icon_file));
|
||||
|
||||
let s = gui#statusbar#new_context "env" in
|
||||
ignore (s#push (sprintf "HOME=%s SRC=%s" Env.paparazzi_home Env.paparazzi_src));
|
||||
|
||||
let ac_combo = AC.parse_conf_xml gui#vbox_ac
|
||||
and target_combo = combo ["sim";"fbw";"ap"] gui#vbox_target in
|
||||
|
||||
@@ -55,18 +58,34 @@ let () =
|
||||
let tag = GText.tag ~name:color () in
|
||||
tag#set_property (`BACKGROUND color);
|
||||
(color, tag))
|
||||
["red"; "green"] in
|
||||
["red"; "green";"orange"] in
|
||||
let tag_table = GText.tag_table () in
|
||||
List.iter (fun (color, tag) -> tag_table#add tag#as_tag) background_tags;
|
||||
let buffer = GText.buffer ~tag_table () in
|
||||
gui#console#set_buffer buffer;
|
||||
|
||||
let error_regexp = Str.regexp_case_fold ".*\\(error\\)\\|\\(no such file\\)" in
|
||||
let errors = "red", ["error"; "no such file"; "undefined reference"]
|
||||
and warnings = "orange", ["warning"] in
|
||||
|
||||
let color_regexps =
|
||||
List.map (fun (color, strings) ->
|
||||
let s = List.map (fun s -> "\\("^s^"\\)") strings in
|
||||
let s = String.concat "\\|" s in
|
||||
let s = ".*\\("^s^"\\)" in
|
||||
color, Str.regexp_case_fold s)
|
||||
[errors; warnings] in
|
||||
let compute_tags = fun s ->
|
||||
if Str.string_match error_regexp s 0 then
|
||||
[List.assoc "red" background_tags]
|
||||
else
|
||||
[] in
|
||||
let rec loop = function
|
||||
(color, regexp)::rs ->
|
||||
if Str.string_match regexp s 0 then
|
||||
[List.assoc color background_tags]
|
||||
else
|
||||
loop rs
|
||||
| [] -> [] in
|
||||
loop color_regexps in
|
||||
|
||||
(* Attach the second console to the buffer of the first one *)
|
||||
gui#console_cp#set_buffer gui#console#buffer;
|
||||
|
||||
let log = fun s ->
|
||||
let iter = gui#console#buffer#end_iter in
|
||||
@@ -91,5 +110,5 @@ let () =
|
||||
ignore(socket_GCS#connect#plug_removed
|
||||
(fun () -> gui#vbox_GCS#remove socket_GCS#coerce; socket ())) in
|
||||
socket ();
|
||||
|
||||
|
||||
GMain.Main.main ();;
|
||||
|
||||
@@ -213,11 +213,15 @@ let supervision = fun ?file gui log ->
|
||||
(* Programs *)
|
||||
let entries = ref [] in
|
||||
Hashtbl.iter
|
||||
(fun name prog ->
|
||||
(fun name prog ->
|
||||
let cb = fun () ->
|
||||
run_and_monitor ?file gui log name "" in
|
||||
entries := `I (name, cb) :: !entries)
|
||||
programs;
|
||||
let compare = fun x y ->
|
||||
match x, y with
|
||||
`I (x, _), `I (y, _) -> compare x y
|
||||
| _ -> compare x y in
|
||||
let menu = GMenu.menu ()
|
||||
and sorted_entries = List.sort compare !entries in
|
||||
GToolbox.build_menu menu sorted_entries;
|
||||
|
||||
Reference in New Issue
Block a user