Permalink
Browse files

• merge back WIP branch

git-svn-id: http://svn.textmate.org/trunk/Bundles/TODO.tmbundle@7699 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent c4bd063 commit dddd37d16fb5e16e80b447f3629ff36d41c770fe @sorbits sorbits committed Jul 7, 2007
View
@@ -7,17 +7,19 @@
<key>bundleUUID</key>
<string>0B296803-7D51-11D9-859D-000D93B6E43C</string>
<key>command</key>
- <string>. "$TM_SUPPORT_PATH/lib/webpreview.sh"
+ <string>#!/usr/bin/env bash
+
+. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "TODO Bundle Help" "TODO"
-"$TM_SUPPORT_PATH/lib/markdown_to_help.rb" &lt;&lt;'EOF'
+"$TM_SUPPORT_PATH/lib/markdown_to_help.rb" &lt;&lt;'MARKDOWN'
# Introduction
The "Show TODO List" command will scan your current document (on disk) or documents in your project for lines containing certain tags (see below).
You will be presented with a row of “Tabs” that are counting matches while the search is going on. Once the search finishes a list for each of the tags and their context is shown. Each entry can be clicked to jump to that line in that file. The lists can be ordered by clicking on their column titles. Clicking on the Tabs will jump to the corresponding list.
-TextMate will ignore files whose full path matches the enviromental variable `TM_TODO_IGNORE`.
+TextMate will ignore files whose full path matches the environment variable `TM_TODO_IGNORE`.
Note: This command requires Ruby 1.8
@@ -30,25 +32,15 @@ Preconfigured tags are:
* &lt;span style="color: #008000;"&gt;CHANGED&lt;/span&gt;
* &lt;span style="color: #0090C8;"&gt;RADAR (as &amp;lt;radar://…&amp;gt; or &amp;lt;rdar://…&amp;gt;)&lt;/span&gt;
-Those tags consist of a label (like "TODO"), a color in which they will be printed and a regular expression to transform them. They can be adapted via the Preferences item in the Bundle. Rearranging the entries will rearrange them in the output, too.
-
-## Tag setup
-
-The shell variable `TM_TODO_MARKERS` has to be defined to make the TODO list work. It holds a comma separated list of markers. The default is: `FIXME, TODO, CHANGED, RADAR`.
-
-The regular expressions for those tags have to be set up as well. This can be done by specifying variables like `TM_TODO_FIXME_REGEXP` for the `FIXME` marker or `TM_TODO_TODO_COLOR` for the `TODO` marker. You should recognize the pattern here. An example for the default `FIXME` regexp is `/FIX ?ME[\s,:]+(\S.*)$/i`.
-
-Furthermore you may specify colors for each marker type. Analog to the regexps those variables are named `TM_TODO_CHANGED_COLOR` or `TM_TODO_FIXED_COLOR` and hold an HTML hexadecimal color value like `#FFD040`. If the color variable for a marker is not set the color will default to grey.
-
-Optionally you can set up a shell variable `TM_TODO_MARKERS_TRIM` which specifies the markers that are only shown when found. The default here is: `RADAR`. So if scanning your project or file did not find any `RADAR` items the section is not displayed at all.
+Those tags can easily be set up via the &lt;span onClick="TextMate.system(&amp;apos;&amp;quot;${TM_RUBY:-ruby}&amp;quot; &amp;quot;$TM_BUNDLE_SUPPORT/lib/settings.rb&amp;quot; &amp;amp;&amp;gt;/dev/null &amp;amp;&amp;apos;, null)"&gt;“Preferences”&lt;/a&gt; command.
# Hints
* The list can be printed using _Print…_ (⌘P) from the _File_ menu.
* The Command will abort when the project directory resolves to the root folder.
* Access keys: `⌃` + first letter of the tag (like `⌃T` for “TODO”) will jump to the respective section.
-EOF
+MARKDOWN
html_footer
</string>
@@ -0,0 +1,27 @@
+<?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/env ruby -wKU
+
+STDOUT.reopen('/dev/console', 'w')
+STDERR.reopen('/dev/console', 'w')
+
+require ENV['TM_BUNDLE_SUPPORT'] + '/lib/settings.rb'
+
+pid = Process.fork { Settings.show_ui }
+Process.detach(pid)
+</string>
+ <key>input</key>
+ <string>none</string>
+ <key>name</key>
+ <string>Preferences</string>
+ <key>output</key>
+ <string>discard</string>
+ <key>uuid</key>
+ <string>65C4098C-BB16-4CA1-9297-B312BCD0433F</string>
+</dict>
+</plist>
@@ -1,76 +0,0 @@
-<?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>name</key>
- <string>TODO Markers</string>
- <key>settings</key>
- <dict>
- <key>shellVariables</key>
- <array>
- <dict>
- <key>name</key>
- <string>TM_TODO_MARKERS</string>
- <key>value</key>
- <string>FIXME, TODO, CHANGED, RADAR</string>
- </dict>
- <dict>
- <key>name</key>
- <string>TM_TODO_MARKERS_TRIM</string>
- <key>value</key>
- <string>RADAR</string>
- </dict>
- <dict>
- <key>name</key>
- <string>TM_TODO_FIXME_COLOR</string>
- <key>value</key>
- <string>#A00000</string>
- </dict>
- <dict>
- <key>name</key>
- <string>TM_TODO_FIXME_REGEXP</string>
- <key>value</key>
- <string>/FIX ?ME[\s,:]+(\S.*)$/i</string>
- </dict>
- <dict>
- <key>name</key>
- <string>TM_TODO_TODO_COLOR</string>
- <key>value</key>
- <string>#CF830D</string>
- </dict>
- <dict>
- <key>name</key>
- <string>TM_TODO_TODO_REGEXP</string>
- <key>value</key>
- <string>/TODO[\s,:]+(\S.*)$/i</string>
- </dict>
- <dict>
- <key>name</key>
- <string>TM_TODO_CHANGED_COLOR</string>
- <key>value</key>
- <string>#008000</string>
- </dict>
- <dict>
- <key>name</key>
- <string>TM_TODO_CHANGED_REGEXP</string>
- <key>value</key>
- <string>/CHANGED[\s,:]+(\S.*)$/</string>
- </dict>
- <dict>
- <key>name</key>
- <string>TM_TODO_RADAR_COLOR</string>
- <key>value</key>
- <string>#0090C8</string>
- </dict>
- <dict>
- <key>name</key>
- <string>TM_TODO_RADAR_REGEXP</string>
- <key>value</key>
- <string>/(.*&lt;)ra?dar:\/(?:\/problem|)\/([&amp;0-9]+)(&gt;.*)$/</string>
- </dict>
- </array>
- </dict>
- <key>uuid</key>
- <string>E276234D-0D53-429C-B579-D975F4D98224</string>
-</dict>
-</plist>
View
@@ -0,0 +1,89 @@
+require ENV['TM_SUPPORT_PATH'] + '/lib/escape.rb'
+require ENV['TM_SUPPORT_PATH'] + '/lib/osx/plist'
+
+class Marker
+ attr_reader :name, :regexp, :color
+ def initialize(options = { })
+ @name = options['name'] || 'untitled'
+ @color = options['color']
+ @has_color = !options['no_color']
+ @trim = !!options['trim']
+ @disabled = !!options['disabled']
+
+ if options['pattern'] =~ %r{\A/(.*)/([imx]*)\z}
+ transform = {
+ 'i' => Regexp::IGNORECASE,
+ 'x' => Regexp::EXTENDED,
+ 'm' => Regexp::MULTILINE,
+ }
+ ptrn, flags = $1, $2.split(//)
+ f = flags.inject(0) { |flags, letter| flags += transform[letter] if transform.has_key? letter }
+ @regexp = Regexp.new(ptrn, f)
+ else
+ raise "Invalid regular expression: #{options['pattern']}"
+ end
+ end
+
+ def has_color?
+ @has_color
+ end
+
+ def disabled?
+ @disabled
+ end
+
+ def trim?
+ @trim
+ end
+end
+
+class Settings
+ @defaults = [
+ { 'name' => 'FIXME',
+ 'pattern' => '/FIX ?ME[\s,:]+(\S.*)$/i',
+ 'color' => '#A00000',
+ },
+ { 'name' => 'TODO',
+ 'pattern' => '/TODO[\s,:]+(\S.*)$/i',
+ 'color' => '#CF830D',
+ },
+ { 'name' => 'CHANGED',
+ 'pattern' => '/CHANGED[\s,:]+(\S.*)$/',
+ 'color' => '#008000',
+ },
+ { 'name' => 'RADAR',
+ 'pattern' => '/(.*<)ra?dar:\/(?:\/problem|)\/([&0-9]+)(>.*)$/',
+ 'color' => '#0090C8',
+ 'trim' => true,
+ },
+ ]
+
+ def self.markers
+ plist = open(ENV['HOME'] + '/Library/Preferences/com.macromates.textmate.plist') { |io| OSX::PropertyList.load(io) }
+ res = plist['TODO Markers'] || @defaults
+ res.map { |e| Marker.new(e) }.reject { |e| e.disabled? }
+ end
+
+ def self.show_ui
+ defaults = { 'TODO Markers' => @defaults }
+ dynamicClasses = {
+ 'TODO_NewMarker' => {
+ 'name' => 'MY MARKER',
+ 'pattern' => '/marker:/i',
+ 'no_color' => true,
+ }
+ }
+
+ %x{ "$DIALOG" \
+ -d #{e_sh defaults.to_plist} \
+ -n #{e_sh dynamicClasses.to_plist} \
+ -q Preferences
+ }
+ end
+end
+
+if __FILE__ == $PROGRAM_NAME
+ STDOUT.reopen('/dev/console')
+ STDERR.reopen('/dev/console')
+ Process.detach(Process.fork { Settings.show_ui })
+end

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Binary file not shown.
View
@@ -23,37 +23,17 @@
abort
end
-if ENV['TM_TODO_MARKERS'].nil? then
- puts html_head(:window_title => "TODO", :page_title => "TODO List", :sub_title => "Error")
- puts <<-HTML
-<h1>Error</h1>
-<p>Your setup is incomplete. Please invoke the Help for this bundle and look up how to specify TODO markers via a Preferences item.</p>
-HTML
-end
-
+require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/settings.rb"
require "#{ENV['TM_SUPPORT_PATH']}/lib/textmate"
require "erb"
require "yaml"
include ERB::Util
-tag_names = ENV['TM_TODO_MARKERS'].split(",")
-tag_trim = ENV['TM_TODO_MARKERS_TRIM'].nil? ? [] : ENV['TM_TODO_MARKERS_TRIM'].split(",")
-
-trim_tags = []
-tag_trim.each { |name|
- trim_tags << name.strip
-}
-
-tags = []
-tag_names.each { |name|
- name.strip!
- regexp = ENV["TM_TODO_#{name}_REGEXP"]
- next if regexp.nil?
- tags << {
- :label => name,
- :color => (ENV["TM_TODO_#{name}_COLOR"] or '#808080'),
- :regexp => Regexp.new(regexp.sub(/^\/(.*)\/i?$/, '\1'), (regexp =~ /i$/) ? 129 : 128),
- :trim_if_empty => trim_tags.include?(name)
+tags = Settings.markers.map { |marker|
+ { :label => marker.name,
+ :color => marker.has_color? ? marker.color : '#808080',
+ :regexp => marker.regexp,
+ :trim_if_empty => marker.trim?
}
}
ignores = ENV['TM_TODO_IGNORE']
View
@@ -27,6 +27,7 @@
<string>14C1643E-7D51-11D9-859D-000D93B6E43C</string>
<string>D2F7F545-5149-47B9-AC62-DBDC6ACAB9BB</string>
<string>46C3E5A1-7E04-11D9-AE69-000D93B6E43C</string>
+ <string>65C4098C-BB16-4CA1-9297-B312BCD0433F</string>
</array>
<key>uuid</key>
<string>0B296803-7D51-11D9-859D-000D93B6E43C</string>

0 comments on commit dddd37d

Please sign in to comment.