Module: environment-tools Synopsis: Environment tools Author: Andy Armstrong, Chris Page Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND /// Constants define constant $playground-description = #["This option starts a simple application that you", "can use to evaluate Dylan code interactively."]; define constant $examples-description = #["This option displays a list of example projects", "that you can use to get started using Dylan."]; /*---*** Not used currently define constant $tutorial-description = #["This option starts a tutorial that describes", "Functional Developer and the Dylan language."]; */ /// Variables ///---*** These really need to be read from a registry define variable *last-project* :: false-or() = #f; //--- cpage: 1997.10.25 This is a bit hackish. We use this variable to pass the // filename or project parameter from start-environment to the // handle-event method on (, ). // Perhaps there's a better way? I explicitly didn't add a slot to // yet because I'm not sure this functionality // is even needed or if it is a remnant of the emulator environment. define variable *startup-open-file* = #f; /// Start environment define method start-environment (#key filename :: false-or(), project) => (status-code :: ) //--- cpage: 1997.09.26 This is a kludge for the emulator, which can restart // the environment without initializing module variables. *application-exiting?* := #f; block() broadcast($environment-channel, make()); *startup-open-file* := project | filename; let primary-frame = make-environment-frame(default-port(), ); start-environment-frame(primary-frame); // hughg, 1998/09/25: See bug 4072 for why we don't WAIT-FOR-SHUTDOWN any // more. We should really remove that and related stuff from ENVIRONMENT- // FRAMEWORK, but it won't hurt to leave it in for now. 0 cleanup broadcast($environment-channel, make()) end block end method start-environment; define method handle-environment-startup (frame :: ) => () broadcast($environment-channel, make()); let (process, id) = just-in-time-debugging-arguments(); let filename = *startup-open-file*; case process & id => frame-open-just-in-time-project(frame, process, id); filename => let location = as(, filename); let full-location = merge-locators(location, working-directory()); open-file(owner: frame, filename: as(, full-location)); // Reset this, for the emulator, which can start the environment more than once. *startup-open-file* := #f; otherwise => select (environment-start-action()) #"start-dialog" => initial-dialog(frame); #"open-file" => open-file(owner: frame); #"no" => /* Do nothing */; end select; end end method handle-environment-startup; /// Initial about box /*---*** andrewa: currently we've decided not to use this... define constant $build-date = make(, day: 20, month: 5, year: 1998); //---*** This is a fake, we should add it for real to release-info! define function release-build-date () => (date :: ) $build-date end function release-build-date; define function six-months-after-build? () => (six-months? :: ) let date = current-date(); let build-date = release-build-date(); let six-month-date = build-date + make(, months: 6); local method debug-show-date (name :: , date :: ) => () debug-message ("%s: %=/%=/%=", name, date.date-day, date.date-month, date.date-year) end method debug-show-date; debug-show-date("Current date", date); debug-show-date(" build date", build-date); debug-show-date(" six months", six-month-date); date >= six-month-date end function six-months-after-build?; */ /// Project browser startup //---*** cpage: 97.08.13 Note that status codes will eventually be replaced by // properly defined exceptions. I've temporarily added this code // to assist in reporting errors to the user. define constant $project-browser-not-found-status = 1; define method find-project-browser (project :: , #rest args, #key, #all-keys) => (status-code :: false-or()) let project = coerce-project(project); if (project) *last-project* := project; apply(ensure-project-browser-showing-project, project, args); 0 else $project-browser-not-found-status end end method find-project-browser; /// Initial dialog define frame () slot initial-dialog-action :: , required-init-keyword: action:; /*---*** Temporarily remove this until we have a Tutorial pane %dialog-tutorial-button (frame) make(, label: "Tutorial", id: #"tutorial", activate-callback: exit-dialog); */ pane %dialog-example-button (frame) make(, label: "Example project", id: #"example", activate-callback: exit-dialog); pane %dialog-playground-button (frame) make(, label: "Dylan playground", id: #"playground", activate-callback: exit-dialog); pane %dialog-new-project-button (frame) make(, label: "Project", id: #"new-project", activate-callback: exit-dialog); pane %dialog-new-text-button (frame) make(, label: "Text File", id: #"new-text", activate-callback: exit-dialog); pane %dialog-open-button (frame) make(, label: "Open", id: #"open", activate-callback: exit-dialog); /*---*** Temporarily remove this until we have a Tutorial pane %dialog-tutorial-layout (frame) vertically (spacing: 0) make(