From 3a754133dbc138390503341fd2e9beba3e43aa4b Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Fri, 27 Jan 2012 12:05:17 -0800
Subject: Merged old FileIO
---
imports/codemirror/mode/rpm/spec/index.html | 99 +++++++++++++++++++++++++++++
imports/codemirror/mode/rpm/spec/spec.css | 5 ++
imports/codemirror/mode/rpm/spec/spec.js | 66 +++++++++++++++++++
3 files changed, 170 insertions(+)
create mode 100755 imports/codemirror/mode/rpm/spec/index.html
create mode 100755 imports/codemirror/mode/rpm/spec/spec.css
create mode 100755 imports/codemirror/mode/rpm/spec/spec.js
(limited to 'imports/codemirror/mode/rpm/spec')
diff --git a/imports/codemirror/mode/rpm/spec/index.html b/imports/codemirror/mode/rpm/spec/index.html
new file mode 100755
index 00000000..e3bca152
--- /dev/null
+++ b/imports/codemirror/mode/rpm/spec/index.html
@@ -0,0 +1,99 @@
+
+
+
+ CodeMirror: RPM spec mode
+
+
+
+
+
+
+
+
+ CodeMirror: RPM spec mode
+
+
+
+
+ MIME types defined: text/x-rpm-spec
.
+
+
diff --git a/imports/codemirror/mode/rpm/spec/spec.css b/imports/codemirror/mode/rpm/spec/spec.css
new file mode 100755
index 00000000..d0a5d430
--- /dev/null
+++ b/imports/codemirror/mode/rpm/spec/spec.css
@@ -0,0 +1,5 @@
+.cm-s-default span.cm-preamble {color: #b26818; font-weight: bold;}
+.cm-s-default span.cm-macro {color: #b218b2;}
+.cm-s-default span.cm-section {color: green; font-weight: bold;}
+.cm-s-default span.cm-script {color: red;}
+.cm-s-default span.cm-issue {color: yellow;}
diff --git a/imports/codemirror/mode/rpm/spec/spec.js b/imports/codemirror/mode/rpm/spec/spec.js
new file mode 100755
index 00000000..3b5c08c9
--- /dev/null
+++ b/imports/codemirror/mode/rpm/spec/spec.js
@@ -0,0 +1,66 @@
+// Quick and dirty spec file highlighting
+
+CodeMirror.defineMode("spec", function(config, modeConfig) {
+ var arch = /^(i386|i586|i686|x86_64|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
+
+ var preamble = /^(Name|Version|Release|License|Summary|Url|Group|Source|BuildArch|BuildRequires|BuildRoot|AutoReqProv|Provides|Requires(\(\w+\))?|Obsoletes|Conflicts|Recommends|Source\d*|Patch\d*|ExclusiveArch|NoSource|Supplements):/;
+ var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preun|postun|pre|post|triggerin|triggerun|pretrans|posttrans|verifyscript|check|triggerpostun|triggerprein|trigger)/;
+ var control_flow_complex = /^%(ifnarch|ifarch|if)/; // rpm control flow macros
+ var control_flow_simple = /^%(else|endif)/; // rpm control flow macros
+ var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/; // operators in control flow macros
+
+ return {
+ startState: function () {
+ return {
+ controlFlow: false,
+ macroParameters: false,
+ section: false,
+ };
+ },
+ token: function (stream, state) {
+ var ch = stream.peek();
+ if (ch == "#") { stream.skipToEnd(); return "comment"; }
+
+ if (stream.sol()) {
+ if (stream.match(preamble)) { return "preamble"; }
+ if (stream.match(section)) { return "section"; }
+ }
+
+ if (stream.match(/^\$\w+/)) { return "def"; } // Variables like '$RPM_BUILD_ROOT'
+ if (stream.match(/^\$\{\w+\}/)) { return "def"; } // Variables like '${RPM_BUILD_ROOT}'
+
+ if (stream.match(control_flow_simple)) { return "keyword"; }
+ if (stream.match(control_flow_complex)) {
+ state.controlFlow = true;
+ return "keyword";
+ }
+ if (state.controlFlow) {
+ if (stream.match(operators)) { return "operator"; }
+ if (stream.match(/^(\d+)/)) { return "number"; }
+ if (stream.eol()) { state.controlFlow = false; }
+ }
+
+ if (stream.match(arch)) { return "number"; }
+
+ // Macros like '%make_install' or '%attr(0775,root,root)'
+ if (stream.match(/^%[\w]+/)) {
+ if (stream.match(/^\(/)) { state.macroParameters = true; }
+ return "macro";
+ }
+ if (state.macroParameters) {
+ if (stream.match(/^\d+/)) { return "number";}
+ if (stream.match(/^\)/)) {
+ state.macroParameters = false;
+ return "macro";
+ }
+ }
+ if (stream.match(/^%\{\??[\w \-]+\}/)) { return "macro"; } // Macros like '%{defined fedora}'
+
+ //TODO: Include bash script sub-parser (CodeMirror supports that)
+ stream.next();
+ return null;
+ }
+ };
+});
+
+CodeMirror.defineMIME("text/x-rpm-spec", "spec");
--
cgit v1.2.3