lib/textbringer/mode.rb in textbringer-0.1.7 vs lib/textbringer/mode.rb in textbringer-0.1.8
- old
+ new
@@ -15,10 +15,11 @@
attr_accessor :mode_name
attr_accessor :command_name
attr_accessor :hook_name
attr_accessor :file_name_pattern
attr_accessor :interpreter_name_pattern
+ attr_reader :syntax_table
end
def self.define_generic_command(name)
command_name = (name.to_s + "_command").intern
define_command(command_name) do |*args|
@@ -33,10 +34,14 @@
end
end
end
end
+ def self.define_syntax(face_name, re)
+ @syntax_table[face_name] = re
+ end
+
def self.inherited(child)
base_name = child.name.slice(/[^:]*\z/)
child.mode_name = base_name.sub(/Mode\z/, "")
command_name = base_name.sub(/\A[A-Z]/) { |s| s.downcase }.
gsub(/(?<=[a-z])([A-Z])/) {
@@ -48,18 +53,23 @@
child.hook_name = hook
define_command(command) do
Buffer.current.apply_mode(child)
end
@@mode_list.push(child)
+ child.instance_variable_set(:@syntax_table, {})
end
attr_reader :buffer
def initialize(buffer)
@buffer = buffer
end
def name
self.class.mode_name
+ end
+
+ def syntax_table
+ self.class.syntax_table
end
end
end