|
@@ -136,19 +136,30 @@ let entry_of_object entry =
|
|
|
|
|
|
(* Now transformed objects *)
|
|
|
|
|
|
-(* Create class for tags to extend it easier *)
|
|
|
+(* Tags may be extend by plugins *)
|
|
|
class tag name arg = object
|
|
|
val name : string = name
|
|
|
val arguments : string = arg
|
|
|
end;;
|
|
|
|
|
|
+class entry ?(tags=[]) command = object
|
|
|
+ val command : string = command
|
|
|
+ val tags : tag list = tags
|
|
|
+
|
|
|
+ method command = command
|
|
|
+ method tags = tags
|
|
|
+
|
|
|
+ method change_command new_command = {< command = new_command >}
|
|
|
+ method change_tags new_tags = {< tags = new_tags >}
|
|
|
+end;;
|
|
|
+
|
|
|
(* Types of objects, exposed *)
|
|
|
-type entry = < command : string; tags : tag list >;;
|
|
|
type setting = < key : string; value : string >;;
|
|
|
type t = <
|
|
|
add_common_tags : tag list -> t;
|
|
|
add_entries : entry list -> t;
|
|
|
add_settings : setting list -> t;
|
|
|
+ change_entries : entry list -> t;
|
|
|
change_entry : int -> f:(entry -> entry) -> t;
|
|
|
change_name : string -> t;
|
|
|
common_tags : tag list;
|
|
@@ -177,12 +188,9 @@ let object_of_tag tag = failwith "Not implemented"
|
|
|
let object_of_tag_list =
|
|
|
List.map ~f:object_of_tag
|
|
|
;;
|
|
|
-let object_of_entry object_common_tags entry = object
|
|
|
- val command = entry.command;
|
|
|
- val tags = (object_of_tag_list entry.tags) @ object_common_tags
|
|
|
- method command = command
|
|
|
- method tags = tags
|
|
|
-end;;
|
|
|
+let object_of_entry object_common_tags entry =
|
|
|
+ new entry ~tags:((object_of_tag_list entry.tags) @ object_common_tags) entry.command
|
|
|
+;;
|
|
|
let object_of_setting setting = failwith "Not implemented";;
|
|
|
|
|
|
let init ?(rc=(!Const.rc_file)) () =
|
|
@@ -197,6 +205,9 @@ let init ?(rc=(!Const.rc_file)) () =
|
|
|
method common_tags = common_tags
|
|
|
method settings = settings
|
|
|
|
|
|
+ (* Change entry list *)
|
|
|
+ method change_entries new_entries = {< entries = new_entries >}
|
|
|
+
|
|
|
(* Get entry number n *)
|
|
|
method entry ~n = List.nth entries n
|
|
|
|
|
@@ -253,16 +264,16 @@ let init ?(rc=(!Const.rc_file)) () =
|
|
|
initializer self#write
|
|
|
end;;
|
|
|
|
|
|
-let create_entry ~cmd ?(tags=[]) = object
|
|
|
- val command = cmd
|
|
|
- val tags = tags
|
|
|
- method command = command
|
|
|
- method tags = tags
|
|
|
-end;;
|
|
|
-let create_tag = failwith "Not implemented"
|
|
|
let create_setting = failwith "Not implemented"
|
|
|
(*
|
|
|
(* Tools to create new tag *)
|
|
|
class enpty_tag = object
|
|
|
val
|
|
|
*)
|
|
|
+
|
|
|
+let change_setting = failwith "Not implemented"
|
|
|
+
|
|
|
+(* Empty entry *)
|
|
|
+let empty_entry () =
|
|
|
+ new entry ~tags:[] ""
|
|
|
+;;
|