~ubuntu-branches/ubuntu/hardy/texmacs/hardy

« back to all changes in this revision

Viewing changes to TeXmacs/progs/texmacs/edit/edit-session.scm

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Treinen
  • Date: 2004-04-19 20:34:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040419203400-g4e34ih0315wcn8v
Tags: upstream-1.0.3-R2
ImportĀ upstreamĀ versionĀ 1.0.3-R2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
3
;;
 
4
;; MODULE      : edit-session.scm
 
5
;; DESCRIPTION : editing routines for sessions
 
6
;; COPYRIGHT   : (C) 2001  Joris van der Hoeven
 
7
;;
 
8
;; This software falls under the GNU general public license and comes WITHOUT
 
9
;; ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for details.
 
10
;; If you don't have this file, write to the Free Software Foundation, Inc.,
 
11
;; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
12
;;
 
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
14
 
 
15
(texmacs-module (texmacs edit edit-session)
 
16
  (:export
 
17
    toggle-session-math-input
 
18
    session-multiline-input? toggle-session-multiline-input
 
19
    session-return session-shift-return))
 
20
 
 
21
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
22
;; Switches
 
23
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
24
 
 
25
(tm-define (toggle-session-math-input)
 
26
  (:synopsis "Toggle mathematical input in sessions.")
 
27
  (:check-mark "v" session-math-input?)
 
28
  (session-use-math-input (not (session-math-input?))))
 
29
 
 
30
(define session-multiline-input #f)
 
31
(define (session-multiline-input?) session-multiline-input)
 
32
 
 
33
(tm-define (toggle-session-multiline-input)
 
34
  (:synopsis "Toggle multi-line input in sessions.")
 
35
  (:check-mark "v" session-multiline-input?)
 
36
  (set! session-multiline-input (not session-multiline-input)))
 
37
 
 
38
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
39
;; The return key in session input
 
40
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
41
 
 
42
(define (session-get-input-string)
 
43
  (let* ((p (search-upwards "input"))
 
44
         (input (tree->object (tm-subtree (rcons p 2))))
 
45
         (s (verbatim-serialize (get-env "prog-language") input)))
 
46
    (substring s 0 (- (string-length s) 1))))
 
47
 
 
48
(define (session-process-input)
 
49
  (let ((lan (get-env "prog-language"))
 
50
        (ses (get-env "prog-session")))
 
51
    (if (plugin-supports-input-done? lan)
 
52
        (let* ((s (escape-quotes (session-get-input-string)))
 
53
               (cmd (string-append "(input-done? \"" s "\")"))
 
54
               (r (tree->object (connection-cmd lan ses cmd))))
 
55
          (if (== r "#f")
 
56
              (insert-return)
 
57
              (process-input)))
 
58
        (process-input))))
 
59
 
 
60
(tm-define (session-return)
 
61
  (:synopsis "Pressing return in session input.")
 
62
  (if (session-multiline-input?)
 
63
      (insert-return)
 
64
      (session-process-input)))
 
65
 
 
66
(tm-define (session-shift-return)
 
67
  (:synopsis "Pressing shift-return in session input.")
 
68
  (if (session-multiline-input?)
 
69
      (session-process-input)
 
70
      (insert-return)))