[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/gnuplot/gnuplot-old/master/lisp/gnuplot-gui.el [Back]  [Original]

;;;; gnuplot-gui.el -- GUI interface to setting options in gnuplot-mode

;; Copyright (C) 1998-2000 Bruce Ravel

;; Author:     Bruce Ravel 
;; Maintainer: Bruce Ravel 
;; Created:    19 December 1998
;; Updated:    16 November 2000
;; Version:    (same as gnuplot.el)
;; Keywords:   gnuplot, plotting, interactive, GUI

;; This file is not part of GNU Emacs.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This lisp script 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.
;;
;; Permission is granted to distribute copies of this lisp script
;; provided the copyright notice and this permission are preserved in
;; all copies.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, you can either send email to this
;; program's maintainer or write to: The Free Software Foundation,
;; Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; send bug reports to the authors (ravel@phys.washington.edu)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; This file provides a graphical user interface to setting arguments
;; to gnuplot commands.  Positioning point near a command and invoking
;; `gnuplot-gui-set-options-and-insert' (C-c C-c or shift-mouse-2)
;; will pop open a frame with widgets for setting the various
;; arguments appropriate the the item that was near point.  The goal
;; is to provide point-and-click functionality to gnuplot-mode.
;;
;; gnuplot-gui is designed for gnuplot 3.7, but since much of 3.7 is
;; backward compatible to 3.5, it will work well for that version
;; also.
;;
;; gnuplot-gui.el was developed using Emacs 19.34 and is known to work
;; on Emacs 20.x and XEmacs 20.x.  I do not know what is the earliest
;; version for which it will work, but I make no guarantees for
;; versions before 19.34.  Note that this makes heavy use of the
;; widget package, so this will not work on Emacs 19.34 unless you
;; install the widget package separately.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; To do:
;;
;; Widgets I need:
;; -- 'position: two or three comma separated numbers used to denote a
;;               position or a tic start/end/increment (see arrow,
;;               need a prefix)
;; -- 'modifier: colon separated fields used for datafile modifiers
;;
;; command types which are currently unsupported or contain mistakes
;; -- unsupported: cntrparam
;; -- plot, splot, fit: rather lame
;; -- label: position information missing
;; -- label: font string handled in overly simple manner
;; -- hidden3d: not really suited to 'list, but all options are exclusive...
;; -- pointstyle argument to "set label"
;;
;; overall:
;; -- continuation lines (ugh!)
;; -- multiple frames end up displaying same window after setting options
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code:

(require 'gnuplot)
(eval-and-compile
  (condition-case ()
      (progn
	(require 'widget)
	(require 'wid-edit))
    (error nil)))
(require 'cl)
(eval-when-compile			; suppress some compiler warnings
  (defvar gnuplot-xemacs-p nil)
  (defvar gnuplot-quote-character nil)
  (defvar gnuplot-info-display nil)
  (defvar gnuplot-mode-map nil))

;; (eval-when-compile
;;   (require 'wid-edit))

(eval-and-compile			; I need this!
  (if (fboundp 'split-string)
      ()
    (defun split-string (string &optional pattern)
      "Return a list of substrings of STRING which are separated by PATTERN.
If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
      (or pattern
	  (setq pattern "[ \f\t\n\r\v]+"))
      ;; The FSF version of this function takes care not to cons in case
      ;; of infloop.  Maybe we should synch?
      (let (parts (start 0))
	(while (string-match pattern string start)
	  (setq parts (cons (substring string start (match-beginning 0)) parts)
		start (match-end 0)))
	(nreverse (cons (substring string start) parts)))) ))


;;; customizable variables

(defgroup gnuplot-gui nil
  "Graphical interface to setting arguments in gnuplot scrips."
  :prefix "gnuplot-gui-"
  :group 'gnuplot)

(defcustom gnuplot-gui-popup-flag nil
  "*Non-nil means to open arguments pop-ups automatically.
This would be done after menu insertion of Gnuplot commands."
  :group 'gnuplot-gui
  :type 'boolean)

(defvar gnuplot-gui-frame nil
  "Frame used to hold the buffer for setting options.")
(defcustom gnuplot-gui-frame-plist
  '(height 18 width 65 border-width 0
	   user-position t top 150 left 150
	   internal-border-width 0 unsplittable t
	   default-toolbar-visible-p nil has-modeline-p nil
	   menubar-visible-p nil)
  "Frame plist for the input run-time display frame in XEmacs."
  :type '(repeat (group :inline t
			(symbol :tag "Property")
			(sexp :tag "Value")))
  :group 'gnuplot-gui)
(defcustom gnuplot-gui-frame-parameters
  '((height . 18)
    (width . 65)
    (user-position . t)
    (top . 150)
    (left . 150)
    (border-width . 0)
    (menu-bar-lines . 0)
    (unsplittable . t))
  "Frame parameters for the input run-time display frame in Emacs."
  :group 'gnuplot-gui
  :type '(repeat (sexp :tag "Parameter:")))

(defcustom gnuplot-gui-fontname-list
  '(" " "\"Helvetica\"" "\"Times-Roman\"")
  "List of known font names.
These *must* be quoted, like so \"\\\"Helvetica\\\"\".  This allows
for fonts with names like \"\\\"Arial Bold Italic\\\"\" to be treated
as single entries in the menu-buttons.  And it is really important that
the first entry in the list be a blank string."
  :group 'gnuplot-gui
  :type '(repeat (string :tag "Font name:")))

;; some global variables
(defvar gnuplot-current-frame nil)
(defvar gnuplot-current-buffer nil)
(defvar gnuplot-current-buffer-point nil)
(defvar gnuplot-gui-alist nil)
(defvar gnuplot-gui-current-string nil)


;;; various tools for handling data structures and text in the buffer

;; tools for accessing the elements of the lists in `gnuplot-gui-all-types'
(defsubst gnuplot-gui-type-tag     (obj) (elt obj 0))
(defsubst gnuplot-gui-type-symbol  (obj) (elt obj 1))
(defsubst gnuplot-gui-type-default (obj) (elt obj 2))
(defsubst gnuplot-gui-type-prefix  (obj) (elt obj 3)) ; also 'range seperator
(defsubst gnuplot-gui-type-fourth  (obj) (elt obj 4))
(defsubst gnuplot-gui-type-list    (obj) (cddr obj))

(defun gnuplot-this-word ()
  "Return the word under point."
  (let ((begin (save-excursion (beginning-of-line) (point-marker)))
	(end   (save-excursion (end-of-line)       (point-marker))))
    (save-excursion
      (or (looking-at "\\

Web Proxy Viewer  |  New URL  |  Original Page