Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.textmate.org/trunk/Review/Bundles/R Console (R_app).tmbundle@9103 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
- Loading branch information
0 parents
commit 16fda51
Showing
13 changed files
with
562 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
<plist version="1.0"> | |||
<dict> | |||
<key>beforeRunningCommand</key> | |||
<string>nop</string> | |||
<key>command</key> | |||
<string>ruby -e ' | |||
require ENV["TM_BUNDLE_SUPPORT"] + "/lib/historyList.rb" | |||
print HistoryList.new(STDIN.read + "\n> ").list.join("\n") | |||
' | pbcopy | |||
echo "Commands from selection/document placed into pasteboard"</string> | |||
<key>fallbackInput</key> | |||
<string>document</string> | |||
<key>input</key> | |||
<string>selection</string> | |||
<key>keyEquivalent</key> | |||
<string>@C</string> | |||
<key>name</key> | |||
<string>Copy Commands into Clipboard</string> | |||
<key>output</key> | |||
<string>showAsTooltip</string> | |||
<key>scope</key> | |||
<string>source.rapp-console</string> | |||
<key>uuid</key> | |||
<string>48E1CB3A-8349-46E4-86B0-671663712005</string> | |||
</dict> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,75 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
<plist version="1.0"> | |||
<dict> | |||
<key>beforeRunningCommand</key> | |||
<string>nop</string> | |||
<key>command</key> | |||
<string>. "$TM_SUPPORT_PATH/lib/webpreview.sh" | |||
html_header "R Console (R.app) Bundle Help" "R" | |||
"$TM_SUPPORT_PATH/lib/markdown_to_help.rb" <<'MARKDOWN' | |||
# Introduction | |||
The "R Console (R.app)" bundle provides some commands to remote the Mac OSX GUI R.app using AppleScript. | |||
# Commands | |||
- __Send Selection / Document to R.app__ | |||
Executes the current document or selection in R.app and switches to R.app's Console. | |||
- __Show Line Output as Tool Tip__ | |||
Executes the current line or selection in R.app and shows only the result as tooltip. | |||
- __Execute Line / Selection__ | |||
Executes the current line or selection in R.app and inserts the result into the current document. | |||
- __Copy Commands into Clipboard__ | |||
Parses the current document or selection for lines beginning with "> " and pastes all found commands into the clipboard. | |||
- __Show History List__ | |||
Shows as inline menu all commands entered in the current document. | |||
- __Next/Previous History Item__ | |||
Inserts the next/previous command found in the current document. | |||
***Notes*** | |||
<blockquote> | |||
All commands specified within the "R" bundle can be used. | |||
</blockquote> | |||
<blockquote> | |||
If the "Rdaemon" also runs in the background and the library "CarbonEL" is loaded the communication between TextMate and R.app wont't work. | |||
</blockquote> | |||
# Main Bundle Maintainer | |||
***Date: Jan 09 2008*** | |||
<pre> | |||
- Charilaos Skiadas&nbsp;<a href="mailto:cskiadas@gmail.com">cskiadas@gmail.com</a> | |||
- Hans-Jörg Bibiko&nbsp;&nbsp;<a href="mailto:bibiko@eva.mpg.de">bibiko@eva.mpg.de</a> | |||
</pre> | |||
MARKDOWN | |||
html_footer</string> | |||
<key>input</key> | |||
<string>none</string> | |||
<key>keyEquivalent</key> | |||
<string></string> | |||
<key>name</key> | |||
<string>Help</string> | |||
<key>output</key> | |||
<string>showAsHTML</string> | |||
<key>scope</key> | |||
<string>source.rapp-console</string> | |||
<key>uuid</key> | |||
<string>CAEB703B-1D79-4D3A-90BB-2A2C2BD846F7</string> | |||
</dict> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
<plist version="1.0"> | |||
<dict> | |||
<key>beforeRunningCommand</key> | |||
<string>nop</string> | |||
<key>command</key> | |||
<string>#!/usr/bin/ruby | |||
require ENV['TM_BUNDLE_SUPPORT'] + "/lib/historyList.rb" | |||
require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" | |||
require ENV['TM_SUPPORT_PATH'] + "/lib/escape.rb" | |||
doc = STDIN.read | |||
new_doc = HistoryList.move_down(doc) | |||
TextMate.exit_discard if new_doc == doc | |||
print e_sn(new_doc)</string> | |||
<key>fallbackInput</key> | |||
<string>document</string> | |||
<key>input</key> | |||
<string>selection</string> | |||
<key>keyEquivalent</key> | |||
<string></string> | |||
<key>name</key> | |||
<string>Next History Item</string> | |||
<key>output</key> | |||
<string>insertAsSnippet</string> | |||
<key>scope</key> | |||
<string>source.rapp-console</string> | |||
<key>uuid</key> | |||
<string>C1302FC5-FDC8-4560-8DFF-2CEC85EFCD19</string> | |||
</dict> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
<plist version="1.0"> | |||
<dict> | |||
<key>beforeRunningCommand</key> | |||
<string>nop</string> | |||
<key>command</key> | |||
<string>#!/usr/bin/ruby | |||
require ENV['TM_BUNDLE_SUPPORT'] + "/lib/historyList.rb" | |||
require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" | |||
require ENV['TM_SUPPORT_PATH'] + "/lib/escape.rb" | |||
doc = STDIN.read | |||
new_doc = HistoryList.move_up(doc) | |||
TextMate.exit_discard if new_doc == doc | |||
print e_sn(new_doc)</string> | |||
<key>fallbackInput</key> | |||
<string>document</string> | |||
<key>input</key> | |||
<string>selection</string> | |||
<key>keyEquivalent</key> | |||
<string></string> | |||
<key>name</key> | |||
<string>Previous History Item</string> | |||
<key>output</key> | |||
<string>insertAsSnippet</string> | |||
<key>scope</key> | |||
<string>source.rapp-console</string> | |||
<key>uuid</key> | |||
<string>2CE460A3-ADAE-47B6-8A89-EE142C714CC2</string> | |||
</dict> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
<plist version="1.0"> | |||
<dict> | |||
<key>beforeRunningCommand</key> | |||
<string>nop</string> | |||
<key>command</key> | |||
<string># input is selection or document | |||
rawText="`cat`" | |||
curDir='' | |||
if [[ ${#TM_DIRECTORY} -gt 0 ]]; then | |||
curDir="$TM_DIRECTORY" | |||
fi | |||
osascript -e 'on run(theCode)' \ | |||
-e 'tell application "R" to activate' \ | |||
-e 'if (item 2 of theCode) is not "" then tell application "R" to cmd "setwd('\''" & (item 2 of theCode) & "'\'')"' \ | |||
-e 'tell application "R" to cmd (item 1 of theCode)' \ | |||
-e 'end run' -- "$rawText" "$curDir" | |||
</string> | |||
<key>input</key> | |||
<string>selection</string> | |||
<key>keyEquivalent</key> | |||
<string>@R</string> | |||
<key>name</key> | |||
<string>Send Selection / Document to R.app</string> | |||
<key>output</key> | |||
<string>showAsTooltip</string> | |||
<key>scope</key> | |||
<string>source.rapp-console</string> | |||
<key>uuid</key> | |||
<string>B2E62E8B-6E70-11D9-A369-000D93B3A10E</string> | |||
</dict> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,33 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
<plist version="1.0"> | |||
<dict> | |||
<key>beforeRunningCommand</key> | |||
<string>nop</string> | |||
<key>command</key> | |||
<string>#!/usr/bin/ruby | |||
require ENV['TM_BUNDLE_SUPPORT'] + "/lib/historyList.rb" | |||
require ENV['TM_SUPPORT_PATH'] + "/lib/ui.rb" | |||
require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes.rb" | |||
require ENV['TM_SUPPORT_PATH'] + "/lib/escape.rb" | |||
doc = STDIN.read | |||
list = HistoryList.new(doc) | |||
choice = TextMate::UI.menu(list.list) | |||
TextMate.exit_discard if choice.nil? | |||
print e_sn(list.add_line(list.list[choice]))</string> | |||
<key>fallbackInput</key> | |||
<string>document</string> | |||
<key>input</key> | |||
<string>selection</string> | |||
<key>keyEquivalent</key> | |||
<string>^~</string> | |||
<key>name</key> | |||
<string>Show History List</string> | |||
<key>output</key> | |||
<string>insertAsSnippet</string> | |||
<key>scope</key> | |||
<string>source.rapp-console</string> | |||
<key>uuid</key> | |||
<string>613CDD87-1F8B-484E-B741-74B95F3C878B</string> | |||
</dict> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||
<plist version="1.0"> | |||
<dict> | |||
<key>beforeRunningCommand</key> | |||
<string>nop</string> | |||
<key>command</key> | |||
<string>echo | |||
#test=`tail -c+2` | |||
test=$(cat) | |||
osascript <<-APPLESCRIPT | tail -n +2 | perl -pe 'BEGIN {$/=undef} s/> $//;s/\n\z//' | |||
tell application "System Events" | |||
-- Get a reference to the text field | |||
set text_area to (process "R")'s (window "R Console")'s (scroll area 1)'s text area 1 | |||
-- Get text before and after our command | |||
set oldtext to text_area's value | |||
tell application "R" to cmd "${test//\"/\"}" | |||
set newtext to text_area's value | |||
-- Find the difference between old and new | |||
text from (oldtext's length + 1) to -1 of newtext | |||
end tell | |||
APPLESCRIPT</string> | |||
<key>fallbackInput</key> | |||
<string>line</string> | |||
<key>input</key> | |||
<string>selection</string> | |||
<key>keyEquivalent</key> | |||
<string>@T</string> | |||
<key>name</key> | |||
<string>Show Line Output as Tool Tip</string> | |||
<key>output</key> | |||
<string>showAsTooltip</string> | |||
<key>scope</key> | |||
<string>source.rapp-console</string> | |||
<key>uuid</key> | |||
<string>1A8EC6F7-D254-4888-9095-75C9DBA519F7</string> | |||
</dict> | |||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,47 @@ | |||
def extract_command(string) | |||
return "" if string.nil? | |||
return string.gsub(/^>\s*|\s*\z/,"") | |||
end | |||
class HistoryList | |||
attr_reader :list, :last_line, :text | |||
def initialize(text) | |||
@text = text.split("\n") | |||
@last_line = @text.pop | |||
@list = @text.grep(/^>(.*)$/).map{|m| extract_command(m)}.grep(/./) | |||
@list = @list.reverse.uniq.reverse | |||
end | |||
def next_item(command) | |||
cmd = extract_command(command) | |||
return @list[0] if cmd.empty? | |||
if i=@list.index(cmd) and i<=@list.length then | |||
return @list[i+1] | |||
end | |||
return nil | |||
end | |||
def previous_item(command) | |||
cmd = extract_command(command) | |||
return @list.last if cmd.empty? | |||
if i=@list.index(cmd) and i>=1 then | |||
return @list[i-1] | |||
end | |||
return nil | |||
end | |||
def text | |||
@text.join("\n") + "\n" | |||
end | |||
def add_line(line) | |||
self.text + "> #{extract_command(line)}" | |||
end | |||
def move_up | |||
add_line(previous_item(@last_line)) | |||
end | |||
def move_down | |||
add_line(next_item(@last_line)) | |||
end | |||
def self.move_up(text) | |||
self.new(text).move_up | |||
end | |||
def self.move_down(text) | |||
self.new(text).move_down | |||
end | |||
end |
Oops, something went wrong.