Permalink
Browse files

add send to repl functions in menu.source

  • Loading branch information...
ghostandthemachine committed Aug 24, 2012
1 parent 633f21b commit e307f70f0f65f3293a3344b511d3e9193886e0ad
View
@@ -12,3 +12,4 @@ The goal is to have the user namespace provide access and functionality as power
This part of the project is still young but will be a central cog in the SketchPad architecture. Leiningen has quickly become one the most popular Clojure project management tools and with the release of 2.0 it will only be more widely used. The goal is to leverage all of the Leiningen features from managing dependencies and projects to publishing projects to clojars all from SketchPad and in Clojure.
![SketchPad screen shot](https://github.com/ghostandthemachine/sketchpad/blob/master/img/SketchPad-screenshot.png?raw=true)
+
@@ -1,4 +1,4 @@
-#GSoC Overtone SketchPad
+ #GSoC Overtone SketchPad
####Project Deliverables
The fundamental goal of the SketchPad GSoC project is to deliver a standalone programming environment for creating and learning sound design with Overtone and Clojure. Inspired by the popular Processing project, SketchPad aims to make the hassle of dependencies, operating systems, and installations a non-factor while also facilitating creative coding through concise and accessible documentation and functionality.
View
@@ -1,4 +1,4 @@
-(def default-background-color [39 49 34])
+ (def default-background-color [39 49 34])
(def default-editor-prefs
{:buffer-theme "sublime.xml" ;; load RSyntaxTextArea from xml theme file
@@ -22,7 +22,7 @@
:tab-lines-enabled true
:tab-lines-color [100 100 100 100]
:templates-enabled true
- :close-curly-braces true})
+ :close-curly-braces true})
(def default-repl-prefs
{:buffer-theme "sublime.xml" ;; load RSyntaxTextArea from xml theme file
View
@@ -7,7 +7,7 @@
<RSyntaxTheme version="1.0">
<!-- Specify family="..." attribute to override system default monospaced. -->
- <baseFont size="13"/>
+ <baseFont size="12"/>
<!-- General editor colors. -->
<background color="272822"/>
@@ -34,35 +34,35 @@
<!-- Syntax tokens. -->
<tokenStyles>
- <style token="IDENTIFIER" fg="FFFFFF"/>
- <style token="RESERVED_WORD" fg="F12772" bold="true"/>
- <style token="RESERVED_WORD_2" fg="FFFFFF" bold="true"/>
+ <style token="IDENTIFIER" fg="E0E2E4"/>
+ <style token="RESERVED_WORD" fg="66D9EF" bold="false" italic="true"/>
+ <style token="RESERVED_WORD_2" fg="FFFFFF" bold="false"/>
<style token="ANNOTATION" fg="E8E2B7"/>
<style token="COMMENT_DOCUMENTATION" fg="716F59"/>
<style token="COMMENT_EOL" fg="716F59"/>
<style token="COMMENT_MULTILINE" fg="716F59"/>
<style token="COMMENT_KEYWORD" fg="716F59"/>
<style token="COMMENT_MARKUP" fg="716F59"/>
- <style token="FUNCTION" fg="66D9EF" bold="true"/>
+ <style token="FUNCTION" fg="66D9E7" italic="true"/>
<style token="DATA_TYPE" fg="678CB1" bold="true"/>
<style token="LITERAL_BOOLEAN" fg="93C763" bold="true"/>
- <style token="LITERAL_NUMBER_DECIMAL_INT" fg="AD73D9" bold="true"/>
- <style token="LITERAL_NUMBER_FLOAT" fg="AD73D9" bold="true"/>
- <style token="LITERAL_NUMBER_HEXADECIMAL" fg="AD73D9" bold="true"/>
- <style token="LITERAL_STRING_DOUBLE_QUOTE" fg="DADB75"/>
- <style token="LITERAL_CHAR" fg="A581FF" bold="true"/>
- <style token="LITERAL_BACKQUOTE" fg="FFF45E" bold="true"/>
+ <style token="LITERAL_NUMBER_DECIMAL_INT" fg="AD73D9"/>
+ <style token="LITERAL_NUMBER_FLOAT" fg="AD73D9"/>
+ <style token="LITERAL_NUMBER_HEXADECIMAL" fg="AD73D9"/>
+ <style token="LITERAL_STRING_DOUBLE_QUOTE" fg="FFF45E"/>
+ <style token="LITERAL_CHAR" fg="A581FF"/>
+ <style token="LITERAL_BACKQUOTE" fg="FFF45E"/>
<style token="MARKUP_TAG_DELIMITER" fg="678CB1"/>
<style token="MARKUP_TAG_NAME" fg="ABBFD3"/>
<style token="MARKUP_TAG_ATTRIBUTE" fg="B3B689"/>
<style token="MARKUP_TAG_ATTRIBUTE_VALUE" fg="e1e2cf"/>
<style token="MARKUP_PROCESSING_INSTRUCTION" fg="A082BD"/>
<style token="MARKUP_CDATA" fg="ae9fbf"/>
- <style token="OPERATOR" fg="EB2828" bold="true"/>
+ <style token="OPERATOR" fg="EB2828"/>
<style token="PREPROCESSOR" fg="F92772"/>
- <style token="REGEX" fg="d39745" bold="true"/>
- <style token="SEPARATOR" fg="E8E2B7" bold="true"/>
- <style token="VARIABLE" fg="D8A20"/>
+ <style token="REGEX" fg="d39745"/>
+ <style token="SEPARATOR" fg="E8E2B7"/>
+ <style token="VARIABLE" fg="D8A20" bold="false"/>
<style token="WHITESPACE" fg="E0E2E4"/>
<style token="ERROR_IDENTIFIER" fg="E0E2E4" bg="2E2E2C"/>
@@ -28,7 +28,7 @@
(defn install-auto-completion
[rta]
- (template/install-templates default-auto-completion)
+; (template/install-templates default-auto-completion)
(config/apply-auto-completion-prefs! default-auto-completion)
(.install default-auto-completion rta))
@@ -6,4 +6,6 @@
(defn install-templates
[ac]
- (.addCompletion (.getCompletionProvider ac) (TemplateCompletion. (.getCompletionProvider ac) "sr" "(search-replace \"${search}\" \"${replace}\"")))
+ (.addCompletion (.getCompletionProvider ac) (TemplateCompletion. (.getCompletionProvider ac) "sr" "(search-replace \"${search}\" \"${replace}\"")))
+
+
@@ -356,7 +356,7 @@
(string/trim (last (string/split text #"=>")))))
(defn buffer-cursor-pos
-([] (buffer-cursor-pos ))
+([] (buffer-cursor-pos (tab/current-text-area)))
([rta]
(let [rta-doc (.getDocument rta)
root (.getDefaultRootElement rta-doc)
@@ -24,3 +24,4 @@
(file/save-file! buffer file)
(tree.utils/update-tree)
(update-info-title (tab/title))))
+
@@ -14,14 +14,11 @@
:class [:editor-comp :syntax-editor])
doc-scroll-pane (sp/scroll-pane text-area)
doc-scroller-container (vertical-panel :border nil
- :items [doc-scroll-pane] :class :rsta-scroller
- :background (color 255 0 0))
+ :items [doc-scroll-pane] :class :rsta-scroller)
doc-scroller-gutter (.getGutter doc-scroll-pane)
doc-vertical-container (vertical-panel :border nil
- :background (color 255 0 0)
:items [doc-scroller-container] :class :container)
doc-horizontal-container (horizontal-panel :border nil
- :background (color 255 0 0)
:items [doc-vertical-container])]
(wrapper.rsyntaxtextarea/set-input-map! text-area (input.default/default-input-map))
@@ -14,20 +14,12 @@
(.put laf (str "TabbedPane." k) v))
(defn tab-change-handler [buffer-tabbed-panel]
-
- ; (listen buffer-tabbed-panel :selection
- ; (fn [e]
- ; (let [buffer (tab/current-buffer)]
- ; (if-let[buffer-project (sketchpad.project/project-by-name (:project buffer))]
- ; (reset! (:last-active-buffer buffer-project) buffer)))))
-
- (listen buffer-tabbed-panel :selection editor.info-utils/update-doc-title-label!)
- (listen buffer-tabbed-panel :selection editor.info-utils/update-doc-position-label!))
+ (listen buffer-tabbed-panel :selection editor.info-utils/update-doc-title-label!)
+ (listen buffer-tabbed-panel :selection editor.info-utils/update-doc-position-label!))
(defn buffer-tabbed-panel []
(let [buffer-tabbed-panel (tabbed-panel :placement :top
:overflow :wrap
- :background (color :black)
:border (empty-border :thickness 0))]
(.setUI buffer-tabbed-panel (editor.ui/sketchpad-tab-ui buffer-tabbed-panel))
(swap! state/app assoc :buffer-tabbed-panel buffer-tabbed-panel)
@@ -28,14 +28,17 @@
(defn update-doc-title-label!
"Update the currently displayed doc title in the info panel"
-[e]
- (if (tab/tabs?)
- (invoke-later
- (config! (:doc-title-label @state/app) :text (tab/title))
- (when @(:file (tab/current-buffer))
- (tree.utils/set-tree-selection (.getAbsolutePath @(:file (tab/current-buffer))))))
- (invoke-later
- (config! (:doc-title-label @state/app) :text ""))))
+ [e]
+ (invoke-later
+ (if (tab/tabs?)
+ (do
+ (let [doc-title (:doc-title-label @state/app)
+ file @(:file (tab/current-buffer))]
+ (config! doc-title :text (tab/title))
+ (when file
+ (tree.utils/set-tree-selection (.getAbsolutePath file)))))
+ (do
+ (config! (:doc-title-label @state/app) :text "")))))
(defn attach-caret-handler [text-area]
(listen text-area :caret-update update-doc-position-label!))
@@ -16,15 +16,16 @@
(defn text-area-from-index [tabbed-panel i]
(select (.getComponentAt tabbed-panel i) [:#editor]))
-(def button-base-color (color 150 150 150))
-
(defn paint-tab-button [buffer c g]
(let [clean? (@(:state buffer) :clean)
w (width c)
h (height c)
+ button-base-color (color 255 255 255)
line-style (style :foreground button-base-color :stroke 2 :cap :round)
project-color (project/buffer-color buffer)
- border-style (style :foreground @project-color :stroke 0.5)
+ border-style (if project-color
+ (style :foreground @project-color :stroke 0.5)
+ (style :foreground (color 255 255 255) :stroke 0.5))
ellipse-style (style :foreground button-base-color :background button-base-color :stroke 1 :cap :round)
d 3
lp 7]
@@ -8,7 +8,7 @@
(clojure.lang RT Reflector)
(java.io File))
(:use [seesaw.core :only (select)]
- [clooj.brackets]
+ [sketchpad.util.brackets]
[clj-inspector.jars :only (clj-sources-from-jar jar-files)]
[clj-inspector.vars :only (analyze-clojure-source
parse-ns-form)]
@@ -96,8 +96,6 @@
(defn find-form-string [text pos]
(let [[left right] (find-enclosing-brackets text pos)]
- (println left right)
- (println (.substring text left right))
(when (> (.length text) left)
(.substring text (inc left)))))
@@ -20,11 +20,14 @@
(defn new-file
"Create a new file"
([]
- (new-file nil))
+ (new-file nil))
([selection-path]
(if-let [current-project-path (first (tree.utils/get-selected-projects))]
(seesaw.core/invoke-later
(editor.buffer/new-project-buffer! current-project-path selection-path)
+ (tree.utils/update-tree))
+ (seesaw.core/invoke-later
+ (editor.buffer/new-project-buffer! "tmp" selection-path)
(tree.utils/update-tree)))))
(defn save
@@ -5,6 +5,9 @@
[sketchpad.buffer.action :as buffer.action]
[sketchpad.repl.print :as sketchpad.repl.print]
[sketchpad.util.tab :as tab]
+ [sketchpad.repl.project-repl :as project-repl]
+ [sketchpad.help.help :as help]
+ [sketchpad.tree.utils :as tree.utils]
[sketchpad.buffer.spell-check :as spell-check]
[sketchpad.config.layout :as layout]
[sketchpad.state.state :as state]))
@@ -82,6 +85,33 @@
(when (tab/tabs?)
(buffer.action/decrease-font)))
+(defn send-selected-or-form-to-repl
+"Send the currently selected text to the last focused REPL for the project associated with the current buffer."
+ []
+ (println "send selected/form to PROJCET REPL")
+ (seesaw/invoke-later
+ (let [project (get @(:projects @state/app) (first (tree.utils/get-selected-projects)))
+ repl (:last-focused-repl project)]
+ (when-not (nil? repl)
+ (let [text-area (tab/current-text-area)
+ text (.getSelectedText text-area)
+ cmd (if (> (count text) 0)
+ text
+ (help/find-form-string
+ (seesaw/config text-area :text)
+ (buffer.action/buffer-cursor-pos)))]
+ (project-repl/send-repl-cmd repl cmd))))))
+
+(defn send-file-to-repl
+"Send the current buffer to it's associated project REPL."
+ []
+ (let [project (first (tree.utils/get-selected-projects))
+ repl (:last-focused-repl project)]
+ (when-not (nil? repl)
+ (seesaw/invoke-later
+ (let [text (seesaw/config (tab/current-text-area) :text)]
+ (project-repl/send-repl-cmd repl text))))))
+
(defn make-source-menu-items []
{:search (seesaw.core/menu-item :text "Search..."
:mnemonic "F"
@@ -119,7 +149,14 @@
:mnemonic "-"
:key (keystroke/keystroke "meta MINUS")
:listen [:action (fn [_] (decrease-font-size))])
- })
+ :send-selected-or-form (seesaw.core/menu-item :text "Send command to REPL..."
+ :mnemonic "R"
+ :key (keystroke/keystroke "meta R")
+ :listen [:action (fn [_] (send-selected-or-form-to-repl))])
+ :send-file-to-repl (seesaw.core/menu-item :text "Send file to REPL..."
+ :mnemonic "R"
+ :key (keystroke/keystroke "meta shift R")
+ :listen [:action (fn [_] (send-file-to-repl))])})
(defn make-source-menu
[]
@@ -131,6 +168,9 @@
(menu-items :search-replace)
(menu-items :search-replace-all)
(seesaw.core/separator)
+ (menu-items :send-selected-or-form)
+ (menu-items :send-file-to-repl)
+ (seesaw.core/separator)
(menu-items :grep)
(seesaw.core/separator)
(menu-items :toggle-comment)
Oops, something went wrong.

0 comments on commit e307f70

Please sign in to comment.