scel: initial support for SCDoc help browser
this patch introduces two new key bindings: C-c C-y: open help browser via Help.gui C-c h: open help browser for a specific topic the old help browser is still available via C-c C-h and can be used to display pre-rendered help files. Signed-off-by: Tim Blechmann <tim@klingt.org>
This commit is contained in:
parent
7c8c5fe535
commit
a20081f26a
2 changed files with 97 additions and 73 deletions
|
@ -567,35 +567,56 @@ Either visit file internally (.sc) or start external editor (.rtf)."
|
||||||
(interactive
|
(interactive
|
||||||
(list
|
(list
|
||||||
(let ((topic (or (and mark-active (buffer-substring-no-properties (region-beginning) (region-end)))
|
(let ((topic (or (and mark-active (buffer-substring-no-properties (region-beginning) (region-end)))
|
||||||
(sclang-help-topic-at-point)
|
(sclang-help-topic-at-point)
|
||||||
"Help")))
|
"Help")))
|
||||||
(completing-read (format "Help topic%s: " (if (sclang-get-help-file topic)
|
(completing-read (format "Help topic%s: " (if (sclang-get-help-file topic)
|
||||||
(format " (default %s)" topic) ""))
|
(format " (default %s)" topic) ""))
|
||||||
sclang-help-topic-alist nil t nil 'sclang-help-topic-history topic))))
|
sclang-help-topic-alist nil t nil 'sclang-help-topic-history topic))))
|
||||||
(let ((file (sclang-get-help-file topic)))
|
(let ((file (sclang-get-help-file topic)))
|
||||||
(if file
|
(if file
|
||||||
(if (file-exists-p file)
|
(if (file-exists-p file)
|
||||||
(let* ((buffer-name (sclang-help-buffer-name topic))
|
(let* ((buffer-name (sclang-help-buffer-name topic))
|
||||||
(buffer (get-buffer buffer-name)))
|
(buffer (get-buffer buffer-name)))
|
||||||
(unless buffer
|
(unless buffer
|
||||||
(if (sclang-html-file-p file)
|
(if (sclang-html-file-p file)
|
||||||
(w3m-find-file file)
|
(w3m-find-file file)
|
||||||
;; (sclang-goto-help-browser)
|
;; (sclang-goto-help-browser)
|
||||||
;; not a sclang-html file
|
;; not a sclang-html file
|
||||||
(setq buffer (get-buffer-create buffer-name))
|
(setq buffer (get-buffer-create buffer-name))
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(insert-file-contents file)
|
(insert-file-contents file)
|
||||||
(let ((sclang-current-help-file file)
|
(let ((sclang-current-help-file file)
|
||||||
(default-directory (file-name-directory file)))
|
(default-directory (file-name-directory file)))
|
||||||
(sclang-help-mode))
|
(sclang-help-mode))
|
||||||
(set-buffer-modified-p nil)))
|
(set-buffer-modified-p nil)))
|
||||||
(switch-to-buffer buffer))
|
(switch-to-buffer buffer))
|
||||||
(if (sclang-html-file-p file)
|
(if (sclang-html-file-p file)
|
||||||
(sclang-goto-help-browser))
|
(sclang-goto-help-browser))
|
||||||
)
|
)
|
||||||
(sclang-message "Help file not found") nil)
|
(sclang-message "Help file not found") nil)
|
||||||
(sclang-message "No help for \"%s\"" topic) nil)))
|
(sclang-message "No help for \"%s\"" topic) nil)))
|
||||||
|
|
||||||
|
|
||||||
|
(defun sclang-open-help-gui ()
|
||||||
|
"Open SCDoc Help Browser"
|
||||||
|
(interactive)
|
||||||
|
(sclang-eval-string (sclang-format "Help.gui"))
|
||||||
|
)
|
||||||
|
|
||||||
|
(defun sclang-find-help-in-gui (topic)
|
||||||
|
"Search for topic in SCDoc Help Browser"
|
||||||
|
(interactive
|
||||||
|
(list
|
||||||
|
(let ((topic (or (and mark-active (buffer-substring-no-properties (region-beginning) (region-end)))
|
||||||
|
(sclang-help-topic-at-point)
|
||||||
|
"Help")))
|
||||||
|
(completing-read (format "Help topic%s: " (if (sclang-get-help-file topic)
|
||||||
|
(format " (default %s)" topic) ""))
|
||||||
|
sclang-help-topic-alist nil t nil 'sclang-help-topic-history topic)))
|
||||||
|
)
|
||||||
|
(sclang-eval-string (sclang-format "HelpBrowser.openHelpFor(%o)" topic))
|
||||||
|
)
|
||||||
|
|
||||||
;; =====================================================================
|
;; =====================================================================
|
||||||
;; module setup
|
;; module setup
|
||||||
;; =====================================================================
|
;; =====================================================================
|
||||||
|
|
|
@ -73,72 +73,75 @@
|
||||||
(easy-menu-create-menu
|
(easy-menu-create-menu
|
||||||
title
|
title
|
||||||
'(
|
'(
|
||||||
["Start Interpreter" sclang-start :included (not (sclang-library-initialized-p))]
|
["Start Interpreter" sclang-start :included (not (sclang-library-initialized-p))]
|
||||||
["Restart Interpreter" sclang-start :included (sclang-library-initialized-p)]
|
["Restart Interpreter" sclang-start :included (sclang-library-initialized-p)]
|
||||||
["Recompile Class Library" sclang-recompile :included (sclang-library-initialized-p)]
|
["Recompile Class Library" sclang-recompile :included (sclang-library-initialized-p)]
|
||||||
["Stop Interpreter" sclang-stop :included (sclang-get-process)]
|
["Stop Interpreter" sclang-stop :included (sclang-get-process)]
|
||||||
["Kill Interpreter" sclang-kill :included (sclang-get-process)]
|
["Kill Interpreter" sclang-kill :included (sclang-get-process)]
|
||||||
"-"
|
"-"
|
||||||
["Show Post Buffer" sclang-show-post-buffer]
|
["Show Post Buffer" sclang-show-post-buffer]
|
||||||
["Clear Post Buffer" sclang-clear-post-buffer]
|
["Clear Post Buffer" sclang-clear-post-buffer]
|
||||||
"-"
|
"-"
|
||||||
["Switch To Workspace" sclang-switch-to-workspace]
|
["Switch To Workspace" sclang-switch-to-workspace]
|
||||||
"-"
|
"-"
|
||||||
["Evaluate Region" sclang-eval-region]
|
["Evaluate Region" sclang-eval-region]
|
||||||
["Evaluate Line" sclang-eval-region-or-line]
|
["Evaluate Line" sclang-eval-region-or-line]
|
||||||
["Evaluate Defun" sclang-eval-defun]
|
["Evaluate Defun" sclang-eval-defun]
|
||||||
["Evaluate Expression ..." sclang-eval-expression]
|
["Evaluate Expression ..." sclang-eval-expression]
|
||||||
["Evaluate Document" sclang-eval-document]
|
["Evaluate Document" sclang-eval-document]
|
||||||
"-"
|
"-"
|
||||||
["Find Definitions ..." sclang-find-definitions]
|
["Find Definitions ..." sclang-find-definitions]
|
||||||
["Find References ..." sclang-find-references]
|
["Find References ..." sclang-find-references]
|
||||||
["Pop Mark" sclang-pop-definition-mark]
|
["Pop Mark" sclang-pop-definition-mark]
|
||||||
["Show Method Arguments" sclang-show-method-args]
|
["Show Method Arguments" sclang-show-method-args]
|
||||||
["Complete keyword" sclang-complete-symbol]
|
["Complete keyword" sclang-complete-symbol]
|
||||||
["Dump Interface" sclang-dump-interface]
|
["Dump Interface" sclang-dump-interface]
|
||||||
["Dump Full Interface" sclang-dump-full-interface]
|
["Dump Full Interface" sclang-dump-full-interface]
|
||||||
"-"
|
"-"
|
||||||
["Index Help Topics" sclang-index-help-topics]
|
["Index Help Topics" sclang-index-help-topics]
|
||||||
["Find Help ..." sclang-find-help]
|
["Find Help ..." sclang-find-help]
|
||||||
["Switch to Help Browser" sclang-goto-help-browser]
|
["Switch to Help Browser" sclang-goto-help-browser]
|
||||||
"-"
|
["Open Help GUI" sclang-open-help-gui]
|
||||||
["Run Main" sclang-main-run]
|
"-"
|
||||||
["Stop Main" sclang-main-stop]
|
["Run Main" sclang-main-run]
|
||||||
["Show Server Panels" sclang-show-server-panel]
|
["Stop Main" sclang-main-stop]
|
||||||
)))
|
["Show Server Panels" sclang-show-server-panel]
|
||||||
|
)))
|
||||||
|
|
||||||
(defun sclang-fill-mode-map (map)
|
(defun sclang-fill-mode-map (map)
|
||||||
;; process control
|
;; process control
|
||||||
(define-key map "\C-c\C-l" 'sclang-recompile)
|
(define-key map "\C-c\C-l" 'sclang-recompile)
|
||||||
(define-key map "\C-c\C-o" 'sclang-start)
|
(define-key map "\C-c\C-o" 'sclang-start)
|
||||||
;; post buffer control
|
;; post buffer control
|
||||||
(define-key map "\C-c<" 'sclang-clear-post-buffer)
|
(define-key map "\C-c<" 'sclang-clear-post-buffer)
|
||||||
(define-key map "\C-c>" 'sclang-show-post-buffer)
|
(define-key map "\C-c>" 'sclang-show-post-buffer)
|
||||||
;; workspace access
|
;; workspace access
|
||||||
(define-key map "\C-c\C-w" 'sclang-switch-to-workspace)
|
(define-key map "\C-c\C-w" 'sclang-switch-to-workspace)
|
||||||
;; code evaluation
|
;; code evaluation
|
||||||
(define-key map "\C-c\C-c" 'sclang-eval-region-or-line)
|
(define-key map "\C-c\C-c" 'sclang-eval-region-or-line)
|
||||||
(define-key map "\C-c\C-d" 'sclang-eval-region)
|
(define-key map "\C-c\C-d" 'sclang-eval-region)
|
||||||
(define-key map "\C-\M-x" 'sclang-eval-defun)
|
(define-key map "\C-\M-x" 'sclang-eval-defun)
|
||||||
(define-key map "\C-c\C-e" 'sclang-eval-expression)
|
(define-key map "\C-c\C-e" 'sclang-eval-expression)
|
||||||
(define-key map "\C-c\C-f" 'sclang-eval-document)
|
(define-key map "\C-c\C-f" 'sclang-eval-document)
|
||||||
;; language information
|
;; language information
|
||||||
(define-key map "\C-c\C-n" 'sclang-complete-symbol)
|
(define-key map "\C-c\C-n" 'sclang-complete-symbol)
|
||||||
(define-key map "\M-\t" 'sclang-complete-symbol)
|
(define-key map "\M-\t" 'sclang-complete-symbol)
|
||||||
(define-key map "\C-c:" 'sclang-find-definitions)
|
(define-key map "\C-c:" 'sclang-find-definitions)
|
||||||
(define-key map "\C-c;" 'sclang-find-references)
|
(define-key map "\C-c;" 'sclang-find-references)
|
||||||
(define-key map "\C-c}" 'sclang-pop-definition-mark)
|
(define-key map "\C-c}" 'sclang-pop-definition-mark)
|
||||||
(define-key map "\C-c\C-m" 'sclang-show-method-args)
|
(define-key map "\C-c\C-m" 'sclang-show-method-args)
|
||||||
(define-key map "\C-c{" 'sclang-dump-full-interface)
|
(define-key map "\C-c{" 'sclang-dump-full-interface)
|
||||||
(define-key map "\C-c[" 'sclang-dump-interface)
|
(define-key map "\C-c[" 'sclang-dump-interface)
|
||||||
;; documentation access
|
;; documentation access
|
||||||
(define-key map "\C-c\C-h" 'sclang-find-help)
|
(define-key map "\C-c\C-h" 'sclang-find-help)
|
||||||
(define-key map "\C-\M-h" 'sclang-goto-help-browser)
|
(define-key map "\C-\M-h" 'sclang-goto-help-browser)
|
||||||
|
(define-key map "\C-c\C-y" 'sclang-open-help-gui)
|
||||||
|
(define-key map "\C-ch" 'sclang-find-help-in-gui)
|
||||||
;; language control
|
;; language control
|
||||||
(define-key map "\C-c\C-r" 'sclang-main-run)
|
(define-key map "\C-c\C-r" 'sclang-main-run)
|
||||||
(define-key map "\C-c\C-s" 'sclang-main-stop)
|
(define-key map "\C-c\C-s" 'sclang-main-stop)
|
||||||
(define-key map "\C-c\C-p" 'sclang-show-server-panel)
|
(define-key map "\C-c\C-p" 'sclang-show-server-panel)
|
||||||
(define-key map "\C-c\C-k" 'sclang-edit-dev-source)
|
(define-key map "\C-c\C-k" 'sclang-edit-dev-source)
|
||||||
;; electric characters
|
;; electric characters
|
||||||
(define-key map "}" 'sclang-electric-brace)
|
(define-key map "}" 'sclang-electric-brace)
|
||||||
(define-key map ")" 'sclang-electric-brace)
|
(define-key map ")" 'sclang-electric-brace)
|
||||||
|
@ -147,7 +150,7 @@
|
||||||
(define-key map "*" 'sclang-electric-star)
|
(define-key map "*" 'sclang-electric-star)
|
||||||
;; menu
|
;; menu
|
||||||
(let ((title "SCLang"))
|
(let ((title "SCLang"))
|
||||||
(define-key map [menu-bar sclang] (cons title (sclang-mode-make-menu title))))
|
(define-key map [menu-bar sclang] (cons title (sclang-mode-make-menu title))))
|
||||||
;; return map
|
;; return map
|
||||||
map)
|
map)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue