Generic Function | Package: cg | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version

## open-text-file

Arguments: window

This function is used by the File | Open menu-item of the default menu-bar that may be interactively attached to a form. In the IDE, it demonstrates a typical "Open" command for opening a text file into an editor, but this function is not available in a runtime image. A custom application that implements an "Open" command will need to supply its own code for such a command instead, but it may be useful to model after the default menu-bar's example. Here is the code for the open-text-file example:

    (in-package :cg)
    (defmethod open-text-file ((window basic-pane))
       (let* ((selected-window (selected-window window))
              (old-pathname (and selected-window
                                 (file selected-window)))
              (pathname
                (ask-user-for-existing-pathname "Edit File"
                 :stream window
                 ;; By default, offer to edit a file from the same
                 ;; directory as the file displayed in the
                 ;; selected window, if it's a text edit window.
                 :host (and old-pathname
                            (excl::path-namestring
                             (pathname old-pathname)))))
              editor)
          (cond ((null pathname) nil)
                ((not (probe-file pathname))
                 #-runtime-system
                 (ide:lisp-warning "File ~a does not exist." pathname)
                 nil)
                (t
                  (setq editor
                    (make-window (gensym-sequential-name :editor)
                      :title (namestring pathname)
                      :device 'text-edit-window
                      :parent window))
                  (load-file (frame-child editor) pathname)))))

See also new-text-editor, save-text-file, and save-as-text-file.

Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.2 page.
Created 2012.5.30.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version