|
@@ -38,20 +38,32 @@ open Core.Std;;
|
|
|
|
|
|
(* This modules contains function to list the content of the rc file *)
|
|
|
|
|
|
-(* Display the command with its number, with a '*' and different color if it is the current one *)
|
|
|
-let disp_cmd_num current_number number command =
|
|
|
- (* If number is the global current one print a '*' *)
|
|
|
- let prepend = (if current_number = number then "* " else " ") in
|
|
|
- sprintf "%s%i: %s" prepend number command
|
|
|
- |> (fun concatenated_msg ->
|
|
|
- match prepend with
|
|
|
- | "* " -> Messages.ok concatenated_msg
|
|
|
- | " " -> Messages.tips concatenated_msg
|
|
|
- | _ -> assert false)
|
|
|
+(* Function which list, rc would be automatically reread, this optional
|
|
|
+ * argument is kept for backward compatibility *)
|
|
|
+(* FIXME Remove ?rc or use it *)
|
|
|
+(* TODO:
|
|
|
+ * Test it, esp. ordering
|
|
|
+ * Allow to set form of the table, multiple rc file, display next to be
|
|
|
+ * launched… *)
|
|
|
+let run ?rc () =
|
|
|
+ let rc_numbered =
|
|
|
+ File_com.init_rc ()
|
|
|
+ |> fun rc -> rc.progs
|
|
|
+ |> List.mapi ~f:(fun i item -> ( item, i ))
|
|
|
+ in
|
|
|
+ let tmp : Tmp_file.t = Tmp_file.init () in
|
|
|
+ Tmp_file.get_accurate_log ~tmp ()
|
|
|
+ (* Generate list to feed the table,
|
|
|
+ * XXX assuming all will be in the right order *)
|
|
|
+ |> List.map ~f:(function
|
|
|
+ ( cmd, number ) ->
|
|
|
+ [ (* Number of a command in rc file, command, number of launch *)
|
|
|
+ (List.Assoc.find_exn rc_numbered cmd |> Int.to_string);
|
|
|
+ cmd;
|
|
|
+ (Int.to_string number)
|
|
|
+ ])
|
|
|
+ |> Textutils.Ascii_table.simple_list_table
|
|
|
+ ~display:Textutils.Ascii_table.Display.column_titles
|
|
|
+ [ "Id" ; "Command" ; "Number of launch" ]
|
|
|
;;
|
|
|
|
|
|
-(* Function which list *)
|
|
|
-let run ~(rc:File_com.t) =
|
|
|
- List.iteri rc.Settings_t.progs ~f:(fun i item ->
|
|
|
- disp_cmd_num (Tmp_file.get_current ()) i item)
|
|
|
-;;
|