[TabWidth] = { "tide.input.tab_width", INTEGER, { .num = 4 } },
[ScrollLines] = { "tide.input.scroll_lines", INTEGER, { .num = 4 } },
[DblClickTime] = { "tide.input.click_time", INTEGER, { .num = 500 } },
- [MaxScanDist] = { "tide.input.max_scan_dist", INTEGER, { .num = 8192 } },
+ [MaxScanDist] = { "tide.input.max_scan_dist", INTEGER, { .num = 0 } },
/* default color palette definition */
[Color00] = { "tide.palette.00", INTEGER, { .num = 0xff002b36 } },
#!/usr/bin/env ruby
if not ARGV[0] then
- $stderr.puts "Usage: tide-hl [LANG]"
+ $stderr.puts "Usage: tide-hl [FILE]"
exit 1
end
Special: (16 << 4),
}
+$language = nil
$buf = StringIO.new
$scan = StringScanner.new("")
Rules = []
-def rule(regex, &block)
- Rules << [regex, block]
+def languages(langmap)
+ file = ARGV[0]
+ ext = File.extname(file).downcase
+ langmap.each do |k,v|
+ if (v.member?(ext) || v.member?(file))
+ return ($language = k)
+ end
+ end
end
-def match(regex, style)
- Rules << [regex, style]
+def language(name, &block)
+ if $language == name
+ block.call()
+ end
end
def style_range(spos, epos, style)
style_range($scan.pos - $scan.matched_size, $scan.pos, s)
end
+def rule(regex, &block)
+ Rules << [regex, block]
+end
+
def range(start=nil, stop=nil, color=nil)
rule start do
beg = $scan.pos - $scan.matched_size
end
end
-def language(name, &block)
- block.call()
+def match(regex, style)
+ Rules << [regex, style]
+end
+
+def match_sets(regex, setmap)
+ rule regex do |m|
+ setmap.each do |k,v|
+ if v.member?(m)
+ style_match(k)
+ break;
+ end
+ end
+ end
end
#-------------------------------------------------------------------------------
+languages({
+ "Ruby" => Set.new(%w[Rakefile Rakefile.rb .rb]),
+ "C" => Set.new(%w[.c .h .cpp .hpp .cc .c++ .cxx]),
+})
+
language "C" do
- Types = Set.new %w[
+ types = Set.new %w[
bool short int long unsigned signed char size_t
void extern static inline struct typedef union
int8_t int16_t int32_t int64_t uint8_t uint16_t uint32_t uint64_t
]
- Control = Set.new %w[
+ keywords = Set.new %w[
goto break return continue asm case default if else switch while for do
]
+ constants = Set.new %w[
+ NULL true false
+ ]
+
range start=/\/\*/, stop=/\*\//, :Comment
- match(/\/\/.*$/, :Comment)
- match(/#\s*\w+/, :PreProcessor)
- match(/"(\\"|[^"\n])*"/, :String)
- match(/'(\\.|[^'\n\\])'/, :Char)
-
- # Highlight identifiers
- rule /[a-zA-Z_][0-9a-zA-Z_]*/ do |match|
- if Types.member? match
- style_match(:Type)
- elsif Control.member? match
- style_match(:Keyword)
- end
- end
- match(/[+-]?[0-9]+[ulUL]*/, :Number)
+ match /\/\/.*$/, :Comment
+ match /#\s*\w+/, :PreProcessor
+ match /"(\\"|[^"\n])*"/, :String
+ match /'(\\.|[^'\n\\])'/, :Char
+
+ match_sets /[a-zA-Z_][0-9a-zA-Z_]*/,
+ :Type => types, :Keyword => keywords, :Constant => constants
+
+ match /0x[0-9a-fA-F]+[ulUL]*/, :Number
+ match /[0-9]+[ulUL]*/, :Number
+end
+
+language "Ruby" do
+ match /#.*$/, :Comment
end
#-------------------------------------------------------------------------------