package frama-c
Platform dedicated to the analysis of source code written in C
Install
Dune Dependency
Authors
-
MMichele Alberti
-
TThibaud Antignac
-
GGergö Barany
-
PPatrick Baudin
-
NNicolas Bellec
-
TThibaut Benjamin
-
AAllan Blanchard
-
LLionel Blatter
-
FFrançois Bobot
-
RRichard Bonichon
-
VVincent Botbol
-
QQuentin Bouillaguet
-
DDavid Bühler
-
ZZakaria Chihani
-
LLoïc Correnson
-
JJulien Crétin
-
PPascal Cuoq
-
ZZaynah Dargaye
-
BBasile Desloges
-
JJean-Christophe Filliâtre
-
PPhilippe Herrmann
-
MMaxime Jacquemin
-
FFlorent Kirchner
-
AAlexander Kogtenkov
-
RRemi Lazarini
-
TTristan Le Gall
-
JJean-Christophe Léchenet
-
MMatthieu Lemerre
-
DDara Ly
-
DDavid Maison
-
CClaude Marché
-
AAndré Maroneze
-
TThibault Martin
-
FFonenantsoa Maurica
-
MMelody Méaulle
-
BBenjamin Monate
-
YYannick Moy
-
PPierre Nigron
-
AAnne Pacalet
-
VValentin Perrelle
-
GGuillaume Petiot
-
DDario Pinto
-
VVirgile Prevosto
-
AArmand Puccetti
-
FFélix Ridoux
-
VVirgile Robles
-
JJan Rochel
-
MMuriel Roger
-
JJulien Signoles
-
NNicolas Stouls
-
KKostyantyn Vorobyov
-
BBoris Yakobowski
Maintainers
Sources
frama-c-29.0-Copper.tar.gz
sha256=d2fbb3b8d0ff83945872e9e6fa258e934a706360e698dae3b4d5f971addf7493
doc/src/frama-c.gui/file_manager.ml.html
Source file file_manager.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
(**************************************************************************) (* *) (* This file is part of Frama-C. *) (* *) (* Copyright (C) 2007-2024 *) (* CEA (Commissariat à l'énergie atomique et aux énergies *) (* alternatives) *) (* *) (* you can redistribute it and/or modify it under the terms of the GNU *) (* Lesser General Public License as published by the Free Software *) (* Foundation, version 2.1. *) (* *) (* It is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU Lesser General Public License for more details. *) (* *) (* See the GNU Lesser General Public License version 2.1 *) (* for more details (enclosed in the file licenses/LGPLv2.1). *) (* *) (**************************************************************************) let add_files (host_window: Design.main_window_extension_points) = Gtk_helper.source_files_chooser (host_window :> Gtk_helper.source_files_chooser_host) (Kernel.Files.get () :> string list) (fun filenames -> Kernel.Files.set (List.map Datatype.Filepath.of_string filenames); if Ast.is_computed () then Gui_parameters.warning "Input files unchanged. Ignored." else begin File.init_from_cmdline (); host_window#reset () end) let filename: Filepath.Normalized.t option ref = ref None (* [None] for opening the 'save as' dialog box; [Some f] for saving in file [f] *) let reparse (host_window: Design.main_window_extension_points) = let old_helt = History.get_current () in let old_scroll = let adj = host_window#source_viewer_scroll#vadjustment in (adj#value -. adj#lower ) /. (adj#upper -. adj#lower) in let succeeded = host_window#full_protect ~cancelable:true (fun () -> let files = Kernel.Files.get () in Kernel.Files.set []; Kernel.Files.set files; Ast.compute (); Boot.play_analysis (); Source_manager.clear host_window#original_source_viewer) in begin match old_helt, succeeded with | None, _ -> (* no history available before reparsing *) host_window#reset () | _, None -> (* the user stopped or an error occurred *) host_window#reset () | Some old_helt, Some () -> let new_helt = History.translate_history_elt old_helt in Option.iter History.push new_helt; host_window#reset (); (* The buffer is not ready yet, modification of its vadjustement is unreliable *) let set () = let adj = host_window#source_viewer_scroll#vadjustment in adj#set_value (old_scroll *. (adj#upper-.adj#lower) +. adj#lower) in Wutil.later set end let save_in (host_window: Design.main_window_extension_points) parent name = try Project.save_all name; filename := Some name with Project.IOError s -> host_window#error ~parent "Cannot save: %s" s (** Save a project file. Choose a filename *) let save_file_as (host_window: Design.main_window_extension_points) = let dialog = GWindow.file_chooser_dialog ~action:`SAVE ~title:"Save the current session" ~parent:host_window#main_window () in (*dialog#set_do_overwrite_confirmation true ; only in later lablgtk2 *) dialog#add_button_stock `CANCEL `CANCEL ; dialog#add_select_button_stock `SAVE `SAVE ; host_window#protect ~cancelable:true ~parent:(dialog :> GWindow.window_skel) (fun () -> match dialog#run () with | `SAVE -> Option.iter (save_in host_window (dialog :> GWindow.window_skel)) (Option.map Filepath.Normalized.of_string dialog#filename) | `DELETE_EVENT | `CANCEL -> ()); dialog#destroy () let save_file (host_window: Design.main_window_extension_points) = match !filename with | None -> save_file_as host_window | Some f -> save_in host_window (host_window#main_window :> GWindow.window_skel) f (** Load a project file *) let load_file (host_window: Design.main_window_extension_points) = let dialog = GWindow.file_chooser_dialog ~action:`OPEN ~title:"Load a saved session" ~parent:host_window#main_window () in dialog#add_button_stock `CANCEL `CANCEL ; dialog#add_select_button_stock `OPEN `OPEN ; host_window#protect ~cancelable:true ~parent:(dialog:>GWindow.window_skel) (fun () -> match dialog#run () with | `OPEN -> begin match dialog#filename with | None -> () | Some f -> Project.load_all (Filepath.Normalized.of_string f) end | `DELETE_EVENT | `CANCEL -> ()); dialog#destroy () (** Open the Preferences dialog *) let preferences (host_window: Design.main_window_extension_points) = let dialog = GWindow.dialog ~modal:true ~border_width:8 ~title:"Preferences" ~parent:host_window#main_window () in let main_box = dialog#vbox in main_box#set_spacing 10; let theme_frame = GBin.frame ~label:"Property bullets theme" () in main_box#pack theme_frame#coerce; let theme_box = GPack.vbox ~spacing:2 ~border_width:10 () in theme_frame#add theme_box#coerce; (* Themes are directories in share/theme. *) let themes_path = !Wutil.share ^ "/theme/" in let themes = Array.to_list (Sys.readdir themes_path) in let is_theme_directory name = Sys.is_directory (themes_path ^ name) in let themes = List.filter is_theme_directory themes in (* The current theme is kept in the configuration file. *) let active_theme = Gtk_helper.Configuration.find_string ~default:"default" "theme" in let theme_group = new Widget.group "" in let name = let label = String.capitalize_ascii name in let widget = theme_group#add_radio ~label ~value:name () in theme_box#add widget#coerce in (* Builds the theme buttons, and sets the active theme. *) List.iter build_theme_button themes; theme_group#set active_theme; (* External editor command. *) let default = "emacs +%d %s" in let editor = Gtk_helper.Configuration.find_string ~default "editor" in let editor_frame = GBin.frame ~label:"Editor command" () in main_box#pack editor_frame#coerce; let editor_box = GPack.vbox ~spacing:5 ~border_width:10 () in editor_frame#add editor_box#coerce; let text = "Command to open an external editor \ on Ctrl-click in the original source code. \n\ Use %s for file name and %d for line number." in let label = GMisc.label ~xalign:0. ~line_wrap:true ~text () in editor_box#pack label#coerce; let editor_input = GEdit.entry ~width_chars:30 ~text:editor () in editor_box#pack editor_input#coerce ~expand:true; (* Save and cancel buttons. *) let = dialog#action_area in let packing = hbox_buttons#pack ~expand:true ~padding:3 in let reset_box = GPack.vbox ~spacing:5 ~border_width:10 () in main_box#pack reset_box#coerce; let reset_packing = reset_box#pack in let = GButton.button ~label:"Reset GUI to factory defaults" ~packing:reset_packing () in ignore (reset_button#event#connect#button_release ~callback:(fun _ -> let answer = GToolbox.question_box ~title:"Reset GUI to factory defaults?" ~buttons:["Reset GUI" ; "Cancel"] ~default:2 "This will restore all GUI-related settings \ to factory defaults,\n\ including panel sizes and preferences." in if answer = 1 then begin Gtk_helper.Configuration.reset (); GToolbox.message_box ~title:"GUI reset" "GUI reset will take place after restarting Frama-C."; end; false)); let wb_ok = GButton.button ~label:"Save" ~packing () in let wb_cancel = GButton.button ~label:"Cancel" ~packing () in wb_ok#grab_default (); let f_ok () = (* retrieve chosen preferences from dialog *) (* note: Guilib does not allow double quotes in strings, but it fails without raising an exception, so we must check if beforehand. *) if String.contains editor_input#text '"' then GToolbox.message_box ~title:"Error" "Error: configuration strings cannot contain double quotes. \n\ Use single quotes instead. \n\ Note that file names (%s) are automatically quoted." else begin Gui_parameters.debug "saving preferences"; Gtk_helper.Configuration.set "theme" (Gtk_helper.Configuration.ConfString theme_group#get); Gtk_helper.Configuration.set "editor" (Gtk_helper.Configuration.ConfString editor_input#text); Gtk_helper.Configuration.save (); dialog#destroy (); (* Reloads the icons from the theme, and resets the icons used as property status bullets.*) Gtk_helper.Icon.clear (); Design.Feedback.declare_markers host_window#source_viewer; end in let f_cancel () = Gui_parameters.debug "canceled, preferences not saved"; dialog#destroy () in ignore (wb_ok#connect#clicked ~callback:f_ok); ignore (wb_cancel#connect#clicked ~callback:f_cancel); (* the enter key is linked to the ok action *) (* the escape key is linked to the cancel action *) dialog#misc#grab_focus (); dialog#show () let insert (host_window: Design.main_window_extension_points) = let = host_window#menu_manager () in let _, = menu_manager#add_menu "_File" in let file_items = menu_manager#add_entries filemenu [ Menu_manager.toolmenubar ~icon:`FILE ~label:"Source files" ~tooltip:"Create a new session from existing C files" (Menu_manager.Unit_callback (fun () -> add_files host_window)); Menu_manager.toolmenubar ~icon:`REFRESH ~label:"Reparse" ~tooltip:"Reparse source files, and replay analyses" (Menu_manager.Unit_callback (fun () -> reparse host_window)); Menu_manager.toolmenubar ~icon:`REVERT_TO_SAVED ~label:"Load session" (Menu_manager.Unit_callback (fun () -> load_file host_window)); Menu_manager.toolmenubar ~icon:`SAVE ~label:"Save session" (Menu_manager.Unit_callback (fun () -> save_file host_window)); Menu_manager.menubar ~icon:`SAVE_AS "Save session as" (Menu_manager.Unit_callback (fun () -> save_file_as host_window)); Menu_manager.menubar ~icon:`PREFERENCES "Preferences" (Menu_manager.Unit_callback (fun () -> preferences host_window)); ] in file_items.(5)#add_accelerator `CONTROL 'p'; file_items.(3)#add_accelerator `CONTROL 's'; file_items.(2)#add_accelerator `CONTROL 'l'; let stock = `QUIT in let quit_item = menu_manager#add_entries filemenu [ Menu_manager.menubar ~icon:stock "Exit Frama-C" (Menu_manager.Unit_callback Cmdline.bail_out) ] in quit_item.(0)#add_accelerator `CONTROL 'q' (** Register this dialog in main window menu bar *) let () = Design.register_extension insert (* Local Variables: compile-command: "make -C ../../.." End: *)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>