Compare commits

...
Sign in to create a new pull request.

730 commits

Author SHA1 Message Date
Joey Payne
ca8da0a3f3 Merge remote-tracking branch 'upstream/master' 2015-06-04 14:23:14 -06:00
Lennart Kats
f10da4cdb0 Merge pull request #2523 from ajaxorg/fix/various
Fix several small issues
2015-06-01 17:59:08 +02:00
Lennart Kats
d953740339 Merge pull request #2507 from ajaxorg/c9
Sync with cloud9
2015-06-01 17:39:25 +02:00
nightwing
6cec0b28b2 improve tmlanguage importer 2015-06-01 13:50:32 +04:00
nightwing
3f31ca57ed fix typo 2015-06-01 01:06:39 +04:00
Joey Payne
fb7144b622 Merge remote-tracking branch 'upstream/master' 2015-05-31 11:49:42 -06:00
nightwing
2249d06337 fix #2484 Hard-coded characterWidth in static_highlight.js
and remove dependence on mockdom
2015-05-31 17:42:00 +04:00
nightwing
1514d5f374 fix #2483 Exception on ctrl-alt-shift-click when $enableJumpToDef is true 2015-05-31 17:42:00 +04:00
nightwing
446e3e1bf9 fix #2522 Popup position is off when gutter isn't shown 2015-05-31 17:42:00 +04:00
Harutyun Amirjanyan
652dd7009c Merge pull request #2516 from ajaxorg/fix/highlighter
fix highlighting of tables in Gherkin  mode
2015-05-31 16:45:58 +04:00
Harutyun Amirjanyan
3d23e1e98f Merge pull request #2518 from ajaxorg/autocompleter
fix autocomplete blur handler
2015-05-31 16:45:36 +04:00
Harutyun Amirjanyan
cafc7e7ce1 Merge pull request #2521 from puffnfresh/patch-1
Fix invalid syntax in autoresize.html
2015-05-31 16:45:13 +04:00
Brian McKenna
abdc4c7510 Fix invalid syntax in autoresize.html
The options literal had a duplicate key.
2015-05-29 09:55:02 -06:00
nightwing
8c1d0ab7cf fix autocomplete blur handler 2015-05-28 13:56:33 +04:00
nightwing
9f57989043 fix highlighting of tables in Gherkin mode 2015-05-28 13:40:56 +04:00
nightwing
2a089863e2 fix highlighting of line-height:1.5 in less mode 2015-05-22 22:14:29 +04:00
nightwing
386c508042 convert paste into command 2015-05-22 22:14:15 +04:00
nightwing
dc7643db8d better invisible tabs (fixes #2109) 2015-05-22 21:57:13 +04:00
nightwing
5705a7c2c1 fix toggle comments in handlebars mode 2015-05-22 02:34:43 +04:00
nightwing
2e2d9bcdc9 add more php extensions 2015-05-22 02:34:43 +04:00
nightwing
a799a4086f fix quote pairing for "\n" 2015-05-22 02:34:43 +04:00
nightwing
af5c7a9c3b improve require support in worker 2015-05-22 02:34:30 +04:00
nightwing
fe96eef206 fix require for paths ending with .js in the worker 2015-05-21 23:01:27 +04:00
Lennart Kats
0a3b002e28 Merge pull request #1819 from ajaxorg/v-1.2
Refactor document delta handling for v1.2
2015-05-21 11:15:29 +02:00
nightwing
60439d927f update changelog 2015-05-21 13:01:17 +04:00
Lennart Kats
95bb17d04b Merge pull request #2496 from ajaxorg/fix/renderer
fix renderer issues with autosize
2015-05-21 10:57:04 +02:00
Lennart Kats
2c1b565591 Merge pull request #2500 from ajaxorg/fix/tokenizer
fix highlighting stopping randomly in the middle of the file
2015-05-21 10:53:05 +02:00
Harutyun Amirjanyan
53ea1a8665 Merge pull request #2502 from Pike/patch-1
Add array-of-tables to keygroup markup for toml files.
2015-05-20 22:30:19 +04:00
Axel Hecht
9534e4ea92 Add array-of-tables to keygroup markup
The markup for array-of-tables at https://github.com/toml-lang/toml#array-of-tables is
[[ foo ]]

Right now, the last ] isn't part of the markup. Figured making this an explicit token is the most apparent way to fix this.
2015-05-20 14:53:02 +02:00
nightwing
fa86327b3d fix highlighting stopping randomly in the middle of the file 2015-05-19 17:43:10 +04:00
Joey Payne
a68e8bea01 Merging latest commits.
Merge remote-tracking branch 'upstream/master'
2015-05-16 16:02:51 -06:00
nightwing
88d8cf3447 fix renderer test 2015-05-15 02:48:12 +04:00
nightwing
9e9aa8f328 use scroller as mousetarget to not miss mouse events on scrollmargin 2015-05-15 02:44:24 +04:00
nightwing
93c39ca5b0 handle hscrollbar change during autoresize 2015-05-15 02:43:41 +04:00
nightwing
0db985a3d7 fix #2495 editor freezes when setting scrollmargin and maxLines together 2015-05-15 01:53:19 +04:00
Ruben Daniels
ad5802be06 Merge pull request #2488 from ajaxorg/rounded-corners
Add rounded corners for selections
2015-05-10 19:07:21 -07:00
nightwing
0abd9ec30e rounded corners for selections 2015-05-10 14:01:28 +04:00
Harutyun Amirjanyan
6d205a8f7e Merge pull request #2470 from ajaxorg/fix/leak
Fix memory leak
2015-05-07 01:28:22 +04:00
Harutyun Amirjanyan
d2dc26f5a5 Merge pull request #2479 from bcjordan/patch-4
Update comment, add missing semicolon [ci skip]
2015-05-07 01:27:42 +04:00
Brian Jordan
ef4537a099 Update edit_session.js
Fix extra `the`
2015-05-05 09:07:46 -07:00
Harutyun Amirjanyan
46f76b4b06 Merge pull request #2473 from Leushenko/master
Add indentation for Scheme
2015-05-05 16:31:02 +04:00
Harutyun Amirjanyan
71d1ca9d20 Merge pull request #2476 from bcjordan/patch-2
Remove unused variable `EditSession`
2015-05-05 16:26:41 +04:00
Harutyun Amirjanyan
263a45db02 Merge pull request #2477 from bcjordan/patch-3
Remove unused parameter `mutateData` & add ;s
2015-05-05 16:26:28 +04:00
Joey Payne
9323a2616b Added support for nim programming language. 2015-05-04 22:54:09 -06:00
Brian Jordan
ad22b71cfe Update comment, add missing semicolon [ci skip] 2015-05-01 10:56:08 -07:00
Brian Jordan
cd8099b0ad Remove unused parameter mutateData & add ;s 2015-04-30 17:38:19 -07:00
Brian Jordan
a61d304cbb Remove unused variable EditSession 2015-04-30 17:14:16 -07:00
Alex Gilding
e72f1d8337 Add indentation for Scheme
Just copied over the Clojure indentation rules to Scheme and changed
the keywords to suit the language, so that Scheme programs can be
automatically indented too
2015-04-28 20:24:13 +01:00
nightwing
d080fe51d4 fix #2468 error in strict mode 2015-04-28 19:01:24 +04:00
Harutyun Amirjanyan
32cb8c6b0e Merge pull request #2472 from ph1ll/master
Expose ClipboardEvent in editor paste event
2015-04-28 00:51:58 +04:00
Phill Campbell
3ce8d76c89 Expose ClipboardEvent in editor paste event 2015-04-27 18:49:12 +01:00
nightwing
a842dcdee3 do not retain ref to the first editor (fixes #2469) 2015-04-26 14:44:47 +04:00
Ruben Daniels
0dcb1281cd Merge pull request #2459 from ajaxorg/c9
Sync with c9
2015-04-25 12:30:37 -07:00
Harutyun Amirjanyan
65ad04082f Merge pull request #2460 from sevin7676/master
SQL Server typos and keyword completion modifier
2015-04-23 18:11:41 +04:00
Lennart Kats
b6f7e5d6a1 Merge pull request #2461 from ajaxorg/highlighter
Fix highlighter issues
2015-04-23 07:38:28 +02:00
sevin7676
5a3bf2570f no keyword if in brackets 2015-04-22 06:06:52 -04:00
sevin7676
2d7ebc34b6 no keyword if in brackets 2015-04-22 06:05:54 -04:00
sevin7676
87044e8816 forgot keyword completions 2015-04-22 05:38:01 -04:00
sevin7676
82453d884b better completions, no unneeded string rule 2015-04-22 05:28:31 -04:00
nightwing
636ace5178 fix typo 2015-04-22 13:20:39 +04:00
Harutyun Amirjanyan
3673aabe2a Merge pull request #2465 from bcjordan/patch-1
Remove unused variable `text`
2015-04-22 11:25:22 +04:00
Brian Jordan
694d7431b7 Remove unused variable text 2015-04-21 14:58:29 -07:00
nightwing
89b9a8ac72 address review comments 2015-04-20 18:25:32 +04:00
sevin7676
67c7da75b6 fix escape character
was using wrong escape char for string, sqlserver uses double single
quote to escape a single quote
2015-04-20 08:52:03 -04:00
sevin7676
662cd11975 no cache as its storing reference in filtered list 2015-04-20 05:08:54 -04:00
sevin7676
68d531ecb2 cleanup 2015-04-20 04:52:18 -04:00
sevin7676
e58fa3e6d7 remove completionModifer, one off for SQL Server Mode 2015-04-20 04:50:25 -04:00
nightwing
e610365e67 fix #2432 setPolling(false) doesn't turn off polling 2015-04-20 01:11:10 +04:00
nightwing
65b2cf2855 update test for rust mode 2015-04-19 20:35:57 +04:00
nightwing
2008ab813f fix bracket matching in modes imported from textmate 2015-04-19 20:29:28 +04:00
nightwing
ecb699aa11 support converting from cson 2015-04-19 20:28:12 +04:00
nightwing
63687f693b fix #2441 function highlighting in rust mode 2015-04-19 20:27:07 +04:00
nightwing
685ba18451 fix #2452 . is a valid XML tagname character 2015-04-19 20:05:25 +04:00
sevin7676
1ec6eb7b5d shorter names 2015-04-19 11:59:31 -04:00
sevin7676
1027dcea7c cache modifier 2015-04-19 11:52:54 -04:00
sevin7676
961f8c4893 completion modifier for SQL and JavaScript 2015-04-19 11:24:30 -04:00
sevin7676
27284cd29f added completionModifier
allows a highlight rule modify keyword completions
2015-04-19 11:23:10 -04:00
nightwing
04f4292fbc enable Emmet for handlebars mode 2015-04-19 17:34:22 +04:00
nightwing
4e6d48bf2e make sure operationEnd events are not emitted to wrong session 2015-04-19 17:34:22 +04:00
nightwing
80f43beb73 fix typo 2015-04-19 17:34:04 +04:00
sevin7676
cf0c81a25f more snippets 2015-04-19 08:37:22 -04:00
sevin7676
ee90854917 bug fix & typo fix 2015-04-19 08:18:04 -04:00
nightwing
ff4429dd5a fixes for emacs mode 2015-04-19 15:50:22 +04:00
nightwing
487408e84d fix +6291 Hard to tell what pane has focus in Vim mode 2015-04-19 15:50:06 +04:00
nightwing
2713d0a8db center cursor after vim jumplist motions
Conflicts:
	lib/ace/editor.js
2015-04-19 15:49:41 +04:00
nightwing
b0ce5630c9 add support for bindkey.position 2015-04-19 15:48:58 +04:00
Harutyun Amirjanyan
d89311e596 Merge pull request #2456 from kevinushey/bugfix/vim-normal-mode-yank
[vim] define 'Y' as 'keyToKey' mapping (fixes #2455)
2015-04-19 02:26:47 +04:00
Kevin Ushey
5482db1c4d [vim] fix 'Y' behaviour in visual mode 2015-04-18 15:19:28 -07:00
nightwing
eb70d5a6c8 Merge remote-tracking branch 'remotes/origin/master'
Conflicts:
	lib/ace/document.js
2015-04-19 01:04:25 +04:00
Harutyun Amirjanyan
abe0286420 Merge pull request #2458 from ajaxorg/vim
update vim mode
2015-04-18 22:00:47 +04:00
nightwing
094b8a147a update vim mode 2015-04-18 21:01:11 +04:00
Harutyun Amirjanyan
f0d01b93d4 Merge pull request #2457 from sevin7676/master
Add SQL Server (Microsoft SQL) Mode
2015-04-18 19:56:27 +04:00
nightwing
ef9cc542e7 fixes for indentedSoftWrap option 2015-04-18 19:53:49 +04:00
sevin7676
73808101cd cleanup 2015-04-18 10:06:55 -04:00
nightwing
0753f9aa12 Merge remote-tracking branch 'remotes/pull/2187' 2015-04-18 18:00:14 +04:00
Harutyun Amirjanyan
f270b4ae69 Merge pull request #2421 from mortalis13/master
Added new Sublime theme
2015-04-18 17:53:16 +04:00
sevin7676
121e0e51f4 add integer 2015-04-18 09:43:13 -04:00
sevin7676
846c2fb3d3 fix space 2015-04-18 09:35:39 -04:00
sevin7676
cd1c5a42c9 cleanup 2015-04-18 09:21:09 -04:00
sevin7676
282331b133 use pound as its the typical method 2015-04-18 09:12:11 -04:00
sevin7676
db0313f2ad fix case 2015-04-18 09:09:05 -04:00
sevin7676
37a80b35da missing execute in demo doc 2015-04-18 09:05:36 -04:00
sevin7676
75f66697f6 more cleanup 2015-04-18 08:55:29 -04:00
sevin7676
32847a6761 clean up 2015-04-18 08:53:11 -04:00
sevin7676
0d0b0b4356 updated demo doc and snippets 2015-04-18 08:45:13 -04:00
sevin7676
a0a31e16a2 cleanup 2015-04-18 08:27:22 -04:00
sevin7676
295ae4dc81 make pound optional for region 2015-04-18 08:25:47 -04:00
sevin7676
d38849ef9f added doc comment highlight to fix folding 2015-04-18 08:24:59 -04:00
sevin7676
184df6d18e inherit cstyle... trying to figure out best end marker 2015-04-18 07:29:10 -04:00
sevin7676
ff0cc12efc folding partially working.. 2015-04-18 06:37:29 -04:00
Morgan Yarbrough
1b9c8bfc88 FOLDING 2015-04-17 14:24:38 -04:00
Morgan Yarbrough
e42bc9a265 progress, and about to work on folding 2015-04-17 14:09:38 -04:00
Morgan Yarbrough
12be220297 even more keywords! 2015-04-17 12:53:42 -04:00
Morgan Yarbrough
7ae5c862c2 progress but not working yet 2015-04-17 11:17:31 -04:00
sevin7676
d8f7003fb8 add null back 2015-04-17 10:03:56 -04:00
sevin7676
76ac79f116 more progress 2015-04-17 10:00:13 -04:00
sevin7676
1a6e2f83f2 small fixes 2015-04-17 09:35:58 -04:00
sevin7676
6b62974118 good progress 2015-04-17 09:28:56 -04:00
sevin7676
461faa9184 more progress 2015-04-17 08:37:54 -04:00
sevin7676
ede82e7137 progress- save comments for reuse here 2015-04-17 08:11:21 -04:00
sevin7676
f0b3aa0a6f PARTIAL 2015-04-17 07:37:17 -04:00
mortalis13
fb5f272f81 Rename Sublime theme to iPlastic 2015-04-15 21:49:38 +03:00
mortalis13
c458f96d3a Edited lib/ace/sublime.css 2015-04-10 22:19:14 +03:00
Harutyun Amirjanyan
6070fe96f7 Merge pull request #2407 from xixixao/configure-block-select
Add configuration option for block select
2015-04-09 14:56:55 +04:00
Harutyun Amirjanyan
6a2d3fcb09 Merge pull request #2408 from bostikforever/vb-case-insensitive
VBScript is case insensitive
2015-04-09 14:52:56 +04:00
Harutyun Amirjanyan
8b29f7f3c9 Merge pull request #2411 from saxbophone/master
Wider SQL Command and Data Types Coverage
2015-04-09 14:51:33 +04:00
Harutyun Amirjanyan
48de4711eb Merge pull request #2418 from xixixao/selection-zero-height
Remove 0 height selection highlight
2015-04-09 14:50:26 +04:00
nightwing
bb3fa62824 Merge commit '510d060cb2' 2015-04-09 14:20:50 +04:00
Harutyun Amirjanyan
6bdc0d6cbb Merge pull request #2440 from grit96/patch-1
Make print margin in cobalt more visible
2015-04-09 14:20:07 +04:00
nightwing
510d060cb2 cleanup 2015-04-09 14:09:03 +04:00
Geraint White
da8d545985 Make print margin in cobalt more visible 2015-04-09 09:14:21 +01:00
César Izurieta
4f655e71d9 Make deepCopy work correctly with arrays 2015-04-05 04:39:36 -03:00
nightwing
8f686eb795 release v1.1.9 2015-04-03 13:43:18 +04:00
nightwing
6fad60f546 tweaks for the new release 2015-04-03 13:30:00 +04:00
nightwing
1ae86f896a update vim mode 2015-04-03 13:29:10 +04:00
nightwing
4e4df645cc add adoc extension for asciidoc files 2015-04-03 13:29:10 +04:00
Joshua Saxby
0bf729d88f added important keywords and data types missed out 2015-03-27 22:21:42 +00:00
Joshua Saxby
cc40177114 Revert "add some new types and change the type of existing keywords"
This reverts commit fcb4023e52.
2015-03-27 22:11:41 +00:00
Joshua Saxby
fcb4023e52 add some new types and change the type of existing keywords 2015-03-27 22:10:02 +00:00
mortalis
22f802a9ff new sublime theme 2015-03-27 12:37:59 +02:00
xixixao
14a8e1f5d9 Remove 0 height selection highlight 2015-03-25 18:07:38 +00:00
Harutyun Amirjanyan
a2e05ac438 Merge pull request #2410 from kevinushey/bugfix/r-sapply-snippet
correct snippet for 'sapply'
2015-03-21 18:06:48 +04:00
Kevin Ushey
f17c67cd01 correct snippet for 'sapply' 2015-03-19 15:30:41 -07:00
Bolutife Ogunsola
9c6720edca Update tokens test file for vbscript 2015-03-19 19:11:49 +01:00
Bolutife Ogunsola
4dd8eda928 VBScript is case insensitive 2015-03-19 18:03:01 +01:00
xixixao
cb83a974b4 Add configuration option for block select 2015-03-18 21:09:45 +00:00
Ruben Daniels
75556854b9 Merge pull request #2397 from ajaxorg/fix/various
Several small fixes
2015-03-17 15:12:49 -07:00
nightwing
7e9e5aea17 remove old code 2015-03-18 01:57:03 +04:00
nightwing
bb16d65cbb update jshint 2015-03-18 01:55:07 +04:00
Harutyun Amirjanyan
c39134411d Merge pull request #2387 from jmcphers/master
Prevent vim ex commandline from obscuring search results
2015-03-17 10:00:34 +04:00
Harutyun Amirjanyan
cb0816b183 Merge pull request #2399 from kevinushey/patch/vim-colon-selection
[vim] don't select range specifier on `:` insertion
2015-03-17 09:58:58 +04:00
Kevin Ushey
e551b090b7 don't select initial text on ':' 2015-03-16 15:50:31 -07:00
nightwing
c5602489f4 add styling for ace_invisble to all themes 2015-03-15 15:27:48 +04:00
nightwing
1c1d56b3ea make blurred state clearer in github theme 2015-03-15 15:18:10 +04:00
nightwing
a78bf8e5ef update links to emmet.js 2015-03-15 15:00:00 +04:00
nightwing
d9db903190 update rust mode 2015-03-15 15:00:00 +04:00
nightwing
4af37cd722 fix #2395 context menu regression in Firefox on mac 2015-03-15 15:00:00 +04:00
Harutyun Amirjanyan
dd69f5939c Merge pull request #2380 from trystanclarke/master
Fix typeerror "Cannot read property 'container' of undefined" in autocomplete
2015-03-15 00:09:42 +04:00
Harutyun Amirjanyan
cac9e261e3 Merge pull request #2386 from timdp/behaviours-keep-selection
CstyleBehaviour: keeping selections after insertion
2015-03-15 00:01:02 +04:00
Joshua Saxby
0216e8bbfd formatting 2015-03-11 21:27:36 +00:00
Joshua Saxby
38e3452313 added SQL data types 2015-03-11 21:05:54 +00:00
Joshua Saxby
fb7b23e627 started adding missing sql keywords and types 2015-03-11 18:42:21 +00:00
Jonathan McPherson
1b1006ac1d prevent vim ex commandline from obscuring search results (fixes #2384) 2015-03-10 14:17:17 -07:00
Harutyun Amirjanyan
101656ea5c Merge pull request #2385 from mikermcneil/patch-1
makes example work out of the box
2015-03-10 23:41:57 +04:00
Ruben Daniels
6a07619ad2 Merge pull request #2370 from ajaxorg/misc
Misc issues
2015-03-10 12:33:01 -07:00
Tim De Pauw
a5c619bda8 CstyleBehaviour: keeping selections after insertion 2015-03-09 17:44:03 +01:00
Mike McNeil
3adde642dc makes example work out of the box 2015-03-07 18:40:04 -08:00
trystanclarke
967177bbc5 Update autocomplete.js 2015-03-02 09:35:46 +00:00
nightwing
60c639a34b Merge branch 'pull/2375' 2015-02-28 22:17:25 +04:00
nightwing
de9e5226bf add tests from v1.2 branch and increase split size to improve performance 2015-02-28 22:16:19 +04:00
nightwing
76e05b7fd5 fix #2381: keycode for ; is missing 2015-02-28 21:51:18 +04:00
nightwing
2506bb0921 Merge branch pull/2376 2015-02-28 21:43:09 +04:00
nightwing
481bca1b09 use ellipsis character instead of dots 2015-02-28 21:41:30 +04:00
nightwing
01f5846ee3 static highlight can be used without editor.css 2015-02-28 20:40:54 +04:00
trystanclarke
cca4ab8b45 Merge pull request #1 from trystanclarke/trystanclarke-fix-autocomp-type-error
Update autocomplete.js
2015-02-27 16:18:03 +00:00
trystanclarke
ae4989eea1 Update autocomplete.js
Fix typeerror "Cannot read property 'container' of undefined" when using live autocomplete. Error can occur when editor loses focus and the autocomplete popup has never been shown.
2015-02-27 16:15:24 +00:00
Daniel Marcotte
6df244d429 Fit what metadata we can into autocompletes
The whole meta string currently gets dropped from the autocompletes
popup if it doesn't fit.  This leads to confusing autocompletes where
the meta for some entries are missing for no apparent reason.

So, instead of dropping the entire meta string when it doesn't fit,
insert what we can and append "..." to communicate that we clipped it.
2015-02-25 16:43:39 -08:00
Scott Glajch
b5064a4bb3 Fix for issue #2374, maximum call stack exceeded in 64 bit chrome when pasting large chunks. 2015-02-25 13:00:39 -05:00
nightwing
9905267e4d fix gutter in static highlight when wrapping is enabled 2015-02-25 00:14:14 +04:00
Harutyun Amirjanyan
bed3a18d49 Merge pull request #2366 from leanprover/add-lean-mode
add 'lean' mode for Lean Theorem Prover files
2015-02-24 23:25:57 +04:00
Soonho Kong
49ff504639 fix qqstring rule in lean-mode 2015-02-24 14:10:41 -05:00
Harutyun Amirjanyan
a035cd2558 Merge pull request #2373 from pamelafox/patch-2
Add ClassName to highlighting
2015-02-24 23:03:48 +04:00
Harutyun Amirjanyan
9a275f304d Merge pull request #2371 from pamelafox/patch-1
Adding cursive and fantasy to keywords list
2015-02-24 23:02:07 +04:00
Pamela Fox
b6910a3094 Add ClassName to highlighting
So that document.getElementsByClassName gets highlighted.
2015-02-24 10:59:36 -08:00
Soonho Kong
27ad846641 highlight names followed nameProviders in lean-mode 2015-02-24 13:21:40 -05:00
Soonho Kong
34d80e81ca clean up string rule for lean-mode 2015-02-24 13:21:22 -05:00
Soonho Kong
3c34a9852f add and sort keywords/storage-modifiers for lean-mode 2015-02-24 13:20:28 -05:00
Soonho Kong
a0fe09f3be clean up unused rules for lean-mode 2015-02-24 13:19:56 -05:00
Pamela Fox
906b6c9d8d Adding cursive and fantasy to keywords list 2015-02-24 09:30:43 -08:00
Soonho Kong
74800e84ee remove single quoted string (qstring) from lean-mode 2015-02-24 12:09:11 -05:00
Soonho Kong
8f49d3d897 add a small demo for lean mode 2015-02-24 11:11:34 -05:00
Soonho Kong
9654382294 use 'defaultToken' for comment/qqstring/qstring in lean-mode
Suggested by @nightwing
2015-02-24 11:02:06 -05:00
nightwing
5ce334e930 update CONTRIBUTING.md 2015-02-24 18:49:59 +04:00
nightwing
7572a9543e update syntax docs 2015-02-24 18:42:15 +04:00
Soonho Kong
b3da9336ee add 'lean' mode for Lean Theorem Prover files 2015-02-23 07:03:52 -05:00
nightwing
4bc34f4eae fix #2341 do not use ace_editor id for the default style 2015-02-18 23:26:22 +04:00
nightwing
16b542aea4 reduce crazy large negative top value on hidden textarea (fixes #2362) 2015-02-18 23:19:27 +04:00
Ruben Daniels
60a1281708 Merge pull request #2355 from ajaxorg/build-issues
Fix build issues
2015-02-16 11:28:20 -08:00
Ruben Daniels
2ff39c2192 Merge pull request #2322 from ajaxorg/altgr
Fix altgr handling
2015-02-16 11:27:45 -08:00
Ruben Daniels
34f57e7499 Merge pull request #2316 from ajaxorg/misc
Fix xml autodindent and several small issues
2015-02-16 11:27:16 -08:00
Harutyun Amirjanyan
04e75ea0db Merge pull request #2359 from invokr/master
Added new C++11 tokens to highlighting rules
2015-02-16 19:13:07 +03:00
Robin
b0475ce3e4 Added C++11 tokens to highlighting rules 2015-02-16 14:27:22 +00:00
Harutyun Amirjanyan
d86b2fd7ee Merge pull request #2332 from kevinushey/bugfix/xml-tag-highlighting
[xml] ensure tag name starts with letter
2015-02-16 15:27:42 +03:00
nightwing
0b20e4dc1d fix #2351 Minification fails on Windows 2015-02-12 19:46:21 +04:00
nightwing
388f0235b7 fix #2348 packaged require breaks node-webkit 2015-02-12 19:45:43 +04:00
nightwing
d9e4b52ee1 fix alt-e at the last error 2015-02-10 19:09:27 +04:00
nightwing
703a5394e3 toggle fold commands must work for all selections 2015-02-10 19:09:11 +04:00
nightwing
42b43b1fbe fix highlighting of indented bash heredocs 2015-02-10 19:08:56 +04:00
nightwing
3e32d5bf7e workaround for vim cursor getting stuck on folded lines 2015-02-10 19:07:55 +04:00
Harutyun Amirjanyan
385a285c58 Merge pull request #2334 from tylerlong/master
XAML is XML
2015-02-02 19:58:44 +04:00
Tyler Long
c840471248 XAML is XML
https://msdn.microsoft.com/en-us/library/cc295302.aspx
2015-01-29 14:47:57 +08:00
Kevin Ushey
3fe1383cdc [xml] ensure tag name starts with letter 2015-01-28 10:53:42 -08:00
Harutyun Amirjanyan
6b88b939c2 Merge pull request #2325 from mdinger/add_usize_isize_highlighting
Add Rust highlight support for isize, usize, us and is
2015-01-27 23:57:24 +04:00
mdinger
1621c1519c Add highlight support for isize, usize, us and is 2015-01-24 14:18:11 -05:00
nightwing
0da0566bac fix pagedown in vim mode 2015-01-24 18:53:41 +04:00
nightwing
b93d772720 do not overwrite ctrl-alt-0 on windows since that is used on German keyboard 2015-01-23 17:21:12 +04:00
nightwing
845a6d4e98 make detection of altGr more robust 2015-01-23 17:21:12 +04:00
nightwing
8df1eb70c5 fix typo 2015-01-23 17:07:20 +04:00
Harutyun Amirjanyan
63178a0511 Merge pull request #2318 from shiroyuki/patch-1
Add the missing mode "Django" to ext-modelist
2015-01-23 16:38:49 +04:00
nightwing
9f8cb78f37 fix require path for tests 2015-01-23 16:35:45 +04:00
nightwing
acd41efcb6 do not include all whitespace lines in vim paragraphs 2015-01-23 13:36:06 +04:00
nightwing
64eaf47c4d do not throw when running vim ':write' command 2015-01-23 13:32:20 +04:00
nightwing
c769031e78 [vim] fix w for non ascii chars 2015-01-22 22:38:32 +04:00
Juti Noppornpitak
8a8bc206db Add the missing mode "Django" to ext-modelist
This is to add Django as an alternative mode for HTML files. The placement of the entry is to ensure that Django syntax highlighter does not override HTML syntax highlighter.
2015-01-19 16:30:38 -05:00
nightwing
7db217dfe0 avoid emitting spurious changeWrapMode event 2015-01-19 01:15:24 +04:00
nightwing
847bfa4bfe cleanup 2015-01-19 01:13:05 +04:00
nightwing
135b9e5baf do not autoindent after self-closing tag 2015-01-19 01:10:03 +04:00
nightwing
c356c14940 fix weird pairing of quotes in cstyle behavior 2015-01-19 00:33:14 +04:00
nightwing
2d06dc6316 workaround for word-wrap bug on chrome 2015-01-19 00:28:51 +04:00
nightwing
8c4173ba11 Merge remote-tracking branch 'remotes/origin/master' 2015-01-18 23:44:18 +04:00
Harutyun Amirjanyan
fe57baaae1 Merge pull request #2289 from iDeBugger/master
Added XMLDOM and worker for XML syntax analysis
2015-01-18 22:37:58 +03:00
Harutyun Amirjanyan
0c3246e0df Merge pull request #2315 from xixixao/patch-1
Fix doc on editor.remove
2015-01-18 22:33:43 +03:00
Michal Srb
d21be42c8a Fix doc on editor.remove 2015-01-18 14:40:51 +00:00
Smirnov O. A
ccd5d689cc Updated xmldom dependency 2015-01-16 10:06:38 +03:00
Smirnov O. A
fb41c6ce4e Update update_deps.js for xmldom 2015-01-16 09:57:52 +03:00
Smirnov O. A
3b703dad56 Merge branch 'master' of github.com:iDeBugger/ace 2015-01-14 11:07:40 +03:00
Smirnov O. A
0a7d192b3d Merge remote-tracking branch 'upstream/master' 2015-01-14 11:06:22 +03:00
Harutyun Amirjanyan
c0b300a8e8 Merge pull request #2311 from yihangho/docs/spacing
Fix spacing in index.html
2015-01-13 17:03:16 +04:00
Yihang Ho
68abe8507a Fix spacing in index.html 2015-01-13 20:45:01 +08:00
Lennart Kats
d62315a740 Merge pull request #2309 from ajaxorg/misc
Fix several small issues
2015-01-13 09:54:25 +01:00
nightwing
eddc5563d8 update json worker tests 2015-01-12 02:23:50 +04:00
nightwing
57f6fbd768 tweak completer 2015-01-12 02:12:00 +04:00
nightwing
100022564c cancel gatherCompletions if cursor position changes 2015-01-12 01:13:27 +04:00
nightwing
b57f2e2ae3 fix inline editor demo 2015-01-11 23:23:53 +04:00
nightwing
264923e4df make worker events more consistent 2015-01-11 22:48:39 +04:00
nightwing
e1a5492a7f do not throw error when trying to match tag at the end of the document 2015-01-11 22:27:12 +04:00
nightwing
5e4facea44 fix livescript highlighting 2015-01-11 22:23:25 +04:00
Harutyun Amirjanyan
37ab8daabe Merge pull request #2300 from kevinushey/patch/vim-visual-block-move-to-eol
Conform with upstream change for Vim Visual Block + move to EOL behaviour
2015-01-07 22:49:58 +04:00
nightwing
55bf8e56d3 fix highlighting of ?" in ruby mode 2015-01-07 01:18:28 +04:00
nightwing
ced37c0c19 update jshint 2015-01-06 15:45:55 +04:00
Kevin Ushey
a50833cfea conform with upstream change
Ref:
1e5ae06ba4
2015-01-05 17:11:14 -08:00
iDeBugger
b2b0e73e0f Fixed some troubles with language and codestyle 2015-01-05 00:27:11 +03:00
nightwing
72edcd332d tweak mode_creator 2015-01-05 00:34:25 +04:00
nightwing
bcc2cd9b68 Merge remote-tracking branch 'remotes/origin/master' 2015-01-05 00:20:02 +04:00
nightwing
f4ea1ccb6a always call the callback form setMode 2015-01-05 00:17:16 +04:00
nightwing
a06739af9a Merge remote-tracking branch 'remotes/origin/fix/webkit-focus-bug' 2015-01-04 23:54:53 +04:00
nightwing
aceddd9f8f Merge branch 'pull/2273' 2015-01-04 23:54:00 +04:00
nightwing
ad9aa35ffe Revert "Reduced size of sample document" 2015-01-04 23:52:40 +04:00
nightwing
b66fb6def8 Merge branch 'pull/2269' 2015-01-04 23:50:57 +04:00
nightwing
0054bb8794 cleanup 2015-01-04 23:48:28 +04:00
nightwing
4603c34b10 workaround for webkit focus bug 2015-01-01 02:00:02 +04:00
Bernhard Weichel
07d01fda44 fixed a few typos and added more snippets 2014-12-29 22:10:03 +01:00
Smirnov O. A
4aff48a837 Added XMLDOM and worker for XML syntax analysis 2014-12-24 14:44:31 +03:00
Harutyun Amirjanyan
4b8a9a475b Merge pull request #2284 from darabos/patch-1
Fix getVScrollBarAlwaysVisible
2014-12-23 23:30:26 +04:00
Matthias S. Benkmann
eccc98b83b net.put => net.request('PUT'; improved usability for "Save" buttons 2014-12-23 16:33:56 +01:00
Matthias S. Benkmann
e7afb4f19e support glob patterns for --puttable; reformat for ancient terminals 2014-12-23 15:51:23 +01:00
Matthias S. Benkmann
8919b113d1 add server upload buttons and Ctrl-S bindings to mode_editor
in combination with PUT support in ./static.py (or whatever other web server)
this allows people to save both the highlighting rules and the demo documents right
from the mode editor for a better workflow.
2014-12-23 13:03:09 +01:00
Matthias S. Benkmann
ded43d9d69 HTTP PUT support for static.py
change host default to 127.0.0.1 for better security
improved option parsing
2014-12-23 13:03:09 +01:00
Bernhard Weichel
14850f5b9e Reduced size of sample document 2014-12-22 16:55:40 +01:00
Lennart Kats
7ff1f1dd0d Merge pull request #2283 from ajaxorg/misc
Sync with cloud9
2014-12-22 13:29:17 +01:00
nightwing
8ff856186d update tests for c mode 2014-12-22 02:47:38 +04:00
nightwing
b46a0fb4f9 do not include xml tag attributes in the fold range 2014-12-22 02:47:31 +04:00
Daniel Darabos
b9a4f293ed Fix getVScrollBarAlwaysVisible.
By accident it was returning `$hScrollBarAlwaysVisible`.
2014-12-21 22:52:21 +01:00
nightwing
724b66857d Merge remote-tracking branch 'remotes/pull/2281' 2014-12-21 13:47:50 +04:00
nightwing
56cb246c78 max stack size on chrome is smaller now 2014-12-21 13:46:41 +04:00
nightwing
fed215d046 do not discard modifier info of modifier keys 2014-12-21 13:39:25 +04:00
nightwing
7a3257ab58 fix incorrect highlighting in c and haskell modes 2014-12-21 13:39:25 +04:00
nightwing
2d12ebb1df improve global access warning in the demo 2014-12-21 13:39:13 +04:00
Kevin Ushey
15b83aca5f fix move to EOL behaviour for visual block mode 2014-12-20 13:31:23 -08:00
nightwing
60dd224d96 remove old delta shim from vim mode 2014-12-20 19:53:51 +04:00
nightwing
067a1ee68b Merge remote-tracking branch 'remotes/origin/master' 2014-12-20 19:51:39 +04:00
Harutyun Amirjanyan
5ea0a9b802 Merge pull request #2280 from ajaxorg/vim2
Update vim mode to the latest version
2014-12-20 19:45:50 +04:00
nightwing
66ede32c42 update build submodule 2014-12-20 16:19:58 +04:00
nightwing
ed5c38b7c8 update list of users 2014-12-19 18:50:55 +04:00
nightwing
b5c9b7f395 fix typo in IE mouse handler 2014-12-19 18:45:25 +04:00
Lennart Kats
7b037f35ba Merge pull request #2267 from ajaxorg/fix/various
Fix various small issues
2014-12-16 16:06:41 +01:00
Harutyun Amirjanyan
52de738e8a Merge pull request #2275 from mehtaphysical/char_reserved_in_js
change variable char to character
2014-12-16 01:01:45 +04:00
Ryan Mehta
dafa24d5e1 change variable char to character 2014-12-15 12:33:49 -08:00
Bernhard Weichel
95eed25439 small fix in the snippets 2014-12-14 23:53:52 +01:00
Bernhard Weichel
7da354d5f3 fixed Uncaught TypeError: undefined is not a functionapp_config.js:147
(anonymous function)app_config.js:146 setDefaultValuesmode_creator.js:6
2014-12-14 23:40:47 +01:00
Bernhard Weichel
18b3c57de9 Merge branch 'master' of https://github.com/ajaxorg/ace into feature/ace_language_definition
# By nightwing (7) and others
# Via Harutyun Amirjanyan (4) and others
* 'master' of https://github.com/ajaxorg/ace:
  do not pair quotes inside strings
  fix toggleComment command in php mode
  fix copyLines* for multiple selections
  fix pairing of quotes in cstyle behavior
  add helper for creating tests
  Autocomplete exactMatch option
  add *~ (backup files created by various editors) to .gitignore
  Remove unneeded regex groups for Eiffel
  Update Eiffel programming language definition.
  add config.warn and refactor config to allow sharing with ace_tree
  do not use automatic scroll into view
  Teach tmlanguage.js to process multiple .tmLanguage files at once
2014-12-14 23:11:35 +01:00
Bernhard Weichel
8019a21475 added abc mode 2014-12-14 20:34:41 +01:00
nightwing
c5edaa3608 allow filtering tests in browser runner 2014-12-13 16:45:56 +04:00
nightwing
5a03993f65 update vim.js 2014-12-13 00:50:13 +04:00
Lennart Kats
5fc3bbbe09 Merge pull request #2249 from ajaxorg/misc
Several small fixes
2014-12-12 20:48:16 +01:00
nightwing
6b13aedf5f do not pair quotes inside strings 2014-12-12 17:38:39 +04:00
nightwing
ec18d9493d fix toggleComment command in php mode 2014-12-12 17:38:39 +04:00
nightwing
3fa54ce97e fix copyLines* for multiple selections 2014-12-12 17:38:39 +04:00
nightwing
852e0673ca fix pairing of quotes in cstyle behavior 2014-12-12 17:38:38 +04:00
nightwing
278f1d1674 add helper for creating tests 2014-12-12 17:38:38 +04:00
Harutyun Amirjanyan
232b3c0f8c Merge pull request #2272 from adamjimenez/autocomplete-exact
Autocomplete exactMatch option
2014-12-12 17:21:39 +04:00
nightwing
d8f0ab2a16 fix regression in setDefaultValues 2014-12-12 16:56:02 +04:00
Adam Jimenez
cfdb223e7a Autocomplete exactMatch option
Option to show only exact matches in autocomplete
2014-12-12 10:27:45 +00:00
Harutyun Amirjanyan
d68050c62b Merge pull request #2268 from mbenkmann/gitignore_backup_files
add *~ (backup files created by various editors) to .gitignore
2014-12-10 11:11:00 -08:00
Matthias S. Benkmann
119259b702 add *~ (backup files created by various editors) to .gitignore 2014-12-07 18:21:03 +01:00
nightwing
c49e5bfef9 disable warning 2014-12-07 01:26:44 +04:00
nightwing
2fc497477d highlight tags when cursor is before tagname 2014-12-07 01:26:24 +04:00
nightwing
e54882db64 use setAttribute instead of autocorrect setter, since the setter doesn't work on ipad 2014-12-07 01:08:06 +04:00
Harutyun Amirjanyan
e217418d39 Merge pull request #2266 from Conaclos/master
Update Eiffel definition
2014-12-06 13:03:03 -08:00
Victorien ELVINGER
354dc37ea6 Remove unneeded regex groups for Eiffel 2014-12-06 20:04:27 +01:00
Victorien ELVINGER
29597325d9 Update Eiffel programming language definition.
- Disable comments into strings
- Enable concise form for real numbers
- Enable juxtaposed digit separators
- Check char and string content.
2014-12-06 19:50:52 +01:00
Harutyun Amirjanyan
0d4566b42b Merge pull request #2264 from aroben/convert-many-tmlanguages
Teach tmlanguage.js to process multiple .tmLanguage files at once
2014-12-04 03:44:16 -08:00
Lennart Kats
e1933043dc Merge pull request #2254 from ajaxorg/do-not-scroll
Disable automatic scroll into view
2014-12-04 11:10:29 +01:00
nightwing
a71c17b46f add config.warn and refactor config to allow sharing with ace_tree 2014-12-04 14:02:49 +04:00
nightwing
8c1aa5c772 do not use automatic scroll into view
prepares for deprecating the feature in the next version of ace
2014-12-04 14:02:19 +04:00
Lennart Kats
35155075e0 Merge pull request #2219 from ajaxorg/vim2
better vim mode
2014-12-04 10:55:29 +01:00
Adam Roben
23a3ba85f0 Teach tmlanguage.js to process multiple .tmLanguage files at once
You can now pass more than one .tmLanguage file to tmlanguage.js and it will
process each one in turn. This can vastly speed up the processing of multiple
files as you don't have to pay the node/V8 startup cost for each file.

Note that the script's "dev mode" is now controlled by a --dev flag rather than
an unnamed second argument.
2014-12-03 13:56:22 -05:00
Lennart Kats
57a07f54b3 Merge pull request #2261 from ajaxorg/build
fix broken paths in kitchen-sink demo
2014-12-01 16:10:08 +01:00
Harutyun Amirjanyan
93bd34e1cf Merge pull request #2238 from sevin7676/master
cstyle Comment Folding (region and triple star single line block comment)
2014-11-29 23:59:14 -08:00
Harutyun Amirjanyan
16cdd9ddb3 Merge pull request #2259 from jpallen/patch-2
Highlight \ref, \vref, \cite and \citep as labels
2014-11-28 06:33:29 -08:00
James Allen
fc322711ca Highlight \ref, \vref, \cite and \citep as labels
The `\ref`, and `\cite` commands in LaTeX are similar to `\label`s in that they refer to user defined labels elsewhere in the text, and it makes sense to highlight them with the same color scheme. Particularly the coloring of arguments to `\ref` commands should match the color of `\label` commands because `\label` defines the strings that `\ref` then references.
2014-11-28 13:34:16 +00:00
sevin7676
c1a8e77760 Add comment to explain unusual naming and remove ending whitespace 2014-11-28 08:18:33 -05:00
Harutyun Amirjanyan
097d19e943 Merge pull request #2256 from devoncarew/devoncarew_dart_keywords
more dart keywords
2014-11-26 07:31:07 -08:00
Devon Carew
f7144da4ec more dart keywords 2014-11-25 13:37:36 -08:00
sevin7676
41df1f265f Fix fold widget range for region
End range should be at end of line as we don't want to display the
'#endregion' text after the fold widget (this is consistent with cstyle
region comment folding).

Added missing semi-colons.
2014-11-25 07:01:09 -05:00
sevin7676
1869024de6 changes per nightwing recommendations
Rename this.getFoldWidgetBase to avoid conflict with C# mode.

Use regex instead of substring and trim to determine single line block
comment.

Fixed formatting.

Renamed this.getRegionBlock to this.getCommentRegionBlock to prevent C#
mode conflict.

Updated this.getCommentRegionBlock regex to make nested regions work
properly.

Cleaned up this.startRegionRe (had unneeded parenthesis).
2014-11-25 06:58:45 -05:00
sevin7676
602a7efd5f removed unused line
the end of the range should be the end of the line as we don't want to
see [//#endreigon] in our fold widget.
2014-11-24 10:18:00 -05:00
sevin7676
03730ce381 extra comment to help explain code 2014-11-24 09:52:57 -05:00
sevin7676
f26841da41 tested and cleaned up 2014-11-24 09:48:41 -05:00
sevin7676
fb32897b85 progress
appears to be working, need to clean up still
2014-11-24 09:29:37 -05:00
nightwing
49b50ff347 fix broken paths in kitchen-sink demo 2014-11-23 20:06:41 +04:00
Harutyun Amirjanyan
a50fe34925 Merge pull request #2253 from wcandillon/patch-1
Remove references to built-in modules
2014-11-23 14:27:33 +04:00
William Candillon
332472ecc6 Remove references to built-in modules 2014-11-22 19:27:52 -08:00
nightwing
2f32304c2e update vim.js 2014-11-22 00:52:50 +04:00
nightwing
a40060c1ae increase timeout for intermittently failing placeholder_test.js 2014-11-21 23:15:39 +04:00
nightwing
b4d2cf810d fix failing test 2014-11-21 23:15:37 +04:00
nightwing
a185414f64 remove old vim mode 2014-11-21 23:15:34 +04:00
nightwing
f9de0a5661 use ctrl-c and mac repeat handling from old vim mode 2014-11-21 23:14:28 +04:00
nightwing
068c950517 add support for multiple selections 2014-11-21 23:14:27 +04:00
nightwing
bd7de6b43b fix find next for regexps matching empty range 2014-11-21 23:14:26 +04:00
nightwing
aa472742cc allow to customize cursor appearance 2014-11-21 23:14:24 +04:00
nightwing
8daf190b2e add CodeMirror api proxy for vim mode 2014-11-21 23:14:21 +04:00
nightwing
f47c3ea8bd add cm vim mode 2014-11-21 23:04:16 +04:00
Harutyun Amirjanyan
38ed6de508 Merge pull request #2246 from wcandillon/patch-1
Disable module resolver
2014-11-21 16:51:49 +04:00
Harutyun Amirjanyan
d8d1e08a86 Merge pull request #2236 from tenbits/master
Add Mask Highlighter
2014-11-21 16:50:44 +04:00
Harutyun Amirjanyan
2c796133e0 Merge pull request #2247 from aroben/custom-tmtheme
Teach tmtheme.js how to convert a non-built-in theme
2014-11-21 16:49:45 +04:00
Alex Kit
1587b96b3c Add Mask Highlighter 2014-11-21 05:08:12 +01:00
Adam Roben
11d15b2f28 Pretty-print CSS even when creating a new file 2014-11-20 15:19:27 -05:00
nightwing
eec012b24e fix ignoring empty delta 2014-11-20 23:28:09 +04:00
nightwing
004a19855a do not throw for broken anchors since that can break editor 2014-11-20 23:23:46 +04:00
nightwing
d619e4e746 allow passing newLineCharacter ot getValue 2014-11-20 23:02:34 +04:00
nightwing
27264bb9d9 fix infinite loop when inserting more than 0xF000 lines at once 2014-11-20 23:01:53 +04:00
Adam Roben
89702bf606 Make tmtheme.js handle elements with no settings
We just ignore them now rather than throwing an exception.
2014-11-20 10:56:57 -05:00
Adam Roben
f471e54ef0 Teach tmtheme.js how to convert a non-built-in theme
You can now pass a .tmTheme file on the command line to have it converted.
2014-11-20 10:56:32 -05:00
William Candillon
e0bd006ffc Update xqlint dependency 2014-11-18 13:55:32 -08:00
William Candillon
9f2473bce2 Disable module resolver 2014-11-18 13:48:02 -08:00
Lennart Kats
d097d41144 Merge pull request #2237 from ajaxorg/focus
fix focus related issues
2014-11-17 10:34:12 +01:00
Harutyun Amirjanyan
a0f7864b78 Merge pull request #2241 from jmeas/fix-position
Sets offset of fontMetrics div to be 0.
2014-11-16 19:14:29 +04:00
Jmeas
a45385be98 Sets offset of fontMetrics div to be 0.
Offsetting the fontMetrics div causes the 'ghost image' created when
drag and dropping an Ace Editor to be offset by that same amount. By
removing the offset we fix the problem. Closes #2240.
2014-11-15 19:59:07 +01:00
sevin7676
ef856d0f61 Javascript fixes
added forceMultiline parameter and removed line copied from C# folding
2014-11-15 09:15:25 -05:00
sevin7676
a70a9a88a9 new javascript folding in html mode 2014-11-15 09:03:31 -05:00
sevin7676
11bbc03e1d Javascript region folding 2014-11-15 08:48:20 -05:00
sevin7676
1bed3ec951 Javscript region folding 2014-11-15 08:38:21 -05:00
nightwing
bf7eba2253 fix focusing window with click on ie 2014-11-14 23:57:06 +04:00
nightwing
7326de2a48 reset cached scroll values when resizing
this is needed since scrollTop of scrollbar element can be reset to 0
when ace is moved in the document.
2014-11-14 23:57:06 +04:00
nightwing
1721ca8a0c fix unwanted scrolling into view of hidden textarea 2014-11-14 23:56:55 +04:00
Lennart Kats
c5c1bb2b13 Merge pull request #2235 from ajaxorg/hotfix/php_folding
Hotfix for regression in php folding
2014-11-12 17:08:35 +01:00
nightwing
3a8b279e43 update fold widgets in mixed modes when tokenizer state changes 2014-11-12 18:40:22 +04:00
nightwing
742e8c01a8 fix folding of li tags containing unclosed p tags 2014-11-12 18:38:50 +04:00
nightwing
5801b75b5d fix php folding 2014-11-12 18:37:59 +04:00
nightwing
a4532dd8b9 Merge remote-tracking branch 'remotes/origin/master' into v-1.2
Conflicts:
	build
	lib/ace/multi_select_test.js
2014-11-11 11:47:04 +04:00
nightwing
64f2fc4015 add newLineCharacter argument to getValue 2014-11-11 11:45:20 +04:00
nightwing
ffaf44ec0b copy insert start position before storing it in undoStack 2014-11-11 11:44:17 +04:00
nightwing
bacaeb07d8 cleanup 2014-11-11 11:40:18 +04:00
nightwing
271cefb44a fix typo 2014-11-08 23:52:05 +04:00
nightwing
b8e3198ba8 version 1.1.8 2014-11-08 23:45:22 +04:00
nightwing
a4d831f474 add more users 2014-11-08 20:56:18 +04:00
nightwing
c4e937939a Merge remote-tracking branch 'remotes/origin/mode_issues' 2014-11-08 16:25:19 +04:00
nightwing
5562566b37 Merge remote-tracking branch 'remotes/origin/emacs'
Conflicts:
	lib/ace/incremental_search_test.js
2014-11-08 16:02:02 +04:00
nightwing
d09740f494 fix emacs universal argument 2014-11-08 15:57:23 +04:00
Robert Krahn
e83252130c emacs: improved multi selection handling for emacs mark 2014-11-06 23:27:54 -08:00
nightwing
072dcb1c11 fix tripple brace highlighting in handlebars mode 2014-11-06 20:43:08 +04:00
Harutyun Amirjanyan
989d0ac3fb Merge pull request #2226 from LivelyKernel/isearch-regexp-support
isearch regexp support
2014-11-06 10:15:53 +04:00
Robert Krahn
775cdedefb isearch test fix 2014-11-05 15:30:05 -08:00
Robert Krahn
a93646d2f7 isearch: commands searchAsRegExp and selectAllMatches 2014-11-05 15:30:03 -08:00
Robert Krahn
7bb5b305be isearch: add regexp support 2014-11-05 15:30:01 -08:00
Robert Krahn
939e0739a7 adding improvements as suggested by @nightwing 2014-11-05 15:25:28 -08:00
Robert Krahn
8786e17e6b isearch test: ensure multi select 2014-11-05 15:25:27 -08:00
Robert Krahn
0a055cb725 isearch: being flexible about whether emacs mode is on or not 2014-11-05 15:25:26 -08:00
Robert Krahn
54d80d79ab emacs: make code strict conform 2014-11-05 15:25:16 -08:00
Robert Krahn
ea67201540 emacs: fix exchangePointAndMark in normal select mode 2014-11-05 15:25:15 -08:00
Robert Krahn
78b2147c3c emacs/isearch: select when moving cursor via isearch and emacs mark is set 2014-11-05 15:25:14 -08:00
Robert Krahn
b966cfd7da emacs: cleanup 2014-11-05 15:25:12 -08:00
Robert Krahn
24f3bab19d emacs: fix multi select exchangePointAndMark
Conflicts:
	lib/ace/keyboard/emacs.js
2014-11-05 15:25:08 -08:00
Robert Krahn
90034c3a44 fixing multi selection handling for various emacs commands
Conflicts:
	lib/ace/keyboard/emacs.js
2014-11-05 15:24:41 -08:00
nightwing
9ccf68dbb2 make sure missing emmet can't break tab key 2014-11-05 23:17:59 +04:00
nightwing
22de936727 fix bracket pairing for multiple selections 2014-11-05 23:15:45 +04:00
Lennart Kats
f133231df8 Merge pull request #2222 from ajaxorg/mode_issues
Fix mode issues
2014-11-05 14:47:05 +01:00
nightwing
e26c70ad53 update soy_template test 2014-11-05 17:36:14 +04:00
nightwing
f362d2e84a add markdown comment to elixir demo 2014-11-05 16:56:51 +04:00
nightwing
96061f72ae update ChangeLog 2014-11-05 16:51:34 +04:00
nightwing
70337ea5ba fix infinite loop in soy mode and make tokenizer more robust 2014-11-05 16:42:39 +04:00
nightwing
78cda6bc3a update architect-build 2014-11-02 15:33:23 +04:00
nightwing
c83f39e4a9 update tests for ruby mode 2014-11-02 15:33:10 +04:00
nightwing
399e25ceaf fix errors in imported elixir mode 2014-11-02 15:32:26 +04:00
nightwing
4da689e71b add elixir mode 2014-11-02 15:06:12 +04:00
nightwing
ca9bc7a97a improve highlighting of ruby strings 2014-11-01 21:44:53 +04:00
nightwing
5b3bbba54e fix xquery mode breaking autocompletion and add tests 2014-11-01 19:27:40 +04:00
nightwing
671a8d6543 support nested comments in rust mode 2014-11-01 18:15:00 +04:00
nightwing
fd4be8535f Merge pull request #2216 from adamjimenez/php-delegate
use mode delegates in PHP
2014-10-31 15:18:02 +04:00
nightwing
366675a7a7 fix inline php mode 2014-10-31 15:08:44 +04:00
Adam Jimenez
2bd2e37367 fix php indentation 2014-10-30 01:52:38 +00:00
Harutyun Amirjanyan
e08a925870 Merge pull request #2218 from SomeKittens/master
Add COPY as a Docker command to be highlighted
2014-10-30 04:34:30 +04:00
Randall Koutnik
c0b37c1ac2 Add COPY as a Docker command to be highlighted 2014-10-29 17:09:09 -07:00
nightwing
2e8d7184e2 Merge pull/2215 2014-10-29 23:19:25 +04:00
nightwing
f121ca93ff update comment too 2014-10-29 23:18:09 +04:00
Adam Jimenez
b204cd7236 use mode delegates in PHP
fixes #2197
2014-10-29 17:01:41 +00:00
Bolutife Ogunsola
292d92ab8c Update documentation to reflect change introduced in 9253fffb9f 2014-10-29 14:25:21 +01:00
Bolutife Ogunsola
5b30207d74 Fix typo 2014-10-29 14:25:21 +01:00
Harutyun Amirjanyan
20cd631f0a Merge pull request #2198 from adamjimenez/patch-2
Autoindent doesn't always occur
2014-10-29 16:37:17 +04:00
Adam Jimenez
8e3da36bc7 autoindent tweaks
use camelcase and start line indent
2014-10-29 12:08:30 +00:00
Adam Jimenez
5e724c5ebd autoindent from start of tag 2014-10-29 10:13:20 +00:00
Adam Jimenez
b3d0c62a8d tidy up autoindent
use voidElements and double quotes.
2014-10-29 09:54:16 +00:00
Lennart Kats
695e24c418 Merge pull request #2210 from ajaxorg/misc
Fix several small issues
2014-10-28 11:04:05 +01:00
nightwing
3ef6bc2097 do not show error for empty json files 2014-10-27 21:35:51 +04:00
Harutyun Amirjanyan
e8419e5742 Merge pull request #2208 from coderaiser/patch-2
feature(package) v1.1.7
2014-10-27 13:05:04 +04:00
Harutyun Amirjanyan
2de76b5251 Merge pull request #2207 from coderaiser/patch-1
Simplified reading version from package.json
2014-10-27 13:04:17 +04:00
coderaiser
f3d9c588bd feature(package) v1.1.7 2014-10-25 18:35:41 +03:00
coderaiser
d068e2f737 feature(version) simplified reading version from package.json 2014-10-25 18:34:22 +03:00
nightwing
1a70ef15e2 fix #2190 autocomplete doesn't show tooltip when list initially appears 2014-10-25 03:25:44 +04:00
nightwing
58d166d647 do not add extra semicolon in built files 2014-10-25 02:07:06 +04:00
nightwing
fd5a6ade03 fix #2183 scrollPastEnd breaks vScrollBarAlwaysVisible=false option 2014-10-24 16:40:53 +04:00
Adam Jimenez
289ada0a2f don't indent after closing tag 2014-10-23 09:28:42 +01:00
Harutyun Amirjanyan
af859e2b0c Merge pull request #2189 from takapa/master
Improve tooltips
2014-10-21 19:55:27 +04:00
Harutyun Amirjanyan
94514a8456 Merge pull request #2200 from adamjimenez/patch-5
Fix string tooltips not showing
2014-10-21 18:19:46 +04:00
Harutyun Amirjanyan
1d39be41a6 Merge pull request #2201 from adamjimenez/patch-6
send completion data to completer callback
2014-10-21 18:19:38 +04:00
Adam Jimenez
7b01a4273e send completion data to completer callback 2014-10-21 12:46:29 +01:00
Adam Jimenez
bf8e9ddf45 Fix string tooltips not showing 2014-10-21 10:35:34 +01:00
Chris Ainsley
cef48f6887 Responded to suggestions by nightwing
Removed style changes (no style changes are part of the PR).

Only change now should be that we create a <div/> element instead of a <pre/> element.
2014-10-20 21:33:23 +01:00
Adam Jimenez
631695a0e4 Autoindent doesn't always occur
Currently autoindent only kicks in as so: 
```
<div>|</div>
```

This allows it to also work with:
```
<div>|

</div>
```
2014-10-20 17:30:26 +01:00
nightwing
525fe1ffe3 do not wrap change events in additional e.data 2014-10-18 00:56:13 +04:00
nightwing
bb827051a6 Merge branch 'master' into v-1.2
Conflicts:
	lib/ace/commands/command_manager.js
2014-10-17 19:25:02 +04:00
nightwing
c97858705d cleanup 2014-10-17 19:23:43 +04:00
Harutyun Amirjanyan
40a9c308b9 Merge pull request #2191 from maxh/patch-1
Fix errors in Anchor docs
2014-10-14 14:53:10 +04:00
Max Heinritz
f8bf6f253a Fix errors in Anchor docs
At least, I think they are errors.
2014-10-13 11:54:33 -07:00
DanyaPostfactum
6502a3d2cb Update tests for wrap indent 2014-10-12 18:37:52 +10:00
DanyaPostfactum
f625dfeea3 Add indentSubsequentLines to options 2014-10-12 18:37:20 +10:00
takapa
2636e5de5f Improve tooltips
Allow tooltips in div element (currently tooltips only allow items in pre element which is tricky to format). Also fix wrapping, remove gradient fill, and introduce a maximum width of 500px by default.
2014-10-12 01:20:27 +01:00
DanyaPostfactum
60367772a9 Add wrap indent 2014-10-12 01:56:19 +10:00
Lennart Kats
3af776df12 Merge pull request #2186 from ajaxorg/highlighter-fixes
Highlighter fixes
2014-10-11 17:16:48 +02:00
nightwing
43cdfd792f Add HACK and XXX 2014-10-10 23:54:19 +04:00
Lennart Kats
a02ca596b9 Merge pull request #2073 from ajaxorg/multihash
Allow binding multiple commands to one key
2014-10-10 15:41:23 +02:00
nightwing
ed40c1f51f improve tmlanguage.js 2014-10-10 02:05:15 +04:00
nightwing
9683d80f84 highlight todo in javascript comments 2014-10-09 20:49:25 +04:00
nightwing
52e8bc3082 add elm mode (fixes #2099) 2014-10-09 16:41:49 +04:00
nightwing
23c64c6ebb Add highlighting for raw string literals in rust mode. 2014-10-09 16:39:14 +04:00
nightwing
9cc394d3b9 Merge pull request #2169
allow removing completers
2014-10-09 01:32:30 +04:00
nightwing
38ce8b8919 less java:) 2014-10-09 01:30:05 +04:00
takapa
28b95df12c Added setCompleters(...) function
Added setCompleters() method, so that completers can be explicitly set from a pre-populated array, or can be removed entirely (if null is passed, or setCompleters() is called without an argument or an empty array is passed.

Please check this carefully for rookie JavaScript bugs, as I'm not sure if the null/undefined test is best-practise here as I don't typically code in JavaScript in my day-job.
2014-10-08 22:07:23 +01:00
Ruben Daniels
18f999fc47 Merge pull request #2174 from ajaxorg/autoscroll
AutoScrollEditorIntoView doesn't work for search
2014-10-06 16:57:58 -07:00
Ruben Daniels
0609c8e1a8 Merge pull request #2175 from ajaxorg/misc
Fix several small issues
2014-10-06 16:57:39 -07:00
Ruben Daniels
61ca159312 Merge pull request #2148 from ajaxorg/autocomplete
Add documentation tooltip for autocompleter
2014-10-06 16:57:16 -07:00
Harutyun Amirjanyan
cc40b8ceb8 Merge pull request #2177 from richo/fix-username
Fix @richo's username
2014-10-06 18:56:30 +04:00
Richo Healey
1a6bb0591b Fix @richo's username 2014-10-05 19:22:17 -07:00
nightwing
6814187c51 fix name of templates/highlight_rules.js 2014-10-05 23:07:34 +04:00
nightwing
29023787e5 Merge remote-tracking branch 'remotes/origin/master' into v-1.2
Conflicts:
	build
	lib/ace/document.js
	lib/ace/editor.js
2014-10-05 23:04:57 +04:00
nightwing
2983c4b19f do not throw when trying to add intersecting folds 2014-10-05 22:53:31 +04:00
nightwing
c2ce33f368 fix search.$assembleRegExp not working for multiline strings 2014-10-05 22:53:31 +04:00
nightwing
a1042e0d94 fix reattaching linewidgets to editor 2014-10-05 22:53:31 +04:00
nightwing
6c0bc56500 improve error handling in worker 2014-10-05 22:53:31 +04:00
nightwing
ab6aa3be5c fix gutter colors in theme importer 2014-10-05 22:53:31 +04:00
nightwing
14fc8adac2 cleanup mode_creator tool 2014-10-05 22:53:30 +04:00
nightwing
6867d1f4c6 fix several highlighter issues 2014-10-05 22:53:30 +04:00
nightwing
6e9ce4dbc8 fix #2173 AutoScrollEditorIntoView doesn't work for search 2014-10-05 00:14:10 +04:00
takapa
9b8385b07d Update language_tools.js
Added removeCompleters() function to language tools exports as it is not possible to access the completers array directly.

This is currently utilized by Ace GWT to cleardown existing completers (for entirely programmatic completers without snippets or  keyword completions) but I feel it belongs in the mainline (I have to manage a fork at the moment and there seems to be no other workaround).
2014-09-30 19:55:06 +01:00
Harutyun Amirjanyan
54e022fab2 Merge pull request #2168 from phungleson/patch-1
Change line comment start to //
2014-09-30 18:57:10 +04:00
Son
47b9c6c225 Change line comment start to //
http://doc.rust-lang.org/guide.html#comments
2014-09-30 22:07:53 +08:00
Harutyun Amirjanyan
cec6779003 Merge pull request #2165 from Newbrict/master
clipped trailing whitespace
2014-09-27 23:57:58 +04:00
Dimitar Dimitrov
753fa6b904 clipped trailing whitespace 2014-09-27 13:58:04 -04:00
Harutyun Amirjanyan
f4356993b2 Merge pull request #2157 from cvoege/master
Added Find All Functionality to Ctrl-F searchbox.
2014-09-27 13:35:16 +04:00
Colton Voege
4b44bad687 Replace all with Alt-Enter fixed. 2014-09-25 12:57:32 -04:00
Colton Voege
a33cc3223a Merge branch 'master' of https://github.com/ajaxorg/ace 2014-09-25 12:54:50 -04:00
nightwing
1bb84debca update build submodule 2014-09-21 00:14:53 +04:00
nightwing
c62b0b134f fix regression in ace_popup 2014-09-21 00:04:01 +04:00
Harutyun Amirjanyan
79eda6d2a8 Merge pull request #2111 from wcandillon/patch-3
Update XQLint dependency
2014-09-20 12:35:08 +04:00
Ruben Daniels
961eee344c Merge pull request #2159 from ajaxorg/misc
Fix several small issues
2014-09-20 10:10:04 +02:00
nightwing
8a306d8a8e workaround for inaccurate font rendering on chrome 37 2014-09-20 01:43:52 +04:00
nightwing
121835bed8 add menuitem to the list of void tags 2014-09-20 00:07:54 +04:00
Colton Voege
378a72a91c Added Find All functionality to searchbox. 2014-09-17 13:33:29 -04:00
Ruben Daniels
a0327aebd9 Merge pull request #2156 from ajaxorg/dragcursor
improve drag cursor on windows
2014-09-17 15:20:33 +02:00
Ruben Daniels
0989419251 Merge pull request #2155 from ajaxorg/keyboard/emacs
fix #2154 Emacs copy/paste issue with highlighting marker
2014-09-17 15:20:12 +02:00
nightwing
b25f4b6a10 fix #2154 Emacs copy/paste issue with highlighting marker 2014-09-17 17:05:38 +04:00
nightwing
f68ca6266a improve drag cursor on windows 2014-09-16 00:34:39 +04:00
nightwing
953e452f70 add doc tooltip 2014-09-13 03:22:55 +04:00
Ruben Daniels
e894b5f9e0 Merge pull request #2137 from ajaxorg/autocomplete
Fix several small issues
2014-09-12 20:18:22 +02:00
Ruben Daniels
74f7d0095b Merge pull request #2135 from ajaxorg/tool/add_mode
Add tool/add_mode.js for creating stub files for a new mode
2014-09-12 20:18:07 +02:00
Ruben Daniels
c029ba57c5 Merge pull request #2138 from ajaxorg/demo/warn
show warning if build/src/ace.js is missing
2014-09-12 20:17:56 +02:00
Harutyun Amirjanyan
8cc22b10eb Merge pull request #2145 from tobiasahlin/clean-up-css
Clean up CSS
2014-09-12 20:58:44 +04:00
Tobias Ahlin
ec3750edcb float triggers display block 2014-09-11 10:26:49 +02:00
Tobias Ahlin
bde7daaf1b Use animation and font shorthand 2014-09-11 10:26:13 +02:00
Tobias Ahlin
6593e25de6 Keyframes can share values 2014-09-11 10:25:52 +02:00
Tobias Ahlin
87dcd881e3 Use font shorthand 2014-09-11 10:18:23 +02:00
Tobias Ahlin
eabb4b2cb5 float triggers display: block 2014-09-11 10:17:55 +02:00
Tobias Ahlin
6a0a108d2a Vendor prefixes are not needed for border-radius 2014-09-11 09:11:54 +02:00
Tobias Ahlin
a36e7bb0c1 position: fixed triggers display: block 2014-09-11 09:11:32 +02:00
Tobias Ahlin
f103d2632c px is redundant for zero values 2014-09-11 09:06:33 +02:00
Tobias Ahlin
f4afa89d4e Vendor prefixes aren't necessary for box-shadow 2014-09-11 00:55:33 +02:00
Tobias Ahlin
a89e3d0d9d Only -webkit prefix for transitions is necessary
Android and iOS safari both support it without the prefix, but hasn’t
for long
2014-09-11 00:53:25 +02:00
Tobias Ahlin
2cdd9fef70 Use font shorthand for ace_editor 2014-09-11 00:47:41 +02:00
Harutyun Amirjanyan
4ff4d1ee43 Merge pull request #2144 from girving/doc-fix
Fix documentation typo: "includeText" should be "insertText"
2014-09-11 01:58:48 +04:00
Geoffrey Irving
6795b35135 Fix documentation type: "includeText" should be "insertText" 2014-09-10 14:43:36 -07:00
Harutyun Amirjanyan
706f2ea172 Merge pull request #2143 from p2004a/fix-filteredlist-behaviour
Changed FilteredList.setFilter unique matches computing in autocomplete.js
2014-09-10 17:47:25 +04:00
nightwing
d2b6b43679 Merge branch 'pull/2139' 2014-09-10 17:18:36 +04:00
nightwing
aec7db80d8 fix more typos 2014-09-10 17:17:11 +04:00
Marek Rusinowski
c0c99ad5c6 changed FilteredList.setFilter unique matches computing 2014-09-10 12:35:04 +02:00
Chris Schmich
91db934fe6 Fixing another typo. 2014-09-09 20:33:09 -05:00
Chris Schmich
8b996b0a09 Fix typo. 2014-09-09 20:29:44 -05:00
nightwing
fb16e59f03 do not trigger keyLocation warning (fixes #1731) 2014-09-10 04:29:43 +04:00
nightwing
cdaf4c1539 show warning if build/src/ace.js is missing 2014-09-10 04:12:42 +04:00
nightwing
1bce1b2a60 cleanup tools directory 2014-09-09 21:44:27 +04:00
nightwing
dbeeea2dd9 add helper tool for starting new mode 2014-09-09 21:18:52 +04:00
nightwing
bd95f782d8 close completion popup when backspacing to empty string 2014-09-07 17:22:04 +04:00
nightwing
e6660cd47c improve matlab highlighting fixes #2042, #2043 2014-09-07 17:21:36 +04:00
nightwing
5f6782d949 fix #2103 completion filtering doesn't work when started with empty prefix 2014-09-07 15:00:21 +04:00
nightwing
e8f7419131 fix #2054 Completer ignores better match if autoinsert is enabled 2014-09-07 14:46:20 +04:00
nightwing
bb76c62c7b fix several ie8 issues 2014-09-06 02:23:37 +04:00
nightwing
c0741f3511 fix #2119 Soft Hyphen (U+00AD) breaks cursor position calculation 2014-09-05 23:55:16 +04:00
nightwing
36f62e3792 fix #1840 The last CJK character of a wrapped line drops down 2014-09-05 23:53:16 +04:00
Lennart Kats
badade8f4e Merge pull request #2125 from ajaxorg/highlighter-fixes
Highlighter fixes
2014-09-02 16:44:48 +02:00
Harutyun Amirjanyan
8a91b43b67 Merge pull request #2117 from camertron/sql_union
Adding highlight support for the UNION SQL keyword
2014-09-02 15:27:35 +04:00
nightwing
3d6b93b946 update tests 2014-09-02 15:12:15 +04:00
nightwing
30f7f8a3f2 add es6 template string highlighting to javascript mode 2014-09-02 13:42:59 +04:00
nightwing
9f2fba320d fix herestring highlighting in sh mode 2014-09-02 13:04:33 +04:00
nightwing
09ddbeb341 add Io mode 2014-09-02 12:55:58 +04:00
nightwing
7a3a84c858 fix error in coffeeScript mode 2014-09-02 01:16:10 +04:00
Cameron Dutro
0d8865bcfe Adding highlight support for the UNION sql keyword 2014-08-27 20:01:31 -06:00
nightwing
69edbf9460 github pages now requires https submodule urls 2014-08-27 17:30:12 +04:00
Harutyun Amirjanyan
9bc0dbd788 Merge pull request #2115 from danyaPostfactum/dragdropfix
Make DragdropHandler more bulletproof
2014-08-27 15:10:45 +02:00
DanyaPostfactum
f9591eb16f Make DragdropHandler more bulletproof 2014-08-24 00:37:06 +10:00
William Candillon
bf8b6806a0 Update XQLint dependency
fixes #2108
2014-08-21 21:42:14 +02:00
Harutyun Amirjanyan
3c4afde47b Merge pull request #2080 from jpallen/master
Keep apparent scroll position fixed when changes are made offscreen
2014-08-20 15:49:03 +04:00
Harutyun Amirjanyan
60dd9156fe Merge pull request #2104 from Razer6/vhdl_mode
Add VHDL to modelist
2014-08-19 17:29:31 +04:00
Robert Schilling
fd2e51f120 Add VHDL mode 2014-08-18 22:17:39 +02:00
nightwing
bb4f7a0f1b update build 2014-08-17 15:21:17 +04:00
Lennart Kats
df58b5b710 Merge pull request #2096 from ajaxorg/old-worker
Allow using uiWorker on ie9 where Worker is undefined
2014-08-14 11:08:40 +02:00
nightwing
084dd4c132 fix regression in loading workers in packed mode 2014-08-14 12:49:00 +04:00
nightwing
6682c18ab3 allow using uiWorker on ie9 where Worker is undefined 2014-08-14 12:41:57 +04:00
Zef Hemel
d6c51fe898 Fix Docker highlighter again 2014-08-14 09:42:32 +02:00
Zef Hemel
5ba99b5fd4 Updated Dockerfile highlighter
Now uses constants rather than variables (which in many highlighters don't appear any differently).
2014-08-14 09:36:57 +02:00
Harutyun Amirjanyan
97d39e2912 Merge pull request #2095 from ajaxorg/revert-2076-no-auto-scroll
Revert "Disable automatic scroll into view"
2014-08-13 23:11:14 +04:00
Harutyun Amirjanyan
217635fe67 Merge pull request #2094 from ajaxorg/ruby-behaviors
Enabled C-style behaviors for Ruby
2014-08-13 22:57:22 +04:00
Harutyun Amirjanyan
1dc42fd46e Revert "Disable automatic scroll into view" 2014-08-13 22:53:35 +04:00
Zef Hemel
1f14f3fc32 Enabled C-style behaviors for Ruby which are pretty much accurate. 2014-08-13 20:44:51 +02:00
Harutyun Amirjanyan
706b7815e3 Merge pull request #2089 from dfelder/master
Some more highlight rules for latex mode
2014-08-13 00:47:59 +04:00
Daniel Felder
ed320af6f4 fix code folding in equation mode 2014-08-11 12:21:20 +00:00
Daniel Felder
b01fe5de13 cleanup 2014-08-11 11:59:42 +00:00
Daniel Felder
917c4da39d cleanup 2014-08-11 11:57:29 +00:00
Daniel Felder
b8c111b832 add folding for paragraph 2014-08-11 11:54:15 +00:00
Daniel Felder
c3411631a1 highlight input command 2014-08-11 11:51:38 +00:00
Daniel Felder
e227811a21 highlight input command 2014-08-11 11:46:27 +00:00
Harutyun Amirjanyan
fe9b95f9e2 Merge pull request #2090 from adamjcook/gcode
Adding G-code (ISO 6983) language mode.
2014-08-11 15:41:43 +04:00
Daniel Felder
f79a7a7b0b exit equation mode on empty lines 2014-08-11 11:40:16 +00:00
Daniel Felder
2f56fb208c allow comments in equation, default token in equation 2014-08-11 11:03:43 +00:00
Daniel Felder
114166a0ce fix code folding 2014-08-11 11:02:43 +00:00
Daniel Felder
69dcab3479 Merge https://github.com/ajaxorg/ace 2014-08-11 09:20:25 +00:00
Daniel Felder
9fb80fb72c simplifications and different highlight for labels etc. 2014-08-11 09:13:50 +00:00
Daniel Felder
b4dc4b7694 adjust tests 2014-08-11 09:12:46 +00:00
Adam Joseph Cook
37aa485137 Adding G-code (ISO 6983) language mode. 2014-08-10 22:24:52 -05:00
Lennart Kats
549df3c756 Merge pull request #2087 from ajaxorg/destroy
destroy session when destroying the editor
2014-08-10 11:26:07 +02:00
Lennart Kats
2fda9268f3 Merge pull request #2088 from ajaxorg/misc
Code cleanup + minor fixes
2014-08-10 11:24:41 +02:00
Lennart Kats
3752d20b13 Merge pull request #2086 from ajaxorg/textinput
IME issues
2014-08-10 10:56:28 +02:00
Lennart Kats
5f8c5e0fb6 Merge pull request #2077 from ajaxorg/mode/css
update csslint
2014-08-10 10:55:31 +02:00
Lennart Kats
5348712ce2 Merge pull request #2076 from ajaxorg/no-auto-scroll
Disable automatic scroll into view
2014-08-10 10:55:18 +02:00
Lennart Kats
4b5409c5cb Merge pull request #2070 from ajaxorg/static-highlight
accept mode options object in static highlight extension
2014-08-10 10:50:32 +02:00
Lennart Kats
b714925ed8 Merge pull request #2063 from ajaxorg/fix/build
do not rename kr_theme to kr during the build
2014-08-10 10:49:50 +02:00
Daniel Felder
4115fd24b3 adjust tests 2014-08-10 01:40:09 +00:00
Daniel Felder
b5560a9cad adjust tests 2014-08-10 01:18:28 +00:00
Daniel Felder
d029129b28 lparen, rparen in block 2014-08-10 01:17:39 +00:00
Daniel Felder
b8f135a37d adjustments to latex mode 2014-08-10 00:29:39 +00:00
Daniel Felder
08bf3696e7 some more syntax highlighting for latex mode 2014-08-10 00:02:33 +00:00
nightwing
9b489c752b minor fixes 2014-08-09 22:32:07 +04:00
nightwing
10860343ab fix error when inserting text inside code 2014-08-09 22:32:07 +04:00
nightwing
1bd38560b4 code style 2014-08-09 22:32:07 +04:00
nightwing
383b798901 disable automatic scroll into view 2014-08-09 22:22:49 +04:00
nightwing
dc37f938c9 destroy session when destroying the editor 2014-08-09 18:48:43 +04:00
nightwing
920cd20327 improve ime style 2014-08-09 18:44:24 +04:00
nightwing
d493325973 make sure editor container never scrolls because of out of view textarea 2014-08-09 18:44:24 +04:00
Harutyun Amirjanyan
ffc547d2c3 Merge pull request #2079 from buildersbrewery/master
Updated LSL language
2014-08-08 22:28:26 +04:00
Harutyun Amirjanyan
e2ab837178 Merge pull request #2084 from jpallen/patch-1
Don't ignore contextmenu event in Firefox on Windows/Linux
2014-08-08 22:27:44 +04:00
James Allen
1109188a93 Don't ignore contextmenu event in Firefox on Windows/Linux 2014-08-08 18:28:41 +01:00
James Allen
146d832e19 Keep apparent scroll position fixed when changes are made offscreen 2014-08-06 13:59:11 +01:00
Zef Hemel
2859373983 Merge pull request #2075 from ajaxorg/highlighter-fixes
Highlighter fixes
2014-08-05 11:56:34 +02:00
nightwing
0842d27710 fix failing test
allow folding <p> tags
2014-08-04 18:27:45 +04:00
Builder's Brewery
89b5597948 Updated regex for entity.name.state.lsl 2014-08-04 15:52:57 +02:00
Builder's Brewery
36198a50f4 Updated LSL snippets 2014-08-04 15:38:52 +02:00
Builder's Brewery
91cc993bb2 Updated LSL keywords 2014-08-04 15:24:56 +02:00
nightwing
b69f7450aa fix autoclosing of p tag 2014-08-02 01:02:52 +04:00
nightwing
d120d050fb update test 2014-08-02 01:02:03 +04:00
nightwing
518166324b add constexpr keyword to c++ 2014-08-02 01:02:03 +04:00
nightwing
0eff326d62 tweak modes 2014-08-02 01:01:46 +04:00
nightwing
b990ad3f90 update csslint 2014-08-02 00:57:21 +04:00
nightwing
dfee740802 update command_manager test 2014-08-01 22:33:32 +04:00
nightwing
5744a3c6e3 fix bracket matching in vala mode 2014-08-01 22:12:45 +04:00
nightwing
ec6ffec1e4 Merge branch 'missing-redraw' 2014-08-01 22:07:25 +04:00
nightwing
72dcd28905 trigger redraw less often 2014-08-01 22:06:43 +04:00
nightwing
f4990b3a56 make sure text redraw isn't missed when bgTokenizer state changes 2014-08-01 21:52:25 +04:00
nightwing
d01cbaf698 Merge pull request #2041 from jpallen:master
Redraw lines and active line highlight when offscreen updates are made
2014-08-01 21:50:51 +04:00
Harutyun Amirjanyan
f80dea7915 Merge pull request #2066 from gatof81/master
ie11 fix getBoundingClientRect() error
2014-08-01 21:47:27 +04:00
nightwing
a00ce9cd72 update keyboard shortcuts extension 2014-08-01 20:47:49 +04:00
nightwing
b2612c6039 cleanup emmet extension 2014-08-01 20:19:17 +04:00
nightwing
c673190bf7 allow binding multiple commands to same key 2014-07-29 17:40:19 +04:00
Diego Ferreyra
b0babd3f25 ie11 fix getBoundingClientRect() error missing ";" 2014-07-28 14:37:15 -03:00
Diego Ferreyra
7ab9ce686f ie11 fix getBoundingClientRect() error 2014-07-28 14:34:39 -03:00
nightwing
80f42e13ff accept mode options object in static highlight extension 2014-07-28 19:10:41 +04:00
Diego Ferreyra
d40bec839d ie11 fix getBoundingClientRect() error 2014-07-24 17:14:40 -03:00
nightwing
23f678229a update config_test.js 2014-07-22 16:57:14 +04:00
nightwing
0eaae8712e do not rename kr_theme to kr during the build 2014-07-22 16:32:40 +04:00
Lennart Kats
f3d4147f6b Merge pull request #2023 from ajaxorg/edit_textarea
Do not hang the browser when ace.edit is called for textarea
2014-07-21 14:07:47 +02:00
Lennart Kats
c079a49ce7 Merge pull request #2053 from ajaxorg/fix/highlighting
Fix highlighting issues
2014-07-21 14:07:20 +02:00
Lennart Kats
b71a09d8d0 Merge pull request #2052 from ajaxorg/double_tap
fix Double tapping to select words doesn't work reliably
2014-07-21 14:06:19 +02:00
Harutyun Amirjanyan
c073766cc3 Merge pull request #2055 from Conaclos/working
Eiffel programming language mode
2014-07-21 04:37:47 +04:00
Conaclos
b651a424f1 Adding the new Eiffel example. 2014-07-20 19:12:34 +02:00
Conaclos
9284732a28 Remove eiffel example.
Current example is too large.
2014-07-20 19:12:03 +02:00
Conaclos
7e55724c52 Add comment mark in Eiffel mode. 2014-07-20 19:10:50 +02:00
Conaclos
fcd1dbb98d Adding Eiffel language mode.
- Adding Eiffel highlight rules and Eiffel mode
- Use Sudoku grid example of Eiffel Rosetta Code project as Eiffel example
2014-07-20 17:22:21 +02:00
nightwing
d53c91e41a update mode tests 2014-07-16 23:29:37 +04:00
nightwing
1ad5e66be0 fix #2051 highlighting php string in script tag 2014-07-16 23:27:20 +04:00
nightwing
a52b30317b add heredoc support for sh mode 2014-07-16 22:50:12 +04:00
nightwing
c1c08945b2 do not scroll cursor into view after quad click 2014-07-16 22:46:35 +04:00
nightwing
d3d2e0823b fix Double tapping to select words doesn't work reliably 2014-07-16 19:03:23 +04:00
Harutyun Amirjanyan
3b85ddfa05 Merge pull request #2048 from dfelder/patch-1
Update latex.js
2014-07-15 14:25:18 +04:00
Daniel Felder
0afb5f6da6 Update latex.js
Most of LaTeX is text. Word wrapping etc. should behave accordingly.
2014-07-15 01:38:50 +02:00
Harutyun Amirjanyan
e9faed1868 Merge pull request #2040 from devoncarew/devoncarew_show_hide_dart
add the show and hide keywords to the dart mode
2014-07-10 22:24:55 +04:00
James Allen
fd182ea76f Redraw lines and active line highlight when offscreen updates are made
When setUseWrapMode is true, if some text is inserted into a line which is
above the cursor and offscreen, then the renderer did not previously redraw the
lines or active line highlight. However, if this insert causes the line to wrap
onto another line then everything is shifted down by one visual line, leaving
the onscreen lines in an out of date state. With this commit, the onscreen
lines and active line highlight are now redrawn when this happens.
2014-07-10 12:56:11 +01:00
Devon Carew
a885aea2f0 add the show and hide keywords to the dart mode 2014-07-09 16:22:24 -07:00
Harutyun Amirjanyan
4b286a5c0d Merge pull request #2036 from jjatria/praat
Praat syntax highlighting rules
2014-07-09 21:02:18 +04:00
nightwing
a3bb907f46 v1.1.5 2014-07-09 18:32:00 +04:00
baboso
5ebcf9298b Merge branch 'master' of git://github.com/ajaxorg/ace into praat 2014-07-08 15:22:40 -04:00
baboso
4904f74dbd Minor changes to Praat syntax files 2014-07-08 15:18:57 -04:00
Harutyun Amirjanyan
d3ddd74fe7 Merge pull request #2029 from devoncarew/devoncarew_gitignore
Devoncarew gitignore
2014-07-07 19:30:04 +04:00
Devon Carew
cc03e77327 review comments 2014-07-07 08:17:25 -07:00
Fabian Jakobs
779912d517 Merge pull request #2027 from ajaxorg/autocomplete
Tweak autocomplete
2014-07-07 15:08:28 +02:00
Devon Carew
e6f01878d7 add snippets; fix the kitchensink demo 2014-07-04 11:35:07 -07:00
Devon Carew
bf72097811 add a gitignore mode 2014-07-04 11:25:53 -07:00
Ruben Daniels
c3bb709318 Merge pull request #2022 from ajaxorg/performance
do not use setInnerHTML since it isn't faster on new browsers
2014-07-03 13:53:19 +02:00
nightwing
8ed2799620 do not close the popup if there are matching completions 2014-07-03 00:12:27 +04:00
nightwing
f8be5072ac allow using name instead of caption 2014-07-02 23:56:24 +04:00
nightwing
f9b3655c94 fix autocomplete popup click regression 2014-07-02 23:38:11 +04:00
nightwing
ad54d2c46c disabled validateDelta since it breaks autocompletion popup 2014-07-02 22:04:32 +04:00
nightwing
1f7582b5a6 Merge remote-tracking branch 'remotes/origin/master' into v-1.2
Conflicts:
	lib/ace/anchor.js
	lib/ace/keyboard/vim/maps/operators.js
2014-07-02 21:58:13 +04:00
nightwing
109923873a do not hang the browser when edit is called for textarea 2014-07-02 10:58:21 +04:00
Harutyun Amirjanyan
7fbfbc4c16 Merge pull request #2025 from devoncarew/master
add the export keyword to dart
2014-07-02 07:43:30 +04:00
Devon Carew
2ce7ed0f44 add the export keyword to dart 2014-07-01 16:15:45 -07:00
nightwing
ccfb820418 add test for whitespace extension 2014-07-01 01:32:24 +04:00
nightwing
b5eda22bfc update changelog 2014-07-01 01:21:09 +04:00
nightwing
299d174dc7 do not use setInnerHTML since it isn't faster on new browsers 2014-06-29 09:58:48 +04:00
Harutyun Amirjanyan
416f5582e8 Merge pull request #2021 from devoncarew/master
remove the invalid rule from the go syntax file
2014-06-29 09:48:51 +04:00
Devon Carew
f8b7dce3e0 remove the invalid rule from the go syntax file 2014-06-28 22:21:52 -07:00
Harutyun Amirjanyan
63f43da96a Merge pull request #2012 from hartman/dragDelay
Match platform specifics for dragDelay of text
2014-06-27 20:07:43 +04:00
Derk-Jan Hartman
2dcc4a3f04 Match platform specifics for dragDelay of text
On Mac we keep it at 150ms. On other platforms it either
does not exist or at most it's very small.

This fixes issue #1879
2014-06-27 14:20:09 +02:00
nightwing
0450a1a539 remove unneeded setOption call 2014-06-25 19:01:06 +04:00
Lennart Kats
fdbd11d3df Merge pull request #2014 from ajaxorg/build
Use architect-build for building ace
2014-06-23 12:21:04 +02:00
Harutyun Amirjanyan
14f5095c92 Merge pull request #2005 from ajaxorg/overridable-mergeables
Make mergeable commands (for undo history) overridable.
2014-06-23 00:31:18 +04:00
Zef Hemel
1dd41ea75d Make mergeable commands (for undo history) overridable. 2014-06-23 00:12:20 +04:00
nightwing
ce070285a4 Merge remote-tracking branch 'remotes/origin/keybinding' 2014-06-22 23:49:13 +04:00
nightwing
3ebc2828e6 add textarea keybinding (probably fixes #36) 2014-06-22 23:44:59 +04:00
nightwing
6aaede1a2e keep mac line movement keybindings (still overridden by jumptomatching) 2014-06-22 23:33:45 +04:00
Harutyun Amirjanyan
8c86ff6fab Merge pull request #2013 from rmsmith/master
mode/applescript : set the `$id` to the correct value
2014-06-21 22:51:55 +04:00
rmsmith
739e86cde7 mode/applescript : set the $id to the correct value
This brings the new applescript mode into alignment with the other modes
per #1778
2014-06-21 19:15:52 +03:00
nightwing
6714359998 tweak 2014-06-21 01:48:07 +04:00
nightwing
e5b2eed5c5 add architect build to package.json 2014-06-20 20:55:21 +04:00
nightwing
e52884761d keep demo/kitchein-sink folders location in the build 2014-06-20 20:55:21 +04:00
nightwing
b42108a2c9 remove unnecessary use of async 2014-06-20 20:55:12 +04:00
nightwing
d63863ac0c use architect-build for building ace 2014-06-20 02:27:50 +04:00
nightwing
fcb3331d69 remove special build version for bookmarklet 2014-06-20 02:26:10 +04:00
Adam Jimenez
08bfa14dd2 jumptomatching/ selecttomatching mac shortcut
fixes #2007
2014-06-19 23:06:52 +01:00
Harutyun Amirjanyan
ffe22ce2be Merge pull request #2009 from themgt/master
adding package.json start script
2014-06-18 11:05:47 +04:00
Harutyun Amirjanyan
bdd54043b5 Merge pull request #2004 from tomalec/html-import-issue
Use current document to process <script> tags (fixes ajaxorg/ace#2003)
2014-06-18 11:05:26 +04:00
Paul
9a4bb06bb7 adding package.json start script 2014-06-16 14:08:34 -04:00
Tomek Wytrebowicz
3ce44130d4 comment the need of ownerDocument ajaxorg/ace#2003 2014-06-16 13:48:18 +02:00
Harutyun Amirjanyan
8db9dc255a Merge pull request #1994 from hitode909/fix-is-gecko
useragent.isGecko is false on Firefox 29
2014-06-16 15:05:39 +04:00
Ruben Daniels
5496351529 Merge pull request #1985 from ajaxorg/focus
fix issue with scrolling into view on focus
2014-06-16 12:34:23 +02:00
Ruben Daniels
f25b14a328 Merge pull request #1982 from ajaxorg/misc
Sync with cloud9 version
2014-06-16 12:34:04 +02:00
Tomek Wytrebowicz
b8c21d4c6f Use current document to process <script> tags (fixes ajaxorg/ace#2003) 2014-06-13 01:58:05 +02:00
nightwing
c5031db61c fix tests 2014-06-09 23:44:27 +04:00
baboso
84a8201dfd Removed useless rule 2014-06-05 18:44:20 -04:00
hitode909
84abfa5ff8 window.controllers was renamed to window.Controllers in Firefox 29
useragent.isGecko was false on Firefox 29
2014-06-05 14:10:25 +09:00
baboso
17c75da27b Added sendpraat and unquoted string directives, simplified demo example, added some other missing functions/directives 2014-06-05 00:45:20 -04:00
baboso
a519520ae7 Removed useless rules, added support for do() syntax 2014-06-04 18:03:55 -04:00
José Joaquín Atria
d57e010ca3 Added single number font size changing commands (praat) 2014-06-03 15:10:31 -04:00
José Joaquín Atria
08afa03cb9 Fixed operators and introduced broken lines 2014-06-03 14:32:55 -04:00
baboso
df92a99e93 Praat syntax highlighter, first release 2014-06-01 18:27:03 -04:00
baboso
e4355adae7 Initial commit for praat highlighting: based on Perl 2014-05-31 19:51:41 -04:00
nightwing
1c2bc29424 fix selecting with ctrl-alt click 2014-05-28 01:25:18 +04:00
nightwing
66866121e9 fix issue with scrolling into view on focus 2014-05-23 14:13:23 +04:00
nightwing
d0acc15e67 fix #1973 custom array of autocompleters never used 2014-05-23 00:16:31 +04:00
nightwing
7e2dda1e18 allow tokenizer states with only defaultToken 2014-05-21 20:38:07 +04:00
nightwing
72a509e542 improve ruby outdent 2014-05-21 20:32:34 +04:00
nightwing
4872441bc6 fix vim cc 2014-05-21 20:32:08 +04:00
nightwing
ba93cc6dfa fix tab detection 2014-05-21 20:30:47 +04:00
nightwing
88aed65212 fix home key on folded line 2014-05-21 20:26:13 +04:00
nightwing
9ab12a6ed3 fix ctrl-shift-mousedown 2014-05-21 20:07:07 +04:00
nightwing
4e2d7a41f5 update jshint 2014-05-21 18:16:08 +04:00
nightwing
ec97ad7904 Merge remote-tracking branch 'remotes/origin/master' into v-1.2
Conflicts:
	build
	lib/ace/document.js
2014-03-31 00:49:41 +04:00
nightwing
27b6d6dcd3 apply arguments max length also includes actual call stack 2014-02-15 00:20:10 +04:00
nightwing
6b60bcbbd6 continue refactoring 2014-02-14 23:52:59 +04:00
nightwing
46f3d77068 simplify apply_delta.js 2014-02-14 22:33:30 +04:00
nightwing
c8d1df203e restore single line delta optimization in anchor.js 2014-02-14 22:32:51 +04:00
nightwing
4299db01bd remove delta.range 2014-02-14 22:32:31 +04:00
nightwing
b5af2c898c Merge remote-tracking branch 'remotes/origin/master'
Conflicts:
	lib/ace/document.js
	lib/ace/editor.js
	lib/ace/undomanager.js
2014-02-14 18:23:03 +04:00
nightwing
c8fca3053c Merge remote-tracking branch 'remotes/origin/master'
Conflicts:
	lib/ace/line_widgets.js
2014-01-16 00:14:34 +04:00
nightwing
8d57d8765f Merge pull request #1745 aldendaniels:master into v-1.2
Refactor document delta handling
2014-01-16 00:11:00 +04:00
aldendaniels
7f1bc7af2f Break out Anchor.onChange helper functions
This should be faster since we don't have to re-initialize the helper
functions each time Anchor.onChange is fired.
2014-01-11 15:48:38 -06:00
aldendaniels
6b280bf6bb Code review fixes (mostly formatting)
- Fix unconventional '{' formatting
- Reformat `UndoManager` changes
- Revert change from `insertInLine` to `insert` in text.js
2014-01-11 15:23:20 -06:00
aldendaniels
35a27fd1ba Treat deltas with empty ranges as NOOPs 2014-01-11 14:45:08 -06:00
aldendaniels
ddd695ee3f Store single-line deltas as .text instead of .lines in undo history
Stores single-line delta content as .text instead of .lines in undo
history. This is done without modifying the original delta object in
case the caller still retains a handle to the original.
2014-01-11 14:43:47 -06:00
aldendaniels
f59708a5ba Add a doNotValidate param to applyDelta
Set it to true in insertInLine/removeInLine.

Also sped up indent/dedent by using insertInLine and removeInLine.
2014-01-11 12:00:10 -06:00
aldendaniels
ef0e8da522 Fix / complete validateDelta
This uncovered the fact that until now delta.range had not always been a
Range object. This inconsistency has been resolved by my changes in
mirror.js.
2014-01-11 11:20:34 -06:00
aldendaniels
08edcdfc98 Stop doing a line-by-line splicing in applyDelta
Also brings back the functionality where large deltas are split into
smaller deltas so that .splice.apply() calls will work.
2014-01-10 22:49:17 -06:00
aldendaniels
3a048cdf61 Bring back insertInLine
Avoids an extra $split call.
2014-01-08 22:51:39 -06:00
aldendaniels
f2a2e4e1a8 Rename the 'delete' delta action to 'remove'
Matches previous naming convention.
2014-01-08 22:18:05 -06:00
aldendaniels
6fe381f633 Rename insertText back to insert 2014-01-08 22:00:11 -06:00
aldendaniels
91df7cd663 Revert "Stop using splice.appy() in ace"
This reverts commit 8624ab8dcb.
2014-01-08 21:39:30 -06:00
aldendaniels
8624ab8dcb Stop using splice.appy() in ace
Since .apply() can't handle more than 65535 parameters, splice.apply()
is brittle. It's also hard to read. This replaces splice.apply() calls
throughout ace code with lang.spliceIntoArray().
2014-01-04 01:59:30 -06:00
aldendaniels
b503e65e03 Break on applyDelta into its own module
This makes it possible to break out helper functions without exposing
them to the rest of the document class. Also, long term, we may want to
have a stand-alone test suite for applyDelta, so it makes sense in its
own file.

All other changes involve syntax corrections (some syntax issues were
mine, others pre-existed) to make the documentation compilation work.
2014-01-03 14:59:22 -06:00
aldendaniels
612478e39f Speed up single-line deltas
2e6f12725b slowed down the application of
deltas that only affect a single line. The slow-down, though trivial for
a single line, is significant for operations than separately modify
thousands of rows (such as indenting a large document).

This commit speeds up single-line deltas by avoiding unnecessary calls
to splitLine() and joinLineWithNext().
2014-01-01 14:45:54 -06:00
aldendaniels
810e196cc6 Use console.warn for deprecated methods
console.warn makes better sense than console.log and matches similar
warnings in ace (see gutter.js for example).
2014-01-01 12:06:19 -06:00
aldendaniels
026af74016 Fix render bugs
Both were introduced in 2e6f12725b.
2014-01-01 12:04:12 -06:00
aldendaniels
27768230c8 Maintain public API and update coding convention
This seeks to keep the public API in-tact while improving method names
within ace by keeping the old methods as wrappers around the new
better-named methods.

For example, document.insert() now simply calls document.insertText()
and warns the caller via a console.log() that they are using a
deprecated method.

I've also updated the coding style of my changes (where I noticed
discrepancies) to match the rest of Ace.
2014-01-01 11:05:27 -06:00
aldendaniels
2e6f12725b #1744: Refactor document delta handling
Refactor delta handling code to:

- Combine the "insertText" and "insertLines" delta types into a single
"insert" delta type

- Combine the "removeText" and "removeLines" delta types into a single
"remove" delta type

- Make all document mutations in a single applyDelta function.

- Add basic delta validation (more needed . . . see TODOs)

- Rework anchor logic to handle new delta types (also simplified)

- Rename "insert()" to "insertText()" and "remove()" to "removeText()"

- Rename "insertLines()" to "insertFullLines()" and "removeLines()" to
"removeFullLines()"

See related issue for more information. All tests are passing and the
changes appear functional under preliminary testing, but careful review
and testing will be necessary.
2014-01-01 00:41:45 -06:00
368 changed files with 120076 additions and 93656 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
.DS_Store
*.swp
*.tmp
*~
# Project files that should not be in the repo
.*

4
.gitmodules vendored
View file

@ -1,6 +1,6 @@
[submodule "doc/wiki"]
path = doc/wiki
url = git://github.com/ajaxorg/ace.wiki.git
url = https://github.com/ajaxorg/ace.wiki.git
[submodule "build"]
path = build
url = git://github.com/ajaxorg/ace-builds.git
url = https://github.com/ajaxorg/ace-builds.git

View file

@ -7,16 +7,9 @@ Feel free to fork and improve/enhance Ace any way you want. If you feel that the
There are two versions of the agreement:
1. [The Individual CLA](https://github.com/ajaxorg/ace/raw/master/doc/Contributor_License_Agreement-v2.pdf): use this version if you're working on an ajax.org in your spare time, or can clearly claim ownership of copyright in what you'll be submitting.
2. [The Corporate CLA](https://github.com/ajaxorg/ace/raw/master/doc/Corporate_Contributor_License_Agreement-v2.pdf): have your corporate lawyer review and submit this if your company is going to be contributing to ajax.org projects
1. [The Individual CLA](https://docs.google.com/a/c9.io/forms/d/1MfmfrxqD_PNlNsuK0lC2KSelRLxGLGfh_wEcG0ijVvo/viewform): use this version if you're working on the Cloud9 SDK or open source projects in your spare time, or can clearly claim ownership of copyright in what you'll be submitting.
2. [The Corporate CLA](https://docs.google.com/a/c9.io/forms/d/1vFejn4111GdnCNuQ6BfnJDaxdsUEMD4KCo1ayovAfu0/viewform): have your corporate lawyer review and submit this if your company is going to be contributing to the Cloud9 SDK and/or open source projects.
If you want to contribute to an ajax.org project please print the CLA and fill it out and sign it. Then either send it by snail mail or fax to us or send it back scanned (or as a photo) by email.
If you want to contribute to the Cloud9 SDK and/or open source projects please go to the online form, fill it out and submit it.
Email: ace+cla@c9.io
Fax: +31 (0) 206388953
Address: Ajax.org B.V.
Keizersgracht 241
1016 EA, Amsterdam
the Netherlands
Happy coding, Cloud9

View file

@ -1,3 +1,66 @@
Version 1.2.0-pre
* New Features
- Indented soft wrap (danyaPostfactum)
* API Changes
- unified delta types `{start, end, action, lines}` (Alden Daniels https://github.com/ajaxorg/ace/pull/1745)
- "change" event listeners on session and editor get delta objects directly
2015.04.03 Version 1.1.9
- Small Enhancements and Bugfixes
2014.11.08 Version 1.1.8
* API Changes
- `editor.commands.commandKeyBinding` now contains direct map from keys to commands instead of grouping them by hashid
* New Features
- Improved autoindent for html and php modes (Adam Jimenez)
- Find All from searchbox (Colton Voege)
* new language modes
- Elixir, Elm
2014.09.21 Version 1.1.7
* Bugfixes
- fix several bugs in autocompletion
- workaround for inaccurate getBoundingClientRect on chrome 37
2014.08.17 Version 1.1.6
* Bugfixes
- fix regression in double tap to highlight
- Improved Latex Mode (Daniel Felder)
* API Changes
- editor.destroy destroys editor.session too (call editor.setSession(null) to prevent that)
* new language modes
- Praat (José Joaquín Atria)
- Eiffel (Victorien Elvinger)
- G-code (Adam Joseph Cook)
2014.07.09 Version 1.1.5
* Bugfixes
- fix regression in autocomplete popup
* new language modes
- gitignore (Devon Carew)
2014.07.01 Version 1.1.4
* New Features
- Highlight matching tags (Adam Jimenez)
- Improved jump to matching command (Adam Jimenez)
* new language modes
- AppleScript (Yaogang Lian)
- Vala
2014.03.08 Version 1.1.3
* New Features

View file

@ -13,7 +13,6 @@ pre_build:
build: pre_build
./Makefile.dryice.js normal
./Makefile.dryice.js demo
./Makefile.dryice.js bm
# Minimal build: call Makefile.dryice.js only if our sources changed
basic: build/src/ace.js

File diff suppressed because it is too large Load diff

View file

@ -30,7 +30,7 @@ Take Ace for a spin!
Check out the Ace live [demo](http://ace.c9.io/build/kitchen-sink.html) or get a [Cloud9 IDE account](https://c9.io/) to experience Ace while editing one of your own GitHub projects.
If you want, you can use Ace as a textarea replacement thanks to the [Ace Bookmarklet](http://ajaxorg.github.io/ace/build/textarea/editor.html).
If you want, you can use Ace as a textarea replacement thanks to the [Ace Bookmarklet](http://ajaxorg.github.io/ace/build/demo/bookmarklet/index.html).
Embedding Ace
-------------
@ -79,7 +79,7 @@ By default the editor only supports plain text mode; many other languages are av
The mode can then be used like this:
```javascript
var JavaScriptMode = require("ace/mode/javascript").Mode;
var JavaScriptMode = ace.require("ace/mode/javascript").Mode;
editor.getSession().setMode(new JavaScriptMode());
```

View file

@ -390,8 +390,8 @@
</div>
<div class="description"><p>Creates a new <code>Editor</code> object.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">renderer</td><td class="argType" "><a href="virtual_renderer.html" class="" title="VirtualRenderer (class)" data-id="VirtualRenderer">VirtualRenderer</a></td><td class="argDescription "><p>Required. Associated <code>VirtualRenderer</code> that draws everything</p>
</td></tr><tr class="argumentRow "><td class="argName ">session</td><td class="argType" "><a href="edit_session.html" class="" title="EditSession (class)" data-id="EditSession">EditSession</a></td><td class="argDescription "><p>Required. The <code>EditSession</code> to refer to</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">renderer</td><td class="argType"><a href="virtual_renderer.html" class="" title="VirtualRenderer (class)" data-id="VirtualRenderer">VirtualRenderer</a></td><td class="argDescription "><p>Required. Associated <code>VirtualRenderer</code> that draws everything</p>
</td></tr><tr class="argumentRow "><td class="argName ">session</td><td class="argType"><a href="edit_session.html" class="" title="EditSession (class)" data-id="EditSession">EditSession</a></td><td class="argDescription "><p>Required. The <code>EditSession</code> to refer to</p>
</td></tr></table>
</div>
</div>
@ -444,7 +444,7 @@
</div>
<div class="description"><p>Emitted whenever the document is changed.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. Contains a single property, <code>data</code>, which has the delta of changes</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. Contains a single property, <code>data</code>, which has the delta of changes</p>
</td></tr></table>
</div>
</div>
@ -471,7 +471,7 @@
</div>
<div class="description"><p>Emitted when the selection style changes, via <a href="#Editor.setSelectionStyle" class="link-short" title="Editor.setSelectionStyle (class method)" data-id="Editor.setSelectionStyle"><code>Editor.setSelectionStyle()</code></a>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">data</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. Contains one property, <code>data</code>, which indicates the new selection style</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">data</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. Contains one property, <code>data</code>, which indicates the new selection style</p>
</td></tr></table>
</div>
</div>
@ -498,7 +498,7 @@
</div>
<div class="description"><p>Emitted whenever the <a href="edit_session.html" class="link-short" title="EditSession (class)" data-id="EditSession"><code>EditSession</code></a> changes.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object with two properties, <code>oldSession</code> and <code>session</code>, that represent the old and new <a href="edit_session.html" class="link-short" title="EditSession (class)" data-id="EditSession"><code>EditSession</code></a>s.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object with two properties, <code>oldSession</code> and <code>session</code>, that represent the old and new <a href="edit_session.html" class="link-short" title="EditSession (class)" data-id="EditSession"><code>EditSession</code></a>s.</p>
</td></tr></table>
</div>
</div>
@ -525,7 +525,7 @@
</div>
<div class="description"><p>Emitted when text is copied.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The copied text</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The copied text</p>
</td></tr></table>
</div>
</div>
@ -564,7 +564,7 @@
<ul class="signatures">
<li class="signature">
<ul>
<li class="signature-call"><span class="eventObjName">Editor</span><span class="eventListenerStart">.on("</span><span id="Editor.event.paste" class="member-name eventMember methodClicker">paste</span><span class="eventListenerClose">", </span><span class="eventFunctionOpen">function(</span><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="argument methodClicker" title="String" data-id="String">String</a> text<span class="eventFunctionClose">))</span></li>
<li class="signature-call"><span class="eventObjName">Editor</span><span class="eventListenerStart">.on("</span><span id="Editor.event.paste" class="member-name eventMember methodClicker">paste</span><span class="eventListenerClose">", </span><span class="eventFunctionOpen">function(</span><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="argument methodClicker" title="Object" data-id="Object">Object</a> e<span class="eventFunctionClose">))</span></li>
</ul>
<ul class="metaInfo">
</ul>
@ -577,7 +577,7 @@
</div>
<div class="description"><p>Emitted when text is pasted.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The pasted text</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object which contains one property, <code>text</code>, that represents the text to be pasted. Editing this property will alter the text that is pasted.</p>
</td></tr></table>
</div>
</div>
@ -610,7 +610,7 @@
</div>
<div class="description"><p>Adds the selection and cursor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">orientedRange</td><td class="argType" "><a href="range.html" class="" title="Range (class)" data-id="Range">Range</a></td><td class="argDescription "><p>Required. A range containing a cursor</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">orientedRange</td><td class="argType"><a href="range.html" class="" title="Range (class)" data-id="Range">Range</a></td><td class="argDescription "><p>Required. A range containing a cursor</p>
</td></tr></table>
</div>
</div>
@ -920,9 +920,9 @@
</div>
<div class="description"><p>Attempts to find <code>needle</code> within the document. For more information on <code>options</code>, see <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">needle</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to search for (optional)</p>
</td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object defining various search properties</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">needle</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to search for (optional)</p>
</td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object defining various search properties</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p>
</td></tr></table>
</div>
</div>
@ -954,9 +954,9 @@
</div>
<div class="description"><p>Finds and selects all the occurences of <code>needle</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">The</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. text to find</p>
</td></tr><tr class="argumentRow "><td class="argName ">The</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p>
</td></tr><tr class="argumentRow "><td class="argName ">keeps</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. </p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">The</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. text to find</p>
</td></tr><tr class="argumentRow "><td class="argName ">The</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p>
</td></tr><tr class="argumentRow "><td class="argName ">keeps</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table>
</div>
</div>
@ -983,8 +983,8 @@
</div>
<div class="description"><p>Performs another search for <code>needle</code> in the document. For more information on <code>options</code>, see <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p>
</td></tr></table>
</div>
</div>
@ -1011,8 +1011,8 @@
</div>
<div class="description"><p>Performs a search for <code>needle</code> backwards. For more information on <code>options</code>, see <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p>
</td></tr></table>
</div>
</div>
@ -1064,8 +1064,8 @@
</div>
<div class="description"><p>Executes a command for each selection range.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">cmd</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The command to execute</p>
</td></tr><tr class="argumentRow "><td class="argName ">args</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. Any arguments for the command</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">cmd</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The command to execute</p>
</td></tr><tr class="argumentRow "><td class="argName ">args</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. Any arguments for the command</p>
</td></tr></table>
</div>
</div>
@ -1523,8 +1523,8 @@
</div>
<div class="description"><p>Works like <a href="#nav=api&api=edit_session" class="link-short" title="EditSession.getTokenAt (class method)" data-id="EditSession.getTokenAt"><code>EditSession.getTokenAt()</code></a>, except it returns a number.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table>
</div>
</div>
@ -1966,9 +1966,9 @@
</div>
<div class="description"><p>Moves the cursor to the specified line number, and also into the indiciated column.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">lineNumber</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The line number to go to</p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A column number to go to</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animates scolling</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">lineNumber</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The line number to go to</p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A column number to go to</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animates scolling</p>
</td></tr></table>
</div>
</div>
@ -2070,7 +2070,7 @@
</div>
<div class="description"><p>Inserts <code>text</code> into wherever the cursor is pointing.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new text to add</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new text to add</p>
</td></tr></table>
</div>
</div>
@ -2132,7 +2132,7 @@
</div>
<div class="description"><p>Indicates if the entire row is currently visible on the screen.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The row to check</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The row to check</p>
</td></tr></table>
</div>
</div>
@ -2164,7 +2164,7 @@
</div>
<div class="description"><p>Indicates if the row is currently visible on the screen.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The row to check</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The row to check</p>
</td></tr></table>
</div>
</div>
@ -2191,7 +2191,7 @@
</div>
<div class="description"><p>Moves the cursor&#39;s row and column to the next matching bracket.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">select</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">select</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table>
</div>
</div>
@ -2218,7 +2218,7 @@
</div>
<div class="description"><p>If the character before the cursor is a number, this functions changes its value by <code>amount</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">amount</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The value to change the numeral by (can be negative to decrease value)</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">amount</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The value to change the numeral by (can be negative to decrease value)</p>
</td></tr></table>
</div>
</div>
@ -2245,8 +2245,8 @@
</div>
<div class="description"><p>Moves the cursor to the specified row and column. Note that this does not de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new row number</p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new column number</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new row number</p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new column number</p>
</td></tr></table>
</div>
</div>
@ -2273,7 +2273,7 @@
</div>
<div class="description"><p>Moves the cursor to the position indicated by <code>pos.row</code> and <code>pos.column</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">pos</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object with two properties, row and column</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">pos</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object with two properties, row and column</p>
</td></tr></table>
</div>
</div>
@ -2384,7 +2384,7 @@
</div>
<div class="description"><p>Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
</td></tr></table>
</div>
</div>
@ -2461,7 +2461,7 @@
</div>
<div class="description"><p>Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
</td></tr></table>
</div>
</div>
@ -2538,7 +2538,7 @@
</div>
<div class="description"><p>Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
</td></tr></table>
</div>
</div>
@ -2565,8 +2565,8 @@
</div>
<div class="description"><p>Moves the cursor to the specified row and column. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new row number</p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new column number</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new row number</p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new column number</p>
</td></tr></table>
</div>
</div>
@ -2593,7 +2593,7 @@
</div>
<div class="description"><p>Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
</td></tr></table>
</div>
</div>
@ -3105,7 +3105,7 @@
</div>
<div class="description"><p>Called whenever a text &quot;paste&quot; happens.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The pasted text</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The pasted text</p>
</td></tr></table>
</div>
</div>
@ -3277,7 +3277,7 @@
</div>
<div class="description"><p>Removes words of text from the editor. A &quot;word&quot; is defined as a string of characters bookended by whitespace.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The direction of the deletion to occur, either &quot;left&quot; or &quot;right&quot;</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The direction of the deletion to occur, either &quot;left&quot; or &quot;right&quot;</p>
</td></tr></table>
</div>
</div>
@ -3329,7 +3329,7 @@
</div>
<div class="description"><p>Removes the selection marker.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">The</td><td class="argType" "><a href="range.html" class="" title="Range (class)" data-id="Range">Range</a></td><td class="argDescription "><p>Required. selection range added with <a href="#nav=api&api=multi_select" class="link-short" title="Editor.addSelectionMarker (class method)" data-id="Editor.addSelectionMarker"><code>addSelectionMarker()</code></a>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">The</td><td class="argType"><a href="range.html" class="" title="Range (class)" data-id="Range">Range</a></td><td class="argDescription "><p>Required. selection range added with <a href="#nav=api&api=multi_select" class="link-short" title="Editor.addSelectionMarker (class method)" data-id="Editor.addSelectionMarker"><code>addSelectionMarker()</code></a>.</p>
</td></tr></table>
</div>
</div>
@ -3456,8 +3456,8 @@
</div>
<div class="description"><p>Replaces the first occurance of <code>options.needle</code> with the value in <code>replacement</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">replacement</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to replace with</p>
</td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. The <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a> options to use</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">replacement</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to replace with</p>
</td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. The <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a> options to use</p>
</td></tr></table>
</div>
</div>
@ -3484,8 +3484,8 @@
</div>
<div class="description"><p>Replaces all occurances of <code>options.needle</code> with the value in <code>replacement</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">replacement</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to replace with</p>
</td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. The <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a> options to use</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">replacement</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to replace with</p>
</td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. The <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a> options to use</p>
</td></tr></table>
</div>
</div>
@ -3512,7 +3512,7 @@
</div>
<div class="description"><p>Triggers a resize of the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">force</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, recomputes the size, even if the height and width haven&#39;t changed</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">force</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, recomputes the size, even if the height and width haven&#39;t changed</p>
</td></tr></table>
</div>
</div>
@ -3613,10 +3613,10 @@
</div>
<div class="description"><p>Scrolls to a line. If <code>center</code> is <code>true</code>, it puts the line in middle of screen (or attempts to).</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">line</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The line to scroll to</p>
</td></tr><tr class="argumentRow "><td class="argName ">center</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code></p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animates scrolling</p>
</td></tr><tr class="argumentRow "><td class="argName ">callback</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function" class="" title="Function" data-id="Function">Function</a></td><td class="argDescription "><p>Required. Function to be called when the animation has finished</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">line</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The line to scroll to</p>
</td></tr><tr class="argumentRow "><td class="argName ">center</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code></p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animates scrolling</p>
</td></tr><tr class="argumentRow "><td class="argName ">callback</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function" class="" title="Function" data-id="Function">Function</a></td><td class="argDescription "><p>Required. Function to be called when the animation has finished</p>
</td></tr></table>
</div>
</div>
@ -3643,7 +3643,7 @@
</div>
<div class="description"><p>Moves the editor to the specified row.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table>
</div>
</div>
@ -3695,8 +3695,8 @@
</div>
<div class="description"><p>Finds the next occurence of text in an active selection and adds it to the selections.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction of lines to select: -1 for up, 1 for down</p>
</td></tr><tr class="argumentRow "><td class="argName ">skip</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, removes the active selection range</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction of lines to select: -1 for up, 1 for down</p>
</td></tr><tr class="argumentRow "><td class="argName ">skip</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, removes the active selection range</p>
</td></tr></table>
</div>
</div>
@ -3723,8 +3723,8 @@
</div>
<div class="description"><p>Adds a cursor above or below the active cursor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction of lines to select: -1 for up, 1 for down</p>
</td></tr><tr class="argumentRow "><td class="argName ">skip</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, removes the active selection range</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction of lines to select: -1 for up, 1 for down</p>
</td></tr><tr class="argumentRow "><td class="argName ">skip</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, removes the active selection range</p>
</td></tr></table>
</div>
</div>
@ -3825,7 +3825,7 @@
</div>
<div class="description"><p>Specifies whether to use behaviors or not. &quot;Behaviors&quot; in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">enabled</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Enables or disables behaviors</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">enabled</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Enables or disables behaviors</p>
</td></tr></table>
</div>
</div>
@ -3876,7 +3876,7 @@
</div>
<div class="description"><p>Sets the delay (in milliseconds) of the mouse drag.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dragDelay</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A value indicating the new delay</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dragDelay</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A value indicating the new delay</p>
</td></tr></table>
</div>
</div>
@ -3927,7 +3927,7 @@
</div>
<div class="description"><p>Set a new font size (in pixels) for the editor text.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">size</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A font size</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">size</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A font size</p>
</td></tr></table>
</div>
</div>
@ -3954,7 +3954,7 @@
</div>
<div class="description"><p>Determines whether or not the current line should be highlighted.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">shouldHighlight</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Set to <code>true</code> to highlight the current line</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">shouldHighlight</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Set to <code>true</code> to highlight the current line</p>
</td></tr></table>
</div>
</div>
@ -4005,7 +4005,7 @@
</div>
<div class="description"><p>Determines if the currently selected word should be highlighted.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">shouldHighlight</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Set to <code>true</code> to highlight the currently selected word</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">shouldHighlight</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Set to <code>true</code> to highlight the currently selected word</p>
</td></tr></table>
</div>
</div>
@ -4032,7 +4032,7 @@
</div>
<div class="description"><p>Sets a new key handler, such as &quot;vim&quot; or &quot;windows&quot;.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">keyboardHandler</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new key handler</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">keyboardHandler</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new key handler</p>
</td></tr></table>
</div>
</div>
@ -4059,7 +4059,7 @@
</div>
<div class="description"><p>Pass in <code>true</code> to enable overwrites in your session, or <code>false</code> to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of <code>overwrite</code> changes, this function also emites the <code>changeOverwrite</code> event.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">overwrite</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Defines wheter or not to set overwrites</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">overwrite</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Defines wheter or not to set overwrites</p>
</td></tr></table>
</div>
</div>
@ -4086,7 +4086,7 @@
</div>
<div class="description"><p>Sets the column defining where the print margin should be.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showPrintMargin</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. Specifies the new print margin</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showPrintMargin</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. Specifies the new print margin</p>
</td></tr></table>
</div>
</div>
@ -4113,7 +4113,7 @@
</div>
<div class="description"><p>If <code>readOnly</code> is true, then the editor is set to read-only mode, and none of the content can change.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">readOnly</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether the editor can be modified or not</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">readOnly</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether the editor can be modified or not</p>
</td></tr></table>
</div>
</div>
@ -4140,7 +4140,7 @@
</div>
<div class="description"><p>Sets how fast the mouse scrolling should do.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">speed</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A value indicating the new speed (in milliseconds)</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">speed</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A value indicating the new speed (in milliseconds)</p>
</td></tr></table>
</div>
</div>
@ -4170,7 +4170,7 @@
although this code change in the future.</p>
<p>This function also emits the <code>&#39;changeSelectionStyle&#39;</code> event.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new selection style</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new selection style</p>
</td></tr></table>
</div>
</div>
@ -4197,7 +4197,7 @@ although this code change in the future.</p>
</div>
<div class="description"><p>Sets a new editsession to use. This method also emits the <code>&#39;changeSession&#39;</code> event.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">session</td><td class="argType" "><a href="edit_session.html" class="" title="EditSession (class)" data-id="EditSession">EditSession</a></td><td class="argDescription "><p>Required. The new session to use</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">session</td><td class="argType"><a href="edit_session.html" class="" title="EditSession (class)" data-id="EditSession">EditSession</a></td><td class="argDescription "><p>Required. The new session to use</p>
</td></tr></table>
</div>
</div>
@ -4224,7 +4224,7 @@ although this code change in the future.</p>
</div>
<div class="description"><p>Indicates whether the fold widgets are shown or not.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">show</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether the fold widgets are shown</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">show</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether the fold widgets are shown</p>
</td></tr></table>
</div>
</div>
@ -4251,7 +4251,7 @@ although this code change in the future.</p>
</div>
<div class="description"><p>If <code>showInvisibles</code> is set to <code>true</code>, invisible characters&mdash;like spaces or new lines&mdash;are show in the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showInvisibles</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether or not to show invisible characters</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showInvisibles</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether or not to show invisible characters</p>
</td></tr></table>
</div>
</div>
@ -4278,7 +4278,7 @@ although this code change in the future.</p>
</div>
<div class="description"><p>If <code>showPrintMargin</code> is set to <code>true</code>, the print margin is shown in the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showPrintMargin</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether or not to show the print margin</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showPrintMargin</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether or not to show the print margin</p>
</td></tr></table>
</div>
</div>
@ -4305,7 +4305,7 @@ although this code change in the future.</p>
</div>
<div class="description"><p>Adds a new class, <code>style</code>, to the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. A class name</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. A class name</p>
</td></tr></table>
</div>
</div>
@ -4332,7 +4332,7 @@ although this code change in the future.</p>
</div>
<div class="description"><p>Sets a new theme for the editor. <code>theme</code> should exist, and be a directory path, like <code>ace/theme/textmate</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">theme</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The path to a theme</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">theme</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The path to a theme</p>
</td></tr></table>
</div>
</div>
@ -4364,8 +4364,8 @@ although this code change in the future.</p>
</div>
<div class="description"><p>Sets the current document to <code>val</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">val</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new value to set for the document</p>
</td></tr><tr class="argumentRow "><td class="argName ">cursorPos</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. Where to set the new value. <code>undefined</code> or 0 is selectAll, -1 is at the document start, and 1 is at the end</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">val</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new value to set for the document</p>
</td></tr><tr class="argumentRow "><td class="argName ">cursorPos</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. Where to set the new value. <code>undefined</code> or 0 is selectAll, -1 is at the document start, and 1 is at the end</p>
</td></tr></table>
</div>
</div>
@ -4394,7 +4394,7 @@ when such a character is typed in.</p>
<div class="description"><p>Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets
when such a character is typed in.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">enabled</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Enables or disables wrapping behaviors</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">enabled</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Enables or disables wrapping behaviors</p>
</td></tr></table>
</div>
</div>
@ -4595,7 +4595,7 @@ when such a character is typed in.</p>
</div>
<div class="description"><p>Transposes the selected ranges.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction to rotate selections</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction to rotate selections</p>
</td></tr></table>
</div>
</div>
@ -4647,7 +4647,7 @@ when such a character is typed in.</p>
</div>
<div class="description"><p>Removes the class <code>style</code> from the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table>
</div>
</div>

View file

@ -163,7 +163,7 @@
<article id="Selection" data-title="Selection (class)" class="article">
<div class="section description">
<div class="memberContent"><p>Contains the cursor position and the text selection of an edit session.</p>
<p>The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding.</p>
<p>The row/columns used in the selection are in document coordinates representing the coordinates as they appear in the document before applying soft wrap and folding.</p>
</div>
</div>
@ -1778,4 +1778,4 @@
<script defer src="./resources/javascripts/disqus-ext.js"></script>
<script defer src="./resources/javascripts/ga.js"></script>
<div id="disqus_thread"></div>
</div>
</div>

2
build

@ -1 +1 @@
Subproject commit fc9d2cae9fe8e6e95e74c86a31d21caadd8f9f39
Subproject commit a4e495d8901876c6bafe3870a35cb8e32c827e97

View file

@ -20,7 +20,7 @@ function foo() {
var bar = true;
}</textarea><br>
SourceUrl: <br>
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/textarea/src/"></input><br>
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/src-noconflict"></input><br>
<button id="buBuild">Build Link</button> <br> <a href="#"></a>
<a href="https://github.com/ajaxorg/ace/">
<div class="fork_on_github" ></div>
@ -49,63 +49,60 @@ function foo() {
<script>
function inject(callback) {
var baseUrl = "src/";
var load = window.__ace_loader__ = function(path, module, callback) {
function inject(options, callback) {
var baseUrl = options.baseUrl || "../../src-noconflict";
var load = function(path, callback) {
var head = document.getElementsByTagName('head')[0];
var s = document.createElement('script');
s.src = baseUrl + path;
s.src = baseUrl + "/" + path;
head.appendChild(s);
s.onload = function() {
window.__ace_shadowed__.require([module], callback);
s.onload = s.onreadystatechange = function(_, isAbort) {
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
s = s.onload = s.onreadystatechange = null;
if (!isAbort)
callback();
}
};
};
load('ace-bookmarklet.js', "ace/ext/textarea", function() {
var ace = window.__ace_shadowed__;
ace.options.mode = "javascript";
var Event = ace.require("ace/lib/event");
var areas = document.getElementsByTagName("textarea");
for (var i = 0; i < areas.length; i++) {
Event.addListener(areas[i], "click", function(e) {
if (e.detail == 3) {
ace.transformTextarea(e.target, load);
}
});
}
callback && callback();
load("ace.js", function() {
ace.config.loadModule("ace/ext/textarea", function() {
var event = ace.require("ace/lib/event");
var areas = document.getElementsByTagName("textarea");
for (var i = 0; i < areas.length; i++) {
event.addListener(areas[i], "click", function(e) {
if (e.detail == 3) {
ace.transformTextarea(e.target, options.ace);
}
});
}
callback && callback();
});
});
}
// Call the inject function to load the ace files.
var textAce;
inject(function () {
inject({}, function () {
// Transform the textarea on the page into an ace editor.
var ace = window.__ace_shadowed__;
var t = document.querySelector("textarea");
textAce = ace.transformTextarea(t, window.__ace_loader__);
textAce = ace.require("ace/ext/textarea").transformTextarea(t);
setTimeout(function(){textAce.setDisplaySettings(true)});
});
document.getElementById("buBuild").onclick = function() {
var injectSrc = inject.toString().split("\n").join("");
injectSrc = injectSrc.replace('baseUrl = "src/"', 'baseUrl="' + document.getElementById("srcURL").value + '"');
var aceOptions = textAce.getOptions();
var opt = [];
for (var option in aceOptions) {
opt.push(option + ":'" + aceOptions[option] + "'");
}
injectSrc = injectSrc.replace('ace.options.mode = "javascript"', 'ace.options = { ' + opt.join(",") + ' }');
injectSrc = injectSrc.replace(/\s+/g, " ");
var options = textAce.getOptions();
options.baseUrl = document.getElementById("srcURL").value;
var a = document.querySelector("a");
a.href = "javascript:(" + injectSrc + ")()";
a.href = "javascript:(" + injectSrc + ")(" + JSON.stringify(options) + ")";
a.innerHTML = "Ace Bookmarklet Link";
}

View file

@ -8,8 +8,8 @@
body {
overflow: hidden;
}
#editor {
#editor {
margin: 0;
position: absolute;
top: 0;
@ -27,7 +27,7 @@
alert("Ace Rocks " + items[i]);
}
}</pre>
<script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");

View file

@ -3,7 +3,7 @@
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@ -14,7 +14,7 @@
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -38,69 +38,62 @@
var ACE_NAMESPACE = "";
var global = (function() {
return this;
})();
var global = (function() { return this; })();
if (!global && typeof window != "undefined") global = window; // strict mode
if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
return;
var _define = function(module, deps, payload) {
if (typeof module !== 'string') {
if (_define.original)
_define.original.apply(window, arguments);
var define = function(module, deps, payload) {
if (typeof module !== "string") {
if (define.original)
define.original.apply(this, arguments);
else {
console.error('dropping module because define wasn\'t a string.');
console.error("dropping module because define wasn\'t a string.");
console.trace();
}
return;
}
if (arguments.length == 2)
payload = deps;
if (!_define.modules) {
_define.modules = {};
_define.payloads = {};
if (!define.modules[module]) {
define.payloads[module] = payload;
define.modules[module] = null;
}
_define.payloads[module] = payload;
_define.modules[module] = null;
};
define.modules = {};
define.payloads = {};
/**
* Get at functionality define()ed using the function above
*/
var _require = function(parentId, module, callback) {
if (Object.prototype.toString.call(module) === "[object Array]") {
if (typeof module === "string") {
var payload = lookup(parentId, module);
if (payload != undefined) {
callback && callback();
return payload;
}
} else if (Object.prototype.toString.call(module) === "[object Array]") {
var params = [];
for (var i = 0, l = module.length; i < l; ++i) {
var dep = lookup(parentId, module[i]);
if (!dep && _require.original)
return _require.original.apply(window, arguments);
if (dep == undefined && require.original)
return;
params.push(dep);
}
if (callback) {
callback.apply(null, params);
}
return callback && callback.apply(null, params) || true;
}
else if (typeof module === 'string') {
var payload = lookup(parentId, module);
if (!payload && _require.original)
return _require.original.apply(window, arguments);
};
if (callback) {
callback();
}
return payload;
}
else {
if (_require.original)
return _require.original.apply(window, arguments);
}
var require = function(module, callback) {
var packagedModule = _require("", module, callback);
if (packagedModule == undefined && require.original)
return require.original.apply(this, arguments);
return packagedModule;
};
var normalizeModule = function(parentId, moduleName) {
@ -119,7 +112,6 @@ var normalizeModule = function(parentId, moduleName) {
moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
}
}
return moduleName;
};
@ -128,12 +120,11 @@ var normalizeModule = function(parentId, moduleName) {
* definition function if needed.
*/
var lookup = function(parentId, moduleName) {
moduleName = normalizeModule(parentId, moduleName);
var module = _define.modules[moduleName];
var module = define.modules[moduleName];
if (!module) {
module = _define.payloads[moduleName];
module = define.payloads[moduleName];
if (typeof module === 'function') {
var exports = {};
var mod = {
@ -149,19 +140,15 @@ var lookup = function(parentId, moduleName) {
var returnValue = module(req, exports, mod);
exports = returnValue || mod.exports;
_define.modules[moduleName] = exports;
delete _define.payloads[moduleName];
define.modules[moduleName] = exports;
delete define.payloads[moduleName];
}
module = _define.modules[moduleName] = exports || module;
module = define.modules[moduleName] = exports || module;
}
return module;
};
function exportAce(ns) {
var require = function(module, callback) {
return _require("", module, callback);
};
var root = global;
if (ns) {
if (!global[ns])
@ -170,13 +157,13 @@ function exportAce(ns) {
}
if (!root.define || !root.define.packaged) {
_define.original = root.define;
root.define = _define;
define.original = root.define;
root.define = define;
root.define.packaged = true;
}
if (!root.require || !root.require.packaged) {
_require.original = root.require;
require.original = root.require;
root.require = require;
root.require.packaged = true;
}

View file

@ -4,7 +4,7 @@ body {
margin:0;
padding:0;
background-color:#e6f5fc;
}
H2, H3, H4 {
@ -58,7 +58,7 @@ PRE{
position:relative;
overflow:hidden;
background: url(images/background.png) repeat-x 0 0;
border-bottom:1px solid #c9e8fa;
border-bottom:1px solid #c9e8fa;
}
#header .content .signature {
@ -224,7 +224,3 @@ UL.menu-footer LI A {
UL.menu-footer LI A:hover {
text-decoration:underline;
}

View file

@ -7,14 +7,13 @@
<style type="text/css" media="screen">
.ace_editor {
position: relative !important;
border: 1px solid lightgray;
margin: auto;
height: 200px;
width: 80%;
}
.scrollmargin {
height: 100px;
height: 80px;
text-align: center;
}
</style>
@ -24,30 +23,43 @@
<div class="scrollmargin"></div>
<pre id="editor2">minHeight = 2 lines</pre>
<div class="scrollmargin"></div>
<pre id="editor3" style="width: 40%;"></pre>
<div class="scrollmargin"></div>
<pre id="editor"></pre>
<script src="../build/src/ace.js"></script>
<script src="kitchen-sink/require.js"></script>
<script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace"], function(ace) {
var editor1 = ace.edit("editor1");
editor1.setTheme("ace/theme/tomorrow_night_eighties");
editor1.session.setMode("ace/mode/html");
editor1.setAutoScrollEditorIntoView(true);
editor1.setOption("maxLines", 30);
var editor1 = ace.edit("editor1");
editor1.setTheme("ace/theme/tomorrow_night_eighties");
editor1.session.setMode("ace/mode/html");
editor1.setAutoScrollEditorIntoView(true);
editor1.setOption("maxLines", 30);
var editor2 = ace.edit("editor2");
editor2.setTheme("ace/theme/tomorrow_night_blue");
editor2.session.setMode("ace/mode/html");
editor2.setAutoScrollEditorIntoView(true);
editor2.setOption("maxLines", 30);
editor2.setOption("minLines", 2);
var editor = ace.edit("editor");
editor.setTheme("ace/theme/tomorrow");
editor.session.setMode("ace/mode/html");
editor.setAutoScrollEditorIntoView(true);
editor.setOption("maxLines", 100);
var editor2 = ace.edit("editor2");
editor2.setTheme("ace/theme/tomorrow_night_blue");
editor2.session.setMode("ace/mode/html");
editor2.setAutoScrollEditorIntoView(true);
editor2.setOption("maxLines", 30);
editor2.setOption("minLines", 2);
var editor = ace.edit("editor3");
editor.setOptions({
autoScrollEditorIntoView: true,
maxLines: 8
});
editor.renderer.setScrollMargin(10, 10, 10, 10);
var editor = ace.edit("editor");
editor.setTheme("ace/theme/tomorrow");
editor.session.setMode("ace/mode/html");
editor.setAutoScrollEditorIntoView(true);
editor.setOption("maxLines", 100);
});
</script>
<script src="./show_own_source.js"></script>

View file

@ -23,7 +23,7 @@
<pre id="editor"></pre>
<!-- load emmet code and snippets compiled for browser -->
<script src="https://nightwing.github.io/emmet-core/emmet.js"></script>
<script src="https://cloud9ide.github.io/emmet-core/emmet.js"></script>
<script src="kitchen-sink/require.js"></script>
<script>

View file

@ -415,28 +415,11 @@ bindDropdown("folding", function(value) {
});
bindDropdown("soft_wrap", function(value) {
var session = env.editor.session;
var renderer = env.editor.renderer;
switch (value) {
case "off":
session.setUseWrapMode(false);
renderer.setPrintMarginColumn(80);
break;
case "free":
session.setUseWrapMode(true);
session.setWrapLimitRange(null, null);
renderer.setPrintMarginColumn(80);
break;
default:
session.setUseWrapMode(true);
var col = parseInt(value, 10);
session.setWrapLimitRange(col, col);
renderer.setPrintMarginColumn(col);
}
env.editor.setOption("wrap", value);
});
bindCheckbox("select_style", function(checked) {
env.editor.setSelectionStyle(checked ? "line" : "text");
env.editor.setOption("selectionStyle", checked ? "line" : "text");
});
bindCheckbox("highlight_active", function(checked) {
@ -548,7 +531,7 @@ new StatusBar(env.editor, cmdLine.container);
var Emmet = require("ace/ext/emmet");
net.loadScript("https://nightwing.github.io/emmet-core/emmet.js", function() {
net.loadScript("https://cloud9ide.github.io/emmet-core/emmet.js", function() {
Emmet.setCore(window.emmet);
env.editor.setOption("enableEmmet", true);
});
@ -592,7 +575,7 @@ env.editSnippets = function() {
require("ace/ext/language_tools");
env.editor.setOptions({
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
enableLiveAutocompletion: false,
enableSnippets: true
});

View file

@ -29,13 +29,17 @@
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
// allow easy access to ace in console, but not in ace code which uses strict
function isStrict() {
try { return !arguments.callee.caller.caller.caller}
catch(e){ return true }
}
var dom = require("ace/lib/dom");
var Range = require("ace/range").Range;
function warn() {
if (isStrict()) {
var s = (new Error()).stack || "";
s = s.split("\n");
if (s[1] == "Error") s.shift(); // remove error description on chrome
s.shift(); // remove warn
s.shift(); // remove the getter
s = s.join("\n");
// allow easy access to ace in console, but not in ace code
if (!/at Object.InjectedScript.|@debugger eval|snippets:\/{3}|\(<anonymous>:\d+:\d+\)/.test(s)) {
console.error("trying to access to global variable");
}
}
@ -59,21 +63,155 @@ def(window, "session", function(){ warn(); return window.env.editor.session });
def(window, "split", function(){ warn(); return window.env.split });
/* for textinput debuggging
dom.importCssString("\
.ace_text-input {\
position: absolute;\
z-index: 10!important;\
width: 6em!important;\
height: 1em;\
opacity: 1!important;\
background: rgba(0, 92, 255, 0.11);\
border: none;\
font: inherit;\
padding: 0 1px;\
margin: 0 -1px;\
text-indent: 0em;\
}\
")*/
def(window, "devUtil", function(){ warn(); return exports });
exports.showTextArea = function(argument) {
dom.importCssString("\
.ace_text-input {\
position: absolute;\
z-index: 10!important;\
width: 6em!important;\
height: 1em;\
opacity: 1!important;\
background: rgba(0, 92, 255, 0.11);\
border: none;\
font: inherit;\
padding: 0 1px;\
margin: 0 -1px;\
text-indent: 0em;\
}\
");
};
exports.addGlobals = function() {
window.oop = require("ace/lib/oop");
window.dom = require("ace/lib/dom");
window.Range = require("ace/range").Range;
window.Editor = require("ace/editor").Editor;
window.assert = require("ace/test/asyncjs/assert");
window.asyncjs = require("ace/test/asyncjs/async");
window.UndoManager = require("ace/undomanager").UndoManager;
window.EditSession = require("ace/edit_session").EditSession;
window.MockRenderer = require("ace/test/mockrenderer").MockRenderer;
window.EventEmitter = require("ace/lib/event_emitter").EventEmitter;
window.getSelection = getSelection;
window.setSelection = setSelection;
window.testSelection = testSelection;
};
function getSelection(editor) {
var data = editor.multiSelect.toJSON();
if (!data.length) data = [data];
data = data.map(function(x) {
var a, c;
if (x.isBackwards) {
a = x.end;
c = x.start;
} else {
c = x.end;
a = x.start;
}
return Range.comparePoints(a, c)
? [a.row, a.column, c.row, c.column]
: [a.row, a.column];
});
return data.length > 1 ? data : data[0];
}
function setSelection(editor, data) {
if (typeof data[0] == "number")
data = [data];
editor.selection.fromJSON(data.map(function(x) {
var start = {row: x[0], column: x[1]};
var end = x.length == 2 ? start : {row: x[2], column: x[3]};
var isBackwards = Range.comparePoints(start, end) > 0;
return isBackwards ? {
start: end,
end: start,
isBackwards: true
} : {
start: start,
end: end,
isBackwards: true
};
}));
}
function testSelection(editor, data) {
assert.equal(getSelection(editor) + "", data + "");
}
exports.recordTestCase = function() {
exports.addGlobals();
var editor = window.editor;
var testcase = window.testcase = [];
var assert;
testcase.push({
type: "setValue",
data: editor.getValue()
}, {
type: "setSelection",
data: getSelection(editor)
});
editor.commands.on("afterExec", function(e) {
testcase.push({
type: "exec",
data: e
});
testcase.push({
type: "value",
data: editor.getValue()
});
testcase.push({
type: "selection",
data: getSelection(editor)
});
});
editor.on("mouseup", function() {
testcase.push({
type: "setSelection",
data: getSelection(editor)
});
});
testcase.toString = function() {
var lastValue = "";
// var lastSelection = ""
var str = this.map(function(x) {
var data = x.data;
switch (x.type) {
case "exec":
return 'editor.execCommand("'
+ data.command.name
+ (data.args ? '", ' + JSON.stringify(data.args) : '"')
+ ')';
case "setSelection":
return 'setSelection(editor, ' + JSON.stringify(data) + ')';
case "setValue":
if (lastValue != data) {
lastValue = data;
return 'editor.setValue(' + JSON.stringify(data) + ', -1)';
}
return;
case "selection":
return 'testSelection(editor, ' + JSON.stringify(data) + ')';
case "value":
if (lastValue != data) {
lastValue = data;
return 'assert.equal('
+ 'editor.getValue(),'
+ JSON.stringify(data)
+ ')';
}
return;
}
}).filter(Boolean).join("\n");
return getSelection + "\n"
+ testSelection + "\n"
+ setSelection + "\n"
+ "\n" + str + "\n";
};
};
});

View file

@ -86,9 +86,12 @@ var ownSource = {
/* filled from require*/
};
var hugeDocs = {
var hugeDocs = require.toUrl ? {
"build/src/ace.js": "",
"build/src-min/ace.js": ""
} : {
"src/ace.js": "",
"src-min/ace.js": ""
};
modelist.modes.forEach(function(m) {
@ -166,13 +169,44 @@ function loadDoc(name, callback) {
});
}
function saveDoc(name, callback) {
var doc = fileCache[name] || name;
if (!doc || !doc.session)
return callback("Unknown document: " + name);
var path = doc.path;
var parts = path.split("/");
if (parts[0] == "docs")
path = "demo/kitchen-sink/" + path;
else if (parts[0] == "ace")
path = "lib/" + path;
upload(path, doc.session.getValue(), callback);
}
function upload(url, data, callback) {
url = net.qualifyURL(url);
if (!/https?:/.test(url))
return callback(new Error("Unsupported url scheme"));
var xhr = new XMLHttpRequest();
xhr.open("PUT", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
callback(!/^2../.test(xhr.status));
}
};
xhr.send(data);
};
module.exports = {
fileCache: fileCache,
docs: sort(prepareDocList(docs)),
ownSource: prepareDocList(ownSource),
hugeDocs: prepareDocList(hugeDocs),
initDoc: initDoc,
loadDoc: loadDoc
loadDoc: loadDoc,
saveDoc: saveDoc,
};
module.exports.all = {
"Mode Examples": module.exports.docs,

11
demo/kitchen-sink/docs/.gitignore vendored Normal file
View file

@ -0,0 +1,11 @@
# A sample .gitignore file.
.buildlog
.DS_Store
.svn
# Negated patterns:
!foo.bar
# Also ignore user settings...
/.settings

View file

@ -0,0 +1,171 @@
%abc-2.1
H:This file contains some example English tunes
% note that the comments (like this one) are to highlight usages
% and would not normally be included in such detail
O:England % the origin of all tunes is England
X:1 % tune no 1
T:Dusty Miller, The % title
T:Binny's Jig % an alternative title
C:Trad. % traditional
R:DH % double hornpipe
M:3/4 % meter
K:G % key
B>cd BAG|FA Ac BA|B>cd BAG|DG GB AG:|
Bdd gfg|aA Ac BA|Bdd gfa|gG GB AG:|
BG G/2G/2G BG|FA Ac BA|BG G/2G/2G BG|DG GB AG:|
W:Hey, the dusty miller, and his dusty coat;
W:He will win a shilling, or he spend a groat.
W:Dusty was the coat, dusty was the colour;
W:Dusty was the kiss, that I got frae the miller.
X:2
T:Old Sir Simon the King
C:Trad.
S:Offord MSS % from Offord manuscript
N:see also Playford % reference note
M:9/8
R:SJ % slip jig
N:originally in C % transcription note
K:G
D|GFG GAG G2D|GFG GAG F2D|EFE EFE EFG|A2G F2E D2:|
D|GAG GAB d2D|GAG GAB c2D|[1 EFE EFE EFG|[A2G] F2E D2:|\ % no line-break in score
M:12/8 % change of meter
[2 E2E EFE E2E EFG|\ % no line-break in score
M:9/8 % change of meter
A2G F2E D2|]
X:3
T:William and Nancy
T:New Mown Hay
T:Legacy, The
C:Trad.
O:England; Gloucs; Bledington % place of origin
B:Sussex Tune Book % can be found in these books
B:Mally's Cotswold Morris vol.1 2
D:Morris On % can be heard on this record
P:(AB)2(AC)2A % play the parts in this order
M:6/8
K:G
[P:A] D|"G"G2G GBd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
[P:B] d|"G"e2d B2d|"C"gfe "G"d2d| "G"e2d B2d|"C"gfe "D7"d2c|
"G"B2B Bcd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
% changes of meter, using inline fields
[T:Slows][M:4/4][L:1/4][P:C]"G"d2|"C"e2 "G"d2|B2 d2|"Em"gf "A7"e2|"D7"d2 "G"d2|\
"C"e2 "G"d2|[M:3/8][L:1/8] "G"B2 d |[M:6/8] "C"gfe "D7"d2c|
"G"B2B Bcd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
X:4
T:South Downs Jig
R:jig
S:Robert Harbron
M:6/8
L:1/8
K:G
|: d | dcA G3 | EFG AFE | DEF GAB | cde d2d |
dcA G3 | EFG AFE | DEF GAB | cAF G2 :|
B | Bcd e2c | d2B c2A | Bcd e2c | [M:9/8]d2B c2B A3 |
[M:6/8]DGF E3 | cBA FED | DEF GAB |1 cAF G2 :|2 cAF G3 |]
X:5
T:Atholl Brose
% in this example, which reproduces Highland Bagpipe gracing,
% the large number of grace notes mean that it is more convenient to be specific about
% score line-breaks (using the $ symbol), rather than using code line breaks to indicate them
I:linebreak $
K:D
{gcd}c<{e}A {gAGAG}A2 {gef}e>A {gAGAG}Ad|
{gcd}c<{e}A {gAGAG}A>e {ag}a>f {gef}e>d|
{gcd}c<{e}A {gAGAG}A2 {gef}e>A {gAGAG}Ad|
{g}c/d/e {g}G>{d}B {gf}gG {dc}d>B:|$
{g}c<e {gf}g>e {ag}a>e {gf}g>e|
{g}c<e {gf}g>e {ag}a2 {GdG}a>d|
{g}c<e {gf}g>e {ag}a>e {gf}g>f|
{gef}e>d {gf}g>d {gBd}B<{e}G {dc}d>B|
{g}c<e {gf}g>e {ag}a>e {gf}g>e|
{g}c<e {gf}g>e {ag}a2 {GdG}ad|
{g}c<{GdG}e {gf}ga {f}g>e {g}f>d|
{g}e/f/g {Gdc}d>c {gBd}B<{e}G {dc}d2|]
X:6
T:Untitled Reel
C:Trad.
K:D
eg|a2ab ageg|agbg agef|g2g2 fgag|f2d2 d2:|\
ed|cecA B2ed|cAcA E2ed|cecA B2ed|c2A2 A2:|
K:G
AB|cdec BcdB|ABAF GFE2|cdec BcdB|c2A2 A2:|
X:7
T:Kitchen Girl
C:Trad.
K:D
[c4a4] [B4g4]|efed c2cd|e2f2 gaba|g2e2 e2fg|
a4 g4|efed cdef|g2d2 efed|c2A2 A4:|
K:G
ABcA BAGB|ABAG EDEG|A2AB c2d2|e3f edcB|ABcA BAGB|
ABAG EGAB|cBAc BAG2|A4 A4:|
%abc-2.1
%%pagewidth 21cm
%%pageheight 29.7cm
%%topspace 0.5cm
%%topmargin 1cm
%%botmargin 0cm
%%leftmargin 1cm
%%rightmargin 1cm
%%titlespace 0cm
%%titlefont Times-Bold 32
%%subtitlefont Times-Bold 24
%%composerfont Times 16
%%vocalfont Times-Roman 14
%%staffsep 60pt
%%sysstaffsep 20pt
%%musicspace 1cm
%%vocalspace 5pt
%%measurenb 0
%%barsperstaff 5
%%scale 0.7
X: 1
T: Canzonetta a tre voci
C: Claudio Monteverdi (1567-1643)
M: C
L: 1/4
Q: "Andante mosso" 1/4 = 110
%%score [1 2 3]
V: 1 clef=treble name="Soprano"sname="A"
V: 2 clef=treble name="Alto" sname="T"
V: 3 clef=bass middle=d name="Tenor" sname="B"
%%MIDI program 1 75 % recorder
%%MIDI program 2 75
%%MIDI program 3 75
K: Eb
% 1 - 4
[V: 1] |:z4 |z4 |f2ec |_ddcc |
w: Son que-sti~i cre-spi cri-ni~e
w: Que-sti son gli~oc-chi che mi-
[V: 2] |:c2BG|AAGc|(F/G/A/B/)c=A|B2AA |
w: Son que-sti~i cre-spi cri-ni~e que - - - - sto~il vi-so e
w: Que-sti son~gli oc-chi che mi-ran - - - - do fi-so mi-
[V: 3] |:z4 |f2ec|_ddcf |(B/c/_d/e/)ff|
w: Son que-sti~i cre-spi cri-ni~e que - - - - sto~il
w: Que-sti son~gli oc-chi che mi-ran - - - - do
% 5 - 9
[V: 1] cAB2 |cAAA |c3B|G2!fermata!Gz ::e4|
w: que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,
w: ran-do fi-so, tut-to re-stai con-qui-so.
[V: 2] AAG2 |AFFF |A3F|=E2!fermata!Ez::c4|
w: que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,
w: ran-do fi-so tut-to re-stai con-qui-so.
[V: 3] (ag/f/e2)|A_ddd|A3B|c2!fermata!cz ::A4|
w: vi - - - so ond' io ti-man-go~uc-ci-so. Deh,
w: fi - - - so tut-to re-stai con-qui-so.
% 10 - 15
[V: 1] f_dec |B2c2|zAGF |\
w: dim-me-lo ben mi-o, che que-sto\
=EFG2 |1F2z2:|2F8|] % more notes
w: sol de-si-o_. % more lyrics
[V: 2] ABGA |G2AA|GF=EF |(GF3/2=E//D//E)|1F2z2:|2F8|]
w: dim-me-lo ben mi-o, che que-sto sol de-si - - - - o_.
[V: 3] _dBc>d|e2AF|=EFc_d|c4 |1F2z2:|2F8|]
w: dim-me-lo ben mi-o, che que-sto sol de-si-o_.

View file

@ -1,28 +1,18 @@
.text-layer {
font-family: Monaco, "Courier New", monospace;
font-size: 12pX;
font: 12px Monaco, "Courier New", monospace;
cursor: text;
}
.blinker {
animation-duration: 1s;
animation-name: blink;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: linear;
animation: blink 1s linear infinite alternate;
}
@keyframes blink {
0% {
0%, 40% {
opacity: 0;
}
40% {
opacity: 0;
}
40.5% {
opacity: 1
}
100% {
40.5%, 100% {
opacity: 1
}
}

View file

@ -0,0 +1,30 @@
note
description: "Represents a person."
class
PERSON
create
make, make_unknown
feature {NONE} -- Creation
make (a_name: like name)
-- Create a person with `a_name' as `name'.
do
name := a_name
ensure
name = a_name
end
make_unknown
do ensure
name = Void
end
feature -- Access
name: detachable STRING
-- Full name or Void if unknown.
end

View file

@ -0,0 +1,42 @@
defmodule HelloModule do
@moduledoc """
This is supposed to be `markdown`.
__Yes__ this is [mark](http://down.format)
# Truly
## marked
* with lists
* more
* and more
Even.with(code)
blocks |> with |> samples
_Docs are first class citizens in Elixir_ (Jose Valim)
"""
# A "Hello world" function
def some_fun do
IO.puts "Juhu Kinners!"
end
# A private function
defp priv do
is_regex ~r"""
This is a regex
spanning several
lines.
"""
x = elem({ :a, :b, :c }, 0) #=> :a
end
end
test_fun = fn(x) ->
cond do
x > 10 ->
:greater_than_ten
true ->
:maybe_ten
end
end

View file

@ -0,0 +1,12 @@
{- Ace {- 4 -} Elm -}
main = lift clock (every second)
clock t = collage 400 400 [ filled lightGrey (ngon 12 110)
, outlined (solid grey) (ngon 12 110)
, hand orange 100 t
, hand charcoal 100 (t/60)
, hand charcoal 60 (t/720) ]
hand clr len time =
let angle = degrees (90 - 6 * inSeconds time)
in traced (solid clr) <| segment (0,0) (len * cos angle, len * sin angle)

View file

@ -0,0 +1,31 @@
O003 (DIAMOND SQUARE)
N2 G54 G90 G49 G80
N3 M6 T1 (1.ENDMILL)
N4 M3 S1800
N5 G0 X-.6 Y2.050
N6 G43 H1 Z.1
N7 G1 Z-.3 F50.
N8 G41 D1 Y1.45
N9 G1 X0 F20.
N10 G2 J-1.45
(CUTTER COMP CANCEL)
N11 G1 Z-.2 F50.
N12 Y-.990
N13 G40
N14 G0 X-.6 Y1.590
N15 G0 Z.1
N16 M5 G49 G28 G91 Z0
N17 CALL O9456
N18 #500=0.004
N19 #503=[#500+#501]
N20 VC45=0.0006
VS4=0.0007
N21 G90 G10 L20 P3 X5.Y4. Z6.567
N22 G0 X5000
N23 IF [#1 LT 0.370] GOTO 49
N24 X-0.678 Y+.990
N25 G84.3 X-0.1
N26 #4=#5*COS[45]
N27 #4=#5*SIN[45]
N28 VZOFZ=652.9658
%

View file

@ -3,6 +3,6 @@
<div id="comments">
{{#each comments}}
<h2><a href="/posts/{{../permalink}}#{{id}}">{{title}}</a></h2>
<div>{{body}}</div>
<div>{{{body}}}</div>
{{/each}}
</div>

View file

@ -0,0 +1,6 @@
// computes factorial of a number
factorial := method(n,
if(n == 0, return 1)
res := 1
Range 1 to(n) foreach(i, res = res * i)
)

View file

@ -0,0 +1,9 @@
import logic
section
variables (A : Type) (p q : A Prop)
example : (x : A, p x q x) y : A, p y :=
assume H : x : A, p x q x,
take y : A,
show p y, from and.elim_left (H y)
end

View file

@ -0,0 +1,52 @@
/* Mask Syntax Demo */
div > ' Test ~[name]';
define :userProfile {
header {
h4 > @title;
button.close;
}
}
:userProfile {
@title > ' Hello ~[: username.toUpperCase()]'
}
style {
html, body {
background: url('name.png') 0 0 no-repeat;
}
}
button {
event click (e) {
this.textContent = `name ${e.clientX} !`;
}
}
md > """
- div
- span
Hello
[one](http://google.com)
""";
header .foo > 'Heading'
button .baz x-signal='click: test' disabled > "
Hello,
world
\"Buddy\"
"
var a = {
name: `name ${window.innerWidth}`
};
span .foo > "~[bind: a.name]"

View file

@ -1 +1,17 @@
TODO
%{
%{
Ace Matlab demo
%}
%}
classdef hello
methods
function greet(this)
disp('Hello!') % say hi
end
end
end
% transpose
a = [ 'x''y', "x\n\
y", 1' ]' + 2'

View file

@ -0,0 +1,148 @@
form Highlighter test
sentence My_sentence This should all be a string
text My_text This should also all be a string
word My_word Only the first word is a string, the rest is invalid
boolean Binary 1
boolean Text no
boolean Quoted "yes"
comment This should be a string
real left_Range -123.6
positive right_Range_max 3.3
integer Int 4
natural Nat 4
endform
# External scripts
include /path/to/file
runScript: "/path/to/file"
execute /path/to/file
stopwatch
# old-style procedure call
call oldStyle "quoted" 2 unquoted string
assert oldStyle.local = 1
# New-style procedure call with parens
@newStyle("quoted", 2, "quoted string")
if praatVersion >= 5364
# New-style procedure call with colon
@newStyle: "quoted", 2, "quoted string"
endif
# if-block with built-in variables
if windows
# We are on Windows
elsif unix = 1 or !macintosh
exitScript: "We are on Linux"
else macintosh == 1
exit We are on Mac
endif
# inline if with inline comment
var = if macintosh = 1 then 0 else 1 fi ; This is an inline comment
# for-loop with explicit from using local variable
# and paren-style function calls and variable interpolation
n = numberOfSelected("Sound")
for i from newStyle.local to n
sound'i' = selected("Sound", i)
sound[i] = sound'i'
endfor
for i from 1 to n
# Different styles of object selection
select sound'i'
sound = selected()
sound$ = selected$("Sound")
select Sound 'sound$'
selectObject(sound[i])
selectObject: sound
# Pause commands
beginPause("Viewing " + sound$)
if i > 1
button = endPause("Stop", "Previous",
...if i = total_sounds then "Finish" else "Next" fi,
...3, 1)
else
button = endPause("Stop",
...if i = total_sounds then "Finish" else "Next" fi,
...2, 1)
endif
editor_name$ = if total_textgrids then "TextGrid " else "Sound " fi + name$
nocheck editor 'editor_name$'
nocheck Close
nocheck endeditor
# New-style standalone command call
Rename: "SomeName"
# Command call with assignment
duration = Get total duration
# Multi-line command with modifier
pitch = noprogress To Pitch (ac): 0, 75, 15, "no",
...0.03, 0.45, 0.01, 0.35, 0.14, 600
# do-style command with assignment
minimum = do("Get minimum...", 0, 0, "Hertz", "Parabolic")
# New-style multi-line command call with broken strings
table = Create Table with column names: "table", 0,
..."file subject speaker
...f0 f1 f2 f3 " +
..."duration response"
removeObject: pitch, table
# Picture window commands
selectObject: sound
# do-style command
do("Select inner viewport...", 1, 6, 0.5, 1.5)
Black
Draw... 0 0 0 0 "no" Curve
Draw inner box
Text bottom: "yes", sound$
Erase all
# Demo window commands
demo Erase all
demo Select inner viewport... 0 100 0 100
demo Axes... 0 100 0 100
demo Paint rectangle... white 0 100 0 100
demo Text... 50 centre 50 half Click to finish
demoWaitForInput ( )
demo Erase all
demo Text: 50, "centre", 50, "half", "Finished"
endfor
# An old-style sendpraat block
sendpraat Praat
...'newline$' Create Sound as pure tone... "tone" 1 0 0.4 44100 440 0.2 0.01 0.01
...'newline$' Play
...'newline$' Remove
# A new-style sendpraat block
beginSendPraat: "Praat"
Create Sound as pure tone: "tone", 1, 0, 0.4, 44100, 440, 0.2, 0.01, 0.01
duration = Get total duration
Remove
endSendPraat: "duration"
appendInfoLine: "The generated sound lasted for ", duration, "seconds"
time = stopwatch
clearinfo
echo This script took
print 'time' seconds to
printline execute.
# Old-style procedure declaration
procedure oldStyle .str1$ .num .str2$
.local = 1
endproc
# New-style procedure declaration
procedure newStyle (.str1$, .num, .str2$)
.local = 1
endproc

View file

@ -20,7 +20,7 @@ class Range
end
end
{:id => 34, :key => "value"}
{:id => ?", :key => "value"}
herDocs = [<<'FOO', <<BAR, <<-BAZ, <<-`EXEC`] #comment

View file

@ -2,9 +2,9 @@
# Script to open a browser to current branch
# Repo formats:
# ssh git@github.com:richoH/gh_pr.git
# http https://richoH@github.com/richoH/gh_pr.git
# git git://github.com/richoH/gh_pr.git
# ssh git@github.com:richo/gh_pr.git
# http https://richoH@github.com/richo/gh_pr.git
# git git://github.com/richo/gh_pr.git
username=`git config --get github.user`

View file

@ -0,0 +1,72 @@
-- =============================================
-- Author: Morgan Yarbrough
-- Create date: 4/27/2015
-- Description: Test procedure that shows off language features.
-- Includes non-standard folding with region comments using either
-- line comments or block comments (both are demonstrated below).
-- This mode imitates SSMS and it designed to be used with SQL Server theme.
-- =============================================
CREATE PROCEDURE dbo.TestProcedure
--#region parameters
@vint INT = 1
,@vdate DATE = NULL
,@vdatetime DATETIME = DATEADD(dd, 1, GETDATE())
,@vvarchar VARCHAR(MAX) = ''
--#endregion
AS
BEGIN
/*#region set statements */
SET NOCOUNT ON;
SET XACT_ABORT ON;
SET QUOTED_IDENTIFIER ON;
/*#endregion*/
/**
* These comments will produce a fold widget
*/
-- folding demonstration
SET @vint = CASE
WHEN @vdate IS NULL
THEN 1
ELSE 2
END
-- another folding demonstration
IF @vint = 1
BEGIN
SET @vvarchar = 'one'
SET @vint = DATEDIFF(dd, @vdate, @vdatetime)
END
-- this mode handles strings properly
DECLARE @sql NVARCHAR(4000) = N'SELECT TOP(1) OrderID
FROM Orders
WHERE @OrderDate > GETDATE()'
-- this mode is aware of built in stored procedures
EXECUTE sp_executesql @sql
-- demonstrating some syntax highlighting
SELECT Orders.OrderID
,Customers.CompanyName
,DATEFROMPARTS(YEAR(GETDATE()), 1, 1) AS FirstDayOfYear
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID = Customers.CustomerID
WHERE CompanyName NOT LIKE '%something'
OR CompanyName IS NULL
OR CompanyName IN ('bla', 'nothing')
-- this mode includes snippets
-- place your cusor at the end of the line below and trigger auto complete (Ctrl+Space)
createpr
-- SQL Server allows using keywords as object names (not recommended) as long as they are wrapped in brackets
DATABASE -- keyword
[DATABASE] -- not a keyword
END

View file

@ -53,16 +53,16 @@ require("ace/commands/default_commands").commands.push({
return;
}
var rowCount = 10;
var rowCount = 10;
var w = {
row: row,
// rowCount: rowCount,
fixedWidth: true,
el: dom.createElement("div"),
editor: editor
editor: inlineEditor
};
var el = w.el;
el.appendChild(inlineEditor.container);
el.appendChild(inlineEditor.container);
if (!editor.session.widgetManager) {
editor.session.widgetManager = new LineWidgets(editor.session);
@ -96,9 +96,6 @@ require("ace/commands/default_commands").commands.push({
editor.keyBinding.addKeyboardHandler(kb);
inlineEditor.keyBinding.addKeyboardHandler(kb);
editor.on("changeSession", function(e) {
w.el.parentNode && w.el.parentNode.removeChild(w.el);
});
inlineEditor.setTheme("ace/theme/solarized_light");
}
});

View file

@ -116,7 +116,6 @@ exports.singleLineEditor = function(el) {
renderer.setStyle("ace_one-line");
var editor = new Editor(renderer);
new MultiSelect(editor);
editor.session.setUndoManager(new UndoManager());
editor.setShowPrintMargin(false);

View file

@ -46,4 +46,10 @@ body {
position: absolute;
right: 0;
border-left: 1px solid;
}
}
/* .ace_text-input {
z-index: 10!important;
opacity: 1!important;
background: rgb(84, 0, 255)!important;
}*/

View file

@ -29,14 +29,20 @@
}</pre>
<script src="../demo/kitchen-sink/require.js"></script>
<script src="../build/src/ace.js" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/javascript");
require(["ace/requirejs/text!src/ace"], function(e){
editor.setValue(e);
})
require.config({paths: {ace: "../build/src"}})
define('testace', ['ace/ace'],
function(ace, langtools) {
console.log("This is the testace module");
var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/javascript");
require(["ace/requirejs/text!src/ace"], function(e){
editor.setValue(e);
})
}
);
require(['testace'])
</script>
</body>

View file

@ -2,13 +2,13 @@
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Static Code highlighter using Ace</title>
<meta name="author" content="Matthew Kastor">
<title>Static Code highlighter using Ace</title>
<meta name="author" content="Matthew Kastor">
<style type="text/css">
.code {
width: 50%;
position: relative;
white-space: pre-wrap;
border: solid lightgrey 1px
}
</style>
</head>
@ -21,9 +21,8 @@
<div class="code" ace-mode="ace/mode/css" ace-theme="ace/theme/chrome" ace-gutter="true">
.code {
width: 50%;
position: relative;
white-space: pre-wrap;
border: solid lightgrey 1px
}
</div>
@ -35,6 +34,26 @@ function wobble (flam) {
</pre>
<div class="code" ace-mode="ace/mode/lua" ace-theme="ace/theme/chrome" ace-gutter="true" style="width: 30em;">
--[[--
num_args takes in 5.1 byte code and extracts the number of arguments from its function header.
--]]--
function int(t)
return t:byte(1) + t:byte(2) * 0x100 + t:byte(3) * 0x10000 + t:byte(4) * 0x1000000
end
function num_args(func)
local dump = string.dump(func)
local offset, cursor = int(dump:sub(13)), offset + 26
--Get the params and var flag (whether there's a ... in the param)
return dump:sub(cursor):byte(), dump:sub(cursor+1):byte()
end
</div>
<script src="kitchen-sink/require.js"></script>
<script>
require.config({paths: { "ace" : "../lib/ace"}});

View file

@ -2,15 +2,13 @@
* Simple node.js server, which generates the synax highlighted version of itself
* using the Ace modes and themes on the server and serving a static web page.
*/
// $'
// include ace search path and modules
require("amd-loader");
// load jsdom, which is required by Ace
require("../../lib/ace/test/mockdom");
var http = require("http");
var fs = require("fs");
var resolve = require("path").resolve;
// load the highlighter and the desired mode and theme
var highlighter = require("../../lib/ace/ext/static_highlight");
@ -20,15 +18,22 @@ var theme = require("../../lib/ace/theme/twilight");
var port = process.env.PORT || 2222;
http.createServer(function(req, res) {
var url = req.url;
var path = /[^#?\x00]*/.exec(url)[0];
var root = resolve(__dirname + "/../../").replace(/\\/g, "/");
path = resolve(root + "/" + path).replace(/\\/g, "/");
if (path.indexOf(root + "/") != 0)
path = __filename;
res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"});
fs.readFile(__filename, "utf8", function(err, data) {
fs.readFile(path, "utf8", function(err, data) {
if (err) data = err.message;
var highlighted = highlighter.render(data, new JavaScriptMode(), theme);
res.end(
'<html><body>\n' +
'<style type="text/css" media="screen">\n' +
highlighted.css +
'</style>\n' +
highlighted.html +
highlighted.html +
'</body></html>'
);
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View file

@ -1,39 +1,49 @@
var editor;
var embedded_editor;
$(function() {
ace.config.set("workerPath", "build/src-min");
editor = ace.edit("ace_editor_demo");
editor.container.style.opacity = "";
embedded_editor = ace.edit("embedded_ace_code");
embedded_editor.container.style.opacity = "";
embedded_editor.session.setMode("ace/mode/html");
embedded_editor.setAutoScrollEditorIntoView(true);
embedded_editor.setOption("maxLines", 40);
editor.setOptions({
maxLines: 30,
mode: "ace/mode/javascript",
autoScrollEditorIntoView: true
});
ace.config.loadModule("ace/ext/emmet", function() {
ace.require("ace/lib/net").loadScript("http://nightwing.github.io/emmet-core/emmet.js", function() {
embedded_editor.setOption("enableEmmet", true);
editor.setOption("enableEmmet", true);
});
});
ace.config.loadModule("ace/ext/language_tools", function() {
embedded_editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
if (typeof ace !== "undefined") {
ace.config.set("workerPath", "build/src-min");
editor = ace.edit("ace_editor_demo");
editor.container.style.opacity = "";
embedded_editor = ace.edit("embedded_ace_code");
embedded_editor.container.style.opacity = "";
embedded_editor.session.setMode("ace/mode/html");
embedded_editor.setAutoScrollEditorIntoView(true);
embedded_editor.setOption("maxLines", 40);
editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
maxLines: 30,
mode: "ace/mode/javascript",
autoScrollEditorIntoView: true
});
});
ace.config.loadModule("ace/ext/emmet", function() {
ace.require("ace/lib/net").loadScript("http://cloud9ide.github.io/emmet-core/emmet.js", function() {
embedded_editor.setOption("enableEmmet", true);
editor.setOption("enableEmmet", true);
});
});
ace.config.loadModule("ace/ext/language_tools", function() {
embedded_editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
});
} else {
document.body.insertAdjacentHTML("afterbegin", '<div class="bs-docs-example">\
<div class="alert alert-error">\
<button type="button" class="close" data-dismiss="alert">\xd7</button>\
<strong>Oh No!</strong> Couldn\'t load <code>build/src/ace.js</code>.<br>\
You can build it by running <code>node Makefile.dryice.js</code><br>\
Or download older version by running <code>git submodule update --init --recursive</code><br>\
</div>\
</div>');
}
$("ul.menu-list").mousedown(function(e) {
if (e.button === 1) {
e.preventDefault();
@ -137,22 +147,22 @@ $(function() {
});
});
$(window).on("hashchange", function(e) {
_gaq.push(['_trackPageview',location.pathname + location.search + location.hash]);
tabs.each(function() {
$(window).on("hashchange", function(e) {
_gaq.push(['_trackPageview',location.pathname + location.search + location.hash]);
tabs.each(function() {
var idx = $.bbq.getState("nav") || "about";
var section = e.fragment.split("&")[1] || "";
$(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click');
// handles dropping in from new link
var api = $.bbq.getState("api");
if (api) {
$(tab_a_selector + "[href='./api/" + api + ".html']").triggerHandler('click');
}
});
}).trigger("hashchange");
});
}).trigger("hashchange");
highlight();
highlight();
});
@ -161,7 +171,11 @@ function highlight() {
var highlighter = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom")
function qsa(sel) {
return Array.apply(null, document.querySelectorAll(sel));
var els = document.querySelectorAll(sel);
var result = [];
for (var i = 0, l = els.length; i < l; i++)
result[i] = els[i];
return result;
}
qsa("code[class]").forEach(function(el) {

View file

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="../demo/kitchen-sink/require.js"></script>
<script type="text/javascript">
require.config({
paths: { ace: "../lib/ace" },
waitSeconds: 0
});
</script>
</head>
<body>
<p><button onclick="toggleEditor()">Toggle editor</button></p>
<div id="container"></div>
<script>
var editor;
var counter = 0
function toggleEditor() {
if (!editor) {
var root = document.createElement("div");
root.style.height = "100px";
root.setAttribute("id", "editor");
root.textContent = "function foo(items) {\nvar x = 'All this is syntax highlighted';\nreturn x;\n}";
document.getElementById("container").appendChild(root);
editor = ace.edit(root);
if (counter++ % 2)
editor.setTheme("ace/theme/monokai");
else
editor.setTheme("ace/theme/clouds");
editor.session.setMode("ace/mode/javascript");
} else {
editor.destroy();
var el = editor.container;
el.parentNode.removeChild(el);
editor.container = null
editor.renderer = null
editor = null;
var root = document.getElementById("editor")
if (root)
root.parentNode.removeChild(root);
}
}
require(["ace/ace"], function(ace) {
window.ace = ace;
toggleEditor();
})
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -11,16 +11,10 @@
commit %commit%
-->
<!--DEVEL-->
<link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
<script async="true" src="https://use.edgefonts.net/source-code-pro.js"></script>
<!--DEVEL-->
<link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
<script async="true" src="https://use.edgefonts.net/source-code-pro.js"></script>
<link href="./doc/site/images/favicon.ico" rel="icon" type="image/x-icon">
<!--PACKAGE
<link rel="stylesheet" href="kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
<script async="true" src="https://use.edgefonts.net/source-code-pro.js"></script>
PACKAGE-->
</head>
<body>
<div id="optionsPanel" style="position:absolute;height:100%;width:260px">
@ -263,7 +257,9 @@
<a href="http://ace.c9.io">
<img id="ace-logo" src="doc/site/images/ace-logo.png" style="width: 134px;margin: 46px 0px 4px 66px;">
</a>
<div><a target="_test" href="./lib/ace/test/tests.html"
style="color: whitesmoke; text-align: left; padding: 1em;">tests</a>
</div>
</div>
</div>
</div>
@ -287,7 +283,7 @@
<script src="src/ace.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script>
<script src="src/keybinding-vim.js"></script>
<script src="src/keybinding-emacs.js"></script>
<script src="kitchen-sink/demo.js"></script>
<script src="demo/kitchen-sink/demo.js"></script>
<script type="text/javascript" charset="utf-8">
require("kitchen-sink/demo");
</script>

View file

@ -79,11 +79,21 @@ exports.edit = function(el) {
throw new Error("ace.edit can't find div #" + _id);
}
if (el.env && el.env.editor instanceof Editor)
if (el && el.env && el.env.editor instanceof Editor)
return el.env.editor;
var doc = exports.createEditSession(dom.getInnerText(el));
el.innerHTML = '';
var value = "";
if (el && /input|textarea/i.test(el.tagName)) {
var oldNode = el;
value = oldNode.value;
el = dom.createElement("pre");
oldNode.parentNode.replaceChild(el, oldNode);
} else {
value = dom.getInnerText(el);
el.innerHTML = '';
}
var doc = exports.createEditSession(value);
var editor = new Editor(new Renderer(el));
editor.setSession(doc);
@ -93,11 +103,13 @@ exports.edit = function(el) {
editor: editor,
onResize: editor.resize.bind(editor, null)
};
if (oldNode) env.textarea = oldNode;
event.addListener(window, "resize", env.onResize);
editor.on("destroy", function() {
event.removeListener(window, "resize", env.onResize);
env.editor.container.env = null; // prevent memory leak on old ie
});
el.env = editor.env = env;
editor.container.env = editor.env = env;
return editor;
};

View file

@ -36,7 +36,7 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
/**
*
* Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated.
* Defines a floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the anchor is updated.
*
* @class Anchor
**/
@ -99,72 +99,54 @@ var Anchor = exports.Anchor = function(doc, row, column) {
* - `value`: An object describing the new Anchor position
*
**/
this.onChange = function(e) {
var delta = e.data;
var range = delta.range;
if (range.start.row == range.end.row && range.start.row != this.row)
this.onChange = function(delta) {
if (delta.start.row == delta.end.row && delta.start.row != this.row)
return;
if (range.start.row > this.row)
if (delta.start.row > this.row)
return;
if (range.start.row == this.row && range.start.column > this.column)
return;
var row = this.row;
var column = this.column;
var start = range.start;
var end = range.end;
if (delta.action === "insertText") {
if (start.row === row && start.column <= column) {
if (start.column === column && this.$insertRight) {
// do nothing
} else if (start.row === end.row) {
column += end.column - start.column;
} else {
column -= start.column;
row += end.row - start.row;
}
} else if (start.row !== end.row && start.row < row) {
row += end.row - start.row;
}
} else if (delta.action === "insertLines") {
if (start.row === row && column === 0 && this.$insertRight) {
// do nothing
}
else if (start.row <= row) {
row += end.row - start.row;
}
} else if (delta.action === "removeText") {
if (start.row === row && start.column < column) {
if (end.column >= column)
column = start.column;
else
column = Math.max(0, column - (end.column - start.column));
} else if (start.row !== end.row && start.row < row) {
if (end.row === row)
column = Math.max(0, column - end.column) + start.column;
row -= (end.row - start.row);
} else if (end.row === row) {
row -= end.row - start.row;
column = Math.max(0, column - end.column) + start.column;
}
} else if (delta.action == "removeLines") {
if (start.row <= row) {
if (end.row <= row)
row -= end.row - start.row;
else {
row = start.row;
column = 0;
}
}
}
this.setPosition(row, column, true);
var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
this.setPosition(point.row, point.column, true);
};
function $pointsInOrder(point1, point2, equalPointsInOrder) {
var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
}
function $getTransformedPoint(delta, point, moveIfEqual) {
// Get delta info.
var deltaIsInsert = delta.action == "insert";
var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
var deltaStart = delta.start;
var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
// DELTA AFTER POINT: No change needed.
if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
return {
row: point.row,
column: point.column
};
}
// DELTA BEFORE POINT: Move point by delta shift.
if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
return {
row: point.row + deltaRowShift,
column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
};
}
// DELTA ENVELOPS POINT (delete only): Move point to delta start.
// TODO warn if delta.action != "remove" ?
return {
row: deltaStart.row,
column: deltaStart.column
};
}
/**
* Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped.
@ -201,7 +183,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
};
/**
* When called, the `'change'` event listener is removed.
* When called, the `"change"` event listener is removed.
*
**/
this.detach = function() {

View file

@ -71,7 +71,7 @@ module.exports = {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4);
doc.insertLines(1, ["123", "456"]);
doc.insertFullLines(1, ["123", "456"]);
assert.position(anchor.getPosition(), 3, 4);
},
@ -105,7 +105,7 @@ module.exports = {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4);
doc.insertNewLine({row: 0, column: 0});
doc.insertMergedLines({row: 0, column: 0}, ['', '']);
assert.position(anchor.getPosition(), 2, 4);
},
@ -113,7 +113,7 @@ module.exports = {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4);
doc.insertNewLine({row: 1, column: 2});
doc.insertMergedLines({row: 1, column: 2}, ['', '']);
assert.position(anchor.getPosition(), 2, 2);
},
@ -145,7 +145,7 @@ module.exports = {
var doc = new Document("juhu\n1\n2\nkinners");
var anchor = new Anchor(doc, 3, 4);
doc.removeLines(1, 2);
doc.removeFullLines(1, 2);
assert.position(anchor.getPosition(), 1, 4);
},
@ -169,7 +169,7 @@ module.exports = {
var doc = new Document("juhu\nkinners\n123");
var anchor = new Anchor(doc, 1, 5);
doc.removeLines(1, 1);
doc.removeFullLines(1, 1);
assert.position(anchor.getPosition(), 1, 0);
},
@ -208,9 +208,9 @@ module.exports = {
var doc = new Document("juhu\nkinners\n123");
var anchor = new Anchor(doc, 2, 4);
doc.removeLines(0, 3);
doc.removeFullLines(0, 3);
assert.position(anchor.getPosition(), 0, 0);
doc.insertLines(0, ["a", "b", "c"]);
doc.insertFullLines(0, ["a", "b", "c"]);
assert.position(anchor.getPosition(), 3, 0);
assert.equal(doc.getValue(), "a\nb\nc\n");
}

108
lib/ace/apply_delta.js Normal file
View file

@ -0,0 +1,108 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
function throwDeltaError(delta, errorText){
console.log("Invalid Delta:", delta);
throw "Invalid Delta: " + errorText;
}
function positionInDocument(docLines, position) {
return position.row >= 0 && position.row < docLines.length &&
position.column >= 0 && position.column <= docLines[position.row].length;
}
function validateDelta(docLines, delta) {
// Validate action string.
if (delta.action != "insert" && delta.action != "remove")
throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
// Validate lines type.
if (!(delta.lines instanceof Array))
throwDeltaError(delta, "delta.lines must be an Array");
// Validate range type.
if (!delta.start || !delta.end)
throwDeltaError(delta, "delta.start/end must be an present");
// Validate that the start point is contained in the document.
var start = delta.start;
if (!positionInDocument(docLines, delta.start))
throwDeltaError(delta, "delta.start must be contained in document");
// Validate that the end point is contained in the document (remove deltas only).
var end = delta.end;
if (delta.action == "remove" && !positionInDocument(docLines, end))
throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
// Validate that the .range size matches the .lines size.
var numRangeRows = end.row - start.row;
var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
throwDeltaError(delta, "delta.range must match delta lines");
}
exports.applyDelta = function(docLines, delta, doNotValidate) {
// disabled validation since it breaks autocompletion popup
// if (!doNotValidate)
// validateDelta(docLines, delta);
var row = delta.start.row;
var startColumn = delta.start.column;
var line = docLines[row] || "";
switch (delta.action) {
case "insert":
var lines = delta.lines;
if (lines.length === 1) {
docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
} else {
var args = [row, 1].concat(delta.lines);
docLines.splice.apply(docLines, args);
docLines[row] = line.substring(0, startColumn) + docLines[row];
docLines[row + delta.lines.length - 1] += line.substring(startColumn);
}
break;
case "remove":
var endColumn = delta.end.column;
var endRow = delta.end.row;
if (row === endRow) {
docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
} else {
docLines.splice(
row, endRow - row + 1,
line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
);
}
break;
}
}
});

View file

@ -36,11 +36,14 @@ var AcePopup = require("./autocomplete/popup").AcePopup;
var util = require("./autocomplete/util");
var event = require("./lib/event");
var lang = require("./lib/lang");
var dom = require("./lib/dom");
var snippetManager = require("./snippets").snippetManager;
var Autocomplete = function() {
this.autoInsert = true;
this.autoInsert = false;
this.autoSelect = true;
this.exactMatch = false;
this.gatherCompletionsId = 0;
this.keyboardHandler = new HashHandler();
this.keyboardHandler.bindKeys(this.commands);
@ -52,10 +55,11 @@ var Autocomplete = function() {
this.changeTimer = lang.delayedCall(function() {
this.updateCompletions(true);
}.bind(this));
this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
};
(function() {
this.gatherCompletionsId = 0;
this.$init = function() {
this.popup = new AcePopup(document.body || document.documentElement);
@ -64,6 +68,14 @@ var Autocomplete = function() {
e.stop();
}.bind(this));
this.popup.focus = this.editor.focus.bind(this.editor);
this.popup.on("show", this.tooltipTimer.bind(null, null));
this.popup.on("select", this.tooltipTimer.bind(null, null));
this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
return this.popup;
};
this.getPopup = function() {
return this.popup || this.$init();
};
this.openPopup = function(editor, prefix, keepPopupPosition) {
@ -72,6 +84,8 @@ var Autocomplete = function() {
this.popup.setData(this.completions.filtered);
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
var renderer = editor.renderer;
this.popup.setRow(this.autoSelect ? 0 : -1);
if (!keepPopupPosition) {
@ -86,9 +100,11 @@ var Autocomplete = function() {
var rect = editor.container.getBoundingClientRect();
pos.top += rect.top - renderer.layerConfig.offset;
pos.left += rect.left - editor.renderer.scrollLeft;
pos.left += renderer.$gutterLayer.gutterWidth;
pos.left += renderer.gutterWidth;
this.popup.show(pos, lineHeight);
} else if (keepPopupPosition && !prefix) {
this.detach();
}
};
@ -99,14 +115,14 @@ var Autocomplete = function() {
this.editor.off("mousedown", this.mousedownListener);
this.editor.off("mousewheel", this.mousewheelListener);
this.changeTimer.cancel();
this.hideDocTooltip();
if (this.popup && this.popup.isOpen) {
this.gatherCompletionsId = this.gatherCompletionsId + 1;
}
if (this.popup)
this.gatherCompletionsId += 1;
if (this.popup && this.popup.isOpen)
this.popup.hide();
if (this.base)
this.base.detach();
this.activated = false;
this.completions = this.base = null;
};
@ -122,12 +138,18 @@ var Autocomplete = function() {
this.detach();
};
this.blurListener = function() {
this.blurListener = function(e) {
// we have to check if activeElement is a child of popup because
// on IE preventDefault doesn't stop scrollbar from being focussed
var el = document.activeElement;
if (el != this.editor.textInput.getElement() && el.parentNode != this.popup.container)
var text = this.editor.textInput.getElement();
var fromTooltip = e.relatedTarget && e.relatedTarget == this.tooltipNode;
var container = this.popup && this.popup.container;
if (el != text && el.parentNode != container && !fromTooltip
&& el != this.tooltipNode && e.relatedTarget != text
) {
this.detach();
}
};
this.mousedownListener = function(e) {
@ -159,7 +181,7 @@ var Autocomplete = function() {
return false;
if (data.completer && data.completer.insertMatch) {
data.completer.insertMatch(this.editor);
data.completer.insertMatch(this.editor, data);
} else {
if (this.completions.filterText) {
var ranges = this.editor.selection.getAllRanges();
@ -176,6 +198,7 @@ var Autocomplete = function() {
this.detach();
};
this.commands = {
"Up": function(editor) { editor.completer.goTo("up"); },
"Down": function(editor) { editor.completer.goTo("down"); },
@ -183,7 +206,6 @@ var Autocomplete = function() {
"Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },
"Esc": function(editor) { editor.completer.detach(); },
"Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
"Return": function(editor) { return editor.completer.insertMatch(); },
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
"Tab": function(editor) {
@ -205,8 +227,8 @@ var Autocomplete = function() {
var line = session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
this.base = editor.getCursorPosition();
this.base.column -= prefix.length;
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
this.base.$insertRight = true;
var matches = [];
var total = editor.completers.length;
@ -240,7 +262,6 @@ var Autocomplete = function() {
editor.completer = this;
}
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
editor.on("changeSelection", this.changeListener);
editor.on("blur", this.blurListener);
editor.on("mousedown", this.mousedownListener);
@ -277,7 +298,7 @@ var Autocomplete = function() {
var prefix = results.prefix;
var matches = results && results.matches;
if (!matches || !matches.length)
return detachIfFinished();
@ -286,6 +307,10 @@ var Autocomplete = function() {
return;
this.completions = new FilteredList(matches);
if (this.exactMatch)
this.completions.exactMatch = true;
this.completions.setFilter(prefix);
var filtered = this.completions.filtered;
@ -298,7 +323,7 @@ var Autocomplete = function() {
return detachIfFinished();
// Autoinsert if one result
if (this.autoInsert && filtered.length == 1)
if (this.autoInsert && filtered.length == 1 && results.finished)
return this.insertMatch(filtered[0]);
this.openPopup(this.editor, prefix, keepPopupPosition);
@ -306,13 +331,74 @@ var Autocomplete = function() {
};
this.cancelContextMenu = function() {
var stop = function(e) {
this.editor.off("nativecontextmenu", stop);
if (e && e.domEvent)
event.stopEvent(e.domEvent);
}.bind(this);
setTimeout(stop, 10);
this.editor.on("nativecontextmenu", stop);
this.editor.$mouseHandler.cancelContextMenu();
};
this.updateDocTooltip = function() {
var popup = this.popup;
var all = popup.data;
var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]);
var doc = null;
if (!selected || !this.editor || !this.popup.isOpen)
return this.hideDocTooltip();
this.editor.completers.some(function(completer) {
if (completer.getDocTooltip)
doc = completer.getDocTooltip(selected);
return doc;
});
if (!doc)
doc = selected;
if (typeof doc == "string")
doc = {docText: doc};
if (!doc || !(doc.docHTML || doc.docText))
return this.hideDocTooltip();
this.showDocTooltip(doc);
};
this.showDocTooltip = function(item) {
if (!this.tooltipNode) {
this.tooltipNode = dom.createElement("div");
this.tooltipNode.className = "ace_tooltip ace_doc-tooltip";
this.tooltipNode.style.margin = 0;
this.tooltipNode.style.pointerEvents = "auto";
this.tooltipNode.tabIndex = -1;
this.tooltipNode.onblur = this.blurListener.bind(this);
}
var tooltipNode = this.tooltipNode;
if (item.docHTML) {
tooltipNode.innerHTML = item.docHTML;
} else if (item.docText) {
tooltipNode.textContent = item.docText;
}
if (!tooltipNode.parentNode)
document.body.appendChild(tooltipNode);
var popup = this.popup;
var rect = popup.container.getBoundingClientRect();
tooltipNode.style.top = popup.container.style.top;
tooltipNode.style.bottom = popup.container.style.bottom;
if (window.innerWidth - rect.right < 320) {
tooltipNode.style.right = window.innerWidth - rect.left + "px";
tooltipNode.style.left = "";
} else {
tooltipNode.style.left = (rect.right + 1) + "px";
tooltipNode.style.right = "";
}
tooltipNode.style.display = "block";
};
this.hideDocTooltip = function() {
this.tooltipTimer.cancel();
if (!this.tooltipNode) return;
var el = this.tooltipNode;
if (!this.editor.isFocused() && document.activeElement == el)
this.editor.focus();
this.tooltipNode = null;
if (el.parentNode)
el.parentNode.removeChild(el);
};
}).call(Autocomplete.prototype);
@ -322,19 +408,20 @@ Autocomplete.startCommand = {
exec: function(editor) {
if (!editor.completer)
editor.completer = new Autocomplete();
editor.completer.autoInsert =
editor.completer.autoInsert = false;
editor.completer.autoSelect = true;
editor.completer.showPopup(editor);
// needed for firefox on mac
// prevent ctrl-space opening context menu on firefox on mac
editor.completer.cancelContextMenu();
},
bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
};
var FilteredList = function(array, filterText, mutateData) {
var FilteredList = function(array, filterText) {
this.all = array;
this.filtered = array;
this.filterText = filterText || "";
this.exactMatch = false;
};
(function(){
this.setFilter = function(str) {
@ -352,7 +439,7 @@ var FilteredList = function(array, filterText, mutateData) {
// make unique
var prev = null;
matches = matches.filter(function(item){
var caption = item.value || item.caption || item.snippet;
var caption = item.snippet || item.caption || item.value;
if (caption === prev) return false;
prev = caption;
return true;
@ -371,23 +458,29 @@ var FilteredList = function(array, filterText, mutateData) {
var matchMask = 0;
var penalty = 0;
var index, distance;
// caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf
for (var j = 0; j < needle.length; j++) {
// TODO add penalty on case mismatch
var i1 = caption.indexOf(lower[j], lastIndex + 1);
var i2 = caption.indexOf(upper[j], lastIndex + 1);
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
if (index < 0)
if (this.exactMatch) {
if (needle !== caption.substr(0, needle.length))
continue loop;
distance = index - lastIndex - 1;
if (distance > 0) {
// first char mismatch should be more sensitive
if (lastIndex === -1)
penalty += 10;
penalty += distance;
}else{
// caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf
for (var j = 0; j < needle.length; j++) {
// TODO add penalty on case mismatch
var i1 = caption.indexOf(lower[j], lastIndex + 1);
var i2 = caption.indexOf(upper[j], lastIndex + 1);
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
if (index < 0)
continue loop;
distance = index - lastIndex - 1;
if (distance > 0) {
// first char mismatch should be more sensitive
if (lastIndex === -1)
penalty += 10;
penalty += distance;
}
matchMask = matchMask | (1 << index);
lastIndex = index;
}
matchMask = matchMask | (1 << index);
lastIndex = index;
}
item.matchMask = matchMask;
item.exactMatch = penalty ? 0 : 1;

View file

@ -31,7 +31,6 @@
define(function(require, exports, module) {
"use strict";
var EditSession = require("../edit_session").EditSession;
var Renderer = require("../virtual_renderer").VirtualRenderer;
var Editor = require("../editor").Editor;
var Range = require("../range").Range;
@ -52,6 +51,7 @@ var $singleLineEditor = function(el) {
editor.renderer.setHighlightGutterLine(false);
editor.$mouseHandler.$focusWaitTimout = 0;
editor.$highlightTagPending = true;
return editor;
};
@ -67,6 +67,7 @@ var AcePopup = function(parentNode) {
popup.renderer.setStyle("ace_autocomplete");
popup.setOption("displayIndentGuides", false);
popup.setOption("dragDelay", 150);
var noop = function(){};
@ -102,7 +103,7 @@ var AcePopup = function(parentNode) {
popup.session.removeMarker(hoverMarker.id);
hoverMarker.id = null;
}
}
};
popup.setSelectOnHover(false);
popup.on("mousemove", function(e) {
if (!lastMouseEvent) {
@ -170,15 +171,15 @@ var AcePopup = function(parentNode) {
};
var bgTokenizer = popup.session.bgTokenizer;
bgTokenizer.$tokenizeRow = function(i) {
var data = popup.data[i];
bgTokenizer.$tokenizeRow = function(row) {
var data = popup.data[row];
var tokens = [];
if (!data)
return tokens;
if (typeof data == "string")
data = {value: data};
if (!data.caption)
data.caption = data.value;
data.caption = data.value || data.name;
var last = -1;
var flag, c;
@ -195,8 +196,12 @@ var AcePopup = function(parentNode) {
if (data.meta) {
var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth;
if (data.meta.length + data.caption.length < maxW - 2)
tokens.push({type: "rightAlignedText", value: data.meta});
var metaData = data.meta;
if (metaData.length + data.caption.length > maxW - 2) {
// trim meta to fit this popup and add ellipsis
metaData = metaData.substr(0, maxW - data.caption.length - 3) + "\u2026"
}
tokens.push({type: "rightAlignedText", value: metaData});
}
return tokens;
};
@ -205,7 +210,9 @@ var AcePopup = function(parentNode) {
popup.session.$computeWidth = function() {
return this.screenWidth = 0;
}
};
popup.$blockScrolling = Infinity;
// public
popup.isOpen = false;
@ -213,8 +220,8 @@ var AcePopup = function(parentNode) {
popup.data = [];
popup.setData = function(list) {
popup.data = list || [];
popup.setValue(lang.stringRepeat("\n", list.length), -1);
popup.data = list || [];
popup.setRow(0);
};
popup.getData = function(row) {
@ -239,6 +246,7 @@ var AcePopup = function(parentNode) {
popup.on("changeSelection", function() {
if (popup.isOpen)
popup.setRow(popup.selection.lead.row);
popup.renderer.scrollCursorIntoView();
});
popup.hide = function() {
@ -333,4 +341,4 @@ dom.importCssString("\
exports.AcePopup = AcePopup;
});
});

View file

@ -68,7 +68,7 @@ define(function(require, exports, module) {
var wordList = Object.keys(wordScore);
callback(null, wordList.map(function(word) {
return {
name: word,
caption: word,
value: word,
score: wordScore[word],
meta: "local"

View file

@ -36,8 +36,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
/**
*
*
* Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use.
*
* If a certain row is changed, everything below that row is re-tokenized.
@ -50,8 +48,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
* @param {Tokenizer} tokenizer The tokenizer to use
* @param {Editor} editor The editor to associate with
*
*
*
* @constructor
**/
@ -72,11 +68,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
var endLine = -1;
var doc = self.doc;
var startLine = currentLine;
while (self.lines[currentLine])
currentLine++;
var startLine = currentLine;
var len = doc.getLength();
var processedLines = 0;
self.running = false;
@ -89,10 +84,9 @@ var BackgroundTokenizer = function(tokenizer, editor) {
// only check every 5 lines
processedLines ++;
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
self.running = setTimeout(self.$worker, 20);
self.currentLine = currentLine;
return;
break;
}
}
self.currentLine = currentLine;
@ -177,13 +171,12 @@ var BackgroundTokenizer = function(tokenizer, editor) {
}
this.$updateOnChange = function(delta) {
var range = delta.range;
var startRow = range.start.row;
var len = range.end.row - startRow;
var startRow = delta.start.row;
var len = delta.end.row - startRow;
if (len === 0) {
this.lines[startRow] = null;
} else if (delta.action == "removeText" || delta.action == "removeLines") {
} else if (delta.action == "remove") {
this.lines.splice(startRow, len + 1, null);
this.states.splice(startRow, len + 1, null);
} else {

View file

@ -75,6 +75,49 @@ module.exports = {
forceTokenize(doc)
testStates(doc, ["comment_regex_allowed", "start", "no_regex"])
},
"test background tokenizer sends update event" : function() {
var doc = new EditSession([
"/*",
"var",
"juhu",
"*/"
]);
doc.setMode("./mode/javascript");
var updateEvent = null;
doc.bgTokenizer.on("update", function(e) {
updateEvent = e.data;
});
function checkEvent(first, last) {
assert.ok(!updateEvent, "unneccessary update event");
doc.bgTokenizer.running = 1;
doc.bgTokenizer.$worker();
assert.ok(updateEvent);
assert.equal([first, last] + "",
[updateEvent.first, updateEvent.last] + "")
updateEvent = null;
}
forceTokenize(doc);
var comment = "comment_regex_allowed";
testStates(doc, [comment, comment, comment, "start"]);
doc.remove(new Range(0,0,0,2));
testStates(doc, [comment, comment, comment, "start"]);
checkEvent(0, 3);
testStates(doc, ["start", "no_regex", "no_regex", "regex"]);
// insert /* and and press down several times quickly
doc.insert({row:0, column:0}, "/*");
doc.getTokens(0);
doc.getTokens(1);
doc.getTokens(2);
checkEvent(0, 3);
forceTokenize(doc);
testStates(doc, [comment, comment, comment, "start"]);
}
};

View file

@ -2,38 +2,44 @@ define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var HashHandler = require("../keyboard/hash_handler").HashHandler;
var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
var EventEmitter = require("../lib/event_emitter").EventEmitter;
/**
* @class CommandManager
*
*
**/
/**
* new CommandManager(platform, commands)
* @param {String} platform Identifier for the platform; must be either `'mac'` or `'win'`
* @param {String} platform Identifier for the platform; must be either `"mac"` or `"win"`
* @param {Array} commands A list of commands
*
**/
var CommandManager = function(platform, commands) {
HashHandler.call(this, commands, platform);
MultiHashHandler.call(this, commands, platform);
this.byName = this.commands;
this.setDefaultHandler("exec", function(e) {
return e.command.exec(e.editor, e.args || {});
});
};
oop.inherits(CommandManager, HashHandler);
oop.inherits(CommandManager, MultiHashHandler);
(function() {
oop.implement(this, EventEmitter);
this.exec = function(command, editor, args) {
if (typeof command === 'string')
if (Array.isArray(command)) {
for (var i = command.length; i--; ) {
if (this.exec(command[i], editor, args)) return true;
}
return false;
}
if (typeof command === "string")
command = this.commands[command];
if (!command)
@ -43,10 +49,10 @@ oop.inherits(CommandManager, HashHandler);
return false;
var e = {editor: editor, command: command, args: args};
var retvalue = this._emit("exec", e);
e.returnValue = this._emit("exec", e);
this._signal("afterExec", e);
return retvalue === false ? false : true;
return e.returnValue === false ? false : true;
};
this.toggleRecording = function(editor) {

View file

@ -188,7 +188,7 @@ module.exports = {
assert.equal(command, "cm2");
var command = this.cm.findKeyCommand(0, "return");
assert.equal(command, "cm3");
assert.equal(command + "", ["cm4", "cm3"] + "");
}
};

View file

@ -97,29 +97,33 @@ exports.commands = [{
name: "fold",
bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
exec: function(editor) { editor.session.toggleFold(false); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
name: "unfold",
bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
exec: function(editor) { editor.session.toggleFold(true); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
name: "toggleFoldWidget",
bindKey: bindKey("F2", "F2"),
exec: function(editor) { editor.session.toggleFoldWidget(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
name: "toggleParentFoldWidget",
bindKey: bindKey("Alt-F2", "Alt-F2"),
exec: function(editor) { editor.session.toggleFoldWidget(true); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
name: "foldall",
bindKey: bindKey("Ctrl-Alt-0", "Ctrl-Command-Option-0"),
bindKey: bindKey(null, "Ctrl-Command-Option-0"),
exec: function(editor) { editor.session.foldAll(); },
scrollIntoView: "center",
readOnly: true
@ -205,12 +209,14 @@ exports.commands = [{
bindKey: bindKey("Shift-Up", "Shift-Up"),
exec: function(editor) { editor.getSelection().selectUp(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "golineup",
bindKey: bindKey("Up", "Up|Ctrl-P"),
exec: function(editor, args) { editor.navigateUp(args.times); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selecttoend",
@ -392,17 +398,38 @@ exports.commands = [{
readOnly: true
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-P", "Ctrl-Shift-P"),
bindKey: bindKey("Ctrl-P", "Ctrl-P"),
exec: function(editor) { editor.jumpToMatching(); },
multiSelectAction: "forEach",
scrollIntoView: "animate",
readOnly: true
}, {
name: "selecttomatching",
bindKey: bindKey("Ctrl-Shift-P", null),
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(true); },
multiSelectAction: "forEach",
scrollIntoView: "animate",
readOnly: true
},
}, {
name: "expandToMatching",
bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
exec: function(editor) { editor.jumpToMatching(true, true); },
multiSelectAction: "forEach",
scrollIntoView: "animate",
readOnly: true
}, {
name: "passKeysToBrowser",
bindKey: bindKey(null, null),
exec: function() {},
passEvent: true,
readOnly: true
}, {
name: "copy",
exec: function(editor) {
// placeholder for replay macro
},
readOnly: true
},
// commands disabled in readOnly mode
{
@ -418,6 +445,12 @@ exports.commands = [{
},
scrollIntoView: "cursor",
multiSelectAction: "forEach"
}, {
name: "paste",
exec: function(editor, args) {
editor.$handlePaste(args);
},
scrollIntoView: "cursor"
}, {
name: "removeline",
bindKey: bindKey("Ctrl-D", "Command-D"),
@ -452,11 +485,13 @@ exports.commands = [{
name: "modifyNumberUp",
bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
exec: function(editor) { editor.modifyNumber(1); },
scrollIntoView: "cursor",
multiSelectAction: "forEach"
}, {
name: "modifyNumberDown",
bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
exec: function(editor) { editor.modifyNumber(-1); },
scrollIntoView: "cursor",
multiSelectAction: "forEach"
}, {
name: "replace",
@ -623,7 +658,7 @@ exports.commands = [{
var isBackwards = editor.selection.isBackwards();
var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length
var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
var selectedCount = selectedText.replace(/\n\s*/, " ").length;
var insertLine = editor.session.doc.getLine(selectionStart.row);
@ -634,7 +669,7 @@ exports.commands = [{
curLine = " " + curLine;
}
insertLine += curLine;
};
}
if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
// Don't insert a newline at the end of the document

View file

@ -69,18 +69,14 @@ exports.iSearchCommands = [{
bindKey: {win: "Ctrl-F", mac: "Command-F"},
exec: function(iSearch) {
iSearch.cancelSearch(true);
},
readOnly: true,
isIncrementalSearchCommand: true
}
}, {
name: "searchForward",
bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
exec: function(iSearch, options) {
options.useCurrentOrPrevSearch = true;
iSearch.next(options);
},
readOnly: true,
isIncrementalSearchCommand: true
}
}, {
name: "searchBackward",
bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
@ -88,42 +84,30 @@ exports.iSearchCommands = [{
options.useCurrentOrPrevSearch = true;
options.backwards = true;
iSearch.next(options);
},
readOnly: true,
isIncrementalSearchCommand: true
}
}, {
name: "extendSearchTerm",
exec: function(iSearch, string) {
iSearch.addString(string);
},
readOnly: true,
isIncrementalSearchCommand: true
}
}, {
name: "extendSearchTermSpace",
bindKey: "space",
exec: function(iSearch) { iSearch.addString(' '); },
readOnly: true,
isIncrementalSearchCommand: true
exec: function(iSearch) { iSearch.addString(' '); }
}, {
name: "shrinkSearchTerm",
bindKey: "backspace",
exec: function(iSearch) {
iSearch.removeChar();
},
readOnly: true,
isIncrementalSearchCommand: true
}
}, {
name: 'confirmSearch',
bindKey: 'return',
exec: function(iSearch) { iSearch.deactivate(); },
readOnly: true,
isIncrementalSearchCommand: true
exec: function(iSearch) { iSearch.deactivate(); }
}, {
name: 'cancelSearch',
bindKey: 'esc|Ctrl-G',
exec: function(iSearch) { iSearch.deactivate(true); },
readOnly: true,
isIncrementalSearchCommand: true
exec: function(iSearch) { iSearch.deactivate(true); }
}, {
name: 'occurisearch',
bindKey: 'Ctrl-O',
@ -131,9 +115,7 @@ exports.iSearchCommands = [{
var options = oop.mixin({}, iSearch.$options);
iSearch.deactivate();
occurStartCommand.exec(iSearch.$editor, options);
},
readOnly: true,
isIncrementalSearchCommand: true
}
}, {
name: "yankNextWord",
bindKey: "Ctrl-w",
@ -142,9 +124,7 @@ exports.iSearchCommands = [{
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }),
string = ed.session.getTextRange(range);
iSearch.addString(string);
},
readOnly: true,
isIncrementalSearchCommand: true
}
}, {
name: "yankNextChar",
bindKey: "Ctrl-Alt-y",
@ -153,16 +133,35 @@ exports.iSearchCommands = [{
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }),
string = ed.session.getTextRange(range);
iSearch.addString(string);
},
readOnly: true,
isIncrementalSearchCommand: true
}
}, {
name: 'recenterTopBottom',
bindKey: 'Ctrl-l',
exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); },
readOnly: true,
isIncrementalSearchCommand: true
}];
exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); }
}, {
name: 'selectAllMatches',
bindKey: 'Ctrl-space',
exec: function(iSearch) {
var ed = iSearch.$editor,
hl = ed.session.$isearchHighlight,
ranges = hl && hl.cache ? hl.cache
.reduce(function(ranges, ea) {
return ranges.concat(ea ? ea : []); }, []) : [];
iSearch.deactivate(false);
ranges.forEach(ed.selection.addRange.bind(ed.selection));
}
}, {
name: 'searchAsRegExp',
bindKey: 'Alt-r',
exec: function(iSearch) {
iSearch.convertNeedleToRegExp();
}
}].map(function(cmd) {
cmd.readOnly = true;
cmd.isIncrementalSearchCommand = true;
cmd.scrollIntoView = "animate-cursor";
return cmd;
});
function IncrementalSearchKeyboardHandler(iSearch) {
this.$iSearch = iSearch;
@ -170,7 +169,7 @@ function IncrementalSearchKeyboardHandler(iSearch) {
oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
;(function() {
(function() {
this.attach = function(editor) {
var iSearch = this.$iSearch;
@ -179,15 +178,19 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
if (!e.command.isIncrementalSearchCommand) return undefined;
e.stopPropagation();
e.preventDefault();
return e.command.exec(iSearch, e.args || {});
var scrollTop = editor.session.getScrollTop();
var result = e.command.exec(iSearch, e.args || {});
editor.renderer.scrollCursorIntoView(null, 0.5);
editor.renderer.animateScrolling(scrollTop);
return result;
});
}
};
this.detach = function(editor) {
if (!this.$commandExecHandler) return;
editor.commands.removeEventListener('exec', this.$commandExecHandler);
delete this.$commandExecHandler;
}
};
var handleKeyboard$super = this.handleKeyboard;
this.handleKeyboard = function(data, hashId, key, keyCode) {
@ -200,7 +203,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
if (extendCmd) { return {command: extendCmd, args: key}; }
}
return {command: "null", passEvent: hashId == 0 || hashId == 4};
}
};
}).call(IncrementalSearchKeyboardHandler.prototype);

View file

@ -35,41 +35,49 @@ exports.defaultCommands = [{
name: "addCursorAbove",
exec: function(editor) { editor.selectMoreLines(-1); },
bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
scrollIntoView: "cursor",
readonly: true
}, {
name: "addCursorBelow",
exec: function(editor) { editor.selectMoreLines(1); },
bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
scrollIntoView: "cursor",
readonly: true
}, {
name: "addCursorAboveSkipCurrent",
exec: function(editor) { editor.selectMoreLines(-1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
scrollIntoView: "cursor",
readonly: true
}, {
name: "addCursorBelowSkipCurrent",
exec: function(editor) { editor.selectMoreLines(1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
scrollIntoView: "cursor",
readonly: true
}, {
name: "selectMoreBefore",
exec: function(editor) { editor.selectMore(-1); },
bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
scrollIntoView: "cursor",
readonly: true
}, {
name: "selectMoreAfter",
exec: function(editor) { editor.selectMore(1); },
bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
scrollIntoView: "cursor",
readonly: true
}, {
name: "selectNextBefore",
exec: function(editor) { editor.selectMore(-1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
scrollIntoView: "cursor",
readonly: true
}, {
name: "selectNextAfter",
exec: function(editor) { editor.selectMore(1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
scrollIntoView: "cursor",
readonly: true
}, {
name: "splitIntoLines",
@ -79,11 +87,13 @@ exports.defaultCommands = [{
}, {
name: "alignCursors",
exec: function(editor) { editor.alignCursors(); },
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
scrollIntoView: "cursor"
}, {
name: "findAll",
exec: function(editor) { editor.findAll(); },
bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
scrollIntoView: "cursor",
readonly: true
}];
@ -92,6 +102,7 @@ exports.multiSelectCommands = [{
name: "singleSelection",
bindKey: "esc",
exec: function(editor) { editor.exitMultiSelectMode(); },
scrollIntoView: "cursor",
readonly: true,
isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
}];

View file

@ -34,10 +34,12 @@ define(function(require, exports, module) {
var lang = require("./lib/lang");
var oop = require("./lib/oop");
var net = require("./lib/net");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var AppConfig = require("./lib/app_config").AppConfig;
module.exports = exports = new AppConfig();
var global = (function() {
return this;
return this || typeof window != "undefined" && window;
})();
var options = {
@ -69,8 +71,6 @@ exports.all = function() {
};
// module loading
oop.implement(exports, EventEmitter);
exports.moduleUrl = function(name, component) {
if (options.$moduleUrls[name])
return options.$moduleUrls[name];
@ -80,8 +80,8 @@ exports.moduleUrl = function(name, component) {
// todo make this configurable or get rid of '-'
var sep = component == "snippets" ? "/" : "-";
var base = parts[parts.length - 1];
if (sep == "-") {
var base = parts[parts.length - 1];
if (component == "worker" && sep == "-") {
var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
base = base.replace(re, "");
}
@ -142,7 +142,6 @@ exports.loadModule = function(moduleName, onLoad) {
net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
};
// initialization
function init(packaged) {
options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
@ -153,7 +152,11 @@ function init(packaged) {
var scriptOptions = {};
var scriptUrl = "";
var scripts = document.getElementsByTagName("script");
// Use currentScript.ownerDocument in case this file was loaded from imported document. (HTML Imports)
var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
var currentDocument = currentScript && currentScript.ownerDocument || document;
var scripts = currentDocument.getElementsByTagName("script");
for (var i=0; i<scripts.length; i++) {
var script = scripts[i];
@ -196,102 +199,4 @@ function deHyphenate(str) {
return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
}
var optionsProvider = {
setOptions: function(optList) {
Object.keys(optList).forEach(function(key) {
this.setOption(key, optList[key]);
}, this);
},
getOptions: function(optionNames) {
var result = {};
if (!optionNames) {
optionNames = Object.keys(this.$options);
} else if (!Array.isArray(optionNames)) {
result = optionNames;
optionNames = Object.keys(result);
}
optionNames.forEach(function(key) {
result[key] = this.getOption(key);
}, this);
return result;
},
setOption: function(name, value) {
if (this["$" + name] === value)
return;
var opt = this.$options[name];
if (!opt) {
if (typeof console != "undefined" && console.warn)
console.warn('misspelled option "' + name + '"');
return undefined;
}
if (opt.forwardTo)
return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
if (!opt.handlesSet)
this["$" + name] = value;
if (opt && opt.set)
opt.set.call(this, value);
},
getOption: function(name) {
var opt = this.$options[name];
if (!opt) {
if (typeof console != "undefined" && console.warn)
console.warn('misspelled option "' + name + '"');
return undefined;
}
if (opt.forwardTo)
return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
return opt && opt.get ? opt.get.call(this) : this["$" + name];
}
};
var defaultOptions = {};
/*
* option {name, value, initialValue, setterName, set, get }
*/
exports.defineOptions = function(obj, path, options) {
if (!obj.$options)
defaultOptions[path] = obj.$options = {};
Object.keys(options).forEach(function(key) {
var opt = options[key];
if (typeof opt == "string")
opt = {forwardTo: opt};
opt.name || (opt.name = key);
obj.$options[opt.name] = opt;
if ("initialValue" in opt)
obj["$" + opt.name] = opt.initialValue;
});
// implement option provider interface
oop.implement(obj, optionsProvider);
return this;
};
exports.resetOptions = function(obj) {
Object.keys(obj.$options).forEach(function(key) {
var opt = obj.$options[key];
if ("value" in opt)
obj.setOption(key, opt.value);
});
};
exports.setDefaultValue = function(path, name, value) {
var opts = defaultOptions[path] || (defaultOptions[path] = {});
if (opts[name]) {
if (opts.forwardTo)
exports.setDefaultValue(opts.forwardTo, name, value);
else
opts[name].value = value;
}
};
exports.setDefaultValues = function(path, optionHash) {
Object.keys(optionHash).forEach(function(key) {
exports.setDefaultValue(path, key, optionHash[key]);
});
};
});

View file

@ -43,7 +43,7 @@ module.exports = {
"test: path resolution" : function() {
config.set("packaged", "true");
var url = config.moduleUrl("kr_theme", "theme");
assert.equal(url, "theme-kr.js");
assert.equal(url, "theme-kr_theme.js");
config.set("basePath", "a/b");
url = config.moduleUrl("m/theme", "theme");
@ -117,12 +117,19 @@ module.exports = {
assert.equal(o.getOption("initialValue"), 8);
o.setOption("initialValue", 7);
assert.equal(o.getOption("opt2"), 7);
config.setDefaultValues("test_object", {
opt1: 1,
forwarded: 2
});
config.resetOptions(o);
assert.equal(o.getOption("opt1"), 1);
assert.equal(o.getOption("forwarded"), 2);
}
};
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec()
require("asyncjs").test.testcase(module.exports).exec();
}

View file

@ -1,9 +1,7 @@
.ace_editor {
position: relative;
overflow: hidden;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
font-size: 12px;
line-height: normal;
font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
direction: ltr;
}
@ -17,6 +15,7 @@
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: text;
}
.ace_content {
@ -24,14 +23,9 @@
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: text;
min-width: 100%;
}
.ace_dragging, .ace_dragging * {
cursor: move !important;
}
.ace_dragging .ace_scroller:before{
position: absolute;
top: 0;
@ -155,8 +149,8 @@
}
.ace_text-input.ace_composition {
background: #f8f8f8;
color: #111;
background: inherit;
color: inherit;
z-index: 1000;
opacity: 1;
text-indent: 0;
@ -166,6 +160,8 @@
z-index: 1;
position: absolute;
overflow: hidden;
/* workaround for chrome bug https://github.com/ajaxorg/ace/issues/2312*/
word-wrap: normal;
white-space: pre;
height: 100%;
width: 100%;
@ -211,7 +207,7 @@
}
.ace_overwrite-cursors .ace_cursor {
border-left-width: 0px;
border-left-width: 0;
border-bottom: 1px solid;
}
@ -220,10 +216,7 @@
}
.ace_smooth-blinking .ace_cursor {
-moz-transition: opacity 0.18s;
-webkit-transition: opacity 0.18s;
-o-transition: opacity 0.18s;
-ms-transition: opacity 0.18s;
transition: opacity 0.18s;
}
@ -277,8 +270,6 @@
color: transparent;
border: 1px solid black;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
cursor: pointer;
@ -302,7 +293,6 @@
border-radius: 1px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
color: black;
display: block;
max-width: 100%;
padding: 3px 4px;
position: fixed;
@ -359,16 +349,12 @@
.ace_fold-widget:hover {
border: 1px solid rgba(0, 0, 0, 0.3);
background-color: rgba(255, 255, 255, 0.2);
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
}
.ace_fold-widget:active {
border: 1px solid rgba(0, 0, 0, 0.4);
background-color: rgba(0, 0, 0, 0.05);
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}
/**
@ -388,8 +374,6 @@
background-color: rgba(255, 255, 255, 0.1);
}
.ace_dark .ace_fold-widget:active {
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
}
@ -399,19 +383,13 @@
}
.ace_fade-fold-widgets .ace_fold-widget {
-moz-transition: opacity 0.4s ease 0.05s;
-webkit-transition: opacity 0.4s ease 0.05s;
-o-transition: opacity 0.4s ease 0.05s;
-ms-transition: opacity 0.4s ease 0.05s;
transition: opacity 0.4s ease 0.05s;
opacity: 0;
}
.ace_fade-fold-widgets:hover .ace_fold-widget {
-moz-transition: opacity 0.05s ease 0.05s;
-webkit-transition: opacity 0.05s ease 0.05s;
-o-transition: opacity 0.05s ease 0.05s;
-ms-transition: opacity 0.05s ease 0.05s;
transition: opacity 0.05s ease 0.05s;
opacity:1;
}
@ -444,3 +422,30 @@
position: absolute;
z-index: 8;
}
/*
styles = []
for (var i = 1; i < 16; i++) {
styles.push(".ace_br" + i + "{" + (
["top-left", "top-right", "bottom-right", "bottom-left"]
).map(function(x, j) {
return i & (1<<j) ? "border-" + x + "-radius: 3px;" : ""
}).filter(Boolean).join(" ") + "}")
}
styles.join("\n")
*/
.ace_br1 {border-top-left-radius : 3px;}
.ace_br2 {border-top-right-radius : 3px;}
.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}
.ace_br4 {border-bottom-right-radius: 3px;}
.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}
.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}
.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}
.ace_br8 {border-bottom-left-radius : 3px;}
.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}
.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}
.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}

View file

@ -32,36 +32,36 @@ define(function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var applyDelta = require("./apply_delta").applyDelta;
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Range = require("./range").Range;
var Anchor = require("./anchor").Anchor;
/**
* Contains the text of the document. Document can be attached to several [[EditSession `EditSession`]]s.
*
* At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index.
*
* @class Document
**/
/**
/**
*
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
* @param {String | Array} text The starting text
* @constructor
**/
var Document = function(text) {
this.$lines = [];
var Document = function(textOrLines) {
this.$lines = [""];
// There has to be one line at least in the document. If you pass an empty
// string to the insert function, nothing will happen. Workaround.
if (text.length === 0) {
if (textOrLines.length === 0) {
this.$lines = [""];
} else if (Array.isArray(text)) {
this._insertLines(0, text);
} else if (Array.isArray(textOrLines)) {
this.insertMergedLines({row: 0, column: 0}, textOrLines);
} else {
this.insert({row: 0, column:0}, text);
this.insert({row: 0, column:0}, textOrLines);
}
};
@ -75,9 +75,9 @@ var Document = function(text) {
* @param {String} text The text to use
**/
this.setValue = function(text) {
var len = this.getLength();
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
this.insert({row: 0, column:0}, text);
var len = this.getLength() - 1;
this.remove(new Range(0, 0, len, this.getLine(len).length));
this.insert({row: 0, column: 0}, text);
};
/**
@ -98,7 +98,7 @@ var Document = function(text) {
};
/**
* Splits a string of text on any newline (`\n`) or carriage-return ('\r') characters.
* Splits a string of text on any newline (`\n`) or carriage-return (`\r`) characters.
*
* @method $split
* @param {String} text The text to work with
@ -107,14 +107,15 @@ var Document = function(text) {
**/
// check for IE split bug
if ("aaa".split(/a/).length === 0)
if ("aaa".split(/a/).length === 0) {
this.$split = function(text) {
return text.replace(/\r\n|\r/g, "\n").split("\n");
};
else
} else {
this.$split = function(text) {
return text.split(/\r\n|\r|\n/);
};
}
this.$detectNewLine = function(text) {
@ -207,32 +208,49 @@ var Document = function(text) {
};
/**
* [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc}
* @param {Range} range The range to work with
* Returns all the text within `range` as a single string.
* @param {Range} range The range to work with.
*
* @returns {String}
**/
this.getTextRange = function(range) {
if (range.start.row == range.end.row) {
return this.getLine(range.start.row)
.substring(range.start.column, range.end.column);
return this.getLinesForRange(range).join(this.getNewLineCharacter());
};
/**
* Returns all the text within `range` as an array of lines.
* @param {Range} range The range to work with.
*
* @returns {Array}
**/
this.getLinesForRange = function(range) {
var lines;
if (range.start.row === range.end.row) {
// Handle a single-line range.
lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
} else {
// Handle a multi-line range.
lines = this.getLines(range.start.row, range.end.row);
lines[0] = (lines[0] || "").substring(range.start.column);
var l = lines.length - 1;
if (range.end.row - range.start.row == l)
lines[l] = lines[l].substring(0, range.end.column);
}
var lines = this.getLines(range.start.row, range.end.row);
lines[0] = (lines[0] || "").substring(range.start.column);
var l = lines.length - 1;
if (range.end.row - range.start.row == l)
lines[l] = lines[l].substring(0, range.end.column);
return lines.join(this.getNewLineCharacter());
return lines;
};
this.$clipPosition = function(position) {
var length = this.getLength();
if (position.row >= length) {
position.row = Math.max(0, length - 1);
position.column = this.getLine(length-1).length;
} else if (position.row < 0)
position.row = 0;
return position;
// Deprecated methods retained for backwards compatibility.
this.insertLines = function(row, lines) {
console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
return this.insertFullLines(row, lines);
};
this.removeLines = function(firstRow, lastRow) {
console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
return this.removeFullLines(firstRow, lastRow);
};
this.insertNewLine = function(position) {
console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead.");
return this.insertMergedLines(position, ["", ""]);
};
/**
@ -243,53 +261,97 @@ var Document = function(text) {
*
**/
this.insert = function(position, text) {
if (!text || text.length === 0)
return position;
position = this.$clipPosition(position);
// only detect new lines if the document has no line break yet
// Only detect new lines if the document has no line break yet.
if (this.getLength() <= 1)
this.$detectNewLine(text);
var lines = this.$split(text);
var firstLine = lines.splice(0, 1)[0];
var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
position = this.insertInLine(position, firstLine);
if (lastLine !== null) {
position = this.insertNewLine(position); // terminate first line
position = this._insertLines(position.row, lines);
position = this.insertInLine(position, lastLine || "");
return this.insertMergedLines(position, this.$split(text));
};
/**
* Inserts `text` into the `position` at the current row. This method also triggers the `"change"` event.
*
* This differs from the `insert` method in two ways:
* 1. This does NOT handle newline characters (single-line text only).
* 2. This is faster than the `insert` method for single-line text insertions.
*
* @param {Object} position The position to insert at; it's an object that looks like `{ row: row, column: column}`
* @param {String} text A chunk of text
* @returns {Object} Returns an object containing the final row and column, like this:
* ```
* {row: endRow, column: 0}
* ```
**/
this.insertInLine = function(position, text) {
var start = this.clippedPos(position.row, position.column);
var end = this.pos(position.row, position.column + text.length);
this.applyDelta({
start: start,
end: end,
action: "insert",
lines: [text]
}, true);
return this.clonePos(end);
};
this.clippedPos = function(row, column) {
var length = this.getLength();
if (row === undefined) {
row = length;
} else if (row < 0) {
row = 0;
} else if (row >= length) {
row = length - 1;
column = undefined;
}
var line = this.getLine(row);
if (column == undefined)
column = line.length;
column = Math.min(Math.max(column, 0), line.length);
return {row: row, column: column};
};
this.clonePos = function(pos) {
return {row: pos.row, column: pos.column};
};
this.pos = function(row, column) {
return {row: row, column: column};
};
this.$clipPosition = function(position) {
var length = this.getLength();
if (position.row >= length) {
position.row = Math.max(0, length - 1);
position.column = this.getLine(length - 1).length;
} else {
position.row = Math.max(0, position.row);
position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
}
return position;
};
/**
* Fires whenever the document changes.
*
* Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available:
*
* * `"insertLines"` (emitted by [[Document.insertLines]])
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines in the document that are changing
* * `"insertText"` (emitted by [[Document.insertNewLine]])
* * `range`: the [[Range]] of the change within the document
* * `text`: the text that's being added
* * `"removeLines"` (emitted by [[Document.insertLines]])
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines in the document that were removed
* * `nl`: the new line character (as defined by [[Document.getNewLineCharacter]])
* * `"removeText"` (emitted by [[Document.removeInLine]] and [[Document.removeNewLine]])
* * `range`: the [[Range]] of the change within the document
* * `text`: the text that's being removed
*
* @event change
* @param {Object} e Contains at least one property called `"action"`. `"action"` indicates the action that triggered the change. Each action also has a set of additional properties.
*
**/
* Fires whenever the document changes.
*
* Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available:
*
* * `"insert"`
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines being added
* * `"remove"`
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines being removed
*
* @event change
* @param {Object} e Contains at least one property called `"action"`. `"action"` indicates the action that triggered the change. Each action also has a set of additional properties.
*
**/
/**
* Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
* Inserts the elements in `lines` into the document as full lines (does not merge with existing line), starting at the row index given by `row`. This method also triggers the `"change"` event.
* @param {Number} row The index of the row to insert at
* @param {Array} lines An array of strings
* @returns {Object} Contains the final row and column, like this:
@ -302,100 +364,57 @@ var Document = function(text) {
* ```
*
**/
this.insertLines = function(row, lines) {
if (row >= this.getLength())
return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
return this._insertLines(Math.max(row, 0), lines);
};
this._insertLines = function(row, lines) {
if (lines.length == 0)
return {row: row, column: 0};
// apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF)
// to circumvent that we have to break huge inserts into smaller chunks here
while (lines.length > 0xF000) {
var end = this._insertLines(row, lines.slice(0, 0xF000));
lines = lines.slice(0xF000);
row = end.row;
this.insertFullLines = function(row, lines) {
// Clip to document.
// Allow one past the document end.
row = Math.min(Math.max(row, 0), this.getLength());
// Calculate insertion point.
var column = 0;
if (row < this.getLength()) {
// Insert before the specified row.
lines = lines.concat([""]);
column = 0;
} else {
// Insert after the last row in the document.
lines = [""].concat(lines);
row--;
column = this.$lines[row].length;
}
// Insert.
this.insertMergedLines({row: row, column: column}, lines);
};
var args = [row, 0];
args.push.apply(args, lines);
this.$lines.splice.apply(this.$lines, args);
var range = new Range(row, 0, row + lines.length, 0);
var delta = {
action: "insertLines",
range: range,
/**
* Inserts the elements in `lines` into the document, starting at the position index given by `row`. This method also triggers the `"change"` event.
* @param {Number} row The index of the row to insert at
* @param {Array} lines An array of strings
* @returns {Object} Contains the final row and column, like this:
* ```
* {row: endRow, column: 0}
* ```
* If `lines` is empty, this function returns an object containing the current row, and column, like this:
* ```
* {row: row, column: 0}
* ```
*
**/
this.insertMergedLines = function(position, lines) {
var start = this.clippedPos(position.row, position.column);
var end = {
row: start.row + lines.length - 1,
column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
};
this.applyDelta({
start: start,
end: end,
action: "insert",
lines: lines
};
this._signal("change", { data: delta });
return range.end;
};
/**
* Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event.
* @param {Object} position The position to insert at
* @returns {Object} Returns an object containing the final row and column, like this:<br/>
* ```
* {row: endRow, column: 0}
* ```
*
**/
this.insertNewLine = function(position) {
position = this.$clipPosition(position);
var line = this.$lines[position.row] || "";
this.$lines[position.row] = line.substring(0, position.column);
this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
var end = {
row : position.row + 1,
column : 0
};
var delta = {
action: "insertText",
range: Range.fromPoints(position, end),
text: this.getNewLineCharacter()
};
this._signal("change", { data: delta });
return end;
};
/**
* Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
* @param {Object} position The position to insert at; it's an object that looks like `{ row: row, column: column}`
* @param {String} text A chunk of text
* @returns {Object} Returns an object containing the final row and column, like this:
* ```
* {row: endRow, column: 0}
* ```
*
**/
this.insertInLine = function(position, text) {
if (text.length == 0)
return position;
var line = this.$lines[position.row] || "";
this.$lines[position.row] = line.substring(0, position.column) + text
+ line.substring(position.column);
var end = {
row : position.row,
column : position.column + text.length
};
var delta = {
action: "insertText",
range: Range.fromPoints(position, end),
text: text
};
this._signal("change", { data: delta });
return end;
});
return this.clonePos(end);
};
/**
@ -405,113 +424,90 @@ var Document = function(text) {
*
**/
this.remove = function(range) {
if (!(range instanceof Range))
range = Range.fromPoints(range.start, range.end);
// clip to document
range.start = this.$clipPosition(range.start);
range.end = this.$clipPosition(range.end);
if (range.isEmpty())
return range.start;
var firstRow = range.start.row;
var lastRow = range.end.row;
if (range.isMultiLine()) {
var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
var lastFullRow = lastRow - 1;
if (range.end.column > 0)
this.removeInLine(lastRow, 0, range.end.column);
if (lastFullRow >= firstFullRow)
this._removeLines(firstFullRow, lastFullRow);
if (firstFullRow != firstRow) {
this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
this.removeNewLine(range.start.row);
}
}
else {
this.removeInLine(firstRow, range.start.column, range.end.column);
}
return range.start;
var start = this.clippedPos(range.start.row, range.start.column);
var end = this.clippedPos(range.end.row, range.end.column);
this.applyDelta({
start: start,
end: end,
action: "remove",
lines: this.getLinesForRange({start: start, end: end})
});
return this.clonePos(start);
};
/**
* Removes the specified columns from the `row`. This method also triggers the `'change'` event.
* @param {Number} row The row to remove from
* @param {Number} startColumn The column to start removing at
* @param {Number} endColumn The column to stop removing at
* @returns {Object} Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.<br/>If `startColumn` is equal to `endColumn`, this function returns nothing.
*
**/
* Removes the specified columns from the `row`. This method also triggers a `"change"` event.
* @param {Number} row The row to remove from
* @param {Number} startColumn The column to start removing at
* @param {Number} endColumn The column to stop removing at
* @returns {Object} Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.<br/>If `startColumn` is equal to `endColumn`, this function returns nothing.
*
**/
this.removeInLine = function(row, startColumn, endColumn) {
if (startColumn == endColumn)
return;
var range = new Range(row, startColumn, row, endColumn);
var line = this.getLine(row);
var removed = line.substring(startColumn, endColumn);
var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
this.$lines.splice(row, 1, newLine);
var delta = {
action: "removeText",
range: range,
text: removed
};
this._signal("change", { data: delta });
return range.start;
var start = this.clippedPos(row, startColumn);
var end = this.clippedPos(row, endColumn);
this.applyDelta({
start: start,
end: end,
action: "remove",
lines: this.getLinesForRange({start: start, end: end})
}, true);
return this.clonePos(start);
};
/**
* Removes a range of full lines. This method also triggers the `'change'` event.
* Removes a range of full lines. This method also triggers the `"change"` event.
* @param {Number} firstRow The first row to be removed
* @param {Number} lastRow The last row to be removed
* @returns {[String]} Returns all the removed lines.
*
**/
this.removeLines = function(firstRow, lastRow) {
if (firstRow < 0 || lastRow >= this.getLength())
return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
return this._removeLines(firstRow, lastRow);
};
this._removeLines = function(firstRow, lastRow) {
var range = new Range(firstRow, 0, lastRow + 1, 0);
var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
var delta = {
action: "removeLines",
range: range,
nl: this.getNewLineCharacter(),
lines: removed
};
this._signal("change", { data: delta });
return removed;
this.removeFullLines = function(firstRow, lastRow) {
// Clip to document.
firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
// Calculate deletion range.
// Delete the ending new line unless we're at the end of the document.
// If we're at the end of the document, delete the starting new line.
var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
var deleteLastNewLine = lastRow < this.getLength() - 1;
var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
var range = new Range(startRow, startCol, endRow, endCol);
// Store delelted lines with bounding newlines ommitted (maintains previous behavior).
var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
this.applyDelta({
start: range.start,
end: range.end,
action: "remove",
lines: this.getLinesForRange(range)
});
// Return the deleted lines.
return deletedLines;
};
/**
* Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
* Removes the new line between `row` and the row immediately following it. This method also triggers the `"change"` event.
* @param {Number} row The row to check
*
**/
this.removeNewLine = function(row) {
var firstLine = this.getLine(row);
var secondLine = this.getLine(row+1);
var range = new Range(row, firstLine.length, row+1, 0);
var line = firstLine + secondLine;
this.$lines.splice(row, 2, line);
var delta = {
action: "removeText",
range: range,
text: this.getNewLineCharacter()
};
this._signal("change", { data: delta });
if (row < this.getLength() - 1 && row >= 0) {
this.applyDelta({
start: this.pos(row, this.getLine(row).length),
end: this.pos(row + 1, 0),
action: "remove",
lines: ["", ""]
});
}
};
/**
@ -525,9 +521,9 @@ var Document = function(text) {
*
**/
this.replace = function(range, text) {
if (!(range instanceof Range))
if (!range instanceof Range)
range = Range.fromPoints(range.start, range.end);
if (text.length == 0 && range.isEmpty())
if (text.length === 0 && range.isEmpty())
return range.start;
// Shortcut: If the text we want to insert is the same as it is already
@ -536,55 +532,106 @@ var Document = function(text) {
return range.end;
this.remove(range);
var end;
if (text) {
var end = this.insert(range.start, text);
end = this.insert(range.start, text);
}
else {
end = range.start;
}
return end;
};
/**
* Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
* Applies all changes in `deltas` to the document.
* @param {Array} deltas An array of delta objects (can include "insert" and "remove" actions)
**/
this.applyDeltas = function(deltas) {
for (var i=0; i<deltas.length; i++) {
var delta = deltas[i];
var range = Range.fromPoints(delta.range.start, delta.range.end);
if (delta.action == "insertLines")
this.insertLines(range.start.row, delta.lines);
else if (delta.action == "insertText")
this.insert(range.start, delta.text);
else if (delta.action == "removeLines")
this._removeLines(range.start.row, range.end.row - 1);
else if (delta.action == "removeText")
this.remove(range);
this.applyDelta(deltas[i]);
}
};
/**
* Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
* Reverts all changes in `deltas` from the document.
* @param {Array} deltas An array of delta objects (can include "insert" and "remove" actions)
**/
this.revertDeltas = function(deltas) {
for (var i=deltas.length-1; i>=0; i--) {
var delta = deltas[i];
var range = Range.fromPoints(delta.range.start, delta.range.end);
if (delta.action == "insertLines")
this._removeLines(range.start.row, range.end.row - 1);
else if (delta.action == "insertText")
this.remove(range);
else if (delta.action == "removeLines")
this._insertLines(range.start.row, delta.lines);
else if (delta.action == "removeText")
this.insert(range.start, delta.text);
this.revertDelta(deltas[i]);
}
};
/**
* Applies `delta` to the document.
* @param {Object} delta A delta object (can include "insert" and "remove" actions)
**/
this.applyDelta = function(delta, doNotValidate) {
var isInsert = delta.action == "insert";
// An empty range is a NOOP.
if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
: !Range.comparePoints(delta.start, delta.end)) {
return;
}
if (isInsert && delta.lines.length > 20000)
this.$splitAndapplyLargeDelta(delta, 20000);
// Apply.
applyDelta(this.$lines, delta, doNotValidate);
this._signal("change", delta);
};
this.$splitAndapplyLargeDelta = function(delta, MAX) {
// Split large insert deltas. This is necessary because:
// 1. We need to support splicing delta lines into the document via $lines.splice.apply(...)
// 2. fn.apply() doesn't work for a large number of params. The smallest threshold is on chrome 40 ~42000.
// we use 20000 to leave some space for actual stack
//
// To Do: Ideally we'd be consistent and also split 'delete' deltas. We don't do this now, because delete
// delta handling is too slow. If we make delete delta handling faster we can split all large deltas
// as shown in https://gist.github.com/aldendaniels/8367109#file-document-snippet-js
// If we do this, update validateDelta() to limit the number of lines in a delete delta.
var lines = delta.lines;
var l = lines.length;
var row = delta.start.row;
var column = delta.start.column;
var from = 0, to = 0;
do {
from = to;
to += MAX - 1;
var chunk = lines.slice(from, to);
if (to > l) {
// Update remaining delta.
delta.lines = chunk;
delta.start.row = row + from;
delta.start.column = column;
break;
}
chunk.push("");
this.applyDelta({
start: this.pos(row + from, column),
end: this.pos(row + to, column = 0),
action: delta.action,
lines: chunk
}, true);
} while(true);
};
/**
* Reverts `delta` from the document.
* @param {Object} delta A delta object (can include "insert" and "remove" actions)
**/
this.revertDelta = function(delta) {
this.applyDelta({
start: this.clonePos(delta.start),
end: this.clonePos(delta.end),
action: (delta.action == "insert" ? "remove" : "insert"),
lines: delta.lines.slice()
});
};
/**
* Converts an index position in a document to a `{row, column}` object.
*

View file

@ -46,7 +46,7 @@ module.exports = {
var doc = new Document(["12", "34"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.insert({row: 0, column: 1}, "juhu");
assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n"));
@ -63,9 +63,9 @@ module.exports = {
var doc = new Document(["12", "34"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.insertNewLine({row: 0, column: 1});
doc.insertMergedLines({row: 0, column: 1}, ['', '']);
assert.equal(doc.getValue(), ["1", "2", "34"].join("\n"));
var d = deltas.concat();
@ -80,9 +80,9 @@ module.exports = {
var doc = new Document(["12", "34"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.insertLines(0, ["aa", "bb"]);
doc.insertFullLines(0, ["aa", "bb"]);
assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n"));
var d = deltas.concat();
@ -97,9 +97,9 @@ module.exports = {
var doc = new Document(["12", "34"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.insertLines(2, ["aa", "bb"]);
doc.insertFullLines(2, ["aa", "bb"]);
assert.equal(doc.getValue(), ["12", "34", "aa", "bb"].join("\n"));
},
@ -107,9 +107,9 @@ module.exports = {
var doc = new Document(["12", "34"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.insertLines(1, ["aa", "bb"]);
doc.insertFullLines(1, ["aa", "bb"]);
assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n"));
var d = deltas.concat();
@ -124,7 +124,7 @@ module.exports = {
var doc = new Document(["12", "34"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.insert({row: 0, column: 0}, "aa\nbb\ncc");
assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n"));
@ -141,9 +141,9 @@ module.exports = {
var doc = new Document(["12", "34"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.insert({row: 2, column: 0}, "aa\nbb\ncc");
doc.insert({row: 1, column: 2}, "aa\nbb\ncc");
assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n"));
var d = deltas.concat();
@ -158,7 +158,7 @@ module.exports = {
var doc = new Document(["12", "34"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.insert({row: 0, column: 1}, "aa\nbb\ncc");
assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n"));
@ -175,7 +175,7 @@ module.exports = {
var doc = new Document(["1234", "5678"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.remove(new Range(0, 1, 0, 3));
assert.equal(doc.getValue(), ["14", "5678"].join("\n"));
@ -192,7 +192,7 @@ module.exports = {
var doc = new Document(["1234", "5678"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.remove(new Range(0, 4, 1, 0));
assert.equal(doc.getValue(), ["12345678"].join("\n"));
@ -209,7 +209,7 @@ module.exports = {
var doc = new Document(["1234", "5678", "abcd"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.remove(new Range(0, 2, 2, 2));
assert.equal(doc.getValue(), ["12cd"].join("\n"));
@ -226,7 +226,7 @@ module.exports = {
var doc = new Document(["1234", "5678", "abcd"]);
var deltas = [];
doc.on("change", function(e) { deltas.push(e.data); });
doc.on("change", function(e) { deltas.push(e); });
doc.remove(new Range(1, 0, 3, 0));
assert.equal(doc.getValue(), ["1234", ""].join("\n"));
@ -235,7 +235,7 @@ module.exports = {
"test: remove lines should return the removed lines" : function() {
var doc = new Document(["1234", "5678", "abcd"]);
var removed = doc.removeLines(1, 2);
var removed = doc.removeFullLines(1, 2);
assert.equal(removed.join("\n"), ["5678", "abcd"].join("\n"));
},
@ -296,6 +296,35 @@ module.exports = {
"test: empty document has to contain one line": function() {
var doc = new Document("");
assert.equal(doc.$lines.length, 1);
},
"test: ignore empty delta": function() {
var doc = new Document("");
doc.on("change", function() {
throw "should ignore empty delta";
})
doc.insert({row: 0, column: 0}, "");
doc.insert({row: 1, column: 1}, "");
doc.remove({start: {row: 1, column: 1}, end: {row: 1, column: 1}});
},
"test: inserting huge delta": function() {
var doc = new Document("");
var val = "";
var MAX = 0xF000;
for (var i = 0; i < 10 * MAX; i++) {
val += i + "\n"
}
doc.setValue(val);
assert.equal(doc.getValue(), val);
for (var i = 3 * MAX + 2; i >= 3 * MAX - 2; i--) {
val = doc.getLines(0, i).join("\n");
doc.setValue("\nab");
assert.equal(doc.getValue(), "\nab");
doc.insert({row: 1, column: 1}, val);
assert.equal(doc.getValue(), "\na" + val + "b");
}
}
};

View file

@ -151,7 +151,7 @@ var EditSession = function(text, mode) {
this.$foldData = [];
this.$foldData.toString = function() {
return this.join("\n");
}
};
this.on("changeFold", this.onChangeFold.bind(this));
this.$onChange = this.onChange.bind(this);
@ -249,13 +249,12 @@ var EditSession = function(text, mode) {
this.$resetRowCache(fold.start.row);
};
this.onChange = function(e) {
var delta = e.data;
this.onChange = function(delta) {
this.$modified = true;
this.$resetRowCache(delta.range.start.row);
this.$resetRowCache(delta.start.row);
var removedFolds = this.$updateInternalDataOnChange(e);
var removedFolds = this.$updateInternalDataOnChange(delta);
if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
this.$deltasDoc.push(delta);
if (removedFolds && removedFolds.length != 0) {
@ -268,16 +267,14 @@ var EditSession = function(text, mode) {
this.$informUndoManager.schedule();
}
this.bgTokenizer.$updateOnChange(delta);
this._signal("change", e);
this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
this._signal("change", delta);
};
/**
* Sets the session text.
* @param {String} text The new text to place
*
*
*
**/
this.setValue = function(text) {
this.doc.setValue(text);
@ -681,10 +678,10 @@ var EditSession = function(text, mode) {
};
/**
* Returns an array containing the IDs of all the markers, either front or back.
* Returns an object containing all of the markers, either front or back.
* @param {Boolean} inFront If `true`, indicates you only want front markers; `false` indicates only back markers
*
* @returns {Array}
* @returns {Object}
**/
this.getMarkers = function(inFront) {
return inFront ? this.$frontMarkers : this.$backMarkers;
@ -895,17 +892,17 @@ var EditSession = function(text, mode) {
config.loadModule(["mode", path], function(m) {
if (this.$modeId !== path)
return cb && cb();
if (this.$modes[path] && !options)
return this.$onChangeMode(this.$modes[path]);
if (m && m.Mode) {
if (this.$modes[path] && !options) {
this.$onChangeMode(this.$modes[path]);
} else if (m && m.Mode) {
m = new m.Mode(options);
if (!options) {
this.$modes[path] = m;
m.$id = path;
}
this.$onChangeMode(m);
cb && cb();
}
cb && cb();
}.bind(this));
// set mode to text until loading is finished
@ -950,6 +947,9 @@ var EditSession = function(text, mode) {
if (!$isPlaceholder) {
// experimental method, used by c9 findiniles
if (mode.attachToSession)
mode.attachToSession(this);
this.$options.wrapMethod.set.call(this, this.$wrapMethod);
this.$setFolding(mode.foldingRules);
this.bgTokenizer.start(0);
@ -957,26 +957,20 @@ var EditSession = function(text, mode) {
}
};
this.$stopWorker = function() {
if (this.$worker)
if (this.$worker) {
this.$worker.terminate();
this.$worker = null;
this.$worker = null;
}
};
this.$startWorker = function() {
if (typeof Worker !== "undefined" && !require.noWorker) {
try {
this.$worker = this.$mode.createWorker(this);
} catch (e) {
console.log("Could not load worker");
console.log(e);
this.$worker = null;
}
}
else
try {
this.$worker = this.$mode.createWorker(this);
} catch (e) {
config.warn("Could not load worker", e);
this.$worker = null;
}
};
/**
@ -1151,6 +1145,19 @@ var EditSession = function(text, mode) {
this.remove = function(range) {
return this.doc.remove(range);
};
/**
* Removes a range of full lines. This method also triggers the `'change'` event.
* @param {Number} firstRow The first row to be removed
* @param {Number} lastRow The last row to be removed
* @returns {[String]} Returns all the removed lines.
*
* @related Document.removeFullLines
*
**/
this.removeFullLines = function(firstRow, lastRow){
return this.doc.removeFullLines(firstRow, lastRow);
};
/**
* Reverts previous changes to your document.
@ -1227,39 +1234,36 @@ var EditSession = function(text, mode) {
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
function isInsert(delta) {
var insert =
delta.action === "insertText" || delta.action === "insertLines";
return isUndo ? !insert : insert;
return isUndo ? delta.action !== "insert" : delta.action === "insert";
}
var delta = deltas[0];
var range, point;
var lastDeltaIsInsert = false;
if (isInsert(delta)) {
range = Range.fromPoints(delta.range.start, delta.range.end);
range = Range.fromPoints(delta.start, delta.end);
lastDeltaIsInsert = true;
} else {
range = Range.fromPoints(delta.range.start, delta.range.start);
range = Range.fromPoints(delta.start, delta.start);
lastDeltaIsInsert = false;
}
for (var i = 1; i < deltas.length; i++) {
delta = deltas[i];
if (isInsert(delta)) {
point = delta.range.start;
point = delta.start;
if (range.compare(point.row, point.column) == -1) {
range.setStart(delta.range.start);
range.setStart(point);
}
point = delta.range.end;
point = delta.end;
if (range.compare(point.row, point.column) == 1) {
range.setEnd(delta.range.end);
range.setEnd(point);
}
lastDeltaIsInsert = true;
} else {
point = delta.range.start;
point = delta.start;
if (range.compare(point.row, point.column) == -1) {
range =
Range.fromPoints(delta.range.start, delta.range.start);
range = Range.fromPoints(delta.start, delta.start);
}
lastDeltaIsInsert = false;
}
@ -1373,7 +1377,7 @@ var EditSession = function(text, mode) {
this.indentRows = function(startRow, endRow, indentString) {
indentString = indentString.replace(/\t/g, this.getTabString());
for (var row=startRow; row<=endRow; row++)
this.insert({row: row, column:0}, indentString);
this.doc.insertInLine({row: row, column: 0}, indentString);
};
/**
@ -1430,11 +1434,11 @@ var EditSession = function(text, mode) {
x.end.row += diff;
return x;
});
var lines = dir == 0
? this.doc.getLines(firstRow, lastRow)
: this.doc.removeLines(firstRow, lastRow);
this.doc.insertLines(firstRow+diff, lines);
: this.doc.removeFullLines(firstRow, lastRow);
this.doc.insertFullLines(firstRow+diff, lines);
folds.length && this.addFolds(folds);
return diff;
};
@ -1444,8 +1448,6 @@ var EditSession = function(text, mode) {
* @param {Number} lastRow The final row to move up
* @returns {Number} If `firstRow` is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1.
*
* @related Document.insertLines
*
**/
this.moveLinesUp = function(firstRow, lastRow) {
return this.$moveLines(firstRow, lastRow, -1);
@ -1456,8 +1458,6 @@ var EditSession = function(text, mode) {
* @param {Number} firstRow The starting row to move down
* @param {Number} lastRow The final row to move down
* @returns {Number} If `firstRow` is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1.
*
* @related Document.insertLines
**/
this.moveLinesDown = function(firstRow, lastRow) {
return this.$moveLines(firstRow, lastRow, 1);
@ -1585,13 +1585,11 @@ var EditSession = function(text, mode) {
**/
this.setWrapLimitRange = function(min, max) {
if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
this.$wrapLimitRange = {
min: min,
max: max
};
this.$wrapLimitRange = { min: min, max: max };
this.$modified = true;
// This will force a recalculation of the wrap limit
this._signal("changeWrapMode");
if (this.$useWrapMode)
this._signal("changeWrapMode");
}
};
@ -1603,7 +1601,7 @@ var EditSession = function(text, mode) {
* @private
**/
this.adjustWrapLimit = function(desiredLimit, $printMargin) {
var limits = this.$wrapLimitRange
var limits = this.$wrapLimitRange;
if (limits.max < 0)
limits = {min: $printMargin, max: $printMargin};
var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
@ -1663,34 +1661,23 @@ var EditSession = function(text, mode) {
};
};
this.$updateInternalDataOnChange = function(e) {
this.$updateInternalDataOnChange = function(delta) {
var useWrapMode = this.$useWrapMode;
var len;
var action = e.data.action;
var firstRow = e.data.range.start.row;
var lastRow = e.data.range.end.row;
var start = e.data.range.start;
var end = e.data.range.end;
var action = delta.action;
var start = delta.start;
var end = delta.end;
var firstRow = start.row;
var lastRow = end.row;
var len = lastRow - firstRow;
var removedFolds = null;
if (action.indexOf("Lines") != -1) {
if (action == "insertLines") {
lastRow = firstRow + (e.data.lines.length);
} else {
lastRow = firstRow;
}
len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
} else {
len = lastRow - firstRow;
}
this.$updating = true;
if (len != 0) {
if (action.indexOf("remove") != -1) {
if (action === "remove") {
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
var foldLines = this.$foldData;
removedFolds = this.getFoldsInRange(e.data.range);
removedFolds = this.getFoldsInRange(delta);
this.removeFolds(removedFolds);
var foldLine = this.getFoldLine(end.row);
@ -1727,13 +1714,14 @@ var EditSession = function(text, mode) {
var foldLine = this.getFoldLine(firstRow);
var idx = 0;
if (foldLine) {
var cmp = foldLine.range.compareInside(start.row, start.column)
var cmp = foldLine.range.compareInside(start.row, start.column);
// Inside of the foldLine range. Need to split stuff up.
if (cmp == 0) {
foldLine = foldLine.split(start.row, start.column);
foldLine.shiftRow(len);
foldLine.addRemoveChars(
lastRow, 0, end.column - start.column);
if (foldLine) {
foldLine.shiftRow(len);
foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
}
} else
// Infront of the foldLine but same row. Need to shift column.
if (cmp == -1) {
@ -1754,10 +1742,10 @@ var EditSession = function(text, mode) {
} else {
// Realign folds. E.g. if you add some new chars before a fold, the
// fold should "move" to the right.
len = Math.abs(e.data.range.start.column - e.data.range.end.column);
if (action.indexOf("remove") != -1) {
len = Math.abs(delta.start.column - delta.end.column);
if (action === "remove") {
// Get all the folds in the change range and remove them.
removedFolds = this.getFoldsInRange(e.data.range);
removedFolds = this.getFoldsInRange(delta);
this.removeFolds(removedFolds);
len = -len;
@ -1841,7 +1829,7 @@ var EditSession = function(text, mode) {
TAB_SPACE = 12;
this.$computeWrapSplits = function(tokens, wrapLimit) {
this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
if (tokens.length == 0) {
return [];
}
@ -1852,6 +1840,31 @@ var EditSession = function(text, mode) {
var isCode = this.$wrapAsCode;
var indentedSoftWrap = this.$indentedSoftWrap;
var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
|| indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
function getWrapIndent() {
var indentation = 0;
if (maxIndent === 0)
return indentation;
if (indentedSoftWrap) {
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token == SPACE)
indentation += 1;
else if (token == TAB)
indentation += tabSize;
else if (token == TAB_SPACE)
continue;
else
break;
}
}
if (isCode && indentedSoftWrap !== false)
indentation += tabSize;
return Math.min(indentation, maxIndent);
}
function addSplit(screenPos) {
var displayed = tokens.slice(lastSplit, screenPos);
@ -1868,14 +1881,18 @@ var EditSession = function(text, mode) {
len -= 1;
});
if (!splits.length) {
indent = getWrapIndent();
splits.indent = indent;
}
lastDocSplit += len;
splits.push(lastDocSplit);
lastSplit = screenPos;
}
while (displayLength - lastSplit > wrapLimit) {
var indent = 0;
while (displayLength - lastSplit > wrapLimit - indent) {
// This is, where the split should be.
var split = lastSplit + wrapLimit;
var split = lastSplit + wrapLimit - indent;
// If there is a space or tab at this split position, then making
// a split is simple.
@ -1935,7 +1952,7 @@ var EditSession = function(text, mode) {
// === ELSE ===
// Search for the first non space/tab/placeholder/punctuation token backwards.
var minSplit = Math.max(split - (isCode ? 10 : wrapLimit-(wrapLimit>>2)), lastSplit - 1);
var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1);
while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
split --;
}
@ -1961,7 +1978,9 @@ var EditSession = function(text, mode) {
split = lastSplit + wrapLimit;
// The split is inside of a CHAR or CHAR_EXT token and no space
// around -> force a split.
addSplit(split);
if (tokens[split] == CHAR_EXT)
split--;
addSplit(split - indent);
}
return splits;
};
@ -2068,6 +2087,16 @@ var EditSession = function(text, mode) {
}
};
this.getRowWrapIndent = function(screenRow) {
if (this.$useWrapMode) {
var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
var splits = this.$wrapData[pos.row];
return splits.length && splits[0] < pos.column ? splits.indent : 0;
} else {
return 0;
}
}
/**
* Returns the position (on screen) for the last character in the provided screen row.
* @param {Number} screenRow The screen row to check
@ -2200,25 +2229,26 @@ var EditSession = function(text, mode) {
return {
row: maxRow,
column: this.getLine(maxRow).length
}
};
} else {
line = this.getLine(docRow);
foldLine = null;
}
var wrapIndent = 0;
if (this.$useWrapMode) {
var splits = this.$wrapData[docRow];
if (splits) {
var splitIndex = Math.floor(screenRow - row);
column = splits[splitIndex];
if(splitIndex > 0 && splits.length) {
wrapIndent = splits.indent;
docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
line = line.substring(docColumn);
}
}
}
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
// We remove one character at the end so that the docColumn
// position returned is not associated to the next row on the screen.
@ -2310,6 +2340,7 @@ var EditSession = function(text, mode) {
textLine = this.getLine(docRow).substring(0, docColumn);
foldStartRow = docRow;
}
var wrapIndent = 0;
// Clamp textLine if in wrapMode.
if (this.$useWrapMode) {
var wrapRow = this.$wrapData[foldStartRow];
@ -2322,12 +2353,13 @@ var EditSession = function(text, mode) {
textLine = textLine.substring(
wrapRow[screenRowOffset - 1] || 0, textLine.length
);
wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
}
}
return {
row: screenRow,
column: this.$getStringScreenWidth(textLine)[0]
column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
};
};
@ -2400,7 +2432,15 @@ var EditSession = function(text, mode) {
*/
this.$setFontMetrics = function(fm) {
// todo
}
};
this.destroy = function() {
if (this.bgTokenizer) {
this.bgTokenizer.setDocument(null);
this.bgTokenizer = null;
}
this.$stopWorker();
};
// For every keystroke this gets called once per char in the whole doc!!
// Wouldn't hurt to make it a bit faster for c >= 0x1100
@ -2461,6 +2501,7 @@ config.defineOptions(EditSession.prototype, "session", {
if (this.$wrap == value)
return;
this.$wrap = value;
if (!value) {
this.setUseWrapMode(false);
} else {
@ -2468,7 +2509,6 @@ config.defineOptions(EditSession.prototype, "session", {
this.setWrapLimitRange(col, col);
this.setUseWrapMode(true);
}
this.$wrap = value;
},
get: function() {
if (this.getUseWrapMode()) {
@ -2499,6 +2539,7 @@ config.defineOptions(EditSession.prototype, "session", {
},
initialValue: "auto"
},
indentedSoftWrap: { initialValue: true },
firstLineNumber: {
set: function() {this._signal("changeBreakpoint");},
initialValue: 1

View file

@ -117,6 +117,7 @@ function BracketMatch() {
typeRe = new RegExp(
"(\\.?" +
token.type.replace(".", "\\.").replace("rparen", ".paren")
.replace(/\b(?:end)\b/, "(?:start|begin|end)")
+ ")+"
);
}
@ -173,6 +174,7 @@ function BracketMatch() {
typeRe = new RegExp(
"(\\.?" +
token.type.replace(".", "\\.").replace("lparen", ".paren")
.replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
+ ")+"
);
}

View file

@ -44,7 +44,7 @@ function FoldLine(foldData, folds) {
folds = this.folds = [ folds ];
}
var last = folds[folds.length - 1]
var last = folds[folds.length - 1];
this.range = new Range(folds[0].start.row, folds[0].start.column,
last.end.row, last.end.column);
this.start = this.range.start;
@ -66,7 +66,7 @@ function FoldLine(foldData, folds) {
fold.start.row += shift;
fold.end.row += shift;
});
}
};
this.addFold = function(fold) {
if (fold.sameRow) {
@ -96,17 +96,17 @@ function FoldLine(foldData, folds) {
throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
}
fold.foldLine = this;
}
};
this.containsRow = function(row) {
return row >= this.start.row && row <= this.end.row;
}
};
this.walk = function(callback, endRow, endColumn) {
var lastEnd = 0,
folds = this.folds,
fold,
comp, stop, isNewRow = true;
cmp, stop, isNewRow = true;
if (endRow == null) {
endRow = this.end.row;
@ -116,9 +116,9 @@ function FoldLine(foldData, folds) {
for (var i = 0; i < folds.length; i++) {
fold = folds[i];
comp = fold.range.compareStart(endRow, endColumn);
cmp = fold.range.compareStart(endRow, endColumn);
// This fold is after the endRow/Column.
if (comp == -1) {
if (cmp == -1) {
callback(null, endRow, endColumn, lastEnd, isNewRow);
return;
}
@ -127,8 +127,8 @@ function FoldLine(foldData, folds) {
stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
// If the user requested to stop the walk or endRow/endColumn is
// inside of this fold (comp == 0), then end here.
if (stop || comp == 0) {
// inside of this fold (cmp == 0), then end here.
if (stop || cmp === 0) {
return;
}
@ -138,7 +138,7 @@ function FoldLine(foldData, folds) {
lastEnd = fold.end.column;
}
callback(null, endRow, endColumn, lastEnd, isNewRow);
}
};
this.getNextFoldTo = function(row, column) {
var fold, cmp;
@ -150,15 +150,15 @@ function FoldLine(foldData, folds) {
fold: fold,
kind: "after"
};
} else if (cmp == 0) {
} else if (cmp === 0) {
return {
fold: fold,
kind: "inside"
}
};
}
}
return null;
}
};
this.addRemoveChars = function(row, column, len) {
var ret = this.getNextFoldTo(row, column),
@ -175,7 +175,7 @@ function FoldLine(foldData, folds) {
} else if (fold.start.row == row) {
folds = this.folds;
var i = folds.indexOf(fold);
if (i == 0) {
if (i === 0) {
this.start.column += len;
}
for (i; i < folds.length; i++) {
@ -189,16 +189,18 @@ function FoldLine(foldData, folds) {
this.end.column += len;
}
}
}
};
this.split = function(row, column) {
var fold = this.getNextFoldTo(row, column).fold;
var pos = this.getNextFoldTo(row, column);
if (!pos || pos.kind == "inside")
return null;
var fold = pos.fold;
var folds = this.folds;
var foldData = this.foldData;
if (!fold)
return null;
var i = folds.indexOf(fold);
var foldBefore = folds[i - 1];
this.end.row = foldBefore.end.row;
@ -211,7 +213,7 @@ function FoldLine(foldData, folds) {
var newFoldLine = new FoldLine(foldData, folds);
foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
return newFoldLine;
}
};
this.merge = function(foldLineNext) {
var folds = foldLineNext.folds;
@ -222,7 +224,7 @@ function FoldLine(foldData, folds) {
// it's merged now with foldLineNext.
var foldData = this.foldData;
foldData.splice(foldData.indexOf(foldLineNext), 1);
}
};
this.toString = function() {
var ret = [this.range.toString() + ": [" ];
@ -230,13 +232,12 @@ function FoldLine(foldData, folds) {
this.folds.forEach(function(fold) {
ret.push(" " + fold.toString());
});
ret.push("]")
ret.push("]");
return ret.join("\n");
}
};
this.idxToPosition = function(idx) {
var lastFoldEndColumn = 0;
var fold;
for (var i = 0; i < this.folds.length; i++) {
var fold = this.folds[i];
@ -261,7 +262,7 @@ function FoldLine(foldData, folds) {
row: this.end.row,
column: this.end.column + idx
};
}
};
}).call(FoldLine.prototype);
exports.FoldLine = FoldLine;

View file

@ -289,13 +289,12 @@ function Folding() {
if (startFold && endFold == startFold)
return startFold.addSubFold(fold);
if (
(startFold && !startFold.range.isStart(startRow, startColumn))
|| (endFold && !endFold.range.isEnd(endRow, endColumn))
) {
throw new Error("A fold can't intersect already existing fold" + fold.range + startFold.range);
}
if (startFold && !startFold.range.isStart(startRow, startColumn))
this.removeFold(startFold);
if (endFold && !endFold.range.isEnd(endRow, endColumn))
this.removeFold(endFold);
// Check if there are folds in the range we create the new fold for.
var folds = this.getFoldsInRange(fold.range);
if (folds.length > 0) {
@ -485,15 +484,15 @@ function Folding() {
};
this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
if (startRow == null) {
if (startRow == null)
startRow = foldLine.start.row;
if (startColumn == null)
startColumn = 0;
}
if (endRow == null) {
if (endRow == null)
endRow = foldLine.end.row;
if (endColumn == null)
endColumn = this.getLine(endRow).length;
}
// Build the textline using the FoldLine walker.
var doc = this.doc;
@ -697,7 +696,8 @@ function Folding() {
this.$foldMode = foldMode;
this.removeListener('change', this.$updateFoldWidgets);
this.off('change', this.$updateFoldWidgets);
this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
this._emit("changeAnnotation");
if (!foldMode || this.$foldStyle == "manual") {
@ -710,8 +710,9 @@ function Folding() {
this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
this.on('change', this.$updateFoldWidgets);
this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
};
this.getParentFoldRangeData = function (row, ignoreCurrent) {
@ -793,7 +794,7 @@ function Folding() {
this.foldAll(startRow, endRow, options.all ? 10000 : 0);
} else if (options.children) {
endRow = range ? range.end.row : this.getLength();
this.foldAll(row + 1, range.end.row, options.all ? 10000 : 0);
this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
} else if (range) {
if (options.all)
range.collapseChildren = 10000;
@ -828,15 +829,13 @@ function Folding() {
}
};
this.updateFoldWidgets = function(e) {
var delta = e.data;
var range = delta.range;
var firstRow = range.start.row;
var len = range.end.row - firstRow;
this.updateFoldWidgets = function(delta) {
var firstRow = delta.start.row;
var len = delta.end.row - firstRow;
if (len === 0) {
this.foldWidgets[firstRow] = null;
} else if (delta.action == "removeText" || delta.action == "removeLines") {
} else if (delta.action == 'remove') {
this.foldWidgets.splice(firstRow, len + 1, null);
} else {
var args = Array(len + 1);
@ -844,7 +843,13 @@ function Folding() {
this.foldWidgets.splice.apply(this.foldWidgets, args);
}
};
this.tokenizerUpdateFoldWidgets = function(e) {
var rows = e.data;
if (rows.first != rows.last) {
if (this.foldWidgets.length > rows.first)
this.foldWidgets.splice(rows.first, this.foldWidgets.length);
}
}
}
exports.Folding = Folding;

View file

@ -280,7 +280,7 @@ module.exports = {
session.setUseWrapMode(true);
session.setWrapLimitRange(12, 12);
session.adjustWrapLimit(80);
session.setOption("wrapMethod", "text");
assert.position(session.documentToScreenPosition(0, 11), 0, 11);
assert.position(session.documentToScreenPosition(0, 12), 1, 0);
},
@ -380,7 +380,8 @@ module.exports = {
line = lang.stringTrimRight(line);
var tokens = EditSession.prototype.$getDisplayTokens(line);
var splits = EditSession.prototype.$computeWrapSplits(tokens, wrapLimit, tabSize);
// console.log("String:", line, "Result:", splits, "Expected:", assertEqual);
console.log("String:", line, "Result:", splits, "Expected:", assertEqual);
assert.ok(splits.length == assertEqual.length);
for (var i = 0; i < splits.length; i++) {
assert.ok(splits[i] == assertEqual[i]);
@ -388,6 +389,7 @@ module.exports = {
}
EditSession.prototype.$wrapAsCode = true;
EditSession.prototype.$indentedSoftWrap = false;
// Basic splitting.
computeAndAssert("foo bar foo bar", [ 12 ]);
computeAndAssert("foo bar f bar", [ 12 ]);
@ -413,16 +415,26 @@ module.exports = {
computeAndAssert("ぁぁ", [1], 2);
computeAndAssert(" ぁぁ", [1, 2], 2);
computeAndAssert(" ぁ\tぁ", [1, 3], 2);
computeAndAssert(" ぁぁ\tぁ", [1, 4], 4);
computeAndAssert(" ぁぁ\tぁ", [2, 4], 4);
computeAndAssert("ぁぁ ぁぁ\tぁ", [3, 6], 6);
// Test wrapping for punctuation.
computeAndAssert(" ab.c;ef++", [1, 3, 5, 7, 8], 2);
computeAndAssert(" ab.c;ef++", [2, 4, 6, 8], 2);
computeAndAssert(" ab.c;ef++", [3, 5, 8], 3);
computeAndAssert(" a.b", [1, 2, 3], 1);
computeAndAssert("#>>", [1, 2], 1);
// Test wrapping for punctuation in
EditSession.prototype.$wrapAsCode = false;
computeAndAssert("ab cde, Juhu kinners", [3, 8, 13, 19], 6);
// test indented wrapping
EditSession.prototype.$indentedSoftWrap = true;
computeAndAssert("foo bar foo bar foo bara foo", [12, 25]);
computeAndAssert("fooooooooooooooooooooooooooo", [12, 24]);
computeAndAssert("\t\tfoo bar fooooooooooobooooooo", [6, 10, 16, 22, 28]);
computeAndAssert("\t\t\tfoo bar fooooooooooobooooooo", [3, 7, 11, 17, 23, 29]);
computeAndAssert("\tfoo \t \t \t \t bar", [6, 12]); // 14
},
"test get longest line" : function() {
@ -430,12 +442,12 @@ module.exports = {
session.setTabSize(4);
assert.equal(session.getScreenWidth(), 2);
session.doc.insertNewLine({row: 0, column: Infinity});
session.doc.insertLines(1, ["123"]);
session.doc.insertMergedLines({row: 0, column: Infinity}, ['', '']);
session.doc.insertFullLines(1, ["123"]);
assert.equal(session.getScreenWidth(), 3);
session.doc.insertNewLine({row: 0, column: Infinity});
session.doc.insertLines(1, ["\t\t"]);
session.doc.insertMergedLines({row: 0, column: Infinity}, ['', '']);
session.doc.insertFullLines(1, ["\t\t"]);
assert.equal(session.getScreenWidth(), 8);
@ -459,9 +471,9 @@ module.exports = {
session.setUseWrapMode(true);
document.insertLines(0, ["a", "b"]);
document.insertLines(2, ["c", "d"]);
document.removeLines(1, 2);
document.insertFullLines(0, ["a", "b"]);
document.insertFullLines(2, ["c", "d"]);
document.removeFullLines(1, 2);
},
"test wrapMode init has to create wrapData array": function() {

View file

@ -94,7 +94,8 @@ var Editor = function(renderer, session) {
this._$emitInputEvent = lang.delayedCall(function() {
this._signal("input", {});
this.session.bgTokenizer && this.session.bgTokenizer.scheduleStart();
if (this.session && this.session.bgTokenizer)
this.session.bgTokenizer.scheduleStart();
}.bind(this));
this.on("change", function(_, _self) {
@ -114,30 +115,8 @@ var Editor = function(renderer, session) {
function last(a) {return a[a.length - 1]}
this.selections = [];
this.commands.on("exec", function(e) {
this.startOperation(e);
var command = e.command;
if (command.aceCommandGroup == "fileJump") {
var prev = this.prevOp;
if (!prev || prev.command.aceCommandGroup != "fileJump") {
this.lastFileJumpPos = last(this.selections);
}
} else {
this.lastFileJumpPos = null;
}
}.bind(this), true);
this.commands.on("afterExec", function(e) {
var command = e.command;
if (command.aceCommandGroup == "fileJump") {
if (this.lastFileJumpPos && !this.curOp.selectionChanged) {
this.selection.fromJSON(this.lastFileJumpPos);
}
}
this.endOperation(e);
}.bind(this), true);
this.commands.on("exec", this.startOperation.bind(this), true);
this.commands.on("afterExec", this.endOperation.bind(this), true);
this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
@ -171,20 +150,24 @@ var Editor = function(renderer, session) {
args: commadEvent.args,
scrollTop: this.renderer.scrollTop
};
var command = this.curOp.command;
if (command && command.scrollIntoView)
if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
this.$blockScrolling++;
this.selections.push(this.selection.toJSON());
};
this.endOperation = function() {
this.endOperation = function(e) {
if (this.curOp) {
if (e && e.returnValue === false)
return this.curOp = null;
this._signal("beforeEndOperation");
var command = this.curOp.command;
if (command && command.scrollIntoView) {
if (command.name && this.$blockScrolling > 0)
this.$blockScrolling--;
switch (command.scrollIntoView) {
var scrollIntoView = command && command.scrollIntoView;
if (scrollIntoView) {
switch (scrollIntoView) {
case "center-animate":
scrollIntoView = "animate";
/* fall through */
case "center":
this.renderer.scrollCursorIntoView(null, 0.5);
break;
@ -202,7 +185,7 @@ var Editor = function(renderer, session) {
default:
break;
}
if (command.scrollIntoView == "animate")
if (scrollIntoView == "animate")
this.renderer.animateScrolling(this.curOp.scrollTop);
}
@ -211,13 +194,14 @@ var Editor = function(renderer, session) {
}
};
// TODO use property on commands instead of this
this.$mergeableCommands = ["backspace", "del", "insertstring"];
this.$historyTracker = function(e) {
if (!this.$mergeUndoDeltas)
return;
var prev = this.prevOp;
var mergeableCommands = ["backspace", "del", "insertstring"];
var mergeableCommands = this.$mergeableCommands;
// previous command was the same
var shouldMerge = prev.command && (e.command.name == prev.command.name);
if (e.command.name == "insertstring") {
@ -253,19 +237,19 @@ var Editor = function(renderer, session) {
* @param {String} keyboardHandler The new key handler
*
**/
this.setKeyboardHandler = function(keyboardHandler) {
if (!keyboardHandler) {
this.keyBinding.setKeyboardHandler(null);
} else if (typeof keyboardHandler === "string") {
this.setKeyboardHandler = function(keyboardHandler, cb) {
if (keyboardHandler && typeof keyboardHandler === "string") {
this.$keybindingId = keyboardHandler;
var _self = this;
config.loadModule(["keybinding", keyboardHandler], function(module) {
if (_self.$keybindingId == keyboardHandler)
_self.keyBinding.setKeyboardHandler(module && module.handler);
cb && cb();
});
} else {
this.$keybindingId = null;
this.keyBinding.setKeyboardHandler(keyboardHandler);
cb && cb();
}
};
@ -294,6 +278,10 @@ var Editor = function(renderer, session) {
this.setSession = function(session) {
if (this.session == session)
return;
// make sure operationEnd events are not emitted to wrong session
if (this.curOp) this.endOperation();
this.curOp = {};
var oldSession = this.session;
if (oldSession) {
@ -383,6 +371,9 @@ var Editor = function(renderer, session) {
this.onChangeAnnotation();
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
this.renderer.updateFull();
} else {
this.selection = null;
this.renderer.setSession(session);
}
this._signal("changeSession", {
@ -390,6 +381,8 @@ var Editor = function(renderer, session) {
oldSession: oldSession
});
this.curOp = null;
oldSession && oldSession._signal("changeEditor", {oldEditor: this});
session && session._signal("changeEditor", {editor: this});
};
@ -524,25 +517,23 @@ var Editor = function(renderer, session) {
this.$highlightPending = true;
setTimeout(function() {
self.$highlightPending = false;
var pos = self.session.findMatchingBracket(self.getCursorPosition());
var session = self.session;
if (!session || !session.bgTokenizer) return;
var pos = session.findMatchingBracket(self.getCursorPosition());
if (pos) {
var range = new Range(pos.row, pos.column, pos.row, pos.column+1);
} else if (self.session.$mode.getMatching) {
var range = self.session.$mode.getMatching(self.session);
var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
} else if (session.$mode.getMatching) {
var range = session.$mode.getMatching(self.session);
}
if (range)
self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text");
session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
}, 50);
};
// todo: move to mode.getMatching
this.$highlightTags = function() {
var session = this.session;
if (this.$highlightTagPending) {
if (this.$highlightTagPending)
return;
}
// perform highlight async to not block the browser during navigation
var self = this;
@ -550,16 +541,25 @@ var Editor = function(renderer, session) {
setTimeout(function() {
self.$highlightTagPending = false;
var session = self.session;
if (!session || !session.bgTokenizer) return;
var pos = self.getCursorPosition();
var iterator = new TokenIterator(self.session, pos.row, pos.column);
var token = iterator.getCurrentToken();
if (!token || token.type.indexOf('tag-name') === -1) {
if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
session.removeMarker(session.$tagHighlight);
session.$tagHighlight = null;
return;
}
if (token.type.indexOf("tag-open") != -1) {
token = iterator.stepForward();
if (!token)
return;
}
var tag = token.value;
var depth = 0;
var prevToken = iterator.stepBackward();
@ -571,28 +571,28 @@ var Editor = function(renderer, session) {
token = iterator.stepForward();
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<'){
if (prevToken.value === '<'){
depth++;
} else if (prevToken.value==='</'){
} else if (prevToken.value === '</'){
depth--;
}
}
} while (token && depth>=0);
}else{
} while (token && depth >= 0);
} else {
//find opening tag
do {
token = prevToken;
prevToken = iterator.stepBackward();
if(token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<') {
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value === '<') {
depth++;
} else if( prevToken.value==='</') {
} else if (prevToken.value === '</') {
depth--;
}
}
} while (prevToken && depth<=0);
} while (prevToken && depth <= 0);
//select tag again
iterator.stepForward();
@ -656,13 +656,13 @@ var Editor = function(renderer, session) {
*
*
**/
this.onFocus = function() {
this.onFocus = function(e) {
if (this.$isFocused)
return;
this.$isFocused = true;
this.renderer.showCursor();
this.renderer.visualizeFocus();
this._emit("focus");
this._emit("focus", e);
};
/**
@ -671,13 +671,13 @@ var Editor = function(renderer, session) {
*
*
**/
this.onBlur = function() {
this.onBlur = function(e) {
if (!this.$isFocused)
return;
this.$isFocused = false;
this.renderer.hideCursor();
this.renderer.visualizeBlur();
this._emit("blur");
this._emit("blur", e);
};
this.$cursorChange = function() {
@ -692,21 +692,17 @@ var Editor = function(renderer, session) {
*
*
**/
this.onDocumentChange = function(e) {
var delta = e.data;
var range = delta.range;
var lastRow;
this.onDocumentChange = function(delta) {
// Rerender and emit "change" event.
var wrap = this.session.$useWrapMode;
var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
this.renderer.updateLines(delta.start.row, lastRow, wrap);
if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
lastRow = range.end.row;
else
lastRow = Infinity;
this.renderer.updateLines(range.start.row, lastRow);
this._signal("change", e);
// update cursor because tab characters can influence the cursor position
this._signal("change", delta);
// Update cursor because tab characters can influence the cursor position.
this.$cursorChange();
this.$updateHighlightActiveLine();
};
this.onTokenizerUpdate = function(e) {
@ -731,6 +727,10 @@ var Editor = function(renderer, session) {
this.$cursorChange();
if (!this.$blockScrolling) {
config.warn("Automatically scrolling cursor into view after selection change",
"this will be disabled in the next version",
"set editor.$blockScrolling = Infinity to disable this message"
);
this.renderer.scrollCursorIntoView();
}
@ -905,7 +905,7 @@ var Editor = function(renderer, session) {
/**
* Emitted when text is pasted.
* @event paste
* @param {String} text The pasted text
* @param {Object} an object which contains one property, `text`, that represents the text to be pasted. Editing this property will alter the text that is pasted.
*
*
**/
@ -915,18 +915,37 @@ var Editor = function(renderer, session) {
*
*
**/
this.onPaste = function(text) {
// todo this should change when paste becomes a command
if (this.$readOnly)
return;
var e = {text: text};
this.onPaste = function(text, event) {
var e = {text: text, event: event};
this.commands.exec("paste", this, e);
};
this.$handlePaste = function(e) {
if (typeof e == "string")
e = {text: e};
this._signal("paste", e);
this.insert(e.text, true);
var text = e.text;
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
this.insert(text);
} else {
var lines = text.split(/\r\n|\r|\n/);
var ranges = this.selection.rangeList.ranges;
if (lines.length > ranges.length || lines.length < 2 || !lines[1])
return this.commands.exec("insertstring", this, text);
for (var i = ranges.length; i--;) {
var range = ranges[i];
if (!range.isEmpty())
this.session.remove(range);
this.session.insert(range.start, lines[i]);
}
}
};
this.execCommand = function(command, args) {
this.commands.exec(command, this, args);
return this.commands.exec(command, this, args);
};
/**
@ -1278,7 +1297,7 @@ var Editor = function(renderer, session) {
};
/**
* Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace.
* Removes the current selection or one character.
* @param {String} dir The direction of the deletion to occur, either "left" or "right"
*
**/
@ -1610,15 +1629,7 @@ var Editor = function(renderer, session) {
**/
this.removeLines = function() {
var rows = this.$getSelectedRows();
var range;
if (rows.first === 0 || rows.last+1 < this.session.getLength())
range = new Range(rows.first, 0, rows.last+1, 0);
else
range = new Range(
rows.first-1, this.session.getLine(rows.first-1).length,
rows.last, this.session.getLine(rows.last).length
);
this.session.remove(range);
this.session.removeFullLines(rows.first, rows.last);
this.clearSelection();
};
@ -1647,9 +1658,7 @@ var Editor = function(renderer, session) {
* @related EditSession.moveLinesUp
**/
this.moveLinesDown = function() {
this.$moveLines(function(firstRow, lastRow) {
return this.session.moveLinesDown(firstRow, lastRow);
});
this.$moveLines(1, false);
};
/**
@ -1658,9 +1667,7 @@ var Editor = function(renderer, session) {
* @related EditSession.moveLinesDown
**/
this.moveLinesUp = function() {
this.$moveLines(function(firstRow, lastRow) {
return this.session.moveLinesUp(firstRow, lastRow);
});
this.$moveLines(-1, false);
};
/**
@ -1684,10 +1691,7 @@ var Editor = function(renderer, session) {
*
**/
this.copyLinesUp = function() {
this.$moveLines(function(firstRow, lastRow) {
this.session.duplicateLines(firstRow, lastRow);
return 0;
});
this.$moveLines(-1, true);
};
/**
@ -1697,51 +1701,61 @@ var Editor = function(renderer, session) {
*
**/
this.copyLinesDown = function() {
this.$moveLines(function(firstRow, lastRow) {
return this.session.duplicateLines(firstRow, lastRow);
});
this.$moveLines(1, true);
};
/**
* Executes a specific function, which can be anything that manipulates selected lines, such as copying them, duplicating them, or shifting them.
* @param {Function} mover A method to call on each selected row
*
* for internal use
* @ignore
*
**/
this.$moveLines = function(mover) {
this.$moveLines = function(dir, copy) {
var rows, moved;
var selection = this.selection;
if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
var range = selection.toOrientedRange();
var rows = this.$getSelectedRows(range);
var linesMoved = mover.call(this, rows.first, rows.last);
range.moveBy(linesMoved, 0);
rows = this.$getSelectedRows(range);
moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
if (copy && dir == -1) moved = 0;
range.moveBy(moved, 0);
selection.fromOrientedRange(range);
} else {
var ranges = selection.rangeList.ranges;
selection.rangeList.detach(this.session);
for (var i = ranges.length; i--; ) {
this.inVirtualSelectionMode = true;
var diff = 0;
var totalDiff = 0;
var l = ranges.length;
for (var i = 0; i < l; i++) {
var rangeIndex = i;
var rows = ranges[i].collapseRows();
var last = rows.end.row;
var first = rows.start.row;
while (i--) {
rows = ranges[i].collapseRows();
if (first - rows.end.row <= 1)
first = rows.end.row;
else
ranges[i].moveBy(diff, 0);
rows = this.$getSelectedRows(ranges[i]);
var first = rows.first;
var last = rows.last;
while (++i < l) {
if (totalDiff) ranges[i].moveBy(totalDiff, 0);
var subRows = this.$getSelectedRows(ranges[i]);
if (copy && subRows.first != last)
break;
else if (!copy && subRows.first > last + 1)
break;
last = subRows.last;
}
i++;
var linesMoved = mover.call(this, first, last);
while (rangeIndex >= i) {
ranges[rangeIndex].moveBy(linesMoved, 0);
rangeIndex--;
i--;
diff = this.session.$moveLines(first, last, copy ? 0 : dir);
if (copy && dir == -1) rangeIndex = i + 1;
while (rangeIndex <= i) {
ranges[rangeIndex].moveBy(diff, 0);
rangeIndex++;
}
if (!copy) diff = 0;
totalDiff += diff;
}
selection.fromOrientedRange(selection.ranges[0]);
selection.rangeList.attach(this.session);
this.inVirtualSelectionMode = false;
}
};
@ -1754,8 +1768,8 @@ var Editor = function(renderer, session) {
*
* @returns {Object}
**/
this.$getSelectedRows = function() {
var range = this.getSelectionRange().collapseRows();
this.$getSelectedRows = function(range) {
range = (range || this.getSelectionRange()).collapseRows();
return {
first: this.session.getRowFoldStart(range.start.row),
@ -2003,17 +2017,13 @@ var Editor = function(renderer, session) {
* Moves the cursor's row and column to the next matching bracket or HTML tag.
*
**/
this.jumpToMatching = function(select) {
this.jumpToMatching = function(select, expand) {
var cursor = this.getCursorPosition();
var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
var prevToken = iterator.getCurrentToken();
var token = prevToken;
var token = prevToken || iterator.stepForward();
if (!token)
token = iterator.stepForward();
if (!token)
return;
if (!token) return;
//get next closing tag or bracket
var matchType;
@ -2032,12 +2042,12 @@ var Editor = function(renderer, session) {
do {
if (token.value.match(/[{}()\[\]]/g)) {
for (; i<token.value.length && !found; i++) {
for (; i < token.value.length && !found; i++) {
if (!brackets[token.value[i]]) {
continue;
}
bracketType = brackets[token.value[i]]+'.'+token.type.replace("rparen", "lparen");
bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
if (isNaN(depth[bracketType])) {
depth[bracketType] = 0;
@ -2048,27 +2058,29 @@ var Editor = function(renderer, session) {
case '[':
case '{':
depth[bracketType]++;
break;
break;
case ')':
case ']':
case '}':
depth[bracketType]--;
if (depth[bracketType]===-1) {
if (depth[bracketType] === -1) {
matchType = 'bracket';
found = true;
}
break;
}
}
} else if (token && token.type.indexOf('tag-name') !== -1) {
}
else if (token && token.type.indexOf('tag-name') !== -1) {
if (isNaN(depth[token.value])) {
depth[token.value] = 0;
}
if (prevToken.value === '<') {
depth[token.value]++;
} else if (prevToken.value === '</') {
}
else if (prevToken.value === '</') {
depth[token.value]--;
}
@ -2086,37 +2098,35 @@ var Editor = function(renderer, session) {
} while (token && !found);
//no match found
if (!matchType) {
if (!matchType)
return;
}
var range;
if (matchType==='bracket') {
var range, pos;
if (matchType === 'bracket') {
range = this.session.getBracketRange(cursor);
if (!range) {
range = new Range(
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()+i-1,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()+i-1
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() + i - 1,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() + i - 1
);
if (!range)
return;
var pos = range.start;
if (pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
pos = range.start;
if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
range = this.session.getBracketRange(pos);
}
} else if(matchType==='tag') {
if (token && token.type.indexOf('tag-name') !== -1)
}
else if (matchType === 'tag') {
if (token && token.type.indexOf('tag-name') !== -1)
var tag = token.value;
else
return;
var range = new Range(
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()-2,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()-2
range = new Range(
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() - 2,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() - 2
);
//find matching tag
@ -2128,17 +2138,18 @@ var Editor = function(renderer, session) {
if (prevToken) {
if (prevToken.type.indexOf('tag-close') !== -1) {
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn()+1);
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
}
if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value === '<') {
depth[tag]++;
} else if ( prevToken.value === '</') {
}
else if (prevToken.value === '</') {
depth[tag]--;
}
if (depth[tag]===0)
if (depth[tag] === 0)
found = true;
}
}
@ -2147,7 +2158,7 @@ var Editor = function(renderer, session) {
//we found it
if (token && token.type.indexOf('tag-name')) {
var pos = range.start;
pos = range.start;
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
pos = range.end;
}
@ -2156,10 +2167,13 @@ var Editor = function(renderer, session) {
pos = range && range.cursor || pos;
if (pos) {
if (select) {
if (range && range.isEqual(this.getSelectionRange()))
if (range && expand) {
this.selection.setRange(range);
} else if (range && range.isEqual(this.getSelectionRange())) {
this.clearSelection();
else
} else {
this.selection.selectTo(pos.row, pos.column);
}
} else {
this.selection.moveTo(pos.row, pos.column);
}
@ -2517,6 +2531,9 @@ var Editor = function(renderer, session) {
this.destroy = function() {
this.renderer.destroy();
this._signal("destroy", this);
if (this.session) {
this.session.destroy();
}
};
/**
@ -2543,7 +2560,9 @@ var Editor = function(renderer, session) {
rect = self.renderer.container.getBoundingClientRect();
});
var onAfterRender = this.renderer.on("afterRender", function() {
if (shouldScroll && rect && self.isFocused()) {
if (shouldScroll && rect && (self.isFocused()
|| self.searchBox && self.searchBox.isFocused())
) {
var renderer = self.renderer;
var pos = renderer.$cursorLayer.$pixelPos;
var config = renderer.layerConfig;
@ -2663,6 +2682,7 @@ config.defineOptions(Editor.prototype, "editor", {
useSoftTabs: "session",
tabSize: "session",
wrap: "session",
indentedSoftWrap: "session",
foldStyle: "session",
mode: "session"
});

View file

@ -578,15 +578,14 @@ var onSelectionChange = function(evt) {
* and deleting text.
* @param {!Event} evt The event.
*/
var onChange = function(evt) {
var data = evt.data;
var onChange = function(delta) {
switch (data.action) {
case 'removeText':
case 'remove':
cvox.Api.speak(data.text, 0, DELETED_PROP);
/* Let the future cursor change event know it's from text change. */
changed = true;
break;
case 'insertText':
case 'insert':
cvox.Api.speak(data.text, 0);
/* Let the future cursor change event know it's from text change. */
changed = true;

View file

@ -44,13 +44,12 @@ var ElasticTabstopsLite = function(editor) {
this.onExec = function() {
recordChanges = true;
};
this.onChange = function(e) {
var range = e.data.range
this.onChange = function(delta) {
if (recordChanges) {
if (changedRows.indexOf(range.start.row) == -1)
changedRows.push(range.start.row);
if (range.end.row != range.start.row)
changedRows.push(range.end.row);
if (changedRows.indexOf(delta.start.row) == -1)
changedRows.push(delta.start.row);
if (delta.end.row != delta.start.row)
changedRows.push(delta.end.row);
}
};
};

View file

@ -34,15 +34,7 @@ var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
var Editor = require("ace/editor").Editor;
var snippetManager = require("ace/snippets").snippetManager;
var Range = require("ace/range").Range;
var emmet;
Editor.prototype.indexToPosition = function(index) {
return this.session.doc.indexToPosition(index);
};
Editor.prototype.positionToIndex = function(pos) {
return this.session.doc.positionToIndex(pos);
};
var emmet, emmetPath;
/**
* Implementation of {@link IEmmetEditor} interface for Ace
@ -72,9 +64,10 @@ AceEmmetEditor.prototype = {
getSelectionRange: function() {
// TODO should start be caret position instead?
var range = this.ace.getSelectionRange();
var doc = this.ace.session.doc;
return {
start: this.ace.positionToIndex(range.start),
end: this.ace.positionToIndex(range.end)
start: doc.positionToIndex(range.start),
end: doc.positionToIndex(range.end)
};
},
@ -91,9 +84,10 @@ AceEmmetEditor.prototype = {
* editor.createSelection(15);
*/
createSelection: function(start, end) {
var doc = this.ace.session.doc;
this.ace.selection.setRange({
start: this.ace.indexToPosition(start),
end: this.ace.indexToPosition(end)
start: doc.indexToPosition(start),
end: doc.indexToPosition(end)
});
},
@ -106,9 +100,10 @@ AceEmmetEditor.prototype = {
* alert(range.start + ', ' + range.end);
*/
getCurrentLineRange: function() {
var row = this.ace.getCursorPosition().row;
var lineLength = this.ace.session.getLine(row).length;
var index = this.ace.positionToIndex({row: row, column: 0});
var ace = this.ace;
var row = ace.getCursorPosition().row;
var lineLength = ace.session.getLine(row).length;
var index = ace.session.doc.positionToIndex({row: row, column: 0});
return {
start: index,
end: index + lineLength
@ -121,7 +116,7 @@ AceEmmetEditor.prototype = {
*/
getCaretPos: function(){
var pos = this.ace.getCursorPosition();
return this.ace.positionToIndex(pos);
return this.ace.session.doc.positionToIndex(pos);
},
/**
@ -129,7 +124,7 @@ AceEmmetEditor.prototype = {
* @param {Number} index Caret position
*/
setCaretPos: function(index){
var pos = this.ace.indexToPosition(index);
var pos = this.ace.session.doc.indexToPosition(index);
this.ace.selection.moveToPosition(pos);
},
@ -169,14 +164,15 @@ AceEmmetEditor.prototype = {
start = 0;
var editor = this.ace;
var range = Range.fromPoints(editor.indexToPosition(start), editor.indexToPosition(end));
var doc = editor.session.doc;
var range = Range.fromPoints(doc.indexToPosition(start), doc.indexToPosition(end));
editor.session.remove(range);
range.end = range.start;
//editor.selection.setRange(range);
value = this.$updateTabstops(value);
snippetManager.insertSnippet(editor, value)
snippetManager.insertSnippet(editor, value);
},
/**
@ -292,7 +288,7 @@ AceEmmetEditor.prototype = {
lastZero = range.create(data.start, result);
}
return result
return result;
},
escape: function(ch) {
if (ch == '$') return '\\$';
@ -346,29 +342,34 @@ var keymap = {
var editorProxy = new AceEmmetEditor();
exports.commands = new HashHandler();
exports.runEmmetCommand = function(editor) {
editorProxy.setupContext(editor);
if (editorProxy.getSyntax() == "php")
return false;
var actions = emmet.require("actions");
if (this.action == "expand_abbreviation_with_tab") {
if (!editor.selection.isEmpty())
return false;
}
if (this.action == "wrap_with_abbreviation") {
// without setTimeout prompt doesn't work on firefox
return setTimeout(function() {
actions.run("wrap_with_abbreviation", editorProxy);
}, 0);
}
try {
editorProxy.setupContext(editor);
if (editorProxy.getSyntax() == "php")
return false;
var actions = emmet.require("actions");
if (this.action == "expand_abbreviation_with_tab") {
if (!editor.selection.isEmpty())
return false;
}
if (this.action == "wrap_with_abbreviation") {
// without setTimeout prompt doesn't work on firefox
return setTimeout(function() {
actions.run("wrap_with_abbreviation", editorProxy);
}, 0);
}
var pos = editor.selection.lead;
var token = editor.session.getTokenAt(pos.row, pos.column);
if (token && /\btag\b/.test(token.type))
return false;
var result = actions.run(this.action, editorProxy);
} catch(e) {
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
console.log(e);
result = false
result = false;
}
return result;
};
@ -383,21 +384,35 @@ for (var command in keymap) {
});
}
exports.updateCommands = function(editor, enabled) {
if (enabled) {
editor.keyBinding.addKeyboardHandler(exports.commands);
} else {
editor.keyBinding.removeKeyboardHandler(exports.commands);
}
};
exports.isSupportedMode = function(modeId) {
return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(modeId);
};
var onChangeMode = function(e, target) {
var editor = target;
if (!editor)
return;
var modeId = editor.session.$modeId;
var enabled = modeId && /css|less|scss|sass|stylus|html|php/.test(modeId);
var enabled = exports.isSupportedMode(editor.session.$modeId);
if (e.enableEmmet === false)
enabled = false;
if (enabled)
editor.keyBinding.addKeyboardHandler(exports.commands);
else
editor.keyBinding.removeKeyboardHandler(exports.commands);
if (enabled) {
if (typeof emmetPath == "string") {
require("ace/config").loadModule(emmetPath, function() {
emmetPath = null;
});
}
}
exports.updateCommands(editor, enabled);
};
exports.AceEmmetEditor = AceEmmetEditor;
require("ace/config").defineOptions(Editor.prototype, "editor", {
enableEmmet: {
@ -409,7 +424,11 @@ require("ace/config").defineOptions(Editor.prototype, "editor", {
}
});
exports.setCore = function(e) {emmet = e;};
exports.setCore = function(e) {
if (typeof e == "string")
emmetPath = e;
else
emmet = e;
};
});

View file

@ -30,9 +30,9 @@
define(function(require, exports, module) {
"use strict";
var LineWidgets = require("ace/line_widgets").LineWidgets;
var dom = require("ace/lib/dom");
var Range = require("ace/range").Range;
var LineWidgets = require("../line_widgets").LineWidgets;
var dom = require("../lib/dom");
var Range = require("../range").Range;
function binarySearch(array, needle, comparator) {
var first = 0;
@ -62,7 +62,7 @@ function findAnnotations(session, row, dir) {
if (i < 0)
i = -i - 1;
if (i >= annotations.length - 1)
if (i >= annotations.length)
i = dir > 0 ? 0 : annotations.length - 1;
else if (i === 0 && dir < 0)
i = annotations.length - 1;

View file

@ -34,11 +34,15 @@ define(function(require, exports, module) {
var snippetManager = require("../snippets").snippetManager;
var Autocomplete = require("../autocomplete").Autocomplete;
var config = require("../config");
var lang = require("../lib/lang");
var util = require("../autocomplete/util");
var textCompleter = require("../autocomplete/text_completer");
var keyWordCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
if (session.$mode.completer) {
return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback);
}
var state = editor.session.getState(pos.row);
var completions = session.$mode.getCompletions(state, session, pos, prefix);
callback(null, completions);
@ -59,15 +63,29 @@ var snippetCompleter = {
completions.push({
caption: caption,
snippet: s.content,
meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet"
meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet",
type: "snippet"
});
}
}, this);
callback(null, completions);
},
getDocTooltip: function(item) {
if (item.type == "snippet" && !item.docHTML) {
item.docHTML = [
"<b>", lang.escapeHTML(item.caption), "</b>", "<hr></hr>",
lang.escapeHTML(item.snippet)
].join("");
}
}
};
var completers = [snippetCompleter, textCompleter, keyWordCompleter];
// Allows default completers to be removed or replaced with a explict set of completers
// A null argument here will result in an empty completer array, not a null attribute
exports.setCompleters = function(val) {
completers = val || [];
};
exports.addCompleter = function(completer) {
completers.push(completer);
};
@ -80,9 +98,7 @@ exports.snippetCompleter = snippetCompleter;
var expandSnippet = {
name: "expandSnippet",
exec: function(editor) {
var success = snippetManager.expandWithTab(editor);
if (!success)
editor.execCommand("indent");
return snippetManager.expandWithTab(editor);
},
bindKey: "Tab"
};
@ -121,45 +137,42 @@ var loadSnippetFile = function(id) {
});
};
var doLiveAutocomplete = function(e) {
var editor = e.editor;
var text = e.args || "";
function getCompletionPrefix(editor) {
var pos = editor.getCursorPosition();
var line = editor.session.getLine(pos.row);
var hasCompleter = editor.completer && editor.completer.activated;
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
//Try to find custom prefixes on the completers
completers.forEach(function(completer) {
var prefix;
// Try to find custom prefixes on the completers
editor.completers.forEach(function(completer) {
if (completer.identifierRegexps) {
completer.identifierRegexps.forEach(function(identifierRegex) {
if (!prefix) {
if (!prefix && identifierRegex)
prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
}
});
}
});
return prefix || util.retrievePrecedingIdentifier(line, pos.column);
}
var doLiveAutocomplete = function(e) {
var editor = e.editor;
var hasCompleter = editor.completer && editor.completer.activated;
// We don't want to autocomplete with no prefix
if (e.command.name === "backspace" && !prefix) {
if (hasCompleter)
if (e.command.name === "backspace") {
if (hasCompleter && !getCompletionPrefix(editor))
editor.completer.detach();
}
else if (e.command.name === "insertstring") {
var prefix = getCompletionPrefix(editor);
// Only autocomplete if there's a prefix that can be matched
if (prefix && !hasCompleter) {
if (!editor.completer) {
// Create new autocompleter
editor.completer = new Autocomplete();
// Disable autoInsert
editor.completer.autoSelect = false;
editor.completer.autoInsert = false;
}
// Disable autoInsert
editor.completer.autoInsert = false;
editor.completer.showPopup(editor);
} else if (!prefix && hasCompleter) {
// When the prefix is empty
// close the autocomplete dialog
editor.completer.detach();
}
}
};
@ -169,7 +182,8 @@ require("../config").defineOptions(Editor.prototype, "editor", {
enableBasicAutocompletion: {
set: function(val) {
if (val) {
this.completers = Array.isArray(val)? val: completers;
if (!this.completers)
this.completers = Array.isArray(val)? val: completers;
this.commands.addCommand(Autocomplete.startCommand);
} else {
this.commands.removeCommand(Autocomplete.startCommand);
@ -184,7 +198,8 @@ require("../config").defineOptions(Editor.prototype, "editor", {
enableLiveAutocompletion: {
set: function(val) {
if (val) {
this.completers = Array.isArray(val)? val: completers;
if (!this.completers)
this.completers = Array.isArray(val)? val: completers;
// On each change automatically trigger the autocomplete
this.commands.on('afterExec', doLiveAutocomplete);
} else {

View file

@ -60,41 +60,47 @@ module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) {
var modelist = require('../modelist');
var themelist = require('../themelist');
editor.menuOptions = {
"setNewLineMode" : [{
"textContent" : "unix",
"value" : "unix"
setNewLineMode: [{
textContent: "unix",
value: "unix"
}, {
"textContent" : "windows",
"value" : "windows"
textContent: "windows",
value: "windows"
}, {
"textContent" : "auto",
"value" : "auto"
textContent: "auto",
value: "auto"
}],
"setTheme" : [],
"setMode" : [],
"setKeyboardHandler": [{
"textContent" : "ace",
"value" : ""
setTheme: [],
setMode: [],
setKeyboardHandler: [{
textContent: "ace",
value: ""
}, {
"textContent" : "vim",
"value" : "ace/keyboard/vim"
textContent: "vim",
value: "ace/keyboard/vim"
}, {
"textContent" : "emacs",
"value" : "ace/keyboard/emacs"
textContent: "emacs",
value: "ace/keyboard/emacs"
}, {
textContent: "textarea",
value: "ace/keyboard/textarea"
}, {
textContent: "sublime",
value: "ace/keyboard/sublime"
}]
};
editor.menuOptions.setTheme = themelist.themes.map(function(theme) {
return {
'textContent' : theme.caption,
'value' : theme.theme
textContent: theme.caption,
value: theme.theme
};
});
editor.menuOptions.setMode = modelist.modes.map(function(mode) {
return {
'textContent' : mode.name,
'value' : mode.mode
textContent: mode.name,
value: mode.mode
};
});
};

View file

@ -91,6 +91,12 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
elements.forEach(function(element) {
topmenu.appendChild(element);
});
var el = topmenu.appendChild(document.createElement('div'));
var version = "1.1.9";
el.style.padding = "1em";
el.textContent = "Ace version " + version;
return topmenu;
}
/**

View file

@ -69,29 +69,20 @@ module.exports.getEditorKeybordShortcuts = function(editor) {
editor.keyBinding.$handlers.forEach(function(handler) {
var ckb = handler.commandKeyBinding;
for (var i in ckb) {
var modifier = parseInt(i);
if (modifier == -1) {
modifier = "";
} else if(isNaN(modifier)) {
modifier = i;
} else {
modifier = "" +
(modifier & KEY_MODS.command ? "Cmd-" : "") +
(modifier & KEY_MODS.ctrl ? "Ctrl-" : "") +
(modifier & KEY_MODS.alt ? "Alt-" : "") +
(modifier & KEY_MODS.shift ? "Shift-" : "");
}
for (var key in ckb[i]) {
var command = ckb[i][key]
var key = i.replace(/(^|-)\w/g, function(x) { return x.toUpperCase(); });
var commands = ckb[i];
if (!Array.isArray(commands))
commands = [commands];
commands.forEach(function(command) {
if (typeof command != "string")
command = command.name
if (commandMap[command]) {
commandMap[command].key += "|" + modifier + key;
commandMap[command].key += "|" + key;
} else {
commandMap[command] = {key: modifier+key, command: command};
commandMap[command] = {key: key, command: command};
keybindings.push(commandMap[command]);
}
}
}
});
}
});
return keybindings;

View file

@ -43,17 +43,18 @@ Mode.prototype.supportsFile = function(filename) {
// todo firstlinematch
var supportedModes = {
ABAP: ["abap"],
ABC: ["abc"],
ActionScript:["as"],
ADA: ["ada|adb"],
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
AsciiDoc: ["asciidoc"],
AsciiDoc: ["asciidoc|adoc"],
Assembly_x86:["asm"],
AutoHotKey: ["ahk"],
BatchFile: ["bat|cmd"],
C9Search: ["c9search_results"],
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
Cirru: ["cirru|cr"],
Clojure: ["clj"],
Clojure: ["clj|cljs"],
Cobol: ["CBL|COB"],
coffee: ["coffee|cf|cson|^Cakefile"],
ColdFusion: ["cfm"],
@ -65,11 +66,18 @@ var supportedModes = {
Diff: ["diff|patch"],
Dockerfile: ["^Dockerfile"],
Dot: ["dot"],
Erlang: ["erl|hrl"],
Dummy: ["dummy"],
DummySyntax: ["dummy"],
Eiffel: ["e"],
EJS: ["ejs"],
Elixir: ["ex|exs"],
Elm: ["elm"],
Erlang: ["erl|hrl"],
Forth: ["frt|fs|ldr"],
FTL: ["ftl"],
Gcode: ["gcode"],
Gherkin: ["feature"],
Gitignore: ["^.gitignore"],
Glsl: ["glsl|frag|vert"],
golang: ["go"],
Groovy: ["groovy"],
@ -80,6 +88,7 @@ var supportedModes = {
HTML: ["html|htm|xhtml"],
HTML_Ruby: ["erb|rhtml|html.erb"],
INI: ["ini|conf|cfg|prefs"],
Io: ["io"],
Jack: ["jack"],
Jade: ["jade"],
Java: ["java"],
@ -90,6 +99,7 @@ var supportedModes = {
JSX: ["jsx"],
Julia: ["jl"],
LaTeX: ["tex|latex|ltx|bib"],
Lean: ["lean|hlean"],
LESS: ["less"],
Liquid: ["liquid"],
Lisp: ["lisp"],
@ -100,19 +110,22 @@ var supportedModes = {
LuaPage: ["lp"],
Lucene: ["lucene"],
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
MATLAB: ["matlab"],
Markdown: ["md|markdown"],
Mask: ["mask"],
MATLAB: ["matlab"],
MEL: ["mel"],
MySQL: ["mysql"],
MUSHCode: ["mc|mush"],
MySQL: ["mysql"],
Nix: ["nix"],
Nim: ["nim"],
ObjectiveC: ["m|mm"],
OCaml: ["ml|mli"],
Pascal: ["pas|p"],
Perl: ["pl|pm"],
pgSQL: ["pgsql"],
PHP: ["php|phtml"],
PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp"],
Powershell: ["ps1"],
Praat: ["praat|praatscript|psc|proc"],
Prolog: ["plg|prolog"],
Properties: ["properties"],
Protobuf: ["proto"],
@ -125,15 +138,16 @@ var supportedModes = {
SASS: ["sass"],
SCAD: ["scad"],
Scala: ["scala"],
Smarty: ["smarty|tpl"],
Scheme: ["scm|rkt"],
SCSS: ["scss"],
SH: ["sh|bash|^.bashrc"],
SJS: ["sjs"],
Space: ["space"],
Smarty: ["smarty|tpl"],
snippets: ["snippets"],
Soy_Template:["soy"],
Space: ["space"],
SQL: ["sql"],
SQLServer: ["sqlserver"],
Stylus: ["styl|stylus"],
SVG: ["svg"],
Tcl: ["tcl"],
@ -144,19 +158,22 @@ var supportedModes = {
Twig: ["twig"],
Typescript: ["ts|typescript|str"],
Vala: ["vala"],
VBScript: ["vbs"],
VBScript: ["vbs|vb"],
Velocity: ["vm"],
Verilog: ["v|vh|sv|svh"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
VHDL: ["vhd|vhdl"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
XQuery: ["xq"],
YAML: ["yaml|yml"]
YAML: ["yaml|yml"],
// Add the missing mode "Django" to ext-modelist
Django: ["html"]
};
var nameOverrides = {
ObjectiveC: "Objective-C",
CSharp: "C#",
golang: "Go",
C_Cpp: "C/C++",
C_Cpp: "C and C++",
coffee: "CoffeeScript",
HTML_Ruby: "HTML (Ruby)",
FTL: "FreeMarker"
@ -178,4 +195,3 @@ module.exports = {
};
});

View file

@ -7,7 +7,7 @@
background-color: #ddd;
border: 1px solid #cbcbcb;
border-top: 0 none;
max-width: 297px;
max-width: 325px;
overflow: hidden;
margin: 0;
padding: 4px;
@ -47,7 +47,6 @@
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
display: block;
float: left;
height: 22px;
outline: 0;
@ -61,7 +60,6 @@
border: 0 none;
border-left: 1px solid #dcdcdc;
cursor: pointer;
display: block;
float: left;
height: 22px;
margin: 0;
@ -94,12 +92,9 @@
border: 0 none;
color: #656565;
cursor: pointer;
display: block;
float: right;
font-family: Arial;
font-size: 16px;
font: 16px/16px Arial;
height: 14px;
line-height: 16px;
margin: 5px 1px 9px 5px;
padding: 0;
text-align: center;

View file

@ -46,6 +46,7 @@ var html = '<div class="ace_search right">\
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\
<button type="button" action="findNext" class="ace_searchbtn next"></button>\
<button type="button" action="findPrev" class="ace_searchbtn prev"></button>\
<button type="button" action="findAll" class="ace_searchbtn" title="Alt-Enter">All</button>\
</div>\
<div class="ace_replace_form">\
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\
@ -170,6 +171,11 @@ var SearchBox = function(editor, range, showReplaceForm) {
sb.replace();
sb.findPrev();
},
"Alt-Return": function(sb) {
if (sb.activeInput == sb.replaceInput)
sb.replaceAll();
sb.findAll();
},
"Tab": function(sb) {
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
}
@ -229,6 +235,18 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.findPrev = function() {
this.find(true, true);
};
this.findAll = function(){
var range = this.editor.findAll(this.searchInput.value, {
regExp: this.regExpOption.checked,
caseSensitive: this.caseSensitiveOption.checked,
wholeWord: this.wholeWordOption.checked
});
var noMatch = !range && this.searchInput.value;
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
this.editor._emit("findSearchBox", { match: !noMatch });
this.highlight();
this.hide();
};
this.replace = function() {
if (!this.editor.getReadOnly())
this.editor.replace(this.replaceInput.value);
@ -263,6 +281,10 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
};
this.isFocused = function() {
var el = document.activeElement;
return el == this.searchInput || el == this.replaceInput;
}
}).call(SearchBox.prototype);
exports.SearchBox = SearchBox;

View file

@ -1,25 +1,31 @@
.ace_static_highlight {
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace;
font-size: 12px;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace;
font-size: 12px;
white-space: pre-wrap
}
.ace_static_highlight .ace_gutter {
width: 25px !important;
display: block;
float: left;
width: 2em;
text-align: right;
padding: 0 3px 0 0;
margin-right: 3px;
position: static !important;
}
.ace_static_highlight .ace_line { clear: both; }
.ace_static_highlight.ace_show_gutter .ace_line {
padding-left: 2.6em;
}
.ace_static_highlight .ace_line { position: relative; }
.ace_static_highlight .ace_gutter-cell {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
top: 0;
bottom: 0;
left: 0;
position: absolute;
}

View file

@ -37,6 +37,10 @@ var baseStyles = require("../requirejs/text!./static.css");
var config = require("../config");
var dom = require("../lib/dom");
var SimpleTextLayer = function() {
this.config = {};
};
SimpleTextLayer.prototype = TextLayer.prototype;
var highlight = function(el, opts, callback) {
var m = el.className.match(/lang-(\w+)/);
@ -98,7 +102,6 @@ var highlight = function(el, opts, callback) {
* and `css`.
* @returns {object} An object containing the properties `html` and `css`.
*/
highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) {
var waiting = 1;
var modeCache = EditSession.prototype.$modes;
@ -112,11 +115,17 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba
--waiting || done();
});
}
// allow setting mode options e.h {path: "ace/mode/php", inline:true}
var modeOptions;
if (mode && typeof mode === "object" && !mode.getTokenizer) {
modeOptions = mode;
mode = modeOptions.path;
}
if (typeof mode == "string") {
waiting++;
config.loadModule(['mode', mode], function(m) {
if (!modeCache[mode]) modeCache[mode] = new m.Mode();
if (!modeCache[mode] || modeOptions)
modeCache[mode] = new m.Mode(modeOptions);
mode = modeCache[mode];
--waiting || done();
});
@ -130,14 +139,13 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba
return --waiting || done();
};
/*
/**
* Transforms a given input code snippet into HTML using the given mode
* @param {string} input Code snippet
* @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode')
* @param {string} r Code snippet
* @returns {object} An object containing: html, css
*/
highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
lineStart = parseInt(lineStart || 1, 10);
@ -145,12 +153,8 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
session.setUseWorker(false);
session.setMode(mode);
var textLayer = new TextLayer(document.createElement("div"));
var textLayer = new SimpleTextLayer();
textLayer.setSession(session);
textLayer.config = {
characterWidth: 10,
lineHeight: 20
};
session.setValue(input);
@ -167,7 +171,8 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
// let's prepare the whole html
var html = "<div class='" + theme.cssClass + "'>" +
"<div class='ace_static_highlight' style='counter-reset:ace_line " + (lineStart - 1) + "'>" +
"<div class='ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter") +
"' style='counter-reset:ace_line " + (lineStart - 1) + "'>" +
stringBuilder.join("") +
"</div>" +
"</div>";

View file

@ -28,12 +28,12 @@ module.exports = {
var mode = new JavaScriptMode();
var result = highlighter.render(snippet, mode, theme);
assert.equal(result.html, "<div class='ace-tomorrow'><div class='ace_static_highlight' style='counter-reset:ace_line 0'>"
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_comment ace_doc'>/**\xa0this\xa0is\xa0a\xa0function</span>\n</div>"
assert.equal(result.html, "<div class='ace-tomorrow'><div class='ace_static_highlight ace_show_gutter' style='counter-reset:ace_line 0'>"
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_comment ace_doc'>/** this is a function</span>\n</div>"
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_comment ace_doc'>*</span>\n</div>"
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_comment ace_doc'>*/</span>\n</div>"
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_storage ace_type'>function</span>\xa0<span class='ace_entity ace_name ace_function'>hello</span>\xa0<span class='ace_paren ace_lparen'>(</span><span class='ace_variable ace_parameter'>a</span><span class='ace_punctuation ace_operator'>,\xa0</span><span class='ace_variable ace_parameter'>b</span><span class='ace_punctuation ace_operator'>,\xa0</span><span class='ace_variable ace_parameter'>c</span><span class='ace_paren ace_rparen'>)</span>\xa0<span class='ace_paren ace_lparen'>{</span>\n</div>"
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span>\xa0\xa0\xa0\xa0<span class='ace_storage ace_type'>console</span><span class='ace_punctuation ace_operator'>.</span><span class='ace_support ace_function ace_firebug'>log</span><span class='ace_paren ace_lparen'>(</span><span class='ace_identifier'>a</span>\xa0<span class='ace_keyword ace_operator'>*</span>\xa0<span class='ace_identifier'>b</span>\xa0<span class='ace_keyword ace_operator'>+</span>\xa0<span class='ace_identifier'>c</span>\xa0<span class='ace_keyword ace_operator'>+</span>\xa0<span class='ace_string'>'sup$'</span><span class='ace_paren ace_rparen'>)</span><span class='ace_punctuation ace_operator'>;</span>\n</div>"
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_storage ace_type'>function</span> <span class='ace_entity ace_name ace_function'>hello</span> <span class='ace_paren ace_lparen'>(</span><span class='ace_variable ace_parameter'>a</span><span class='ace_punctuation ace_operator'>, </span><span class='ace_variable ace_parameter'>b</span><span class='ace_punctuation ace_operator'>, </span><span class='ace_variable ace_parameter'>c</span><span class='ace_paren ace_rparen'>)</span> <span class='ace_paren ace_lparen'>{</span>\n</div>"
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span> <span class='ace_storage ace_type'>console</span><span class='ace_punctuation ace_operator'>.</span><span class='ace_support ace_function ace_firebug'>log</span><span class='ace_paren ace_lparen'>(</span><span class='ace_identifier'>a</span> <span class='ace_keyword ace_operator'>*</span> <span class='ace_identifier'>b</span> <span class='ace_keyword ace_operator'>+</span> <span class='ace_identifier'>c</span> <span class='ace_keyword ace_operator'>+</span> <span class='ace_string'>'sup$'</span><span class='ace_paren ace_rparen'>)</span><span class='ace_punctuation ace_operator'>;</span>\n</div>"
+ "<div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'></span><span class='ace_paren ace_rparen'>}</span>\n</div>"
+ "</div></div>");
assert.ok(!!result.css);

View file

@ -28,9 +28,8 @@ var StatusBar = function(editor, parentNode) {
str && status.push(str, separator || "|");
}
if (editor.$vimModeHandler)
add(editor.$vimModeHandler.getStatusText());
else if (editor.commands.recording)
add(editor.keyBinding.getStatusText(editor));
if (editor.commands.recording)
add("REC");
var c = editor.selection.lead;

View file

@ -155,7 +155,7 @@ function setupContainer(element, getValue) {
return container;
}
exports.transformTextarea = function(element, loader) {
exports.transformTextarea = function(element, options) {
var session;
var container = setupContainer(element, function() {
return session.getValue();
@ -215,9 +215,8 @@ exports.transformTextarea = function(element, loader) {
applyStyles(settingDiv, settingDivStyles);
container.appendChild(settingDiv);
options = options || exports.defaultOptions;
// Power up ace on the textarea:
var options = {};
var editor = ace.edit(editorDiv);
session = editor.getSession();
@ -228,10 +227,10 @@ exports.transformTextarea = function(element, loader) {
container.appendChild(settingOpener);
// Create the API.
setupApi(editor, editorDiv, settingDiv, ace, options, loader);
setupApi(editor, editorDiv, settingDiv, ace, options, load);
// Create the setting's panel.
setupSettingPanel(settingDiv, settingOpener, editor, options);
setupSettingPanel(settingDiv, settingOpener, editor);
var state = "";
event.addListener(settingOpener, "mousemove", function(e) {
@ -296,37 +295,15 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
};
editor.$setOption = editor.setOption;
editor.$getOption = editor.getOption;
editor.setOption = function(key, value) {
if (options[key] == value) return;
switch (key) {
case "mode":
if (value != "text") {
// Load the required mode file. Files get loaded only once.
loader("mode-" + value + ".js", "ace/mode/" + value, function() {
var aceMode = require("../mode/" + value).Mode;
session.setMode(new aceMode());
});
} else {
session.setMode(new (require("../mode/text").Mode));
}
editor.$setOption("mode", "ace/mode/" + value)
break;
case "theme":
if (value != "textmate") {
// Load the required theme file. Files get loaded only once.
loader("theme-" + value + ".js", "ace/theme/" + value, function() {
editor.setTheme("ace/theme/" + value);
});
} else {
editor.setTheme("ace/theme/textmate");
}
editor.$setOption("theme", "ace/theme/" + value)
break;
case "fontSize":
editorDiv.style.fontSize = value;
break;
case "keybindings":
switch (value) {
case "vim":
@ -341,58 +318,55 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
break;
case "softWrap":
switch (value) {
case "off":
session.setUseWrapMode(false);
renderer.setPrintMarginColumn(80);
break;
case "40":
session.setUseWrapMode(true);
session.setWrapLimitRange(40, 40);
renderer.setPrintMarginColumn(40);
break;
case "80":
session.setUseWrapMode(true);
session.setWrapLimitRange(80, 80);
renderer.setPrintMarginColumn(80);
break;
case "free":
session.setUseWrapMode(true);
session.setWrapLimitRange(null, null);
renderer.setPrintMarginColumn(80);
break;
}
case "fontSize":
editor.$setOption(key, value);
break;
default:
editor.$setOption(key, toBool(value));
}
options[key] = value;
};
editor.getOption = function(key) {
return options[key];
switch (key) {
case "mode":
return editor.$getOption("mode").substr("ace/mode/".length)
break;
case "theme":
return editor.$getOption("theme").substr("ace/theme/".length)
break;
case "keybindings":
var value = editor.getKeyboardHandler()
switch (value && value.$id) {
case "ace/keyboard/vim":
return "vim";
case "ace/keyboard/emacs":
return "emacs";
default:
return "ace";
}
break;
default:
return editor.$getOption(key);
}
};
editor.getOptions = function() {
return options;
};
editor.setOptions(exports.options);
editor.setOptions(options);
return editor;
}
function setupSettingPanel(settingDiv, settingOpener, editor, options) {
function setupSettingPanel(settingDiv, settingOpener, editor) {
var BOOL = null;
var desc = {
mode: "Mode:",
gutter: "Display Gutter:",
wrap: "Soft Wrap:",
theme: "Theme:",
fontSize: "Font Size:",
softWrap: "Soft Wrap:",
showGutter: "Display Gutter:",
keybindings: "Keyboard",
showPrintMargin: "Show Print Margin:",
useSoftTabs: "Use Soft Tabs:",
@ -445,7 +419,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
twilight: "Twilight",
vibrant_ink: "Vibrant Ink"
},
gutter: BOOL,
showGutter: BOOL,
fontSize: {
"10px": "10px",
"11px": "11px",
@ -453,7 +427,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
"14px": "14px",
"16px": "16px"
},
softWrap: {
wrap: {
off: "Off",
40: "40",
80: "80",
@ -476,7 +450,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
if (!obj) {
builder.push(
"<input type='checkbox' title='", option, "' ",
cValue == "true" ? "checked='true'" : "",
cValue + "" == "true" ? "checked='true'" : "",
"'></input>"
);
return;
@ -496,10 +470,10 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
builder.push("</select>");
}
for (var option in options) {
for (var option in exports.defaultOptions) {
table.push("<tr><td>", desc[option], "</td>");
table.push("<td>");
renderOption(table, option, optionValues[option], options[option]);
renderOption(table, option, optionValues[option], editor.getOption(option));
table.push("</td></tr>");
}
table.push("</table>");
@ -532,12 +506,12 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
}
// Default startup options.
exports.options = {
mode: "text",
exports.defaultOptions = {
mode: "javascript",
theme: "textmate",
gutter: "false",
wrap: "off",
fontSize: "12px",
softWrap: "off",
showGutter: "false",
keybindings: "ace",
showPrintMargin: "false",
useSoftTabs: "true",

View file

@ -51,12 +51,14 @@ var themeData = [
["Dreamweaver" ],
["Eclipse" ],
["GitHub" ],
["IPlastic" ],
["Solarized Light"],
["TextMate" ],
["Tomorrow" ],
["XCode" ],
["Kuroir"],
["KatzenMilch"],
["SQL Server" ,"sqlserver" , "light"],
["Ambiance" ,"ambiance" , "dark"],
["Chaos" ,"chaos" , "dark"],
["Clouds Midnight" ,"clouds_midnight" , "dark"],
@ -71,6 +73,7 @@ var themeData = [
["Solarized Dark" ,"solarized_dark" , "dark"],
["Terminal" ,"terminal" , "dark"],
["Tomorrow Night" ,"tomorrow_night" , "dark"],
["The Night After Tomorrow" ,"the_night_after_tomorrow" , "dark"],
["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],

View file

@ -46,7 +46,6 @@ exports.$detectIndentation = function(lines, fallback) {
if (!/^\s*[^*+\-\s]/.test(line))
continue;
var tabs = line.match(/^\t*/)[0].length;
if (line[0] == "\t")
tabIndents++;
@ -65,9 +64,6 @@ exports.$detectIndentation = function(lines, fallback) {
line = lines[i++];
}
if (!stats.length)
return;
function getScore(indent) {
var score = 0;
for (var i = indent; i < stats.length; i += indent)
@ -80,11 +76,14 @@ exports.$detectIndentation = function(lines, fallback) {
var first = {score: 0, length: 0};
var spaceIndents = 0;
for (var i = 1; i < 12; i++) {
var score = getScore(i);
if (i == 1) {
spaceIndents = getScore(i);
var score = 1;
spaceIndents = score;
score = stats[1] ? 0.9 : 0.8;
if (!stats.length)
score = 0
} else
var score = getScore(i) / spaceIndents;
score /= spaceIndents;
if (changes[i])
score += changes[i] / changesTotal;
@ -99,7 +98,7 @@ exports.$detectIndentation = function(lines, fallback) {
if (tabIndents > spaceIndents + 1)
return {ch: "\t", length: tabLength};
if (spaceIndents + 1 > tabIndents)
if (spaceIndents > tabIndents + 1)
return {ch: " ", length: tabLength};
};

View file

@ -0,0 +1,116 @@
if (typeof process !== "undefined") {
require("amd-loader");
require("../test/mockdom");
}
define(function(require, exports, module) {
"use strict";
var assert = require("assert");
var EditSession = require("../edit_session").EditSession;
var whitespace = require("./whitespace");
// Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite
module.exports = {
timeout: 10000,
"test tab detection": function(next) {
var s = new EditSession([
"define({",
"\tfoo:1,",
"\tbar:2,",
"\tbaz:{,",
"\t\tx:3",
"\t}",
"})"
]);
var indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, "\t");
assert.equal(indent.length, undefined);
s.insert({row: 0, column: 0}, " ");
indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, "\t");
assert.equal(indent.length, 4);
s.setValue("");
indent = whitespace.$detectIndentation(s.doc.$lines);
assert.ok(!indent);
next();
},
"test empty session": function(next) {
var s = new EditSession([
"define({",
"foo:1,",
"})"
]);
var indent = whitespace.$detectIndentation(s.doc.$lines);
assert.ok(!indent);
s.insert({row: 1, column: 0}, " x\n ");
indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, " ");
assert.equal(indent.length, 4);
next();
},
"!test one line": function(next) {
var s = new EditSession([
"define({",
" foo:1,",
"})"
]);
var indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, " ");
assert.equal(indent.length, 4);
next();
},
"test 1 width indents": function(next) {
var s = new EditSession([
"define({",
" foo:1,",
"})",
"define({",
" bar:1,",
"})",
" t",
" t",
" t",
" t",
" t",
" t",
" t",
" t"
]);
var indent = whitespace.$detectIndentation(s.doc.$lines);
// assert.equal(indent.ch, " ");
// assert.equal(indent.length, 4);
s = new EditSession([
"{",
" foo:1,",
" bar: {",
" baz:2",
" }",
"}"
]);
indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, " ");
assert.equal(indent.length, 1);
next();
},
};
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec();
}

View file

@ -64,6 +64,34 @@ function IncrementalSearch() {
oop.inherits(IncrementalSearch, Search);
// regexp handling
function isRegExp(obj) {
return obj instanceof RegExp;
}
function regExpToObject(re) {
var string = String(re),
start = string.indexOf('/'),
flagStart = string.lastIndexOf('/');
return {
expression: string.slice(start+1, flagStart),
flags: string.slice(flagStart+1)
}
}
function stringToRegExp(string, flags) {
try {
return new RegExp(string, flags);
} catch (e) { return string; }
}
function objectToRegExp(obj) {
return stringToRegExp(obj.expression, obj.flags);
}
// iSearch class
;(function() {
this.activate = function(ed, backwards) {
@ -77,7 +105,7 @@ oop.inherits(IncrementalSearch, Search);
this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this));
this.selectionFix(ed);
this.statusMessage(true);
}
};
this.deactivate = function(reset) {
this.cancelSearch(reset);
@ -89,7 +117,7 @@ oop.inherits(IncrementalSearch, Search);
}
ed.onPaste = this.$originalEditorOnPaste;
this.message('');
}
};
this.selectionFix = function(editor) {
// Fix selection bug: When clicked inside the editor
@ -100,7 +128,7 @@ oop.inherits(IncrementalSearch, Search);
if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
editor.clearSelection();
}
}
};
this.highlight = function(regexp) {
var sess = this.$editor.session,
@ -108,7 +136,7 @@ oop.inherits(IncrementalSearch, Search);
new SearchHighlight(null, "ace_isearch-result", "text"));
hl.setRegexp(regexp);
sess._emit("changeBackMarker"); // force highlight layer redraw
}
};
this.cancelSearch = function(reset) {
var e = this.$editor;
@ -122,7 +150,7 @@ oop.inherits(IncrementalSearch, Search);
}
this.highlight(null);
return Range.fromPoints(this.$currentPos, this.$currentPos);
}
};
this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) {
if (!this.$editor) return null;
@ -135,36 +163,46 @@ oop.inherits(IncrementalSearch, Search);
if (options.needle.length === 0) {
this.statusMessage(true);
return this.cancelSearch(true);
};
}
// try to find the next occurence and enable highlighting marker
options.start = this.$currentPos;
var session = this.$editor.session,
found = this.find(session);
found = this.find(session),
shouldSelect = this.$editor.emacsMark ?
!!this.$editor.emacsMark() : !this.$editor.selection.isEmpty();
if (found) {
if (options.backwards) found = Range.fromPoints(found.end, found.start);
this.$editor.moveCursorToPosition(found.end);
this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end));
if (moveToNext) this.$currentPos = found.end;
// highlight after cursor move, so selection works properly
this.highlight(options.re)
this.highlight(options.re);
}
this.statusMessage(found);
return found;
}
};
this.addString = function(s) {
return this.highlightAndFindWithNeedle(false, function(needle) {
return needle + s;
if (!isRegExp(needle))
return needle + s;
var reObj = regExpToObject(needle);
reObj.expression += s;
return objectToRegExp(reObj);
});
}
};
this.removeChar = function(c) {
return this.highlightAndFindWithNeedle(false, function(needle) {
return needle.length > 0 ? needle.substring(0, needle.length-1) : needle;
if (!isRegExp(needle))
return needle.substring(0, needle.length-1);
var reObj = regExpToObject(needle);
reObj.expression = reObj.expression.substring(0, reObj.expression.length-1);
return objectToRegExp(reObj);
});
}
};
this.next = function(options) {
// try to find the next occurence of whatever we have searched for
@ -177,17 +215,29 @@ oop.inherits(IncrementalSearch, Search);
return options.useCurrentOrPrevSearch && needle.length === 0 ?
this.$prevNeedle || '' : needle;
});
}
};
this.onMouseDown = function(evt) {
// when mouse interaction happens then we quit incremental search
this.deactivate();
return true;
}
};
this.onPaste = function(text) {
this.addString(text);
}
};
this.convertNeedleToRegExp = function() {
return this.highlightAndFindWithNeedle(false, function(needle) {
return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig');
});
};
this.convertNeedleToString = function() {
return this.highlightAndFindWithNeedle(false, function(needle) {
return isRegExp(needle) ? regExpToObject(needle).expression : needle;
});
};
this.statusMessage = function(found) {
var options = this.$options, msg = '';
@ -195,7 +245,7 @@ oop.inherits(IncrementalSearch, Search);
msg += 'isearch: ' + options.needle;
msg += found ? '' : ' (not found)';
this.message(msg);
}
};
this.message = function(msg) {
if (this.$editor.showCommandLine) {
@ -204,7 +254,7 @@ oop.inherits(IncrementalSearch, Search);
} else {
console.log(msg);
}
}
};
}).call(IncrementalSearch.prototype);

View file

@ -35,13 +35,17 @@ if (typeof process !== "undefined") {
define(function(require, exports, module) {
"use strict";
var emacs = require('./keyboard/emacs');
var EditSession = require("./edit_session").EditSession;
var Editor = require("./editor").Editor;
var MockRenderer = require("./test/mockrenderer").MockRenderer;
var Range = require("./range").Range;
var MultiSelect = require("./multi_select").MultiSelect;
var assert = require("./test/assertions");
var IncrementalSearch = require("./incremental_search").IncrementalSearch;
require("./multi_select");
var editor, iSearch;
function testRanges(str, ranges) {
ranges = ranges || editor.selection.getAllRanges();
@ -69,6 +73,7 @@ module.exports = {
setUp: function() {
var session = new EditSession(["abc123", "xyz124"]);
editor = new Editor(new MockRenderer(), session);
new MultiSelect(editor);
iSearch = new IncrementalSearch();
},
@ -195,7 +200,7 @@ module.exports = {
editor.keyBinding.addKeyboardHandler(emacs.handler);
emacs.handler.commands.setMark.exec(editor);
iSearch.activate(editor);
iSearch.addString('1'); iSearch.addString('2');;
iSearch.addString('1'); iSearch.addString('2');
testRanges("Range: [0/0] -> [0/5]", [editor.getSelectionRange()], "sel range");
}

View file

@ -64,7 +64,7 @@ exports.handler.attach = function(editor) {
initialized = true;
dom.importCssString('\
.emacs-mode .ace_cursor{\
border: 2px rgba(50,250,50,0.8) solid!important;\
border: 1px rgba(50,250,50,0.8) solid!important;\
-moz-box-sizing: border-box!important;\
-webkit-box-sizing: border-box!important;\
box-sizing: border-box!important;\
@ -125,6 +125,24 @@ exports.handler.attach = function(editor) {
return this.session.$emacsMark || this.session.$emacsMarkRing.slice(-1)[0];
};
editor.emacsMarkForSelection = function(replacement) {
// find the mark in $emacsMarkRing corresponding to the current
// selection
var sel = this.selection,
multiRangeLength = this.multiSelect ?
this.multiSelect.getAllRanges().length : 1,
selIndex = sel.index || 0,
markRing = this.session.$emacsMarkRing,
markIndex = markRing.length - (multiRangeLength - selIndex),
lastMark = markRing[markIndex] || sel.anchor;
if (replacement) {
markRing.splice(markIndex, 1,
"row" in replacement && "column" in replacement ?
replacement : undefined);
}
return lastMark;
}
editor.on("click", $resetMarkMode);
editor.on("changeSession", $kbSessionChange);
editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates;
@ -146,6 +164,7 @@ exports.handler.detach = function(editor) {
editor.commands.removeCommands(commands);
editor.removeEventListener('copy', this.onCopy);
editor.removeEventListener('paste', this.onPaste);
editor.$emacsModeHandler = null;
};
var $kbSessionChange = function(e) {
@ -187,7 +206,7 @@ exports.handler.onCopy = function(e, editor) {
if (editor.$handlesEmacsOnCopy) return;
editor.$handlesEmacsOnCopy = true;
exports.handler.commands.killRingSave.exec(editor);
delete editor.$handlesEmacsOnCopy;
editor.$handlesEmacsOnCopy = false;
};
exports.handler.onPaste = function(e, editor) {
@ -195,6 +214,8 @@ exports.handler.onPaste = function(e, editor) {
};
exports.handler.bindKey = function(key, command) {
if (typeof key == "object")
key = key[this.platform];
if (!key)
return;
@ -218,12 +239,22 @@ exports.handler.bindKey = function(key, command) {
}, this);
};
exports.handler.getStatusText = function(editor, data) {
var str = "";
if (data.count)
str += data.count;
if (data.keyChain)
str += " " + data.keyChain
return str;
};
exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
// if keyCode == -1 a non-printable key was pressed, such as just
// control. Handling those is currently not supported in this handler
if (keyCode === -1) return undefined;
var editor = data.editor;
editor._signal("changeStatus");
// insertstring data.count times
if (hashId == -1) {
editor.pushEmacsMark();
@ -234,24 +265,17 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
}
}
if (key == "\x00") return undefined;
var modifier = eMods[hashId];
// CTRL + number / universalArgument for setting data.count
if (modifier == "c-" || data.universalArgument) {
var prevCount = String(data.count || 0);
if (modifier == "c-" || data.count) {
var count = parseInt(key[key.length - 1]);
if (typeof count === 'number' && !isNaN(count)) {
data.count = parseInt(prevCount + count);
data.count = Math.max(data.count, 0) || 0;
data.count = 10 * data.count + count;
return {command: "null"};
} else if (data.universalArgument) {
// if no number pressed use emacs defaults for universalArgument
// which is 4
data.count = 4;
}
}
data.universalArgument = false;
// this.commandKeyBinding maps key specs like "c-p" (for CTRL + P) to
// command objects, for lookup key needs to include the modifier
@ -273,7 +297,9 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
if (command === "null") return {command: "null"};
if (command === "universalArgument") {
data.universalArgument = true;
// if no number pressed emacs repeats action 4 times.
// minus sign is needed to allow next keypress to replace it
data.count = -4;
return {command: "null"};
}
@ -300,9 +326,12 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
if (!command) return undefined;
}
if (!command.readonly && !command.isYank)
if (!command.readOnly && !command.isYank)
data.lastCommand = null;
if (!command.readOnly && editor.emacsMark())
editor.setEmacsMark(null)
if (data.count) {
var count = data.count;
data.count = 0;
@ -313,7 +342,8 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
exec: function(editor, args) {
for (var i = 0; i < count; i++)
command.exec(editor, args);
}
},
multiSelectAction: command.multiSelectAction
}
};
} else {
@ -384,7 +414,7 @@ exports.emacsKeys = {
"M-y": "yankRotate",
"C-g": "keyboardQuit",
"C-w": "killRegion",
"C-w|C-S-W": "killRegion",
"M-w": "killRingSave",
"C-Space": "setMark",
"C-x C-x": "exchangePointAndMark",
@ -398,7 +428,7 @@ exports.emacsKeys = {
"M-;": "togglecomment",
"C-/|C-x u|S-C--|C-z": "undo",
"S-C-/|S-C-x u|C--|S-C-z": "redo", //infinite undo?
"S-C-/|S-C-x u|C--|S-C-z": "redo", // infinite undo?
// vertical editing
"C-x r": "selectRectangularRegion",
"M-x": {command: "focusCommandLine", args: "M-x "}
@ -434,61 +464,65 @@ exports.handler.addCommands({
// selection modification commands. That is,
// "goto" commands become "select" commands.
// Any insertion or mouse click resets mark-mode.
// setMark twice in a row at the same place resets markmode
// setMark twice in a row at the same place resets markmode.
// in multi select mode, ea selection is handled individually
if (args && args.count) {
var mark = editor.popEmacsMark();
mark && editor.selection.moveCursorToPosition(mark);
if (editor.inMultiSelectMode) editor.forEachSelection(moveToMark);
else moveToMark();
moveToMark();
return;
}
var mark = editor.emacsMark(),
transientMarkModeActive = true;
ranges = editor.selection.getAllRanges(),
rangePositions = ranges.map(function(r) { return {row: r.start.row, column: r.start.column}; }),
transientMarkModeActive = true,
hasNoSelection = ranges.every(function(range) { return range.isEmpty(); });
// if transientMarkModeActive then mark behavior is a little
// different. Deactivate the mark when setMark is run with active
// mark
if (transientMarkModeActive && (mark || !editor.selection.isEmpty())) {
editor.pushEmacsMark();
editor.clearSelection();
if (transientMarkModeActive && (mark || !hasNoSelection)) {
if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)});
else editor.clearSelection();
if (mark) editor.pushEmacsMark(null);
return;
}
if (mark) {
var cp = editor.getCursorPosition();
if (editor.selection.isEmpty() &&
mark.row == cp.row && mark.column == cp.column) {
editor.pushEmacsMark();
return;
}
if (!mark) {
rangePositions.forEach(function(pos) { editor.pushEmacsMark(pos); });
editor.setEmacsMark(rangePositions[rangePositions.length-1]);
return;
}
// turn on mark mode
mark = editor.getCursorPosition();
editor.setEmacsMark(mark);
editor.selection.setSelectionAnchor(mark.row, mark.column);
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function moveToMark() {
var mark = editor.popEmacsMark();
mark && editor.moveCursorToPosition(mark);
}
},
readonly: true,
handlesCount: true,
multiSelectAction: "forEach"
readOnly: true,
handlesCount: true
},
exchangePointAndMark: {
exec: function(editor, args) {
exec: function exchangePointAndMark$exec(editor, args) {
var sel = editor.selection;
if (args.count) {
var pos = editor.getCursorPosition();
if (!args.count && !sel.isEmpty()) { // just invert selection
sel.setSelectionRange(sel.getRange(), !sel.isBackwards());
return;
}
if (args.count) { // replace mark and point
var pos = {row: sel.lead.row, column: sel.lead.column};
sel.clearSelection();
sel.moveCursorToPosition(editor.popEmacsMark());
editor.pushEmacsMark(pos);
return;
sel.moveCursorToPosition(editor.emacsMarkForSelection(pos));
} else { // create selection to last mark
sel.selectToPosition(editor.emacsMarkForSelection());
}
var lastMark = editor.getLastEmacsMark();
var range = sel.getRange();
if (range.isEmpty()) {
sel.selectToPosition(lastMark);
return;
}
sel.setSelectionRange(range, !sel.isBackwards());
},
readonly: true,
readOnly: true,
handlesCount: true,
multiSelectAction: "forEach"
},
@ -539,6 +573,7 @@ exports.handler.addCommands({
if (editor.keyBinding.$data.lastCommand != "yank")
return;
editor.undo();
editor.session.$emacsMarkRing.pop(); // also undo recording mark
editor.onPaste(exports.killRing.rotate());
editor.keyBinding.$data.lastCommand = "yank";
},
@ -547,24 +582,38 @@ exports.handler.addCommands({
exports.killRing.add(editor.getCopyText());
editor.commands.byName.cut.exec(editor);
},
readonly: true,
readOnly: true,
multiSelectAction: "forEach"
},
killRingSave: {
exec: function(editor) {
// copy text and deselect. will save marks for starts of the
// selection(s)
editor.$handlesEmacsOnCopy = true;
var marks = editor.session.$emacsMarkRing.slice(),
deselectedMarks = [];
exports.killRing.add(editor.getCopyText());
setTimeout(function() {
var sel = editor.selection,
range = sel.getRange();
editor.pushEmacsMark(sel.isBackwards() ? range.end : range.start);
sel.clearSelection();
function deselect() {
var sel = editor.selection, range = sel.getRange(),
pos = sel.isBackwards() ? range.end : range.start;
deselectedMarks.push({row: pos.row, column: pos.column});
sel.clearSelection();
}
editor.$handlesEmacsOnCopy = false;
if (editor.inMultiSelectMode) editor.forEachSelection({exec: deselect});
else deselect();
editor.session.$emacsMarkRing = marks.concat(deselectedMarks.reverse());
}, 0);
},
readonly: true
readOnly: true
},
keyboardQuit: function(editor) {
editor.selection.clearSelection();
editor.setEmacsMark(null);
editor.keyBinding.$data.count = null;
},
focusCommandLine: function(editor, arg) {
if (editor.showCommandLine)

View file

@ -35,17 +35,29 @@ if (typeof process !== "undefined") {
define(function(require, exports, module) {
"use strict";
require("../multi_select");
var EditSession = require("./../edit_session").EditSession,
Editor = require("./../editor").Editor,
Range = require("./../range").Range,
MockRenderer = require("./../test/mockrenderer").MockRenderer,
emacs = require('./emacs'),
assert = require("./../test/assertions"),
editor;
editor, sel;
function initEditor(docString) {
var doc = new EditSession(docString.split("\n"));
editor = new Editor(new MockRenderer(), doc);
editor.setKeyboardHandler(emacs.handler);
sel = editor.selection;
}
function print(obj) {
return JSON.stringify(obj, null, 2);
}
function pluck(arr, what) {
return arr.map(function(ea) { return ea[what]; });
}
module.exports = {
@ -62,6 +74,72 @@ module.exports = {
editor.selectAll();
editor.execCommand('keyboardQuit');
assert.ok(editor.selection.isEmpty(), 'selection non-empty');
},
"test: exchangePointAndMark without mark set": function() {
initEditor('foo');
sel.setRange(Range.fromPoints({row: 0, column: 1}, {row: 0, column: 3}));
editor.execCommand('exchangePointAndMark');
assert.deepEqual({row: 0, column: 1}, editor.getCursorPosition(), print(editor.getCursorPosition()));
},
"test: exchangePointAndMark with mark set": function() {
initEditor('foo');
editor.pushEmacsMark({row: 0, column: 1});
editor.pushEmacsMark({row: 0, column: 2});
editor.execCommand('exchangePointAndMark', {count: 4});
assert.deepEqual({row: 0, column: 2}, editor.getCursorPosition(), print(editor.getCursorPosition()));
assert.deepEqual([{row: 0, column: 1}, {row: 0, column: 0}], editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing));
},
"test: exchangePointAndMark with selection": function() {
initEditor('foo');
editor.pushEmacsMark({row: 0, column: 1});
editor.pushEmacsMark({row: 0, column: 2});
sel.setRange(Range.fromPoints({row: 0, column: 0}, {row: 0, column: 1}), true);
editor.execCommand('exchangePointAndMark');
assert.deepEqual({row: 0, column: 1}, editor.getCursorPosition(), print(editor.getCursorPosition()));
assert.deepEqual([{row: 0, column: 1}, {row: 0, column: 2}], editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing));
},
"test: exchangePointAndMark with multi selection": function() {
initEditor('foo\nhello world\n123');
var ranges = [[{row: 0, column: 0}, {row: 0, column: 3}],
[{row: 1, column: 0}, {row: 1, column: 5}],
[{row: 1, column: 6}, {row: 1, column: 11}]]
ranges.forEach(function(r) {
sel.addRange(Range.fromPoints(r[0], r[1]));
});
assert.equal("foo\nhello\nworld", editor.getSelectedText());
editor.execCommand('exchangePointAndMark');
assert.equal("foo\nhello\nworld", editor.getSelectedText());
assert.deepEqual(pluck(ranges, 0), pluck(sel.getAllRanges(), 'cursor'), "selections dir not inverted");
},
"test: exchangePointAndMark with multi cursors": function() {
initEditor('foo\nhello world\n123');
var ranges = [[{row: 0, column: 0}, {row: 0, column: 3}],
[{row: 1, column: 0}, {row: 1, column: 5}],
[{row: 1, column: 6}, {row: 1, column: 11}]];
// move cursors to the start of each range and set a mark to its end
// without selecting anything
ranges.forEach(function(r) {
editor.pushEmacsMark(r[1]);
sel.addRange(Range.fromPoints(r[0], r[0]));
});
assert.deepEqual(pluck(ranges, 0), pluck(sel.getAllRanges(), 'cursor'), print(sel.getAllRanges()));
editor.execCommand('exchangePointAndMark');
assert.deepEqual(pluck(ranges, 1), pluck(sel.getAllRanges(), 'cursor'), "not inverted: " + print(sel.getAllRanges()));
},
"test: setMark with multi cursors": function() {
initEditor('foo\nhello world\n123');
var positions = [{row: 0, column: 0},
{row: 1, column: 0},
{row: 1, column: 6}];
positions.forEach(function(p) { sel.addRange(Range.fromPoints(p,p)); });
editor.execCommand('setMark');
assert.deepEqual(positions, editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing));
}
};

View file

@ -33,37 +33,25 @@ define(function(require, exports, module) {
var keyUtil = require("../lib/keys");
var useragent = require("../lib/useragent");
var KEY_MODS = keyUtil.KEY_MODS;
function HashHandler(config, platform) {
this.platform = platform || (useragent.isMac ? "mac" : "win");
this.commands = {};
this.commandKeyBinding = {};
// todo remove this after a while
if (this.__defineGetter__ && this.__defineSetter__ && typeof console != "undefined" && console.error) {
var warned = false;
var warn = function() {
if (!warned) {
warned = true;
console.error("commmandKeyBinding has too many m's. use commandKeyBinding");
}
};
this.__defineGetter__("commmandKeyBinding", function() {
warn();
return this.commandKeyBinding;
});
this.__defineSetter__("commmandKeyBinding", function(val) {
warn();
return this.commandKeyBinding = val;
});
} else {
this.commmandKeyBinding = this.commandKeyBinding;
}
this.addCommands(config);
};
this.$singleCommand = true;
}
function MultiHashHandler(config, platform) {
HashHandler.call(this, config, platform);
this.$singleCommand = false;
}
MultiHashHandler.prototype = HashHandler.prototype;
(function() {
this.addCommand = function(command) {
if (this.commands[command.name])
@ -75,37 +63,93 @@ function HashHandler(config, platform) {
this._buildKeyHash(command);
};
this.removeCommand = function(command) {
var name = (typeof command === 'string' ? command : command.name);
this.removeCommand = function(command, keepCommand) {
var name = command && (typeof command === 'string' ? command : command.name);
command = this.commands[name];
delete this.commands[name];
if (!keepCommand)
delete this.commands[name];
// exhaustive search is brute force but since removeCommand is
// not a performance critical operation this should be OK
var ckb = this.commandKeyBinding;
for (var hashId in ckb) {
for (var key in ckb[hashId]) {
if (ckb[hashId][key] == command)
delete ckb[hashId][key];
for (var keyId in ckb) {
var cmdGroup = ckb[keyId];
if (cmdGroup == command) {
delete ckb[keyId];
} else if (Array.isArray(cmdGroup)) {
var i = cmdGroup.indexOf(command);
if (i != -1) {
cmdGroup.splice(i, 1);
if (cmdGroup.length == 1)
ckb[keyId] = cmdGroup[0];
}
}
}
};
this.bindKey = function(key, command) {
if(!key)
return;
if (typeof command == "function") {
this.addCommand({exec: command, bindKey: key, name: command.name || key});
return;
this.bindKey = function(key, command, position) {
if (typeof key == "object") {
if (position == undefined)
position = key.position;
key = key[this.platform];
}
var ckb = this.commandKeyBinding;
if (!key)
return;
if (typeof command == "function")
return this.addCommand({exec: command, bindKey: key, name: command.name || key});
key.split("|").forEach(function(keyPart) {
var binding = this.parseKeys(keyPart, command);
var hashId = binding.hashId;
(ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command;
var chain = "";
if (keyPart.indexOf(" ") != -1) {
var parts = keyPart.split(/\s+/);
keyPart = parts.pop();
parts.forEach(function(keyPart) {
var binding = this.parseKeys(keyPart);
var id = KEY_MODS[binding.hashId] + binding.key;
chain += (chain ? " " : "") + id;
this._addCommandToBinding(chain, "chainKeys");
}, this);
chain += " ";
}
var binding = this.parseKeys(keyPart);
var id = KEY_MODS[binding.hashId] + binding.key;
this._addCommandToBinding(chain + id, command, position);
}, this);
};
function getPosition(command) {
return typeof command == "object" && command.bindKey
&& command.bindKey.position || 0;
}
this._addCommandToBinding = function(keyId, command, position) {
var ckb = this.commandKeyBinding, i;
if (!command) {
delete ckb[keyId];
} else if (!ckb[keyId] || this.$singleCommand) {
ckb[keyId] = command;
} else {
if (!Array.isArray(ckb[keyId])) {
ckb[keyId] = [ckb[keyId]];
} else if ((i = ckb[keyId].indexOf(command)) != -1) {
ckb[keyId].splice(i, 1);
}
if (typeof position != "number") {
if (position || command.isDefault)
position = -100;
else
position = getPosition(command);
}
var commands = ckb[keyId];
for (i = 0; i < commands.length; i++) {
var other = commands[i];
var otherPos = getPosition(other);
if (otherPos > position)
break;
}
commands.splice(i, 0, command);
}
};
this.addCommands = function(commands) {
commands && Object.keys(commands).forEach(function(name) {
@ -142,21 +186,12 @@ function HashHandler(config, platform) {
};
this._buildKeyHash = function(command) {
var binding = command.bindKey;
if (!binding)
return;
var key = typeof binding == "string" ? binding: binding[this.platform];
this.bindKey(key, command);
this.bindKey(command.bindKey, command);
};
// accepts keys in the form ctrl+Enter or ctrl-Enter
// keys without modifiers or shift only
this.parseKeys = function(keys) {
// todo support keychains
if (keys.indexOf(" ") != -1)
keys = keys.split(/\s+/).pop();
var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
var key = parts.pop();
@ -173,7 +208,7 @@ function HashHandler(config, platform) {
var modifier = keyUtil.KEY_MODS[parts[i]];
if (modifier == null) {
if (typeof console != "undefined")
console.error("invalid modifier " + parts[i] + " in " + keys);
console.error("invalid modifier " + parts[i] + " in " + keys);
return false;
}
hashId |= modifier;
@ -182,17 +217,40 @@ function HashHandler(config, platform) {
};
this.findKeyCommand = function findKeyCommand(hashId, keyString) {
var ckbr = this.commandKeyBinding;
return ckbr[hashId] && ckbr[hashId][keyString];
var key = KEY_MODS[hashId] + keyString;
return this.commandKeyBinding[key];
};
this.handleKeyboard = function(data, hashId, keyString, keyCode) {
return {
command: this.findKeyCommand(hashId, keyString)
};
var key = KEY_MODS[hashId] + keyString;
var command = this.commandKeyBinding[key];
if (data.$keyChain) {
data.$keyChain += " " + key;
command = this.commandKeyBinding[data.$keyChain] || command;
}
if (command) {
if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
data.$keyChain = data.$keyChain || key;
return {command: "null"};
}
}
if (data.$keyChain) {
if ((!hashId || hashId == 4) && keyString.length == 1)
data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
else if (hashId == -1 || keyCode > 0)
data.$keyChain = ""; // reset keyChain
}
return {command: command};
};
this.getStatusText = function(editor, data) {
return data.$keyChain || "";
};
}).call(HashHandler.prototype)
}).call(HashHandler.prototype);
exports.HashHandler = HashHandler;
exports.MultiHashHandler = MultiHashHandler;
});

View file

@ -89,8 +89,16 @@ var KeyBinding = function(editor) {
this.getKeyboardHandler = function() {
return this.$handlers[this.$handlers.length - 1];
};
this.getStatusText = function() {
var data = this.$data;
var editor = data.editor;
return this.$handlers.map(function(h) {
return h.getStatusText && h.getStatusText(editor, data) || "";
}).filter(Boolean).join(" ");
};
this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
var toExecute;
var success = false;
var commands = this.$editor.commands;

View file

@ -0,0 +1,82 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var HashHandler = require("./hash_handler").HashHandler;
exports.handler = new HashHandler();
[{
bindKey: "Shift-Tab|Tab",
command: "passKeysToBrowser"
}, {
bindKey: {win: "Ctrl-L", mac: "Cmd-L"},
command: "passKeysToBrowser"
}, {
bindKey: {win: "Ctrl-G", mac: "Cmd-G"},
command: "gotoline"
}, {
bindKey: {win: "Ctrl-T|Ctrl-Shift-T", mac: "Cmd-T|Cmd-Shift-T"},
command: "passKeysToBrowser"
}, {
bindKey: {win: "Ctrl-G", mac: "Cmd-G"},
command: "passKeysToBrowser"
}, {
bindKey: {win: "Ctrl-G", mac: "Cmd-G"},
command: "passKeysToBrowser"
}, {
name: "golineup",
bindKey: {win: null, mac: "Ctrl-P"},
}, {
name: "golinedown",
bindKey: {win: null, mac: "Ctrl-N"},
}, {
name: "gotoleft",
bindKey: {win: null, mac: "Ctrl-B"},
}, {
name: "gotoright",
bindKey: {win: null, mac: "Ctrl-F"},
}, {
name: "gotolineend",
bindKey: {win: null, mac: "Ctrl-E"},
}, {
name: "gotolinestart",
bindKey: {win: null, mac: "Ctrl-A"},
}
].forEach(function(k) {
var bindKey = k.bindKey;
if (typeof bindKey == "object")
bindKey = bindKey[exports.handler.platform];
exports.handler.bindKey(bindKey, k.command);
});
exports.handler.$id = "ace/keyboard/textarea";
});

View file

@ -45,12 +45,13 @@ var TextInput = function(parentNode, host) {
if (useragent.isTouchPad)
text.setAttribute("x-palm-disable-auto-cap", true);
text.wrap = "off";
text.autocorrect = "off";
text.autocapitalize = "off";
text.spellcheck = false;
text.setAttribute("wrap", "off");
text.setAttribute("autocorrect", "off");
text.setAttribute("autocapitalize", "off");
text.setAttribute("spellcheck", false);
text.style.opacity = "0";
if (useragent.isOldIE) text.style.top = "-1000px";
parentNode.insertBefore(text, parentNode.firstChild);
var PLACEHOLDER = "\x01\x01";
@ -65,16 +66,24 @@ var TextInput = function(parentNode, host) {
// ie9 throws error if document.activeElement is accessed too soon
try { var isFocused = document.activeElement === text; } catch(e) {}
event.addListener(text, "blur", function() {
host.onBlur();
event.addListener(text, "blur", function(e) {
host.onBlur(e);
isFocused = false;
});
event.addListener(text, "focus", function() {
event.addListener(text, "focus", function(e) {
isFocused = true;
host.onFocus();
host.onFocus(e);
resetSelection();
});
this.focus = function() { text.focus(); };
this.focus = function() {
if (tempStyle) return text.focus();
text.style.position = "fixed";
text.style.top = "-1000px";
text.focus();
setTimeout(function() {
text.style.position = "";
}, 0);
};
this.blur = function() { text.blur(); };
this.isFocused = function() {
return isFocused;
@ -94,6 +103,11 @@ var TextInput = function(parentNode, host) {
function resetSelection(isEmpty) {
if (inComposition)
return;
// this prevents infinite recursion on safari 8
// see https://github.com/ajaxorg/ace/issues/2114
inComposition = true;
if (inputHandler) {
selectionStart = 0;
selectionEnd = isEmpty ? 0 : text.value.length - 1;
@ -105,6 +119,8 @@ var TextInput = function(parentNode, host) {
try {
text.setSelectionRange(selectionStart, selectionEnd);
} catch(e){}
inComposition = false;
}
function resetValue() {
@ -255,7 +271,7 @@ var TextInput = function(parentNode, host) {
} else {
return clipboardData.getData(mime);
}
}
};
var doCopy = function(e, isCut) {
var data = host.getCopyText();
@ -280,17 +296,17 @@ var TextInput = function(parentNode, host) {
var onCut = function(e) {
doCopy(e, true);
}
};
var onCopy = function(e) {
doCopy(e, false);
}
};
var onPaste = function(e) {
var data = handleClipboardData(e);
if (typeof data == "string") {
if (data)
host.onPaste(data);
host.onPaste(data, e);
if (useragent.isIE)
setTimeout(resetSelection);
event.preventDefault(e);
@ -335,7 +351,8 @@ var TextInput = function(parentNode, host) {
// COMPOSITION
var onCompositionStart = function(e) {
if (inComposition || !host.onCompositionStart) return;
if (inComposition || !host.onCompositionStart || host.$readOnly)
return;
// console.log("onCompositionStart", inComposition)
inComposition = {};
host.onCompositionStart();
@ -351,7 +368,8 @@ var TextInput = function(parentNode, host) {
var onCompositionUpdate = function() {
// console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
if (!inComposition || !host.onCompositionUpdate) return;
if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
return;
var val = text.value.replace(/\x01/g, "");
if (inComposition.lastValue === val) return;
@ -370,7 +388,7 @@ var TextInput = function(parentNode, host) {
};
var onCompositionEnd = function(e) {
if (!host.onCompositionEnd) return;
if (!host.onCompositionEnd || host.$readOnly) return;
// console.log("onCompositionEnd", inComposition &&inComposition.lastValue)
var c = inComposition;
inComposition = false;
@ -379,7 +397,7 @@ var TextInput = function(parentNode, host) {
var str = text.value.replace(/\x01/g, "");
// console.log(str, c.lastValue)
if (inComposition)
return
return;
else if (str == c.lastValue)
resetValue();
else if (!c.lastValue && str) {
@ -428,18 +446,25 @@ var TextInput = function(parentNode, host) {
this.onContextMenu = function(e) {
afterContextMenu = true;
if (!tempStyle)
tempStyle = text.style.cssText;
text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : "");
resetSelection(host.selection.isEmpty());
host._emit("nativecontextmenu", {target: host, domEvent: e});
this.moveToMouse(e, true);
};
this.moveToMouse = function(e, bringToFront) {
if (!bringToFront && useragent.isOldIE)
return;
if (!tempStyle)
tempStyle = text.style.cssText;
text.style.cssText = (bringToFront ? "z-index:100000;" : "")
+ "height:" + text.style.height + ";"
+ (useragent.isIE ? "opacity:0.1;" : "");
var rect = host.container.getBoundingClientRect();
var style = dom.computedStyle(host.container);
var top = rect.top + (parseInt(style.borderTopWidth) || 0);
var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
var maxTop = rect.bottom - top - text.clientHeight;
var maxTop = rect.bottom - top - text.clientHeight -2;
var move = function(e) {
text.style.left = e.clientX - left - 2 + "px";
text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
@ -453,13 +478,15 @@ var TextInput = function(parentNode, host) {
host.renderer.$keepTextAreaAtCursor = null;
// on windows context menu is opened after mouseup
if (useragent.isWin)
if (useragent.isWin && !useragent.isOldIE)
event.capture(host.container, move, onContextMenuClose);
};
this.onContextMenuClose = onContextMenuClose;
var closeTimeout;
function onContextMenuClose() {
setTimeout(function () {
clearTimeout(closeTimeout)
closeTimeout = setTimeout(function () {
if (tempStyle) {
text.style.cssText = tempStyle;
tempStyle = '';
@ -468,18 +495,15 @@ var TextInput = function(parentNode, host) {
host.renderer.$keepTextAreaAtCursor = true;
host.renderer.$moveTextAreaToCursor();
}
}, 0);
}, useragent.isOldIE ? 200 : 0);
}
// firefox fires contextmenu event after opening it
if (!useragent.isGecko || useragent.isMac) {
var onContextMenu = function(e) {
host.textInput.onContextMenu(e);
onContextMenuClose();
};
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
event.addListener(text, "contextmenu", onContextMenu);
}
var onContextMenu = function(e) {
host.textInput.onContextMenu(e);
onContextMenuClose();
};
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
event.addListener(text, "contextmenu", onContextMenu);
};
exports.TextInput = TextInput;

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