Generic FunctionPackage: cgToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version

save-text-file

Arguments: window

This function is used by the File | Save menu-item of the default menu-bar that may be interactively attached to a form. In the IDE, it demonstrates a typical "Save" command for saving a text file but this function is not available in a runtime image. A custom application that implements a "Save" 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. So here is the code for the save-text-file example (note that this code changed between the 6.2 and 7.0 releases):

(in-package :cg)

(defmethod save-text-file ((window basic-pane))
  ;; Called by the default "Save" menu-item added to a form.
  (let* ((selected-window (selected-window window)))
    (when selected-window
      (save-text-file-2
       selected-window (file selected-window)))))

(defmethod save-text-file-2 ((window basic-pane)
                             &optional pathname old-pathname)
  (declare (ignore pathname old-pathname))
  (warn "The selected window does not know how to do a save."))

(defmethod save-text-file-2 ((window text-edit-window)
                             &optional pathname old-pathname)
  (unless pathname
    (setq pathname (ask-user-for-new-pathname
                    "Specify the new directory and filename."
                    :stream window
                    :initial-directory
                    (and old-pathname
                         (path-namestring old-pathname))
                    :initial-name (and old-pathname
                                       (file-namestring old-pathname)))))
  (when pathname
    (let* ((text-edit-pane (frame-child window)))
      (save-file text-edit-pane pathname)
      (setf (file text-edit-pane) pathname)
      (setf (title window)(namestring pathname)))))

See also new-text-editor, open-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.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version