\w+<\/code>/).each do |x|
63 | code = x.match(/>(\w+))[1]
64 | if not codes.include? code
65 | completion_file << " \"#{code}\",\n"
66 | codes << code
67 | end
68 | end
69 |
70 | print "[Notice]: Grabing color tables from NCL website.\n"
71 | page1 = `curl -s #{url_prefix}/Document/Graphics/color_table_gallery.shtml`
72 |
73 | color_tables = []
74 | page1.scan(/^\w+ $/).each do |x|
75 | color_table = x.match(/>(\w+))[1]
76 | if not color_tables.include? color_table
77 | completion_file << " \"#{color_table}\",\n"
78 | color_tables << color_table
79 | end
80 | end
81 |
82 | completion_file.write(" ]\n")
83 | completion_file.write("}\n")
84 |
--------------------------------------------------------------------------------
/create_ncl_syntax.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby -wU
2 |
3 | require 'nokogiri'
4 |
5 | builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
6 | xml.doc.create_internal_subset(
7 | 'plist',
8 | "-//Apple//DTD PLIST 1.0//EN",
9 | "http://www.apple.com/DTDs/PropertyList-1.0.dtd"
10 | )
11 | xml.plist(:version => '1.0') {
12 | xml.dict {
13 | xml.key "fileTypes"
14 | xml.array {
15 | xml.string "ncl"
16 | }
17 | xml.key "name"
18 | xml.string "NCL"
19 | xml.key "scopeName"
20 | xml.string "source.ncl"
21 | xml.key "uuid"
22 | xml.string "43d57527-c0c4-46f3-a175-08a320bc52de"
23 | xml.key "patterns"
24 | xml.array {
25 | xml.dict {
26 | xml.key "name"
27 | xml.string "comment.line.source.ncl"
28 | xml.key "comment"
29 | xml.string "NCL comment"
30 | xml.key "match"
31 | xml.string ";.*$"
32 | }
33 | xml.dict {
34 | xml.key "name"
35 | xml.string "support.type.source.ncl"
36 | xml.key "comment"
37 | xml.string "NCL types"
38 | xml.key "match"
39 | xml.string "\\b(integer|float|double|string|graphic)\\b"
40 | }
41 | xml.dict {
42 | xml.key "name"
43 | xml.string "constant.numeric.source.ncl"
44 | xml.key "comment"
45 | xml.string "NCL numerics"
46 | xml.key "match"
47 | xml.string "\\b(\\+|-)?\\d+(\\.\\d+((d|D|e|E)(\\+|-)?\\d+)?)?\\b"
48 | }
49 | xml.dict {
50 | xml.key "name"
51 | xml.string "keyword.operator.source.ncl"
52 | xml.key "comment"
53 | xml.string "NCL operators"
54 | xml.key "match"
55 | xml.string "\\.(eq|ne|gt|ge|lt|le|not|and|or)\\."
56 | }
57 | xml.dict {
58 | xml.key "name"
59 | xml.string "keyword.control.source.ncl"
60 | xml.key "comment"
61 | xml.string "NCL control keywords"
62 | xml.key "match"
63 | xml.string "\\b(do|end|if|then|else|while|break|continue|return|load|begin|end|procedure|function|local)\\b"
64 | }
65 | xml.dict {
66 | xml.key "name"
67 | xml.string "constant.language.source.ncl"
68 | xml.key "comment"
69 | xml.string "NCL boolean"
70 | xml.key "match"
71 | xml.string "\\b(True|False)\\b"
72 | }
73 | xml.dict {
74 | xml.key "name"
75 | xml.string "string.quoted.double.source.ncl"
76 | xml.key "comment"
77 | xml.string "NCL string"
78 | xml.key "begin"
79 | xml.string "\""
80 | xml.key "end"
81 | xml.string "\""
82 | xml.key "patterns"
83 | xml.array {
84 | xml.dict {
85 | xml.key "name"
86 | xml.string "constant.character.escape.source.ncl"
87 | xml.key "match"
88 | xml.string "\\."
89 | }
90 | xml.dict {
91 | xml.key "name"
92 | xml.string "storage.type.source.ncl"
93 | xml.key "comment"
94 | xml.string "Environment variable"
95 | xml.key "match"
96 | xml.string "\\$\\w+"
97 | }
98 | }
99 | }
100 | xml.dict {
101 | xml.key "name"
102 | xml.string "support.function.source.ncl"
103 | xml.key "comment"
104 | xml.string "NCL intrinsic functions"
105 | print "[Notice]: Grabing functions from NCL webpage.\n"
106 | page = `curl -s http://www.ncl.ucar.edu/Document/Functions/list_alpha.shtml`
107 | categories = ['Functions/Built-in', 'Functions/Contributed',
108 | 'Functions/User_contributed', 'Functions/WRF_arw', 'Graphics/Interfaces']
109 | string = ''
110 | categories.each do |category|
111 | page.scan(/^\s*<\/a>/).each do |x|
129 | res = x.match(/"(\w+)">)[1]
130 | # Also remove the trailing '_*' stuff.
131 | res.gsub!(/_\w+/, '')
132 | if not resources.include? res
133 | string << "#{res}|"
134 | resources << res
135 | end
136 | end
137 | xml.key 'match'
138 | xml.string "\\b(#{string[0..-2]})\\b"
139 | }
140 | }
141 | }
142 | }
143 | end
144 |
145 | File.open('NCL.tmLanguage', 'w') do |file|
146 | file << builder.to_xml
147 | end
148 |
--------------------------------------------------------------------------------
/messages.json:
--------------------------------------------------------------------------------
1 | {
2 | "install": "messages/install.txt",
3 | "1.0.1": "messages/1.0.1.txt",
4 | "1.0.2": "messages/1.0.2.txt",
5 | "1.0.3": "messages/1.0.3.txt",
6 | "1.0.4": "messages/1.0.4.txt",
7 | "1.0.5": "messages/1.0.5.txt",
8 | "1.0.6": "messages/1.0.6.txt",
9 | "1.0.7": "messages/1.0.7.txt",
10 | "1.0.8": "messages/1.0.8.txt",
11 | "1.0.8a": "messages/1.0.8a.txt"
12 | }
13 |
--------------------------------------------------------------------------------
/messages/1.0.1.txt:
--------------------------------------------------------------------------------
1 | Updates:
2 |
3 | - Fix a syntax error for numerics.
4 | - Add completion list.
5 | - Add NCL running short cut (press 'ctrl-b' in Windows/Linux or 'command-b' in Mac).
--------------------------------------------------------------------------------
/messages/1.0.2.txt:
--------------------------------------------------------------------------------
1 | Update:
2 |
3 | - Add comment toggle, you can comment a block of script by pressing 'ctrl-/' in
4 | Windows/Linux and 'command-b' in Mac back and forth.
5 | - Add 'do', 'if', 'ifelse', 'openwks' snippets.
6 | - Add all colormaps into completion list.
7 |
--------------------------------------------------------------------------------
/messages/1.0.3.txt:
--------------------------------------------------------------------------------
1 | Update:
2 |
3 | - Add function completions:
4 |
5 | gsn_open_wks -> wks = gsn_open_wks("pdf", "figure")
6 | gsn_csm_contour_map -> plot = gsn_csm_contour_map(wks, var, res)
7 | gsn_csm_xy -> plot = gsn_csm_xy(wks, x, y, res)
8 | gsn_panel -> gsn_panel(wks, plots, dims, res)
9 | overlay -> overlay(back_plot, front_plot)
10 |
11 | - Add resources completions:
12 |
13 | res_axis_ranges ->
14 | res@trXMinF = 0
15 | res@trXMaxF = 1
16 | res@trYMinF = 0
17 | res@trYMaxF = 1
18 | res@tmXBTickStartF = 0
19 | res@tmXBTickEndF = 1
20 | res@tmYLTickStartF = 0
21 | res@tmYLTickEndF = 1
22 | res_axis_reverse -> res@tr{X or Y}Reverse = True
23 | res_contour_manual_levels ->
24 | res@cnLevelSelectionMode = "ManualLevels"
25 | res@cnMinLevelValF = min_level
26 | res@cnMaxLevelValF = max_level
27 | res@cnLevelSpacingF = level_spacing
28 | res_contour_explicit_levels ->
29 | res@cnLevelSelectionMode = "ExplicitLevels"
30 | res@cnLevels = (/.../)
31 |
32 | Authors:
33 |
34 | - Li Dong
--------------------------------------------------------------------------------
/messages/1.0.4.txt:
--------------------------------------------------------------------------------
1 | Update:
2 |
3 | - Add the auto-completion for all the NCL functions, so you can just type the
4 | function name, and press TAB, the argument list should show up.
5 |
6 | Authors:
7 |
8 | - Li Dong
9 |
--------------------------------------------------------------------------------
/messages/1.0.5.txt:
--------------------------------------------------------------------------------
1 | Update:
2 |
3 | - Update the syntax and completions to NCL 6.2.0.
4 | - The syntax for NCL intrinsic functions and resources are
5 | auto-generated by a Ruby script.
6 |
7 |
8 | Authors:
9 |
10 | - Li Dong
11 |
--------------------------------------------------------------------------------
/messages/1.0.6.txt:
--------------------------------------------------------------------------------
1 | [2014-10-14] Update:
2 |
3 | - Update the syntax and completions to NCL 6.2.1.
4 | - Improve the Ruby scripts to auto-generate NCL syntax and completion files.
5 | - Change the tag rule to date so users can know how new this NCL package is.
6 |
7 | Authors:
8 |
9 | - Li Dong
10 |
--------------------------------------------------------------------------------
/messages/1.0.7.txt:
--------------------------------------------------------------------------------
1 | [2015-04-08] Update:
2 |
3 | - Update the syntax and completions to NCL 6.3.0.
4 |
5 | Authors:
6 |
7 | - Li Dong
8 |
--------------------------------------------------------------------------------
/messages/1.0.8.txt:
--------------------------------------------------------------------------------
1 | [2016-04-05] Update:
2 |
3 | - Update the syntax and completions routinely.
4 |
5 | Authors:
6 |
7 | - Li Dong
8 |
--------------------------------------------------------------------------------
/messages/1.0.8a.txt:
--------------------------------------------------------------------------------
1 | [2017-11-28] Update:
2 |
3 | - Update the syntax and completions to NCL 6.4.0.
4 | - Slightly modified ruby script 'create_ncl_completions.rb' to skip 404 Not Found errors.
5 |
6 | Authors:
7 |
8 | - Li Dong
9 | - Benjamin Ng
10 |
--------------------------------------------------------------------------------
/messages/install.txt:
--------------------------------------------------------------------------------
1 | Introduction:
2 |
3 | This is the NCL configuration for Sublime Text editor.
4 |
5 | Features:
6 |
7 | - Syntax highlighting for NCL following NCL website.
8 | - Completion list for long and hard to remember NCL functions and resources.
9 | - Some useful snippets, e.g. 'load' (try it yourself).
10 | - Running NCL without leaving editor.
11 |
12 | Authors:
13 |
14 | - Li Dong
--------------------------------------------------------------------------------
|