module File:sig
..end
File dialog and file monitor
This module offers a quite complete file dialog layout.
Popup
on top of any
existing layout. It can also be inserted anywhere just like any other
layout.Warning: Some File.options
are not implemented yet; these -- and more
features -- will certainly be added in the future.
module Monitor:sig
..end
Monitoring changes in a directory.
module Mime:sig
..end
Mimetype information
type
t
The type for file dialogs.
type
options
val set_options : ?width:int ->
?height:int ->
?dirs_first:bool ->
?show_hidden:bool ->
?hide_backup:bool ->
?max_selected:int ->
?hide_dirs:bool ->
?only_dirs:bool ->
?select_dir:bool ->
?allow_new:bool ->
?default_name:string ->
?breadcrumb:bool ->
?system_icons:bool ->
?open_dirs_on_click:bool ->
?mimetype:Str.regexp ->
?on_select:(int * int -> unit) -> unit -> options
dirs_first
: partially implementedsystem_icons
: not implementedtype
entry
The entry
type can be used to create filters for selecting
what is actually displayed by the file dialog.
val filename : entry -> string
val lstat_opt : entry -> Unix.stats option
val stat_opt : entry -> Unix.stats option
The stat_opt
and lstat_opt
return the corresponding pre-computed
Unix.stats
results, without actually calling any system function.
val dialog : ?full_filter:(entry -> bool) ->
?options:options -> string -> t
Use this function if you need unusual combinations of options. For most
common uses, see File.select_file
(and others) below.
val get_layout : t -> Layout.t
Return the layout containing the whole file dialog except for the "select" and "cancel" buttons.
val get_selected : t -> string list
Return the (alphabetically sorted) list of selected files or directories.
val basedir : t -> string
Return the full path of the currently displayed directory.
val select_file : ?dst:Layout.t ->
?board:Main.board ->
?w:int ->
?h:int ->
?mimetype:Str.regexp -> ?name:string -> string -> (string -> unit) -> unit
select_file dirname continue
will open a file dialog, initially showing
the content of the directory dirname
. The user can then navigate to
other directories. When the user selects a file in the list and presses
the "Select file" button, the dialog will close, and the continue
function will be applied to the selected filename (full path).
If the dialog is closed by the user pressing the "Cancel" button or the
ESCAPE key, the continue
function is not used.
Note that global bindings to the ESCAPE key are temporarily disabled when the file dialog is open.
dst
: the file selector will show up on top of the dst
layout, or
in a new window if dst
is not provided.board
: See Popup.two_buttons
. Note that, if board
is omitted,
the window will be created at the next frame, but the file selector
layout is immediately created.mimetype
: only show files whose mimetype string (like "image/png")
matches the regular expression.name
: default name to be chosen.val select_files : ?dst:Layout.t ->
?board:Main.board ->
?w:int ->
?h:int ->
?mimetype:Str.regexp ->
?n_files:int -> string -> (string list -> unit) -> unit
Similar to File.select_file
except that here several files can be
selected. If n_files
is provided, it will be the maximum number of files
that may be selected.
val select_dir : ?dst:Layout.t ->
?board:Main.board ->
?w:int -> ?h:int -> ?name:string -> string -> (string -> unit) -> unit
Similar to File.select_file
except that here only a directory can be
selected. If the user clicks on a directory name, they will be given the
option to either open this directory (for further navigation), or select
it (hence closing the dialog).
val select_dirs : ?dst:Layout.t ->
?board:Main.board ->
?w:int -> ?h:int -> ?n_dirs:int -> string -> (string list -> unit) -> unit
Similar to File.select_files
except that here only directories can be
selected.
val save_as : ?dst:Layout.t ->
?board:Main.board ->
?w:int -> ?h:int -> ?name:string -> string -> (string -> unit) -> unit
Similar to File.select_file
, but here the user can enter a filename that
does not already exist in the displayed directory.
val let@ : ('a -> 'b) -> 'a -> 'b
( let@ ) f x
is just f x
. You can use this "syntaxic sugar"
to write your code like this:
let open File in
let@ file = select_file "/tmp" in
print_endline ("Selected file : " ^ file)
instead of
File.select_file "/tmp" (fun file ->
print_endline ("Selected file : " ^ file))