Compare commits

...

362 Commits

Author SHA1 Message Date
mdipierro
a55c6777d3 R-2.8.1 2013-11-27 13:54:04 -06:00
mdipierro
f9e16557c4 Merge pull request #308 from niphlod/issue/1780
fixes issue 1780
2013-11-27 10:00:49 -08:00
mdipierro
165b682e01 no more drawer open in edit mode 2013-11-27 12:00:21 -06:00
niphlod
92ab6dc635 fix issue 1780 2013-11-25 22:46:27 +01:00
mdipierro
0385ce6eb2 allow add_button(...,'javascript:') 2013-11-25 15:22:21 -06:00
mdipierro
5ba6e8fea2 Merge pull request #307 from erikmontes/patch-1
Comment documentation typo correction
2013-11-25 10:50:05 -08:00
mdipierro
8979c0919f Merge pull request #306 from ilvalle/git-fix
fix issue-1789
2013-11-25 10:49:05 -08:00
Erik Montes
b9048b6d65 Comment documentation typo correction 2013-11-25 10:34:55 -08:00
ilvalle
3592dba7f5 fix issue-1789 2013-11-25 09:49:43 +01:00
mdipierro
a7defed64c no more Tkinter is not necessary 2013-11-24 20:33:31 -06:00
mdipierro
ff2f11a706 generic.jsonp raises HTTP(404) 2013-11-24 09:44:08 -06:00
mdipierro
84cc47920b Merge branch 'cm-3.20' of https://github.com/ilvalle/web2py into ilvalle-cm-3.20 2013-11-23 21:49:54 -06:00
mdipierro
f57d96d64d no more 2.5 testing on Travis 2013-11-23 21:49:34 -06:00
mdipierro
c310627d1b possibly fixed the PyPy testing problem 2013-11-23 21:42:09 -06:00
ilvalle
be66f53c7e fix form action 2013-11-24 00:20:13 +01:00
mdipierro
77f32a8f4b wmv in expand all 2013-11-22 21:20:47 -06:00
mdipierro
9b8a24eeb9 fixed undefined form last commit 2013-11-22 12:14:08 -06:00
mdipierro
c87bf553f6 fixed issue 1783:Forgot password and forgot username functionality breaks when multiple usernames are created against the same email address 2013-11-22 10:50:29 -06:00
mdipierro
2361eb4a84 fixed issue 1786:Allow formargs to override grid parameters., thanks iiijjjiii 2013-11-22 10:25:22 -06:00
mdipierro
4f4cc8f98f fixed link to download jquery plugin 2013-11-22 10:18:29 -06:00
mdipierro
5f1caf668b colnames in grid, thanks Niphlod, Arnon, and Paolo 2013-11-22 08:38:12 -06:00
mdipierro
054152f162 extract_oracle_models.py 2013-11-20 10:24:08 -06:00
mdipierro
78cf9df6ef Retire the Splash Screen and Beautify GUI., thanks skyscooby 2013-11-20 09:41:04 -06:00
mdipierro
2924b20c92 Merge pull request #303 from skyscooby/master
Retire the Splash Screen and Beautify GUI.
2013-11-20 07:19:50 -08:00
mdipierro
f6318ae86c Merge pull request #301 from gi0baro/issue1772
Issue #1772: let the user choose uploads_in_blob with mongodb
2013-11-20 07:17:49 -08:00
Massimo
e57907de35 do not truncate on delete 2013-11-19 17:38:13 -06:00
Massimo
df2f9e7119 NDB accepts set, list and tuple, thanks Quint 2013-11-19 17:07:19 -06:00
Andrew Greenwood
23d7eb7a43 Retire the Splash Screen and Beautify GUI.
Lets give 5 seconds back to most users on startup by retiring the
artificial Splash Screen. Replace with a prettier server manager window.

-Makes product feel faster.
-Looks much better
-Fixes bug where two windows are created when using (-Q)
-Blocks resize on UI window.
-Window is now labeled ProgramName
2013-11-19 16:49:28 -05:00
mdipierro
6868ddeed5 fixed 1779:Query class __str__ method should cast non string values, thanks Alan 2013-11-18 15:41:32 -06:00
mdipierro
8de6bff2fb fixed (again) issue 1774:CAS client broken when using routes.py, thanks remco.boerma 2013-11-18 15:37:52 -06:00
gi0baro
9028ec9857 Issue #1772: let the user choose uploads_in_blob with mongodb 2013-11-18 01:02:43 +01:00
mdipierro
8696a01eda some GAE optimization, thanks Quint 2013-11-17 13:36:35 -06:00
mdipierro
f8f91c6a6a experiment with mongodb and belongs 2013-11-17 12:03:20 -06:00
mdipierro
97739e9e8a in mongodb uploads_in_blob = False, because of https://code.google.com/p/web2py/issues/detail?id=1772, thanks Alan 2013-11-17 09:32:01 -06:00
mdipierro
16b68572cd attempt to support GAE IN operator, thanks Quint 2013-11-17 09:28:46 -06:00
mdipierro
d6e63b4d7c simpled int to hex conversion of mongo id, thanks Alan 2013-11-17 09:21:16 -06:00
mdipierro
a6e8111484 Merge pull request #300 from spametki/master
MongoDB: fixed object_id function (hex values)
2013-11-17 07:15:33 -08:00
Alan Etkin
bdc214f45b MongoDB: fixed object_id function (hex values) 2013-11-16 17:16:59 -03:00
mdipierro
a91570768e fixed typo 2013-11-16 11:52:18 -06:00
mdipierro
d35321c6c6 improvements to GoogleAdapter, thanks Quint 2013-11-16 04:10:18 -06:00
mdipierro
e482cba237 minor dal rewrite in real_referenced 2013-11-16 03:54:30 -06:00
mdipierro
c7cf13f8ea minor rewrite of mongoDB adapter 2013-11-16 03:39:39 -06:00
mdipierro
e0329ce59a fixed 1771:MongoDBAdapter ILIKE and widget.autocomplete, thanks Francisco 2013-11-16 03:32:36 -06:00
mdipierro
de7848ba21 Merge pull request #298 from chuckis/patch-1
Update ru.py
2013-11-16 01:28:14 -08:00
mdipierro
d6f5a5684f Merge pull request #297 from xbello/master
Added two libs and icon path to setup.py
2013-11-16 01:27:39 -08:00
mdipierro
9883590a91 Merge pull request #295 from niphlod/enhancement/mssql4
improved performance on mssql4
2013-11-16 01:24:55 -08:00
mdipierro
b11bdddfe2 Merge pull request #294 from timrichardson/issue/1773
replace write to stderr with LOGGER in failed database connection attemp...
2013-11-16 01:24:18 -08:00
mdipierro
623cd515de Merge pull request #293 from magnunleno/patch-1
Adds bind capability to OpenLDAP
2013-11-16 01:23:30 -08:00
mdipierro
f53da87f6f fixed 1774:CAS client broken when using routes.py, thanks remco.boerma 2013-11-16 03:23:03 -06:00
mdipierro
ff7ef47cc7 fix issue 1777:MongoDB: upload representation error, thanks Francisco Betancourt 2013-11-16 03:16:57 -06:00
chuckis
108b24abdd Update ru.py 2013-11-15 12:05:24 +02:00
xbello
2d309c6e81 Added two libs and icon path to setup.py 2013-11-15 10:16:09 +01:00
Massimo
07f0cdadcd memdb conflict check, thanks Luca 2013-11-14 13:29:46 -06:00
niphlod
7c8c9bc3af improved performance on mssql4 2013-11-13 23:18:07 +01:00
mdipierro
948e0b1f43 possible to fix to memdb threading issue 2013-11-13 14:07:26 -06:00
tim
be9027f36f replace write to stderr with LOGGER in failed database connection attempt 2013-11-13 17:42:21 +11:00
mdipierro
9bb4155460 adding spanish plurals, thanks Vlad Vladyslav 2013-11-11 17:42:58 -06:00
Magnun Leno
ad877b2305 Adds bind capability to OpenLDAP
Adds to OpenLDAP (mode=uid and mode=cn) the capability to bind to the directory with an admin account in order to search it.
2013-11-11 15:53:38 -02:00
mdipierro
fb9ad028f8 fixed problem with multiple uris and lazy tables 2013-11-11 10:16:38 -06:00
mdipierro
833694229d Merge pull request #292 from flavour/master
Support HTTP Status 509
2013-11-11 07:43:56 -08:00
mdipierro
d6a8a3d410 Espanol language patches, thanks Vladyslav Kozlovskyy 2013-11-11 09:40:57 -06:00
Fran Boon
4e9d228a60 Support HTTP Status 509
Whilst this isn't an official RFC, it's documented on e.g. Wikipedia. http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_Error
2013-11-08 10:46:47 +00:00
Massimo
db0d31260e NDB support for GAE, thanks Quint, needs testing 2013-11-07 11:16:04 -06:00
Massimo
9178b23473 Merge branch 'master' of github.com:web2py/web2py
Conflicts:
	VERSION
2013-11-07 11:06:37 -06:00
Massimo
40d5e5dfe9 fixed 1746:auth.wiki renders multi-line code as single-line, thanks Alan 2013-11-07 11:00:39 -06:00
Massimo
f95476c51e fixed colgroup issue in grid, thanks Anthony 2013-11-07 10:47:57 -06:00
Massimo
73ab77ad8b fixed 1765:Verify email message seams to only accept username, key and link 2013-11-07 10:31:54 -06:00
Massimo
e6f84c45b9 fixed 1756:scripts/sessions2trash.py doesn't work with 'separate=True', thanks Paolo Valleri 2013-11-07 10:25:29 -06:00
mdipierro
58c22b8ed0 synced web2py.js, thanks Vinicius 2013-11-06 16:57:33 -06:00
mdipierro
ee1de04544 Merge pull request #291 from viniciusban/master
Make component forms submit to their own action property
2013-11-06 14:55:12 -08:00
Vinicius Assef
9977aa571a Make component forms submit to their own action property 2013-11-06 19:37:55 -02:00
mdipierro
65b883749a fixed 1757:Broken support for 'belongs' with GAE datastore, thanks Alan 2013-11-06 11:14:56 -06:00
mdipierro
5cee4f8876 fixed issue 1763 user of arrows in numerical fields 2013-11-06 11:13:10 -06:00
mdipierro
3aec2c4568 Merge branch 'master' of github.com:web2py/web2py 2013-11-06 11:11:55 -06:00
mdipierro
3defd7d7b1 fixed issue 1763 user of arrows in numerical fields 2013-11-06 11:11:01 -06:00
mdipierro
ac97332393 Merge pull request #290 from erikmontes/patch-1
Closed html commment.
2013-11-06 08:32:01 -08:00
mdipierro
62bda4b917 Merge pull request #289 from michele-comitini/SQLCustomType_in_grid_fix
simple fix for wrong type detection of SQLCustomTypes
2013-11-06 08:31:34 -08:00
mdipierro
cb6857c16b Merge pull request #288 from hectord/translate_date_in_range_formatters
Translate the formatters for DATE/DATETIME_IN_RANGE validators
2013-11-06 08:31:06 -08:00
mdipierro
643e945540 fixed web2py.js for trapped non-self-submitting forms, thanks Vinicius 2013-11-06 10:30:41 -06:00
Erik Montes
b52b639eed Closed html commment. 2013-11-05 14:09:01 -08:00
Michele Comitini
e0ea9b78f8 simple fix for wrong type detection of SQLCustomTypes 2013-11-05 16:09:42 +01:00
mdipierro
8e4f92ac64 fixed TeradataAdapter CLOB, thnaks Andrew Willmott 2013-11-03 22:46:20 -06:00
mdipierro
350bd25404 another iteration to col/colgroup in grid, thanks Anthony for advice 2013-11-03 09:26:26 -06:00
mdipierro
6d3fe6cf89 col in colgroup for grid extracolumns, thanks Anthony 2013-11-02 10:09:11 -05:00
mdipierro
a3bf95e423 fixed colgroup wrapping, thanks Anthony 2013-11-02 09:26:19 -05:00
mdipierro
fc72cdf3d0 change in way args are parsed and less test_routes.py 2013-11-01 20:11:46 -05:00
mdipierro
b619bd3db7 minor rewrite in rewrite.py 2013-11-01 18:49:38 -05:00
mdipierro
b1631ae2b3 fixed issue 1758:Missing comment parameter in Recaptcha 2013-11-01 18:07:29 -05:00
mdipierro
a01aa78f36 fixed issue 1761:Add <col> elements to the grid for easier column formatting, thanks Anthony 2013-11-01 18:01:02 -05:00
mdipierro
975bc64fd0 fixed 1760:option -p or --port not working at command line 2013-11-01 17:45:43 -05:00
hectord
231fa489cb Translate the formatters for DATE/DATETIME_IN_RANGE validators 2013-11-01 22:43:31 +01:00
mdipierro
123f0f8269 Merge pull request #287 from niphlod/issue/1753
fixes issue 1753, web2py.js doesn't set the disabled state for inputs with name
2013-11-01 07:34:56 -07:00
niphlod
a6223cc319 fixes issue 1753, web2py.js doesn't set the disabled state for inputs with name 2013-10-31 21:10:37 +01:00
Massimo
8bdc5f20e7 fixed websocket_messaging.py, thanks Junior Phanter 2013-10-31 10:21:38 -05:00
Massimo
bb4f3d6e1a fixed issue 1755:IE11 vs gluon.contrib.user_agent - 'browser' key not existing anymore 2013-10-31 10:19:07 -05:00
Massimo
25f54356d4 fixed issue 1755:IE11 vs gluon.contrib.user_agent - 'browser' key not existing anymore 2013-10-31 09:42:03 -05:00
Massimo
5b3b5b6821 fixed issue 1736, Unable to create/re-create cache file error for cache.disk, thanks arglanir 2013-10-31 09:40:39 -05:00
mdipierro
1474a4fe79 link to pythonanywhere 2013-10-30 08:59:55 -05:00
mdipierro
c89ed53be1 Merge pull request #286 from ilvalle/fix-editor
fix for empty python file in admin editor
2013-10-29 14:05:21 -07:00
mdipierro
e692beafba Merge pull request #285 from niphlod/enhancement/dal_rname
fixed issue with ordereddict in python < 2.7, added rname support also for fields
2013-10-29 14:03:22 -07:00
mdipierro
850ef39bf7 Merge pull request #284 from spametki/master
Admin app: changed string interpolation in T calls
2013-10-29 14:01:38 -07:00
ilvalle
1bbb99b548 fix codemirror gutter managment 2013-10-29 17:24:46 +01:00
ilvalle
7675d605ea fix width after window resize 2013-10-29 17:02:50 +01:00
ilvalle
7d5cdb9220 fix for empty file in admin editor 2013-10-28 10:17:47 +01:00
mdipierro
78089bc0c4 small aesthetic change 2013-10-27 23:22:55 -05:00
mdipierro
eb9d7bf5c3 code simplification in wiki 2013-10-27 23:18:01 -05:00
mdipierro
8ce53e8dfa Wiki(...groups=['x','y']) allows to user groups names other then those set in auth_group.role, completely by-passing auth groups and memberships 2013-10-27 22:55:41 -05:00
niphlod
0f2b2daeab fixed issue with ordereddict in python < 2.7, added rname support also for fields 2013-10-27 14:36:38 +01:00
spametki
68ccf6510d admin app: changed string interpolation in T calls 2013-10-27 10:28:23 -03:00
mdipierro
d960513ef2 fixed issues 1742:dal Teradata connection issue. cursors not being closed at the end of sessions, thanks awilliman01 2013-10-26 21:46:48 -05:00
mdipierro
1865c0b1dd Merge pull request #283 from spametki/master
Fixed wiki get render method
2013-10-26 18:25:44 -07:00
mdipierro
af412e7e24 Merge pull request #282 from michele-comitini/make_executesql_as_dict_ordered
Make executesql as dict ordered
2013-10-26 18:24:57 -07:00
mdipierro
a74b1dd1bf Merge pull request #281 from niphlod/enhancement/update_pypyodbc
update pypyodbc to 1.2.0
2013-10-26 18:24:25 -07:00
mdipierro
7d9c853eeb Merge pull request #280 from gi0baro/mongo-binary
Fixing mongodb binary repr
2013-10-26 18:23:52 -07:00
mdipierro
7caf1c0794 Merge pull request #279 from ilvalle/fix-editor
Dynamic tab width in editor settings
2013-10-26 18:23:16 -07:00
spametki
70b3edcbeb Fixed wiki get render method 2013-10-26 21:39:26 -03:00
Michele Comitini
50543724d4 fix a docstring 2013-10-25 23:12:43 +02:00
Michele Comitini
ad81e641b3 optionally use OrderedDict in place of dict in executesql 2013-10-25 23:09:46 +02:00
niphlod
429ee8e423 update pypyodbc to 1.2.0 2013-10-25 21:41:50 +02:00
gi0baro
604795d6fc Fixing mongodb binary repr: if value is not a basestring we got type Exception in converting to Binary 2013-10-25 10:40:56 +02:00
ilvalle
6599e08d32 'Highlight current line' & 'Display line numbers' options in admin editor 2013-10-24 16:16:41 +02:00
ilvalle
94ddb6c11f dynamic tab size in admin editor (all tabs are placed along the same line) 2013-10-24 09:48:03 +02:00
mdipierro
a514060402 cleaning up pending references 2013-10-23 20:13:43 -05:00
mdipierro
fec5ddd150 Merge pull request #278 from niphlod/fix/dal_references
allow unordered references (NOT recommended but still possible with limitations)
2013-10-23 17:46:09 -07:00
mdipierro
811a44fd14 Merge pull request #277 from ilvalle/fix-editor
codemirror 3.19 and directory cleanup
2013-10-23 17:44:15 -07:00
mdipierro
1c5bad24f3 Merge pull request #276 from niphlod/enhancement/scheduler_current
inject W2P_TASK in current, so you can use current.W2P_TASK in imported ...
2013-10-23 17:43:36 -07:00
niphlod
17b4de18d7 allow unordered references (NOT recommended but still possible with limitations) 2013-10-23 21:42:55 +02:00
ilvalle
290cb2f1a7 simplified editor's options management 2013-10-23 14:33:15 +02:00
ilvalle
ff7cb99bfe jQuery -> $ in admin editor 2013-10-23 14:07:51 +02:00
ilvalle
339de2fa41 codemirror 3.19 and directory cleanup 2013-10-23 13:31:57 +02:00
Massimo
cafab17ee0 syncing 2013-10-22 17:05:52 -05:00
mdipierro
9fa1757ffb Merge pull request #275 from ilvalle/fix-editor
bootstrapSwitch in admin
2013-10-22 15:04:01 -07:00
Massimo
e94921c002 fixed issues with Rows.__or__, thanks Anthony 2013-10-22 17:03:54 -05:00
niphlod
d30098d646 inject W2P_TASK in current, so you can use current.W2P_TASK in imported modules. Thanks @Xiaonuo for the feature request 2013-10-23 00:03:04 +02:00
mdipierro
fba11869b6 Merge pull request #274 from Jaripekkaf/web2py_bs3
bootstrap3 formstyle
2013-10-22 14:59:48 -07:00
ilvalle
453412fa0c added bootstrap switch in editor settings 2013-10-22 17:36:45 +02:00
ilvalle
607897a1b0 boostrap switch plugin in admin 2013-10-22 17:36:19 +02:00
Jaripekkaf
221fdc51ba bootstrap3 formstyle 2013-10-22 13:15:21 +03:00
mdipierro
37551a8517 Merge pull request #272 from niphlod/enhancement/boostrap_232
bumped bootstrap to 2.3.2
2013-10-21 19:34:58 -07:00
mdipierro
8877eab977 Merge pull request #271 from niphlod/enhancement/windows_build
fix building on windows. New handler for gevented webserver
2013-10-21 19:32:34 -07:00
mdipierro
2d0205714c Merge pull request #270 from niphlod/fix/dal_reference
fix for references, DAL tests pass also on MSSQL now
2013-10-21 19:31:50 -07:00
mdipierro
49111345d1 Merge pull request #269 from ilvalle/fix-editor
Fix config to save checkboxes values when they are unchecked (false)
2013-10-21 19:31:14 -07:00
mdipierro
570564b0c4 fixed bug in compileapp models_to_run, thanks Anthony 2013-10-21 21:30:20 -05:00
niphlod
22dd63d77b bumped bootstrap to 2.3.2 2013-10-21 23:17:07 +02:00
niphlod
736311ff9a fix building on windows. New handler for gevented webserver 2013-10-21 12:52:43 -07:00
Massimo
34b377522a allow as_trees to deal with orphan children 2013-10-21 14:32:49 -05:00
niphlod
9f846dbe3c fix for references, DAL tests pass also on MSSQL now 2013-10-21 12:09:47 -07:00
ilvalle
845694beb6 Fix config to save checkboxes values when they are unchecked (false) 2013-10-21 09:57:36 +02:00
mdipierro
665f728946 db().select().as_trees() 2013-10-20 22:55:17 -05:00
mdipierro
d879e4a560 db().select().as_tree() 2013-10-20 22:51:03 -05:00
mdipierro
8e1a68d461 simplified logic 2013-10-20 16:58:08 -05:00
mdipierro
2738d12e0f fixed problem with _ot and rname 2013-10-20 16:51:34 -05:00
mdipierro
25148d06fe reverted to rname 2013-10-20 16:48:22 -05:00
mdipierro
4870b197de revering rname 2013-10-20 16:42:52 -05:00
mdipierro
12377794a6 remove actual_name 2013-10-20 15:48:15 -05:00
mdipierro
bf27623756 Merge branch 'master' of github.com:web2py/web2py 2013-10-20 15:47:10 -05:00
mdipierro
9afdf01430 PRAGMA foreign_keys=ON by default 2013-10-20 15:46:41 -05:00
mdipierro
80f16dadde Merge pull request #263 from niphlod/enhancement/dal_rname
add support for rname (meaning "real name") for table names
2013-10-20 13:45:00 -07:00
mdipierro
a68ac4fc02 Merge pull request #268 from spametki/master
imap: use common field types plus appadmin support
2013-10-20 07:56:59 -07:00
mdipierro
3dde465427 Merge pull request #267 from ilvalle/fix-editor
Tab width (new option in editor settings)
2013-10-20 07:56:18 -07:00
spametki
f77232740c imap: return to common field type for attachment and content plus appadmin imap support 2013-10-20 08:38:07 -03:00
ilvalle
56f251ca0c tab size in editor settings and better options management 2013-10-20 08:40:05 +02:00
mdipierro
9282bfcc60 fixed issue 1732:ignore_common_filters missing in appadmin, thanks mweissen 2013-10-19 17:41:17 -05:00
mdipierro
8d0bbbc9f1 Merge pull request #266 from niphlod/rm/windows_service
remove winservice support
2013-10-19 15:34:56 -07:00
mdipierro
ee33f2a4a8 Merge pull request #265 from spametki/master
Fixed imap get_last_message to return positive integer (google code issue 1729)
2013-10-19 15:33:46 -07:00
mdipierro
ab313c2d4d Merge pull request #264 from ilvalle/fix-editor
Code folding in admin editor
2013-10-19 15:32:03 -07:00
spametki
4c1de287cd dal imap: strip native folder names (google code issue 1734) 2013-10-19 16:50:20 -03:00
niphlod
9ea9f828bc remove winservice support 2013-10-19 20:44:56 +02:00
spametki
58e4cd91cc Fixed imap get_last_message to return positive integer 2013-10-19 09:57:08 -03:00
ilvalle
b5f17b1acb code folding in editor settings 2013-10-19 12:22:24 +02:00
ilvalle
e9c884d674 experimental code folding feature in admin editor 2013-10-19 12:18:46 +02:00
Massimo
492953c7f0 t -m "editor cleanup, thanks Paolo"
Merge branch 'master' of github.com:web2py/web2py
2013-10-18 12:31:13 -05:00
mdipierro
dd8d9d9d8d Merge pull request #261 from ilvalle/fix-editor
Editor cleanup
2013-10-18 10:30:36 -07:00
Massimo
9ff32ed9cd setup-web2py-debian-sid.sh, thanks Rusy 2013-10-18 12:27:23 -05:00
niphlod
c9b0c4547a add support for rname (meaning "real name") for table names 2013-10-18 00:09:32 +02:00
ilvalle
037b499cb2 correct editor's mode when editing javascript 2013-10-17 16:32:22 +02:00
ilvalle
f4fc987597 editor cleanup (second pass) 2013-10-17 16:20:06 +02:00
ilvalle
580bc6fd6e editor works again when is_mobile=True (No tabs when is mobile) 2013-10-17 16:10:53 +02:00
ilvalle
c91e6160fe initial editor cleanup and html fix 2013-10-17 15:25:12 +02:00
mdipierro
13c6c1ad37 Merge pull request #260 from spametki/master
New admin app plugin download
2013-10-16 07:15:08 -07:00
mdipierro
0faa7d3174 removed print statment, thanks Johann 2013-10-16 09:11:28 -05:00
mdipierro
cfe7c65987 fixed issue 1725:No debugging under WingIDE, thanks Joe 2013-10-16 09:09:22 -05:00
mdipierro
c5a2706c1b fixed issue 1724:webclient no longer handles integer post data, thanks iiijjjiii 2013-10-16 09:03:19 -05:00
mdipierro
a379d7020e fixed issue 1723:Missing translation for the word file in the upload widget, thanks mweissen 2013-10-16 09:00:42 -05:00
mdipierro
a74a16cfba fixed issue 1719:decorators ignore routes, thanks vladsalehov 2013-10-16 08:56:53 -05:00
spametki
37e0e1c384 Added missing plugin download views 2013-10-14 15:12:14 -03:00
spametki
62061ae737 admin app plugin download feature 2013-10-14 15:05:20 -03:00
mdipierro
8fe2680f80 R-2.7.4 2013-10-14 10:14:58 -05:00
mdipierro
09a747ce59 Merge pull request #256 from niphlod/enhancement/test_validators
removed unmaintained test.sh, ported validators doctests to unittests (and more added), fixed an issue with IS_MATCH() that never worked
2013-10-14 06:39:58 -07:00
mdipierro
2b34f738b1 Merge pull request #259 from niphlod/enhacement/mssql_limit
mssql 2012 support for pagination
2013-10-13 18:50:08 -07:00
mdipierro
050c4075b8 Merge pull request #258 from niphlod/issue/graph_contenttype
return the correct content-type for the graph
2013-10-13 18:48:56 -07:00
mdipierro
e64a6d6129 Merge pull request #257 from niphlod/enhancement/admin_static_version
response.static_version support in admin
2013-10-13 18:48:04 -07:00
niphlod
b27537a44b mssql 2012 support for pagination
enable true pagination support for MSSQL
2013-10-13 14:02:04 -07:00
niphlod
db8ce08794 return the correct content-type for the graph 2013-10-13 21:29:32 +02:00
niphlod
4b2f599f4b response.static_version support in admin 2013-10-13 21:26:17 +02:00
niphlod
78a0fe0769 removed unmaintained test.sh, ported validators doctests to unittests, fixed an issue with IS_MATCH() that never worked 2013-10-13 17:48:07 +02:00
mdipierro
927a1362af Merge pull request #255 from spametki/master
IMAP: insert support for base64 attachment payload
2013-10-13 06:27:16 -07:00
mdipierro
7e31612c3c Merge pull request #254 from pochmann/master
Improvements for number range validators
2013-10-13 06:26:27 -07:00
mdipierro
fbf75915f4 Merge pull request #253 from michele-comitini/issue-1710
use appropriate module for IPython 1.0.0
2013-10-13 06:24:13 -07:00
mdipierro
bf3d0bdd3d fixed problem with compileapp and compiled apps 2013-10-13 08:10:56 -05:00
Stefan Pochmann
20cdd86fcf simpler integer validation test 2013-10-12 22:42:27 +02:00
spametki
c6f048adc7 IMAP: insert support for base64 attachment payload 2013-10-12 17:28:57 -03:00
Michele Comitini
1451997172 use appropriate module for IPython 1.0.0 2013-10-12 21:52:30 +02:00
Stefan Pochmann
351a59033f unified and easier number range validator constructors 2013-10-12 21:46:17 +02:00
Stefan Pochmann
34bfe4527d consistency in error messages of number range validators 2013-10-12 21:22:11 +02:00
Stefan Pochmann
667069b573 Corrections for IS_INT_IN_RANGE 2013-10-12 21:10:29 +02:00
mdipierro
c3a7486930 fixed json contenttype in ajax_aditor.js, thanks Paolo 2013-10-12 09:48:13 -05:00
mdipierro
1a2a69b21a Merge pull request #252 from timrichardson/issue/1692v3
Issue/1692v3 OK merged my fix for virtual fields when fields argument is specified
2013-10-12 07:23:25 -07:00
mdipierro
06168c5364 Merge pull request #251 from niphlod/enhancement/build_with_bbfreeze
build web2py also with bbfreeze
2013-10-12 07:21:37 -07:00
mdipierro
a0ab8b9432 Merge pull request #250 from timrichardson/issue/1715
Add git pull and git push to the experimental mobile interface
2013-10-12 07:20:26 -07:00
mdipierro
0eab440a8a Merge pull request #248 from robertop23/master
New Codemirror option in editor config page to enable/disable autoclose-tag
2013-10-12 07:17:44 -07:00
robertop23
567e36badf Added extraKeys 'Shift-Tab' to codemirror 2013-10-12 08:11:40 -04:30
Tim Richardson
cff267c9c6 This fixes SQLFORM.grid virtualfields with fields= 2013-10-12 23:25:59 +11:00
niphlod
cf8ee0acac build web2py also with bbfreeze 2013-10-12 14:25:30 +02:00
Tim Richardson
f387c4c358 Add git pull and git push to the experimental mobile interface 2013-10-12 17:08:02 +11:00
Tim Richardson
c526cedd41 completed merge of virtual fields in fields arguemnt for SQLFORM.grid 2013-10-12 14:37:14 +11:00
mdipierro
5551a018ac fixed unnecessary escaping in regex, thanks Stefan Pochmann 2013-10-11 22:36:39 -05:00
robertop23
3744d9b71d Select option added in editor config button to enable/disable autoclosetag in html mode 2013-10-11 22:31:22 -04:30
Tim Richardson
436bd7b39c fix virtual fields with SQLFORM.grid fields=
Conflicts:
	gluon/sqlhtml.py
2013-10-12 13:59:39 +11:00
robertop23
4233383a98 Unused codemirror directories removed 2013-10-11 22:25:07 -04:30
mdipierro
1356dc1ef0 +-int in IS_INT validator 2013-10-11 20:42:51 -05:00
mdipierro
484cc81a73 Merge branch 'master' of github.com:web2py/web2py 2013-10-11 19:42:00 -05:00
mdipierro
914caadeec fixed onlogout next 2013-10-11 19:31:12 -05:00
mdipierro
1770fa0026 Merge pull request #246 from erikmontes/patch-1
Typo correction
2013-10-11 16:37:07 -07:00
mdipierro
63224e8ce6 2.7.3 2013-10-11 18:10:57 -05:00
mdipierro
ff7f9568db fixed validation of nagtive integers, thanks Stefan 2013-10-11 18:06:57 -05:00
mdipierro
3635dd8faf fixed problem with Virtual Fields and grid 2013-10-11 17:59:30 -05:00
mdipierro
d5fda056ff simplified logic for number validators 2013-10-11 17:07:17 -05:00
mdipierro
d8e8d1d597 fixed problem with IS_INT_IN_RANGE for large numbers 2013-10-11 16:59:05 -05:00
mdipierro
59290534bc fixed issue 1708:gae memcache_contrib does not set the time_expire, thanks Nicholas 2013-10-09 11:58:15 -05:00
mdipierro
8fb0b71be6 fixed compilerapp sorting issue, better 2013-10-09 11:31:33 -05:00
mdipierro
ddc0fc9949 fixed compilerapp sorting issue, possibly 2013-10-09 11:15:07 -05:00
mdipierro
5428fdbd04 reverted error commit 2013-10-09 09:07:00 -05:00
Erik Montes
c8a20b0d32 Typo correction
"simply" not "simple"
2013-10-08 17:55:31 -07:00
Massimo
98f2bfbfb6 Merge branch 'master' of github.com:web2py/web2py 2013-10-08 11:39:30 -05:00
Massimo
d780d26cc9 merge heads 2013-10-08 11:38:28 -05:00
mdipierro
a5711bd933 Merge pull request #244 from timrichardson/issue/1692
fix for Issue 1692 virtual fields in SQLFORM.grid
2013-10-08 09:35:51 -07:00
mdipierro
b96cde2f77 Merge pull request #243 from cccaballero/master
more spanish translations
2013-10-08 09:34:16 -07:00
Tim Richardson
a3f3ed1298 fix for Issue 1692 virtual fields in forms 2013-10-08 13:31:36 +11:00
mdipierro
5f34193ac7 fixed demo mode 2013-10-07 09:17:51 -05:00
cccaballero
6fe6852a0c more spanish translations
more spanish translations
2013-10-07 09:49:48 -04:00
mdipierro
961d143f7d 2.7.2 2013-10-07 08:40:39 -05:00
mdipierro
0e98544a79 Merge pull request #242 from rhr/master
fix for using the shell with IPython >= 1.0
2013-10-06 19:37:56 -07:00
mdipierro
86d8b8dece Merge pull request #241 from spametki/master
IMAP fixed patch for google code issue 1707
2013-10-06 19:37:11 -07:00
Rick Ree
46e2a663e9 fix for using the shell with IPython >= 1.0 2013-10-06 17:18:04 -05:00
spametki
e7fbd0095f IMAP google code issue 1707: fixed patch 2013-10-06 14:39:23 -03:00
mdipierro
add6fa526e fixed regex status in http.py 2013-10-06 11:52:23 -05:00
mdipierro
47e77e9a9c Merge pull request #239 from abastardi/patch-1
Fixed problem with Rows.render
2013-10-06 08:15:09 -07:00
mdipierro
81036ac997 Merge pull request #237 from alfonsodg/master
Added gitignore restrictions and changes for admin.py
2013-10-06 08:13:58 -07:00
mdipierro
77df883566 Merge pull request #236 from niphlod/enhancement/anyserver_options
fixed gevent workers
2013-10-06 08:11:03 -07:00
mdipierro
bfc7e3b4e9 Merge pull request #238 from houdinihound/patch-1
Support for HTTP Status Code: 429 - Too Many Requests
2013-10-06 08:09:52 -07:00
spametki
e05fe15470 IMAP .insert support for custom date (Google Code issue 1707) 2013-10-06 12:09:44 -03:00
mdipierro
2a062a2ff5 fixed setup scripts for apache to use processes, not threads, thanks Thomas 2013-10-06 10:08:40 -05:00
abastardi
44e7b70dbc Fixed problem with Rows.render 2013-10-06 09:04:47 -04:00
Jose C
88abefb896 Support for HTTP Status Code: 429 - Too Many Requests
Currently raising HTTP 429 results in HTTP 500 being sent.  This patch resolves that issue.
2013-10-05 15:42:48 +01:00
mdipierro
06ca5e6857 grid refcator patch for ajax, thanks Niphlod 2013-10-05 08:52:45 -05:00
Alfonso de la Guarda Reyes
c1f8d34892 Minor fixes for pep and styles widget.py 2013-10-05 08:08:37 -05:00
Alfonso de la Guarda Reyes
5679661914 Minor fixes for pep and style 2013-10-05 08:03:50 -05:00
Alfonso de la Guarda Reyes
cd957cf52b Fixes for some pep and code syntax 2013-10-05 07:59:04 -05:00
Alfonso de la Guarda Reyes
fff798c1cc Added restriction for .idea inside gitignore 2013-10-05 07:51:12 -05:00
niphlod
b464d3185e fixed gevent workers 2013-10-05 13:43:03 +02:00
mdipierro
cfb68ff90f fixed ldap_auth.py 2013-10-04 21:31:39 -05:00
mdipierro
8418fca2f6 R-2.7.1 2013-10-04 15:14:53 -05:00
mdipierro
68c0baeb22 R-2.7.1 2013-10-04 15:04:25 -05:00
mdipierro
700fd846a8 fixed a problem with grid 2013-10-04 14:56:16 -05:00
mdipierro
72a7643cde fixed issue 1704, groups in ldap, thanks Peter Gastinger 2013-10-04 14:41:19 -05:00
mdipierro
6b0177979f fixed issue 1705, sorting of model, thanks Anthony 2013-10-04 14:39:32 -05:00
mdipierro
7eb67fe6fa fields with readable=False should not be exportable from grid 2013-10-04 00:16:30 -05:00
mdipierro
5be65e8bd4 fixed issue 1697:gae memcached is not storing anything, thanks Yair 2013-10-03 08:40:19 -05:00
mdipierro
46903a3732 fixed issue 1698:Application Name Containing a Period . Not Supported, thanks Anton 2013-10-03 08:37:42 -05:00
mdipierro
c5b9b4d723 fixed issue 1700:DAL contains is not working on MSSQL 2013-10-03 08:33:57 -05:00
mdipierro
302a985aa7 fixed self.settings.table_<> 2013-10-03 08:19:34 -05:00
mdipierro
21a11ec47a removing garbage from admin it.py 2013-10-02 18:44:42 -05:00
mdipierro
814f4f4b4c fixed issue 1701:Restore menu/page after end of impersonation, thanks kmouts 2013-10-02 18:36:32 -05:00
mdipierro
87eeaaf028 fixed bug in stripe.py 2013-10-02 13:29:14 -05:00
mdipierro
b44aefc384 fixed some problems with StripeForm 2013-10-02 11:42:02 -05:00
mdipierro
e2c940532d new gluon.contrib.strip.StripeForm for PCI compliant payments 2013-10-02 11:06:30 -05:00
Massimo
66d6b3b511 fixed issue 1696:webclient not built to handle lists, thanks Yair 2013-10-01 15:25:34 -05:00
mdipierro
f0010f320e Merge pull request #233 from niphlod/issue/taskbar
fixed import for taskbar
2013-10-01 13:18:01 -07:00
niphlod
f092530a8c fixed import for taskbar 2013-10-01 20:46:00 +02:00
mdipierro
11a9fa345d Merge pull request #232 from timrichardson/issue/1695
Updated jquery-ui css resource to fix 404 error
2013-10-01 08:04:16 -07:00
Tim Richardson
a1c2019960 Updated jquery-ui css resource to fix 404 error 2013-09-29 06:47:19 +10:00
mdipierro
96e17ff1db SQLFORM.grid(...,ignore_common_filters=True) 2013-09-27 13:08:02 -05:00
mdipierro
4292cf38d9 more translations, thanks Vladyslav 2013-09-26 21:26:55 -05:00
mdipierro
fcba1650a0 Merge pull request #231 from ilvalle/cm-3.18
codemirror 3.18 with enabled the fullscreen addon
2013-09-26 14:37:47 -07:00
Paolo
ddf1998d49 codemirror 3.18 with enabled the fullscreen addon 2013-09-26 21:52:53 +02:00
Massimo
633acffd28 made form session logic backward compatible 2013-09-26 13:35:39 -05:00
Massimo
09ba525f2e possible fix to issue 1688, support for multiple forms with same formname in different browser pages 2013-09-26 11:26:08 -05:00
mdipierro
a8cbb1590d Translation of An 2013-09-26 07:56:49 -05:00
mdipierro
89971d1cb5 revised markmin.html, thanks Vladyslav 2013-09-25 19:54:42 -05:00
mdipierro
35180d61fa simplification in auth multilogin 2013-09-25 09:44:37 -05:00
mdipierro
8954d90ada minor change in languages/it.py 2013-09-25 09:08:40 -05:00
mdipierro
c0d399680e Merge pull request #227 from letolabs/fix_min_web2py
Update location of handlers so that make_min_web2py.py works again
2013-09-24 15:24:39 -07:00
mdipierro
528dd912d8 Merge pull request #228 from niphlod/enhancement/trapped_links
pass the correct element when trapping links
2013-09-24 15:23:07 -07:00
niphlod
cb6ae0516c pass the correct element when trapping links 2013-09-25 00:09:19 +02:00
Jonathan "Duke" Leto
4e1ad9bfa8 Update location of handlers to that make_min_web2py.py works again
The location of the handlers changed in 07f74c6362 and since then
this error blocked the creation of a minizimed web2py instance:

IOError: [Errno 2] No such file or directory: 'fcgihandler.py'
2013-09-24 13:44:38 -07:00
Massimo
6bea258722 update pbkdf2_ctypes.py to upstream, thanks Michele 2013-09-24 13:52:52 -05:00
mdipierro
554a52d548 Merge pull request #226 from michele-comitini/master
update pbkdf2_ctypes.py to upstream
2013-09-24 11:51:34 -07:00
Massimo
1a17655ef1 fixed line not found issues in set breakpoint, thanks Mariano 2013-09-24 13:51:08 -05:00
Massimo
5af2db1ff8 Merge branch 'master' of github.com:web2py/web2py 2013-09-24 13:48:49 -05:00
Massimo
a8567ae9ed syncing 2013-09-24 13:45:14 -05:00
mdipierro
40925165e6 Merge pull request #225 from reingart/master
fixed line not found issues in set breakpoint (linecache patch, used by the debugger)
2013-09-24 11:44:22 -07:00
mdipierro
eb4942a38d Merge pull request #224 from niphlod/enhancement/sessions2trash.py
session2trash.py: easier to use within a module, e.g. in the scheduler
2013-09-24 11:41:29 -07:00
Massimo
5f9d8a9cc2 no more if len(dpost) 2013-09-24 13:37:25 -05:00
Massimo
b67141b1ef fixed problem with ENABLED/DISABLED, issue 1689 2013-09-24 13:29:54 -05:00
Michele Comitini
9f69b9aa42 still support for python2.5 2013-09-24 20:01:51 +02:00
Michele Comitini
18cdade705 added support for python2.5 2013-09-24 18:37:10 +02:00
Michele Comitini
7eb8a604bd update pbkdf2_ctypes.py to upstream 2013-09-24 18:03:49 +02:00
Mariano Reingart
d55470f753 fixed line not found issues in set breakpoint (linecache patch, used by the debugger) 2013-09-24 02:52:01 -03:00
mdipierro
c4042dc475 improved es.py, thanks mcamel and Vladyslav 2013-09-23 16:33:06 -05:00
niphlod
0688c86dee easier to use within a module, e.g. in the scheduler 2013-09-23 22:41:37 +02:00
mdipierro
d111f331ca fixed issue 1196:add language subfolders, thanks jamarcer 2013-09-23 14:54:29 -05:00
mdipierro
f622f2936a Merge pull request #223 from robertop23/master
Fixes and improvements in admin editor
2013-09-23 08:35:05 -07:00
mdipierro
4e017d3ffa Merge pull request #222 from charleslaw/master
Various Minor Auth Additions
2013-09-23 08:34:28 -07:00
Roberto Perdomo
2ebf0d12ed Fix lost flash message in case of error when save editor (crtl-s). Change Esc to Ctrl-Esc to exit from Fullscreen mode, because this cause collision with the Vim mode (Esc key). Add a select into the config button to select 'default', 'vim' or 'emacs' editor 2013-09-22 18:36:28 -04:30
mdipierro
d547a9d6ea added nl, es plural rules, thanks Vladyslav 2013-09-22 10:10:28 -05:00
mdipierro
afdb028070 R-2.6.4 2013-09-21 20:42:19 -05:00
mdipierro
80d4615f32 R-2.6.4 2013-09-21 20:24:31 -05:00
Charles Law
cb7753af2a add a hook for a pre registration message 2013-09-21 19:48:21 -04:00
mdipierro
5a12a7fb31 manually committed pull 221, update vars only if FieldStorage holds actually something, thanks Niphlod 2013-09-21 18:15:27 -05:00
Charles Law
d4bceef5b4 Send username/email in verification email 2013-09-21 18:47:41 -04:00
Charles Law
931082f426 add password class to 2nd password registration field 2013-09-21 18:35:34 -04:00
Charles Law
333fb4ebd8 allow for a multi_login option that accepts both emails and usernames 2013-09-21 18:21:34 -04:00
Charles Law
27b6319f2e have more descriptive messages for username issues 2013-09-21 15:42:10 -04:00
Charles Law
70d8b2d755 show message when an email is already taken 2013-09-21 15:16:06 -04:00
mdipierro
17c10b8a45 things got out of sync 2013-09-20 21:28:26 -05:00
mdipierro
f8e2c8e319 new validator IS_LIST_OF_EMAILS 2013-09-20 21:17:05 -05:00
mdipierro
9ea82fdaaf fixed issue 1686:admin editor files menu hidden when codemirror is in fullscreen mode, thanks Paolo Caruccio 2013-09-20 20:57:29 -05:00
mdipierro
3d01a83c85 Merge pull request #220 from bunnyhugdev/master
Edited cookie handling code when using a db to store sessions
2013-09-20 12:51:49 -07:00
Joel Rathgaber
13f8b1a10c Edited cookie handling code when using a db to store sessions
- Session id cookie is always sent back to client in response
- When no cookie is sent in as a request, a new session id is created
2013-09-20 13:29:50 -06:00
Massimo
f78e172eda fixed issue 1673, propagation for format in archive tables 2013-09-20 12:47:15 -05:00
mdipierro
bd452f90b2 session._fixup_before_save 2013-09-20 08:36:52 -05:00
mdipierro
2b1f150f02 relaxed REST conditions 2013-09-19 22:18:45 -05:00
mdipierro
e7a9457249 fixed problem with widget and list:string 2013-09-19 22:03:37 -05:00
mdipierro
d3ab2e73d5 support for driver mysql.connector, thank you Josiel Santos 2013-09-19 21:44:12 -05:00
mdipierro
860f40ca63 added support for 3letter language files, issue 1680, thanks Fran 2013-09-19 21:33:31 -05:00
mdipierro
59a7db56a4 fixed major problem with persistance of session.flash 2013-09-19 20:51:11 -05:00
mdipierro
01e5107a96 possible fix to issues 1682, REST and DELETE 2013-09-19 18:33:27 -05:00
mdipierro
8765dbbe0f an attempt to fix 1685 2013-09-19 18:26:35 -05:00
mdipierro
d125b0b95b expires can be str or datetime 2013-09-19 18:03:35 -05:00
mdipierro
1d2fc4b8f5 simpler logic in parse POST but not functional difference 2013-09-19 17:47:29 -05:00
mdipierro
146ea115bf Merge pull request #219 from niphlod/enhancement/ajax_page_notarget
fixed issue when target is none. removed useless file in admin/static/js
2013-09-19 14:44:03 -07:00
niphlod
4f44188997 fixed issue when target is not none. removed useless file in admin/static/js 2013-09-19 21:52:45 +02:00
mdipierro
ac5fb303eb Merge pull request #218 from mpranjic/masterfix
startswith, endswith and contains for upload fields
2013-09-19 12:10:07 -07:00
mdipierro
31a14997f8 Merge pull request #216 from ilvalle/ajax_title
Set document title when an ajax fragment has got a <title> element
2013-09-19 12:09:01 -07:00
mpranjic
4cd4ff2c5e startswith, endswith and contains for upload fields 2013-09-19 10:58:23 +02:00
Massimo
26ef508966 added some missing files, is admin/static/js/jquery-1.10.0.min.map correct? 2013-09-18 14:37:28 -05:00
Paolo
28b4badb9a concatenation of filter and find for a better <title> discovery 2013-09-18 17:33:54 +02:00
mdipierro
8e2e2420b0 fixed style of edit in admin 2013-09-18 10:18:31 -05:00
mdipierro
67349627f4 Merge pull request #214 from niphlod/fix/admin_emmet
fixes keyboard shortcuts in admin when modifying js or css files
2013-09-18 08:05:49 -07:00
mdipierro
cfe825f94a Merge pull request #213 from spametki/master
Fix imap insert multipart detection
2013-09-18 08:05:05 -07:00
mdipierro
53e79915fa skip virtual fields on AttributeError 2013-09-18 08:29:31 -05:00
ilvalle
9fb5f688ed Set document title if an ajax fragment has a <title> element 2013-09-18 09:15:06 +02:00
mdipierro
c2cdae0615 new setup_exe.py, thanks Niphlod 2013-09-17 08:31:01 -05:00
mdipierro
2516bb59a1 fixed issue 1679:auth.navbar() duplicates first link if mode is 'default', thanks wkl 2013-09-16 08:55:43 -05:00
mdipierro
13c78fae58 R-2.6.3 2013-09-15 12:00:13 -05:00
mdipierro
91c0a31800 R-2.6.3 2013-09-15 11:51:01 -05:00
mdipierro
277137c8e6 R-2.6.3 2013-09-15 11:48:32 -05:00
mdipierro
4556a355a2 fixed a problem with CRYPT password length 2013-09-15 11:46:46 -05:00
mdipierro
7dafb07438 added a extra level of protection for long passwords, even if IS_LENGTH validator is missing 2013-09-15 09:40:15 -05:00
niphlod
3c8e7a1364 fixes keyboard shortcuts in admin when modifying js or css files 2013-09-15 11:23:58 +02:00
spametki
921cd46c10 Fix imap insert multipart detection 2013-09-14 16:03:41 -03:00
357 changed files with 8873 additions and 27183 deletions

1
.gitignore vendored
View File

@@ -55,3 +55,4 @@ applications/admin/cron/cron.master
HOWTO-web2py-devel
*.sublime-project
*.sublime-workspace
.idea/*

View File

@@ -1,7 +1,6 @@
language: python
python:
- '2.5'
- '2.6'
- '2.7'
- 'pypy'

View File

@@ -1,4 +1,35 @@
## 2.6.1
## 2.8.1
- no more winservice (use nssm instead)
- better imap support in DAL
- db().select().as_tree()
- bootstrap 2.3.2
- codemirror 3.19
- improved mongoDB support, thanks Alan
- suport for wiki custom render function
- Wiki(...groups=['x','y']) allows bypassing default permissions
- fixed websocket_messaging.py to support newer Tornado
- NDB support for GAE, thanks Quint
- fixed major concurrecy issue with MEMDB
- blocked generic.jsonp for security reasons
- many bug fixes, thanks Niphlod, Michele, Anthony, Tim, and many others.
## 2.7.1 - 2.7.4
- jQuery 1.10.2
- codemirror 3.18, thanks Paolo
- namespaces in T("Welcome", ns="namespace"), thanks jamarcer (experimental)
- more Auth options, thanks Charles
- more admin configuration, thanks Roberto
- new gluon.contrib.strip.StripeForm for PCI compliant payments
- webclient can hendle lists, thanks Yair
- allows SQLFORM.grid(...,ignore_common_filters=True)
- more translations, thanks Vladyslav
- better session2trash.py, works with scheduler, thanks niphlod
- fixed problem with ENABLED/DISABLED
- many bug fixes, thanks niphlod, michele, anthony, roberto, tim, and others
## 2.6.1 - 2.6.4
Attention all users: For pre 2.6 applications to work with web2py >=2.6, you must copy static/js/web2py.js, controllers/appadmin.py, and views/appadmin.html from the welcome app to your own apps (all of them).
@@ -38,6 +69,8 @@ Attention MySQL users: The length of string fields changed from 255 to 512 bytes
- speedup for define_table, thanks Michele
- settings.cfg to admin, thanks Paolo
- many bugs fixed, thanks Niphlod, Michele, Roberto, Jonathan, and many others
- 2.6,3 specifically fixed a possible DoS vulnerability
- 2.6.4 specifically fixes major problem introduced in 2.6.1 with session logic
## 2.5.2

View File

@@ -30,7 +30,7 @@ update:
echo "remember that pymysql was tweaked"
src:
### Use semantic versioning
echo 'Version 2.6.2-stable+timestamp.'`date +%Y.%m.%d.%H.%M.%S` > VERSION
echo 'Version 2.8.1-stable+timestamp.'`date +%Y.%m.%d.%H.%M.%S` > VERSION
### rm -f all junk files
make clean
### clean up baisc apps
@@ -81,6 +81,7 @@ app:
cp -r applications/examples ../web2py_osx/web2py/web2py.app/Contents/Resources/applications
cp applications/__init__.py ../web2py_osx/web2py/web2py.app/Contents/Resources/applications
cd ../web2py_osx; zip -r web2py_osx.zip web2py
mv ../web2py_osx/web2py_osx.zip .
win:
python2.7 -c 'import compileall; compileall.compile_dir("gluon/")'

View File

@@ -1 +1 @@
Version 2.6.2-stable+timestamp.2013.09.13.17.43.10
Version 2.8.1-stable+timestamp.2013.11.27.13.52.50

View File

@@ -33,7 +33,7 @@ class Servers:
@staticmethod
def wsgiref(app, address, **options): # pragma: no cover
from wsgiref.simple_server import make_server, WSGIRequestHandler
options = {}
class QuietHandler(WSGIRequestHandler):
def log_request(*args, **kw):
pass
@@ -71,6 +71,7 @@ class Servers:
@staticmethod
def paste(app, address, **options):
options = {}
from paste import httpserver
from paste.translogger import TransLogger
httpserver.serve(app, host=address[0], port=address[1], **options)
@@ -90,10 +91,12 @@ class Servers:
@staticmethod
def gevent(app, address, **options):
options = options['options']
workers = options.workers
from gevent import pywsgi
from gevent.pool import Pool
pywsgi.WSGIServer(address, app, spawn='workers' in options and Pool(
int(options.workers)) or 'default').serve_forever()
pywsgi.WSGIServer(address, app, spawn=workers and Pool(
int(options.workers)) or 'default', log=None).serve_forever()
@staticmethod
def bjoern(app, address, **options):
@@ -130,6 +133,7 @@ class Servers:
@staticmethod
def gunicorn(app, address, **options):
options = {}
from gunicorn.app.base import Application
config = {'bind': "%s:%d" % address}
config.update(options)
@@ -176,27 +180,6 @@ class Servers:
s = wsgi.WSGIServer(callable=app, bind="%s:%d" % address)
s.start()
def run(servername, ip, port, softcron=True, logging=False, profiler=None):
if servername == 'gevent':
from gevent import monkey
monkey.patch_all()
elif servername == 'eventlet':
import eventlet
eventlet.monkey_patch()
import gluon.main
if logging:
application = gluon.main.appfactory(wsgiapp=gluon.main.wsgibase,
logfilename='httpserver.log',
profiler_dir=profiler)
else:
application = gluon.main.wsgibase
if softcron:
from gluon.settings import global_settings
global_settings.web2py_crontype = 'soft'
getattr(Servers, servername)(application, (ip, int(port)))
def mongrel2_handler(application, conn, debug=False):
"""
@@ -303,6 +286,30 @@ def mongrel2_handler(application, conn, debug=False):
req, data, code=code, status=status, headers=headers)
def run(servername, ip, port, softcron=True, logging=False, profiler=None,
options=None):
if servername == 'gevent':
from gevent import monkey
monkey.patch_all()
elif servername == 'eventlet':
import eventlet
eventlet.monkey_patch()
import gluon.main
if logging:
application = gluon.main.appfactory(wsgiapp=gluon.main.wsgibase,
logfilename='httpserver.log',
profiler_dir=profiler)
else:
application = gluon.main.wsgibase
if softcron:
from gluon.settings import global_settings
global_settings.web2py_crontype = 'soft'
getattr(Servers, servername)(application, (ip, int(port)), options=options)
def main():
usage = "python anyserver.py -s tornado -i 127.0.0.1 -p 8000 -l -P"
try:
@@ -339,14 +346,15 @@ def main():
help='port number')
parser.add_option('-w',
'--workers',
default='',
default=None,
dest='workers',
help='number of workers number')
(options, args) = parser.parse_args()
print 'starting %s on %s:%s...' % (
options.server, options.ip, options.port)
run(options.server, options.ip, options.port,
logging=options.logging, profiler=options.profiler_dir)
logging=options.logging, profiler=options.profiler_dir,
options=options)
if __name__ == '__main__':
main()

View File

@@ -54,7 +54,7 @@ elif (request.application == 'admin' and not session.authorized) or \
redirect(URL('admin', 'default', 'index',
vars=dict(send=URL(args=request.args, vars=request.vars))))
else:
response.subtitle = 'Database Administration (appadmin)'
response.subtitle = T('Database Administration (appadmin)')
menu = True
ignore_rw = True
@@ -186,6 +186,10 @@ def select():
import re
db = get_database(request)
dbname = request.args[0]
try:
is_imap = db._uri.startswith("imap://")
except (KeyError, AttributeError, TypeError):
is_imap = False
regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>\d+)')
if len(request.args) > 1 and hasattr(db[request.args[1]], '_primarykey'):
regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>.+)')
@@ -203,7 +207,15 @@ def select():
else:
start = 0
nrows = 0
stop = start + 100
step = 100
fields = []
if is_imap:
step = 3
stop = start + step
table = None
rows = []
orderby = request.vars.orderby
@@ -235,21 +247,27 @@ def select():
if match:
table = match.group('table')
try:
nrows = db(query).count()
nrows = db(query, ignore_common_filters=True).count()
if form.vars.update_check and form.vars.update_fields:
db(query).update(**eval_in_global_env('dict(%s)'
% form.vars.update_fields))
db(query, ignore_common_filters=True).update(
**eval_in_global_env('dict(%s)' % form.vars.update_fields))
response.flash = T('%s %%{row} updated', nrows)
elif form.vars.delete_check:
db(query).delete()
db(query, ignore_common_filters=True).delete()
response.flash = T('%s %%{row} deleted', nrows)
nrows = db(query).count()
nrows = db(query, ignore_common_filters=True).count()
if is_imap:
fields = [db[table][name] for name in
("id", "uid", "created", "to",
"sender", "subject")]
if orderby:
rows = db(query, ignore_common_filters=True).select(limitby=(
start, stop), orderby=eval_in_global_env(orderby))
rows = db(query, ignore_common_filters=True).select(
*fields, limitby=(start, stop),
orderby=eval_in_global_env(orderby))
else:
rows = db(query, ignore_common_filters=True).select(
limitby=(start, stop))
*fields, limitby=(start, stop))
except Exception, e:
import traceback
tb = traceback.format_exc()
@@ -278,11 +296,12 @@ def select():
table=table,
start=start,
stop=stop,
step=step,
nrows=nrows,
rows=rows,
query=request.vars.query,
formcsv=formcsv,
tb=tb,
tb=tb
)
@@ -577,8 +596,8 @@ def bg_graph_model():
graph.add_edge(n1, n2, color="#4C4C4C", label='')
graph.layout()
#return graph.draw(format='png', prog='dot')
if not request.args:
response.headers['Content-Type'] = 'image/png'
return graph.draw(format='png', prog='dot')
else:
response.headers['Content-Disposition']='attachment;filename=graph.%s'%request.args(0)

View File

@@ -1,6 +1,7 @@
# coding: utf8
EXPERIMENTAL_STUFF = True
MAXNFILES = 1000
if EXPERIMENTAL_STUFF:
if is_mobile:
@@ -108,7 +109,7 @@ def index():
if session.authorized:
redirect(send)
elif request.vars.password:
if verify_password(request.vars.password):
if verify_password(request.vars.password[:1024]):
session.authorized = True
login_record(True)
@@ -197,7 +198,7 @@ def site():
class IS_VALID_APPNAME(object):
def __call__(self, value):
if not re.compile('\w+').match(value):
if not re.compile('^\w+$').match(value):
return (value, T('Invalid application name'))
if not request.vars.overwrite and \
os.path.exists(os.path.join(apath(r=request), value)):
@@ -230,7 +231,7 @@ def site():
redirect(URL('design', args=appname))
else:
session.flash = \
DIV(T('unable to create application "%s"' % appname),
DIV(T('unable to create application "%s"', appname),
PRE(error))
redirect(URL(r=request))
@@ -341,7 +342,7 @@ def pack():
response.headers['Content-Disposition'] = disposition
return safe_read(filename, 'rb')
else:
session.flash = T('internal error: %s' % e)
session.flash = T('internal error: %s', e)
redirect(URL('site'))
def pack_plugin():
@@ -375,7 +376,7 @@ def pack_custom():
response.headers['Content-Disposition'] = disposition
return safe_read(filename, 'rb')
else:
session.flash = T('internal error: %s' % e)
session.flash = T('internal error: %s', e)
redirect(URL(args=request.args))
def ignore(fs):
return [f for f in fs if not (
@@ -494,6 +495,7 @@ def enable():
if is_gae:
return SPAN(T('Not supported'), _style='color:yellow')
elif os.path.exists(filename):
os.unlink(filename)
return SPAN(T('Disable'), _style='color:green')
else:
safe_open(filename, 'wb').write('disabled: True\ntime-disabled: %s' % request.now)
@@ -562,36 +564,30 @@ def edit():
# Load json only if it is ajax edited...
app = get_app(request.vars.app)
app_path = apath(app, r=request)
editor_defaults={'theme':'web2py'}
editor_defaults={'theme':'web2py', 'editor': 'default', 'closetag': 'true', 'codefolding': 'false', 'tabwidth':'4', 'indentwithtabs':'false', 'linenumbers':'true', 'highlightline':'true'}
config = Config(os.path.join(request.folder, 'settings.cfg'),
section='editor', default_values=editor_defaults)
preferences = config.read()
if not(request.ajax):
if not(request.ajax) and not(is_mobile):
# return the scaffolding, the rest will be through ajax requests
response.title = T('Editing %s' % app)
editarea_preferences = {}
editarea_preferences['FONT_SIZE'] = '10'
editarea_preferences['FULL_SCREEN'] = 'false'
editarea_preferences['ALLOW_TOGGLE'] = 'true'
editarea_preferences['REPLACE_TAB_BY_SPACES'] = '4'
editarea_preferences['DISPLAY'] = 'onload'
for key in editarea_preferences:
if key in globals():
editarea_preferences[key] = globals()[key]
return response.render ('default/edit.html', dict(app=request.args[0], editor_settings=preferences, editarea_preferences=editarea_preferences))
response.title = T('Editing %s') % app
return response.render ('default/edit.html', dict(app=app, editor_settings=preferences))
# show settings tab and save prefernces
if 'settings' in request.vars:
if request.post_vars: #save new preferences
if config.save(request.post_vars.items()):
post_vars = request.post_vars.items()
# Since unchecked checkbox are not serialized, we must set them as false by hand to store the correct preference in the settings
post_vars+= [(opt, 'false') for opt in editor_defaults if opt not in request.post_vars ]
if config.save(post_vars):
response.headers["web2py-component-flash"] = T('Preferences saved correctly')
else:
response.headers["web2py-component-flash"] = T('Preferences saved on session only')
response.headers["web2py-component-command"] = "update_theme('%s'); jQuery('a[href=#editor_settings] button.close').click();" % config.read()['theme']
response.headers["web2py-component-command"] = "update_editor(%s);$('a[href=#editor_settings] button.close').click();" % response.json(config.read())
return
else:
details = {'filename':'settings', 'id':'editor_settings', 'force': False}
details = {'realfilename':'settings', 'filename':'settings', 'id':'editor_settings', 'force': False}
details['plain_html'] = response.render('default/editor_settings.html', {'editor_settings':preferences})
return response.json(details)
@@ -599,12 +595,12 @@ def edit():
# Load json only if it is ajax edited...
app = get_app(request.vars.app)
filename = '/'.join(request.args)
response.title = request.args[-1]
realfilename = request.args[-1]
if request.vars.app:
path = abspath(filename)
else:
path = apath(filename, r=request)
# Try to discover the file type
# Try to discover the file type
if filename[-3:] == '.py':
filetype = 'python'
elif filename[-5:] == '.html':
@@ -614,7 +610,7 @@ def edit():
elif filename[-4:] == '.css':
filetype = 'css'
elif filename[-3:] == '.js':
filetype = 'js'
filetype = 'javascript'
else:
filetype = 'html'
@@ -700,7 +696,6 @@ def edit():
offset and ' ' +
T('at char %s', offset) or '',
PRE(str(e)))
if data_or_revert and request.args[1] == 'modules':
# Lets try to reload the modules
try:
@@ -755,7 +750,9 @@ def edit():
return response.json({'file_hash': file_hash, 'saved_on': saved_on, 'functions': functions, 'controller': controller, 'application': request.args[0], 'highlight': highlight})
else:
file_details = dict(app=request.args[0],
editor_settings=preferences,
filename=filename,
realfilename=realfilename,
filetype=filetype,
data=data,
edit_controller=edit_controller,
@@ -766,10 +763,15 @@ def edit():
view_link=view_link,
editviewlinks=editviewlinks,
id=IS_SLUG()(filename)[0],
force= True if (request.vars.restore or request.vars.revert) else False)
force= True if (request.vars.restore or
request.vars.revert) else False)
plain_html = response.render('default/edit_js.html', file_details)
file_details['plain_html'] = plain_html
return response.json(file_details)
if is_mobile:
return response.render('default.mobile/edit.html',
file_details, editor_settings=preferences)
else:
return response.json(file_details)
def resolve():
@@ -1037,9 +1039,9 @@ def design():
privates.sort()
# Get all static files
MAXNFILES = 1000
statics = listdir(apath('%s/static/' % app, r=request), '[^\.#].*')
statics = [x.replace('\\', '/') for x in statics[:MAXNFILES]]
statics = listdir(apath('%s/static/' % app, r=request), '[^\.#].*',
maxnum = MAXNFILES)
statics = [x.replace(os.path.sep, '/') for x in statics]
statics.sort()
# Get all languages
@@ -1173,8 +1175,9 @@ def plugin():
privates.sort()
# Get all static files
statics = listdir(apath('%s/static/' % app, r=request), '[^\.#].*')
statics = [x.replace('\\', '/') for x in statics]
statics = listdir(apath('%s/static/' % app, r=request), '[^\.#].*',
maxnum = MAXNFILES)
statics = [x.replace(os.path.sep, '/') for x in statics]
statics.sort()
# Get all languages
@@ -1325,7 +1328,8 @@ def create_file():
from gluon import *\n""")[1:]
elif (path[-8:] == '/static/') or (path[-9:] == '/private/'):
if request.vars.plugin and not filename.startswith('plugin_%s/' % request.vars.plugin):
if (request.vars.plugin and
not filename.startswith('plugin_%s/' % request.vars.plugin)):
filename = 'plugin_%s/%s' % (request.vars.plugin, filename)
text = ''
@@ -1791,3 +1795,55 @@ def git_push():
session.flash = T("Push failed, there are unmerged entries in the cache. Resolve merge issues manually and try again.")
redirect(URL('site'))
return dict(app=app, form=form)
def plugins():
app = request.args(0)
from serializers import loads_json
if not session.plugins:
rawlist = urllib.urlopen("http://www.web2pyslices.com/" +
"public/api.json/action/list/content/Package?package" +
"_type=plugin&search_index=false").read()
session.plugins = loads_json(rawlist)
plugins = TABLE(
*[TR(TD(H5(article["article"]["title"]),
A(T("Install"),
_href=URL(c="default",
f="install_plugin",
args=[app,],
vars={"source":
article["package_data"]["download"],
"plugin": article["article"]["title"]}
))),
TD(article["article"]["description"], BR(),
A(T("Plugin page"),
_href="http://www.web2pyslices.com/slice/show/%s/" % \
article["article"]["id"])),
TD(IMG(_src="http://www.web2pyslices.com/download/%s" % \
article["article"]["thumbnail"])))
for article in session.plugins["results"]])
return dict(plugins=plugins, app=request.args(0))
def install_plugin():
app = request.args(0)
source = request.vars.source
plugin = request.vars.plugin
if not (source and app):
raise HTTP(500, T("Invalid request"))
form = SQLFORM.factory()
result = None
if form.process().accepted:
# get w2p plugin
if "web2py.plugin." in source:
filename = "web2py.plugin.%s.w2p" % \
source.split("web2py.plugin.")[-1].split(".w2p")[0]
else:
filename = "web2py.plugin.%s.w2p" % cleanpath(plugin)
if plugin_install(app, urllib.urlopen(source),
request, filename):
session.flash = T('New plugin installed: %s', filename)
else:
session.flash = \
T('unable to create application "%s"', filename)
redirect(URL(f="plugins", args=[app,]))
return dict(form=form, app=app, plugin=plugin, source=source)

View File

@@ -43,14 +43,14 @@ def commit():
app = request.args(0)
path = apath(app, r=request)
repo = hg_repo(path)
form = FORM('Comment:', INPUT(_name='comment', requires=IS_NOT_EMPTY()),
form = FORM(T('Comment:'), INPUT(_name='comment', requires=IS_NOT_EMPTY()),
INPUT(_type='submit', _value=T('Commit')))
if form.accepts(request.vars, session):
oldid = repo[repo.lookup('.')]
addremove(repo)
repo.commit(text=form.vars.comment)
if repo[repo.lookup('.')] == oldid:
response.flash = 'no changes'
response.flash = T('no changes')
try:
files = TABLE(*[TR(file) for file in repo[repo.lookup('.')].files()])
changes = TABLE(TR(TH('revision'), TH('description')))
@@ -75,7 +75,7 @@ def revision():
form = FORM(INPUT(_type='submit', _value=T('Revert')))
if form.accepts(request.vars):
hg.update(repo, revision)
session.flash = "reverted to revision %s" % ctx.rev()
session.flash = T("reverted to revision %s") % ctx.rev()
redirect(URL('default', 'design', args=app))
return dict(
files=ctx.files(),

View File

@@ -7,31 +7,37 @@
'%s %%{row} updated': '%s filas actualizadas',
'%Y-%m-%d': '%Y-%m-%d',
'%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
'(requires internet access, experimental)': '(requiere acceso a internet, experimental)',
'(something like "it-it")': '(algo como "it-it")',
'@markmin\x01(file **gluon/contrib/plural_rules/%s.py** is not found)': '(file **gluon/contrib/plural_rules/%s.py** is not found)',
'@markmin\x01An error occured, please [[reload %s]] the page': 'An error occured, please [[reload %s]] the page',
'@markmin\x01Searching: **%s** %%{file}': 'Searching: **%s** files',
'A new version of web2py is available': 'Hay una nueva versión de web2py disponible',
'A new version of web2py is available: %s': 'Hay una nueva versión de web2py disponible: %s',
'About': 'acerca de',
'About application': 'Acerca de la aplicación',
'additional code for your application': 'código adicional para su aplicación',
'Additional code for your application': 'Additional code for your application',
'admin disabled because no admin password': ' por falta de contraseña',
'Additional code for your application': 'Código adicional para su aplicación',
'admin disabled because no admin password': 'admin deshabilitado por falta de contraseña',
'admin disabled because not supported on google app engine': 'admin deshabilitado, no es soportado en GAE',
'admin disabled because unable to access password file': 'admin deshabilitado, imposible acceder al archivo con la contraseña',
'Admin is disabled because insecure channel': 'Admin deshabilitado, el canal no es seguro',
'Admin is disabled because unsecure channel': 'Admin deshabilitado, el canal no es seguro',
'Admin language': 'Admin language',
'administrative interface': 'administrative interface',
'Admin language': 'Lenguaje de administración',
'administrative interface': 'interfaz administrativa',
'Administrator Password:': 'Contraseña del Administrador:',
'An error occured, please %s the page': 'An error occured, please %s the page',
'An error occured, please %s the page': 'Ha ocurrido un error, por favor %s la página',
'and rename it (required):': 'y renombrela (requerido):',
'and rename it:': ' y renombrelo:',
'App does not exist or you are not authorized': 'App does not exist or you are not authorized',
'appadmin': 'appadmin',
'appadmin is disabled because insecure channel': 'admin deshabilitado, el canal no es seguro',
'application "%s" uninstalled': 'aplicación "%s" desinstalada',
'application %(appname)s installed with md5sum: %(digest)s': 'application %(appname)s installed with md5sum: %(digest)s',
'application compiled': 'aplicación compilada',
'Application exists already': 'Application exists already',
'application is compiled and cannot be designed': 'la aplicación está compilada y no puede ser modificada',
'Application name:': 'Nombre de la aplicación:',
'are not used': 'are not used',
'are not used yet': 'are not used yet',
'Are you sure you want to delete file "%s"?': '¿Está seguro que desea eliminar el archivo "%s"?',
@@ -40,28 +46,35 @@
'Are you sure you want to uninstall application "%s"': '¿Está seguro que desea desinstalar la aplicación "%s"',
'Are you sure you want to uninstall application "%s"?': '¿Está seguro que desea desinstalar la aplicación "%s"?',
'Are you sure you want to upgrade web2py now?': '¿Está seguro que desea actualizar web2py ahora?',
'Are you sure?': 'Are you sure?',
'arguments': 'argumentos',
'at char %s': 'at char %s',
'at line %s': 'at line %s',
'at char %s': 'en el caracter %s',
'at line %s': 'en la línea %s',
'ATTENTION: Login requires a secure (HTTPS) connection or running on localhost.': 'ATENCION: Inicio de sesión requiere una conexión segura (HTTPS) o localhost.',
'ATTENTION: TESTING IS NOT THREAD SAFE SO DO NOT PERFORM MULTIPLE TESTS CONCURRENTLY.': 'ATENCION: NO EJECUTE VARIAS PRUEBAS SIMULTANEAMENTE, NO SON THREAD SAFE.',
'ATTENTION: you cannot edit the running application!': 'ATENCION: no puede modificar la aplicación que se ejecuta!',
'Autocomplete': 'Autocomplete',
'Autocomplete Python Code': 'Autocompletar código Python',
'Available databases and tables': 'Bases de datos y tablas disponibles',
'back': 'atrás',
'Back to the plugins list': 'Back to the plugins list',
'breakpoint': 'breakpoint',
'breakpoints': 'breakpoints',
'browse': 'buscar',
'cache': 'cache',
'cache, errors and sessions cleaned': 'cache, errores y sesiones eliminados',
'can be a git repo': 'puede ser un repositorio git',
'Cancel': 'Cancel',
'Cannot be empty': 'No puede estar vacío',
'Cannot compile: there are errors in your app. Debug it, correct errors and try again.': 'No se puede compilar: hay errores en su aplicación. Depure, corrija errores y vuelva a intentarlo.',
'Cannot compile: there are errors in your app:': 'No se puede compilar: hay errores en su aplicación:',
'cannot create file': 'no es posible crear archivo',
'cannot upload file "%(filename)s"': 'no es posible subir archivo "%(filename)s"',
'Change admin password': 'cambie contraseña admin',
'change editor settings': 'cambiar la configuración del editor',
'Change Password': 'Cambie Contraseña',
'check all': 'marcar todos',
'Check for upgrades': 'buscar actualizaciones',
'Check to delete': 'Marque para eliminar',
'Checking for upgrades...': 'Buscando actulizaciones...',
'Clean': 'limpiar',
@@ -69,28 +82,30 @@
'click here for the administrative interface': 'haga clic aquí para usar la interfaz administrativa',
'Click row to expand traceback': 'Click row to expand traceback',
'click to check for upgrades': 'haga clic para buscar actualizaciones',
'click to open': 'click to open',
'click to open': 'click para abrir',
'Client IP': 'IP del Cliente',
'code': 'código',
'Code listing': 'Code listing',
'collapse/expand all': 'collapse/expand all',
'commit (mercurial)': 'commit (mercurial)',
'Code listing': 'Listado de código',
'collapse/expand all': 'contraer/expandir todo',
'commit (mercurial)': 'confirmar (mercurial)',
'Compile': 'compilar',
'compiled application removed': 'aplicación compilada removida',
'continue': 'continue',
'continue': 'continuar',
'Controllers': 'Controladores',
'controllers': 'controladores',
'Count': 'Count',
'Create': 'crear',
'Create': 'Crear',
'create file with filename:': 'cree archivo con nombre:',
'Create new application using the Wizard': 'Create new application using the Wizard',
'Create new application using the Wizard': 'Crear nueva aplicación utilizando el asistente',
'create new application:': 'nombre de la nueva aplicación:',
'Create new simple application': 'Cree una nueva aplicación',
'Create/Upload': 'Create/Upload',
'created by': 'creado por',
'crontab': 'crontab',
'Current request': 'Solicitud en curso',
'Current response': 'Respuesta en curso',
'Current session': 'Sesión en curso',
'currently running': 'currently running',
'currently saved or': 'actualmente guardado o',
'customize me!': 'Adaptame!',
'data uploaded': 'datos subidos',
@@ -105,37 +120,56 @@
'delete': 'eliminar',
'delete all checked': 'eliminar marcados',
'delete plugin': 'eliminar plugin',
'Delete this file (you will be asked to confirm deletion)': 'Delete this file (you will be asked to confirm deletion)',
'Delete this file (you will be asked to confirm deletion)': 'Elimine este fichero (se le pedirá confirmación)',
'Delete:': 'Elimine:',
'Deploy': 'Deploy',
'Deploy on Google App Engine': 'Instale en Google App Engine',
'Deploy to OpenShift': 'Instale en OpenShift',
'Description': 'Descripción',
'design': 'modificar',
'DESIGN': 'DISEÑO',
'Design for': 'Diseño para',
'Detailed traceback description': 'Detailed traceback description',
'details': 'detalles',
'direction: ltr': 'direction: ltr',
'Disable': 'Deshabilitar',
'docs': 'docs',
'Done!': 'Done!',
'done!': 'listo!',
'download layouts': 'download layouts',
'download plugins': 'download plugins',
'Download': 'Descargar',
'download files via http:': 'descargar archivos via http:',
'download layouts': 'descargar layouts',
'download plugins': 'descargar plugins',
'E-mail': 'Correo electrónico',
'EDIT': 'EDITAR',
'Edit': 'editar',
'Edit application': 'Editar aplicación',
'edit controller': 'editar controlador',
'edit controller:': 'edit controller:',
'Edit current record': 'Edite el registro actual',
'Edit Profile': 'Editar Perfil',
'edit views:': 'editar vistas:',
'Editing %s': 'Editing %s',
'Editing file': 'Editando archivo',
'Editing file "%s"': 'Editando archivo "%s"',
'Editing Language file': 'Editando archivo de lenguaje',
'Editing myclientapi': 'Editing myclientapi',
'Editing myemail': 'Editing myemail',
'Editing rbare': 'Editing rbare',
'Editing ul': 'Editing ul',
'Enterprise Web Framework': 'Armazón Empresarial para Internet',
'Error': 'Error',
'Error logs for "%(app)s"': 'Bitácora de errores en "%(app)s"',
'Error snapshot': 'Error snapshot',
'Error ticket': 'Error ticket',
'Errors': 'errores',
'Errors in form, please check it out.': 'Errors in form, please check it out.',
'Exception instance attributes': 'Atributos de la instancia de Excepción',
'Exit Fullscreen': 'Exit Fullscreen',
'Expand Abbreviation': 'Expand Abbreviation',
'export as csv file': 'exportar como archivo CSV',
'exposes': 'expone',
'exposes:': 'exposes:',
'exposes:': 'expone:',
'extends': 'extiende',
'failed to compile file because:': 'failed to compile file because:',
'failed to reload module': 'recarga del módulo ha fallado',
@@ -151,22 +185,28 @@
'file saved on %(time)s': 'archivo guardado %(time)s',
'file saved on %s': 'archivo guardado %s',
'filter': 'filter',
'Find Next': 'Find Next',
'Find Previous': 'Find Previous',
'Find Next': 'Buscar próximo',
'Find Previous': 'Bucar anterior',
'First name': 'Nombre',
'Frames': 'Frames',
'Functions with no doctests will result in [passed] tests.': 'Funciones sin doctests equivalen a pruebas [aceptadas].',
'Globals##debug': 'Globals',
'graph model': 'graph model',
'Group ID': 'ID de Grupo',
'Hello World': 'Hola Mundo',
'Help': 'ayuda',
'here': 'here',
'htmledit': 'htmledit',
'If the report above contains a ticket number it indicates a failure in executing the controller, before any attempt to execute the doctests. This is usually due to an indentation error or an error outside function code.\nA green title indicates that all tests (if defined) passed. In this case test results are not shown.': 'Si el reporte anterior contiene un número de tiquete este indica un falla en la ejecución del controlador, antes de cualquier intento de ejecutat doctests. Esto generalmente se debe a un error en la indentación o un error por fuera del código de la función.\r\nUn titulo verde indica que todas las pruebas pasaron (si existen). En dicho caso los resultados no se muestran.',
'Image': 'Image',
'Import/Export': 'Importar/Exportar',
'includes': 'incluye',
'insert new': 'inserte nuevo',
'insert new %s': 'inserte nuevo %s',
'inspect attributes': 'inspect attributes',
'Install': 'instalar',
'Installation of %(plugin)s for %(app)s': 'Installation of %(plugin)s for %(app)s',
'Installation of %(plugin)s for %(app)s app': 'Installation of %(plugin)s for %(app)s app',
'Installed applications': 'Aplicaciones instaladas',
'Interaction at %s line %s': 'Interaction at %s line %s',
'Interactive console': 'Interactive console',
@@ -175,10 +215,13 @@
'Invalid action': 'Acción inválida',
'Invalid email': 'Correo inválido',
'invalid password': 'contraseña inválida',
'invalid password.': 'invalid password.',
'Invalid Query': 'Consulta inválida',
'invalid request': 'solicitud inválida',
'Invalid request': 'Invalid request',
'invalid ticket': 'tiquete inválido',
'Key bindings': 'Key bindings',
'Key bindings for ZenCoding Plugin': 'Key bindings for ZenCoding Plugin',
'language file "%(filename)s" created/updated': 'archivo de lenguaje "%(filename)s" creado/actualizado',
'Language files (static strings) updated': 'Archivos de lenguaje (cadenas estáticas) actualizados',
'languages': 'lenguajes',
@@ -187,14 +230,17 @@
'Last name': 'Apellido',
'Last saved on:': 'Guardado en:',
'License for': 'Licencia para',
'lists by ticket': 'lists by ticket',
'loading...': 'cargando...',
'locals': 'locals',
'Locals##debug': 'Locals',
'Login': 'Inicio de sesión',
'login': 'inicio de sesión',
'Login to the Administrative Interface': 'Inicio de sesión para la Interfaz Administrativa',
'Logout': 'fin de sesión',
'Lost Password': 'Contraseña perdida',
'manage': 'manage',
'manage': 'gestionar',
'Manage': 'Gestionar',
'merge': 'combinar',
'Models': 'Modelos',
'models': 'modelos',
@@ -202,40 +248,55 @@
'modules': 'módulos',
'Name': 'Nombre',
'new application "%s" created': 'nueva aplicación "%s" creada',
'New application wizard': 'Asistente para nueva aplicación',
'new plugin installed': 'nuevo plugin instalado',
'New plugin installed: web2py.plugin.attachment.w2p': 'New plugin installed: web2py.plugin.attachment.w2p',
'New plugin installed: web2py.plugin.dialog.w2p': 'New plugin installed: web2py.plugin.dialog.w2p',
'New plugin installed: web2py.plugin.math2py.w2p': 'New plugin installed: web2py.plugin.math2py.w2p',
'New plugin installed: web2py.plugin.timezone.w2p': 'New plugin installed: web2py.plugin.timezone.w2p',
'New Record': 'Registro nuevo',
'new record inserted': 'nuevo registro insertado',
'New simple application': 'Nueva aplicación',
'next': 'next',
'next 100 rows': '100 filas siguientes',
'NO': 'NO',
'No databases in this application': 'No hay bases de datos en esta aplicación',
'No Interaction yet': 'No Interaction yet',
'no match': 'no encontrado',
'no package selected': 'no package selected',
'No ticket_storage.txt found under /private folder': 'No ticket_storage.txt found under /private folder',
'online designer': 'online designer',
'or alternatively': 'or alternatively',
'Or Get from URL:': 'O obtener desde una URL:',
'or import from csv file': 'o importar desde archivo CSV',
'or provide app url:': 'o provea URL de la aplicación:',
'or provide application url:': 'o provea URL de la aplicación:',
'Origin': 'Origen',
'Original/Translation': 'Original/Traducción',
'Overwrite installed app': 'sobreescriba aplicación instalada',
'Overwrite installed app': 'sobreescriba la aplicación instalada',
'Pack all': 'empaquetar todo',
'Pack compiled': 'empaquete compiladas',
'Pack custom': 'empaquetar personalizado',
'pack plugin': 'empaquetar plugin',
'PAM authenticated user, cannot change password here': 'usuario autenticado por PAM, no puede cambiar la contraseña aquí',
'Password': 'Contraseña',
'password changed': 'contraseña cambiada',
'Peeking at file': 'Visualizando archivo',
'Please': 'Please',
'Plugin': 'Plugin',
'plugin "%(plugin)s" deleted': 'plugin "%(plugin)s" eliminado',
'Plugin "%s" in application': 'Plugin "%s" en aplicación',
'Plugin page': 'Plugin page',
'plugins': 'plugins',
'Plugins': 'Plugins',
'Plural-Forms:': 'Plural-Forms:',
'Powered by': 'Este sitio usa',
'previous 100 rows': '100 filas anteriores',
'Private files': 'Private files',
'private files': 'private files',
'Private files': 'Archivos privados',
'private files': 'archivos privados',
'Project Progress': 'Project Progress',
'Query:': 'Consulta:',
'Rapid Search': 'Rapid Search',
'record': 'registro',
'record does not exist': 'el registro no existe',
'record id': 'id de registro',
@@ -244,11 +305,14 @@
'Register': 'Registrese',
'Registration key': 'Contraseña de Registro',
'reload': 'reload',
'Reload routes': 'Reload routes',
'Remove compiled': 'eliminar compiladas',
'Removed Breakpoint on %s at line %s': 'Removed Breakpoint on %s at line %s',
'Replace': 'Replace',
'Replace All': 'Replace All',
'Removed Breakpoint on %s at line %s': 'Eliminado punto de ruptura en %s en la línea %s',
'Replace': 'Reemplazar',
'Replace All': 'Reemplazar todos',
'request': 'request',
'Resolve Conflict file': 'archivo Resolución de Conflicto',
'response': 'response',
'restore': 'restaurar',
'return': 'return',
'revert': 'revertir',
@@ -256,65 +320,77 @@
'Rows in table': 'Filas en la tabla',
'Rows selected': 'Filas seleccionadas',
'rules are not defined': 'rules are not defined',
'Run tests in this file': 'Run tests in this file',
"Run tests in this file (to run all files, you may also use the button labelled 'test')": "Run tests in this file (to run all files, you may also use the button labelled 'test')",
'Running on %s': 'Running on %s',
'Save': 'Save',
'save': 'guardar',
'Save file:': 'Save file:',
'Save via Ajax': 'Save via Ajax',
'Save file:': 'Guardar:',
'Save file: %s': 'Guardar: %s',
'Save via Ajax': 'Guardar via Ajax',
'Saved file hash:': 'Hash del archivo guardado:',
'selected': 'seleccionado(s)',
'session': 'session',
'session expired': 'sesión expirada',
'Set Breakpoint on %s at line %s: %s': 'Set Breakpoint on %s at line %s: %s',
'Set Breakpoint on %s at line %s: %s': 'Establecer punto de ruptura en %s en la línea %s: %s',
'shell': 'shell',
'Site': 'sitio',
'some files could not be removed': 'algunos archivos no pudieron ser removidos',
'Start searching': 'Start searching',
'Start searching': 'Iniciar búsqueda',
'Start wizard': 'Iniciar asistente',
'state': 'estado',
'static': 'estáticos',
'Static': 'Static',
'static': 'estáticos',
'Static files': 'Archivos estáticos',
'step': 'step',
'stop': 'stop',
'submit': 'enviar',
'successful': 'successful',
'Submit': 'Submit',
'Success!': 'Success!',
'successful': 'exitoso',
'Sure you want to delete this object?': '¿Está seguro que desea eliminar este objeto?',
'switch to : db': 'switch to : db',
'table': 'tabla',
'Table name': 'Nombre de la tabla',
'test': 'probar',
'Testing application': 'Probando aplicación',
'The "query" is a condition like "db.table1.field1==\'value\'". Something like "db.table1.field1==db.table2.field2" results in a SQL JOIN.': 'La "consulta" es una condición como "db.tabla1.campo1==\'valor\'". Algo como "db.tabla1.campo1==db.tabla2.campo2" resulta en un JOIN SQL.',
'the application logic, each URL path is mapped in one exposed function in the controller': 'la lógica de la aplicación, cada ruta URL se mapea en una función expuesta en el controlador',
'The application logic, each URL path is mapped in one exposed function in the controller': 'The application logic, each URL path is mapped in one exposed function in the controller',
'The application logic, each URL path is mapped in one exposed function in the controller': 'La lógica de la aplicación, cada ruta URL se mapea en una función expuesta en el controlador',
'the data representation, define database tables and sets': 'la representación de datos, define tablas y conjuntos de base de datos',
'The data representation, define database tables and sets': 'The data representation, define database tables and sets',
'The presentations layer, views are also known as templates': 'The presentations layer, views are also known as templates',
'The data representation, define database tables and sets': 'La representación de datos, define tablas y conjuntos de base de datos',
'The presentations layer, views are also known as templates': 'La capa de presentación, las vistas también son llamadas plantillas',
'the presentations layer, views are also known as templates': 'la capa de presentación, las vistas también son llamadas plantillas',
'There are no controllers': 'No hay controladores',
'There are no models': 'No hay modelos',
'There are no modules': 'No hay módulos',
'There are no plugins': 'There are no plugins',
'There are no private files': 'There are no private files',
'There are no plugins': 'No hay plugins',
'There are no private files': 'No hay archivos privados',
'There are no static files': 'No hay archivos estáticos',
'There are no translators, only default language is supported': 'No hay traductores, sólo el lenguaje por defecto es soportado',
'There are no views': 'No hay vistas',
'These files are not served, they are only available from within your app': 'These files are not served, they are only available from within your app',
'These files are served without processing, your images go here': 'These files are served without processing, your images go here',
'These files are not served, they are only available from within your app': 'Estos archivos no son servidos, ellos solo estan disponibles para su aplicación',
'These files are served without processing, your images go here': 'Estos archivos son servidos sin procesar, sus imágenes van aquí',
'these files are served without processing, your images go here': 'estos archivos son servidos sin procesar, sus imágenes van aquí',
'This is the %(filename)s template': 'Esta es la plantilla %(filename)s',
'this page to see if a breakpoint was hit and debug interaction is required.': 'this page to see if a breakpoint was hit and debug interaction is required.',
'Ticket': 'Tiquete',
'Ticket ID': 'Ticket ID',
'Timestamp': 'Timestamp',
'TM': 'MR',
'to previous version.': 'a la versión previa.',
'To create a plugin, name a file/folder plugin_[name]': 'Para crear un plugin, nombre un archivo/carpeta plugin_[nombre]',
'To emulate a breakpoint programatically, write:': 'To emulate a breakpoint programatically, write:',
'to use the debugger!': 'to use the debugger!',
'toggle breakpoint': 'toggle breakpoint',
'Toggle Fullscreen': 'Toggle Fullscreen',
'toggle breakpoint': 'alternar punto de ruptura',
'Toggle Fullscreen': 'Alternar pantalla completa',
'Traceback': 'Traceback',
'translation strings for the application': 'cadenas de caracteres de traducción para la aplicación',
'Translation strings for the application': 'Translation strings for the application',
'Translation strings for the application': 'Cadenas de caracteres de traducción para la aplicación',
'try': 'intente',
'try something like': 'intente algo como',
'Try the mobile interface': 'Pruebe la interfaz móvil',
'try view': 'try view',
'Type some Python code in here and hit Return (Enter) to execute it.': 'Type some Python code in here and hit Return (Enter) to execute it.',
'Unable to check for upgrades': 'No es posible verificar la existencia de actualizaciones',
'unable to create application "%s"': 'no es posible crear la aplicación "%s"',
@@ -332,9 +408,12 @@
'update': 'actualizar',
'update all languages': 'actualizar todos los lenguajes',
'Update:': 'Actualice:',
'upgrade now to %s': 'upgrade now to %s',
'upgrade web2py now': 'actualize web2py ahora',
'Upload': 'Upload',
'Upload': 'Subir',
'Upload & install packed application': 'Suba e instale aplicación empaquetada',
'Upload a package:': 'Subir un paquete:',
'Upload and install packed application': 'Suba e instale una aplicación empaquetada',
'upload application:': 'subir aplicación:',
'Upload existing application': 'Suba esta aplicación',
'upload file:': 'suba archivo:',
@@ -348,12 +427,15 @@
'view': 'vista',
'Views': 'Vistas',
'views': 'vistas',
'Web Framework': 'Web Framework',
'web2py is up to date': 'web2py está actualizado',
'web2py online debugger': 'web2py online debugger',
'web2py Recent Tweets': 'Tweets Recientes de web2py',
'web2py upgraded; please restart it': 'web2py actualizado; favor reiniciar',
'Welcome to web2py': 'Bienvenido a web2py',
'YES': 'SI',
'Yes': 'Yes',
'You are going to install': 'You are going to install',
'You need to set up and reach a': 'You need to set up and reach a',
'Your application will be blocked until you click an action button (next, step, continue, etc.)': 'Your application will be blocked until you click an action button (next, step, continue, etc.)',
'Your can inspect variables using the console below': 'Your can inspect variables using the console below',

View File

@@ -11,6 +11,7 @@
'(requires internet access, experimental)': '(requires internet access, experimental)',
'(something like "it-it")': '(qualcosa simile a "it-it")',
'@markmin\x01(file **gluon/contrib/plural_rules/%s.py** is not found)': '(file **gluon/contrib/plural_rules/%s.py** is not found)',
'@markmin\x01An error occured, please [[reload %s]] the page': 'An error occured, please [[reload %s]] the page',
'@markmin\x01Searching: **%s** %%{file}': 'Searching: **%s** files',
'A new version of web2py is available: %s': 'È disponibile una nuova versione di web2py: %s',
'About': 'informazioni',
@@ -55,6 +56,7 @@
'cannot create file': 'impossibile creare il file',
'cannot upload file "%(filename)s"': 'impossibile caricare il file "%(filename)s"',
'Change admin password': 'change admin password',
'change editor settings': 'change editor settings',
'change password': 'cambia password',
'check all': 'controlla tutto',
'Check for upgrades': 'check for upgrades',
@@ -76,6 +78,7 @@
'create file with filename:': 'crea un file col nome:',
'create new application:': 'create new application:',
'Create new simple application': 'Crea nuova applicazione',
'Create/Upload': 'Create/Upload',
'created by': 'creato da',
'crontab': 'crontab',
'Current request': 'Richiesta (request) corrente',
@@ -120,17 +123,14 @@
'edit profile': 'modifica profilo',
'Edit This App': 'Modifica questa applicazione',
'edit views:': 'modifica viste (view):',
'Editing bigul': 'Editing bigul',
'Editing file "%s"': 'Modifica del file "%s"',
'Editing italo': 'Editing italo',
'Editing italo3': 'Editing italo3',
'Editing Language file': 'Modifica file linguaggio',
'Editing %s': 'Editing %s',
'Enterprise Web Framework': 'Enterprise Web Framework',
'Error logs for "%(app)s"': 'Log degli errori per "%(app)s"',
'Error snapshot': 'Error snapshot',
'Error ticket': 'Error ticket',
'Errors': 'errori',
'Exception instance attributes': 'Exception instance attributes',
'Exit Fullscreen': 'Exit Fullscreen',
'Expand Abbreviation': 'Expand Abbreviation',
'export as csv file': 'esporta come file CSV',
'exposes': 'espone',

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env python
{
# "singular form (0)": ["first plural form (1)", "second plural form (2)", ...],
'останній': ['останні','останніх'],
'файл': ['файли','файлів'],
'твіт': ['твіти','твітів'],
}

View File

@@ -185,8 +185,8 @@
'Invalid Query': 'Неверный запрос',
'invalid request': 'неверный запрос',
'invalid ticket': 'неверный тикет',
'Key bindings': 'Связываник клавиш',
'Key bindings for ZenConding Plugin': 'Связывание клавиш для плагина ZenConding',
'Key bindings': 'Комбинации клавиш',
'Key bindings for ZenConding Plugin': 'Комбинации клавиш для плагина ZenConding',
'language file "%(filename)s" created/updated': 'Языковой файл "%(filename)s" создан/обновлен',
'Language files (static strings) updated': 'Языковые файлы (статичные строки) обновлены',
'languages': 'языки',
@@ -204,7 +204,7 @@
'Login to the Administrative Interface': 'Вход в интерфейс администратора',
'Logout': 'выход',
'Lost Password': 'Забыли пароль',
'lost password?': 'Пароль утерен?',
'lost password?': 'Пароль утерян?',
'Main Menu': 'Главное меню',
'Match Pair': 'Найти пару',
'Menu Model': 'Модель меню',

View File

@@ -8,13 +8,16 @@
'%s': '%s',
'%s %%{row} deleted': 'Вилучено %s %%{рядок}',
'%s %%{row} updated': 'Вилучено %s %%{рядок}',
'%s Recent Tweets': '%s останніх твітів',
'%s Recent Tweets': '%s %%{останній} %%{твіт}',
'%s students registered': '%s студентів зареєстровано',
'%Y-%m-%d': '%Y/%m/%d',
'%Y-%m-%d %H:%M:%S': '%Y/%m/%d %H:%M:%S',
'(requires internet access)': '(потрібно мати доступ в інтернет)',
'(requires internet access, experimental)': '(потрібно мати доступ в інтернет, експериментально)',
'(something like "it-it")': '(щось схоже на "uk-ua")',
'@markmin\x01(file **gluon/contrib/plural_rules/%s.py** is not found)': '(не існує файлу **gluon/contrib/plural_rules/%s.py**)',
'@markmin\x01An error occured, please [[reload %s]] the page': 'Сталась помилка, будь-ласка [[переватажте %s]] сторінку',
"@markmin\x01Mercurial Version Control System Interface[[NEWLINE]]for application '%s'": "Інтерфейс системи контролю версій Mercurial[[NEWLINE]]для додатку '%s'",
'@markmin\x01Searching: **%s** %%{file}': 'Знайдено: **%s** %%{файл}',
'Abort': 'Припинити',
'About': 'Про',
@@ -55,6 +58,7 @@
'ATTENTION: Login requires a secure (HTTPS) connection or running on localhost.': "УВАГА: Вхід потребує надійного (HTTPS) з'єднання або запуску на локальному комп'ютері.",
'ATTENTION: TESTING IS NOT THREAD SAFE SO DO NOT PERFORM MULTIPLE TESTS CONCURRENTLY.': 'ОБЕРЕЖНО: ТЕСТУВАННЯ НЕ Є ПОТОКО-БЕЗПЕЧНИМ, ТОЖ НЕ ЗАПУСКАЙТЕ ДЕКІЛЬКА ТЕСТІВ ОДНОЧАСНО.',
'ATTENTION: you cannot edit the running application!': 'УВАГА: Ви не можете редагувати додаток, який зараз виконуєте!',
'Autocomplete Python Code': 'Автозавершення коду на Python',
'Available databases and tables': 'Доступні бази даних та таблиці',
'back': '<< назад',
'bad_resource': 'поганий_ресурс',
@@ -75,6 +79,7 @@
'cannot create file': 'не можу створити файл',
'cannot upload file "%(filename)s"': 'не можу завантажити файл "%(filename)s"',
'Change admin password': 'Змінити пароль адміністратора',
'change editor settings': 'змінити налаштування редактора',
'check all': 'відмітити всі',
'Check for upgrades': 'Перевірити оновлення',
'Check to delete': 'Помітити на вилучення',
@@ -89,7 +94,9 @@
'Code listing': 'Лістинг',
'collapse/expand all': 'згорнути/розгорнути все',
'Command': 'Команда',
'Comment:': 'Пояснення:',
'Commit': 'Комміт',
'Commit form': 'Commit form',
'Compile': 'Компілювати',
'compiled application removed': 'скомпільований додаток вилучено',
'Condition': 'Умова',
@@ -103,6 +110,7 @@
'create file with filename:': 'створити файл з назвою:',
'create plural-form': 'створити форму множини',
'Create rules': 'Створити правила',
'Create/Upload': 'Створити/Завантажити',
'created by': 'Автор:',
'Created On': 'Створено в',
'crontab': 'таблиця cron',
@@ -150,8 +158,10 @@
'edit all': 'редагувати всі',
'Edit application': 'Налаштування додатку',
'edit controller': 'редагувати контролер',
'edit controller:': 'редагувати контролер:',
'Edit current record': 'Редагувати поточний запис',
'edit views:': 'редагувати відображення (views):',
'Editing %s': 'Редагується %s',
'Editing file "%s"': 'Редагується файл "%s"',
'Editing Language file': 'Редагується файл перекладу',
'Editing Plural Forms File': 'Редагується файл форм множини',
@@ -166,6 +176,7 @@
'Exception %(extype)s: %(exvalue)s': 'Виключення %(extype)s: %(exvalue)s',
'Exception %s': 'Виключення %s',
'Exception instance attributes': 'Атрибути примірника класу Exception (виключення)',
'Exit Fullscreen': 'Вийти з повноекранного режиму',
'Expand Abbreviation': 'Розгорнути абревіатуру',
'export as csv file': 'експортувати як файл csv',
'exposes': 'обслуговує',
@@ -186,6 +197,8 @@
'file saved on %s': 'файл збережено в %s',
'Filename': "Ім'я файлу",
'filter': 'фільтр',
'Find Next': 'Шукати наступний',
'Find Previous': 'Шукати попередній',
'Frames': 'Стек викликів',
'Functions with no doctests will result in [passed] tests.': 'Функції, в яких відсутні док-тести відносяться до функцій, які успішно пройшли тести.',
'GAE Email': 'Ел.пошта GAE',
@@ -201,6 +214,7 @@
'Google App Engine Deployment Interface': 'Інтерфейс розгортання Google App Engine',
'Google Application Id': 'Ідентифікатор Google Application',
'Goto': 'Перейти до',
'graph model': 'графова модель',
'Help': 'Допомога',
'Hide/Show Translated strings': 'Сховати/показати ВЖЕ ПЕРЕКЛАДЕНІ рядки',
'Hits': 'Спрацьовувань',
@@ -208,7 +222,7 @@
'honored only if the expression evaluates to true': 'точка зупинки активується тільки за істинності умови',
'If start the downgrade, be patient, it may take a while to rollback': 'Запустивши повернення на попередню версію, будьте терплячими, це може зайняти трохи часу',
'If start the upgrade, be patient, it may take a while to download': 'Запустивши оновлення, будьте терплячими, потрібен час для завантаження необхідних даних',
'If the report above contains a ticket number it indicates a failure in executing the controller, before any attempt to execute the doctests. This is usually due to an indentation error or an error outside function code.\nA green title indicates that all tests (if defined) passed. In this case test results are not shown.': 'Якщо в наданому вище звіті присутня позначка про помилку (ticket number), то це вказує на збій у виконанні контролера ще до початку запуску док-тестів. Це, зазвичай, сигналізує про помилку вирівнювання тексту програми (indention error) або помилку за межами функції (error outside function code). Зелений заголовок сигналізує, що всі тести (з наявних) пройшли успішно. В цьому випадку результат тестів показано не буде.',
'If the report above contains a ticket number it indicates a failure in executing the controller, before any attempt to execute the doctests. This is usually due to an indentation error or an error outside function code.\n\t\tA green title indicates that all tests (if defined) passed. In this case test results are not shown.': 'Якщо в наданому вище звіті присутня позначка про помилку (ticket number), то це вказує на збій у виконанні контролера ще до початку запуску док-тестів. Це, зазвичай, сигналізує про помилку вирівнювання тексту програми (indention error) або помилку за межами функції (error outside function code).\n\t\tЗелений заголовок сигналізує, що всі тести (з наявних) пройшли успішно. В цьому випадку результат тестів показано не буде.',
'Import/Export': 'Імпорт/Експорт',
'In development, use the default Rocket webserver that is currently supported by this debugger.': 'Під час розробки , використовуйте вбудований веб-сервер Rocket, він найкраще налаштований на спільну роботу з інтерактивним ладначем.',
'includes': 'включає',
@@ -245,6 +259,8 @@
'License for': 'Ліцензія додатку',
'Line number': '№ рядка',
'LineNo': '№ рядка',
'lists by exception': 'список виключень (exceptions)',
'lists by ticket': 'список позначок (tickets)',
'loading...': 'завантаження...',
'locals': 'локальні',
'Locals##debug': 'Локальні змінні',
@@ -253,6 +269,7 @@
'Login to the Administrative Interface': 'Вхід в адміністративний інтерфейс',
'Logout': 'Вихід',
'Main Menu': 'Основне меню',
'Manage': 'Керувати',
'Manage Admin Users/Students': 'Адміністратор керування користувачами/студентами',
'Manage Students': 'Керувати студентами',
'Match Pair': 'Знайти пару',
@@ -282,6 +299,7 @@
'No databases in this application': 'Даний додаток не використовує бази даних',
'No Interaction yet': 'Ладнач не активовано',
'no match': 'співпадань нема',
'no package selected': 'пакет не вибрано',
'no permission to uninstall "%s"': 'нема прав на вилучення (uninstall) "%s"',
'No ticket_storage.txt found under /private folder': 'В каталозі /private відсутній файл ticket_storage.txt',
'Not Authorized': 'Не дозволено',
@@ -290,11 +308,14 @@
'online designer': 'дизайнер БД',
'OpenShift Deployment Interface': 'OpenShift: Інтерфейс розгортання',
'OpenShift Output': 'Вивід OpenShift',
'or alternatively': 'або альтернативно',
'Or Get from URL:': 'Або Отримати з мережі (ч/з URL):',
'or import from csv file': 'або імпортувати через csv-файл',
'Original/Translation': 'Оригінал/переклад',
'Overwrite installed app': 'Перезаписати встановлений додаток',
'Pack all': 'Запак.все',
'Pack compiled': 'Запак.компл',
'Pack all': 'Пакувати все',
'Pack compiled': 'Пакувати зкомпільоване',
'Pack custom': 'Пакувати вибране',
'pack plugin': 'запакувати втулку',
'PAM authenticated user, cannot change password here': 'Ввімкнена система ідентифікації користувачів PAM. Для зміни паролю скористайтесь командами вашої ОС ',
'password changed': 'пароль змінено',
@@ -322,13 +343,17 @@
'Query:': 'Запит:',
'RAM Cache Keys': 'Ключ ОЗП-кешу (RAM Cache)',
'Ram Cleared': "Кеш в пам'яті очищено",
'Rapid Search': 'Миттєвий пошук',
'record': 'запис',
'record does not exist': 'запису не існує',
'record id': 'Ід.запису',
'refresh': 'оновіть',
'reload': 'перевантажити',
'Reload routes': 'Перезавантажити маршрути',
'Remove compiled': 'Вилуч.компл',
'Removed Breakpoint on %s at line %s': 'Вилучено точку зупинки у %s в рядку %s',
'Replace': 'Замінити',
'Replace All': 'Замінити все',
'request': 'запит',
'requires python-git, but not installed': 'Для розгортання необхідний пакет python-git, але він не встановлений',
'resolve': "розв'язати",
@@ -349,6 +374,8 @@
'Running on %s': 'Запущено на %s',
'runonce': 'одноразово',
'Save': 'Зберегти',
'Save file:': 'Зберегти файл:',
'Save file: %s': 'Зберегти файл: %s',
'Save via Ajax': 'зберегти через Ajax',
'Saved file hash:': 'Хеш збереженого файлу:',
'search': 'пошук',
@@ -366,8 +393,10 @@
'some files could not be removed': 'деякі файли не можна вилучити',
'Sorry, could not find mercurial installed': 'Не вдалось виявити встановлену систему контролю версій Mercurial',
'Start a new app': 'Створюється новий додаток',
'Start searching': 'Розпочати пошук',
'Start wizard': 'Активувати майстра',
'state': 'стан',
'Static': 'Статичні',
'static': 'статичні',
'Static files': 'Статичні файли',
'Step': 'Крок',
@@ -376,6 +405,7 @@
'submit': 'застосувати',
'Submit': 'Застосувати',
'successful': 'успішно',
'switch to : db': 'перемкнути на : БД',
'table': 'таблиця',
'tags': 'мітки (tags)',
'Temporary': 'Тимчасово',
@@ -450,8 +480,10 @@
'Update:': 'Поновити:',
'Upgrade': 'Оновити',
'upgrade now': 'оновитись зараз',
'upgrade now to %s': 'оновити зараз до %s',
'upgrade_web2py': 'оновити web2py',
'upload': 'завантажити',
'Upload': 'Завантажити',
'Upload a package:': 'Завантажити пакет:',
'Upload and install packed application': 'Завантажити та встановити запакований додаток',
'upload file:': 'завантажити файл:',

View File

@@ -8,41 +8,6 @@ WEB2PY_VERSION_URL = WEB2PY_URL + '/examples/default/version'
# the user-interface feature that allows you to edit files in your web
# browser.
## Default editor (to change editor you need web2py.admin.editors.zip)
TEXT_EDITOR = 'codemirror' or 'ace' or 'edit_area' or 'amy'
## Editor Color scheme (only for ace)
TEXT_EDITOR_THEME = (
"chrome", "clouds", "clouds_midnight", "cobalt", "crimson_editor", "dawn",
"dreamweaver", "eclipse", "idle_fingers", "kr_theme", "merbivore",
"merbivore_soft", "monokai", "mono_industrial", "pastel_on_dark",
"solarized_dark", "solarized_light", "textmate", "tomorrow",
"tomorrow_night", "tomorrow_night_blue", "tomorrow_night_bright",
"tomorrow_night_eighties", "twilight", "vibrant_ink")[0]
## Editor Keyboard bindings (only for ace and codemirror)
TEXT_EDITOR_KEYBINDING = '' # 'emacs' or 'vi'
### edit_area only
# The default font size, measured in 'points'. The value must be an integer > 0
FONT_SIZE = 10
# Displays the editor in full screen mode. The value must be 'true' or 'false'
FULL_SCREEN = 'false'
# Display a check box under the editor to allow the user to switch
# between the editor and a simple
# HTML text area. The value must be 'true' or 'false'
ALLOW_TOGGLE = 'true'
# Replaces tab characters with space characters.
# The value can be 'false' (meaning that tabs are not replaced),
# or an integer > 0 that specifies the number of spaces to replace a tab with.
REPLACE_TAB_BY_SPACES = 4
# Toggle on/off the code editor instead of textarea on startup
DISPLAY = "onload" or "later"
# if demo mode is True then admin works readonly and does not require login
DEMO_MODE = False
@@ -78,3 +43,6 @@ PLUGINS_APP = 'http://web2py.com/plugins'
# set the language
if 'adminLanguage' in request.cookies and not (request.cookies['adminLanguage'] is None):
T.force(request.cookies['adminLanguage'].value)
#set static_version
response.static_version = '2.7.3'

View File

@@ -8,6 +8,7 @@ from gluon.fileutils import read_file
# ## make sure administrator is on localhost or https
# ###########################################################
http_host = request.env.http_host.split(':')[0]
if request.env.web2py_runtime_gae:
@@ -49,7 +50,7 @@ def verify_password(password):
session.pam_user = None
if DEMO_MODE:
return True
elif not 'password' in _config:
elif not _config.get('password'):
return False
elif _config['password'].startswith('pam_user:'):
session.pam_user = _config['password'][9:].strip()
@@ -145,6 +146,10 @@ elif session.is_mobile == 'false':
else:
is_mobile = request.user_agent().is_mobile
if DEMO_MODE:
session.authorized = True
session.forget()
if request.controller == "webservices":
basic = request.env.http_authorization
if not basic or not basic[:6].lower() == 'basic ':

View File

@@ -0,0 +1,17 @@
response.files.append(URL('static','plugin_statebutton/js/bootstrap-switch.js'))
response.files.append(URL('static','plugin_statebutton/css/bootstrap-switch.css'))
def stateWidget(field, value, data={'on-label':'Enabled', 'off-label':'Disabled', 'on':"primary", 'off':"default" }):
try:
fieldName = str(field).split('.')[1]
except:
fieldName = field
div = DIV(INPUT( _type='checkbox', _name='%s' % fieldName, _checked= 'checked' if value == 'true' else None, _value='true'),
_class='make-bootstrap-switch',
data=data)
script = SCRIPT("""
jQuery(".make-bootstrap-switch input[name='%s']").parent().bootstrapSwitch();
""" % fieldName)
return DIV(div, script)

View File

@@ -1,6 +1,10 @@
[DEFAULT]
theme = web2py
closetag = true
editor = default
[editor]
theme = night
theme = web2py
editor = default
closetag = true

View File

@@ -4,12 +4,12 @@
- [Submitting bug reports](#submitting-bug-reports-)
- [Contributing code](#contributing-code-)
## Getting help [^](#how-to-contribute)
## Getting help
Community discussion, questions, and informal bug reporting is done on the
[CodeMirror Google group](http://groups.google.com/group/codemirror).
## Submitting bug reports [^](#how-to-contribute)
## Submitting bug reports
The preferred way to report bugs is to use the
[GitHub issue tracker](http://github.com/marijnh/CodeMirror/issues). Before
@@ -45,7 +45,7 @@ should be asked on the
[jsbin.com](http://jsbin.com/ihunin/edit), enter it there, press save, and
include the resulting link in your bug report.
## Contributing code [^](#how-to-contribute)
## Contributing code
- Make sure you have a [GitHub Account](https://github.com/signup/free)
- Fork [CodeMirror](https://github.com/marijnh/CodeMirror/)

View File

@@ -1,4 +1,4 @@
Copyright (C) 2013 by Marijn Haverbeke <marijnh@gmail.com>
Copyright (C) 2013 by Marijn Haverbeke <marijnh@gmail.com> and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -17,7 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Please note that some subdirectories of the CodeMirror distribution
include their own LICENSE files, and are released under different
licences.

View File

@@ -17,7 +17,7 @@
CodeMirror.defineExtension("lineComment", function(from, to, options) {
if (!options) options = noOptions;
var self = this, mode = CodeMirror.innerMode(self.getMode(), self.getTokenAt(from).state).mode;
var self = this, mode = self.getModeAt(from);
var commentString = options.lineComment || mode.lineComment;
if (!commentString) {
if (options.blockCommentStart || mode.blockCommentStart) {
@@ -52,7 +52,7 @@
CodeMirror.defineExtension("blockComment", function(from, to, options) {
if (!options) options = noOptions;
var self = this, mode = CodeMirror.innerMode(self.getMode(), self.getTokenAt(from).state).mode;
var self = this, mode = self.getModeAt(from);
var startString = options.blockCommentStart || mode.blockCommentStart;
var endString = options.blockCommentEnd || mode.blockCommentEnd;
if (!startString || !endString) {
@@ -85,7 +85,7 @@
CodeMirror.defineExtension("uncomment", function(from, to, options) {
if (!options) options = noOptions;
var self = this, mode = CodeMirror.innerMode(self.getMode(), self.getTokenAt(from).state).mode;
var self = this, mode = self.getModeAt(from);
var end = Math.min(to.line, self.lastLine()), start = Math.min(from.line, end);
// Try finding line comments

View File

@@ -0,0 +1,6 @@
.CodeMirror-fullscreen {
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
height: auto;
z-index: 9;
}

View File

@@ -0,0 +1,30 @@
(function() {
"use strict";
CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
if (old == CodeMirror.Init) old = false;
if (!old == !val) return;
if (val) setFullscreen(cm);
else setNormal(cm);
});
function setFullscreen(cm) {
var wrap = cm.getWrapperElement();
cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
width: wrap.style.width, height: wrap.style.height};
wrap.style.width = wrap.style.height = "";
wrap.className += " CodeMirror-fullscreen";
document.documentElement.style.overflow = "hidden";
cm.refresh();
}
function setNormal(cm) {
var wrap = cm.getWrapperElement();
wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
document.documentElement.style.overflow = "";
var info = cm.state.fullScreenRestore;
wrap.style.width = info.width; wrap.style.height = info.height;
window.scrollTo(info.scrollLeft, info.scrollTop);
cm.refresh();
}
})();

View File

@@ -54,7 +54,9 @@
if (cm.somethingSelected()) return surround(cm);
if (left == right && maybeOverwrite(cm) != CodeMirror.Pass) return;
var cur = cm.getCursor(), ahead = CodeMirror.Pos(cur.line, cur.ch + 1);
var line = cm.getLine(cur.line), nextChar = line.charAt(cur.ch);
var line = cm.getLine(cur.line), nextChar = line.charAt(cur.ch), curChar = cur.ch > 0 ? line.charAt(cur.ch - 1) : "";
if (left == right && CodeMirror.isWordChar(curChar))
return CodeMirror.Pass;
if (line.length == cur.ch || closingBrackets.indexOf(nextChar) >= 0 || SPACE_CHAR_REGEX.test(nextChar))
cm.replaceSelection(left + right, {head: ahead, anchor: ahead});
else

View File

@@ -27,9 +27,9 @@
if (val && (old == CodeMirror.Init || !old)) {
var map = {name: "autoCloseTags"};
if (typeof val != "object" || val.whenClosing)
map["'/'"] = function(cm) { return autoCloseTag(cm, '/'); };
map["'/'"] = function(cm) { return autoCloseSlash(cm); };
if (typeof val != "object" || val.whenOpening)
map["'>'"] = function(cm) { return autoCloseTag(cm, '>'); };
map["'>'"] = function(cm) { return autoCloseGT(cm); };
cm.addKeyMap(map);
} else if (!val && (old != CodeMirror.Init && old)) {
cm.removeKeyMap("autoCloseTags");
@@ -41,40 +41,41 @@
var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4",
"h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"];
function autoCloseTag(cm, ch) {
function autoCloseGT(cm) {
var pos = cm.getCursor(), tok = cm.getTokenAt(pos);
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
if (inner.mode.name != "xml") return CodeMirror.Pass;
if (inner.mode.name != "xml" || !state.tagName) return CodeMirror.Pass;
var opt = cm.getOption("autoCloseTags"), html = inner.mode.configuration == "html";
var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);
if (ch == ">" && state.tagName) {
var tagName = state.tagName;
if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
var lowerTagName = tagName.toLowerCase();
// Don't process the '>' at the end of an end-tag or self-closing tag
if (tok.type == "tag" && state.type == "closeTag" ||
tok.string.indexOf("/") == (tok.string.length - 1) || // match something like <someTagName />
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1)
return CodeMirror.Pass;
var tagName = state.tagName;
if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
var lowerTagName = tagName.toLowerCase();
// Don't process the '>' at the end of an end-tag or self-closing tag
if (tok.type == "tag" && state.type == "closeTag" ||
tok.string.indexOf("/") == (tok.string.length - 1) || // match something like <someTagName />
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1)
return CodeMirror.Pass;
var doIndent = indentTags && indexOf(indentTags, lowerTagName) > -1;
var curPos = doIndent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1);
cm.replaceSelection(">" + (doIndent ? "\n\n" : "") + "</" + tagName + ">",
{head: curPos, anchor: curPos});
if (doIndent) {
cm.indentLine(pos.line + 1);
cm.indentLine(pos.line + 2);
}
return;
} else if (ch == "/" && tok.string == "<") {
var tagName = state.context && state.context.tagName;
if (tagName) cm.replaceSelection("/" + tagName + ">", "end");
return;
var doIndent = indentTags && indexOf(indentTags, lowerTagName) > -1;
var curPos = doIndent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1);
cm.replaceSelection(">" + (doIndent ? "\n\n" : "") + "</" + tagName + ">",
{head: curPos, anchor: curPos});
if (doIndent) {
cm.indentLine(pos.line + 1);
cm.indentLine(pos.line + 2);
}
return CodeMirror.Pass;
}
function autoCloseSlash(cm) {
var pos = cm.getCursor(), tok = cm.getTokenAt(pos);
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
if (tok.string.charAt(0) != "<" || tok.start != pos.ch - 1 || inner.mode.name != "xml") return CodeMirror.Pass;
var tagName = state.context && state.context.tagName;
if (tagName) cm.replaceSelection("/" + tagName + ">", "end");
}
function indexOf(collection, elt) {

View File

@@ -1,44 +0,0 @@
(function() {
var modes = ["clike", "css", "javascript"];
for (var i = 0; i < modes.length; ++i)
CodeMirror.extendMode(modes[i], {blockCommentStart: "/*",
blockCommentEnd: "*/",
blockCommentContinue: " * "});
function continueComment(cm) {
var pos = cm.getCursor(), token = cm.getTokenAt(pos);
var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
var space;
if (token.type == "comment" && mode.blockCommentStart) {
var end = token.string.indexOf(mode.blockCommentEnd);
var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length) {
// Comment ended, don't continue it
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
space = full.slice(0, token.start);
if (!/^\s*$/.test(space)) {
space = "";
for (var i = 0; i < token.start; ++i) space += " ";
}
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
found + mode.blockCommentContinue.length > token.start &&
/^\s*$/.test(full.slice(0, found))) {
space = full.slice(0, found);
}
}
if (space != null)
cm.replaceSelection("\n" + space + mode.blockCommentContinue, "end");
else
return CodeMirror.Pass;
}
CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
if (prev && prev != CodeMirror.Init)
cm.removeKeyMap("continueComment");
var map = {name: "continueComment"};
map[typeof val == "string" ? val : "Enter"] = continueComment;
cm.addKeyMap(map);
});
})();

View File

@@ -6,7 +6,7 @@
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
var pos = cm.getCursor(),
inList = cm.getStateAfter(pos.line).list,
inList = cm.getStateAfter(pos.line).list !== false,
match;
if (!inList || !(match = cm.getLine(pos.line).match(listRE))) {

View File

@@ -1,10 +1,10 @@
CodeMirror.braceRangeFinder = function(cm, start) {
CodeMirror.registerHelper("fold", "brace", function(cm, start) {
var line = start.line, lineText = cm.getLine(line);
var startCh, tokenType;
function findOpening(openCh) {
for (var at = start.ch, pass = 0;;) {
var found = lineText.lastIndexOf(openCh, at - 1);
var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1);
if (found == -1) {
if (pass == 1) break;
pass = 1;
@@ -12,7 +12,7 @@ CodeMirror.braceRangeFinder = function(cm, start) {
continue;
}
if (pass == 1 && found < start.ch) break;
tokenType = cm.getTokenAt(CodeMirror.Pos(line, found + 1)).type;
tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
if (!/^(comment|string)/.test(tokenType)) return found + 1;
at = found - 1;
}
@@ -34,7 +34,7 @@ CodeMirror.braceRangeFinder = function(cm, start) {
if (nextClose < 0) nextClose = text.length;
pos = Math.min(nextOpen, nextClose);
if (pos == text.length) break;
if (cm.getTokenAt(CodeMirror.Pos(i, pos + 1)).type == tokenType) {
if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) {
if (pos == nextOpen) ++count;
else if (!--count) { end = i; endCh = pos; break outer; }
}
@@ -44,9 +44,10 @@ CodeMirror.braceRangeFinder = function(cm, start) {
if (end == null || line == end && endCh == startCh) return;
return {from: CodeMirror.Pos(line, startCh),
to: CodeMirror.Pos(end, endCh)};
};
});
CodeMirror.braceRangeFinder = CodeMirror.fold.brace; // deprecated
CodeMirror.importRangeFinder = function(cm, start) {
CodeMirror.registerHelper("fold", "import", function(cm, start) {
function hasImport(line) {
if (line < cm.firstLine() || line > cm.lastLine()) return null;
var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
@@ -68,9 +69,10 @@ CodeMirror.importRangeFinder = function(cm, start) {
end = next.end;
}
return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
};
});
CodeMirror.importRangeFinder = CodeMirror.fold["import"]; // deprecated
CodeMirror.includeRangeFinder = function(cm, start) {
CodeMirror.registerHelper("fold", "include", function(cm, start) {
function hasInclude(line) {
if (line < cm.firstLine() || line > cm.lastLine()) return null;
var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
@@ -87,4 +89,5 @@ CodeMirror.includeRangeFinder = function(cm, start) {
}
return {from: CodeMirror.Pos(start, has + 1),
to: cm.clipPos(CodeMirror.Pos(end))};
};
});
CodeMirror.includeRangeFinder = CodeMirror.fold.include; // deprecated

View File

@@ -0,0 +1,40 @@
CodeMirror.registerHelper("fold", "comment", function(cm, start) {
var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd;
if (!startToken || !endToken) return;
var line = start.line, lineText = cm.getLine(line);
var startCh;
for (var at = start.ch, pass = 0;;) {
var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1);
if (found == -1) {
if (pass == 1) return;
pass = 1;
at = lineText.length;
continue;
}
if (pass == 1 && found < start.ch) return;
if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
startCh = found + startToken.length;
break;
}
at = found - 1;
}
var depth = 1, lastLine = cm.lastLine(), end, endCh;
outer: for (var i = line; i <= lastLine; ++i) {
var text = cm.getLine(i), pos = i == line ? startCh : 0;
for (;;) {
var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
if (nextOpen < 0) nextOpen = text.length;
if (nextClose < 0) nextClose = text.length;
pos = Math.min(nextOpen, nextClose);
if (pos == text.length) break;
if (pos == nextOpen) ++depth;
else if (!--depth) { end = i; endCh = pos; break outer; }
++pos;
}
}
if (end == null || line == end && endCh == startCh) return;
return {from: CodeMirror.Pos(line, startCh),
to: CodeMirror.Pos(end, endCh)};
});

View File

@@ -1,8 +1,9 @@
(function() {
"use strict";
function doFold(cm, pos, options) {
var finder = options.call ? options : (options && options.rangeFinder);
function doFold(cm, pos, options, force) {
var finder = options && (options.call ? options : options.rangeFinder);
if (!finder) finder = cm.getHelper(pos, "fold");
if (!finder) return;
if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);
var minSize = options && options.minFoldSize || 0;
@@ -12,7 +13,7 @@
if (!range || range.to.line - range.from.line < minSize) return null;
var marks = cm.findMarksAt(range.from);
for (var i = 0; i < marks.length; ++i) {
if (marks[i].__isFold) {
if (marks[i].__isFold && force !== "fold") {
if (!allowFolded) return null;
range.cleared = true;
marks[i].clear();
@@ -26,15 +27,19 @@
pos = CodeMirror.Pos(pos.line - 1, 0);
range = getRange(false);
}
if (!range || range.cleared) return;
if (!range || range.cleared || force === "unfold") return;
var myWidget = makeWidget(options);
CodeMirror.on(myWidget, "mousedown", function() {myRange.clear();});
CodeMirror.on(myWidget, "mousedown", function() { myRange.clear(); });
var myRange = cm.markText(range.from, range.to, {
replacedWith: myWidget,
clearOnEnter: true,
__isFold: true
});
myRange.on("clear", function(from, to) {
CodeMirror.signal(cm, "unfold", cm, from, to);
});
CodeMirror.signal(cm, "fold", cm, range.from, range.to);
}
function makeWidget(options) {
@@ -54,9 +59,11 @@
};
// New-style interface
CodeMirror.defineExtension("foldCode", function(pos, options) { doFold(this, pos, options); });
CodeMirror.defineExtension("foldCode", function(pos, options, force) {
doFold(this, pos, options, force);
});
CodeMirror.combineRangeFinders = function() {
CodeMirror.registerHelper("fold", "combine", function() {
var funcs = Array.prototype.slice.call(arguments, 0);
return function(cm, start) {
for (var i = 0; i < funcs.length; ++i) {
@@ -64,5 +71,5 @@
if (found) return found;
}
};
};
});
})();

View File

@@ -0,0 +1,21 @@
.CodeMirror-foldmarker {
color: blue;
text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
font-family: arial;
line-height: .3;
cursor: pointer;
}
.CodeMirror-foldgutter {
width: .7em;
}
.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
color: #555;
cursor: pointer;
}
.CodeMirror-foldgutter-open:after {
content: "\25BE";
}
.CodeMirror-foldgutter-folded:after {
content: "\25B8";
}

View File

@@ -0,0 +1,124 @@
(function() {
"use strict";
CodeMirror.defineOption("foldGutter", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
cm.clearGutter(cm.state.foldGutter.options.gutter);
cm.state.foldGutter = null;
cm.off("gutterClick", onGutterClick);
cm.off("change", onChange);
cm.off("viewportChange", onViewportChange);
cm.off("fold", onFold);
cm.off("unfold", onFold);
cm.off("swapDoc", updateInViewport);
}
if (val) {
cm.state.foldGutter = new State(parseOptions(val));
updateInViewport(cm);
cm.on("gutterClick", onGutterClick);
cm.on("change", onChange);
cm.on("viewportChange", onViewportChange);
cm.on("fold", onFold);
cm.on("unfold", onFold);
cm.on("swapDoc", updateInViewport);
}
});
var Pos = CodeMirror.Pos;
function State(options) {
this.options = options;
this.from = this.to = 0;
}
function parseOptions(opts) {
if (opts === true) opts = {};
if (opts.gutter == null) opts.gutter = "CodeMirror-foldgutter";
if (opts.indicatorOpen == null) opts.indicatorOpen = "CodeMirror-foldgutter-open";
if (opts.indicatorFolded == null) opts.indicatorFolded = "CodeMirror-foldgutter-folded";
return opts;
}
function isFolded(cm, line) {
var marks = cm.findMarksAt(Pos(line));
for (var i = 0; i < marks.length; ++i)
if (marks[i].__isFold && marks[i].find().from.line == line) return true;
}
function marker(spec) {
if (typeof spec == "string") {
var elt = document.createElement("div");
elt.className = spec;
return elt;
} else {
return spec.cloneNode(true);
}
}
function updateFoldInfo(cm, from, to) {
var opts = cm.state.foldGutter.options, cur = from;
cm.eachLine(from, to, function(line) {
var mark = null;
if (isFolded(cm, cur)) {
mark = marker(opts.indicatorFolded);
} else {
var pos = Pos(cur, 0), func = opts.rangeFinder || cm.getHelper(pos, "fold");
var range = func && func(cm, pos);
if (range && range.from.line + 1 < range.to.line)
mark = marker(opts.indicatorOpen);
}
cm.setGutterMarker(line, opts.gutter, mark);
++cur;
});
}
function updateInViewport(cm) {
var vp = cm.getViewport(), state = cm.state.foldGutter;
if (!state) return;
cm.operation(function() {
updateFoldInfo(cm, vp.from, vp.to);
});
state.from = vp.from; state.to = vp.to;
}
function onGutterClick(cm, line, gutter) {
var opts = cm.state.foldGutter.options;
if (gutter != opts.gutter) return;
cm.foldCode(Pos(line, 0), opts.rangeFinder);
}
function onChange(cm) {
var state = cm.state.foldGutter;
state.from = state.to = 0;
clearTimeout(state.changeUpdate);
state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, 600);
}
function onViewportChange(cm) {
var state = cm.state.foldGutter;
clearTimeout(state.changeUpdate);
state.changeUpdate = setTimeout(function() {
var vp = cm.getViewport();
if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
updateInViewport(cm);
} else {
cm.operation(function() {
if (vp.from < state.from) {
updateFoldInfo(cm, vp.from, state.from);
state.from = vp.from;
}
if (vp.to > state.to) {
updateFoldInfo(cm, state.to, vp.to);
state.to = vp.to;
}
});
}
}, 400);
}
function onFold(cm, from) {
var state = cm.state.foldGutter, line = from.line;
if (line >= state.from && line < state.to)
updateFoldInfo(cm, line, line + 1);
}
})();

View File

@@ -1,11 +1,27 @@
CodeMirror.indentRangeFinder = function(cm, start) {
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
var lastLine = cm.lastLine(),
tabSize = cm.getOption("tabSize"),
firstLine = cm.getLine(start.line);
if (!tabSize || !firstLine) return;
var myIndent = CodeMirror.countColumn(firstLine, null, tabSize);
for (var i = start.line + 1, end = cm.lineCount(); i < end; ++i) {
var curLine = cm.getLine(i);
if (CodeMirror.countColumn(curLine, null, tabSize) < myIndent &&
CodeMirror.countColumn(cm.getLine(i-1), null, tabSize) > myIndent)
return {from: CodeMirror.Pos(start.line, firstLine.length),
to: CodeMirror.Pos(i, curLine.length)};
function foldEnded(curColumn, prevColumn) {
return curColumn < myIndent ||
(curColumn == myIndent && prevColumn >= myIndent) ||
(curColumn > myIndent && i == lastLine);
}
};
for (var i = start.line + 1; i <= lastLine; i++) {
var curColumn = CodeMirror.countColumn(cm.getLine(i), null, tabSize);
var prevColumn = CodeMirror.countColumn(cm.getLine(i-1), null, tabSize);
if (foldEnded(curColumn, prevColumn)) {
var lastFoldLineNumber = curColumn > myIndent && i == lastLine ? i : i-1;
var lastFoldLine = cm.getLine(lastFoldLineNumber);
return {from: CodeMirror.Pos(start.line, firstLine.length),
to: CodeMirror.Pos(lastFoldLineNumber, lastFoldLine.length)};
}
}
});
CodeMirror.indentRangeFinder = CodeMirror.fold.indent; // deprecated

View File

@@ -2,14 +2,17 @@
"use strict";
var Pos = CodeMirror.Pos;
function cmp(a, b) { return a.line - b.line || a.ch - b.ch; }
var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
var xmlTagStart = new RegExp("<(/?)([" + nameStartChar + "][" + nameChar + "]*)", "g");
function Iter(cm, line, ch) {
function Iter(cm, line, ch, range) {
this.line = line; this.ch = ch;
this.cm = cm; this.text = cm.getLine(line);
this.min = range ? range.from : cm.firstLine();
this.max = range ? range.to - 1 : cm.lastLine();
}
function tagAt(iter, ch) {
@@ -18,13 +21,13 @@
}
function nextLine(iter) {
if (iter.line >= iter.cm.lastLine()) return;
if (iter.line >= iter.max) return;
iter.ch = 0;
iter.text = iter.cm.getLine(++iter.line);
return true;
}
function prevLine(iter) {
if (iter.line <= iter.cm.firstLine()) return;
if (iter.line <= iter.min) return;
iter.text = iter.cm.getLine(--iter.line);
iter.ch = iter.text.length;
return true;
@@ -43,7 +46,7 @@
}
function toTagStart(iter) {
for (;;) {
var lt = iter.text.lastIndexOf("<", iter.ch - 1);
var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1;
if (lt == -1) { if (prevLine(iter)) continue; else return; }
if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; }
xmlTagStart.lastIndex = lt;
@@ -65,7 +68,7 @@
}
function toPrevTag(iter) {
for (;;) {
var gt = iter.text.lastIndexOf(">", iter.ch - 1);
var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1;
if (gt == -1) { if (prevLine(iter)) continue; else return; }
if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; }
var lastSlash = iter.text.lastIndexOf("/", gt);
@@ -121,7 +124,7 @@
}
}
CodeMirror.tagRangeFinder = function(cm, start) {
CodeMirror.registerHelper("fold", "xml", function(cm, start) {
var iter = new Iter(cm, start.line, 0);
for (;;) {
var openTag = toNextTag(iter), end;
@@ -132,27 +135,31 @@
return close && {from: start, to: close.from};
}
}
};
});
CodeMirror.tagRangeFinder = CodeMirror.fold.xml; // deprecated
CodeMirror.findMatchingTag = function(cm, pos) {
var iter = new Iter(cm, pos.line, pos.ch);
var end = toTagEnd(iter), start = toTagStart(iter);
if (!end || end == "selfClose" || !start) return;
CodeMirror.findMatchingTag = function(cm, pos, range) {
var iter = new Iter(cm, pos.line, pos.ch, range);
if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return;
var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch);
var start = end && toTagStart(iter);
if (!end || end == "selfClose" || !start || cmp(iter, pos) > 0) return;
var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]};
if (start[1]) { // closing tag
return findMatchingOpen(iter, start[2]);
return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"};
} else { // opening tag
toTagEnd(iter);
return findMatchingClose(iter, start[2]);
iter = new Iter(cm, to.line, to.ch, range);
return {open: here, close: findMatchingClose(iter, start[2]), at: "open"};
}
};
CodeMirror.findEnclosingTag = function(cm, pos) {
var iter = new Iter(cm, pos.line, pos.ch);
CodeMirror.findEnclosingTag = function(cm, pos, range) {
var iter = new Iter(cm, pos.line, pos.ch, range);
for (;;) {
var open = findMatchingOpen(iter);
if (!open) break;
var forward = new Iter(cm, pos.line, pos.ch);
var forward = new Iter(cm, pos.line, pos.ch, range);
var close = findMatchingClose(forward, open.tag);
if (close) return {open: open, close: close};
}

View File

@@ -327,9 +327,11 @@
populate(data[tag]);
CodeMirror.htmlSchema = data;
CodeMirror.htmlHint = function(cm, options) {
function htmlHint(cm, options) {
var local = {schemaInfo: data};
if (options) for (var opt in options) local[opt] = options[opt];
return CodeMirror.xmlHint(cm, local);
};
return CodeMirror.hint.xml(cm, local);
}
CodeMirror.htmlHint = htmlHint; // deprecated
CodeMirror.registerHelper("hint", "html", htmlHint);
})();

View File

@@ -33,21 +33,6 @@
tprop = getToken(editor, Pos(cur.line, tprop.start));
if (tprop.string != ".") return;
tprop = getToken(editor, Pos(cur.line, tprop.start));
if (tprop.string == ')') {
var level = 1;
do {
tprop = getToken(editor, Pos(cur.line, tprop.start));
switch (tprop.string) {
case ')': level++; break;
case '(': level--; break;
default: break;
}
} while (level > 0);
tprop = getToken(editor, Pos(cur.line, tprop.start));
if (tprop.type.indexOf("variable") === 0)
tprop.type = "function";
else return; // no clue
}
if (!context) var context = [];
context.push(tprop);
}
@@ -56,11 +41,13 @@
to: Pos(cur.line, token.end)};
}
CodeMirror.javascriptHint = function(editor, options) {
function javascriptHint(editor, options) {
return scriptHint(editor, javascriptKeywords,
function (e, cur) {return e.getTokenAt(cur);},
options);
};
CodeMirror.javascriptHint = javascriptHint; // deprecated
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
function getCoffeeScriptToken(editor, cur) {
// This getToken, it is for coffeescript, imitates the behavior of
@@ -80,9 +67,11 @@
return token;
}
CodeMirror.coffeescriptHint = function(editor, options) {
function coffeescriptHint(editor, options) {
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
};
}
CodeMirror.coffeescriptHint = coffeescriptHint; // deprecated
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
"toUpperCase toLowerCase split concat match replace search").split(" ");
@@ -106,11 +95,11 @@
for (var name in obj) maybeAdd(name);
}
if (context) {
if (context && context.length) {
// If this is a property, see if it belongs to some object we can
// find in the current environment.
var obj = context.pop(), base;
if (obj.type.indexOf("variable") === 0) {
if (obj.type && obj.type.indexOf("variable") === 0) {
if (options && options.additionalContext)
base = options.additionalContext[obj.string];
base = base || window[obj.string];
@@ -128,8 +117,7 @@
while (base != null && context.length)
base = base[context.pop().string];
if (base != null) gatherCompletions(base);
}
else {
} else {
// If not, just look in the window object and any local scope
// (reading into JS mode internals to get at the local and global variables)
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);

View File

@@ -1,4 +1,6 @@
(function () {
"use strict";
function forEach(arr, f) {
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
}
@@ -41,9 +43,11 @@
to: CodeMirror.Pos(cur.line, token.end)};
}
CodeMirror.pigHint = function(editor) {
function pigHint(editor) {
return scriptHint(editor, pigKeywordsU, function (e, cur) {return e.getTokenAt(cur);});
};
}
CodeMirror.pigHint = pigHint; // deprecated
CodeMirror.registerHelper("hint", "pig", pigHint);
var pigKeywords = "VOID IMPORT RETURNS DEFINE LOAD FILTER FOREACH ORDER CUBE DISTINCT COGROUP "
+ "JOIN CROSS UNION SPLIT INTO IF OTHERWISE ALL AS BY USING INNER OUTER ONSCHEMA PARALLEL "

View File

@@ -41,9 +41,11 @@
to: CodeMirror.Pos(cur.line, token.end)};
}
CodeMirror.pythonHint = function(editor) {
function pythonHint(editor) {
return scriptHint(editor, pythonKeywordsU, function (e, cur) {return e.getTokenAt(cur);});
};
}
CodeMirror.pythonHint = pythonHint; // deprecated
CodeMirror.registerHelper("hint", "python", pythonHint);
var pythonKeywords = "and del from not while as elif global or with assert else if pass yield"
+ "break except import print class exec in raise continue finally is return def for lambda try";

View File

@@ -4,6 +4,8 @@
CodeMirror.showHint = function(cm, getHints, options) {
// We want a single cursor position.
if (cm.somethingSelected()) return;
if (getHints == null) getHints = cm.getHelper(cm.getCursor(), "hint");
if (getHints == null) return;
if (cm.state.completionActive) cm.state.completionActive.close();
@@ -25,10 +27,10 @@
Completion.prototype = {
close: function() {
if (!this.active()) return;
this.cm.state.completionActive = null;
if (this.widget) this.widget.close();
if (this.onClose) this.onClose();
this.cm.state.completionActive = null;
CodeMirror.signal(this.cm, "endCompletion", this.cm);
},
@@ -65,24 +67,21 @@
finished = true;
completion.close();
completion.cm.off("cursorActivity", activity);
CodeMirror.signal(data, "close");
}
function isDone() {
if (finished) return true;
if (!completion.widget) { done(); return true; }
if (data) CodeMirror.signal(data, "close");
}
function update() {
if (isDone()) return;
if (finished) return;
CodeMirror.signal(data, "update");
if (completion.options.async)
completion.getHints(completion.cm, finishUpdate, completion.options);
else
finishUpdate(completion.getHints(completion.cm, completion.options));
}
function finishUpdate(data) {
if (isDone()) return;
function finishUpdate(data_) {
data = data_;
if (finished) return;
if (!data || !data.list.length) return done();
completion.widget.close();
completion.widget = new Widget(completion, data);
}
@@ -91,10 +90,12 @@
var pos = completion.cm.getCursor(), line = completion.cm.getLine(pos.line);
if (pos.line != startPos.line || line.length - pos.ch != startLen - startPos.ch ||
pos.ch < startPos.ch || completion.cm.somethingSelected() ||
(pos.ch && closeOn.test(line.charAt(pos.ch - 1))))
(pos.ch && closeOn.test(line.charAt(pos.ch - 1)))) {
completion.close();
else
} else {
debounce = setTimeout(update, 170);
if (completion.widget) completion.widget.close();
}
}
this.cm.on("cursorActivity", activity);
this.onClose = done;
@@ -110,10 +111,10 @@
var baseMap = {
Up: function() {handle.moveFocus(-1);},
Down: function() {handle.moveFocus(1);},
PageUp: function() {handle.moveFocus(-handle.menuSize());},
PageDown: function() {handle.moveFocus(handle.menuSize());},
PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},
PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},
Home: function() {handle.setFocus(0);},
End: function() {handle.setFocus(handle.length);},
End: function() {handle.setFocus(handle.length - 1);},
Enter: handle.pick,
Tab: handle.pick,
Esc: handle.close
@@ -166,6 +167,7 @@
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
(options.container || document.body).appendChild(hints);
var box = hints.getBoundingClientRect();
var overlapX = box.right - winW, overlapY = box.bottom - winH;
if (overlapX > 0) {
@@ -186,10 +188,9 @@
}
hints.style.top = (top = pos.bottom - overlapY) + "px";
}
(options.container || document.body).appendChild(hints);
cm.addKeyMap(this.keyMap = buildKeyMap(options, {
moveFocus: function(n) { widget.changeActive(widget.selectedHint + n); },
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
setFocus: function(n) { widget.changeActive(n); },
menuSize: function() { return widget.screenAmount(); },
length: completions.length,
@@ -249,8 +250,11 @@
this.completion.pick(this.data, this.selectedHint);
},
changeActive: function(i) {
i = Math.max(0, Math.min(i, this.data.list.length - 1));
changeActive: function(i, avoidWrap) {
if (i >= this.data.list.length)
i = avoidWrap ? this.data.list.length - 1 : 0;
else if (i < 0)
i = avoidWrap ? 0 : this.data.list.length - 1;
if (this.selectedHint == i) return;
var node = this.hints.childNodes[this.selectedHint];
node.className = node.className.replace(" CodeMirror-hint-active", "");

View File

@@ -3,7 +3,7 @@
var Pos = CodeMirror.Pos;
CodeMirror.xmlHint = function(cm, options) {
function getHints(cm, options) {
var tags = options && options.schemaInfo;
var quote = (options && options.quoteChar) || '"';
if (!tags) return;
@@ -37,6 +37,7 @@
Pos(cur.line, token.type == "string" ? token.start : token.end));
var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues;
if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return;
if (typeof atValues == 'function') atValues = atValues.call(this, cm); // Functions can be used to supply values for autocomplete widget
if (token.type == "string") {
prefix = token.string;
if (/['"]/.test(token.string.charAt(0))) {
@@ -61,5 +62,8 @@
from: replaceToken ? Pos(cur.line, token.start) : cur,
to: replaceToken ? Pos(cur.line, token.end) : cur
};
};
}
CodeMirror.xmlHint = getHints; // deprecated
CodeMirror.registerHelper("hint", "xml", getHints);
})();

View File

@@ -1,6 +1,8 @@
// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
CodeMirror.coffeeValidator = function(text) {
// declare global: coffeelint
CodeMirror.registerHelper("lint", "coffeescript", function(text) {
var found = [];
var parseError = function(err) {
var loc = err.lineNumber;
@@ -21,4 +23,5 @@ CodeMirror.coffeeValidator = function(text) {
message: e.message});
}
return found;
};
});
CodeMirror.coffeeValidator = CodeMirror.lint.coffeescript; // deprecated

View File

@@ -1,4 +1,6 @@
(function() {
"use strict";
// declare global: JSHINT
var bogus = [ "Dangerous comment" ];
@@ -9,18 +11,15 @@
"Unmatched ", " and instead saw", " is not defined",
"Unclosed string", "Stopping, unable to continue" ];
function validator(options, text) {
function validator(text, options) {
JSHINT(text, options);
var errors = JSHINT.data().errors, result = [];
if (errors) parseErrors(errors, result);
return result;
}
CodeMirror.javascriptValidatorWithOptions = function(options) {
return function(text) { return validator(options, text); };
};
CodeMirror.javascriptValidator = CodeMirror.javascriptValidatorWithOptions(null);
CodeMirror.registerHelper("lint", "javascript", validator);
CodeMirror.javascriptValidator = CodeMirror.lint.javascript; // deprecated
function cleanup(error) {
// All problems are warnings by default

View File

@@ -1,6 +1,8 @@
// Depends on jsonlint.js from https://github.com/zaach/jsonlint
CodeMirror.jsonValidator = function(text) {
// declare global: jsonlint
CodeMirror.registerHelper("lint", "json", function(text) {
var found = [];
jsonlint.parseError = function(str, hash) {
var loc = hash.loc;
@@ -11,4 +13,5 @@ CodeMirror.jsonValidator = function(text) {
try { jsonlint.parse(text); }
catch(e) {}
return found;
};
});
CodeMirror.jsonValidator = CodeMirror.lint.json; // deprecated

View File

@@ -14,6 +14,7 @@
padding: 2px 5px;
position: fixed;
white-space: pre;
white-space: pre-wrap;
z-index: 100;
max-width: 600px;
opacity: 0;
@@ -57,40 +58,16 @@
}
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAPVvcvWHiPVucvRuc+ttcfV6f91KVN5LU99PV/FZY/JhaM4oN84pONE4Rd1ATfJLWutVYPRgbdxpcsgWKMgZKs4lNfE/UvE/U+artcpdSc5uXveimslHPuBhW/eJhfV5efaCgO2CgP+/v+PExP///////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACUALAAAAAAQABAAAAZ+wJJwSCwaScgkySgkjTQZTkYzWhadnE5oE+pwqkSshwQqkzxfa4kkQXxEpA9J9EFI1KQGQQBAigYCBA14ExEWF0gXihETeA0QD3AkD5QQg0NsDnAJmwkOd5gYFSQKpXAFDBhqaxgLBwQBBAapq00YEg0UDRKqTGtKSL7Cw8JBADs=");
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=");
}
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAP7bc//egf/ij/7ijv/jl/7kl//mnv7lnv/uwf7CTP7DTf7DT/7IW//Na/7Na//NbP7QdP/dmbltAIJNAF03AMSAJMSCLKqASa2DS6uBSquCSrGHTq6ETbCHT7WKUrKIUcCVXL+UXMOYX8GWXsSZYMiib6+ETbOIUcOXX86uhd3Muf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACsALAAAAAAQABAAAAZowJVwSCwaj0ihikRSJYcoBEL0XKlGkcjImQQhJBREKFnyICoThKeE/AAW6AXgdPyUAgrLJBEo0YsbAQyDhAEdRRwDDw8OaA4NDQImRBgFEJdglxAEGEQZKQcHBqOkKRpFF6mqq1WtrUEAOw==");
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=");
}
.CodeMirror-lint-marker-multiple {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJEAQvB2JVdrAAAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAD1JREFUCNdtjkESADAEAzemf69f66HMqGlOIhYiFRFRtSQBWAY7mzx+EDTL6sSgb1jTk7Q87rxyqe37fXsAa78gLyZnRgEAAAAASUVORK5CYII=");
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");
background-repeat: no-repeat;
background-position: right bottom;
width: 100%; height: 100%;
}
/* Styles for the overview ruler
.annotationOverview {
cursor: pointer;
border-radius: 2px;
left: 2px;
width: 8px;
}
.annotationOverview.error {
background-color: lightcoral;
border: 1px solid darkred;
}
.annotationOverview.warning {
background-color: Gold;
border: 1px solid black;
}
.annotationHTML.overlay {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJEAQvB2JVdrAAAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAD1JREFUCNdtjkESADAEAzemf69f66HMqGlOIhYiFRFRtSQBWAY7mzx+EDTL6sSgb1jTk7Q87rxyqe37fXsAa78gLyZnRgEAAAAASUVORK5CYII=");
background-position: right bottom;
position: relative;
top: -16px;
}
*/

View File

@@ -1,4 +1,5 @@
CodeMirror.validate = (function() {
(function() {
"use strict";
var GUTTER_ID = "CodeMirror-lint-markers";
var SEVERITIES = /^(?:error|warning)$/;
@@ -52,9 +53,11 @@ CodeMirror.validate = (function() {
this.onMouseOver = function(e) { onMouseOver(cm, e); };
}
function parseOptions(options) {
function parseOptions(cm, options) {
if (options instanceof Function) return {getAnnotations: options};
else if (!options || !options.getAnnotations) throw new Error("Required option 'getAnnotations' missing (lint addon)");
if (!options || options === true) options = {};
if (!options.getAnnotations) options.getAnnotations = cm.getHelper(CodeMirror.Pos(0, 0), "lint");
if (!options.getAnnotations) throw new Error("Required option 'getAnnotations' missing (lint addon)");
return options;
}
@@ -109,7 +112,7 @@ CodeMirror.validate = (function() {
if (options.async)
options.getAnnotations(cm, updateLinting, options);
else
updateLinting(cm, options.getAnnotations(cm.getValue()));
updateLinting(cm, options.getAnnotations(cm.getValue(), options));
}
function updateLinting(cm, annotationsNotSorted) {
@@ -175,7 +178,7 @@ CodeMirror.validate = (function() {
}
}
CodeMirror.defineOption("lintWith", false, function(cm, val, old) {
function optionHandler(cm, val, old) {
if (old && old != CodeMirror.Init) {
clearMarks(cm);
cm.off("change", onChange);
@@ -186,12 +189,15 @@ CodeMirror.validate = (function() {
if (val) {
var gutters = cm.getOption("gutters"), hasLintGutter = false;
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
var state = cm.state.lint = new LintState(cm, parseOptions(val), hasLintGutter);
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
cm.on("change", onChange);
if (state.options.tooltips != false)
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
startLinting(cm);
}
});
}
CodeMirror.defineOption("lintWith", false, optionHandler); // deprecated
CodeMirror.defineOption("lint", false, optionHandler); // deprecated
})();

View File

@@ -1,24 +1,34 @@
.CodeMirror-diff {
.CodeMirror-merge {
position: relative;
border: 1px solid #ddd;
white-space: pre;
}
.CodeMirror-diff, .CodeMirror-diff .CodeMirror {
.CodeMirror-merge, .CodeMirror-merge .CodeMirror {
height: 350px;
}
.CodeMirror-diff-2pane .CodeMirror-diff-pane { width: 47%; }
.CodeMirror-diff-2pane .CodeMirror-diff-gap { width: 6%; }
.CodeMirror-diff-3pane .CodeMirror-diff-pane { width: 31%; }
.CodeMirror-diff-3pane .CodeMirror-diff-gap { width: 3.5%; }
.CodeMirror-merge-2pane .CodeMirror-merge-pane { width: 47%; }
.CodeMirror-merge-2pane .CodeMirror-merge-gap { width: 6%; }
.CodeMirror-merge-3pane .CodeMirror-merge-pane { width: 31%; }
.CodeMirror-merge-3pane .CodeMirror-merge-gap { width: 3.5%; }
.CodeMirror-diff-pane {
float: left;
.CodeMirror-merge-pane {
display: inline-block;
white-space: normal;
vertical-align: top;
}
.CodeMirror-merge-pane-rightmost {
position: absolute;
right: 0px;
z-index: 1;
}
.CodeMirror-diff-gap {
float: left;
.CodeMirror-merge-gap {
z-index: 2;
display: inline-block;
height: 100%;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow: hidden;
border-left: 1px solid #ddd;
@@ -27,11 +37,11 @@
background: #f8f8f8;
}
.CodeMirror-diff-scrolllock-wrap {
.CodeMirror-merge-scrolllock-wrap {
position: absolute;
bottom: 0; left: 50%;
}
.CodeMirror-diff-scrolllock {
.CodeMirror-merge-scrolllock {
position: relative;
left: -50%;
cursor: pointer;
@@ -39,44 +49,44 @@
line-height: 1;
}
.CodeMirror-diff-copybuttons-left, .CodeMirror-diff-copybuttons-right {
.CodeMirror-merge-copybuttons-left, .CodeMirror-merge-copybuttons-right {
position: absolute;
left: 0; top: 0;
right: 0; bottom: 0;
line-height: 1;
}
.CodeMirror-diff-copy {
.CodeMirror-merge-copy {
position: absolute;
cursor: pointer;
color: #44c;
}
.CodeMirror-diff-copybuttons-left .CodeMirror-diff-copy { left: 2px; }
.CodeMirror-diff-copybuttons-right .CodeMirror-diff-copy { right: 2px; }
.CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy { left: 2px; }
.CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy { right: 2px; }
.CodeMirror-diff-r-inserted, .CodeMirror-diff-l-inserted {
.CodeMirror-merge-r-inserted, .CodeMirror-merge-l-inserted {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==);
background-position: bottom left;
background-repeat: repeat-x;
}
.CodeMirror-diff-r-deleted, .CodeMirror-diff-l-deleted {
.CodeMirror-merge-r-deleted, .CodeMirror-merge-l-deleted {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==);
background-position: bottom left;
background-repeat: repeat-x;
}
.CodeMirror-diff-r-chunk { background: #ffffe0; }
.CodeMirror-diff-r-chunk-start { border-top: 1px solid #ee8; }
.CodeMirror-diff-r-chunk-end { border-bottom: 1px solid #ee8; }
.CodeMirror-diff-r-connect { fill: #ffffe0; stroke: #ee8; stroke-width: 1px; }
.CodeMirror-merge-r-chunk { background: #ffffe0; }
.CodeMirror-merge-r-chunk-start { border-top: 1px solid #ee8; }
.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #ee8; }
.CodeMirror-merge-r-connect { fill: #ffffe0; stroke: #ee8; stroke-width: 1px; }
.CodeMirror-diff-l-chunk { background: #eef; }
.CodeMirror-diff-l-chunk-start { border-top: 1px solid #88e; }
.CodeMirror-diff-l-chunk-end { border-bottom: 1px solid #88e; }
.CodeMirror-diff-l-connect { fill: #eef; stroke: #88e; stroke-width: 1px; }
.CodeMirror-merge-l-chunk { background: #eef; }
.CodeMirror-merge-l-chunk-start { border-top: 1px solid #88e; }
.CodeMirror-merge-l-chunk-end { border-bottom: 1px solid #88e; }
.CodeMirror-merge-l-connect { fill: #eef; stroke: #88e; stroke-width: 1px; }
.CodeMirror-diff-l-chunk.CodeMirror-diff-r-chunk { background: #dfd; }
.CodeMirror-diff-l-chunk-start.CodeMirror-diff-r-chunk-start { border-top: 1px solid #4e4; }
.CodeMirror-diff-l-chunk-end.CodeMirror-diff-r-chunk-end { border-bottom: 1px solid #4e4; }
.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk { background: #dfd; }
.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start { border-top: 1px solid #4e4; }
.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #4e4; }

View File

@@ -1,5 +1,6 @@
(function() {
"use strict";
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
var Pos = CodeMirror.Pos;
var svgNS = "http://www.w3.org/2000/svg";
@@ -8,18 +9,18 @@
this.mv = mv;
this.type = type;
this.classes = type == "left"
? {chunk: "CodeMirror-diff-l-chunk",
start: "CodeMirror-diff-l-chunk-start",
end: "CodeMirror-diff-l-chunk-end",
insert: "CodeMirror-diff-l-inserted",
del: "CodeMirror-diff-l-deleted",
connect: "CodeMirror-diff-l-connect"}
: {chunk: "CodeMirror-diff-r-chunk",
start: "CodeMirror-diff-r-chunk-start",
end: "CodeMirror-diff-r-chunk-end",
insert: "CodeMirror-diff-r-inserted",
del: "CodeMirror-diff-r-deleted",
connect: "CodeMirror-diff-r-connect"};
? {chunk: "CodeMirror-merge-l-chunk",
start: "CodeMirror-merge-l-chunk-start",
end: "CodeMirror-merge-l-chunk-end",
insert: "CodeMirror-merge-l-inserted",
del: "CodeMirror-merge-l-deleted",
connect: "CodeMirror-merge-l-connect"}
: {chunk: "CodeMirror-merge-r-chunk",
start: "CodeMirror-merge-r-chunk-start",
end: "CodeMirror-merge-r-chunk-end",
insert: "CodeMirror-merge-r-inserted",
del: "CodeMirror-merge-r-deleted",
connect: "CodeMirror-merge-r-connect"};
}
DiffView.prototype = {
@@ -31,9 +32,17 @@
this.diff = getDiff(orig, options.value);
this.diffOutOfDate = false;
this.showDifferences = options.showDifferences !== false;
this.forceUpdate = registerUpdate(this);
setScrollLock(this, true, false);
registerScroll(this);
},
setShowDifferences: function(val) {
val = val !== false;
if (val != this.showDifferences) {
this.showDifferences = val;
this.forceUpdate("full");
}
}
};
@@ -41,26 +50,38 @@
var edit = {from: 0, to: 0, marked: []};
var orig = {from: 0, to: 0, marked: []};
var debounceChange;
function update() {
function update(mode) {
if (mode == "full") {
if (dv.svg) clear(dv.svg);
clear(dv.copyButtons);
clearMarks(dv.edit, edit.marked, dv.classes);
clearMarks(dv.orig, orig.marked, dv.classes);
edit.from = edit.to = orig.from = orig.to = 0;
}
if (dv.diffOutOfDate) {
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue());
dv.diffOutOfDate = false;
CodeMirror.signal(dv.edit, "updateDiff", dv.diff);
}
if (dv.showDifferences) {
updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes);
updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes);
}
updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes);
updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes);
drawConnectors(dv);
}
function set(slow) {
clearTimeout(debounceChange);
debounceChange = setTimeout(update, slow == true ? 250 : 100);
}
dv.edit.on("change", function() {
function change() {
if (!dv.diffOutOfDate) {
dv.diffOutOfDate = true;
edit.from = edit.to = orig.from = orig.to = 0;
}
set(true);
});
}
dv.edit.on("change", change);
dv.orig.on("change", change);
dv.edit.on("viewportChange", set);
dv.orig.on("viewportChange", set);
update();
@@ -93,7 +114,21 @@
var off = getOffsets(editor, type == DIFF_INSERT ? around.edit : around.orig);
var offOther = getOffsets(other, type == DIFF_INSERT ? around.orig : around.edit);
var ratio = (midY - off.top) / (off.bot - off.top);
other.scrollTo(null, (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top));
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top);
var botDist, mix;
// Some careful tweaking to make sure no space is left out of view
// when scrolling to top or bottom.
if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) {
targetPos = targetPos * mix + sInfo.top * (1 - mix);
} else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) {
var otherInfo = other.getScrollInfo();
var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos;
if (botDistOther > botDist && (mix = botDist / halfScreen) < 1)
targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix);
}
other.scrollTo(sInfo.left, targetPos);
other.state.scrollSetAt = now;
other.state.scrollSetBy = dv;
return true;
@@ -197,6 +232,8 @@
// Updating the gap between editor and original
function drawConnectors(dv) {
if (!dv.showDifferences) return;
if (dv.svg) {
clear(dv.svg);
var w = dv.gap.offsetWidth;
@@ -208,8 +245,8 @@
var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top;
iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) {
if (topEdit >= vpEdit.to || botEdit < vpEdit.from ||
topOrig >= vpOrig.to || botOrig < vpOrig.from)
if (topEdit > vpEdit.to || botEdit < vpEdit.from ||
topOrig > vpOrig.to || botOrig < vpOrig.from)
return;
var topLpx = dv.orig.heightAtLine(topOrig, "local") - sTopOrig, top = topLpx;
if (dv.svg) {
@@ -225,7 +262,7 @@
"class", dv.classes.connect);
}
var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc",
"CodeMirror-diff-copy"));
"CodeMirror-merge-copy"));
copy.title = "Revert chunk";
copy.chunk = {topEdit: topEdit, botEdit: botEdit, topOrig: topOrig, botOrig: botOrig};
copy.style.top = top + "px";
@@ -250,23 +287,25 @@
if (hasLeft) {
left = this.left = new DiffView(this, "left");
var leftPane = elt("div", null, "CodeMirror-diff-pane");
var leftPane = elt("div", null, "CodeMirror-merge-pane");
wrap.push(leftPane);
wrap.push(buildGap(left));
}
var editPane = elt("div", null, "CodeMirror-diff-pane");
var editPane = elt("div", null, "CodeMirror-merge-pane");
wrap.push(editPane);
if (hasRight) {
right = this.right = new DiffView(this, "right");
wrap.push(buildGap(right));
var rightPane = elt("div", null, "CodeMirror-diff-pane");
var rightPane = elt("div", null, "CodeMirror-merge-pane");
wrap.push(rightPane);
}
(hasRight ? rightPane : editPane).className += " CodeMirror-merge-pane-rightmost";
wrap.push(elt("div", null, null, "height: 0; clear: both;"));
var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-diff CodeMirror-diff-" + panes + "pane"));
var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-merge CodeMirror-merge-" + panes + "pane"));
this.edit = CodeMirror(editPane, copyObj(options));
if (left) left.init(leftPane, origLeft, options);
@@ -284,11 +323,11 @@
};
function buildGap(dv) {
var lock = dv.lockButton = elt("div", null, "CodeMirror-diff-scrolllock");
var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock");
lock.title = "Toggle locked scrolling";
var lockWrap = elt("div", [lock], "CodeMirror-diff-scrolllock-wrap");
var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap");
CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); });
dv.copyButtons = elt("div", null, "CodeMirror-diff-copybuttons-" + dv.type);
dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type);
CodeMirror.on(dv.copyButtons, "click", function(e) {
var node = e.target || e.srcElement;
if (node.chunk) copyChunk(dv, node.chunk);
@@ -299,14 +338,18 @@
dv.svg = svg;
if (svg) gapElts.push(svg);
return dv.gap = elt("div", gapElts, "CodeMirror-diff-gap");
return dv.gap = elt("div", gapElts, "CodeMirror-merge-gap");
}
MergeView.prototype = {
constuctor: MergeView,
editor: function() { return this.edit; },
rightOriginal: function() { return this.right && this.right.orig; },
leftOriginal: function() { return this.left && this.left.orig; }
leftOriginal: function() { return this.left && this.left.orig; },
setShowDifferences: function(val) {
if (this.right) this.right.setShowDifferences(val);
if (this.left) this.left.setShowDifferences(val);
}
};
// Operations on diffs

View File

@@ -2,6 +2,9 @@
window.CodeMirror = {};
(function() {
"use strict";
function splitLines(string){ return string.split(/\r?\n|\r/); };
function StringStream(string) {
@@ -43,12 +46,14 @@ StringStream.prototype = {
match: function(pattern, consume, caseInsensitive) {
if (typeof pattern == "string") {
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
var substr = this.string.substr(this.pos, pattern.length);
if (cased(substr) == cased(pattern)) {
if (consume !== false) this.pos += pattern.length;
return true;
}
} else {
var match = this.string.slice(this.pos).match(pattern);
if (match && match.index > 0) return null;
if (match && consume !== false) this.pos += match[0].length;
return match;
}
@@ -123,8 +128,9 @@ CodeMirror.runMode = function (string, modespec, callback, options) {
var stream = new CodeMirror.StringStream(lines[i]);
while (!stream.eol()) {
var style = mode.token(stream, state);
callback(stream.current(), style, i, stream.start);
callback(stream.current(), style, i, stream.start, state);
stream.start = stream.pos;
}
}
};
})();

View File

@@ -49,7 +49,7 @@ CodeMirror.runMode = function(string, modespec, callback, options) {
var stream = new CodeMirror.StringStream(lines[i]);
while (!stream.eol()) {
var style = mode.token(stream, state);
callback(stream.current(), style, i, stream.start);
callback(stream.current(), style, i, stream.start, state);
stream.start = stream.pos;
}
}

View File

@@ -41,12 +41,14 @@ StringStream.prototype = {
match: function(pattern, consume, caseInsensitive) {
if (typeof pattern == "string") {
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
var substr = this.string.substr(this.pos, pattern.length);
if (cased(substr) == cased(pattern)) {
if (consume !== false) this.pos += pattern.length;
return true;
}
} else {
var match = this.string.slice(this.pos).match(pattern);
if (match && match.index > 0) return null;
if (match && consume !== false) this.pos += match[0].length;
return match;
}
@@ -94,7 +96,7 @@ exports.runMode = function(string, modespec, callback) {
var stream = new exports.StringStream(lines[i]);
while (!stream.eol()) {
var style = mode.token(stream, state);
callback(stream.current(), style, i, stream.start);
callback(stream.current(), style, i, stream.start, state);
stream.start = stream.pos;
}
}

View File

@@ -15,15 +15,18 @@
(function() {
var DEFAULT_MIN_CHARS = 2;
var DEFAULT_TOKEN_STYLE = "matchhighlight";
var DEFAULT_DELAY = 100;
function State(options) {
if (typeof options == "object") {
this.minChars = options.minChars;
this.style = options.style;
this.showToken = options.showToken;
this.delay = options.delay;
}
if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
if (this.delay == null) this.delay = DEFAULT_DELAY;
this.overlay = this.timeout = null;
}
@@ -45,7 +48,7 @@
function cursorActivity(cm) {
var state = cm.state.matchHighlighter;
clearTimeout(state.timeout);
state.timeout = setTimeout(function() {highlightMatches(cm);}, 100);
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay);
}
function highlightMatches(cm) {
@@ -55,11 +58,13 @@
cm.removeOverlay(state.overlay);
state.overlay = null;
}
if (!cm.somethingSelected() && state.showToken) {
var tok = cm.getTokenAt(cm.getCursor()).string;
if (/\w/.test(tok))
cm.addOverlay(state.overlay = makeOverlay(tok, true, state.style));
var re = state.showToken === true ? /[\w$]/ : state.showToken;
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
while (start && re.test(line.charAt(start - 1))) --start;
while (end < line.length && re.test(line.charAt(end))) ++end;
if (start < end)
cm.addOverlay(state.overlay = makeOverlay(line.slice(start, end), re, state.style));
return;
}
if (cm.getCursor("head").line != cm.getCursor("anchor").line) return;
@@ -69,15 +74,15 @@
});
}
function boundariesAround(stream) {
return (stream.start || /.\b./.test(stream.string.slice(stream.start - 1, stream.start + 1))) &&
(stream.pos == stream.string.length || /.\b./.test(stream.string.slice(stream.pos - 1, stream.pos + 1)));
function boundariesAround(stream, re) {
return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) &&
(stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos)));
}
function makeOverlay(query, wordBoundaries, style) {
function makeOverlay(query, hasBoundary, style) {
return {token: function(stream) {
if (stream.match(query) &&
(!wordBoundaries || boundariesAround(stream)))
(!hasBoundary || boundariesAround(stream, hasBoundary)))
return style;
stream.next();
stream.skipTo(query.charAt(0)) || stream.skipToEnd();

View File

@@ -70,6 +70,7 @@
if (!cursor.find(rev)) return;
}
cm.setSelection(cursor.from(), cursor.to());
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
state.posFrom = cursor.from(); state.posTo = cursor.to();
});}
function clearSearch(cm) {cm.operation(function() {
@@ -108,6 +109,7 @@
(start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
}
cm.setSelection(cursor.from(), cursor.to());
cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
confirmDialog(cm, doReplaceConfirm, "Replace?",
[function() {doReplace(match);}, advance]);
};

View File

@@ -69,8 +69,8 @@
this.matches = function(reverse, pos) {
var ln = pos.line, idx = (reverse ? target.length - 1 : 0), match = target[idx], line = fold(doc.getLine(ln));
var offsetA = (reverse ? line.indexOf(match) + match.length : line.lastIndexOf(match));
if (reverse ? offsetA >= pos.ch || offsetA != match.length
: offsetA <= pos.ch || offsetA != line.length - match.length)
if (reverse ? offsetA > pos.ch || offsetA != match.length
: offsetA < pos.ch || offsetA != line.length - match.length)
return;
for (;;) {
if (reverse ? !ln : ln == doc.lineCount() - 1) return;

View File

@@ -29,7 +29,7 @@
}
function updateActiveLine(cm) {
var line = cm.getLineHandle(cm.getCursor().line);
var line = cm.getLineHandleVisualStart(cm.getCursor().line);
if (cm.state.activeLine == line) return;
clearActiveLine(cm);
cm.addLineClass(line, "wrap", WRAP_CLASS);

View File

@@ -1,11 +1,12 @@
#!/usr/bin/env node
var lint = require("../test/lint/lint");
var lint = require("../test/lint/lint"),
path = require("path");
if (process.argv.length > 2) {
lint.checkDir(process.argv[2]);
} else {
process.chdir(__dirname.slice(0, __dirname.lastIndexOf("/")));
process.chdir(path.resolve(__dirname, ".."));
lint.checkDir("lib");
lint.checkDir("mode");
lint.checkDir("addon");

View File

@@ -353,7 +353,7 @@
},
"Ctrl-S": "save", "Ctrl-W": "save", "S": "saveAll", "F": "open", "U": repeated("undo"), "K": "close",
"Delete": function(cm) { kill(cm, cm.getCursor(), sentenceEnd(cm, 1), true); },
"Delete": function(cm) { kill(cm, cm.getCursor(), bySentence(cm, cm.getCursor(), 1), true); },
auto: "emacs", nofallthrough: true, disableInput: true
};

View File

@@ -40,6 +40,10 @@
* TODO: Implement the remaining special marks. They have more complex
* behavior.
*
* Events:
* 'vim-mode-change' - raised on the editor anytime the current mode changes,
* Event object: {mode: "visual", subMode: "linewise"}
*
* Code structure:
* 1. Default keymap
* 2. Variable declarations and short basic helpers
@@ -72,8 +76,10 @@
{ keys: ['<C-p>'], type: 'keyToKey', toKeys: ['k'] },
{ keys: ['C-['], type: 'keyToKey', toKeys: ['<Esc>'] },
{ keys: ['<C-c>'], type: 'keyToKey', toKeys: ['<Esc>'] },
{ keys: ['s'], type: 'keyToKey', toKeys: ['c', 'l'] },
{ keys: ['S'], type: 'keyToKey', toKeys: ['c', 'c'] },
{ keys: ['s'], type: 'keyToKey', toKeys: ['c', 'l'], context: 'normal' },
{ keys: ['s'], type: 'keyToKey', toKeys: ['x', 'i'], context: 'visual'},
{ keys: ['S'], type: 'keyToKey', toKeys: ['c', 'c'], context: 'normal' },
{ keys: ['S'], type: 'keyToKey', toKeys: ['d', 'c', 'c'], context: 'visual' },
{ keys: ['<Home>'], type: 'keyToKey', toKeys: ['0'] },
{ keys: ['<End>'], type: 'keyToKey', toKeys: ['$'] },
{ keys: ['<PageUp>'], type: 'keyToKey', toKeys: ['<C-b>'] },
@@ -206,8 +212,7 @@
// Operators
{ keys: ['d'], type: 'operator', operator: 'delete' },
{ keys: ['y'], type: 'operator', operator: 'yank' },
{ keys: ['c'], type: 'operator', operator: 'change',
operatorArgs: { enterInsertMode: true } },
{ keys: ['c'], type: 'operator', operator: 'change' },
{ keys: ['>'], type: 'operator', operator: 'indent',
operatorArgs: { indentRight: true }},
{ keys: ['<'], type: 'operator', operator: 'indent',
@@ -231,10 +236,11 @@
motion: 'moveToEol', motionArgs: { inclusive: true },
operatorMotionArgs: { visualLine: true }},
{ keys: ['C'], type: 'operatorMotion',
operator: 'change', operatorArgs: { enterInsertMode: true },
operator: 'change',
motion: 'moveToEol', motionArgs: { inclusive: true },
operatorMotionArgs: { visualLine: true }},
{ keys: ['~'], type: 'operatorMotion', operator: 'swapcase',
{ keys: ['~'], type: 'operatorMotion',
operator: 'swapcase', operatorArgs: { shouldMoveCursor: true },
motion: 'moveByCharacters', motionArgs: { forward: true }},
// Actions
{ keys: ['<C-i>'], type: 'action', action: 'jumpListWalk',
@@ -315,6 +321,28 @@
];
var Vim = function() {
CodeMirror.defineOption('vimMode', false, function(cm, val) {
if (val) {
cm.setOption('keyMap', 'vim');
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
cm.on('beforeSelectionChange', beforeSelectionChange);
maybeInitVimState(cm);
} else if (cm.state.vim) {
cm.setOption('keyMap', 'default');
cm.off('beforeSelectionChange', beforeSelectionChange);
cm.state.vim = null;
}
});
function beforeSelectionChange(cm, cur) {
var vim = cm.state.vim;
if (vim.insertMode || vim.exMode) return;
var head = cur.head;
if (head.ch && head.ch == cm.doc.getLine(head.line).length) {
head.ch--;
}
}
var numberRegex = /[\d]/;
var wordRegexp = [(/\w/), (/[^\w\s]/)], bigWordRegexp = [(/\S/)];
function makeKeyRange(start, size) {
@@ -450,28 +478,11 @@
};
};
// Global Vim state. Call getVimGlobalState to get and initialize.
var vimGlobalState;
function getVimGlobalState() {
if (!vimGlobalState) {
vimGlobalState = {
// The current search query.
searchQuery: null,
// Whether we are searching backwards.
searchIsReversed: false,
jumpList: createCircularJumpList(),
macroModeState: createMacroState(),
// Recording latest f, t, F or T motion command.
lastChararacterSearch: {increment:0, forward:true, selectedCharacter:''},
registerController: new RegisterController({})
};
}
return vimGlobalState;
}
function getVimState(cm) {
if (!cm.vimState) {
function maybeInitVimState(cm) {
if (!cm.state.vim) {
// Store instance state in the CodeMirror object.
cm.vimState = {
cm.state.vim = {
inputState: new InputState(),
// Vim's input state that triggered the last edit, used to repeat
// motions and operators with '.'.
@@ -500,7 +511,21 @@
visualLine: false
};
}
return cm.vimState;
return cm.state.vim;
}
var vimGlobalState;
function resetVimGlobalState() {
vimGlobalState = {
// The current search query.
searchQuery: null,
// Whether we are searching backwards.
searchIsReversed: false,
jumpList: createCircularJumpList(),
macroModeState: createMacroState(),
// Recording latest f, t, F or T motion command.
lastChararacterSearch: {increment:0, forward:true, selectedCharacter:''},
registerController: new RegisterController({})
};
}
var vimApi= {
@@ -510,16 +535,19 @@
// Testing hook, though it might be useful to expose the register
// controller anyways.
getRegisterController: function() {
return getVimGlobalState().registerController;
return vimGlobalState.registerController;
},
// Testing hook.
clearVimGlobalState_: function() {
vimGlobalState = null;
},
resetVimGlobalState_: resetVimGlobalState,
// Testing hook.
getVimGlobalState_: function() {
return vimGlobalState;
},
// Testing hook.
maybeInitVimState_: maybeInitVimState,
InsertModeKey: InsertModeKey,
map: function(lhs, rhs) {
// Add user defined key bindings.
@@ -532,17 +560,12 @@
exCommands[name]=func;
exCommandDispatcher.commandMap_[prefix]={name:name, shortName:prefix, type:'api'};
},
// Initializes vim state variable on the CodeMirror object. Should only be
// called lazily by handleKey or for testing.
maybeInitState: function(cm) {
getVimState(cm);
},
// This is the outermost function called by CodeMirror, after keys have
// been mapped to their Vim equivalents.
handleKey: function(cm, key) {
var command;
var vim = getVimState(cm);
var macroModeState = getVimGlobalState().macroModeState;
var vim = maybeInitVimState(cm);
var macroModeState = vimGlobalState.macroModeState;
if (macroModeState.enteredMacroMode) {
if (key == 'q') {
actions.exitMacroRecordMode();
@@ -554,19 +577,17 @@
// Clear input state and get back to normal mode.
vim.inputState = new InputState();
if (vim.visualMode) {
exitVisualMode(cm, vim);
exitVisualMode(cm);
}
return;
}
if (vim.visualMode &&
cursorEqual(cm.getCursor('head'), cm.getCursor('anchor'))) {
// The selection was cleared. Exit visual mode.
exitVisualMode(cm, vim);
}
// Enter visual mode when the mouse selects text.
if (!vim.visualMode &&
!cursorEqual(cm.getCursor('head'), cm.getCursor('anchor'))) {
vim.visualMode = true;
vim.visualLine = false;
CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"});
cm.on('mousedown', exitVisualMode);
}
if (key != '0' || (key == '0' && vim.inputState.getRepeat() === 0)) {
// Have to special case 0 since it's both a motion and a number.
@@ -590,6 +611,9 @@
}
commandDispatcher.processCommand(cm, vim, command);
}
},
handleEx: function(cm, input) {
exCommandDispatcher.processCommand(cm, input);
}
};
@@ -676,6 +700,9 @@
if (linewise && text.charAt(0) == '\n') {
text = text.slice(1) + '\n';
}
if(linewise && text.charAt(text.length - 1) !== '\n'){
text += '\n';
}
// Lowercase and uppercase registers refer to the same register.
// Uppercase just means append.
var register = this.isValidRegister(registerName) ?
@@ -747,44 +774,74 @@
matchCommand: function(key, keyMap, vim) {
var inputState = vim.inputState;
var keys = inputState.keyBuffer.concat(key);
var matchedCommands = [];
var selectedCharacter;
for (var i = 0; i < keyMap.length; i++) {
var command = keyMap[i];
if (matchKeysPartial(keys, command.keys)) {
if (keys.length < command.keys.length) {
// Matches part of a multi-key command. Buffer and wait for next
// stroke.
inputState.keyBuffer.push(key);
return null;
}
if (inputState.operator && command.type == 'action') {
// Ignore matched action commands after an operator. Operators
// only operate on motions. This check is really for text
// objects since aW, a[ etcs conflicts with a.
continue;
}
// Matches whole comand. Return the command.
// Match commands that take <character> as an argument.
if (command.keys[keys.length - 1] == 'character') {
inputState.selectedCharacter = keys[keys.length - 1];
if(inputState.selectedCharacter.length>1){
switch(inputState.selectedCharacter){
selectedCharacter = keys[keys.length - 1];
if(selectedCharacter.length>1){
switch(selectedCharacter){
case '<CR>':
inputState.selectedCharacter='\n';
selectedCharacter='\n';
break;
case '<Space>':
inputState.selectedCharacter=' ';
selectedCharacter=' ';
break;
default:
continue;
}
}
}
// Add the command to the list of matched commands. Choose the best
// command later.
matchedCommands.push(command);
}
}
// Returns the command if it is a full match, or null if not.
function getFullyMatchedCommandOrNull(command) {
if (keys.length < command.keys.length) {
// Matches part of a multi-key command. Buffer and wait for next
// stroke.
inputState.keyBuffer.push(key);
return null;
} else {
if (command.keys[keys.length - 1] == 'character') {
inputState.selectedCharacter = selectedCharacter;
}
// Clear the buffer since a full match was found.
inputState.keyBuffer = [];
return command;
}
}
// Clear the buffer since there are no partial matches.
inputState.keyBuffer = [];
return null;
if (!matchedCommands.length) {
// Clear the buffer since there were no matches.
inputState.keyBuffer = [];
return null;
} else if (matchedCommands.length == 1) {
return getFullyMatchedCommandOrNull(matchedCommands[0]);
} else {
// Find the best match in the list of matchedCommands.
var context = vim.visualMode ? 'visual' : 'normal';
var bestMatch = matchedCommands[0]; // Default to first in the list.
for (var i = 0; i < matchedCommands.length; i++) {
if (matchedCommands[i].context == context) {
bestMatch = matchedCommands[i];
break;
}
}
return getFullyMatchedCommandOrNull(bestMatch);
}
},
processCommand: function(cm, vim, command) {
vim.inputState.repeatOverride = command.repeatOverride;
@@ -970,7 +1027,7 @@
// cachedCursor is used to save the old position of the cursor
// when * or # causes vim to seek for the nearest word and shift
// the cursor before entering the motion.
getVimGlobalState().jumpList.cachedCursor = cm.getCursor();
vimGlobalState.jumpList.cachedCursor = cm.getCursor();
cm.setCursor(word.start);
handleQuery(query, true /** ignoreCase */, false /** smartCase */);
@@ -1052,7 +1109,7 @@
return;
}
if (motionArgs.toJumplist) {
var jumpList = getVimGlobalState().jumpList;
var jumpList = vimGlobalState.jumpList;
// if the current motion is # or *, use cachedCursor
var cachedCursor = jumpList.cachedCursor;
if (cachedCursor) {
@@ -1091,6 +1148,11 @@
if (vim.visualLine) {
if (cursorIsBefore(selectionStart, selectionEnd)) {
selectionStart.ch = 0;
var lastLine = cm.lastLine();
if (selectionEnd.line > lastLine) {
selectionEnd.line = lastLine;
}
selectionEnd.ch = lineLength(cm, selectionEnd.line);
} else {
selectionEnd.ch = 0;
@@ -1146,15 +1208,12 @@
operators[operator](cm, operatorArgs, vim, curStart,
curEnd, curOriginal);
if (vim.visualMode) {
exitVisualMode(cm, vim);
}
if (operatorArgs.enterInsertMode) {
actions.enterInsertMode(cm, {}, vim);
exitVisualMode(cm);
}
}
},
recordLastEdit: function(vim, inputState, actionCommand) {
var macroModeState = getVimGlobalState().macroModeState;
var macroModeState = vimGlobalState.macroModeState;
if (macroModeState.inReplay) { return; }
vim.lastEditInputState = inputState;
vim.lastEditActionCommand = actionCommand;
@@ -1272,8 +1331,13 @@
}
var repeat = motionArgs.repeat+(motionArgs.repeatOffset||0);
var line = motionArgs.forward ? cur.line + repeat : cur.line - repeat;
if (line < cm.firstLine() || line > cm.lastLine() ) {
return null;
var first = cm.firstLine();
var last = cm.lastLine();
// Vim cancels linewise motions that start on an edge and move beyond
// that edge. It does not cancel motions that do not start on an edge.
if ((line < first && cur.line == first) ||
(line > last && cur.line == last)) {
return;
}
if(motionArgs.toFirstChar){
endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));
@@ -1456,7 +1520,7 @@
return [start, end];
},
repeatLastCharacterSearch: function(cm, motionArgs) {
var lastSearch = getVimGlobalState().lastChararacterSearch;
var lastSearch = vimGlobalState.lastChararacterSearch;
var repeat = motionArgs.repeat;
var forward = motionArgs.forward === lastSearch.forward;
var increment = (lastSearch.increment ? 1 : 0) * (forward ? -1 : 1);
@@ -1474,22 +1538,16 @@
var operators = {
change: function(cm, operatorArgs, _vim, curStart, curEnd) {
getVimGlobalState().registerController.pushText(
vimGlobalState.registerController.pushText(
operatorArgs.registerName, 'change', cm.getRange(curStart, curEnd),
operatorArgs.linewise);
if (operatorArgs.linewise) {
// Delete starting at the first nonwhitespace character of the first
// line, instead of from the start of the first line. This way we get
// an indent when we get into insert mode. This behavior isn't quite
// correct because we should treat this as a completely new line, and
// indent should be whatever codemirror thinks is the right indent.
// But cm.indentLine doesn't seem work on empty lines.
// TODO: Fix the above.
curStart.ch =
findFirstNonWhiteSpaceCharacter(cm.getLine(curStart.line));
// Insert an additional newline so that insert mode can start there.
// curEnd should be on the first character of the new line.
cm.replaceRange('\n', curStart, curEnd);
// Push the next line back down, if there is a next line.
var replacement = curEnd.line > cm.lastLine() ? '' : '\n';
cm.replaceRange(replacement, curStart, curEnd);
cm.indentLine(curStart.line, 'smart');
// null ch so setCursor moves to end of line.
curStart.ch = null;
} else {
// Exclude trailing whitespace if the range is not all whitespace.
var text = cm.getRange(curStart, curEnd);
@@ -1501,6 +1559,7 @@
}
cm.replaceRange('', curStart, curEnd);
}
actions.enterInsertMode(cm, {}, cm.state.vim);
cm.setCursor(curStart);
},
// delete is a javascript keyword.
@@ -1512,7 +1571,7 @@
curStart.line--;
curStart.ch = lineLength(cm, curStart.line);
}
getVimGlobalState().registerController.pushText(
vimGlobalState.registerController.pushText(
operatorArgs.registerName, 'delete', cm.getRange(curStart, curEnd),
operatorArgs.linewise);
cm.replaceRange('', curStart, curEnd);
@@ -1542,7 +1601,7 @@
cm.setCursor(curStart);
cm.setCursor(motions.moveToFirstNonWhiteSpaceCharacter(cm));
},
swapcase: function(cm, _operatorArgs, _vim, curStart, curEnd, curOriginal) {
swapcase: function(cm, operatorArgs, _vim, curStart, curEnd, curOriginal) {
var toSwap = cm.getRange(curStart, curEnd);
var swapped = '';
for (var i = 0; i < toSwap.length; i++) {
@@ -1551,10 +1610,12 @@
character.toUpperCase();
}
cm.replaceRange(swapped, curStart, curEnd);
cm.setCursor(curOriginal);
if (!operatorArgs.shouldMoveCursor) {
cm.setCursor(curOriginal);
}
},
yank: function(cm, operatorArgs, _vim, curStart, curEnd, curOriginal) {
getVimGlobalState().registerController.pushText(
vimGlobalState.registerController.pushText(
operatorArgs.registerName, 'yank',
cm.getRange(curStart, curEnd), operatorArgs.linewise);
cm.setCursor(curOriginal);
@@ -1568,7 +1629,7 @@
}
var repeat = actionArgs.repeat;
var forward = actionArgs.forward;
var jumpList = getVimGlobalState().jumpList;
var jumpList = vimGlobalState.jumpList;
var mark = jumpList.move(cm, forward ? repeat : -repeat);
var markPos = mark ? mark.find() : undefined;
@@ -1594,7 +1655,7 @@
replayMacro: function(cm, actionArgs) {
var registerName = actionArgs.selectedCharacter;
var repeat = actionArgs.repeat;
var macroModeState = getVimGlobalState().macroModeState;
var macroModeState = vimGlobalState.macroModeState;
if (registerName == '@') {
registerName = macroModeState.latestRegister;
}
@@ -1604,18 +1665,19 @@
}
},
exitMacroRecordMode: function() {
var macroModeState = getVimGlobalState().macroModeState;
var macroModeState = vimGlobalState.macroModeState;
macroModeState.toggle();
parseKeyBufferToRegister(macroModeState.latestRegister,
macroModeState.macroKeyBuffer);
},
enterMacroRecordMode: function(cm, actionArgs) {
var macroModeState = getVimGlobalState().macroModeState;
var macroModeState = vimGlobalState.macroModeState;
var registerName = actionArgs.selectedCharacter;
macroModeState.toggle(cm, registerName);
emptyMacroKeyBuffer(macroModeState);
},
enterInsertMode: function(cm, actionArgs, vim) {
if (cm.getOption('readOnly')) { return; }
vim.insertMode = true;
vim.insertModeRepeat = actionArgs && actionArgs.repeat || 1;
var insertAt = (actionArgs) ? actionArgs.insertAt : null;
@@ -1633,10 +1695,12 @@
// Handle Replace-mode as a special case of insert mode.
cm.toggleOverwrite(true);
cm.setOption('keyMap', 'vim-replace');
CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
} else {
cm.setOption('keyMap', 'vim-insert');
CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
}
if (!getVimGlobalState().macroModeState.inReplay) {
if (!vimGlobalState.macroModeState.inReplay) {
// Only record if not replaying.
cm.on('change', onChange);
cm.on('cursorActivity', onCursorActivity);
@@ -1651,6 +1715,7 @@
// equal to the repeat times the size of the previous visual
// operation.
if (!vim.visualMode) {
cm.on('mousedown', exitVisualMode);
vim.visualMode = true;
vim.visualLine = !!actionArgs.linewise;
if (vim.visualLine) {
@@ -1675,6 +1740,7 @@
} else {
cm.setSelection(curStart, curEnd);
}
CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: vim.visualLine ? "linewise" : ""});
} else {
curStart = cm.getCursor('anchor');
curEnd = cm.getCursor('head');
@@ -1687,12 +1753,14 @@
curEnd.ch = cursorIsBefore(curStart, curEnd) ?
lineLength(cm, curEnd.line) : 0;
cm.setSelection(curStart, curEnd);
CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: "linewise"});
} else if (vim.visualLine && !actionArgs.linewise) {
// v pressed in linewise visual mode. Switch to characterwise visual
// mode instead of exiting visual mode.
vim.visualLine = false;
CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"});
} else {
exitVisualMode(cm, vim);
exitVisualMode(cm);
}
}
updateMark(cm, vim, '<', cursorIsBefore(curStart, curEnd) ? curStart
@@ -1728,6 +1796,7 @@
});
},
newLineAndEnterInsertMode: function(cm, actionArgs, vim) {
vim.insertMode = true;
var insertAt = cm.getCursor();
if (insertAt.line === cm.firstLine() && !actionArgs.after) {
// Special case for inserting newline before start of document.
@@ -1746,7 +1815,7 @@
},
paste: function(cm, actionArgs) {
var cur = cm.getCursor();
var register = getVimGlobalState().registerController.getRegister(
var register = vimGlobalState.registerController.getRegister(
actionArgs.registerName);
if (!register.text) {
return;
@@ -1832,7 +1901,7 @@
cm.replaceRange(replaceWithStr, curStart, curEnd);
if(vim.visualMode){
cm.setCursor(curStart);
exitVisualMode(cm,vim);
exitVisualMode(cm);
}else{
cm.setCursor(offsetCursor(curEnd, 0, -1));
}
@@ -1989,7 +2058,9 @@
return s.replace(/([.?*+$\[\]\/\\(){}|\-])/g, '\\$1');
}
function exitVisualMode(cm, vim) {
function exitVisualMode(cm) {
cm.off('mousedown', exitVisualMode);
var vim = cm.state.vim;
vim.visualMode = false;
vim.visualLine = false;
var selectionStart = cm.getCursor('anchor');
@@ -2000,6 +2071,7 @@
// it's not supposed to be.
cm.setCursor(clipCursorToContent(cm, selectionEnd));
}
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
}
// Remove any trailing newlines from the selection. For
@@ -2113,12 +2185,11 @@
function recordJumpPosition(cm, oldCur, newCur) {
if(!cursorEqual(oldCur, newCur)) {
getVimGlobalState().jumpList.add(cm, oldCur, newCur);
vimGlobalState.jumpList.add(cm, oldCur, newCur);
}
}
function recordLastCharacterSearch(increment, args) {
var vimGlobalState = getVimGlobalState();
vimGlobalState.lastChararacterSearch.increment = increment;
vimGlobalState.lastChararacterSearch.forward = args.forward;
vimGlobalState.lastChararacterSearch.selectedCharacter = args.selectedCharacter;
@@ -2572,10 +2643,10 @@
function SearchState() {}
SearchState.prototype = {
getQuery: function() {
return getVimGlobalState().query;
return vimGlobalState.query;
},
setQuery: function(query) {
getVimGlobalState().query = query;
vimGlobalState.query = query;
},
getOverlay: function() {
return this.searchOverlay;
@@ -2584,14 +2655,14 @@
this.searchOverlay = overlay;
},
isReversed: function() {
return getVimGlobalState().isReversed;
return vimGlobalState.isReversed;
},
setReversed: function(reversed) {
getVimGlobalState().isReversed = reversed;
vimGlobalState.isReversed = reversed;
}
};
function getSearchState(cm) {
var vim = getVimState(cm);
var vim = cm.state.vim;
return vim.searchState_ || (vim.searchState_ = new SearchState());
}
function dialog(cm, template, shortText, onClose, options) {
@@ -2840,9 +2911,9 @@
};
Vim.ExCommandDispatcher.prototype = {
processCommand: function(cm, input) {
var vim = getVimState(cm);
var vim = cm.state.vim;
if (vim.visualMode) {
exitVisualMode(cm, vim);
exitVisualMode(cm);
}
var inputStream = new CodeMirror.StringStream(input);
var params = {};
@@ -2921,7 +2992,7 @@
case '$':
return cm.lastLine();
case '\'':
var mark = getVimState(cm).marks[inputStream.next()];
var mark = cm.state.vim.marks[inputStream.next()];
if (mark && mark.find()) {
return mark.find().line;
}
@@ -3031,7 +3102,7 @@
exCommandDispatcher.map(mapArgs[0], mapArgs[1], cm);
},
move: function(cm, params) {
commandDispatcher.processCommand(cm, getVimState(cm), {
commandDispatcher.processCommand(cm, cm.state.vim, {
type: 'motion',
motion: 'moveToLineOrEdgeOfDocument',
motionArgs: { forward: false, explicitRepeat: true,
@@ -3186,7 +3257,7 @@
return;
}
var state = getVimState(cm);
var state = cm.state.vim;
var stream = new CodeMirror.StringStream(params.argString.trim());
while (!stream.eol()) {
stream.eatSpace();
@@ -3257,6 +3328,7 @@
function doReplace(cm, confirm, lineStart, lineEnd, searchCursor, query,
replaceWith) {
// Set up all the functions.
cm.state.vim.exMode = true;
var done = false;
var lastPos = searchCursor.from();
function replaceAll() {
@@ -3291,7 +3363,8 @@
cm.focus();
if (lastPos) {
cm.setCursor(lastPos);
var vim = getVimState(cm);
var vim = cm.state.vim;
vim.exMode = false;
vim.lastHPos = vim.lastHSPos = lastPos.ch;
}
}
@@ -3403,9 +3476,8 @@
CodeMirror.keyMap.vim = buildVimKeyMap();
function exitInsertMode(cm) {
var vim = getVimState(cm);
vim.insertMode = false;
var inReplay = getVimGlobalState().macroModeState.inReplay;
var vim = cm.state.vim;
var inReplay = vimGlobalState.macroModeState.inReplay;
if (!inReplay) {
cm.off('change', onChange);
cm.off('cursorActivity', onCursorActivity);
@@ -3419,8 +3491,10 @@
}
delete vim.insertModeRepeat;
cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1, true);
vim.insertMode = false;
cm.setOption('keyMap', 'vim');
cm.toggleOverwrite(false); // exit replace mode if we were in it.
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
}
CodeMirror.keyMap['vim-insert'] = {
@@ -3446,7 +3520,7 @@
function parseRegisterToKeyBuffer(macroModeState, registerName) {
var match, key;
var register = getVimGlobalState().registerController.getRegister(registerName);
var register = vimGlobalState.registerController.getRegister(registerName);
var text = register.toString();
var macroKeyBuffer = macroModeState.macroKeyBuffer;
emptyMacroKeyBuffer(macroModeState);
@@ -3462,7 +3536,7 @@
function parseKeyBufferToRegister(registerName, keyBuffer) {
var text = keyBuffer.join('');
getVimGlobalState().registerController.setRegisterText(registerName, text);
vimGlobalState.registerController.setRegisterText(registerName, text);
}
function emptyMacroKeyBuffer(macroModeState) {
@@ -3490,7 +3564,7 @@
* Should only be active in insert mode.
*/
function onChange(_cm, changeObj) {
var macroModeState = getVimGlobalState().macroModeState;
var macroModeState = vimGlobalState.macroModeState;
var lastChange = macroModeState.lastInsertModeChanges;
while (changeObj) {
lastChange.expectCursorActivityForChange = true;
@@ -3510,7 +3584,7 @@
* - Should only be active in insert mode.
*/
function onCursorActivity() {
var macroModeState = getVimGlobalState().macroModeState;
var macroModeState = vimGlobalState.macroModeState;
var lastChange = macroModeState.lastInsertModeChanges;
if (lastChange.expectCursorActivityForChange) {
lastChange.expectCursorActivityForChange = false;
@@ -3531,7 +3605,7 @@
* - For recording deletes in insert mode.
*/
function onKeyEventTargetKeyDown(e) {
var macroModeState = getVimGlobalState().macroModeState;
var macroModeState = vimGlobalState.macroModeState;
var lastChange = macroModeState.lastInsertModeChanges;
var keyName = CodeMirror.keyName(e);
function onKeyFound() {
@@ -3553,7 +3627,7 @@
* corresponding enterInsertMode call was made with a count.
*/
function repeatLastEdit(cm, vim, repeat, repeatForInsert) {
var macroModeState = getVimGlobalState().macroModeState;
var macroModeState = vimGlobalState.macroModeState;
macroModeState.inReplay = true;
var isAction = !!vim.lastEditActionCommand;
var cachedInputState = vim.inputState;
@@ -3621,6 +3695,7 @@
}
}
resetVimGlobalState();
return vimApi;
};
// Initialize Vim and make it available as an API.

View File

@@ -74,7 +74,6 @@
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
.cm-s-default .cm-error {color: #f00;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
@@ -91,10 +90,12 @@
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
@@ -117,6 +118,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-sizer {
position: relative;
@@ -155,6 +158,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
-moz-box-sizing: content-box;
box-sizing: content-box;
padding-bottom: 30px;
margin-bottom: -32px;
display: inline-block;
@@ -192,6 +197,16 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-code pre {
border-right: 30px solid transparent;
width: -webkit-fit-content;
width: -moz-fit-content;
width: fit-content;
}
.CodeMirror-wrap .CodeMirror-code pre {
border-right: none;
width: auto;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
@@ -204,8 +219,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
overflow: auto;
}
.CodeMirror-widget {
}
.CodeMirror-widget {}
.CodeMirror-wrap .CodeMirror-scroll {
overflow-x: hidden;
@@ -213,7 +227,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-measure {
position: absolute;
width: 100%; height: 0px;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,160 +0,0 @@
CodeMirror.defineMode("apl", function() {
var builtInOps = {
".": "innerProduct",
"\\": "scan",
"/": "reduce",
"⌿": "reduce1Axis",
"⍀": "scan1Axis",
"¨": "each",
"⍣": "power"
};
var builtInFuncs = {
"+": ["conjugate", "add"],
"": ["negate", "subtract"],
"×": ["signOf", "multiply"],
"÷": ["reciprocal", "divide"],
"⌈": ["ceiling", "greaterOf"],
"⌊": ["floor", "lesserOf"],
"": ["absolute", "residue"],
"": ["indexGenerate", "indexOf"],
"?": ["roll", "deal"],
"⋆": ["exponentiate", "toThePowerOf"],
"⍟": ["naturalLog", "logToTheBase"],
"○": ["piTimes", "circularFuncs"],
"!": ["factorial", "binomial"],
"⌹": ["matrixInverse", "matrixDivide"],
"<": [null, "lessThan"],
"≤": [null, "lessThanOrEqual"],
"=": [null, "equals"],
">": [null, "greaterThan"],
"≥": [null, "greaterThanOrEqual"],
"≠": [null, "notEqual"],
"≡": ["depth", "match"],
"≢": [null, "notMatch"],
"∈": ["enlist", "membership"],
"⍷": [null, "find"],
"": ["unique", "union"],
"∩": [null, "intersection"],
"": ["not", "without"],
"": [null, "or"],
"∧": [null, "and"],
"⍱": [null, "nor"],
"⍲": [null, "nand"],
"": ["shapeOf", "reshape"],
",": ["ravel", "catenate"],
"⍪": [null, "firstAxisCatenate"],
"⌽": ["reverse", "rotate"],
"⊖": ["axis1Reverse", "axis1Rotate"],
"⍉": ["transpose", null],
"↑": ["first", "take"],
"↓": [null, "drop"],
"⊂": ["enclose", "partitionWithAxis"],
"⊃": ["diclose", "pick"],
"⌷": [null, "index"],
"⍋": ["gradeUp", null],
"⍒": ["gradeDown", null],
"": ["encode", null],
"⊥": ["decode", null],
"⍕": ["format", "formatByExample"],
"⍎": ["execute", null],
"⊣": ["stop", "left"],
"⊢": ["pass", "right"]
};
var isOperator = /[\.\/⌿⍀¨⍣]/;
var isNiladic = /⍬/;
var isFunction = /[\+−×÷⌈⌊∣⍳\?⋆⍟○!⌹<≤=>≥≠≡≢∈⍷∪∩∼∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢]/;
var isArrow = /←/;
var isComment = /[⍝#].*$/;
var stringEater = function(type) {
var prev;
prev = false;
return function(c) {
prev = c;
if (c === type) {
return prev === "\\";
}
return true;
};
};
return {
startState: function() {
return {
prev: false,
func: false,
op: false,
string: false,
escape: false
};
},
token: function(stream, state) {
var ch, funcName, word;
if (stream.eatSpace()) {
return null;
}
ch = stream.next();
if (ch === '"' || ch === "'") {
stream.eatWhile(stringEater(ch));
stream.next();
state.prev = true;
return "string";
}
if (/[\[{\(]/.test(ch)) {
state.prev = false;
return null;
}
if (/[\]}\)]/.test(ch)) {
state.prev = true;
return null;
}
if (isNiladic.test(ch)) {
state.prev = false;
return "niladic";
}
if (/[¯\d]/.test(ch)) {
if (state.func) {
state.func = false;
state.prev = false;
} else {
state.prev = true;
}
stream.eatWhile(/[\w\.]/);
return "number";
}
if (isOperator.test(ch)) {
return "operator apl-" + builtInOps[ch];
}
if (isArrow.test(ch)) {
return "apl-arrow";
}
if (isFunction.test(ch)) {
funcName = "apl-";
if (builtInFuncs[ch] != null) {
if (state.prev) {
funcName += builtInFuncs[ch][1];
} else {
funcName += builtInFuncs[ch][0];
}
}
state.func = true;
state.prev = false;
return "function " + funcName;
}
if (isComment.test(ch)) {
stream.skipToEnd();
return "comment";
}
if (ch === "∘" && stream.peek() === ".") {
stream.next();
return "function jot-dot";
}
stream.eatWhile(/[\w\$_]/);
word = stream.current();
state.prev = true;
return "keyword";
}
};
});
CodeMirror.defineMIME("text/apl", "apl");

View File

@@ -1,61 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: APL mode</title>
<link rel="stylesheet" href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="./apl.js"></script>
<style>
.CodeMirror { border: 2px inset #dee; }
</style>
</head>
<body>
<h1>CodeMirror: APL mode</h1>
<form><textarea id="code" name="code">
⍝ Conway's game of life
⍝ This example was inspired by the impressive demo at
⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
⍝ Create a matrix:
⍝ 0 1 1
⍝ 1 1 0
⍝ 0 1 0
creature ← (3 3 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
creature ← (3 3 9) ∈ 1 3 6 7 8 ⍝ Glider
⍝ Place the creature on a larger board, near the centre
board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
⍝ A function to move from one generation to the next
life ← {/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
⍝ Compute n-th generation and format it as a
⍝ character matrix
gen ← {' #'[(life ⍣ ⍵) board]}
⍝ Show first three generations
(gen 1) (gen 2) (gen 3)
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/apl"
});
</script>
<p>Simple mode that tries to handle APL as well as it can.</p>
<p>It attempts to label functions/operators based upon
monadic/dyadic usage (but this is far from fully fleshed out).
This means there are meaningful classnames so hover states can
have popups etc.</p>
<p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
</body>
</html>

View File

@@ -1,183 +0,0 @@
/*
* =====================================================================================
*
* Filename: mode/asterisk/asterisk.js
*
* Description: CodeMirror mode for Asterisk dialplan
*
* Created: 05/17/2012 09:20:25 PM
* Revision: none
*
* Author: Stas Kobzar (stas@modulis.ca),
* Company: Modulis.ca Inc.
*
* =====================================================================================
*/
CodeMirror.defineMode("asterisk", function() {
var atoms = ["exten", "same", "include","ignorepat","switch"],
dpcmd = ["#include","#exec"],
apps = [
"addqueuemember","adsiprog","aelsub","agentlogin","agentmonitoroutgoing","agi",
"alarmreceiver","amd","answer","authenticate","background","backgrounddetect",
"bridge","busy","callcompletioncancel","callcompletionrequest","celgenuserevent",
"changemonitor","chanisavail","channelredirect","chanspy","clearhash","confbridge",
"congestion","continuewhile","controlplayback","dahdiacceptr2call","dahdibarge",
"dahdiras","dahdiscan","dahdisendcallreroutingfacility","dahdisendkeypadfacility",
"datetime","dbdel","dbdeltree","deadagi","dial","dictate","directory","disa",
"dumpchan","eagi","echo","endwhile","exec","execif","execiftime","exitwhile","extenspy",
"externalivr","festival","flash","followme","forkcdr","getcpeid","gosub","gosubif",
"goto","gotoif","gotoiftime","hangup","iax2provision","ices","importvar","incomplete",
"ivrdemo","jabberjoin","jabberleave","jabbersend","jabbersendgroup","jabberstatus",
"jack","log","macro","macroexclusive","macroexit","macroif","mailboxexists","meetme",
"meetmeadmin","meetmechanneladmin","meetmecount","milliwatt","minivmaccmess","minivmdelete",
"minivmgreet","minivmmwi","minivmnotify","minivmrecord","mixmonitor","monitor","morsecode",
"mp3player","mset","musiconhold","nbscat","nocdr","noop","odbc","odbc","odbcfinish",
"originate","ospauth","ospfinish","osplookup","ospnext","page","park","parkandannounce",
"parkedcall","pausemonitor","pausequeuemember","pickup","pickupchan","playback","playtones",
"privacymanager","proceeding","progress","queue","queuelog","raiseexception","read","readexten",
"readfile","receivefax","receivefax","receivefax","record","removequeuemember",
"resetcdr","retrydial","return","ringing","sayalpha","saycountedadj","saycountednoun",
"saycountpl","saydigits","saynumber","sayphonetic","sayunixtime","senddtmf","sendfax",
"sendfax","sendfax","sendimage","sendtext","sendurl","set","setamaflags",
"setcallerpres","setmusiconhold","sipaddheader","sipdtmfmode","sipremoveheader","skel",
"slastation","slatrunk","sms","softhangup","speechactivategrammar","speechbackground",
"speechcreate","speechdeactivategrammar","speechdestroy","speechloadgrammar","speechprocessingsound",
"speechstart","speechunloadgrammar","stackpop","startmusiconhold","stopmixmonitor","stopmonitor",
"stopmusiconhold","stopplaytones","system","testclient","testserver","transfer","tryexec",
"trysystem","unpausemonitor","unpausequeuemember","userevent","verbose","vmauthenticate",
"vmsayname","voicemail","voicemailmain","wait","waitexten","waitfornoise","waitforring",
"waitforsilence","waitmusiconhold","waituntil","while","zapateller"
];
function basicToken(stream,state){
var cur = '';
var ch = '';
ch = stream.next();
// comment
if(ch == ";") {
stream.skipToEnd();
return "comment";
}
// context
if(ch == '[') {
stream.skipTo(']');
stream.eat(']');
return "header";
}
// string
if(ch == '"') {
stream.skipTo('"');
return "string";
}
if(ch == "'") {
stream.skipTo("'");
return "string-2";
}
// dialplan commands
if(ch == '#') {
stream.eatWhile(/\w/);
cur = stream.current();
if(dpcmd.indexOf(cur) !== -1) {
stream.skipToEnd();
return "strong";
}
}
// application args
if(ch == '$'){
var ch1 = stream.peek();
if(ch1 == '{'){
stream.skipTo('}');
stream.eat('}');
return "variable-3";
}
}
// extension
stream.eatWhile(/\w/);
cur = stream.current();
if(atoms.indexOf(cur) !== -1) {
state.extenStart = true;
switch(cur) {
case 'same': state.extenSame = true; break;
case 'include':
case 'switch':
case 'ignorepat':
state.extenInclude = true;break;
default:break;
}
return "atom";
}
}
return {
startState: function() {
return {
extenStart: false,
extenSame: false,
extenInclude: false,
extenExten: false,
extenPriority: false,
extenApplication: false
};
},
token: function(stream, state) {
var cur = '';
var ch = '';
if(stream.eatSpace()) return null;
// extension started
if(state.extenStart){
stream.eatWhile(/[^\s]/);
cur = stream.current();
if(/^=>?$/.test(cur)){
state.extenExten = true;
state.extenStart = false;
return "strong";
} else {
state.extenStart = false;
stream.skipToEnd();
return "error";
}
} else if(state.extenExten) {
// set exten and priority
state.extenExten = false;
state.extenPriority = true;
stream.eatWhile(/[^,]/);
if(state.extenInclude) {
stream.skipToEnd();
state.extenPriority = false;
state.extenInclude = false;
}
if(state.extenSame) {
state.extenPriority = false;
state.extenSame = false;
state.extenApplication = true;
}
return "tag";
} else if(state.extenPriority) {
state.extenPriority = false;
state.extenApplication = true;
ch = stream.next(); // get comma
if(state.extenSame) return null;
stream.eatWhile(/[^,]/);
return "number";
} else if(state.extenApplication) {
stream.eatWhile(/,/);
cur = stream.current();
if(cur === ',') return null;
stream.eatWhile(/\w/);
cur = stream.current().toLowerCase();
state.extenApplication = false;
if(apps.indexOf(cur) !== -1){
return "def strong";
}
} else{
return basicToken(stream,state);
}
return null;
}
};
});
CodeMirror.defineMIME("text/x-asterisk", "asterisk");

View File

@@ -1,142 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Asterisk dialplan mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="asterisk.js"></script>
<style>
.CodeMirror {border: 1px solid #999;}
.cm-s-default span.cm-arrow { color: red; }
</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: Asterisk dialplan mode</h1>
<form><textarea id="code" name="code">
; extensions.conf - the Asterisk dial plan
;
[general]
;
; If static is set to no, or omitted, then the pbx_config will rewrite
; this file when extensions are modified. Remember that all comments
; made in the file will be lost when that happens.
static=yes
#include "/etc/asterisk/additional_general.conf
[iaxprovider]
switch => IAX2/user:[key]@myserver/mycontext
[dynamic]
#exec /usr/bin/dynamic-peers.pl
[trunkint]
;
; International long distance through trunk
;
exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
[local]
;
; Master context for local, toll-free, and iaxtel calls only
;
ignorepat => 9
include => default
[demo]
include => stdexten
;
; We start with what to do when a call first comes in.
;
exten => s,1,Wait(1) ; Wait a second, just for fun
same => n,Answer ; Answer the line
same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
same => n(instruct),BackGround(demo-instruct) ; Play some instructions
same => n,WaitExten ; Wait for an extension to be dialed.
exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
exten => 2,n,Goto(s,instruct)
exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
exten => 3,n,Goto(s,restart) ; Start with the congratulations
exten => 1000,1,Goto(default,s,1)
;
; We also create an example user, 1234, who is on the console and has
; voicemail, etc.
;
exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
; (but skip if channel is not up)
exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
exten => 1234,n,Goto(default,s,1) ; exited Voicemail
exten => 1235,1,Voicemail(1234,u) ; Right to voicemail
exten => 1236,1,Dial(Console/dsp) ; Ring forever
exten => 1236,n,Voicemail(1234,b) ; Unless busy
;
; # for when they're done with the demo
;
exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
exten => #,n,Hangup ; Hang them up.
;
; A timeout and "invalid extension rule"
;
exten => t,1,Goto(#,1) ; If they take too long, give up
exten => i,1,Playback(invalid) ; "That's not valid, try again"
;
; Create an extension, 500, for dialing the
; Asterisk demo.
;
exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
exten => 500,n,Goto(s,6) ; Return to the start over message.
;
; Create an extension, 600, for evaluating echo latency.
;
exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
exten => 600,n,Echo ; Do the echo test
exten => 600,n,Playback(demo-echodone) ; Let them know it's over
exten => 600,n,Goto(s,6) ; Start over
;
; You can use the Macro Page to intercom a individual user
exten => 76245,1,Macro(page,SIP/Grandstream1)
; or if your peernames are the same as extensions
exten => _7XXX,1,Macro(page,SIP/${EXTEN})
;
;
; System Wide Page at extension 7999
;
exten => 7999,1,Set(TIMEOUT(absolute)=60)
exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
; Give voicemail at extension 8500
;
exten => 8500,1,VoicemailMain
exten => 8500,n,Goto(s,6)
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: "text/x-asterisk",
matchBrackets: true,
lineNumber: true
});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>
</body>
</html>

View File

@@ -1,361 +0,0 @@
CodeMirror.defineMode("clike", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
dontAlignCalls = parserConfig.dontAlignCalls,
keywords = parserConfig.keywords || {},
builtin = parserConfig.builtin || {},
blockKeywords = parserConfig.blockKeywords || {},
atoms = parserConfig.atoms || {},
hooks = parserConfig.hooks || {},
multiLineStrings = parserConfig.multiLineStrings;
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
var curPunc;
function tokenBase(stream, state) {
var ch = stream.next();
if (hooks[ch]) {
var result = hooks[ch](stream, state);
if (result !== false) return result;
}
if (ch == '"' || ch == "'") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
curPunc = ch;
return null;
}
if (/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
return "number";
}
if (ch == "/") {
if (stream.eat("*")) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
}
if (stream.eat("/")) {
stream.skipToEnd();
return "comment";
}
}
if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return "operator";
}
stream.eatWhile(/[\w\$_]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "keyword";
}
if (builtin.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "builtin";
}
if (atoms.propertyIsEnumerable(cur)) return "atom";
return "variable";
}
function tokenString(quote) {
return function(stream, state) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {end = true; break;}
escaped = !escaped && next == "\\";
}
if (end || !(escaped || multiLineStrings))
state.tokenize = null;
return "string";
};
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = null;
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}
function Context(indented, column, type, align, prev) {
this.indented = indented;
this.column = column;
this.type = type;
this.align = align;
this.prev = prev;
}
function pushContext(state, col, type) {
var indent = state.indented;
if (state.context && state.context.type == "statement")
indent = state.context.indented;
return state.context = new Context(indent, col, type, null, state.context);
}
function popContext(state) {
var t = state.context.type;
if (t == ")" || t == "]" || t == "}")
state.indented = state.context.indented;
return state.context = state.context.prev;
}
// Interface
return {
startState: function(basecolumn) {
return {
tokenize: null,
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
indented: 0,
startOfLine: true
};
},
token: function(stream, state) {
var ctx = state.context;
if (stream.sol()) {
if (ctx.align == null) ctx.align = false;
state.indented = stream.indentation();
state.startOfLine = true;
}
if (stream.eatSpace()) return null;
curPunc = null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style == "comment" || style == "meta") return style;
if (ctx.align == null) ctx.align = true;
if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
else if (curPunc == "{") pushContext(state, stream.column(), "}");
else if (curPunc == "[") pushContext(state, stream.column(), "]");
else if (curPunc == "(") pushContext(state, stream.column(), ")");
else if (curPunc == "}") {
while (ctx.type == "statement") ctx = popContext(state);
if (ctx.type == "}") ctx = popContext(state);
while (ctx.type == "statement") ctx = popContext(state);
}
else if (curPunc == ctx.type) popContext(state);
else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
pushContext(state, stream.column(), "statement");
state.startOfLine = false;
return style;
},
indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
var closing = firstChar == ctx.type;
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
else if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.column + (closing ? 0 : 1);
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
else return ctx.indented + (closing ? 0 : indentUnit);
},
electricChars: "{}",
blockCommentStart: "/*",
blockCommentEnd: "*/",
lineComment: "//"
};
});
(function() {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
"double static else struct entry switch extern typedef float union for unsigned " +
"goto while enum void const signed volatile";
function cppHook(stream, state) {
if (!state.startOfLine) return false;
for (;;) {
if (stream.skipTo("\\")) {
stream.next();
if (stream.eol()) {
state.tokenize = cppHook;
break;
}
} else {
stream.skipToEnd();
state.tokenize = null;
break;
}
}
return "meta";
}
// C#-style strings where "" escapes a quote.
function tokenAtString(stream, state) {
var next;
while ((next = stream.next()) != null) {
if (next == '"' && !stream.eat('"')) {
state.tokenize = null;
break;
}
}
return "string";
}
function mimes(ms, mode) {
for (var i = 0; i < ms.length; ++i) CodeMirror.defineMIME(ms[i], mode);
}
mimes(["text/x-csrc", "text/x-c", "text/x-chdr"], {
name: "clike",
keywords: words(cKeywords),
blockKeywords: words("case do else for if switch while struct"),
atoms: words("null"),
hooks: {"#": cppHook}
});
mimes(["text/x-c++src", "text/x-c++hdr"], {
name: "clike",
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
"static_cast typeid catch operator template typename class friend private " +
"this using const_cast inline public throw virtual delete mutable protected " +
"wchar_t"),
blockKeywords: words("catch class do else finally for if struct switch try while"),
atoms: words("true false null"),
hooks: {"#": cppHook}
});
CodeMirror.defineMIME("text/x-java", {
name: "clike",
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
"do double else enum extends final finally float for goto if implements import " +
"instanceof int interface long native new package private protected public " +
"return short static strictfp super switch synchronized this throw throws transient " +
"try void volatile while"),
blockKeywords: words("catch class do else finally for if switch try while"),
atoms: words("true false null"),
hooks: {
"@": function(stream) {
stream.eatWhile(/[\w\$_]/);
return "meta";
}
}
});
CodeMirror.defineMIME("text/x-csharp", {
name: "clike",
keywords: words("abstract as base break case catch checked class const continue" +
" default delegate do else enum event explicit extern finally fixed for" +
" foreach goto if implicit in interface internal is lock namespace new" +
" operator out override params private protected public readonly ref return sealed" +
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
" global group into join let orderby partial remove select set value var yield"),
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
" Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
" UInt64 bool byte char decimal double short int long object" +
" sbyte float string ushort uint ulong"),
atoms: words("true false null"),
hooks: {
"@": function(stream, state) {
if (stream.eat('"')) {
state.tokenize = tokenAtString;
return tokenAtString(stream, state);
}
stream.eatWhile(/[\w\$_]/);
return "meta";
}
}
});
CodeMirror.defineMIME("text/x-scala", {
name: "clike",
keywords: words(
/* scala */
"abstract case catch class def do else extends false final finally for forSome if " +
"implicit import lazy match new null object override package private protected return " +
"sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
"<% >: # @ " +
/* package scala */
"assert assume require print println printf readLine readBoolean readByte readShort " +
"readChar readInt readLong readFloat readDouble " +
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
/* package java.lang */
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
),
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
atoms: words("true false null"),
hooks: {
"@": function(stream) {
stream.eatWhile(/[\w\$_]/);
return "meta";
}
}
});
mimes(["x-shader/x-vertex", "x-shader/x-fragment"], {
name: "clike",
keywords: words("float int bool void " +
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
"mat2 mat3 mat4 " +
"sampler1D sampler2D sampler3D samplerCube " +
"sampler1DShadow sampler2DShadow" +
"const attribute uniform varying " +
"break continue discard return " +
"for while do if else struct " +
"in out inout"),
blockKeywords: words("for while do if else struct"),
builtin: words("radians degrees sin cos tan asin acos atan " +
"pow exp log exp2 sqrt inversesqrt " +
"abs sign floor ceil fract mod min max clamp mix step smootstep " +
"length distance dot cross normalize ftransform faceforward " +
"reflect refract matrixCompMult " +
"lessThan lessThanEqual greaterThan greaterThanEqual " +
"equal notEqual any all not " +
"texture1D texture1DProj texture1DLod texture1DProjLod " +
"texture2D texture2DProj texture2DLod texture2DProjLod " +
"texture3D texture3DProj texture3DLod texture3DProjLod " +
"textureCube textureCubeLod " +
"shadow1D shadow2D shadow1DProj shadow2DProj " +
"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
"dFdx dFdy fwidth " +
"noise1 noise2 noise3 noise4"),
atoms: words("true false " +
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
"gl_FogCoord " +
"gl_Position gl_PointSize gl_ClipVertex " +
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
"gl_TexCoord gl_FogFragCoord " +
"gl_FragCoord gl_FrontFacing " +
"gl_FragColor gl_FragData gl_FragDepth " +
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
"gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
"gl_ProjectionMatrixInverseTranspose " +
"gl_ModelViewProjectionMatrixInverseTranspose " +
"gl_TextureMatrixInverseTranspose " +
"gl_NormalScale gl_DepthRange gl_ClipPlane " +
"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
"gl_FrontLightModelProduct gl_BackLightModelProduct " +
"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
"gl_FogParameters " +
"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
"gl_MaxDrawBuffers"),
hooks: {"#": cppHook}
});
}());

View File

@@ -1,103 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: C-like mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="clike.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border: 2px inset #dee;}</style>
</head>
<body>
<h1>CodeMirror: C-like mode</h1>
<form><textarea id="code" name="code">
/* C demo code */
#include <zmq.h>
#include <pthread.h>
#include <semaphore.h>
#include <time.h>
#include <stdio.h>
#include <fcntl.h>
#include <malloc.h>
typedef struct {
void* arg_socket;
zmq_msg_t* arg_msg;
char* arg_string;
unsigned long arg_len;
int arg_int, arg_command;
int signal_fd;
int pad;
void* context;
sem_t sem;
} acl_zmq_context;
#define p(X) (context->arg_##X)
void* zmq_thread(void* context_pointer) {
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
char ok = 'K', err = 'X';
int res;
while (1) {
while ((res = sem_wait(&amp;context->sem)) == EINTR);
if (res) {write(context->signal_fd, &amp;err, 1); goto cleanup;}
switch(p(command)) {
case 0: goto cleanup;
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
case 2: p(int) = zmq_close(p(socket)); break;
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &amp;p(len)); break;
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
}
p(command) = errno;
write(context->signal_fd, &amp;ok, 1);
}
cleanup:
close(context->signal_fd);
free(context_pointer);
return 0;
}
void* zmq_thread_init(void* zmq_context, int signal_fd) {
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
pthread_t thread;
context->context = zmq_context;
context->signal_fd = signal_fd;
sem_init(&amp;context->sem, 1, 0);
pthread_create(&amp;thread, 0, &amp;zmq_thread, context);
pthread_detach(thread);
return context;
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-csrc"
});
</script>
<p>Simple mode that tries to handle C-like languages as well as it
can. Takes two configuration parameters: <code>keywords</code>, an
object whose property names are the keywords in the language,
and <code>useCPP</code>, which determines whether C preprocessor
directives are recognized.</p>
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
(C code), <code>text/x-c++src</code> (C++
code), <code>text/x-java</code> (Java
code), <code>text/x-csharp</code> (C#).</p>
</body>
</html>

View File

@@ -1,767 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: C-like mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<link rel="stylesheet" href="../../theme/ambiance.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="clike.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>
body
{
margin: 0;
padding: 0;
max-width:inherit;
height: 100%;
}
html, form, .CodeMirror, .CodeMirror-scroll
{
height: 100%;
}
</style>
</head>
<body>
<form>
<textarea id="code" name="code">
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.collection
import generic._
import mutable.{ Builder, ListBuffer }
import annotation.{tailrec, migration, bridge}
import annotation.unchecked.{ uncheckedVariance => uV }
import parallel.ParIterable
/** A template trait for traversable collections of type `Traversable[A]`.
*
* $traversableInfo
* @define mutability
* @define traversableInfo
* This is a base trait of all kinds of $mutability Scala collections. It
* implements the behavior common to all collections, in terms of a method
* `foreach` with signature:
* {{{
* def foreach[U](f: Elem => U): Unit
* }}}
* Collection classes mixing in this trait provide a concrete
* `foreach` method which traverses all the
* elements contained in the collection, applying a given function to each.
* They also need to provide a method `newBuilder`
* which creates a builder for collections of the same kind.
*
* A traversable class might or might not have two properties: strictness
* and orderedness. Neither is represented as a type.
*
* The instances of a strict collection class have all their elements
* computed before they can be used as values. By contrast, instances of
* a non-strict collection class may defer computation of some of their
* elements until after the instance is available as a value.
* A typical example of a non-strict collection class is a
* <a href="../immutable/Stream.html" target="ContentFrame">
* `scala.collection.immutable.Stream`</a>.
* A more general class of examples are `TraversableViews`.
*
* If a collection is an instance of an ordered collection class, traversing
* its elements with `foreach` will always visit elements in the
* same order, even for different runs of the program. If the class is not
* ordered, `foreach` can visit elements in different orders for
* different runs (but it will keep the same order in the same run).'
*
* A typical example of a collection class which is not ordered is a
* `HashMap` of objects. The traversal order for hash maps will
* depend on the hash codes of its elements, and these hash codes might
* differ from one run to the next. By contrast, a `LinkedHashMap`
* is ordered because it's `foreach` method visits elements in the
* order they were inserted into the `HashMap`.
*
* @author Martin Odersky
* @version 2.8
* @since 2.8
* @tparam A the element type of the collection
* @tparam Repr the type of the actual collection containing the elements.
*
* @define Coll Traversable
* @define coll traversable collection
*/
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
with FilterMonadic[A, Repr]
with TraversableOnce[A]
with GenTraversableLike[A, Repr]
with Parallelizable[A, ParIterable[A]]
{
self =>
import Traversable.breaks._
/** The type implementing this traversable */
protected type Self = Repr
/** The collection of type $coll underlying this `TraversableLike` object.
* By default this is implemented as the `TraversableLike` object itself,
* but this can be overridden.
*/
def repr: Repr = this.asInstanceOf[Repr]
/** The underlying collection seen as an instance of `$Coll`.
* By default this is implemented as the current collection object itself,
* but this can be overridden.
*/
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
/** A conversion from collections of type `Repr` to `$Coll` objects.
* By default this is implemented as just a cast, but this can be overridden.
*/
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
/** Creates a new builder for this collection type.
*/
protected[this] def newBuilder: Builder[A, Repr]
protected[this] def parCombiner = ParIterable.newCombiner[A]
/** Applies a function `f` to all elements of this $coll.
*
* Note: this method underlies the implementation of most other bulk operations.
* It's important to implement this method in an efficient way.
*
*
* @param f the function that is applied for its side-effect to every element.
* The result of function `f` is discarded.
*
* @tparam U the type parameter describing the result of function `f`.
* This result will always be ignored. Typically `U` is `Unit`,
* but this is not necessary.
*
* @usecase def foreach(f: A => Unit): Unit
*/
def foreach[U](f: A => U): Unit
/** Tests whether this $coll is empty.
*
* @return `true` if the $coll contain no elements, `false` otherwise.
*/
def isEmpty: Boolean = {
var result = true
breakable {
for (x <- this) {
result = false
break
}
}
result
}
/** Tests whether this $coll is known to have a finite size.
* All strict collections are known to have finite size. For a non-strict collection
* such as `Stream`, the predicate returns `true` if all elements have been computed.
* It returns `false` if the stream is not yet evaluated to the end.
*
* Note: many collection methods will not work on collections of infinite sizes.
*
* @return `true` if this collection is known to have finite size, `false` otherwise.
*/
def hasDefiniteSize = true
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
b ++= thisCollection
b ++= that.seq
b.result
}
@bridge
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
++(that: GenTraversableOnce[B])(bf)
/** Concatenates this $coll with the elements of a traversable collection.
* It differs from ++ in that the right operand determines the type of the
* resulting collection rather than the left one.
*
* @param that the traversable to append.
* @tparam B the element type of the returned collection.
* @tparam That $thatinfo
* @param bf $bfinfo
* @return a new collection of type `That` which contains all elements
* of this $coll followed by all elements of `that`.
*
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
*
* @return a new $coll which contains all elements of this $coll
* followed by all elements of `that`.
*/
def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
b ++= that
b ++= thisCollection
b.result
}
/** This overload exists because: for the implementation of ++: we should reuse
* that of ++ because many collections override it with more efficient versions.
* Since TraversableOnce has no '++' method, we have to implement that directly,
* but Traversable and down can use the overload.
*/
def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
(that ++ seq)(breakOut)
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
b.sizeHint(this)
for (x <- this) b += f(x)
b.result
}
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
for (x <- this) b ++= f(x).seq
b.result
}
/** Selects all elements of this $coll which satisfy a predicate.
*
* @param p the predicate used to test elements.
* @return a new $coll consisting of all elements of this $coll that satisfy the given
* predicate `p`. The order of the elements is preserved.
*/
def filter(p: A => Boolean): Repr = {
val b = newBuilder
for (x <- this)
if (p(x)) b += x
b.result
}
/** Selects all elements of this $coll which do not satisfy a predicate.
*
* @param p the predicate used to test elements.
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
* predicate `p`. The order of the elements is preserved.
*/
def filterNot(p: A => Boolean): Repr = filter(!p(_))
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
b.result
}
/** Builds a new collection by applying an option-valued function to all
* elements of this $coll on which the function is defined.
*
* @param f the option-valued function which filters and maps the $coll.
* @tparam B the element type of the returned collection.
* @tparam That $thatinfo
* @param bf $bfinfo
* @return a new collection of type `That` resulting from applying the option-valued function
* `f` to each element and collecting all defined results.
* The order of the elements is preserved.
*
* @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
*
* @param pf the partial function which filters and maps the $coll.
* @return a new $coll resulting from applying the given option-valued function
* `f` to each element and collecting all defined results.
* The order of the elements is preserved.
def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
for (x <- this)
f(x) match {
case Some(y) => b += y
case _ =>
}
b.result
}
*/
/** Partitions this $coll in two ${coll}s according to a predicate.
*
* @param p the predicate on which to partition.
* @return a pair of ${coll}s: the first $coll consists of all elements that
* satisfy the predicate `p` and the second $coll consists of all elements
* that don't. The relative order of the elements in the resulting ${coll}s
* is the same as in the original $coll.
*/
def partition(p: A => Boolean): (Repr, Repr) = {
val l, r = newBuilder
for (x <- this) (if (p(x)) l else r) += x
(l.result, r.result)
}
def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
val m = mutable.Map.empty[K, Builder[A, Repr]]
for (elem <- this) {
val key = f(elem)
val bldr = m.getOrElseUpdate(key, newBuilder)
bldr += elem
}
val b = immutable.Map.newBuilder[K, Repr]
for ((k, v) <- m)
b += ((k, v.result))
b.result
}
/** Tests whether a predicate holds for all elements of this $coll.
*
* $mayNotTerminateInf
*
* @param p the predicate used to test elements.
* @return `true` if the given predicate `p` holds for all elements
* of this $coll, otherwise `false`.
*/
def forall(p: A => Boolean): Boolean = {
var result = true
breakable {
for (x <- this)
if (!p(x)) { result = false; break }
}
result
}
/** Tests whether a predicate holds for some of the elements of this $coll.
*
* $mayNotTerminateInf
*
* @param p the predicate used to test elements.
* @return `true` if the given predicate `p` holds for some of the
* elements of this $coll, otherwise `false`.
*/
def exists(p: A => Boolean): Boolean = {
var result = false
breakable {
for (x <- this)
if (p(x)) { result = true; break }
}
result
}
/** Finds the first element of the $coll satisfying a predicate, if any.
*
* $mayNotTerminateInf
* $orderDependent
*
* @param p the predicate used to test elements.
* @return an option value containing the first element in the $coll
* that satisfies `p`, or `None` if none exists.
*/
def find(p: A => Boolean): Option[A] = {
var result: Option[A] = None
breakable {
for (x <- this)
if (p(x)) { result = Some(x); break }
}
result
}
def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
b.sizeHint(this, 1)
var acc = z
b += acc
for (x <- this) { acc = op(acc, x); b += acc }
b.result
}
@migration(2, 9,
"This scanRight definition has changed in 2.9.\n" +
"The previous behavior can be reproduced with scanRight.reverse."
)
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
var scanned = List(z)
var acc = z
for (x <- reversed) {
acc = op(x, acc)
scanned ::= acc
}
val b = bf(repr)
for (elem <- scanned) b += elem
b.result
}
/** Selects the first element of this $coll.
* $orderDependent
* @return the first element of this $coll.
* @throws `NoSuchElementException` if the $coll is empty.
*/
def head: A = {
var result: () => A = () => throw new NoSuchElementException
breakable {
for (x <- this) {
result = () => x
break
}
}
result()
}
/** Optionally selects the first element.
* $orderDependent
* @return the first element of this $coll if it is nonempty, `None` if it is empty.
*/
def headOption: Option[A] = if (isEmpty) None else Some(head)
/** Selects all elements except the first.
* $orderDependent
* @return a $coll consisting of all elements of this $coll
* except the first one.
* @throws `UnsupportedOperationException` if the $coll is empty.
*/
override def tail: Repr = {
if (isEmpty) throw new UnsupportedOperationException("empty.tail")
drop(1)
}
/** Selects the last element.
* $orderDependent
* @return The last element of this $coll.
* @throws NoSuchElementException If the $coll is empty.
*/
def last: A = {
var lst = head
for (x <- this)
lst = x
lst
}
/** Optionally selects the last element.
* $orderDependent
* @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
*/
def lastOption: Option[A] = if (isEmpty) None else Some(last)
/** Selects all elements except the last.
* $orderDependent
* @return a $coll consisting of all elements of this $coll
* except the last one.
* @throws `UnsupportedOperationException` if the $coll is empty.
*/
def init: Repr = {
if (isEmpty) throw new UnsupportedOperationException("empty.init")
var lst = head
var follow = false
val b = newBuilder
b.sizeHint(this, -1)
for (x <- this.seq) {
if (follow) b += lst
else follow = true
lst = x
}
b.result
}
def take(n: Int): Repr = slice(0, n)
def drop(n: Int): Repr =
if (n <= 0) {
val b = newBuilder
b.sizeHint(this)
b ++= thisCollection result
}
else sliceWithKnownDelta(n, Int.MaxValue, -n)
def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
// Precondition: from >= 0, until > 0, builder already configured for building.
private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
var i = 0
breakable {
for (x <- this.seq) {
if (i >= from) b += x
i += 1
if (i >= until) break
}
}
b.result
}
// Precondition: from >= 0
private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
val b = newBuilder
if (until <= from) b.result
else {
b.sizeHint(this, delta)
sliceInternal(from, until, b)
}
}
// Precondition: from >= 0
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
val b = newBuilder
if (until <= from) b.result
else {
b.sizeHintBounded(until - from, this)
sliceInternal(from, until, b)
}
}
def takeWhile(p: A => Boolean): Repr = {
val b = newBuilder
breakable {
for (x <- this) {
if (!p(x)) break
b += x
}
}
b.result
}
def dropWhile(p: A => Boolean): Repr = {
val b = newBuilder
var go = false
for (x <- this) {
if (!p(x)) go = true
if (go) b += x
}
b.result
}
def span(p: A => Boolean): (Repr, Repr) = {
val l, r = newBuilder
var toLeft = true
for (x <- this) {
toLeft = toLeft && p(x)
(if (toLeft) l else r) += x
}
(l.result, r.result)
}
def splitAt(n: Int): (Repr, Repr) = {
val l, r = newBuilder
l.sizeHintBounded(n, this)
if (n >= 0) r.sizeHint(this, -n)
var i = 0
for (x <- this) {
(if (i < n) l else r) += x
i += 1
}
(l.result, r.result)
}
/** Iterates over the tails of this $coll. The first value will be this
* $coll and the final one will be an empty $coll, with the intervening
* values the results of successive applications of `tail`.
*
* @return an iterator over all the tails of this $coll
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
*/
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
/** Iterates over the inits of this $coll. The first value will be this
* $coll and the final one will be an empty $coll, with the intervening
* values the results of successive applications of `init`.
*
* @return an iterator over all the inits of this $coll
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
*/
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
/** Copies elements of this $coll to an array.
* Fills the given array `xs` with at most `len` elements of
* this $coll, starting at position `start`.
* Copying will stop once either the end of the current $coll is reached,
* or the end of the array is reached, or `len` elements have been copied.
*
* $willNotTerminateInf
*
* @param xs the array to fill.
* @param start the starting index.
* @param len the maximal number of elements to copy.
* @tparam B the type of the elements of the array.
*
*
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
*/
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
var i = start
val end = (start + len) min xs.length
breakable {
for (x <- this) {
if (i >= end) break
xs(i) = x
i += 1
}
}
}
def toTraversable: Traversable[A] = thisCollection
def toIterator: Iterator[A] = toStream.iterator
def toStream: Stream[A] = toBuffer.toStream
/** Converts this $coll to a string.
*
* @return a string representation of this collection. By default this
* string consists of the `stringPrefix` of this $coll,
* followed by all elements separated by commas and enclosed in parentheses.
*/
override def toString = mkString(stringPrefix + "(", ", ", ")")
/** Defines the prefix of this object's `toString` representation.
*
* @return a string representation which starts the result of `toString`
* applied to this $coll. By default the string prefix is the
* simple name of the collection class $coll.
*/
def stringPrefix : String = {
var string = repr.asInstanceOf[AnyRef].getClass.getName
val idx1 = string.lastIndexOf('.' : Int)
if (idx1 != -1) string = string.substring(idx1 + 1)
val idx2 = string.indexOf('$')
if (idx2 != -1) string = string.substring(0, idx2)
string
}
/** Creates a non-strict view of this $coll.
*
* @return a non-strict view of this $coll.
*/
def view = new TraversableView[A, Repr] {
protected lazy val underlying = self.repr
override def foreach[U](f: A => U) = self foreach f
}
/** Creates a non-strict view of a slice of this $coll.
*
* Note: the difference between `view` and `slice` is that `view` produces
* a view of the current $coll, whereas `slice` produces a new $coll.
*
* Note: `view(from, to)` is equivalent to `view.slice(from, to)`
* $orderDependent
*
* @param from the index of the first element of the view
* @param until the index of the element following the view
* @return a non-strict view of a slice of this $coll, starting at index `from`
* and extending up to (but not including) index `until`.
*/
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
/** Creates a non-strict filter of this $coll.
*
* Note: the difference between `c filter p` and `c withFilter p` is that
* the former creates a new collection, whereas the latter only
* restricts the domain of subsequent `map`, `flatMap`, `foreach`,
* and `withFilter` operations.
* $orderDependent
*
* @param p the predicate used to test elements.
* @return an object of class `WithFilter`, which supports
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
* All these operations apply to those elements of this $coll which
* satisfy the predicate `p`.
*/
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
/** A class supporting filtered operations. Instances of this class are
* returned by method `withFilter`.
*/
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
/** Builds a new collection by applying a function to all elements of the
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
*
* @param f the function to apply to each element.
* @tparam B the element type of the returned collection.
* @tparam That $thatinfo
* @param bf $bfinfo
* @return a new collection of type `That` resulting from applying
* the given function `f` to each element of the outer $coll
* that satisfies predicate `p` and collecting the results.
*
* @usecase def map[B](f: A => B): $Coll[B]
*
* @return a new $coll resulting from applying the given function
* `f` to each element of the outer $coll that satisfies
* predicate `p` and collecting the results.
*/
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
for (x <- self)
if (p(x)) b += f(x)
b.result
}
/** Builds a new collection by applying a function to all elements of the
* outer $coll containing this `WithFilter` instance that satisfy
* predicate `p` and concatenating the results.
*
* @param f the function to apply to each element.
* @tparam B the element type of the returned collection.
* @tparam That $thatinfo
* @param bf $bfinfo
* @return a new collection of type `That` resulting from applying
* the given collection-valued function `f` to each element
* of the outer $coll that satisfies predicate `p` and
* concatenating the results.
*
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
*
* @return a new $coll resulting from applying the given collection-valued function
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
*/
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
for (x <- self)
if (p(x)) b ++= f(x).seq
b.result
}
/** Applies a function `f` to all elements of the outer $coll containing
* this `WithFilter` instance that satisfy predicate `p`.
*
* @param f the function that is applied for its side-effect to every element.
* The result of function `f` is discarded.
*
* @tparam U the type parameter describing the result of function `f`.
* This result will always be ignored. Typically `U` is `Unit`,
* but this is not necessary.
*
* @usecase def foreach(f: A => Unit): Unit
*/
def foreach[U](f: A => U): Unit =
for (x <- self)
if (p(x)) f(x)
/** Further refines the filter for this $coll.
*
* @param q the predicate used to test elements.
* @return an object of class `WithFilter`, which supports
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
* All these operations apply to those elements of this $coll which
* satisfy the predicate `q` in addition to the predicate `p`.
*/
def withFilter(q: A => Boolean): WithFilter =
new WithFilter(x => p(x) && q(x))
}
// A helper for tails and inits.
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
it ++ Iterator(Nil) map (newBuilder ++= _ result)
}
}
</textarea>
</form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
theme: "ambiance",
mode: "text/x-scala"
});
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@@ -1,76 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Clojure mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="clojure.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: Clojure mode</h1>
<form><textarea id="code" name="code">
; Conway's Game of Life, based on the work of:
;; Laurent Petit https://gist.github.com/1200343
;; Christophe Grand http://clj-me.cgrand.net/2011/08/19/conways-game-of-life
(ns ^{:doc "Conway's Game of Life."}
game-of-life)
;; Core game of life's algorithm functions
(defn neighbours
"Given a cell's coordinates, returns the coordinates of its neighbours."
[[x y]]
(for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])]
[(+ dx x) (+ dy y)]))
(defn step
"Given a set of living cells, computes the new set of living cells."
[cells]
(set (for [[cell n] (frequencies (mapcat neighbours cells))
:when (or (= n 3) (and (= n 2) (cells cell)))]
cell)))
;; Utility methods for displaying game on a text terminal
(defn print-board
"Prints a board on *out*, representing a step in the game."
[board w h]
(doseq [x (range (inc w)) y (range (inc h))]
(if (= y 0) (print "\n"))
(print (if (board [x y]) "[X]" " . "))))
(defn display-grids
"Prints a squence of boards on *out*, representing several steps."
[grids w h]
(doseq [board grids]
(print-board board w h)
(print "\n")))
;; Launches an example board
(def
^{:doc "board represents the initial set of living cells"}
board #{[2 1] [2 2] [2 3]})
(display-grids (take 3 (iterate step board)) 5 5)
;; Let's play with characters
(println \1 \a \# \\
\" \( \newline
\} \" \space
\tab \return \backspace
\u1000 \uAaAa \u9F9F)
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-clojure</code>.</p>
</body>
</html>

View File

@@ -1,240 +0,0 @@
/**
* Author: Gautam Mehta
* Branched from CodeMirror's Scheme mode
*/
CodeMirror.defineMode("cobol", function () {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
ATOM = "atom", NUMBER = "number", KEYWORD = "keyword", MODTAG = "header",
COBOLLINENUM = "def", PERIOD = "link";
function makeKeywords(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var atoms = makeKeywords("TRUE FALSE ZEROES ZEROS ZERO SPACES SPACE LOW-VALUE LOW-VALUES ");
var keywords = makeKeywords(
"ACCEPT ACCESS ACQUIRE ADD ADDRESS " +
"ADVANCING AFTER ALIAS ALL ALPHABET " +
"ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER ALPHANUMERIC ALPHANUMERIC-EDITED " +
"ALSO ALTER ALTERNATE AND ANY " +
"ARE AREA AREAS ARITHMETIC ASCENDING " +
"ASSIGN AT ATTRIBUTE AUTHOR AUTO " +
"AUTO-SKIP AUTOMATIC B-AND B-EXOR B-LESS " +
"B-NOT B-OR BACKGROUND-COLOR BACKGROUND-COLOUR BEEP " +
"BEFORE BELL BINARY BIT BITS " +
"BLANK BLINK BLOCK BOOLEAN BOTTOM " +
"BY CALL CANCEL CD CF " +
"CH CHARACTER CHARACTERS CLASS CLOCK-UNITS " +
"CLOSE COBOL CODE CODE-SET COL " +
"COLLATING COLUMN COMMA COMMIT COMMITMENT " +
"COMMON COMMUNICATION COMP COMP-0 COMP-1 " +
"COMP-2 COMP-3 COMP-4 COMP-5 COMP-6 " +
"COMP-7 COMP-8 COMP-9 COMPUTATIONAL COMPUTATIONAL-0 " +
"COMPUTATIONAL-1 COMPUTATIONAL-2 COMPUTATIONAL-3 COMPUTATIONAL-4 COMPUTATIONAL-5 " +
"COMPUTATIONAL-6 COMPUTATIONAL-7 COMPUTATIONAL-8 COMPUTATIONAL-9 COMPUTE " +
"CONFIGURATION CONNECT CONSOLE CONTAINED CONTAINS " +
"CONTENT CONTINUE CONTROL CONTROL-AREA CONTROLS " +
"CONVERTING COPY CORR CORRESPONDING COUNT " +
"CRT CRT-UNDER CURRENCY CURRENT CURSOR " +
"DATA DATE DATE-COMPILED DATE-WRITTEN DAY " +
"DAY-OF-WEEK DB DB-ACCESS-CONTROL-KEY DB-DATA-NAME DB-EXCEPTION " +
"DB-FORMAT-NAME DB-RECORD-NAME DB-SET-NAME DB-STATUS DBCS " +
"DBCS-EDITED DE DEBUG-CONTENTS DEBUG-ITEM DEBUG-LINE " +
"DEBUG-NAME DEBUG-SUB-1 DEBUG-SUB-2 DEBUG-SUB-3 DEBUGGING " +
"DECIMAL-POINT DECLARATIVES DEFAULT DELETE DELIMITED " +
"DELIMITER DEPENDING DESCENDING DESCRIBED DESTINATION " +
"DETAIL DISABLE DISCONNECT DISPLAY DISPLAY-1 " +
"DISPLAY-2 DISPLAY-3 DISPLAY-4 DISPLAY-5 DISPLAY-6 " +
"DISPLAY-7 DISPLAY-8 DISPLAY-9 DIVIDE DIVISION " +
"DOWN DROP DUPLICATE DUPLICATES DYNAMIC " +
"EBCDIC EGI EJECT ELSE EMI " +
"EMPTY EMPTY-CHECK ENABLE END END. END-ACCEPT END-ACCEPT. " +
"END-ADD END-CALL END-COMPUTE END-DELETE END-DISPLAY " +
"END-DIVIDE END-EVALUATE END-IF END-INVOKE END-MULTIPLY " +
"END-OF-PAGE END-PERFORM END-READ END-RECEIVE END-RETURN " +
"END-REWRITE END-SEARCH END-START END-STRING END-SUBTRACT " +
"END-UNSTRING END-WRITE END-XML ENTER ENTRY " +
"ENVIRONMENT EOP EQUAL EQUALS ERASE " +
"ERROR ESI EVALUATE EVERY EXCEEDS " +
"EXCEPTION EXCLUSIVE EXIT EXTEND EXTERNAL " +
"EXTERNALLY-DESCRIBED-KEY FD FETCH FILE FILE-CONTROL " +
"FILE-STREAM FILES FILLER FINAL FIND " +
"FINISH FIRST FOOTING FOR FOREGROUND-COLOR " +
"FOREGROUND-COLOUR FORMAT FREE FROM FULL " +
"FUNCTION GENERATE GET GIVING GLOBAL " +
"GO GOBACK GREATER GROUP HEADING " +
"HIGH-VALUE HIGH-VALUES HIGHLIGHT I-O I-O-CONTROL " +
"ID IDENTIFICATION IF IN INDEX " +
"INDEX-1 INDEX-2 INDEX-3 INDEX-4 INDEX-5 " +
"INDEX-6 INDEX-7 INDEX-8 INDEX-9 INDEXED " +
"INDIC INDICATE INDICATOR INDICATORS INITIAL " +
"INITIALIZE INITIATE INPUT INPUT-OUTPUT INSPECT " +
"INSTALLATION INTO INVALID INVOKE IS " +
"JUST JUSTIFIED KANJI KEEP KEY " +
"LABEL LAST LD LEADING LEFT " +
"LEFT-JUSTIFY LENGTH LENGTH-CHECK LESS LIBRARY " +
"LIKE LIMIT LIMITS LINAGE LINAGE-COUNTER " +
"LINE LINE-COUNTER LINES LINKAGE LOCAL-STORAGE " +
"LOCALE LOCALLY LOCK " +
"MEMBER MEMORY MERGE MESSAGE METACLASS " +
"MODE MODIFIED MODIFY MODULES MOVE " +
"MULTIPLE MULTIPLY NATIONAL NATIVE NEGATIVE " +
"NEXT NO NO-ECHO NONE NOT " +
"NULL NULL-KEY-MAP NULL-MAP NULLS NUMBER " +
"NUMERIC NUMERIC-EDITED OBJECT OBJECT-COMPUTER OCCURS " +
"OF OFF OMITTED ON ONLY " +
"OPEN OPTIONAL OR ORDER ORGANIZATION " +
"OTHER OUTPUT OVERFLOW OWNER PACKED-DECIMAL " +
"PADDING PAGE PAGE-COUNTER PARSE PERFORM " +
"PF PH PIC PICTURE PLUS " +
"POINTER POSITION POSITIVE PREFIX PRESENT " +
"PRINTING PRIOR PROCEDURE PROCEDURE-POINTER PROCEDURES " +
"PROCEED PROCESS PROCESSING PROGRAM PROGRAM-ID " +
"PROMPT PROTECTED PURGE QUEUE QUOTE " +
"QUOTES RANDOM RD READ READY " +
"REALM RECEIVE RECONNECT RECORD RECORD-NAME " +
"RECORDS RECURSIVE REDEFINES REEL REFERENCE " +
"REFERENCE-MONITOR REFERENCES RELATION RELATIVE RELEASE " +
"REMAINDER REMOVAL RENAMES REPEATED REPLACE " +
"REPLACING REPORT REPORTING REPORTS REPOSITORY " +
"REQUIRED RERUN RESERVE RESET RETAINING " +
"RETRIEVAL RETURN RETURN-CODE RETURNING REVERSE-VIDEO " +
"REVERSED REWIND REWRITE RF RH " +
"RIGHT RIGHT-JUSTIFY ROLLBACK ROLLING ROUNDED " +
"RUN SAME SCREEN SD SEARCH " +
"SECTION SECURE SECURITY SEGMENT SEGMENT-LIMIT " +
"SELECT SEND SENTENCE SEPARATE SEQUENCE " +
"SEQUENTIAL SET SHARED SIGN SIZE " +
"SKIP1 SKIP2 SKIP3 SORT SORT-MERGE " +
"SORT-RETURN SOURCE SOURCE-COMPUTER SPACE-FILL " +
"SPECIAL-NAMES STANDARD STANDARD-1 STANDARD-2 " +
"START STARTING STATUS STOP STORE " +
"STRING SUB-QUEUE-1 SUB-QUEUE-2 SUB-QUEUE-3 SUB-SCHEMA " +
"SUBFILE SUBSTITUTE SUBTRACT SUM SUPPRESS " +
"SYMBOLIC SYNC SYNCHRONIZED SYSIN SYSOUT " +
"TABLE TALLYING TAPE TENANT TERMINAL " +
"TERMINATE TEST TEXT THAN THEN " +
"THROUGH THRU TIME TIMES TITLE " +
"TO TOP TRAILING TRAILING-SIGN TRANSACTION " +
"TYPE TYPEDEF UNDERLINE UNEQUAL UNIT " +
"UNSTRING UNTIL UP UPDATE UPON " +
"USAGE USAGE-MODE USE USING VALID " +
"VALIDATE VALUE VALUES VARYING VLR " +
"WAIT WHEN WHEN-COMPILED WITH WITHIN " +
"WORDS WORKING-STORAGE WRITE XML XML-CODE " +
"XML-EVENT XML-NTEXT XML-TEXT ZERO ZERO-FILL " );
var builtins = makeKeywords("- * ** / + < <= = > >= ");
var tests = {
digit: /\d/,
digit_or_colon: /[\d:]/,
hex: /[0-9a-f]/i,
sign: /[+-]/,
exponent: /e/i,
keyword_char: /[^\s\(\[\;\)\]]/,
symbol: /[\w*+\-]/
};
function isNumber(ch, stream){
// hex
if ( ch === '0' && stream.eat(/x/i) ) {
stream.eatWhile(tests.hex);
return true;
}
// leading sign
if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) {
stream.eat(tests.sign);
ch = stream.next();
}
if ( tests.digit.test(ch) ) {
stream.eat(ch);
stream.eatWhile(tests.digit);
if ( '.' == stream.peek()) {
stream.eat('.');
stream.eatWhile(tests.digit);
}
if ( stream.eat(tests.exponent) ) {
stream.eat(tests.sign);
stream.eatWhile(tests.digit);
}
return true;
}
return false;
}
return {
startState: function () {
return {
indentStack: null,
indentation: 0,
mode: false
};
},
token: function (stream, state) {
if (state.indentStack == null && stream.sol()) {
// update indentation, but only if indentStack is empty
state.indentation = 6 ; //stream.indentation();
}
// skip spaces
if (stream.eatSpace()) {
return null;
}
var returnType = null;
switch(state.mode){
case "string": // multi-line string parsing mode
var next = false;
while ((next = stream.next()) != null) {
if (next == "\"" || next == "\'") {
state.mode = false;
break;
}
}
returnType = STRING; // continue on in string mode
break;
default: // default parsing mode
var ch = stream.next();
var col = stream.column();
if (col >= 0 && col <= 5) {
returnType = COBOLLINENUM;
} else if (col >= 72 && col <= 79) {
stream.skipToEnd();
returnType = MODTAG;
} else if (ch == "*" && col == 6) { // comment
stream.skipToEnd(); // rest of the line is a comment
returnType = COMMENT;
} else if (ch == "\"" || ch == "\'") {
state.mode = "string";
returnType = STRING;
} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
returnType = ATOM;
} else if (ch == ".") {
returnType = PERIOD;
} else if (isNumber(ch,stream)){
returnType = NUMBER;
} else {
if (stream.current().match(tests.symbol)) {
while (col < 71) {
if (stream.eat(tests.symbol) === undefined) {
break;
} else {
col++;
}
}
}
if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
returnType = KEYWORD;
} else if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase())) {
returnType = BUILTIN;
} else if (atoms && atoms.propertyIsEnumerable(stream.current().toUpperCase())) {
returnType = ATOM;
} else returnType = null;
}
}
return returnType;
},
indent: function (state) {
if (state.indentStack == null) return state.indentation;
return state.indentStack.indent;
}
};
});
CodeMirror.defineMIME("text/x-cobol", "cobol");

View File

@@ -1,195 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: COBOL mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="cobol.js"></script>
<link rel="stylesheet" href="../../theme/neat.css">
<link rel="stylesheet" href="../../theme/elegant.css">
<link rel="stylesheet" href="../../theme/erlang-dark.css">
<link rel="stylesheet" href="../../theme/night.css">
<link rel="stylesheet" href="../../theme/monokai.css">
<link rel="stylesheet" href="../../theme/cobalt.css">
<link rel="stylesheet" href="../../theme/eclipse.css">
<link rel="stylesheet" href="../../theme/rubyblue.css">
<link rel="stylesheet" href="../../theme/lesser-dark.css">
<link rel="stylesheet" href="../../theme/xq-dark.css">
<link rel="stylesheet" href="../../theme/xq-light.css">
<link rel="stylesheet" href="../../theme/ambiance.css">
<link rel="stylesheet" href="../../theme/blackboard.css">
<link rel="stylesheet" href="../../theme/vibrant-ink.css">
<link rel="stylesheet" href="../../theme/solarized.css">
<link rel="stylesheet" href="../../theme/twilight.css">
<link rel="stylesheet" href="../../theme/midnight.css">
<link rel="stylesheet" href="../../addon/dialog/dialog.css">
<script src="../../addon/selection/active-line.js"></script>
<script src="../../addon/search/search.js"></script>
<script src="../../addon/dialog/dialog.js"></script>
<script src="../../addon/search/searchcursor.js"></script>
<style>
.CodeMirror {
border: 1px solid #eee;
font-size : 20px;
height : auto !important;
}
.CodeMirror-activeline-background {background: #555555 !important;}
</style>
</head>
<body>
<p> Select Theme <select onchange="selectTheme()" id="selectTheme">
<option>default</option>
<option>ambiance</option>
<option>blackboard</option>
<option>cobalt</option>
<option>eclipse</option>
<option>elegant</option>
<option>erlang-dark</option>
<option>lesser-dark</option>
<option>midnight</option>
<option>monokai</option>
<option>neat</option>
<option>night</option>
<option>rubyblue</option>
<option>solarized dark</option>
<option>solarized light</option>
<option selected>twilight</option>
<option>vibrant-ink</option>
<option>xq-dark</option>
<option>xq-light</option>
</select> Select Font Size <select onchange="selectFontsize()" id="selectFontSize">
<option value="13px">13px</option>
<option value="14px">14px</option>
<option value="16px">16px</option>
<option value="18px">18px</option>
<option value="20px" selected="selected">20px</option>
<option value="24px">24px</option>
<option value="26px">26px</option>
<option value="28px">28px</option>
<option value="30px">30px</option>
<option value="32px">32px</option>
<option value="34px">34px</option>
<option value="36px">36px</option>
</select>
<label for="checkBoxReadOnly">Read-only</label>
<input type="checkbox" id="checkBoxReadOnly" onchange="selectReadOnly()">
<label for="id_tabToIndentSpace">Insert Spaces on Tab</label>
<input type="checkbox" id="id_tabToIndentSpace" onchange="tabToIndentSpace()">
</p>
<textarea id="code" name="code">
---------1---------2---------3---------4---------5---------6---------7---------8
12345678911234567892123456789312345678941234567895123456789612345678971234567898
000010 IDENTIFICATION DIVISION. MODTGHERE
000020 PROGRAM-ID. SAMPLE.
000030 AUTHOR. TEST SAM.
000040 DATE-WRITTEN. 5 February 2013
000041
000042* A sample program just to show the form.
000043* The program copies its input to the output,
000044* and counts the number of records.
000045* At the end this number is printed.
000046
000050 ENVIRONMENT DIVISION.
000060 INPUT-OUTPUT SECTION.
000070 FILE-CONTROL.
000080 SELECT STUDENT-FILE ASSIGN TO SYSIN
000090 ORGANIZATION IS LINE SEQUENTIAL.
000100 SELECT PRINT-FILE ASSIGN TO SYSOUT
000110 ORGANIZATION IS LINE SEQUENTIAL.
000120
000130 DATA DIVISION.
000140 FILE SECTION.
000150 FD STUDENT-FILE
000160 RECORD CONTAINS 43 CHARACTERS
000170 DATA RECORD IS STUDENT-IN.
000180 01 STUDENT-IN PIC X(43).
000190
000200 FD PRINT-FILE
000210 RECORD CONTAINS 80 CHARACTERS
000220 DATA RECORD IS PRINT-LINE.
000230 01 PRINT-LINE PIC X(80).
000240
000250 WORKING-STORAGE SECTION.
000260 01 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.
000261 01 RECORDS-WRITTEN PIC 99.
000270
000280 01 DETAIL-LINE.
000290 05 FILLER PIC X(7) VALUE SPACES.
000300 05 RECORD-IMAGE PIC X(43).
000310 05 FILLER PIC X(30) VALUE SPACES.
000311
000312 01 SUMMARY-LINE.
000313 05 FILLER PIC X(7) VALUE SPACES.
000314 05 TOTAL-READ PIC 99.
000315 05 FILLER PIC X VALUE SPACE.
000316 05 FILLER PIC X(17)
000317 VALUE 'Records were read'.
000318 05 FILLER PIC X(53) VALUE SPACES.
000319
000320 PROCEDURE DIVISION.
000321
000330 PREPARE-SENIOR-REPORT.
000340 OPEN INPUT STUDENT-FILE
000350 OUTPUT PRINT-FILE.
000351 MOVE ZERO TO RECORDS-WRITTEN.
000360 READ STUDENT-FILE
000370 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
000380 END-READ.
000390 PERFORM PROCESS-RECORDS
000410 UNTIL DATA-REMAINS-SWITCH = 'NO'.
000411 PERFORM PRINT-SUMMARY.
000420 CLOSE STUDENT-FILE
000430 PRINT-FILE.
000440 STOP RUN.
000450
000460 PROCESS-RECORDS.
000470 MOVE STUDENT-IN TO RECORD-IMAGE.
000480 MOVE DETAIL-LINE TO PRINT-LINE.
000490 WRITE PRINT-LINE.
000500 ADD 1 TO RECORDS-WRITTEN.
000510 READ STUDENT-FILE
000520 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
000530 END-READ.
000540
000550 PRINT-SUMMARY.
000560 MOVE RECORDS-WRITTEN TO TOTAL-READ.
000570 MOVE SUMMARY-LINE TO PRINT-LINE.
000571 WRITE PRINT-LINE.
000572
000580
</textarea>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-cobol",
theme : "twilight",
styleActiveLine: true,
showCursorWhenSelecting : true,
});
function selectTheme() {
var themeInput = document.getElementById("selectTheme");
var theme = themeInput.options[themeInput.selectedIndex].innerHTML;
editor.setOption("theme", theme);
}
function selectFontsize() {
var fontSizeInput = document.getElementById("selectFontSize");
var fontSize = fontSizeInput.options[fontSizeInput.selectedIndex].innerHTML;
editor.getWrapperElement().style["font-size"] = fontSize;
editor.refresh();
}
function selectReadOnly() {
editor.setOption("readOnly", document.getElementById("checkBoxReadOnly").checked);
}
function tabToIndentSpace() {
if (document.getElementById("id_tabToIndentSpace").checked) {
editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
} else {
editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
}
}
</script>
</body>
</html>

View File

@@ -1,22 +0,0 @@
The MIT License
Copyright (c) 2011 Jeff Pickhardt
Modified from the Python CodeMirror mode, Copyright (c) 2010 Timothy Farrell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -1,347 +0,0 @@
/**
* Link to the project's GitHub page:
* https://github.com/pickhardt/coffeescript-codemirror-mode
*/
CodeMirror.defineMode('coffeescript', function(conf) {
var ERRORCLASS = 'error';
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b");
}
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\?]");
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\},:`=;\\.]');
var doubleOperators = new RegExp("^((\->)|(\=>)|(\\+\\+)|(\\+\\=)|(\\-\\-)|(\\-\\=)|(\\*\\*)|(\\*\\=)|(\\/\\/)|(\\/\\=)|(==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//))");
var doubleDelimiters = new RegExp("^((\\.\\.)|(\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
var tripleDelimiters = new RegExp("^((\\.\\.\\.)|(//=)|(>>=)|(<<=)|(\\*\\*=))");
var identifiers = new RegExp("^[_A-Za-z$][_A-Za-z$0-9]*");
var properties = new RegExp("^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*");
var wordOperators = wordRegexp(['and', 'or', 'not',
'is', 'isnt', 'in',
'instanceof', 'typeof']);
var indentKeywords = ['for', 'while', 'loop', 'if', 'unless', 'else',
'switch', 'try', 'catch', 'finally', 'class'];
var commonKeywords = ['break', 'by', 'continue', 'debugger', 'delete',
'do', 'in', 'of', 'new', 'return', 'then',
'this', 'throw', 'when', 'until'];
var keywords = wordRegexp(indentKeywords.concat(commonKeywords));
indentKeywords = wordRegexp(indentKeywords);
var stringPrefixes = new RegExp("^('{3}|\"{3}|['\"])");
var regexPrefixes = new RegExp("^(/{3}|/)");
var commonConstants = ['Infinity', 'NaN', 'undefined', 'null', 'true', 'false', 'on', 'off', 'yes', 'no'];
var constants = wordRegexp(commonConstants);
// Tokenizers
function tokenBase(stream, state) {
// Handle scope changes
if (stream.sol()) {
var scopeOffset = state.scopes[0].offset;
if (stream.eatSpace()) {
var lineOffset = stream.indentation();
if (lineOffset > scopeOffset) {
return 'indent';
} else if (lineOffset < scopeOffset) {
return 'dedent';
}
return null;
} else {
if (scopeOffset > 0) {
dedent(stream, state);
}
}
}
if (stream.eatSpace()) {
return null;
}
var ch = stream.peek();
// Handle docco title comment (single line)
if (stream.match("####")) {
stream.skipToEnd();
return 'comment';
}
// Handle multi line comments
if (stream.match("###")) {
state.tokenize = longComment;
return state.tokenize(stream, state);
}
// Single line comment
if (ch === '#') {
stream.skipToEnd();
return 'comment';
}
// Handle number literals
if (stream.match(/^-?[0-9\.]/, false)) {
var floatLiteral = false;
// Floats
if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) {
floatLiteral = true;
}
if (stream.match(/^-?\d+\.\d*/)) {
floatLiteral = true;
}
if (stream.match(/^-?\.\d+/)) {
floatLiteral = true;
}
if (floatLiteral) {
// prevent from getting extra . on 1..
if (stream.peek() == "."){
stream.backUp(1);
}
return 'number';
}
// Integers
var intLiteral = false;
// Hex
if (stream.match(/^-?0x[0-9a-f]+/i)) {
intLiteral = true;
}
// Decimal
if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) {
intLiteral = true;
}
// Zero by itself with no other piece of number.
if (stream.match(/^-?0(?![\dx])/i)) {
intLiteral = true;
}
if (intLiteral) {
return 'number';
}
}
// Handle strings
if (stream.match(stringPrefixes)) {
state.tokenize = tokenFactory(stream.current(), 'string');
return state.tokenize(stream, state);
}
// Handle regex literals
if (stream.match(regexPrefixes)) {
if (stream.current() != '/' || stream.match(/^.*\//, false)) { // prevent highlight of division
state.tokenize = tokenFactory(stream.current(), 'string-2');
return state.tokenize(stream, state);
} else {
stream.backUp(1);
}
}
// Handle operators and delimiters
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
return 'punctuation';
}
if (stream.match(doubleOperators)
|| stream.match(singleOperators)
|| stream.match(wordOperators)) {
return 'operator';
}
if (stream.match(singleDelimiters)) {
return 'punctuation';
}
if (stream.match(constants)) {
return 'atom';
}
if (stream.match(keywords)) {
return 'keyword';
}
if (stream.match(identifiers)) {
return 'variable';
}
if (stream.match(properties)) {
return 'property';
}
// Handle non-detected items
stream.next();
return ERRORCLASS;
}
function tokenFactory(delimiter, outclass) {
var singleline = delimiter.length == 1;
return function(stream, state) {
while (!stream.eol()) {
stream.eatWhile(/[^'"\/\\]/);
if (stream.eat('\\')) {
stream.next();
if (singleline && stream.eol()) {
return outclass;
}
} else if (stream.match(delimiter)) {
state.tokenize = tokenBase;
return outclass;
} else {
stream.eat(/['"\/]/);
}
}
if (singleline) {
if (conf.mode.singleLineStringErrors) {
outclass = ERRORCLASS;
} else {
state.tokenize = tokenBase;
}
}
return outclass;
};
}
function longComment(stream, state) {
while (!stream.eol()) {
stream.eatWhile(/[^#]/);
if (stream.match("###")) {
state.tokenize = tokenBase;
break;
}
stream.eatWhile("#");
}
return "comment";
}
function indent(stream, state, type) {
type = type || 'coffee';
var indentUnit = 0;
if (type === 'coffee') {
for (var i = 0; i < state.scopes.length; i++) {
if (state.scopes[i].type === 'coffee') {
indentUnit = state.scopes[i].offset + conf.indentUnit;
break;
}
}
} else {
indentUnit = stream.column() + stream.current().length;
}
state.scopes.unshift({
offset: indentUnit,
type: type
});
}
function dedent(stream, state) {
if (state.scopes.length == 1) return;
if (state.scopes[0].type === 'coffee') {
var _indent = stream.indentation();
var _indent_index = -1;
for (var i = 0; i < state.scopes.length; ++i) {
if (_indent === state.scopes[i].offset) {
_indent_index = i;
break;
}
}
if (_indent_index === -1) {
return true;
}
while (state.scopes[0].offset !== _indent) {
state.scopes.shift();
}
return false;
} else {
state.scopes.shift();
return false;
}
}
function tokenLexer(stream, state) {
var style = state.tokenize(stream, state);
var current = stream.current();
// Handle '.' connected identifiers
if (current === '.') {
style = state.tokenize(stream, state);
current = stream.current();
if (style === 'variable') {
return 'variable';
} else {
return ERRORCLASS;
}
}
// Handle scope changes.
if (current === 'return') {
state.dedent += 1;
}
if (((current === '->' || current === '=>') &&
!state.lambda &&
state.scopes[0].type == 'coffee' &&
stream.peek() === '')
|| style === 'indent') {
indent(stream, state);
}
var delimiter_index = '[({'.indexOf(current);
if (delimiter_index !== -1) {
indent(stream, state, '])}'.slice(delimiter_index, delimiter_index+1));
}
if (indentKeywords.exec(current)){
indent(stream, state);
}
if (current == 'then'){
dedent(stream, state);
}
if (style === 'dedent') {
if (dedent(stream, state)) {
return ERRORCLASS;
}
}
delimiter_index = '])}'.indexOf(current);
if (delimiter_index !== -1) {
if (dedent(stream, state)) {
return ERRORCLASS;
}
}
if (state.dedent > 0 && stream.eol() && state.scopes[0].type == 'coffee') {
if (state.scopes.length > 1) state.scopes.shift();
state.dedent -= 1;
}
return style;
}
var external = {
startState: function(basecolumn) {
return {
tokenize: tokenBase,
scopes: [{offset:basecolumn || 0, type:'coffee'}],
lastToken: null,
lambda: false,
dedent: 0
};
},
token: function(stream, state) {
var style = tokenLexer(stream, state);
state.lastToken = {style:style, content: stream.current()};
if (stream.eol() && stream.lambda) {
state.lambda = false;
}
return style;
},
indent: function(state) {
if (state.tokenize != tokenBase) {
return 0;
}
return state.scopes[0].offset;
},
lineComment: "#"
};
return external;
});
CodeMirror.defineMIME('text/x-coffeescript', 'coffeescript');

View File

@@ -1,728 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: CoffeeScript mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="coffeescript.js"></script>
<style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: CoffeeScript mode</h1>
<form><textarea id="code" name="code">
# CoffeeScript mode for CodeMirror
# Copyright (c) 2011 Jeff Pickhardt, released under
# the MIT License.
#
# Modified from the Python CodeMirror mode, which also is
# under the MIT License Copyright (c) 2010 Timothy Farrell.
#
# The following script, Underscore.coffee, is used to
# demonstrate CoffeeScript mode for CodeMirror.
#
# To download CoffeeScript mode for CodeMirror, go to:
# https://github.com/pickhardt/coffeescript-codemirror-mode
# **Underscore.coffee
# (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.**
# Underscore is freely distributable under the terms of the
# [MIT license](http://en.wikipedia.org/wiki/MIT_License).
# Portions of Underscore are inspired by or borrowed from
# [Prototype.js](http://prototypejs.org/api), Oliver Steele's
# [Functional](http://osteele.com), and John Resig's
# [Micro-Templating](http://ejohn.org).
# For all details and documentation:
# http://documentcloud.github.com/underscore/
# Baseline setup
# --------------
# Establish the root object, `window` in the browser, or `global` on the server.
root = this
# Save the previous value of the `_` variable.
previousUnderscore = root._
### Multiline
comment
###
# Establish the object that gets thrown to break out of a loop iteration.
# `StopIteration` is SOP on Mozilla.
breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration
#### Docco style single line comment (title)
# Helper function to escape **RegExp** contents, because JS doesn't have one.
escapeRegExp = (string) -> string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1')
# Save bytes in the minified (but not gzipped) version:
ArrayProto = Array.prototype
ObjProto = Object.prototype
# Create quick reference variables for speed access to core prototypes.
slice = ArrayProto.slice
unshift = ArrayProto.unshift
toString = ObjProto.toString
hasOwnProperty = ObjProto.hasOwnProperty
propertyIsEnumerable = ObjProto.propertyIsEnumerable
# All **ECMA5** native implementations we hope to use are declared here.
nativeForEach = ArrayProto.forEach
nativeMap = ArrayProto.map
nativeReduce = ArrayProto.reduce
nativeReduceRight = ArrayProto.reduceRight
nativeFilter = ArrayProto.filter
nativeEvery = ArrayProto.every
nativeSome = ArrayProto.some
nativeIndexOf = ArrayProto.indexOf
nativeLastIndexOf = ArrayProto.lastIndexOf
nativeIsArray = Array.isArray
nativeKeys = Object.keys
# Create a safe reference to the Underscore object for use below.
_ = (obj) -> new wrapper(obj)
# Export the Underscore object for **CommonJS**.
if typeof(exports) != 'undefined' then exports._ = _
# Export Underscore to global scope.
root._ = _
# Current version.
_.VERSION = '1.1.0'
# Collection Functions
# --------------------
# The cornerstone, an **each** implementation.
# Handles objects implementing **forEach**, arrays, and raw objects.
_.each = (obj, iterator, context) ->
try
if nativeForEach and obj.forEach is nativeForEach
obj.forEach iterator, context
else if _.isNumber obj.length
iterator.call context, obj[i], i, obj for i in [0...obj.length]
else
iterator.call context, val, key, obj for own key, val of obj
catch e
throw e if e isnt breaker
obj
# Return the results of applying the iterator to each element. Use JavaScript
# 1.6's version of **map**, if possible.
_.map = (obj, iterator, context) ->
return obj.map(iterator, context) if nativeMap and obj.map is nativeMap
results = []
_.each obj, (value, index, list) ->
results.push iterator.call context, value, index, list
results
# **Reduce** builds up a single result from a list of values. Also known as
# **inject**, or **foldl**. Uses JavaScript 1.8's version of **reduce**, if possible.
_.reduce = (obj, iterator, memo, context) ->
if nativeReduce and obj.reduce is nativeReduce
iterator = _.bind iterator, context if context
return obj.reduce iterator, memo
_.each obj, (value, index, list) ->
memo = iterator.call context, memo, value, index, list
memo
# The right-associative version of **reduce**, also known as **foldr**. Uses
# JavaScript 1.8's version of **reduceRight**, if available.
_.reduceRight = (obj, iterator, memo, context) ->
if nativeReduceRight and obj.reduceRight is nativeReduceRight
iterator = _.bind iterator, context if context
return obj.reduceRight iterator, memo
reversed = _.clone(_.toArray(obj)).reverse()
_.reduce reversed, iterator, memo, context
# Return the first value which passes a truth test.
_.detect = (obj, iterator, context) ->
result = null
_.each obj, (value, index, list) ->
if iterator.call context, value, index, list
result = value
_.breakLoop()
result
# Return all the elements that pass a truth test. Use JavaScript 1.6's
# **filter**, if it exists.
_.filter = (obj, iterator, context) ->
return obj.filter iterator, context if nativeFilter and obj.filter is nativeFilter
results = []
_.each obj, (value, index, list) ->
results.push value if iterator.call context, value, index, list
results
# Return all the elements for which a truth test fails.
_.reject = (obj, iterator, context) ->
results = []
_.each obj, (value, index, list) ->
results.push value if not iterator.call context, value, index, list
results
# Determine whether all of the elements match a truth test. Delegate to
# JavaScript 1.6's **every**, if it is present.
_.every = (obj, iterator, context) ->
iterator ||= _.identity
return obj.every iterator, context if nativeEvery and obj.every is nativeEvery
result = true
_.each obj, (value, index, list) ->
_.breakLoop() unless (result = result and iterator.call(context, value, index, list))
result
# Determine if at least one element in the object matches a truth test. Use
# JavaScript 1.6's **some**, if it exists.
_.some = (obj, iterator, context) ->
iterator ||= _.identity
return obj.some iterator, context if nativeSome and obj.some is nativeSome
result = false
_.each obj, (value, index, list) ->
_.breakLoop() if (result = iterator.call(context, value, index, list))
result
# Determine if a given value is included in the array or object,
# based on `===`.
_.include = (obj, target) ->
return _.indexOf(obj, target) isnt -1 if nativeIndexOf and obj.indexOf is nativeIndexOf
return true for own key, val of obj when val is target
false
# Invoke a method with arguments on every item in a collection.
_.invoke = (obj, method) ->
args = _.rest arguments, 2
(if method then val[method] else val).apply(val, args) for val in obj
# Convenience version of a common use case of **map**: fetching a property.
_.pluck = (obj, key) ->
_.map(obj, (val) -> val[key])
# Return the maximum item or (item-based computation).
_.max = (obj, iterator, context) ->
return Math.max.apply(Math, obj) if not iterator and _.isArray(obj)
result = computed: -Infinity
_.each obj, (value, index, list) ->
computed = if iterator then iterator.call(context, value, index, list) else value
computed >= result.computed and (result = {value: value, computed: computed})
result.value
# Return the minimum element (or element-based computation).
_.min = (obj, iterator, context) ->
return Math.min.apply(Math, obj) if not iterator and _.isArray(obj)
result = computed: Infinity
_.each obj, (value, index, list) ->
computed = if iterator then iterator.call(context, value, index, list) else value
computed < result.computed and (result = {value: value, computed: computed})
result.value
# Sort the object's values by a criterion produced by an iterator.
_.sortBy = (obj, iterator, context) ->
_.pluck(((_.map obj, (value, index, list) ->
{value: value, criteria: iterator.call(context, value, index, list)}
).sort((left, right) ->
a = left.criteria; b = right.criteria
if a < b then -1 else if a > b then 1 else 0
)), 'value')
# Use a comparator function to figure out at what index an object should
# be inserted so as to maintain order. Uses binary search.
_.sortedIndex = (array, obj, iterator) ->
iterator ||= _.identity
low = 0
high = array.length
while low < high
mid = (low + high) >> 1
if iterator(array[mid]) < iterator(obj) then low = mid + 1 else high = mid
low
# Convert anything iterable into a real, live array.
_.toArray = (iterable) ->
return [] if (!iterable)
return iterable.toArray() if (iterable.toArray)
return iterable if (_.isArray(iterable))
return slice.call(iterable) if (_.isArguments(iterable))
_.values(iterable)
# Return the number of elements in an object.
_.size = (obj) -> _.toArray(obj).length
# Array Functions
# ---------------
# Get the first element of an array. Passing `n` will return the first N
# values in the array. Aliased as **head**. The `guard` check allows it to work
# with **map**.
_.first = (array, n, guard) ->
if n and not guard then slice.call(array, 0, n) else array[0]
# Returns everything but the first entry of the array. Aliased as **tail**.
# Especially useful on the arguments object. Passing an `index` will return
# the rest of the values in the array from that index onward. The `guard`
# check allows it to work with **map**.
_.rest = (array, index, guard) ->
slice.call(array, if _.isUndefined(index) or guard then 1 else index)
# Get the last element of an array.
_.last = (array) -> array[array.length - 1]
# Trim out all falsy values from an array.
_.compact = (array) -> item for item in array when item
# Return a completely flattened version of an array.
_.flatten = (array) ->
_.reduce array, (memo, value) ->
return memo.concat(_.flatten(value)) if _.isArray value
memo.push value
memo
, []
# Return a version of the array that does not contain the specified value(s).
_.without = (array) ->
values = _.rest arguments
val for val in _.toArray(array) when not _.include values, val
# Produce a duplicate-free version of the array. If the array has already
# been sorted, you have the option of using a faster algorithm.
_.uniq = (array, isSorted) ->
memo = []
for el, i in _.toArray array
memo.push el if i is 0 || (if isSorted is true then _.last(memo) isnt el else not _.include(memo, el))
memo
# Produce an array that contains every item shared between all the
# passed-in arrays.
_.intersect = (array) ->
rest = _.rest arguments
_.select _.uniq(array), (item) ->
_.all rest, (other) ->
_.indexOf(other, item) >= 0
# Zip together multiple lists into a single array -- elements that share
# an index go together.
_.zip = ->
length = _.max _.pluck arguments, 'length'
results = new Array length
for i in [0...length]
results[i] = _.pluck arguments, String i
results
# If the browser doesn't supply us with **indexOf** (I'm looking at you, MSIE),
# we need this function. Return the position of the first occurrence of an
# item in an array, or -1 if the item is not included in the array.
_.indexOf = (array, item) ->
return array.indexOf item if nativeIndexOf and array.indexOf is nativeIndexOf
i = 0; l = array.length
while l - i
if array[i] is item then return i else i++
-1
# Provide JavaScript 1.6's **lastIndexOf**, delegating to the native function,
# if possible.
_.lastIndexOf = (array, item) ->
return array.lastIndexOf(item) if nativeLastIndexOf and array.lastIndexOf is nativeLastIndexOf
i = array.length
while i
if array[i] is item then return i else i--
-1
# Generate an integer Array containing an arithmetic progression. A port of
# [the native Python **range** function](http://docs.python.org/library/functions.html#range).
_.range = (start, stop, step) ->
a = arguments
solo = a.length <= 1
i = start = if solo then 0 else a[0]
stop = if solo then a[0] else a[1]
step = a[2] or 1
len = Math.ceil((stop - start) / step)
return [] if len <= 0
range = new Array len
idx = 0
loop
return range if (if step > 0 then i - stop else stop - i) >= 0
range[idx] = i
idx++
i+= step
# Function Functions
# ------------------
# Create a function bound to a given object (assigning `this`, and arguments,
# optionally). Binding with arguments is also known as **curry**.
_.bind = (func, obj) ->
args = _.rest arguments, 2
-> func.apply obj or root, args.concat arguments
# Bind all of an object's methods to that object. Useful for ensuring that
# all callbacks defined on an object belong to it.
_.bindAll = (obj) ->
funcs = if arguments.length > 1 then _.rest(arguments) else _.functions(obj)
_.each funcs, (f) -> obj[f] = _.bind obj[f], obj
obj
# Delays a function for the given number of milliseconds, and then calls
# it with the arguments supplied.
_.delay = (func, wait) ->
args = _.rest arguments, 2
setTimeout((-> func.apply(func, args)), wait)
# Memoize an expensive function by storing its results.
_.memoize = (func, hasher) ->
memo = {}
hasher or= _.identity
->
key = hasher.apply this, arguments
return memo[key] if key of memo
memo[key] = func.apply this, arguments
# Defers a function, scheduling it to run after the current call stack has
# cleared.
_.defer = (func) ->
_.delay.apply _, [func, 1].concat _.rest arguments
# Returns the first function passed as an argument to the second,
# allowing you to adjust arguments, run code before and after, and
# conditionally execute the original function.
_.wrap = (func, wrapper) ->
-> wrapper.apply wrapper, [func].concat arguments
# Returns a function that is the composition of a list of functions, each
# consuming the return value of the function that follows.
_.compose = ->
funcs = arguments
->
args = arguments
for i in [funcs.length - 1..0] by -1
args = [funcs[i].apply(this, args)]
args[0]
# Object Functions
# ----------------
# Retrieve the names of an object's properties.
_.keys = nativeKeys or (obj) ->
return _.range 0, obj.length if _.isArray(obj)
key for key, val of obj
# Retrieve the values of an object's properties.
_.values = (obj) ->
_.map obj, _.identity
# Return a sorted list of the function names available in Underscore.
_.functions = (obj) ->
_.filter(_.keys(obj), (key) -> _.isFunction(obj[key])).sort()
# Extend a given object with all of the properties in a source object.
_.extend = (obj) ->
for source in _.rest(arguments)
obj[key] = val for key, val of source
obj
# Create a (shallow-cloned) duplicate of an object.
_.clone = (obj) ->
return obj.slice 0 if _.isArray obj
_.extend {}, obj
# Invokes interceptor with the obj, and then returns obj.
# The primary purpose of this method is to "tap into" a method chain,
# in order to perform operations on intermediate results within
the chain.
_.tap = (obj, interceptor) ->
interceptor obj
obj
# Perform a deep comparison to check if two objects are equal.
_.isEqual = (a, b) ->
# Check object identity.
return true if a is b
# Different types?
atype = typeof(a); btype = typeof(b)
return false if atype isnt btype
# Basic equality test (watch out for coercions).
return true if `a == b`
# One is falsy and the other truthy.
return false if (!a and b) or (a and !b)
# One of them implements an `isEqual()`?
return a.isEqual(b) if a.isEqual
# Check dates' integer values.
return a.getTime() is b.getTime() if _.isDate(a) and _.isDate(b)
# Both are NaN?
return false if _.isNaN(a) and _.isNaN(b)
# Compare regular expressions.
if _.isRegExp(a) and _.isRegExp(b)
return a.source is b.source and
a.global is b.global and
a.ignoreCase is b.ignoreCase and
a.multiline is b.multiline
# If a is not an object by this point, we can't handle it.
return false if atype isnt 'object'
# Check for different array lengths before comparing contents.
return false if a.length and (a.length isnt b.length)
# Nothing else worked, deep compare the contents.
aKeys = _.keys(a); bKeys = _.keys(b)
# Different object sizes?
return false if aKeys.length isnt bKeys.length
# Recursive comparison of contents.
return false for key, val of a when !(key of b) or !_.isEqual(val, b[key])
true
# Is a given array or object empty?
_.isEmpty = (obj) ->
return obj.length is 0 if _.isArray(obj) or _.isString(obj)
return false for own key of obj
true
# Is a given value a DOM element?
_.isElement = (obj) -> obj and obj.nodeType is 1
# Is a given value an array?
_.isArray = nativeIsArray or (obj) -> !!(obj and obj.concat and obj.unshift and not obj.callee)
# Is a given variable an arguments object?
_.isArguments = (obj) -> obj and obj.callee
# Is the given value a function?
_.isFunction = (obj) -> !!(obj and obj.constructor and obj.call and obj.apply)
# Is the given value a string?
_.isString = (obj) -> !!(obj is '' or (obj and obj.charCodeAt and obj.substr))
# Is a given value a number?
_.isNumber = (obj) -> (obj is +obj) or toString.call(obj) is '[object Number]'
# Is a given value a boolean?
_.isBoolean = (obj) -> obj is true or obj is false
# Is a given value a Date?
_.isDate = (obj) -> !!(obj and obj.getTimezoneOffset and obj.setUTCFullYear)
# Is the given value a regular expression?
_.isRegExp = (obj) -> !!(obj and obj.exec and (obj.ignoreCase or obj.ignoreCase is false))
# Is the given value NaN -- this one is interesting. `NaN != NaN`, and
# `isNaN(undefined) == true`, so we make sure it's a number first.
_.isNaN = (obj) -> _.isNumber(obj) and window.isNaN(obj)
# Is a given value equal to null?
_.isNull = (obj) -> obj is null
# Is a given variable undefined?
_.isUndefined = (obj) -> typeof obj is 'undefined'
# Utility Functions
# -----------------
# Run Underscore.js in noConflict mode, returning the `_` variable to its
# previous owner. Returns a reference to the Underscore object.
_.noConflict = ->
root._ = previousUnderscore
this
# Keep the identity function around for default iterators.
_.identity = (value) -> value
# Run a function `n` times.
_.times = (n, iterator, context) ->
iterator.call context, i for i in [0...n]
# Break out of the middle of an iteration.
_.breakLoop = -> throw breaker
# Add your own custom functions to the Underscore object, ensuring that
# they're correctly added to the OOP wrapper as well.
_.mixin = (obj) ->
for name in _.functions(obj)
addToWrapper name, _[name] = obj[name]
# Generate a unique integer id (unique within the entire client session).
# Useful for temporary DOM ids.
idCounter = 0
_.uniqueId = (prefix) ->
(prefix or '') + idCounter++
# By default, Underscore uses **ERB**-style template delimiters, change the
# following template settings to use alternative delimiters.
_.templateSettings = {
start: '<%'
end: '%>'
interpolate: /<%=(.+?)%>/g
}
# JavaScript templating a-la **ERB**, pilfered from John Resig's
# *Secrets of the JavaScript Ninja*, page 83.
# Single-quote fix from Rick Strahl.
# With alterations for arbitrary delimiters, and to preserve whitespace.
_.template = (str, data) ->
c = _.templateSettings
endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g")
fn = new Function 'obj',
'var p=[],print=function(){p.push.apply(p,arguments);};' +
'with(obj||{}){p.push(\'' +
str.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
.replace(endMatch,"<22><><EFBFBD>")
.split("'").join("\\'")
.split("<22><><EFBFBD>").join("'")
.replace(c.interpolate, "',$1,'")
.split(c.start).join("');")
.split(c.end).join("p.push('") +
"');}return p.join('');"
if data then fn(data) else fn
# Aliases
# -------
_.forEach = _.each
_.foldl = _.inject = _.reduce
_.foldr = _.reduceRight
_.select = _.filter
_.all = _.every
_.any = _.some
_.contains = _.include
_.head = _.first
_.tail = _.rest
_.methods = _.functions
# Setup the OOP Wrapper
# ---------------------
# If Underscore is called as a function, it returns a wrapped object that
# can be used OO-style. This wrapper holds altered versions of all the
# underscore functions. Wrapped objects may be chained.
wrapper = (obj) ->
this._wrapped = obj
this
# Helper function to continue chaining intermediate results.
result = (obj, chain) ->
if chain then _(obj).chain() else obj
# A method to easily add functions to the OOP wrapper.
addToWrapper = (name, func) ->
wrapper.prototype[name] = ->
args = _.toArray arguments
unshift.call args, this._wrapped
result func.apply(_, args), this._chain
# Add all ofthe Underscore functions to the wrapper object.
_.mixin _
# Add all mutator Array functions to the wrapper.
_.each ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], (name) ->
method = Array.prototype[name]
wrapper.prototype[name] = ->
method.apply(this._wrapped, arguments)
result(this._wrapped, this._chain)
# Add all accessor Array functions to the wrapper.
_.each ['concat', 'join', 'slice'], (name) ->
method = Array.prototype[name]
wrapper.prototype[name] = ->
result(method.apply(this._wrapped, arguments), this._chain)
# Start chaining a wrapped Underscore object.
wrapper::chain = ->
this._chain = true
this
# Extracts the result from a wrapped and chained object.
wrapper::value = -> this._wrapped
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-coffeescript</code>.</p>
<p>The CoffeeScript mode was written by Jeff Pickhardt (<a href="LICENSE">license</a>).</p>
</body>
</html>

View File

@@ -1,105 +0,0 @@
CodeMirror.defineMode("commonlisp", function (config) {
var assumeBody = /^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/;
var numLiteral = /^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/;
var symbol = /[^\s'`,@()\[\]";]/;
var type;
function readSym(stream) {
var ch;
while (ch = stream.next()) {
if (ch == "\\") stream.next();
else if (!symbol.test(ch)) { stream.backUp(1); break; }
}
return stream.current();
}
function base(stream, state) {
if (stream.eatSpace()) {type = "ws"; return null;}
if (stream.match(numLiteral)) return "number";
var ch = stream.next();
if (ch == "\\") ch = stream.next();
if (ch == '"') return (state.tokenize = inString)(stream, state);
else if (ch == "(") { type = "open"; return "bracket"; }
else if (ch == ")" || ch == "]") { type = "close"; return "bracket"; }
else if (ch == ";") { stream.skipToEnd(); type = "ws"; return "comment"; }
else if (/['`,@]/.test(ch)) return null;
else if (ch == "|") {
if (stream.skipTo("|")) { stream.next(); return "symbol"; }
else { stream.skipToEnd(); return "error"; }
} else if (ch == "#") {
var ch = stream.next();
if (ch == "[") { type = "open"; return "bracket"; }
else if (/[+\-=\.']/.test(ch)) return null;
else if (/\d/.test(ch) && stream.match(/^\d*#/)) return null;
else if (ch == "|") return (state.tokenize = inComment)(stream, state);
else if (ch == ":") { readSym(stream); return "meta"; }
else return "error";
} else {
var name = readSym(stream);
if (name == ".") return null;
type = "symbol";
if (name == "nil" || name == "t") return "atom";
if (name.charAt(0) == ":") return "keyword";
if (name.charAt(0) == "&") return "variable-2";
return "variable";
}
}
function inString(stream, state) {
var escaped = false, next;
while (next = stream.next()) {
if (next == '"' && !escaped) { state.tokenize = base; break; }
escaped = !escaped && next == "\\";
}
return "string";
}
function inComment(stream, state) {
var next, last;
while (next = stream.next()) {
if (next == "#" && last == "|") { state.tokenize = base; break; }
last = next;
}
type = "ws";
return "comment";
}
return {
startState: function () {
return {ctx: {prev: null, start: 0, indentTo: 0}, tokenize: base};
},
token: function (stream, state) {
if (stream.sol() && typeof state.ctx.indentTo != "number")
state.ctx.indentTo = state.ctx.start + 1;
type = null;
var style = state.tokenize(stream, state);
if (type != "ws") {
if (state.ctx.indentTo == null) {
if (type == "symbol" && assumeBody.test(stream.current()))
state.ctx.indentTo = state.ctx.start + config.indentUnit;
else
state.ctx.indentTo = "next";
} else if (state.ctx.indentTo == "next") {
state.ctx.indentTo = stream.column();
}
}
if (type == "open") state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null};
else if (type == "close") state.ctx = state.ctx.prev || state.ctx;
return style;
},
indent: function (state, _textAfter) {
var i = state.ctx.indentTo;
return typeof i == "number" ? i : state.ctx.start + 1;
},
lineComment: ";;",
blockCommentStart: "#|",
blockCommentEnd: "|#"
};
});
CodeMirror.defineMIME("text/x-common-lisp", "commonlisp");

View File

@@ -1,165 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Common Lisp mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="commonlisp.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: Common Lisp mode</h1>
<form><textarea id="code" name="code">(in-package :cl-postgres)
;; These are used to synthesize reader and writer names for integer
;; reading/writing functions when the amount of bytes and the
;; signedness is known. Both the macro that creates the functions and
;; some macros that use them create names this way.
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun integer-reader-name (bytes signed)
(intern (with-standard-io-syntax
(format nil "~a~a~a~a" '#:read- (if signed "" '#:u) '#:int bytes))))
(defun integer-writer-name (bytes signed)
(intern (with-standard-io-syntax
(format nil "~a~a~a~a" '#:write- (if signed "" '#:u) '#:int bytes)))))
(defmacro integer-reader (bytes)
"Create a function to read integers from a binary stream."
(let ((bits (* bytes 8)))
(labels ((return-form (signed)
(if signed
`(if (logbitp ,(1- bits) result)
(dpb result (byte ,(1- bits) 0) -1)
result)
`result))
(generate-reader (signed)
`(defun ,(integer-reader-name bytes signed) (socket)
(declare (type stream socket)
#.*optimize*)
,(if (= bytes 1)
`(let ((result (the (unsigned-byte 8) (read-byte socket))))
(declare (type (unsigned-byte 8) result))
,(return-form signed))
`(let ((result 0))
(declare (type (unsigned-byte ,bits) result))
,@(loop :for byte :from (1- bytes) :downto 0
:collect `(setf (ldb (byte 8 ,(* 8 byte)) result)
(the (unsigned-byte 8) (read-byte socket))))
,(return-form signed))))))
`(progn
;; This causes weird errors on SBCL in some circumstances. Disabled for now.
;; (declaim (inline ,(integer-reader-name bytes t)
;; ,(integer-reader-name bytes nil)))
(declaim (ftype (function (t) (signed-byte ,bits))
,(integer-reader-name bytes t)))
,(generate-reader t)
(declaim (ftype (function (t) (unsigned-byte ,bits))
,(integer-reader-name bytes nil)))
,(generate-reader nil)))))
(defmacro integer-writer (bytes)
"Create a function to write integers to a binary stream."
(let ((bits (* 8 bytes)))
`(progn
(declaim (inline ,(integer-writer-name bytes t)
,(integer-writer-name bytes nil)))
(defun ,(integer-writer-name bytes nil) (socket value)
(declare (type stream socket)
(type (unsigned-byte ,bits) value)
#.*optimize*)
,@(if (= bytes 1)
`((write-byte value socket))
(loop :for byte :from (1- bytes) :downto 0
:collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
socket)))
(values))
(defun ,(integer-writer-name bytes t) (socket value)
(declare (type stream socket)
(type (signed-byte ,bits) value)
#.*optimize*)
,@(if (= bytes 1)
`((write-byte (ldb (byte 8 0) value) socket))
(loop :for byte :from (1- bytes) :downto 0
:collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
socket)))
(values)))))
;; All the instances of the above that we need.
(integer-reader 1)
(integer-reader 2)
(integer-reader 4)
(integer-reader 8)
(integer-writer 1)
(integer-writer 2)
(integer-writer 4)
(defun write-bytes (socket bytes)
"Write a byte-array to a stream."
(declare (type stream socket)
(type (simple-array (unsigned-byte 8)) bytes)
#.*optimize*)
(write-sequence bytes socket))
(defun write-str (socket string)
"Write a null-terminated string to a stream \(encoding it when UTF-8
support is enabled.)."
(declare (type stream socket)
(type string string)
#.*optimize*)
(enc-write-string string socket)
(write-uint1 socket 0))
(declaim (ftype (function (t unsigned-byte)
(simple-array (unsigned-byte 8) (*)))
read-bytes))
(defun read-bytes (socket length)
"Read a byte array of the given length from a stream."
(declare (type stream socket)
(type fixnum length)
#.*optimize*)
(let ((result (make-array length :element-type '(unsigned-byte 8))))
(read-sequence result socket)
result))
(declaim (ftype (function (t) string) read-str))
(defun read-str (socket)
"Read a null-terminated string from a stream. Takes care of encoding
when UTF-8 support is enabled."
(declare (type stream socket)
#.*optimize*)
(enc-read-string socket :null-terminated t))
(defun skip-bytes (socket length)
"Skip a given number of bytes in a binary stream."
(declare (type stream socket)
(type (unsigned-byte 32) length)
#.*optimize*)
(dotimes (i length)
(read-byte socket)))
(defun skip-str (socket)
"Skip a null-terminated string."
(declare (type stream socket)
#.*optimize*)
(loop :for char :of-type fixnum = (read-byte socket)
:until (zerop char)))
(defun ensure-socket-is-closed (socket &amp;key abort)
(when (open-stream-p socket)
(handler-case
(close socket :abort abort)
(error (error)
(warn "Ignoring the error which happened while trying to close PostgreSQL socket: ~A" error)))))
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {lineNumbers: true});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-common-lisp</code>.</p>
</body>
</html>

View File

@@ -1,11 +1,9 @@
CodeMirror.defineMode("css", function(config) {
return CodeMirror.getMode(config, "text/css");
});
CodeMirror.defineMode("css-base", function(config, parserConfig) {
CodeMirror.defineMode("css", function(config, parserConfig) {
"use strict";
var indentUnit = config.indentUnit,
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
var indentUnit = config.indentUnit || config.tabSize || 2,
hooks = parserConfig.hooks || {},
atMediaTypes = parserConfig.atMediaTypes || {},
atMediaFeatures = parserConfig.atMediaFeatures || {},
@@ -39,7 +37,7 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
stream.match(/^\s*\w*/);
return ret("keyword", "important");
}
else if (/\d/.test(ch)) {
else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
stream.eatWhile(/[\w.%]/);
return ret("number", "unit");
}
@@ -103,7 +101,8 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
startState: function(base) {
return {tokenize: tokenBase,
baseIndent: base || 0,
stack: []};
stack: [],
lastToken: null};
},
token: function(stream, state) {
@@ -163,7 +162,7 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
var context = state.stack[state.stack.length-1];
if (style == "variable") {
if (type == "variable-definition") state.stack.push("propertyValue");
return "variable-2";
return state.lastToken = "variable-2";
} else if (style == "property") {
var word = stream.current().toLowerCase();
if (context == "propertyValue") {
@@ -251,7 +250,6 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
// Push/pop context stack
if (type == "{") {
if (context == "@media" || context == "@mediaType") {
state.stack.pop();
state.stack[state.stack.length-1] = "@media{";
}
else {
@@ -260,35 +258,57 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
}
}
else if (type == "}") {
var lastState = state.stack[state.stack.length - 1];
if (lastState == "interpolation") style = "operator";
state.stack.pop();
if (context == "propertyValue") state.stack.pop();
if (context == "interpolation") style = "operator";
// Pop off end of array until { is reached
while(state.stack.length){
var removed = state.stack.pop();
if(removed.indexOf("{") > -1){
break;
}
}
}
else if (type == "interpolation") state.stack.push("interpolation");
else if (type == "@media") state.stack.push("@media");
else if (type == "@import") state.stack.push("@import");
else if (context == "@media" && /\b(keyword|attribute)\b/.test(style))
state.stack.push("@mediaType");
else if (context == "@mediaType" && stream.current() == ",") state.stack.pop();
else if (context == "@mediaType" && type == "(") state.stack.push("@mediaType(");
else if (context == "@mediaType(" && type == ")") state.stack.pop();
else if ((context == "rule" || context == "block") && type == ":") state.stack.push("propertyValue");
state.stack[state.stack.length-1] = "@mediaType";
else if (context == "@mediaType" && stream.current() == ",")
state.stack[state.stack.length-1] = "@media";
else if (type == "(") {
if (context == "@media" || context == "@mediaType") {
// Make sure @mediaType is used to avoid error on {
state.stack[state.stack.length-1] = "@mediaType";
state.stack.push("@mediaType(");
}
else state.stack.push("(");
}
else if (type == ")") {
// Pop off end of array until ( is reached
while(state.stack.length){
var removed = state.stack.pop();
if(removed.indexOf("(") > -1){
break;
}
}
}
else if (type == ":" && state.lastToken == "property") state.stack.push("propertyValue");
else if (context == "propertyValue" && type == ";") state.stack.pop();
else if (context == "@import" && type == ";") state.stack.pop();
return style;
return state.lastToken = style;
},
indent: function(state, textAfter) {
var n = state.stack.length;
if (/^\}/.test(textAfter))
n -= state.stack[state.stack.length-1] == "propertyValue" ? 2 : 1;
n -= state.stack[n-1] == "propertyValue" ? 2 : 1;
return state.baseIndent + n * indentUnit;
},
electricChars: "}",
blockCommentStart: "/*",
blockCommentEnd: "*/"
blockCommentEnd: "*/",
fold: "brace"
};
});
@@ -349,8 +369,8 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
"drop-initial-before-align", "drop-initial-size", "drop-initial-value",
"elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
"flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
"float", "float-offset", "font", "font-feature-settings", "font-family",
"font-kerning", "font-language-override", "font-size", "font-size-adjust",
"float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
"font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
"font-stretch", "font-style", "font-synthesis", "font-variant",
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
@@ -374,25 +394,27 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
"page", "page-break-after", "page-break-before", "page-break-inside",
"page-policy", "pause", "pause-after", "pause-before", "perspective",
"perspective-origin", "pitch", "pitch-range", "play-during", "position",
"presentation-level", "punctuation-trim", "quotes", "rendering-intent",
"resize", "rest", "rest-after", "rest-before", "richness", "right",
"rotation", "rotation-point", "ruby-align", "ruby-overhang",
"ruby-position", "ruby-span", "size", "speak", "speak-as", "speak-header",
"presentation-level", "punctuation-trim", "quotes", "region-break-after",
"region-break-before", "region-break-inside", "region-fragment",
"rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
"right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
"ruby-position", "ruby-span", "shape-inside", "shape-outside", "size",
"speak", "speak-as", "speak-header",
"speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
"tab-size", "table-layout", "target", "target-name", "target-new",
"target-position", "text-align", "text-align-last", "text-decoration",
"text-decoration-color", "text-decoration-line", "text-decoration-skip",
"text-decoration-style", "text-emphasis", "text-emphasis-color",
"text-emphasis-position", "text-emphasis-style", "text-height",
"text-indent", "text-justify", "text-outline", "text-shadow",
"text-space-collapse", "text-transform", "text-underline-position",
"text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
"text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
"text-wrap", "top", "transform", "transform-origin", "transform-style",
"transition", "transition-delay", "transition-duration",
"transition-property", "transition-timing-function", "unicode-bidi",
"vertical-align", "visibility", "voice-balance", "voice-duration",
"voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
"voice-volume", "volume", "white-space", "widows", "width", "word-break",
"word-spacing", "word-wrap", "z-index",
"word-spacing", "word-wrap", "z-index", "zoom",
// SVG-specific
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
@@ -415,7 +437,7 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
"gold", "goldenrod", "gray", "green", "greenyellow", "honeydew",
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
@@ -438,22 +460,22 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
"above", "absolute", "activeborder", "activecaption", "afar",
"after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
"arabic-indic", "armenian", "asterisks", "auto", "avoid", "background",
"backwards", "baseline", "below", "bidi-override", "binary", "bengali",
"blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
"both", "bottom", "break-all", "break-word", "button", "button-bevel",
"arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page",
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
"both", "bottom", "break", "break-all", "break-word", "button", "button-bevel",
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
"cell", "center", "checkbox", "circle", "cjk-earthly-branch",
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
"col-resize", "collapse", "compact", "condensed", "contain", "content",
"col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
"content-box", "context-menu", "continuous", "copy", "cover", "crop",
"cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
"decimal-leading-zero", "default", "default-button", "destination-atop",
"destination-in", "destination-out", "destination-over", "devanagari",
"disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
"double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
"element", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
"ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
"ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
"ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
@@ -469,7 +491,7 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
"inline-block", "inline-table", "inset", "inside", "intrinsic", "invert",
"italic", "justify", "kannada", "katakana", "katakana-iroha", "khmer",
"italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer",
"landscape", "lao", "large", "larger", "left", "level", "lighter",
"line-through", "linear", "lines", "list-item", "listbox", "listitem",
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
@@ -488,11 +510,11 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
"ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
"outside", "overlay", "overline", "padding", "padding-box", "painted",
"paused", "persian", "plus-darker", "plus-lighter", "pointer", "portrait",
"pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
"radio", "read-only", "read-write", "read-write-plaintext-only", "relative",
"repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
"painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer",
"polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
"radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region",
"relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
"ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
"s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
"searchfield-cancel-button", "searchfield-decoration",
@@ -563,7 +585,7 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
return false;
}
},
name: "css-base"
name: "css"
});
CodeMirror.defineMIME("text/x-scss", {
@@ -574,6 +596,12 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
valueKeywords: valueKeywords,
allowNested: true,
hooks: {
":": function(stream) {
if (stream.match(/\s*{/)) {
return [null, "{"];
}
return false;
},
"$": function(stream) {
stream.match(/^[\w-]+/);
if (stream.peek() == ":") {
@@ -581,6 +609,11 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
}
return ["variable", "variable"];
},
",": function(_stream, state) {
if (state.stack[state.stack.length - 1] == "propertyValue") {
return ["operator", ";"];
}
},
"/": function(stream, state) {
if (stream.eat("/")) {
stream.skipToEnd();
@@ -601,6 +634,6 @@ CodeMirror.defineMode("css-base", function(config, parserConfig) {
}
}
},
name: "css-base"
name: "css"
});
})();

View File

@@ -1,58 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: CSS mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="css.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: CSS mode</h1>
<form><textarea id="code" name="code">
/* Some example CSS */
@import url("something.css");
body {
margin: 0;
padding: 3em 6em;
font-family: tahoma, arial, sans-serif;
color: #000;
}
#navigation a {
font-weight: bold;
text-decoration: none !important;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 1.7em;
}
h1:before, h2:before {
content: "::";
}
code {
font-family: courier, monospace;
font-size: 80%;
color: #418A8A;
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
</script>
<p><strong>MIME types defined:</strong> <code>text/css</code>.</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#css_*">normal</a>, <a href="../../test/index.html#verbose,css_*">verbose</a>.</p>
</body>
</html>

View File

@@ -1,17 +1,30 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: SCSS mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="css.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: SCSS mode</h1>
<form><textarea id="code" name="code">
<title>CodeMirror: SCSS mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="css.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">SCSS</a>
</ul>
</div>
<article>
<h2>SCSS mode</h2>
<form><textarea id="code" name="code">
/* Some example SCSS */
@import "compass/css3";
@@ -141,5 +154,4 @@ code {
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#scss_*">normal</a>, <a href="../../test/index.html#verbose,scss_*">verbose</a>.</p>
</body>
</html>
</article>

View File

@@ -1,6 +1,7 @@
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "text/x-scss");
var mode = CodeMirror.getMode({tabSize: 1}, "text/x-scss");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); }
function IT(name) { test.indentation(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); }
MT('url_with_quotation',
"[tag foo] { [property background][operator :][string-2 url]([string test.jpg]) }");
@@ -64,7 +65,7 @@
"[tag p] { [tag a] { [property color][operator :][atom #000]; } }");
MT('interpolation_in_property',
"[tag foo] { [operator #{][variable-2 $hello][operator }:][atom #000]; }");
"[tag foo] { [operator #{][variable-2 $hello][operator }:][number 2]; }");
MT('interpolation_in_selector',
"[tag foo][operator #{][variable-2 $hello][operator }] { [property color][operator :][atom #000]; }");
@@ -77,4 +78,7 @@
MT('nested_structure_with_id_selector',
"[tag p] { [builtin #hello] { [property color][operator :][keyword red]; } }");
IT('mixin',
"@mixin container[1 (][2 $a: 10][1 , ][2 $b: 10][1 , ][2 $c: 10]) [1 {]}");
})();

View File

@@ -1,6 +1,7 @@
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "css");
var mode = CodeMirror.getMode({tabSize: 1}, "css");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
function IT(name) { test.indentation(name, mode, Array.prototype.slice.call(arguments, 1)); }
// Requires at least one media query
MT("atMediaEmpty",
@@ -15,6 +16,12 @@
MT("atMediaCheckStack",
"[def @media] [attribute screen] ([property color]) { } [tag foo] { }");
MT("atMediaPropertyOnly",
"[def @media] ([property color]) { } [tag foo] { }");
MT("atMediaCheckStackInvalidAttribute",
"[def @media] [attribute&error foobarhello] { [tag foo] { } }");
MT("atMediaCheckStackInvalidAttribute",
"[def @media] [attribute&error foobarhello] { } [tag foo] { }");
@@ -53,6 +60,10 @@
MT("atMediaUnknownProperty",
"[def @media] [attribute screen] [operator and] ([property&error foobarhello]) { }");
// Make sure nesting works with media queries
MT("atMediaMaxWidthNested",
"[def @media] [attribute screen] [operator and] ([property max-width][operator :] [number 25px]) { [tag foo] { } }");
MT("tagSelector",
"[tag foo] { }");
@@ -108,6 +119,12 @@
MT("tagTwoProperties",
"[tag foo] { [property margin][operator :] [number 0]; [property padding][operator :] [number 0]; }");
MT("tagTwoPropertiesURL",
"[tag foo] { [property background][operator :] [string-2 url]([string //example.com/foo.png]); [property padding][operator :] [number 0]; }");
MT("commentSGML",
"[comment <!--comment-->]");
IT("tagSelector",
"strong, em [1 { background][2 : rgba][3 (255, 255, 0, .2][2 )][1 ;]}");
})();

View File

@@ -1,205 +0,0 @@
CodeMirror.defineMode("d", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
keywords = parserConfig.keywords || {},
builtin = parserConfig.builtin || {},
blockKeywords = parserConfig.blockKeywords || {},
atoms = parserConfig.atoms || {},
hooks = parserConfig.hooks || {},
multiLineStrings = parserConfig.multiLineStrings;
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
var curPunc;
function tokenBase(stream, state) {
var ch = stream.next();
if (hooks[ch]) {
var result = hooks[ch](stream, state);
if (result !== false) return result;
}
if (ch == '"' || ch == "'" || ch == "`") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
curPunc = ch;
return null;
}
if (/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
return "number";
}
if (ch == "/") {
if (stream.eat("+")) {
state.tokenize = tokenComment;
return tokenNestedComment(stream, state);
}
if (stream.eat("*")) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
}
if (stream.eat("/")) {
stream.skipToEnd();
return "comment";
}
}
if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return "operator";
}
stream.eatWhile(/[\w\$_]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "keyword";
}
if (builtin.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "builtin";
}
if (atoms.propertyIsEnumerable(cur)) return "atom";
return "variable";
}
function tokenString(quote) {
return function(stream, state) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {end = true; break;}
escaped = !escaped && next == "\\";
}
if (end || !(escaped || multiLineStrings))
state.tokenize = null;
return "string";
};
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = null;
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}
function tokenNestedComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = null;
break;
}
maybeEnd = (ch == "+");
}
return "comment";
}
function Context(indented, column, type, align, prev) {
this.indented = indented;
this.column = column;
this.type = type;
this.align = align;
this.prev = prev;
}
function pushContext(state, col, type) {
var indent = state.indented;
if (state.context && state.context.type == "statement")
indent = state.context.indented;
return state.context = new Context(indent, col, type, null, state.context);
}
function popContext(state) {
var t = state.context.type;
if (t == ")" || t == "]" || t == "}")
state.indented = state.context.indented;
return state.context = state.context.prev;
}
// Interface
return {
startState: function(basecolumn) {
return {
tokenize: null,
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
indented: 0,
startOfLine: true
};
},
token: function(stream, state) {
var ctx = state.context;
if (stream.sol()) {
if (ctx.align == null) ctx.align = false;
state.indented = stream.indentation();
state.startOfLine = true;
}
if (stream.eatSpace()) return null;
curPunc = null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style == "comment" || style == "meta") return style;
if (ctx.align == null) ctx.align = true;
if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
else if (curPunc == "{") pushContext(state, stream.column(), "}");
else if (curPunc == "[") pushContext(state, stream.column(), "]");
else if (curPunc == "(") pushContext(state, stream.column(), ")");
else if (curPunc == "}") {
while (ctx.type == "statement") ctx = popContext(state);
if (ctx.type == "}") ctx = popContext(state);
while (ctx.type == "statement") ctx = popContext(state);
}
else if (curPunc == ctx.type) popContext(state);
else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
pushContext(state, stream.column(), "statement");
state.startOfLine = false;
return style;
},
indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
var closing = firstChar == ctx.type;
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
else return ctx.indented + (closing ? 0 : indentUnit);
},
electricChars: "{}"
};
});
(function() {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var blockKeywords = "body catch class do else enum for foreach foreach_reverse if in interface mixin " +
"out scope struct switch try union unittest version while with";
CodeMirror.defineMIME("text/x-d", {
name: "d",
keywords: words("abstract alias align asm assert auto break case cast cdouble cent cfloat const continue " +
"debug default delegate delete deprecated export extern final finally function goto immutable " +
"import inout invariant is lazy macro module new nothrow override package pragma private " +
"protected public pure ref return shared short static super synchronized template this " +
"throw typedef typeid typeof volatile __FILE__ __LINE__ __gshared __traits __vector __parameters " +
blockKeywords),
blockKeywords: words(blockKeywords),
builtin: words("bool byte char creal dchar double float idouble ifloat int ireal long real short ubyte " +
"ucent uint ulong ushort wchar wstring void size_t sizediff_t"),
atoms: words("exit failure success true false null"),
hooks: {
"@": function(stream, _state) {
stream.eatWhile(/[\w\$_]/);
return "meta";
}
}
});
}());

View File

@@ -1,262 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: D mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="d.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border: 2px inset #dee;}</style>
</head>
<body>
<h1>CodeMirror: D mode</h1>
<form><textarea id="code" name="code">
/* D demo code // copied from phobos/sd/metastrings.d */
// Written in the D programming language.
/**
Templates with which to do compile-time manipulation of strings.
Macros:
WIKI = Phobos/StdMetastrings
Copyright: Copyright Digital Mars 2007 - 2009.
License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
Authors: $(WEB digitalmars.com, Walter Bright),
Don Clugston
Source: $(PHOBOSSRC std/_metastrings.d)
*/
/*
Copyright Digital Mars 2007 - 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
module std.metastrings;
/**
Formats constants into a string at compile time. Analogous to $(XREF
string,format).
Parameters:
A = tuple of constants, which can be strings, characters, or integral
values.
Formats:
* The formats supported are %s for strings, and %%
* for the % character.
Example:
---
import std.metastrings;
import std.stdio;
void main()
{
string s = Format!("Arg %s = %s", "foo", 27);
writefln(s); // "Arg foo = 27"
}
* ---
*/
template Format(A...)
{
static if (A.length == 0)
enum Format = "";
else static if (is(typeof(A[0]) : const(char)[]))
enum Format = FormatString!(A[0], A[1..$]);
else
enum Format = toStringNow!(A[0]) ~ Format!(A[1..$]);
}
template FormatString(const(char)[] F, A...)
{
static if (F.length == 0)
enum FormatString = Format!(A);
else static if (F.length == 1)
enum FormatString = F[0] ~ Format!(A);
else static if (F[0..2] == "%s")
enum FormatString
= toStringNow!(A[0]) ~ FormatString!(F[2..$],A[1..$]);
else static if (F[0..2] == "%%")
enum FormatString = "%" ~ FormatString!(F[2..$],A);
else
{
static assert(F[0] != '%', "unrecognized format %" ~ F[1]);
enum FormatString = F[0] ~ FormatString!(F[1..$],A);
}
}
unittest
{
auto s = Format!("hel%slo", "world", -138, 'c', true);
assert(s == "helworldlo-138ctrue", "[" ~ s ~ "]");
}
/**
* Convert constant argument to a string.
*/
template toStringNow(ulong v)
{
static if (v < 10)
enum toStringNow = "" ~ cast(char)(v + '0');
else
enum toStringNow = toStringNow!(v / 10) ~ toStringNow!(v % 10);
}
unittest
{
static assert(toStringNow!(1uL << 62) == "4611686018427387904");
}
/// ditto
template toStringNow(long v)
{
static if (v < 0)
enum toStringNow = "-" ~ toStringNow!(cast(ulong) -v);
else
enum toStringNow = toStringNow!(cast(ulong) v);
}
unittest
{
static assert(toStringNow!(0x100000000) == "4294967296");
static assert(toStringNow!(-138L) == "-138");
}
/// ditto
template toStringNow(uint U)
{
enum toStringNow = toStringNow!(cast(ulong)U);
}
/// ditto
template toStringNow(int I)
{
enum toStringNow = toStringNow!(cast(long)I);
}
/// ditto
template toStringNow(bool B)
{
enum toStringNow = B ? "true" : "false";
}
/// ditto
template toStringNow(string S)
{
enum toStringNow = S;
}
/// ditto
template toStringNow(char C)
{
enum toStringNow = "" ~ C;
}
/********
* Parse unsigned integer literal from the start of string s.
* returns:
* .value = the integer literal as a string,
* .rest = the string following the integer literal
* Otherwise:
* .value = null,
* .rest = s
*/
template parseUinteger(const(char)[] s)
{
static if (s.length == 0)
{
enum value = "";
enum rest = "";
}
else static if (s[0] >= '0' && s[0] <= '9')
{
enum value = s[0] ~ parseUinteger!(s[1..$]).value;
enum rest = parseUinteger!(s[1..$]).rest;
}
else
{
enum value = "";
enum rest = s;
}
}
/********
Parse integer literal optionally preceded by $(D '-') from the start
of string $(D s).
Returns:
.value = the integer literal as a string,
.rest = the string following the integer literal
Otherwise:
.value = null,
.rest = s
*/
template parseInteger(const(char)[] s)
{
static if (s.length == 0)
{
enum value = "";
enum rest = "";
}
else static if (s[0] >= '0' && s[0] <= '9')
{
enum value = s[0] ~ parseUinteger!(s[1..$]).value;
enum rest = parseUinteger!(s[1..$]).rest;
}
else static if (s.length >= 2 &&
s[0] == '-' && s[1] >= '0' && s[1] <= '9')
{
enum value = s[0..2] ~ parseUinteger!(s[2..$]).value;
enum rest = parseUinteger!(s[2..$]).rest;
}
else
{
enum value = "";
enum rest = s;
}
}
unittest
{
assert(parseUinteger!("1234abc").value == "1234");
assert(parseUinteger!("1234abc").rest == "abc");
assert(parseInteger!("-1234abc").value == "-1234");
assert(parseInteger!("-1234abc").rest == "abc");
}
/**
Deprecated aliases held for backward compatibility.
*/
deprecated alias toStringNow ToString;
/// Ditto
deprecated alias parseUinteger ParseUinteger;
/// Ditto
deprecated alias parseUinteger ParseInteger;
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
indentUnit: 4,
mode: "text/x-d"
});
</script>
<p>Simple mode that handle D-Syntax (<a href="http://www.dlang.org">DLang Homepage</a>).</p>
<p><strong>MIME types defined:</strong> <code>text/x-d</code>
.</p>
</body>
</html>

View File

@@ -1,32 +0,0 @@
CodeMirror.defineMode("diff", function() {
var TOKEN_NAMES = {
'+': 'positive',
'-': 'negative',
'@': 'meta'
};
return {
token: function(stream) {
var tw_pos = stream.string.search(/[\t ]+?$/);
if (!stream.sol() || tw_pos === 0) {
stream.skipToEnd();
return ("error " + (
TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
}
var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
if (tw_pos === -1) {
stream.skipToEnd();
} else {
stream.pos = tw_pos;
}
return token_name;
}
};
});
CodeMirror.defineMIME("text/x-diff", "diff");

View File

@@ -1,105 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Diff mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="diff.js"></script>
<style>
.CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
span.cm-meta {color: #a0b !important;}
span.cm-error { background-color: black; opacity: 0.4;}
span.cm-error.cm-string { background-color: red; }
span.cm-error.cm-tag { background-color: #2b2; }
</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: Diff mode</h1>
<form><textarea id="code" name="code">
diff --git a/index.html b/index.html
index c1d9156..7764744 100644
--- a/index.html
+++ b/index.html
@@ -95,7 +95,8 @@ StringStream.prototype = {
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
- autoMatchBrackets: true
+ autoMatchBrackets: true,
+ onGutterClick: function(x){console.log(x);}
});
</script>
</body>
diff --git a/lib/codemirror.js b/lib/codemirror.js
index 04646a9..9a39cc7 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -399,10 +399,16 @@ var CodeMirror = (function() {
}
function onMouseDown(e) {
- var start = posFromMouse(e), last = start;
+ var start = posFromMouse(e), last = start, target = e.target();
if (!start) return;
setCursor(start.line, start.ch, false);
if (e.button() != 1) return;
+ if (target.parentNode == gutter) {
+ if (options.onGutterClick)
+ options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom);
+ return;
+ }
+
if (!focused) onFocus();
e.stop();
@@ -808,7 +814,7 @@ var CodeMirror = (function() {
for (var i = showingFrom; i < showingTo; ++i) {
var marker = lines[i].gutterMarker;
if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>');
- else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>");
+ else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>");
}
gutter.style.display = "none"; // TODO test whether this actually helps
gutter.innerHTML = html.join("");
@@ -1371,10 +1377,8 @@ var CodeMirror = (function() {
if (option == "parser") setParser(value);
else if (option === "lineNumbers") setLineNumbers(value);
else if (option === "gutter") setGutter(value);
- else if (option === "readOnly") options.readOnly = value;
- else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);}
- else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value;
- else throw new Error("Can't set option " + option);
+ else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);}
+ else options[option] = value;
},
cursorCoords: cursorCoords,
undo: operation(undo),
@@ -1402,7 +1406,8 @@ var CodeMirror = (function() {
replaceRange: operation(replaceRange),
operation: function(f){return operation(f)();},
- refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}
+ refresh: function(){updateDisplay([{from: 0, to: lines.length}]);},
+ getInputField: function(){return input;}
};
return instance;
}
@@ -1420,6 +1425,7 @@ var CodeMirror = (function() {
readOnly: false,
onChange: null,
onCursorActivity: null,
+ onGutterClick: null,
autoMatchBrackets: false,
workTime: 200,
workDelay: 300,
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
</body>
</html>

View File

@@ -1,192 +0,0 @@
CodeMirror.defineMode("ecl", function(config) {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
function metaHook(stream, state) {
if (!state.startOfLine) return false;
stream.skipToEnd();
return "meta";
}
var indentUnit = config.indentUnit;
var keyword = words("abs acos allnodes ascii asin asstring atan atan2 ave case choose choosen choosesets clustersize combine correlation cos cosh count covariance cron dataset dedup define denormalize distribute distributed distribution ebcdic enth error evaluate event eventextra eventname exists exp failcode failmessage fetch fromunicode getisvalid global graph group hash hash32 hash64 hashcrc hashmd5 having if index intformat isvalid iterate join keyunicode length library limit ln local log loop map matched matchlength matchposition matchtext matchunicode max merge mergejoin min nolocal nonempty normalize parse pipe power preload process project pull random range rank ranked realformat recordof regexfind regexreplace regroup rejected rollup round roundup row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt stepped stored sum table tan tanh thisnode topn tounicode transfer trim truncate typeof ungroup unicodeorder variance which workunit xmldecode xmlencode xmltext xmlunicode");
var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
var variable_2 = words("__compressed__ all and any as atmost before beginc++ best between case const counter csv descend encrypt end endc++ endmacro except exclusive expire export extend false few first flat from full function group header heading hole ifblock import in interface joined keep keyed last left limit load local locale lookup macro many maxcount maxlength min skew module named nocase noroot noscan nosort not of only opt or outer overwrite packed partition penalty physicallength pipe quote record relationship repeat return right scan self separator service shared skew skip sql store terminator thor threshold token transform trim true type unicodeorder unsorted validate virtual whole wild within xml xpath");
var variable_3 = words("ascii big_endian boolean data decimal ebcdic integer pattern qstring real record rule set of string token udecimal unicode unsigned varstring varunicode");
var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
var blockKeywords = words("catch class do else finally for if switch try while");
var atoms = words("true false null");
var hooks = {"#": metaHook};
var multiLineStrings;
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
var curPunc;
function tokenBase(stream, state) {
var ch = stream.next();
if (hooks[ch]) {
var result = hooks[ch](stream, state);
if (result !== false) return result;
}
if (ch == '"' || ch == "'") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
curPunc = ch;
return null;
}
if (/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
return "number";
}
if (ch == "/") {
if (stream.eat("*")) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
}
if (stream.eat("/")) {
stream.skipToEnd();
return "comment";
}
}
if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return "operator";
}
stream.eatWhile(/[\w\$_]/);
var cur = stream.current().toLowerCase();
if (keyword.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "keyword";
} else if (variable.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "variable";
} else if (variable_2.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "variable-2";
} else if (variable_3.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "variable-3";
} else if (builtin.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "builtin";
} else { //Data types are of from KEYWORD##
var i = cur.length - 1;
while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
--i;
if (i > 0) {
var cur2 = cur.substr(0, i + 1);
if (variable_3.propertyIsEnumerable(cur2)) {
if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
return "variable-3";
}
}
}
if (atoms.propertyIsEnumerable(cur)) return "atom";
return null;
}
function tokenString(quote) {
return function(stream, state) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {end = true; break;}
escaped = !escaped && next == "\\";
}
if (end || !(escaped || multiLineStrings))
state.tokenize = tokenBase;
return "string";
};
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}
function Context(indented, column, type, align, prev) {
this.indented = indented;
this.column = column;
this.type = type;
this.align = align;
this.prev = prev;
}
function pushContext(state, col, type) {
return state.context = new Context(state.indented, col, type, null, state.context);
}
function popContext(state) {
var t = state.context.type;
if (t == ")" || t == "]" || t == "}")
state.indented = state.context.indented;
return state.context = state.context.prev;
}
// Interface
return {
startState: function(basecolumn) {
return {
tokenize: null,
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
indented: 0,
startOfLine: true
};
},
token: function(stream, state) {
var ctx = state.context;
if (stream.sol()) {
if (ctx.align == null) ctx.align = false;
state.indented = stream.indentation();
state.startOfLine = true;
}
if (stream.eatSpace()) return null;
curPunc = null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style == "comment" || style == "meta") return style;
if (ctx.align == null) ctx.align = true;
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
else if (curPunc == "{") pushContext(state, stream.column(), "}");
else if (curPunc == "[") pushContext(state, stream.column(), "]");
else if (curPunc == "(") pushContext(state, stream.column(), ")");
else if (curPunc == "}") {
while (ctx.type == "statement") ctx = popContext(state);
if (ctx.type == "}") ctx = popContext(state);
while (ctx.type == "statement") ctx = popContext(state);
}
else if (curPunc == ctx.type) popContext(state);
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
pushContext(state, stream.column(), "statement");
state.startOfLine = false;
return style;
},
indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
var closing = firstChar == ctx.type;
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
else return ctx.indented + (closing ? 0 : indentUnit);
},
electricChars: "{}"
};
});
CodeMirror.defineMIME("text/x-ecl", "ecl");

View File

@@ -1,39 +0,0 @@
<!doctype html>
<html>
<head>
<title>CodeMirror: ECL mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="ecl.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border: 1px solid black;}</style>
</head>
<body>
<h1>CodeMirror: ECL mode</h1>
<form><textarea id="code" name="code">
/*
sample useless code to demonstrate ecl syntax highlighting
this is a multiline comment!
*/
// this is a singleline comment!
import ut;
r :=
record
string22 s1 := '123';
integer4 i1 := 123;
end;
#option('tmp', true);
d := dataset('tmp::qb', r, thor);
output(d);
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
</script>
<p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
<p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>
</body>
</html>

View File

@@ -1,464 +0,0 @@
// block; "begin", "case", "fun", "if", "receive", "try": closed by "end"
// block internal; "after", "catch", "of"
// guard; "when", closed by "->"
// "->" opens a clause, closed by ";" or "."
// "<<" opens a binary, closed by ">>"
// "," appears in arglists, lists, tuples and terminates lines of code
// "." resets indentation to 0
// obsolete; "cond", "let", "query"
CodeMirror.defineMIME("text/x-erlang", "erlang");
CodeMirror.defineMode("erlang", function(cmCfg) {
function rval(state,stream,type) {
// distinguish between "." as terminator and record field operator
if (type == "record") {
state.context = "record";
}else{
state.context = false;
}
// remember last significant bit on last line for indenting
if (type != "whitespace" && type != "comment") {
state.lastToken = stream.current();
}
// erlang -> CodeMirror tag
switch (type) {
case "atom": return "atom";
case "attribute": return "attribute";
case "builtin": return "builtin";
case "comment": return "comment";
case "fun": return "meta";
case "function": return "tag";
case "guard": return "property";
case "keyword": return "keyword";
case "macro": return "variable-2";
case "number": return "number";
case "operator": return "operator";
case "record": return "bracket";
case "string": return "string";
case "type": return "def";
case "variable": return "variable";
case "error": return "error";
case "separator": return null;
case "open_paren": return null;
case "close_paren": return null;
default: return null;
}
}
var typeWords = [
"-type", "-spec", "-export_type", "-opaque"];
var keywordWords = [
"after","begin","catch","case","cond","end","fun","if",
"let","of","query","receive","try","when"];
var separatorWords = [
"->",";",":",".",","];
var operatorWords = [
"and","andalso","band","bnot","bor","bsl","bsr","bxor",
"div","not","or","orelse","rem","xor"];
var symbolWords = [
"+","-","*","/",">",">=","<","=<","=:=","==","=/=","/=","||","<-"];
var openParenWords = [
"<<","(","[","{"];
var closeParenWords = [
"}","]",")",">>"];
var guardWords = [
"is_atom","is_binary","is_bitstring","is_boolean","is_float",
"is_function","is_integer","is_list","is_number","is_pid",
"is_port","is_record","is_reference","is_tuple",
"atom","binary","bitstring","boolean","function","integer","list",
"number","pid","port","record","reference","tuple"];
var bifWords = [
"abs","adler32","adler32_combine","alive","apply","atom_to_binary",
"atom_to_list","binary_to_atom","binary_to_existing_atom",
"binary_to_list","binary_to_term","bit_size","bitstring_to_list",
"byte_size","check_process_code","contact_binary","crc32",
"crc32_combine","date","decode_packet","delete_module",
"disconnect_node","element","erase","exit","float","float_to_list",
"garbage_collect","get","get_keys","group_leader","halt","hd",
"integer_to_list","internal_bif","iolist_size","iolist_to_binary",
"is_alive","is_atom","is_binary","is_bitstring","is_boolean",
"is_float","is_function","is_integer","is_list","is_number","is_pid",
"is_port","is_process_alive","is_record","is_reference","is_tuple",
"length","link","list_to_atom","list_to_binary","list_to_bitstring",
"list_to_existing_atom","list_to_float","list_to_integer",
"list_to_pid","list_to_tuple","load_module","make_ref","module_loaded",
"monitor_node","node","node_link","node_unlink","nodes","notalive",
"now","open_port","pid_to_list","port_close","port_command",
"port_connect","port_control","pre_loaded","process_flag",
"process_info","processes","purge_module","put","register",
"registered","round","self","setelement","size","spawn","spawn_link",
"spawn_monitor","spawn_opt","split_binary","statistics",
"term_to_binary","time","throw","tl","trunc","tuple_size",
"tuple_to_list","unlink","unregister","whereis"];
// ignored for indenting purposes
var ignoreWords = [
",", ":", "catch", "after", "of", "cond", "let", "query"];
var smallRE = /[a-z_]/;
var largeRE = /[A-Z_]/;
var digitRE = /[0-9]/;
var octitRE = /[0-7]/;
var anumRE = /[a-z_A-Z0-9]/;
var symbolRE = /[\+\-\*\/<>=\|:]/;
var openParenRE = /[<\(\[\{]/;
var closeParenRE = /[>\)\]\}]/;
var sepRE = /[\->\.,:;]/;
function isMember(element,list) {
return (-1 < list.indexOf(element));
}
function isPrev(stream,string) {
var start = stream.start;
var len = string.length;
if (len <= start) {
var word = stream.string.slice(start-len,start);
return word == string;
}else{
return false;
}
}
function tokenize(stream, state) {
if (stream.eatSpace()) {
return rval(state,stream,"whitespace");
}
// attributes and type specs
if ((peekToken(state).token == "" || peekToken(state).token == ".") &&
stream.peek() == '-') {
stream.next();
if (stream.eat(smallRE) && stream.eatWhile(anumRE)) {
if (isMember(stream.current(),typeWords)) {
return rval(state,stream,"type");
}else{
return rval(state,stream,"attribute");
}
}
stream.backUp(1);
}
var ch = stream.next();
// comment
if (ch == '%') {
stream.skipToEnd();
return rval(state,stream,"comment");
}
// macro
if (ch == '?') {
stream.eatWhile(anumRE);
return rval(state,stream,"macro");
}
// record
if ( ch == "#") {
stream.eatWhile(anumRE);
return rval(state,stream,"record");
}
// char
if ( ch == "$") {
if (stream.next() == "\\") {
if (!stream.eatWhile(octitRE)) {
stream.next();
}
}
return rval(state,stream,"string");
}
// quoted atom
if (ch == '\'') {
if (singleQuote(stream)) {
return rval(state,stream,"atom");
}else{
return rval(state,stream,"error");
}
}
// string
if (ch == '"') {
if (doubleQuote(stream)) {
return rval(state,stream,"string");
}else{
return rval(state,stream,"error");
}
}
// variable
if (largeRE.test(ch)) {
stream.eatWhile(anumRE);
return rval(state,stream,"variable");
}
// atom/keyword/BIF/function
if (smallRE.test(ch)) {
stream.eatWhile(anumRE);
if (stream.peek() == "/") {
stream.next();
if (stream.eatWhile(digitRE)) {
return rval(state,stream,"fun"); // f/0 style fun
}else{
stream.backUp(1);
return rval(state,stream,"atom");
}
}
var w = stream.current();
if (isMember(w,keywordWords)) {
pushToken(state,stream);
return rval(state,stream,"keyword");
}
if (stream.peek() == "(") {
// 'put' and 'erlang:put' are bifs, 'foo:put' is not
if (isMember(w,bifWords) &&
(!isPrev(stream,":") || isPrev(stream,"erlang:"))) {
return rval(state,stream,"builtin");
}else{
return rval(state,stream,"function");
}
}
if (isMember(w,guardWords)) {
return rval(state,stream,"guard");
}
if (isMember(w,operatorWords)) {
return rval(state,stream,"operator");
}
if (stream.peek() == ":") {
if (w == "erlang") {
return rval(state,stream,"builtin");
} else {
return rval(state,stream,"function");
}
}
return rval(state,stream,"atom");
}
// number
if (digitRE.test(ch)) {
stream.eatWhile(digitRE);
if (stream.eat('#')) {
stream.eatWhile(digitRE); // 16#10 style integer
} else {
if (stream.eat('.')) { // float
stream.eatWhile(digitRE);
}
if (stream.eat(/[eE]/)) {
stream.eat(/[-+]/); // float with exponent
stream.eatWhile(digitRE);
}
}
return rval(state,stream,"number"); // normal integer
}
// open parens
if (nongreedy(stream,openParenRE,openParenWords)) {
pushToken(state,stream);
return rval(state,stream,"open_paren");
}
// close parens
if (nongreedy(stream,closeParenRE,closeParenWords)) {
pushToken(state,stream);
return rval(state,stream,"close_paren");
}
// separators
if (greedy(stream,sepRE,separatorWords)) {
// distinguish between "." as terminator and record field operator
if (state.context == false) {
pushToken(state,stream);
}
return rval(state,stream,"separator");
}
// operators
if (greedy(stream,symbolRE,symbolWords)) {
return rval(state,stream,"operator");
}
return rval(state,stream,null);
}
function nongreedy(stream,re,words) {
if (stream.current().length == 1 && re.test(stream.current())) {
stream.backUp(1);
while (re.test(stream.peek())) {
stream.next();
if (isMember(stream.current(),words)) {
return true;
}
}
stream.backUp(stream.current().length-1);
}
return false;
}
function greedy(stream,re,words) {
if (stream.current().length == 1 && re.test(stream.current())) {
while (re.test(stream.peek())) {
stream.next();
}
while (0 < stream.current().length) {
if (isMember(stream.current(),words)) {
return true;
}else{
stream.backUp(1);
}
}
stream.next();
}
return false;
}
function doubleQuote(stream) {
return quote(stream, '"', '\\');
}
function singleQuote(stream) {
return quote(stream,'\'','\\');
}
function quote(stream,quoteChar,escapeChar) {
while (!stream.eol()) {
var ch = stream.next();
if (ch == quoteChar) {
return true;
}else if (ch == escapeChar) {
stream.next();
}
}
return false;
}
function Token(stream) {
this.token = stream ? stream.current() : "";
this.column = stream ? stream.column() : 0;
this.indent = stream ? stream.indentation() : 0;
}
function myIndent(state,textAfter) {
var indent = cmCfg.indentUnit;
var outdentWords = ["after","catch"];
var token = (peekToken(state)).token;
var wordAfter = takewhile(textAfter,/[^a-z]/);
if (isMember(token,openParenWords)) {
return (peekToken(state)).column+token.length;
}else if (token == "." || token == ""){
return 0;
}else if (token == "->") {
if (wordAfter == "end") {
return peekToken(state,2).column;
}else if (peekToken(state,2).token == "fun") {
return peekToken(state,2).column+indent;
}else{
return (peekToken(state)).indent+indent;
}
}else if (isMember(wordAfter,outdentWords)) {
return (peekToken(state)).indent;
}else{
return (peekToken(state)).column+indent;
}
}
function takewhile(str,re) {
var m = str.match(re);
return m ? str.slice(0,m.index) : str;
}
function popToken(state) {
return state.tokenStack.pop();
}
function peekToken(state,depth) {
var len = state.tokenStack.length;
var dep = (depth ? depth : 1);
if (len < dep) {
return new Token;
}else{
return state.tokenStack[len-dep];
}
}
function pushToken(state,stream) {
var token = stream.current();
var prev_token = peekToken(state).token;
if (isMember(token,ignoreWords)) {
return false;
}else if (drop_both(prev_token,token)) {
popToken(state);
return false;
}else if (drop_first(prev_token,token)) {
popToken(state);
return pushToken(state,stream);
}else{
state.tokenStack.push(new Token(stream));
return true;
}
}
function drop_first(open, close) {
switch (open+" "+close) {
case "when ->": return true;
case "-> end": return true;
case "-> .": return true;
case ". .": return true;
default: return false;
}
}
function drop_both(open, close) {
switch (open+" "+close) {
case "( )": return true;
case "[ ]": return true;
case "{ }": return true;
case "<< >>": return true;
case "begin end": return true;
case "case end": return true;
case "fun end": return true;
case "if end": return true;
case "receive end": return true;
case "try end": return true;
case "-> ;": return true;
default: return false;
}
}
return {
startState:
function() {
return {tokenStack: [],
context: false,
lastToken: null};
},
token:
function(stream, state) {
return tokenize(stream, state);
},
indent:
function(state, textAfter) {
return myIndent(state,textAfter);
},
lineComment: "%"
};
});

View File

@@ -1,64 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Erlang mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="erlang.js"></script>
<link rel="stylesheet" href="../../theme/erlang-dark.css">
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: Erlang mode</h1>
<form><textarea id="code" name="code">
%% -*- mode: erlang; erlang-indent-level: 2 -*-
%%% Created : 7 May 2012 by mats cronqvist <masse@klarna.com>
%% @doc
%% Demonstrates how to print a record.
%% @end
-module('ex').
-author('mats cronqvist').
-export([demo/0,
rec_info/1]).
-record(demo,{a="One",b="Two",c="Three",d="Four"}).
rec_info(demo) -> record_info(fields,demo).
demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
expand_recs(M,List) when is_list(List) ->
[expand_recs(M,L)||L<-List];
expand_recs(M,Tup) when is_tuple(Tup) ->
case tuple_size(Tup) of
L when L < 1 -> Tup;
L ->
try Fields = M:rec_info(element(1,Tup)),
L = length(Fields)+1,
lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
catch _:_ ->
list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
end
end;
expand_recs(_,Term) ->
Term.
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
extraKeys: {"Tab": "indentAuto"},
theme: "erlang-dark"
});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p>
</body>
</html>

View File

@@ -1,330 +0,0 @@
CodeMirror.defineMode("gas", function(_config, parserConfig) {
'use strict';
// If an architecture is specified, its initialization function may
// populate this array with custom parsing functions which will be
// tried in the event that the standard functions do not find a match.
var custom = [];
// The symbol used to start a line comment changes based on the target
// architecture.
// If no architecture is pased in "parserConfig" then only multiline
// comments will have syntax support.
var lineCommentStartSymbol = "";
// These directives are architecture independent.
// Machine specific directives should go in their respective
// architecture initialization function.
// Reference:
// http://sourceware.org/binutils/docs/as/Pseudo-Ops.html#Pseudo-Ops
var directives = {
".abort" : "builtin",
".align" : "builtin",
".altmacro" : "builtin",
".ascii" : "builtin",
".asciz" : "builtin",
".balign" : "builtin",
".balignw" : "builtin",
".balignl" : "builtin",
".bundle_align_mode" : "builtin",
".bundle_lock" : "builtin",
".bundle_unlock" : "builtin",
".byte" : "builtin",
".cfi_startproc" : "builtin",
".comm" : "builtin",
".data" : "builtin",
".def" : "builtin",
".desc" : "builtin",
".dim" : "builtin",
".double" : "builtin",
".eject" : "builtin",
".else" : "builtin",
".elseif" : "builtin",
".end" : "builtin",
".endef" : "builtin",
".endfunc" : "builtin",
".endif" : "builtin",
".equ" : "builtin",
".equiv" : "builtin",
".eqv" : "builtin",
".err" : "builtin",
".error" : "builtin",
".exitm" : "builtin",
".extern" : "builtin",
".fail" : "builtin",
".file" : "builtin",
".fill" : "builtin",
".float" : "builtin",
".func" : "builtin",
".global" : "builtin",
".gnu_attribute" : "builtin",
".hidden" : "builtin",
".hword" : "builtin",
".ident" : "builtin",
".if" : "builtin",
".incbin" : "builtin",
".include" : "builtin",
".int" : "builtin",
".internal" : "builtin",
".irp" : "builtin",
".irpc" : "builtin",
".lcomm" : "builtin",
".lflags" : "builtin",
".line" : "builtin",
".linkonce" : "builtin",
".list" : "builtin",
".ln" : "builtin",
".loc" : "builtin",
".loc_mark_labels" : "builtin",
".local" : "builtin",
".long" : "builtin",
".macro" : "builtin",
".mri" : "builtin",
".noaltmacro" : "builtin",
".nolist" : "builtin",
".octa" : "builtin",
".offset" : "builtin",
".org" : "builtin",
".p2align" : "builtin",
".popsection" : "builtin",
".previous" : "builtin",
".print" : "builtin",
".protected" : "builtin",
".psize" : "builtin",
".purgem" : "builtin",
".pushsection" : "builtin",
".quad" : "builtin",
".reloc" : "builtin",
".rept" : "builtin",
".sbttl" : "builtin",
".scl" : "builtin",
".section" : "builtin",
".set" : "builtin",
".short" : "builtin",
".single" : "builtin",
".size" : "builtin",
".skip" : "builtin",
".sleb128" : "builtin",
".space" : "builtin",
".stab" : "builtin",
".string" : "builtin",
".struct" : "builtin",
".subsection" : "builtin",
".symver" : "builtin",
".tag" : "builtin",
".text" : "builtin",
".title" : "builtin",
".type" : "builtin",
".uleb128" : "builtin",
".val" : "builtin",
".version" : "builtin",
".vtable_entry" : "builtin",
".vtable_inherit" : "builtin",
".warning" : "builtin",
".weak" : "builtin",
".weakref" : "builtin",
".word" : "builtin"
};
var registers = {};
function x86(_parserConfig) {
lineCommentStartSymbol = "#";
registers.ax = "variable";
registers.eax = "variable-2";
registers.rax = "variable-3";
registers.bx = "variable";
registers.ebx = "variable-2";
registers.rbx = "variable-3";
registers.cx = "variable";
registers.ecx = "variable-2";
registers.rcx = "variable-3";
registers.dx = "variable";
registers.edx = "variable-2";
registers.rdx = "variable-3";
registers.si = "variable";
registers.esi = "variable-2";
registers.rsi = "variable-3";
registers.di = "variable";
registers.edi = "variable-2";
registers.rdi = "variable-3";
registers.sp = "variable";
registers.esp = "variable-2";
registers.rsp = "variable-3";
registers.bp = "variable";
registers.ebp = "variable-2";
registers.rbp = "variable-3";
registers.ip = "variable";
registers.eip = "variable-2";
registers.rip = "variable-3";
registers.cs = "keyword";
registers.ds = "keyword";
registers.ss = "keyword";
registers.es = "keyword";
registers.fs = "keyword";
registers.gs = "keyword";
}
function armv6(_parserConfig) {
// Reference:
// http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf
// http://infocenter.arm.com/help/topic/com.arm.doc.ddi0301h/DDI0301H_arm1176jzfs_r0p7_trm.pdf
lineCommentStartSymbol = "@";
directives.syntax = "builtin";
registers.r0 = "variable";
registers.r1 = "variable";
registers.r2 = "variable";
registers.r3 = "variable";
registers.r4 = "variable";
registers.r5 = "variable";
registers.r6 = "variable";
registers.r7 = "variable";
registers.r8 = "variable";
registers.r9 = "variable";
registers.r10 = "variable";
registers.r11 = "variable";
registers.r12 = "variable";
registers.sp = "variable-2";
registers.lr = "variable-2";
registers.pc = "variable-2";
registers.r13 = registers.sp;
registers.r14 = registers.lr;
registers.r15 = registers.pc;
custom.push(function(ch, stream) {
if (ch === '#') {
stream.eatWhile(/\w/);
return "number";
}
});
}
var arch = parserConfig.architecture.toLowerCase();
if (arch === "x86") {
x86(parserConfig);
} else if (arch === "arm" || arch === "armv6") {
armv6(parserConfig);
}
function nextUntilUnescaped(stream, end) {
var escaped = false, next;
while ((next = stream.next()) != null) {
if (next === end && !escaped) {
return false;
}
escaped = !escaped && next === "\\";
}
return escaped;
}
function clikeComment(stream, state) {
var maybeEnd = false, ch;
while ((ch = stream.next()) != null) {
if (ch === "/" && maybeEnd) {
state.tokenize = null;
break;
}
maybeEnd = (ch === "*");
}
return "comment";
}
return {
startState: function() {
return {
tokenize: null
};
},
token: function(stream, state) {
if (state.tokenize) {
return state.tokenize(stream, state);
}
if (stream.eatSpace()) {
return null;
}
var style, cur, ch = stream.next();
if (ch === "/") {
if (stream.eat("*")) {
state.tokenize = clikeComment;
return clikeComment(stream, state);
}
}
if (ch === lineCommentStartSymbol) {
stream.skipToEnd();
return "comment";
}
if (ch === '"') {
nextUntilUnescaped(stream, '"');
return "string";
}
if (ch === '.') {
stream.eatWhile(/\w/);
cur = stream.current().toLowerCase();
style = directives[cur];
return style || null;
}
if (ch === '=') {
stream.eatWhile(/\w/);
return "tag";
}
if (ch === '{') {
return "braket";
}
if (ch === '}') {
return "braket";
}
if (/\d/.test(ch)) {
if (ch === "0" && stream.eat("x")) {
stream.eatWhile(/[0-9a-fA-F]/);
return "number";
}
stream.eatWhile(/\d/);
return "number";
}
if (/\w/.test(ch)) {
stream.eatWhile(/\w/);
if (stream.eat(":")) {
return 'tag';
}
cur = stream.current().toLowerCase();
style = registers[cur];
return style || null;
}
for (var i = 0; i < custom.length; i++) {
style = custom[i](ch, stream, state);
if (style) {
return style;
}
}
},
lineComment: lineCommentStartSymbol,
blockCommentStart: "/*",
blockCommentEnd: "*/"
};
});

View File

@@ -1,57 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Gas mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="gas.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border: 2px inset #dee;}</style>
</head>
<body>
<h1>CodeMirror: Gas mode</h1>
<form>
<textarea id="code" name="code">
.syntax unified
.global main
/*
* A
* multi-line
* comment.
*/
@ A single line comment.
main:
push {sp, lr}
ldr r0, =message
bl puts
mov r0, #0
pop {sp, pc}
message:
.asciz "Hello world!<br />"
</textarea>
</form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
mode: {name: "gas", architecture: "ARMv6"},
});
</script>
<p>Handles AT&amp;T assembler syntax (more specifically this handles
the GNU Assembler (gas) syntax.)
It takes a single optional configuration parameter:
<code>architecture</code>, which can be one of <code>"ARM"</code>,
<code>"ARMv6"</code> or <code>"x86"</code>.
Including the parameter adds syntax for the registers and special
directives for the supplied architecture.
<p><strong>MIME types defined:</strong> <code>text/x-gas</code></p>
</body>
</html>

View File

@@ -1,96 +0,0 @@
CodeMirror.defineMode("gfm", function(config) {
var codeDepth = 0;
function blankLine(state) {
state.code = false;
return null;
}
var gfmOverlay = {
startState: function() {
return {
code: false,
codeBlock: false,
ateSpace: false
};
},
copyState: function(s) {
return {
code: s.code,
codeBlock: s.codeBlock,
ateSpace: s.ateSpace
};
},
token: function(stream, state) {
// Hack to prevent formatting override inside code blocks (block and inline)
if (state.codeBlock) {
if (stream.match(/^```/)) {
state.codeBlock = false;
return null;
}
stream.skipToEnd();
return null;
}
if (stream.sol()) {
state.code = false;
}
if (stream.sol() && stream.match(/^```/)) {
stream.skipToEnd();
state.codeBlock = true;
return null;
}
// If this block is changed, it may need to be updated in Markdown mode
if (stream.peek() === '`') {
stream.next();
var before = stream.pos;
stream.eatWhile('`');
var difference = 1 + stream.pos - before;
if (!state.code) {
codeDepth = difference;
state.code = true;
} else {
if (difference === codeDepth) { // Must be exact
state.code = false;
}
}
return null;
} else if (state.code) {
stream.next();
return null;
}
// Check if space. If so, links can be formatted later on
if (stream.eatSpace()) {
state.ateSpace = true;
return null;
}
if (stream.sol() || state.ateSpace) {
state.ateSpace = false;
if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
// User/Project@SHA
// User@SHA
// SHA
return "link";
} else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
// User/Project#Num
// User#Num
// #Num
return "link";
}
}
if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i)) {
// URLs
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
return "link";
}
stream.next();
return null;
},
blankLine: blankLine
};
CodeMirror.defineMIME("gfmBase", {
name: "markdown",
underscoresBreakWords: false,
taskLists: true,
fencedCodeBlocks: true
});
return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay);
}, "markdown");

View File

@@ -1,74 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: GFM mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/mode/overlay.js"></script>
<script src="../xml/xml.js"></script>
<script src="../markdown/markdown.js"></script>
<script src="gfm.js"></script>
<!-- Code block highlighting modes -->
<script src="../javascript/javascript.js"></script>
<script src="../css/css.js"></script>
<script src="../htmlmixed/htmlmixed.js"></script>
<script src="../clike/clike.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: GFM mode</h1>
<form><textarea id="code" name="code">
GitHub Flavored Markdown
========================
Everything from markdown plus GFM features:
## URL autolinking
Underscores_are_allowed_between_words.
## Fenced code blocks (and syntax highlighting)
```javascript
for (var i = 0; i &lt; items.length; i++) {
console.log(items[i], i); // log them
}
```
## Task Lists
- [ ] Incomplete task list item
- [x] **Completed** task list item
## A bit of GitHub spice
* SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
* User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
* User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
* \#Num: #1
* User/#Num: mojombo#1
* User/Project#Num: mojombo/god#1
See http://github.github.com/github-flavored-markdown/.
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: 'gfm',
lineNumbers: true,
theme: "default"
});
</script>
<p>Optionally depends on other modes for properly highlighted code blocks.</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gfm_*">normal</a>, <a href="../../test/index.html#verbose,gfm_*">verbose</a>.</p>
</body>
</html>

View File

@@ -1,112 +0,0 @@
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
MT("emInWordAsterisk",
"foo[em *bar*]hello");
MT("emInWordUnderscore",
"foo_bar_hello");
MT("emStrongUnderscore",
"[strong __][em&strong _foo__][em _] bar");
MT("fencedCodeBlocks",
"[comment ```]",
"[comment foo]",
"",
"[comment ```]",
"bar");
MT("fencedCodeBlockModeSwitching",
"[comment ```javascript]",
"[variable foo]",
"",
"[comment ```]",
"bar");
MT("taskListAsterisk",
"[variable-2 * []] foo]", // Invalid; must have space or x between []
"[variable-2 * [ ]]bar]", // Invalid; must have space after ]
"[variable-2 * [x]]hello]", // Invalid; must have space after ]
"[variable-2 * ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
" [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested
MT("taskListPlus",
"[variable-2 + []] foo]", // Invalid; must have space or x between []
"[variable-2 + [ ]]bar]", // Invalid; must have space after ]
"[variable-2 + [x]]hello]", // Invalid; must have space after ]
"[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
" [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested
MT("taskListDash",
"[variable-2 - []] foo]", // Invalid; must have space or x between []
"[variable-2 - [ ]]bar]", // Invalid; must have space after ]
"[variable-2 - [x]]hello]", // Invalid; must have space after ]
"[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
" [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested
MT("taskListNumber",
"[variable-2 1. []] foo]", // Invalid; must have space or x between []
"[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
"[variable-2 3. [x]]hello]", // Invalid; must have space after ]
"[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
" [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested
MT("SHA",
"foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
MT("shortSHA",
"foo [link be6a8cc] bar");
MT("tooShortSHA",
"foo be6a8c bar");
MT("longSHA",
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");
MT("badSHA",
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");
MT("userSHA",
"foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
MT("userProjectSHA",
"foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
MT("num",
"foo [link #1] bar");
MT("badNum",
"foo #1bar hello");
MT("userNum",
"foo [link bar#1] hello");
MT("userProjectNum",
"foo [link bar/hello#1] world");
MT("vanillaLink",
"foo [link http://www.example.com/] bar");
MT("vanillaLinkPunctuation",
"foo [link http://www.example.com/]. bar");
MT("vanillaLinkExtension",
"foo [link http://www.example.com/index.html] bar");
MT("notALink",
"[comment ```css]",
"[tag foo] {[property color][operator :][keyword black];}",
"[comment ```][link http://www.example.com/]");
MT("notALink",
"[comment ``foo `bar` http://www.example.com/``] hello");
MT("notALink",
"[comment `foo]",
"[link http://www.example.com/]",
"[comment `foo]",
"",
"[link http://www.example.com/]");
})();

View File

@@ -1,168 +0,0 @@
CodeMirror.defineMode("go", function(config) {
var indentUnit = config.indentUnit;
var keywords = {
"break":true, "case":true, "chan":true, "const":true, "continue":true,
"default":true, "defer":true, "else":true, "fallthrough":true, "for":true,
"func":true, "go":true, "goto":true, "if":true, "import":true,
"interface":true, "map":true, "package":true, "range":true, "return":true,
"select":true, "struct":true, "switch":true, "type":true, "var":true,
"bool":true, "byte":true, "complex64":true, "complex128":true,
"float32":true, "float64":true, "int8":true, "int16":true, "int32":true,
"int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true,
"uint64":true, "int":true, "uint":true, "uintptr":true
};
var atoms = {
"true":true, "false":true, "iota":true, "nil":true, "append":true,
"cap":true, "close":true, "complex":true, "copy":true, "imag":true,
"len":true, "make":true, "new":true, "panic":true, "print":true,
"println":true, "real":true, "recover":true
};
var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
var curPunc;
function tokenBase(stream, state) {
var ch = stream.next();
if (ch == '"' || ch == "'" || ch == "`") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
if (/[\d\.]/.test(ch)) {
if (ch == ".") {
stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
} else if (ch == "0") {
stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
} else {
stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
}
return "number";
}
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
curPunc = ch;
return null;
}
if (ch == "/") {
if (stream.eat("*")) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
}
if (stream.eat("/")) {
stream.skipToEnd();
return "comment";
}
}
if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return "operator";
}
stream.eatWhile(/[\w\$_]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (cur == "case" || cur == "default") curPunc = "case";
return "keyword";
}
if (atoms.propertyIsEnumerable(cur)) return "atom";
return "variable";
}
function tokenString(quote) {
return function(stream, state) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {end = true; break;}
escaped = !escaped && next == "\\";
}
if (end || !(escaped || quote == "`"))
state.tokenize = tokenBase;
return "string";
};
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}
function Context(indented, column, type, align, prev) {
this.indented = indented;
this.column = column;
this.type = type;
this.align = align;
this.prev = prev;
}
function pushContext(state, col, type) {
return state.context = new Context(state.indented, col, type, null, state.context);
}
function popContext(state) {
var t = state.context.type;
if (t == ")" || t == "]" || t == "}")
state.indented = state.context.indented;
return state.context = state.context.prev;
}
// Interface
return {
startState: function(basecolumn) {
return {
tokenize: null,
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
indented: 0,
startOfLine: true
};
},
token: function(stream, state) {
var ctx = state.context;
if (stream.sol()) {
if (ctx.align == null) ctx.align = false;
state.indented = stream.indentation();
state.startOfLine = true;
if (ctx.type == "case") ctx.type = "}";
}
if (stream.eatSpace()) return null;
curPunc = null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style == "comment") return style;
if (ctx.align == null) ctx.align = true;
if (curPunc == "{") pushContext(state, stream.column(), "}");
else if (curPunc == "[") pushContext(state, stream.column(), "]");
else if (curPunc == "(") pushContext(state, stream.column(), ")");
else if (curPunc == "case") ctx.type = "case";
else if (curPunc == "}" && ctx.type == "}") ctx = popContext(state);
else if (curPunc == ctx.type) popContext(state);
state.startOfLine = false;
return style;
},
indent: function(state, textAfter) {
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) {
state.context.type = "}";
return ctx.indented;
}
var closing = firstChar == ctx.type;
if (ctx.align) return ctx.column + (closing ? 0 : 1);
else return ctx.indented + (closing ? 0 : indentUnit);
},
electricChars: "{}:",
blockCommentStart: "/*",
blockCommentEnd: "*/",
lineComment: "//"
};
});
CodeMirror.defineMIME("text/x-go", "go");

View File

@@ -1,74 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Go mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<link rel="stylesheet" href="../../theme/elegant.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="go.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border:1px solid #999; background:#ffc}</style>
</head>
<body>
<h1>CodeMirror: Go mode</h1>
<form><textarea id="code" name="code">
// Prime Sieve in Go.
// Taken from the Go specification.
// Copyright © The Go Authors.
package main
import "fmt"
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func generate(ch chan&lt;- int) {
for i := 2; ; i++ {
ch &lt;- i // Send 'i' to channel 'ch'
}
}
// Copy the values from channel 'src' to channel 'dst',
// removing those divisible by 'prime'.
func filter(src &lt;-chan int, dst chan&lt;- int, prime int) {
for i := range src { // Loop over values received from 'src'.
if i%prime != 0 {
dst &lt;- i // Send 'i' to channel 'dst'.
}
}
}
// The prime sieve: Daisy-chain filter processes together.
func sieve() {
ch := make(chan int) // Create a new channel.
go generate(ch) // Start generate() as a subprocess.
for {
prime := &lt;-ch
fmt.Print(prime, "\n")
ch1 := make(chan int)
go filter(ch, ch1, prime)
ch = ch1
}
}
func main() {
sieve()
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
theme: "elegant",
matchBrackets: true,
indentUnit: 8,
tabSize: 8,
indentWithTabs: true,
mode: "text/x-go"
});
</script>
<p><strong>MIME type:</strong> <code>text/x-go</code></p>
</body>
</html>

View File

@@ -1,210 +0,0 @@
CodeMirror.defineMode("groovy", function(config) {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var keywords = words(
"abstract as assert boolean break byte case catch char class const continue def default " +
"do double else enum extends final finally float for goto if implements import in " +
"instanceof int interface long native new package private protected public return " +
"short static strictfp super switch synchronized threadsafe throw throws transient " +
"try void volatile while");
var blockKeywords = words("catch class do else finally for if switch try while enum interface def");
var atoms = words("null true false this");
var curPunc;
function tokenBase(stream, state) {
var ch = stream.next();
if (ch == '"' || ch == "'") {
return startString(ch, stream, state);
}
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
curPunc = ch;
return null;
}
if (/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
if (stream.eat(/eE/)) { stream.eat(/\+\-/); stream.eatWhile(/\d/); }
return "number";
}
if (ch == "/") {
if (stream.eat("*")) {
state.tokenize.push(tokenComment);
return tokenComment(stream, state);
}
if (stream.eat("/")) {
stream.skipToEnd();
return "comment";
}
if (expectExpression(state.lastToken)) {
return startString(ch, stream, state);
}
}
if (ch == "-" && stream.eat(">")) {
curPunc = "->";
return null;
}
if (/[+\-*&%=<>!?|\/~]/.test(ch)) {
stream.eatWhile(/[+\-*&%=<>|~]/);
return "operator";
}
stream.eatWhile(/[\w\$_]/);
if (ch == "@") { stream.eatWhile(/[\w\$_\.]/); return "meta"; }
if (state.lastToken == ".") return "property";
if (stream.eat(":")) { curPunc = "proplabel"; return "property"; }
var cur = stream.current();
if (atoms.propertyIsEnumerable(cur)) { return "atom"; }
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
return "keyword";
}
return "variable";
}
tokenBase.isBase = true;
function startString(quote, stream, state) {
var tripleQuoted = false;
if (quote != "/" && stream.eat(quote)) {
if (stream.eat(quote)) tripleQuoted = true;
else return "string";
}
function t(stream, state) {
var escaped = false, next, end = !tripleQuoted;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {
if (!tripleQuoted) { break; }
if (stream.match(quote + quote)) { end = true; break; }
}
if (quote == '"' && next == "$" && !escaped && stream.eat("{")) {
state.tokenize.push(tokenBaseUntilBrace());
return "string";
}
escaped = !escaped && next == "\\";
}
if (end) state.tokenize.pop();
return "string";
}
state.tokenize.push(t);
return t(stream, state);
}
function tokenBaseUntilBrace() {
var depth = 1;
function t(stream, state) {
if (stream.peek() == "}") {
depth--;
if (depth == 0) {
state.tokenize.pop();
return state.tokenize[state.tokenize.length-1](stream, state);
}
} else if (stream.peek() == "{") {
depth++;
}
return tokenBase(stream, state);
}
t.isBase = true;
return t;
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize.pop();
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}
function expectExpression(last) {
return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) ||
last == "newstatement" || last == "keyword" || last == "proplabel";
}
function Context(indented, column, type, align, prev) {
this.indented = indented;
this.column = column;
this.type = type;
this.align = align;
this.prev = prev;
}
function pushContext(state, col, type) {
return state.context = new Context(state.indented, col, type, null, state.context);
}
function popContext(state) {
var t = state.context.type;
if (t == ")" || t == "]" || t == "}")
state.indented = state.context.indented;
return state.context = state.context.prev;
}
// Interface
return {
startState: function(basecolumn) {
return {
tokenize: [tokenBase],
context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
indented: 0,
startOfLine: true,
lastToken: null
};
},
token: function(stream, state) {
var ctx = state.context;
if (stream.sol()) {
if (ctx.align == null) ctx.align = false;
state.indented = stream.indentation();
state.startOfLine = true;
// Automatic semicolon insertion
if (ctx.type == "statement" && !expectExpression(state.lastToken)) {
popContext(state); ctx = state.context;
}
}
if (stream.eatSpace()) return null;
curPunc = null;
var style = state.tokenize[state.tokenize.length-1](stream, state);
if (style == "comment") return style;
if (ctx.align == null) ctx.align = true;
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
// Handle indentation for {x -> \n ... }
else if (curPunc == "->" && ctx.type == "statement" && ctx.prev.type == "}") {
popContext(state);
state.context.align = false;
}
else if (curPunc == "{") pushContext(state, stream.column(), "}");
else if (curPunc == "[") pushContext(state, stream.column(), "]");
else if (curPunc == "(") pushContext(state, stream.column(), ")");
else if (curPunc == "}") {
while (ctx.type == "statement") ctx = popContext(state);
if (ctx.type == "}") ctx = popContext(state);
while (ctx.type == "statement") ctx = popContext(state);
}
else if (curPunc == ctx.type) popContext(state);
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
pushContext(state, stream.column(), "statement");
state.startOfLine = false;
state.lastToken = curPunc || style;
return style;
},
indent: function(state, textAfter) {
if (!state.tokenize[state.tokenize.length-1].isBase) return 0;
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context;
if (ctx.type == "statement" && !expectExpression(state.lastToken)) ctx = ctx.prev;
var closing = firstChar == ctx.type;
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit);
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
else return ctx.indented + (closing ? 0 : config.indentUnit);
},
electricChars: "{}"
};
});
CodeMirror.defineMIME("text/x-groovy", "groovy");

View File

@@ -1,73 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Groovy mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="groovy.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border-top: 1px solid #500; border-bottom: 1px solid #500;}</style>
</head>
<body>
<h1>CodeMirror: Groovy mode</h1>
<form><textarea id="code" name="code">
//Pattern for groovy script
def p = ~/.*\.groovy/
new File( 'd:\\scripts' ).eachFileMatch(p) {f ->
// imports list
def imports = []
f.eachLine {
// condition to detect an import instruction
ln -> if ( ln =~ '^import .*' ) {
imports << "${ln - 'import '}"
}
}
// print thmen
if ( ! imports.empty ) {
println f
imports.each{ println " $it" }
}
}
/* Coin changer demo code from http://groovy.codehaus.org */
enum UsCoin {
quarter(25), dime(10), nickel(5), penny(1)
UsCoin(v) { value = v }
final value
}
enum OzzieCoin {
fifty(50), twenty(20), ten(10), five(5)
OzzieCoin(v) { value = v }
final value
}
def plural(word, count) {
if (count == 1) return word
word[-1] == 'y' ? word[0..-2] + "ies" : word + "s"
}
def change(currency, amount) {
currency.values().inject([]){ list, coin ->
int count = amount / coin.value
amount = amount % coin.value
list += "$count ${plural(coin.toString(), count)}"
}
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-groovy"
});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-groovy</code></p>
</body>
</html>

View File

@@ -1,153 +0,0 @@
(function() {
"use strict";
// full haml mode. This handled embeded ruby and html fragments too
CodeMirror.defineMode("haml", function(config) {
var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"});
var rubyMode = CodeMirror.getMode(config, "ruby");
function rubyInQuote(endQuote) {
return function(stream, state) {
var ch = stream.peek();
if (ch == endQuote && state.rubyState.tokenize.length == 1) {
// step out of ruby context as it seems to complete processing all the braces
stream.next();
state.tokenize = html;
return "closeAttributeTag";
} else {
return ruby(stream, state);
}
};
}
function ruby(stream, state) {
if (stream.match("-#")) {
stream.skipToEnd();
return "comment";
}
return rubyMode.token(stream, state.rubyState);
}
function html(stream, state) {
var ch = stream.peek();
// handle haml declarations. All declarations that cant be handled here
// will be passed to html mode
if (state.previousToken.style == "comment" ) {
if (state.indented > state.previousToken.indented) {
stream.skipToEnd();
return "commentLine";
}
}
if (state.startOfLine) {
if (ch == "!" && stream.match("!!")) {
stream.skipToEnd();
return "tag";
} else if (stream.match(/^%[\w:#\.]+=/)) {
state.tokenize = ruby;
return "hamlTag";
} else if (stream.match(/^%[\w:]+/)) {
return "hamlTag";
} else if (ch == "/" ) {
stream.skipToEnd();
return "comment";
}
}
if (state.startOfLine || state.previousToken.style == "hamlTag") {
if ( ch == "#" || ch == ".") {
stream.match(/[\w-#\.]*/);
return "hamlAttribute";
}
}
// donot handle --> as valid ruby, make it HTML close comment instead
if (state.startOfLine && !stream.match("-->", false) && (ch == "=" || ch == "-" )) {
state.tokenize = ruby;
return null;
}
if (state.previousToken.style == "hamlTag" ||
state.previousToken.style == "closeAttributeTag" ||
state.previousToken.style == "hamlAttribute") {
if (ch == "(") {
state.tokenize = rubyInQuote(")");
return null;
} else if (ch == "{") {
state.tokenize = rubyInQuote("}");
return null;
}
}
return htmlMode.token(stream, state.htmlState);
}
return {
// default to html mode
startState: function() {
var htmlState = htmlMode.startState();
var rubyState = rubyMode.startState();
return {
htmlState: htmlState,
rubyState: rubyState,
indented: 0,
previousToken: { style: null, indented: 0},
tokenize: html
};
},
copyState: function(state) {
return {
htmlState : CodeMirror.copyState(htmlMode, state.htmlState),
rubyState: CodeMirror.copyState(rubyMode, state.rubyState),
indented: state.indented,
previousToken: state.previousToken,
tokenize: state.tokenize
};
},
token: function(stream, state) {
if (stream.sol()) {
state.indented = stream.indentation();
state.startOfLine = true;
}
if (stream.eatSpace()) return null;
var style = state.tokenize(stream, state);
state.startOfLine = false;
// dont record comment line as we only want to measure comment line with
// the opening comment block
if (style && style != "commentLine") {
state.previousToken = { style: style, indented: state.indented };
}
// if current state is ruby and the previous token is not `,` reset the
// tokenize to html
if (stream.eol() && state.tokenize == ruby) {
stream.backUp(1);
var ch = stream.peek();
stream.next();
if (ch && ch != ",") {
state.tokenize = html;
}
}
// reprocess some of the specific style tag when finish setting previousToken
if (style == "hamlTag") {
style = "tag";
} else if (style == "commentLine") {
style = "comment";
} else if (style == "hamlAttribute") {
style = "attribute";
} else if (style == "closeAttributeTag") {
style = null;
}
return style;
},
indent: function(state) {
return state.indented;
}
};
}, "htmlmixed", "ruby");
CodeMirror.defineMIME("text/x-haml", "haml");
})();

View File

@@ -1,67 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: HAML mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../xml/xml.js"></script>
<script src="../htmlmixed/htmlmixed.js"></script>
<script src="../javascript/javascript.js"></script>
<script src="../ruby/ruby.js"></script>
<script src="haml.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: HAML mode</h1>
<form><textarea id="code" name="code">
!!!
#content
.left.column(title="title"){:href => "/hello", :test => "#{hello}_#{world}"}
<!-- This is a comment -->
%h2 Welcome to our site!
%p= puts "HAML MODE"
.right.column
= render :partial => "sidebar"
.container
.row
.span8
%h1.title= @page_title
%p.title= @page_title
%p
/
The same as HTML comment
Hello multiline comment
-# haml comment
This wont be displayed
nor will this
Date/Time:
- now = DateTime.now
%strong= now
- if now > DateTime.parse("December 31, 2006")
= "Happy new " + "year!"
%title
= @title
\= @title
<h1>Title</h1>
<h1 title="HELLO">
Title
</h1>
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
mode: "text/x-haml"
});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-haml</code>.</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#haml_*">normal</a>, <a href="../../test/index.html#verbose,haml_*">verbose</a>.</p>
</body>
</html>

View File

@@ -1,94 +0,0 @@
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "haml");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
// Requires at least one media query
MT("elementName",
"[tag %h1] Hey There");
MT("oneElementPerLine",
"[tag %h1] Hey There %h2");
MT("idSelector",
"[tag %h1][attribute #test] Hey There");
MT("classSelector",
"[tag %h1][attribute .hello] Hey There");
MT("docType",
"[tag !!! XML]");
MT("comment",
"[comment / Hello WORLD]");
MT("notComment",
"[tag %h1] This is not a / comment ");
MT("attributes",
"[tag %a]([variable title][operator =][string \"test\"]){[atom :title] [operator =>] [string \"test\"]}");
MT("htmlCode",
"[tag <h1>]Title[tag </h1>]");
MT("rubyBlock",
"[operator =][variable-2 @item]");
MT("selectorRubyBlock",
"[tag %a.selector=] [variable-2 @item]");
MT("nestedRubyBlock",
"[tag %a]",
" [operator =][variable puts] [string \"test\"]");
MT("multilinePlaintext",
"[tag %p]",
" Hello,",
" World");
MT("multilineRuby",
"[tag %p]",
" [comment -# this is a comment]",
" [comment and this is a comment too]",
" Date/Time",
" [operator -] [variable now] [operator =] [tag DateTime][operator .][variable now]",
" [tag %strong=] [variable now]",
" [operator -] [keyword if] [variable now] [operator >] [tag DateTime][operator .][variable parse]([string \"December 31, 2006\"])",
" [operator =][string \"Happy\"]",
" [operator =][string \"Belated\"]",
" [operator =][string \"Birthday\"]");
MT("multilineComment",
"[comment /]",
" [comment Multiline]",
" [comment Comment]");
MT("hamlComment",
"[comment -# this is a comment]");
MT("multilineHamlComment",
"[comment -# this is a comment]",
" [comment and this is a comment too]");
MT("multilineHTMLComment",
"[comment <!--]",
" [comment what a comment]",
" [comment -->]");
MT("hamlAfterRubyTag",
"[attribute .block]",
" [tag %strong=] [variable now]",
" [attribute .test]",
" [operator =][variable now]",
" [attribute .right]");
MT("stretchedRuby",
"[operator =] [variable puts] [string \"Hello\"],",
" [string \"World\"]");
MT("interpolationInHashAttribute",
//"[tag %div]{[atom :id] [operator =>] [string \"#{][variable test][string }_#{][variable ting][string }\"]} test");
"[tag %div]{[atom :id] [operator =>] [string \"#{][variable test][string }_#{][variable ting][string }\"]} test");
MT("interpolationInHTMLAttribute",
"[tag %div]([variable title][operator =][string \"#{][variable test][string }_#{][variable ting]()[string }\"]) Test");
})();

Some files were not shown because too many files have changed in this diff Show More