pygments.rb 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +40 -0
- data/README.md +3 -0
- data/lexers +0 -0
- data/lib/pygments/popen.rb +3 -2
- data/lib/pygments/version.rb +1 -1
- data/pygments.rb.gemspec +2 -1
- data/vendor/pygments-main/AUTHORS +20 -1
- data/vendor/pygments-main/CHANGES +55 -3
- data/vendor/pygments-main/LICENSE +1 -1
- data/vendor/pygments-main/MANIFEST.in +1 -1
- data/vendor/pygments-main/Makefile +5 -8
- data/vendor/pygments-main/REVISION +1 -1
- data/vendor/pygments-main/doc/Makefile +153 -0
- data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
- data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
- data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
- data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
- data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
- data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
- data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
- data/vendor/pygments-main/doc/conf.py +249 -0
- data/vendor/pygments-main/doc/docs/api.rst +316 -0
- data/vendor/pygments-main/doc/docs/authors.rst +4 -0
- data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
- data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
- data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
- data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
- data/vendor/pygments-main/doc/docs/index.rst +66 -0
- data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
- data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
- data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
- data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
- data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
- data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
- data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
- data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
- data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
- data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
- data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
- data/vendor/pygments-main/doc/download.rst +41 -0
- data/vendor/pygments-main/doc/faq.rst +143 -0
- data/vendor/pygments-main/doc/index.rst +53 -0
- data/vendor/pygments-main/doc/languages.rst +151 -0
- data/vendor/pygments-main/doc/make.bat +190 -0
- data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
- data/vendor/pygments-main/external/autopygmentize +65 -48
- data/vendor/pygments-main/external/markdown-processor.py +15 -15
- data/vendor/pygments-main/external/moin-parser.py +1 -1
- data/vendor/pygments-main/external/rst-directive.py +2 -3
- data/vendor/pygments-main/ez_setup.py +340 -234
- data/vendor/pygments-main/pygments/__init__.py +4 -4
- data/vendor/pygments-main/pygments/cmdline.py +81 -68
- data/vendor/pygments-main/pygments/console.py +1 -1
- data/vendor/pygments-main/pygments/filter.py +1 -1
- data/vendor/pygments-main/pygments/filters/__init__.py +11 -9
- data/vendor/pygments-main/pygments/formatter.py +3 -3
- data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
- data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +44 -26
- data/vendor/pygments-main/pygments/formatters/img.py +21 -14
- data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
- data/vendor/pygments-main/pygments/formatters/other.py +53 -6
- data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
- data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
- data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
- data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
- data/vendor/pygments-main/pygments/lexer.py +59 -39
- data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
- data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
- data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
- data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
- data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
- data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
- data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
- data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
- data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
- data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
- data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
- data/vendor/pygments-main/pygments/lexers/math.py +438 -70
- data/vendor/pygments-main/pygments/lexers/other.py +885 -171
- data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
- data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
- data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
- data/vendor/pygments-main/pygments/lexers/special.py +7 -8
- data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
- data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
- data/vendor/pygments-main/pygments/lexers/text.py +208 -46
- data/vendor/pygments-main/pygments/lexers/web.py +729 -264
- data/vendor/pygments-main/pygments/modeline.py +1 -1
- data/vendor/pygments-main/pygments/plugin.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +1 -1
- data/vendor/pygments-main/pygments/sphinxext.py +153 -0
- data/vendor/pygments-main/pygments/style.py +3 -2
- data/vendor/pygments-main/pygments/styles/__init__.py +5 -1
- data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
- data/vendor/pygments-main/pygments/styles/borland.py +1 -1
- data/vendor/pygments-main/pygments/styles/bw.py +1 -1
- data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
- data/vendor/pygments-main/pygments/styles/default.py +1 -1
- data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
- data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
- data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
- data/vendor/pygments-main/pygments/styles/igor.py +29 -0
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
- data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
- data/vendor/pygments-main/pygments/styles/native.py +1 -1
- data/vendor/pygments-main/pygments/styles/paraiso_dark.py +125 -0
- data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
- data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
- data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
- data/vendor/pygments-main/pygments/styles/tango.py +1 -1
- data/vendor/pygments-main/pygments/styles/trac.py +1 -1
- data/vendor/pygments-main/pygments/styles/vim.py +1 -1
- data/vendor/pygments-main/pygments/styles/vs.py +1 -1
- data/vendor/pygments-main/pygments/styles/xcode.py +51 -0
- data/vendor/pygments-main/pygments/token.py +4 -1
- data/vendor/pygments-main/pygments/unistring.py +6 -5
- data/vendor/pygments-main/pygments/util.py +35 -21
- data/vendor/pygments-main/scripts/check_sources.py +28 -44
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
- data/vendor/pygments-main/scripts/find_codetags.py +27 -19
- data/vendor/pygments-main/scripts/find_error.py +16 -13
- data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
- data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
- data/vendor/pygments-main/setup.py +19 -19
- data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
- data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
- data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
- data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
- data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
- data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
- data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
- data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
- data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
- data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
- data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
- data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
- data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
- data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
- data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
- data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
- data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
- data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
- data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
- data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
- data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
- data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
- data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
- data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
- data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
- data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
- data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
- data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
- data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
- data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
- data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
- data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
- data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
- data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
- data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
- data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
- data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
- data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
- data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
- data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
- data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
- data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
- data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
- data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
- data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
- data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
- data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
- data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
- data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
- data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
- data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
- data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
- data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
- data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
- data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
- data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
- data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
- data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
- data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
- data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
- data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
- data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
- data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
- data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
- data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
- data/vendor/pygments-main/tests/run.py +14 -19
- data/vendor/pygments-main/tests/string_asserts.py +22 -0
- data/vendor/pygments-main/tests/test_basic_api.py +28 -14
- data/vendor/pygments-main/tests/test_cfm.py +46 -0
- data/vendor/pygments-main/tests/test_clexer.py +208 -3
- data/vendor/pygments-main/tests/test_cmdline.py +6 -5
- data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
- data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
- data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
- data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
- data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
- data/vendor/pygments-main/tests/test_perllexer.py +1 -1
- data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
- data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
- data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
- data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
- data/vendor/pygments-main/tests/test_token.py +3 -3
- data/vendor/pygments-main/tests/test_using_api.py +1 -1
- data/vendor/pygments-main/tests/test_util.py +1 -1
- metadata +138 -51
- data/vendor/pygments-main/docs/generate.py +0 -472
- data/vendor/pygments-main/docs/src/api.txt +0 -270
- data/vendor/pygments-main/docs/src/authors.txt +0 -5
- data/vendor/pygments-main/docs/src/changelog.txt +0 -5
- data/vendor/pygments-main/docs/src/index.txt +0 -69
- data/vendor/pygments-main/docs/src/installation.txt +0 -71
- data/vendor/pygments-main/external/rst-directive-old.py +0 -77
- data/vendor/pygments-main/scripts/reindent.py +0 -291
- data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
- data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
- data/vendor/pygments-main/tests/old_run.py +0 -138
@@ -0,0 +1,38 @@
|
|
1
|
+
#pike __REAL_VERSION__
|
2
|
+
|
3
|
+
constant Generic = __builtin.GenericError;
|
4
|
+
|
5
|
+
constant Index = __builtin.IndexError;
|
6
|
+
|
7
|
+
constant BadArgument = __builtin.BadArgumentError;
|
8
|
+
|
9
|
+
constant Math = __builtin.MathError;
|
10
|
+
|
11
|
+
constant Resource = __builtin.ResourceError;
|
12
|
+
|
13
|
+
constant Permission = __builtin.PermissionError;
|
14
|
+
|
15
|
+
constant Decode = __builtin.DecodeError;
|
16
|
+
|
17
|
+
constant Cpp = __builtin.CppError;
|
18
|
+
|
19
|
+
constant Compilation = __builtin.CompilationError;
|
20
|
+
|
21
|
+
constant MasterLoad = __builtin.MasterLoadError;
|
22
|
+
|
23
|
+
constant ModuleLoad = __builtin.ModuleLoadError;
|
24
|
+
|
25
|
+
//! Returns an Error object for any argument it receives. If the
|
26
|
+
//! argument already is an Error object or is empty, it does nothing.
|
27
|
+
object mkerror(mixed error)
|
28
|
+
{
|
29
|
+
if (error == UNDEFINED)
|
30
|
+
return error;
|
31
|
+
if (objectp(error) && error->is_generic_error)
|
32
|
+
return error;
|
33
|
+
if (arrayp(error))
|
34
|
+
return Error.Generic(@error);
|
35
|
+
if (stringp(error))
|
36
|
+
return Error.Generic(error);
|
37
|
+
return Error.Generic(sprintf("%O", error));
|
38
|
+
}
|
@@ -0,0 +1,360 @@
|
|
1
|
+
#pike __REAL_VERSION__
|
2
|
+
|
3
|
+
//! A string wrapper that pretends to be a @[Stdio.File] object
|
4
|
+
//! in addition to some features of a @[Stdio.FILE] object.
|
5
|
+
|
6
|
+
|
7
|
+
//! This constant can be used to distinguish a FakeFile object
|
8
|
+
//! from a real @[Stdio.File] object.
|
9
|
+
constant is_fake_file = 1;
|
10
|
+
|
11
|
+
protected string data;
|
12
|
+
protected int ptr;
|
13
|
+
protected int(0..1) r;
|
14
|
+
protected int(0..1) w;
|
15
|
+
protected int mtime;
|
16
|
+
|
17
|
+
protected function read_cb;
|
18
|
+
protected function read_oob_cb;
|
19
|
+
protected function write_cb;
|
20
|
+
protected function write_oob_cb;
|
21
|
+
protected function close_cb;
|
22
|
+
|
23
|
+
//! @seealso
|
24
|
+
//! @[Stdio.File()->close()]
|
25
|
+
int close(void|string direction) {
|
26
|
+
direction = lower_case(direction||"rw");
|
27
|
+
int cr = has_value(direction, "r");
|
28
|
+
int cw = has_value(direction, "w");
|
29
|
+
|
30
|
+
if(cr) {
|
31
|
+
r = 0;
|
32
|
+
}
|
33
|
+
|
34
|
+
if(cw) {
|
35
|
+
w = 0;
|
36
|
+
}
|
37
|
+
|
38
|
+
// FIXME: Close callback
|
39
|
+
return 1;
|
40
|
+
}
|
41
|
+
|
42
|
+
//! @decl void create(string data, void|string type, void|int pointer)
|
43
|
+
//! @seealso
|
44
|
+
//! @[Stdio.File()->create()]
|
45
|
+
void create(string _data, void|string type, int|void _ptr) {
|
46
|
+
if(!_data) error("No data string given to FakeFile.\n");
|
47
|
+
data = _data;
|
48
|
+
ptr = _ptr;
|
49
|
+
mtime = time();
|
50
|
+
if(type) {
|
51
|
+
type = lower_case(type);
|
52
|
+
if(has_value(type, "r"))
|
53
|
+
r = 1;
|
54
|
+
if(has_value(type, "w"))
|
55
|
+
w = 1;
|
56
|
+
}
|
57
|
+
else
|
58
|
+
r = w = 1;
|
59
|
+
}
|
60
|
+
|
61
|
+
protected string make_type_str() {
|
62
|
+
string type = "";
|
63
|
+
if(r) type += "r";
|
64
|
+
if(w) type += "w";
|
65
|
+
return type;
|
66
|
+
}
|
67
|
+
|
68
|
+
//! @seealso
|
69
|
+
//! @[Stdio.File()->dup()]
|
70
|
+
this_program dup() {
|
71
|
+
return this_program(data, make_type_str(), ptr);
|
72
|
+
}
|
73
|
+
|
74
|
+
//! Always returns 0.
|
75
|
+
//! @seealso
|
76
|
+
//! @[Stdio.File()->errno()]
|
77
|
+
int errno() { return 0; }
|
78
|
+
|
79
|
+
//! Returns size and the creation time of the string.
|
80
|
+
Stdio.Stat stat() {
|
81
|
+
Stdio.Stat st = Stdio.Stat();
|
82
|
+
st->size = sizeof(data);
|
83
|
+
st->mtime=st->ctime=mtime;
|
84
|
+
st->atime=time();
|
85
|
+
return st;
|
86
|
+
}
|
87
|
+
|
88
|
+
//! @seealso
|
89
|
+
//! @[Stdio.File()->line_iterator()]
|
90
|
+
String.SplitIterator line_iterator(int|void trim) {
|
91
|
+
if(trim)
|
92
|
+
return String.SplitIterator( data-"\r", '\n' );
|
93
|
+
return String.SplitIterator( data, '\n' );
|
94
|
+
}
|
95
|
+
|
96
|
+
protected mixed id;
|
97
|
+
|
98
|
+
//! @seealso
|
99
|
+
//! @[Stdio.File()->query_id()]
|
100
|
+
mixed query_id() { return id; }
|
101
|
+
|
102
|
+
//! @seealso
|
103
|
+
//! @[Stdio.File()->set_id()]
|
104
|
+
void set_id(mixed _id) { id = _id; }
|
105
|
+
|
106
|
+
//! @seealso
|
107
|
+
//! @[Stdio.File()->read_function()]
|
108
|
+
function(:string) read_function(int nbytes) {
|
109
|
+
return lambda() { return read(nbytes); };
|
110
|
+
}
|
111
|
+
|
112
|
+
//! @seealso
|
113
|
+
//! @[Stdio.File()->peek()]
|
114
|
+
int(-1..1) peek(int|float|void timeout) {
|
115
|
+
if(!r) return -1;
|
116
|
+
if(ptr >= sizeof(data)) return 0;
|
117
|
+
return 1;
|
118
|
+
}
|
119
|
+
|
120
|
+
//! Always returns 0.
|
121
|
+
//! @seealso
|
122
|
+
//! @[Stdio.File()->query_address()]
|
123
|
+
string query_address(void|int(0..1) is_local) { return 0; }
|
124
|
+
|
125
|
+
//! @seealso
|
126
|
+
//! @[Stdio.File()->read()]
|
127
|
+
string read(void|int(0..) len, void|int(0..1) not_all) {
|
128
|
+
if(!r) return 0;
|
129
|
+
if (len < 0) error("Cannot read negative number of characters.\n");
|
130
|
+
int start=ptr;
|
131
|
+
ptr += len;
|
132
|
+
if(zero_type(len) || ptr>sizeof(data))
|
133
|
+
ptr = sizeof(data);
|
134
|
+
|
135
|
+
// FIXME: read callback
|
136
|
+
return data[start..ptr-1];
|
137
|
+
}
|
138
|
+
|
139
|
+
//! @seealso
|
140
|
+
//! @[Stdio.FILE()->gets()]
|
141
|
+
string gets() {
|
142
|
+
if(!r) return 0;
|
143
|
+
string ret;
|
144
|
+
sscanf(data,"%*"+(string)ptr+"s%[^\n]",ret);
|
145
|
+
if(ret)
|
146
|
+
{
|
147
|
+
ptr+=sizeof(ret)+1;
|
148
|
+
if(ptr>sizeof(data))
|
149
|
+
{
|
150
|
+
ptr=sizeof(data);
|
151
|
+
if(!sizeof(ret))
|
152
|
+
ret = 0;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
// FIXME: read callback
|
157
|
+
return ret;
|
158
|
+
}
|
159
|
+
|
160
|
+
//! @seealso
|
161
|
+
//! @[Stdio.FILE()->getchar()]
|
162
|
+
int getchar() {
|
163
|
+
if(!r) return 0;
|
164
|
+
int c;
|
165
|
+
if(catch(c=data[ptr]))
|
166
|
+
c=-1;
|
167
|
+
else
|
168
|
+
ptr++;
|
169
|
+
|
170
|
+
// FIXME: read callback
|
171
|
+
return c;
|
172
|
+
}
|
173
|
+
|
174
|
+
//! @seealso
|
175
|
+
//! @[Stdio.FILE()->unread()]
|
176
|
+
void unread(string s) {
|
177
|
+
if(!r) return;
|
178
|
+
if(data[ptr-sizeof(s)..ptr-1]==s)
|
179
|
+
ptr-=sizeof(s);
|
180
|
+
else
|
181
|
+
{
|
182
|
+
data=s+data[ptr..];
|
183
|
+
ptr=0;
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
//! @seealso
|
188
|
+
//! @[Stdio.File()->seek()]
|
189
|
+
int seek(int pos, void|int mult, void|int add) {
|
190
|
+
if(mult)
|
191
|
+
pos = pos*mult+add;
|
192
|
+
if(pos<0)
|
193
|
+
{
|
194
|
+
pos = sizeof(data)+pos;
|
195
|
+
if( pos < 0 )
|
196
|
+
pos = 0;
|
197
|
+
}
|
198
|
+
ptr = pos;
|
199
|
+
if( ptr > strlen( data ) )
|
200
|
+
ptr = strlen(data);
|
201
|
+
return ptr;
|
202
|
+
}
|
203
|
+
|
204
|
+
//! Always returns 1.
|
205
|
+
//! @seealso
|
206
|
+
//! @[Stdio.File()->sync()]
|
207
|
+
int(1..1) sync() { return 1; }
|
208
|
+
|
209
|
+
//! @seealso
|
210
|
+
//! @[Stdio.File()->tell()]
|
211
|
+
int tell() { return ptr; }
|
212
|
+
|
213
|
+
//! @seealso
|
214
|
+
//! @[Stdio.File()->truncate()]
|
215
|
+
int(0..1) truncate(int length) {
|
216
|
+
data = data[..length-1];
|
217
|
+
return sizeof(data)==length;
|
218
|
+
}
|
219
|
+
|
220
|
+
//! @seealso
|
221
|
+
//! @[Stdio.File()->write()]
|
222
|
+
int(-1..) write(string|array(string) str, mixed ... extra) {
|
223
|
+
if(!w) return -1;
|
224
|
+
if(arrayp(str)) str=str*"";
|
225
|
+
if(sizeof(extra)) str=sprintf(str, @extra);
|
226
|
+
|
227
|
+
if(ptr==sizeof(data)) {
|
228
|
+
data += str;
|
229
|
+
ptr = sizeof(data);
|
230
|
+
}
|
231
|
+
else if(sizeof(str)==1)
|
232
|
+
data[ptr++] = str[0];
|
233
|
+
else {
|
234
|
+
data = data[..ptr-1] + str + data[ptr+sizeof(str)..];
|
235
|
+
ptr += sizeof(str);
|
236
|
+
}
|
237
|
+
|
238
|
+
// FIXME: write callback
|
239
|
+
return sizeof(str);
|
240
|
+
}
|
241
|
+
|
242
|
+
//! @seealso
|
243
|
+
//! @[Stdio.File()->set_blocking]
|
244
|
+
void set_blocking() {
|
245
|
+
close_cb = 0;
|
246
|
+
read_cb = 0;
|
247
|
+
read_oob_cb = 0;
|
248
|
+
write_cb = 0;
|
249
|
+
write_oob_cb = 0;
|
250
|
+
}
|
251
|
+
|
252
|
+
//! @seealso
|
253
|
+
//! @[Stdio.File()->set_blocking_keep_callbacks]
|
254
|
+
void set_blocking_keep_callbacks() { }
|
255
|
+
|
256
|
+
//! @seealso
|
257
|
+
//! @[Stdio.File()->set_blocking]
|
258
|
+
void set_nonblocking(function rcb, function wcb, function ccb,
|
259
|
+
function rocb, function wocb) {
|
260
|
+
read_cb = rcb;
|
261
|
+
write_cb = wcb;
|
262
|
+
close_cb = ccb;
|
263
|
+
read_oob_cb = rocb;
|
264
|
+
write_oob_cb = wocb;
|
265
|
+
}
|
266
|
+
|
267
|
+
//! @seealso
|
268
|
+
//! @[Stdio.File()->set_blocking_keep_callbacks]
|
269
|
+
void set_nonblocking_keep_callbacks() { }
|
270
|
+
|
271
|
+
|
272
|
+
//! @seealso
|
273
|
+
//! @[Stdio.File()->set_close_callback]
|
274
|
+
void set_close_callback(function cb) { close_cb = cb; }
|
275
|
+
|
276
|
+
//! @seealso
|
277
|
+
//! @[Stdio.File()->set_read_callback]
|
278
|
+
void set_read_callback(function cb) { read_cb = cb; }
|
279
|
+
|
280
|
+
//! @seealso
|
281
|
+
//! @[Stdio.File()->set_read_oob_callback]
|
282
|
+
void set_read_oob_callback(function cb) { read_oob_cb = cb; }
|
283
|
+
|
284
|
+
//! @seealso
|
285
|
+
//! @[Stdio.File()->set_write_callback]
|
286
|
+
void set_write_callback(function cb) { write_cb = cb; }
|
287
|
+
|
288
|
+
//! @seealso
|
289
|
+
//! @[Stdio.File()->set_write_oob_callback]
|
290
|
+
void set_write_oob_callback(function cb) { write_oob_cb = cb; }
|
291
|
+
|
292
|
+
|
293
|
+
//! @seealso
|
294
|
+
//! @[Stdio.File()->query_close_callback]
|
295
|
+
function query_close_callback() { return close_cb; }
|
296
|
+
|
297
|
+
//! @seealso
|
298
|
+
//! @[Stdio.File()->query_read_callback]
|
299
|
+
function query_read_callback() { return read_cb; }
|
300
|
+
|
301
|
+
//! @seealso
|
302
|
+
//! @[Stdio.File()->query_read_oob_callback]
|
303
|
+
function query_read_oob_callback() { return read_oob_cb; }
|
304
|
+
|
305
|
+
//! @seealso
|
306
|
+
//! @[Stdio.File()->query_write_callback]
|
307
|
+
function query_write_callback() { return write_cb; }
|
308
|
+
|
309
|
+
//! @seealso
|
310
|
+
//! @[Stdio.File()->query_write_oob_callback]
|
311
|
+
function query_write_oob_callback() { return write_oob_cb; }
|
312
|
+
|
313
|
+
string _sprintf(int t) {
|
314
|
+
return t=='O' && sprintf("%O(%d,%O)", this_program, sizeof(data),
|
315
|
+
make_type_str());
|
316
|
+
}
|
317
|
+
|
318
|
+
|
319
|
+
// FakeFile specials.
|
320
|
+
|
321
|
+
//! A FakeFile can be casted to a string.
|
322
|
+
mixed cast(string to) {
|
323
|
+
switch(to) {
|
324
|
+
case "string": return data;
|
325
|
+
case "object": return this;
|
326
|
+
}
|
327
|
+
error("Can not cast object to %O.\n", to);
|
328
|
+
}
|
329
|
+
|
330
|
+
//! Sizeof on a FakeFile returns the size of its contents.
|
331
|
+
int(0..) _sizeof() {
|
332
|
+
return sizeof(data);
|
333
|
+
}
|
334
|
+
|
335
|
+
//! @ignore
|
336
|
+
|
337
|
+
#define NOPE(X) mixed X (mixed ... args) { error("This is a FakeFile. %s is not available.\n", #X); }
|
338
|
+
NOPE(assign);
|
339
|
+
NOPE(async_connect);
|
340
|
+
NOPE(connect);
|
341
|
+
NOPE(connect_unix);
|
342
|
+
NOPE(open);
|
343
|
+
NOPE(open_socket);
|
344
|
+
NOPE(pipe);
|
345
|
+
NOPE(tcgetattr);
|
346
|
+
NOPE(tcsetattr);
|
347
|
+
|
348
|
+
// Stdio.Fd
|
349
|
+
NOPE(dup2);
|
350
|
+
NOPE(lock); // We could implement this
|
351
|
+
NOPE(mode); // We could implement this
|
352
|
+
NOPE(proxy); // We could implement this
|
353
|
+
NOPE(query_fd);
|
354
|
+
NOPE(read_oob);
|
355
|
+
NOPE(set_close_on_exec);
|
356
|
+
NOPE(set_keepalive);
|
357
|
+
NOPE(trylock); // We could implement this
|
358
|
+
NOPE(write_oob);
|
359
|
+
|
360
|
+
//! @endignore
|
File without changes
|
@@ -0,0 +1,5 @@
|
|
1
|
+
; Note, clojure lexer is here (and is a good deal more liberal than the language spec:
|
2
|
+
; https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L62
|
3
|
+
|
4
|
+
(defn valid [#^java.lang.reflect.Method meth]
|
5
|
+
[:keyword :#initial-hash :h#sh-in-middle :hash-at-end# #js {:keyword "value"}])
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
(ns bounder.core
|
3
|
+
(:require [bounder.html :as html]
|
4
|
+
[domina :refer [value set-value! single-node]]
|
5
|
+
[domina.css :refer [sel]]
|
6
|
+
[lowline.functions :refer [debounce]]
|
7
|
+
[enfocus.core :refer [at]]
|
8
|
+
[cljs.reader :as reader]
|
9
|
+
[clojure.string :as s])
|
10
|
+
(:require-macros [enfocus.macros :as em]))
|
11
|
+
|
12
|
+
(def filter-input
|
13
|
+
(single-node
|
14
|
+
(sel ".search input")))
|
15
|
+
|
16
|
+
(defn project-matches [query project]
|
17
|
+
(let [words (cons (:name project)
|
18
|
+
(map name (:categories project)))
|
19
|
+
to-match (->> words
|
20
|
+
(s/join "")
|
21
|
+
(s/lower-case))]
|
22
|
+
(<= 0 (.indexOf to-match (s/lower-case query)))))
|
23
|
+
|
24
|
+
(defn apply-filter-for [projects]
|
25
|
+
(let [query (value filter-input)]
|
26
|
+
(html/render-projects
|
27
|
+
(filter (partial project-matches query)
|
28
|
+
projects))))
|
29
|
+
|
30
|
+
(defn filter-category [projects evt]
|
31
|
+
(let [target (.-currentTarget evt)]
|
32
|
+
(set-value! filter-input
|
33
|
+
(.-innerHTML target))
|
34
|
+
(apply-filter-for projects)))
|
35
|
+
|
36
|
+
(defn init-listeners [projects]
|
37
|
+
(at js/document
|
38
|
+
["input"] (em/listen
|
39
|
+
:keyup
|
40
|
+
(debounce
|
41
|
+
(partial apply-filter-for projects)
|
42
|
+
500))
|
43
|
+
[".category-links li"] (em/listen
|
44
|
+
:click
|
45
|
+
(partial filter-category projects))))
|
46
|
+
|
47
|
+
(defn init [projects-edn]
|
48
|
+
(let [projects (reader/read-string projects-edn)]
|
49
|
+
(init-listeners projects)
|
50
|
+
(html/render-projects projects)
|
51
|
+
(html/loaded)))
|
52
|
+
|