From 11dad6288db0f067bd445811cece976983ae8d7a Mon Sep 17 00:00:00 2001 From: alvesisaque Date: Tue, 19 Sep 2017 20:24:23 -0300 Subject: [PATCH 01/44] Create question code page Signed-off-by: alvesisaque Signed-off-by: egewarth --- src/Codeschool/Model.elm | 1 + src/Codeschool/Routing.elm | 4 ++++ src/Codeschool/View.elm | 4 ++++ src/Page/Questions/Code.elm | 28 ++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 src/Page/Questions/Code.elm diff --git a/src/Codeschool/Model.elm b/src/Codeschool/Model.elm index 5f18556..61bae67 100644 --- a/src/Codeschool/Model.elm +++ b/src/Codeschool/Model.elm @@ -82,6 +82,7 @@ type Route | Learn | Help | QuestionList + | QuestionCode Id | Question Id | Social | Profile diff --git a/src/Codeschool/Routing.elm b/src/Codeschool/Routing.elm index aee1820..750c49c 100644 --- a/src/Codeschool/Routing.elm +++ b/src/Codeschool/Routing.elm @@ -18,6 +18,7 @@ matchers = , map Help (s "help") , map Question (s "questions" int) , map QuestionList (s "questions") + , map QuestionCode (s "code" int) , map Social (s "social") , map Profile (s "profile") , map Logout (s "logout") @@ -74,6 +75,9 @@ baseReverse route = QuestionList -> "questions/" + QuestionCode id -> + "code/" ++ toString id + Social -> "social" diff --git a/src/Codeschool/View.elm b/src/Codeschool/View.elm index 0c2b86e..70d28ea 100644 --- a/src/Codeschool/View.elm +++ b/src/Codeschool/View.elm @@ -13,6 +13,7 @@ import Page.NotFound import Page.Profile import Page.Progress import Page.Questions.Base +import Page.Questions.Code import Page.ScoreBoard import Page.Social import Page.Submission @@ -52,6 +53,9 @@ getRouteView model = QuestionList -> Page.Questions.Base.viewList Page.Questions.Base.clsList + QuestionCode id -> + Page.Questions.Code.view model + Question id -> Page.Questions.Base.viewDetail model diff --git a/src/Page/Questions/Code.elm b/src/Page/Questions/Code.elm new file mode 100644 index 0000000..8ebf2c6 --- /dev/null +++ b/src/Page/Questions/Code.elm @@ -0,0 +1,28 @@ +module Page.Questions.Code exposing (view) + +-- import Codeschool.Msg exposing (..) +-- import Data.User exposing (User) + +import Codeschool.Model exposing (Model) +import Html exposing (..) +import Html.Attributes exposing (..) +import Ui.Generic exposing (container, icon) +import Ui.Parts exposing (promoSimple, promoTable, simpleHero) + + +-- import Html.Attributes exposing (..) +-- import Html.Events exposing (..) + + + +view : Model -> Html msg +view m = + div [ class "question-info-card" ] + [ Ui.Generic.icon [ class "question-info-card__icon" ] "code" + , h1 [ class "question-info-card__title" ] + [ text "Questão mega hard" + ] + , p [ class "question-info-card__description" ] + [ text "Essa questão foi desenvolvida para ferrar a vida de vocês" + ] + ] From d829d4e5d5d422656fd57cdcfbaef01ba37ebeab Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Thu, 21 Sep 2017 16:26:29 -0300 Subject: [PATCH 02/44] Fixing questions page --- src/Page/Questions/Base.elm | 41 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/Page/Questions/Base.elm b/src/Page/Questions/Base.elm index f6a03ec..2f4d2ec 100644 --- a/src/Page/Questions/Base.elm +++ b/src/Page/Questions/Base.elm @@ -69,36 +69,47 @@ questionInfo cls = questionOne : QuestionInfo questionOne = - { questionName = "VEMMM MALUCOOOOO" - , shortDescription = "DESCREVE INSANOOOOOOOOOOOOOO." - , icon = "code" + { questionName = "Basic" + , shortDescription = "Elementary programming problems." + , icon = "sentiment_very_satisfied" } questionTwo : QuestionInfo questionTwo = - { questionName = "nome da questão pois é" - , shortDescription = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris varius tellus velit, ut accumsan odio tincidunt in." - , icon = "sentiment_very_satisfied" + { questionName = "Conditionals" + , shortDescription = "Conditional flow control (if/else)." + , icon = "code" } - questionThree : QuestionInfo questionThree = - { questionName = "Sequência de Fibonacci" - , shortDescription = "Questão para testar seus conhecimentos sobre como funciona o algoritmo de fibonacci" - , icon = "all_out" + { questionName = "Loops" + , shortDescription = "Iterations with for/while commands" + , icon = "loop" } - questionFour : QuestionInfo questionFour = - { questionName = "Sequência de Fibonacci" - , shortDescription = "Questão para testar seus conhecimentos sobre como funciona o algoritmo de fibonacci" - , icon = "all_out" + { questionName = "Functions" + , shortDescription = "Organize code using functions." + , icon = "functions" + } + +questionFive : QuestionInfo +questionFive = + { questionName = "Files" + , shortDescription = "Open, process and write files." + , icon = "insert_drive_file" } +questionSix : QuestionInfo +questionSix = + { questionName = "Lists" + , shortDescription = "Linear data structures." + , icon = "list" + } clsList : List QuestionInfo clsList = - [ questionOne, questionTwo, questionThree, questionFour ] + [ questionOne, questionTwo, questionThree, questionFour, questionFive, questionSix ] From 7f1ae37e533392ea97005bcf1b05292f4b159c4e Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Thu, 21 Sep 2017 16:49:05 -0300 Subject: [PATCH 03/44] Questions type of urls changed --- src/Codeschool/Model.elm | 2 +- src/Codeschool/Routing.elm | 10 +++++----- src/Codeschool/View.elm | 2 +- src/Page/Questions/Base.elm | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Codeschool/Model.elm b/src/Codeschool/Model.elm index 61bae67..ffca775 100644 --- a/src/Codeschool/Model.elm +++ b/src/Codeschool/Model.elm @@ -83,7 +83,7 @@ type Route | Help | QuestionList | QuestionCode Id - | Question Id + | QuestionType Id | Social | Profile | Logout diff --git a/src/Codeschool/Routing.elm b/src/Codeschool/Routing.elm index 750c49c..5b5642f 100644 --- a/src/Codeschool/Routing.elm +++ b/src/Codeschool/Routing.elm @@ -16,8 +16,8 @@ matchers = , map Progress (s "progress") , map Learn (s "learn") , map Help (s "help") - , map Question (s "questions" int) - , map QuestionList (s "questions") + , map QuestionType (s "questionsType" int) + , map QuestionList (s "questionsType") , map QuestionCode (s "code" int) , map Social (s "social") , map Profile (s "profile") @@ -69,11 +69,11 @@ baseReverse route = Help -> "help/" - Question id -> - "questions/" ++ toString id + QuestionType id -> + "questionsType/" ++ toString id QuestionList -> - "questions/" + "questionsType/" QuestionCode id -> "code/" ++ toString id diff --git a/src/Codeschool/View.elm b/src/Codeschool/View.elm index 70d28ea..dc2df82 100644 --- a/src/Codeschool/View.elm +++ b/src/Codeschool/View.elm @@ -56,7 +56,7 @@ getRouteView model = QuestionCode id -> Page.Questions.Code.view model - Question id -> + QuestionType id -> Page.Questions.Base.viewDetail model ScoreBoard -> diff --git a/src/Page/Questions/Base.elm b/src/Page/Questions/Base.elm index 2f4d2ec..49ec133 100644 --- a/src/Page/Questions/Base.elm +++ b/src/Page/Questions/Base.elm @@ -49,7 +49,7 @@ viewList m = fab_ :: listing in div [] - [ simpleHero "List of Questions" "See all questions available for you" "simple-hero__page-blue" + [ simpleHero "Type of Questions" "See all questions available for you" "simple-hero__page-blue" , div [] children ] From f65c7767eafb4c61861e2bd17937c961553c936e Mon Sep 17 00:00:00 2001 From: alvesisaque Date: Thu, 21 Sep 2017 18:44:16 -0300 Subject: [PATCH 04/44] Editing question page --- src/Page/Questions/Code.elm | 25 ++++++++++------ src/scss/6_components/pages/_question.scss | 33 +++++++++++++++++++--- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/Page/Questions/Code.elm b/src/Page/Questions/Code.elm index 8ebf2c6..169a445 100644 --- a/src/Page/Questions/Code.elm +++ b/src/Page/Questions/Code.elm @@ -17,12 +17,19 @@ import Ui.Parts exposing (promoSimple, promoTable, simpleHero) view : Model -> Html msg view m = - div [ class "question-info-card" ] - [ Ui.Generic.icon [ class "question-info-card__icon" ] "code" - , h1 [ class "question-info-card__title" ] - [ text "Questão mega hard" - ] - , p [ class "question-info-card__description" ] - [ text "Essa questão foi desenvolvida para ferrar a vida de vocês" - ] - ] + div [] + [ simpleHero "Idade" "" "simple-hero__page-blue" + , div [ class "main-container" ] + [ text + """ + Codifique um software receba o ano de nascimento de uma pessoa e o ano atual. Calcule e mostre: + a) A idade dessa pessoa. + b) Quantos anos essa pessoa terá em 2018. + """ + ] + , div [ class "item-question" ] + [ textarea [ class "item-question", maxlength 1000, placeholder "Insert your code" ] [] + ] + , button [ class "cancel-button" ] [ text "Cancel" ] + , button [ class "send-button" ] [ text "Send to evaluation" ] + ] diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 342dba4..333f341 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -15,10 +15,6 @@ width: 30%; padding: 20px; -// > * { - -// } - &__title { position: relative; align-self: center; @@ -61,3 +57,32 @@ } } + +.item-question { + width: 1000px; + height: 300px; + margin: 10px; + align: center; +} + +.cancel-button { + width: 10px; + height: 40px; + margin: 10px; + background-color: $color-teal; + color: white; + border-radius: 5px; + width: 45%; + margin-left: 3%; +} + +.send-button { + width: 10px; + height: 40px; + margin: 10px; + background-color: $color-teal; + color: white; + border-radius: 5px; + width: 45%; + margin-right: 3%; +} From 405b5d9a2c8e3f823a59b26736ae79e9e777a48a Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Tue, 26 Sep 2017 16:39:07 -0300 Subject: [PATCH 05/44] Adding Slug to questionsCode --- src/Codeschool/Model.elm | 2 +- src/Codeschool/Routing.elm | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Codeschool/Model.elm b/src/Codeschool/Model.elm index ffca775..4035a4b 100644 --- a/src/Codeschool/Model.elm +++ b/src/Codeschool/Model.elm @@ -82,7 +82,7 @@ type Route | Learn | Help | QuestionList - | QuestionCode Id + | QuestionCode Slug | QuestionType Id | Social | Profile diff --git a/src/Codeschool/Routing.elm b/src/Codeschool/Routing.elm index 5b5642f..9ae6429 100644 --- a/src/Codeschool/Routing.elm +++ b/src/Codeschool/Routing.elm @@ -18,7 +18,7 @@ matchers = , map Help (s "help") , map QuestionType (s "questionsType" int) , map QuestionList (s "questionsType") - , map QuestionCode (s "code" int) + , map QuestionCode (s "code" string) , map Social (s "social") , map Profile (s "profile") , map Logout (s "logout") @@ -75,8 +75,8 @@ baseReverse route = QuestionList -> "questionsType/" - QuestionCode id -> - "code/" ++ toString id + QuestionCode st -> + "code/" ++ st Social -> "social" From c5117045ac0c992d1806b4098e091f9725cc21b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bedran?= Date: Tue, 26 Sep 2017 16:43:47 -0300 Subject: [PATCH 06/44] Update gitignore. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Bedran --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 887c521..964ab86 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ bower_components dist elm-stuff public/bower_components -src/scss/.sass-cache/ \ No newline at end of file +src/scss/.sass-cache/ +**.DS_STORE From 24ae5bbbf5c2d70eba108b65bb4474e2d7047dfd Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Tue, 26 Sep 2017 18:08:40 -0300 Subject: [PATCH 07/44] Changing question code screen. - Creating classes in css - Deleting cancel button --- src/Page/Questions/Code.elm | 17 ++++++-- src/scss/6_components/pages/_question.scss | 48 ++++++++++++---------- 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/Page/Questions/Code.elm b/src/Page/Questions/Code.elm index 169a445..9e0ce11 100644 --- a/src/Page/Questions/Code.elm +++ b/src/Page/Questions/Code.elm @@ -18,18 +18,27 @@ import Ui.Parts exposing (promoSimple, promoTable, simpleHero) view : Model -> Html msg view m = div [] - [ simpleHero "Idade" "" "simple-hero__page-blue" - , div [ class "main-container" ] + [ simpleHero "Titulo da questão" "" "simple-hero__page-blue" + , div [ class "question-description" ] [ text """ Codifique um software receba o ano de nascimento de uma pessoa e o ano atual. Calcule e mostre: a) A idade dessa pessoa. - b) Quantos anos essa pessoa terá em 2018. + b) Quantos anos essa pessoa terá em 2018.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaa """ ] + , select [ class "select-language" ] + [ option [ value "", disabled True, selected True, class "disabled-item" ] [ text "Select language" ] + , option [ value "C" ] [ text "C" ] + , option [ value "Python" ] [ text "Python" ] + , option [ value "Java" ] [ text "Java" ] + , option [ value "Java" ] [ text "Java" ] + , option [ value "Java" ] [ text "Java" ] + ] , div [ class "item-question" ] [ textarea [ class "item-question", maxlength 1000, placeholder "Insert your code" ] [] ] - , button [ class "cancel-button" ] [ text "Cancel" ] , button [ class "send-button" ] [ text "Send to evaluation" ] ] diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 333f341..7b6672c 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -57,32 +57,38 @@ } } - -.item-question { - width: 1000px; - height: 300px; - margin: 10px; - align: center; +.question-description { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + width: 75%; + margin: 0px auto; + margin-top: 25px; } - -.cancel-button { - width: 10px; - height: 40px; - margin: 10px; - background-color: $color-teal; - color: white; - border-radius: 5px; - width: 45%; - margin-left: 3%; +.select-language { + width: 300px; + margin-top: 50px; + margin-bottom: 10px; + margin-left: 10%; +} +.item-question { + width: 90%; + height: 30vw; + margin: 0 auto; + margin-right: 5%; + margin-left: 5%; } .send-button { width: 10px; - height: 40px; - margin: 10px; - background-color: $color-teal; + height: 50px; + margin: 15px auto; + background-color: $color-green; color: white; border-radius: 5px; - width: 45%; - margin-right: 3%; + width: 20%; + margin-right: 5%; + margin-left: 70%; + } From c74aae3352696d74b6ebfb0a06b328a9ac16eb47 Mon Sep 17 00:00:00 2001 From: egewarth Date: Tue, 26 Sep 2017 18:16:06 -0300 Subject: [PATCH 08/44] Creating the questions list page --- src/Codeschool/Routing.elm | 6 +- src/Codeschool/View.elm | 3 +- src/Page/Questions/BasicQuestion.elm | 86 ++++++++++++++++++++++ src/scss/6_components/pages/_question.scss | 10 +++ 4 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 src/Page/Questions/BasicQuestion.elm diff --git a/src/Codeschool/Routing.elm b/src/Codeschool/Routing.elm index 9ae6429..80a535a 100644 --- a/src/Codeschool/Routing.elm +++ b/src/Codeschool/Routing.elm @@ -16,8 +16,8 @@ matchers = , map Progress (s "progress") , map Learn (s "learn") , map Help (s "help") - , map QuestionType (s "questionsType" int) - , map QuestionList (s "questionsType") + , map QuestionType (s "questionsType" int) + , map QuestionList (s "questionsList") , map QuestionCode (s "code" string) , map Social (s "social") , map Profile (s "profile") @@ -73,7 +73,7 @@ baseReverse route = "questionsType/" ++ toString id QuestionList -> - "questionsType/" + "questionsList/" QuestionCode st -> "code/" ++ st diff --git a/src/Codeschool/View.elm b/src/Codeschool/View.elm index dc2df82..2477937 100644 --- a/src/Codeschool/View.elm +++ b/src/Codeschool/View.elm @@ -13,6 +13,7 @@ import Page.NotFound import Page.Profile import Page.Progress import Page.Questions.Base +import Page.Questions.BasicQuestion import Page.Questions.Code import Page.ScoreBoard import Page.Social @@ -51,7 +52,7 @@ getRouteView model = Page.Progress.view model QuestionList -> - Page.Questions.Base.viewList Page.Questions.Base.clsList + Page.Questions.BasicQuestion.viewList Page.Questions.BasicQuestion.clsList QuestionCode id -> Page.Questions.Code.view model diff --git a/src/Page/Questions/BasicQuestion.elm b/src/Page/Questions/BasicQuestion.elm new file mode 100644 index 0000000..d5be78e --- /dev/null +++ b/src/Page/Questions/BasicQuestion.elm @@ -0,0 +1,86 @@ +module Page.Questions.BasicQuestion exposing (clsList, viewList) + +import Codeschool.Model exposing (Model) +import Data.Question exposing (..) +import Html exposing (..) +import Html.Attributes exposing (..) +import Ui.Generic exposing (container, date, emoticon) +import Ui.Parts exposing (promoSimple, promoTable, simpleHero) + +questions_type = "Basic questions" +questions_type_description = "Easy Easy Maaann, mostly basic questions" + +viewList : List QuestionInfo -> Html msg +viewList m = + let + -- testing if there are no questions + -- m = [] + empty = + [ emoticon ":-(" + , p [ class "center-text" ] + [ text "Sorry, there are no questions for you." + , br [] [] + , text "Please wait for more questions or send a message to you teacher to check if everything is ok." + ] + ] + + listing = + [ div [ class "question-info-list" ] (List.map questionInfo m) + ] + + fab_ = + div [] [] + + children = + case m of + [] -> + fab_ :: empty + + _ -> + fab_ :: listing + in + div [] + [ simpleHero questions_type questions_type_description "simple-hero__page-blue" + , div [] children + ] + + +questionInfo : QuestionInfo -> Html msg +questionInfo cls = + div [ class "question-card" ] + [ Ui.Generic.icon [ class "question-info-card__icon" ] cls.icon + , h1 [ class "question-card__title" ] + [ text cls.questionName + ] + , p [ class "question-card__description" ] + [ text cls.shortDescription + ] + ] + + +questionOne : QuestionInfo +questionOne = + { questionName = "Questão mais facil" + , shortDescription = "Questão mais facil, se n conseguir fazer vaza." + , icon = "sentiment_very_satisfied" + } + + +questionTwo : QuestionInfo +questionTwo = + { questionName = "Segunda mais facil" + , shortDescription = "Questão facil também." + , icon = "code" + } + +questionThree : QuestionInfo +questionThree = + { questionName = "Questão dificil" + , shortDescription = "Essa é hard" + , icon = "loop" + } + + +clsList : List QuestionInfo +clsList = + [ questionOne, questionTwo, questionThree ] diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 7b6672c..0468158 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -40,6 +40,11 @@ } } +.question-card { + @extend .question-info-card; + width: 100%; +} + .question-info-list { display: flex; flex-wrap: wrap; @@ -56,6 +61,11 @@ min-width: 15em; } + .question-card { + flex: 1; + min-width: 15em; + } + } .question-description { display: flex; From d560d939760e6ca385d3941506ac0c5147de8465 Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Tue, 3 Oct 2017 15:34:50 -0300 Subject: [PATCH 09/44] Fixing Questions type urls --- src/Codeschool/Model.elm | 2 +- src/Codeschool/Routing.elm | 6 +++--- src/Codeschool/View.elm | 4 ++-- src/Page/Actions.elm | 2 +- src/Ui/Header.elm | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Codeschool/Model.elm b/src/Codeschool/Model.elm index 4035a4b..38d7b99 100644 --- a/src/Codeschool/Model.elm +++ b/src/Codeschool/Model.elm @@ -83,7 +83,7 @@ type Route | Help | QuestionList | QuestionCode Slug - | QuestionType Id + | QuestionType | Social | Profile | Logout diff --git a/src/Codeschool/Routing.elm b/src/Codeschool/Routing.elm index 80a535a..e6a4e64 100644 --- a/src/Codeschool/Routing.elm +++ b/src/Codeschool/Routing.elm @@ -16,7 +16,7 @@ matchers = , map Progress (s "progress") , map Learn (s "learn") , map Help (s "help") - , map QuestionType (s "questionsType" int) + , map QuestionType (s "questionsType") , map QuestionList (s "questionsList") , map QuestionCode (s "code" string) , map Social (s "social") @@ -69,8 +69,8 @@ baseReverse route = Help -> "help/" - QuestionType id -> - "questionsType/" ++ toString id + QuestionType -> + "questionsType/" QuestionList -> "questionsList/" diff --git a/src/Codeschool/View.elm b/src/Codeschool/View.elm index 2477937..6182dcc 100644 --- a/src/Codeschool/View.elm +++ b/src/Codeschool/View.elm @@ -57,8 +57,8 @@ getRouteView model = QuestionCode id -> Page.Questions.Code.view model - QuestionType id -> - Page.Questions.Base.viewDetail model + QuestionType -> + Page.Questions.Base.viewList Page.Questions.Base.clsList ScoreBoard -> Page.ScoreBoard.view model diff --git a/src/Page/Actions.elm b/src/Page/Actions.elm index 9025754..cbb3e0b 100644 --- a/src/Page/Actions.elm +++ b/src/Page/Actions.elm @@ -22,7 +22,7 @@ view model = div [ attribute "slot" "dropdown-content", class "page-header__user-menu-content" ] [ h1 [class "mobile-button__fonts-title"] [ text "Actions" ] , span [ onClick (ChangeRoute (ClassroomList)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Classrooms"] ] - , span [ onClick (ChangeRoute (QuestionList)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Questions"] ] + , span [ onClick (ChangeRoute (QuestionType)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Questions"] ] , span [ onClick (ChangeRoute (Social)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Social"] ] , span [ onClick (ChangeRoute (Profile)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Profile"] ] , checkLogin model diff --git a/src/Ui/Header.elm b/src/Ui/Header.elm index 2d1bc84..13627b7 100644 --- a/src/Ui/Header.elm +++ b/src/Ui/Header.elm @@ -95,7 +95,7 @@ header model = [] ] , link ClassroomList "Classrooms" - , link QuestionList "Questions" + , link QuestionType "Questions" , link Social "Social" , div [class "page-header__special-buttons"] [ From 9ecaf049a2bd45d5a20115999728bf7cb40e02d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Henrique=20Egewarth?= Date: Tue, 3 Oct 2017 16:16:50 -0300 Subject: [PATCH 10/44] Implementing slug urls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Henrique Egewarth Signed-off-by: Gustavo Moreira Signed-off-by: isaque alves de lima --- src/Codeschool/Model.elm | 6 +++--- src/Codeschool/Routing.elm | 18 +++++++++--------- src/Codeschool/View.elm | 6 +++--- src/Page/Actions.elm | 2 +- src/Ui/Header.elm | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Codeschool/Model.elm b/src/Codeschool/Model.elm index 38d7b99..d212cd9 100644 --- a/src/Codeschool/Model.elm +++ b/src/Codeschool/Model.elm @@ -81,9 +81,9 @@ type Route | Progress | Learn | Help - | QuestionList - | QuestionCode Slug - | QuestionType + | QuestionRoot + | QuestionList Slug + | Question Slug Slug | Social | Profile | Logout diff --git a/src/Codeschool/Routing.elm b/src/Codeschool/Routing.elm index e6a4e64..d59a722 100644 --- a/src/Codeschool/Routing.elm +++ b/src/Codeschool/Routing.elm @@ -16,9 +16,9 @@ matchers = , map Progress (s "progress") , map Learn (s "learn") , map Help (s "help") - , map QuestionType (s "questionsType") - , map QuestionList (s "questionsList") - , map QuestionCode (s "code" string) + , map QuestionRoot (s "questions") + , map QuestionList (s "questions" string) + , map Question (s "questions" string string) , map Social (s "social") , map Profile (s "profile") , map Logout (s "logout") @@ -69,14 +69,14 @@ baseReverse route = Help -> "help/" - QuestionType -> - "questionsType/" + QuestionRoot -> + "questions/" - QuestionList -> - "questionsList/" + QuestionList st -> + "questions/" ++ st - QuestionCode st -> - "code/" ++ st + Question a b -> + "code/" ++ a ++ "/" ++ b Social -> "social" diff --git a/src/Codeschool/View.elm b/src/Codeschool/View.elm index 6182dcc..275516f 100644 --- a/src/Codeschool/View.elm +++ b/src/Codeschool/View.elm @@ -51,13 +51,13 @@ getRouteView model = Progress -> Page.Progress.view model - QuestionList -> + QuestionList string -> Page.Questions.BasicQuestion.viewList Page.Questions.BasicQuestion.clsList - QuestionCode id -> + Question string slug -> Page.Questions.Code.view model - QuestionType -> + QuestionRoot -> Page.Questions.Base.viewList Page.Questions.Base.clsList ScoreBoard -> diff --git a/src/Page/Actions.elm b/src/Page/Actions.elm index cbb3e0b..eae0071 100644 --- a/src/Page/Actions.elm +++ b/src/Page/Actions.elm @@ -22,7 +22,7 @@ view model = div [ attribute "slot" "dropdown-content", class "page-header__user-menu-content" ] [ h1 [class "mobile-button__fonts-title"] [ text "Actions" ] , span [ onClick (ChangeRoute (ClassroomList)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Classrooms"] ] - , span [ onClick (ChangeRoute (QuestionType)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Questions"] ] + , span [ onClick (ChangeRoute (QuestionRoot)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Questions"] ] , span [ onClick (ChangeRoute (Social)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Social"] ] , span [ onClick (ChangeRoute (Profile)), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Profile"] ] , checkLogin model diff --git a/src/Ui/Header.elm b/src/Ui/Header.elm index 13627b7..512203b 100644 --- a/src/Ui/Header.elm +++ b/src/Ui/Header.elm @@ -95,7 +95,7 @@ header model = [] ] , link ClassroomList "Classrooms" - , link QuestionType "Questions" + , link QuestionRoot "Questions" , link Social "Social" , div [class "page-header__special-buttons"] [ From 31706ca5f8fe996045451d2344d8535710cab0d2 Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Tue, 3 Oct 2017 16:28:12 -0300 Subject: [PATCH 11/44] Modifing name of questions classes --- src/Codeschool/View.elm | 8 ++++---- .../Questions/{BasicQuestion.elm => QuestionList.elm} | 2 +- src/Page/Questions/{Base.elm => QuestionRoot.elm} | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/Page/Questions/{BasicQuestion.elm => QuestionList.elm} (97%) rename src/Page/Questions/{Base.elm => QuestionRoot.elm} (97%) diff --git a/src/Codeschool/View.elm b/src/Codeschool/View.elm index 6182dcc..6aca065 100644 --- a/src/Codeschool/View.elm +++ b/src/Codeschool/View.elm @@ -12,8 +12,8 @@ import Page.Learn import Page.NotFound import Page.Profile import Page.Progress -import Page.Questions.Base -import Page.Questions.BasicQuestion +import Page.Questions.QuestionRoot +import Page.Questions.QuestionList import Page.Questions.Code import Page.ScoreBoard import Page.Social @@ -52,13 +52,13 @@ getRouteView model = Page.Progress.view model QuestionList -> - Page.Questions.BasicQuestion.viewList Page.Questions.BasicQuestion.clsList + Page.Questions.QuestionList.viewList Page.Questions.QuestionList.clsList QuestionCode id -> Page.Questions.Code.view model QuestionType -> - Page.Questions.Base.viewList Page.Questions.Base.clsList + Page.Questions.QuestionRoot.viewList Page.Questions.QuestionRoot.clsList ScoreBoard -> Page.ScoreBoard.view model diff --git a/src/Page/Questions/BasicQuestion.elm b/src/Page/Questions/QuestionList.elm similarity index 97% rename from src/Page/Questions/BasicQuestion.elm rename to src/Page/Questions/QuestionList.elm index d5be78e..d539c8a 100644 --- a/src/Page/Questions/BasicQuestion.elm +++ b/src/Page/Questions/QuestionList.elm @@ -1,4 +1,4 @@ -module Page.Questions.BasicQuestion exposing (clsList, viewList) +module Page.Questions.QuestionList exposing (clsList, viewList) import Codeschool.Model exposing (Model) import Data.Question exposing (..) diff --git a/src/Page/Questions/Base.elm b/src/Page/Questions/QuestionRoot.elm similarity index 97% rename from src/Page/Questions/Base.elm rename to src/Page/Questions/QuestionRoot.elm index 49ec133..327b0a4 100644 --- a/src/Page/Questions/Base.elm +++ b/src/Page/Questions/QuestionRoot.elm @@ -1,4 +1,4 @@ -module Page.Questions.Base exposing (clsList, viewDetail, viewList) +module Page.Questions.QuestionRoot exposing (clsList, viewDetail, viewList) -- import Codeschool.Msg exposing (..) -- import Data.User exposing (User) From e92ee6d28b87ac5bffde7af13f47d38cc67a8b39 Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Tue, 3 Oct 2017 16:38:54 -0300 Subject: [PATCH 12/44] Fixing errors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Henrique Egewarth Signed-off-by: Gustavo Moreira Signed-off-by: isaque alves de lima --- src/Codeschool/View.elm | 4 ++-- src/Page/Questions/QuestionList.elm | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Codeschool/View.elm b/src/Codeschool/View.elm index 8e6f48a..ca4552a 100644 --- a/src/Codeschool/View.elm +++ b/src/Codeschool/View.elm @@ -51,13 +51,13 @@ getRouteView model = Progress -> Page.Progress.view model - QuestionList -> + QuestionList string -> Page.Questions.QuestionList.viewList Page.Questions.QuestionList.clsList Question string slug -> Page.Questions.Code.view model - QuestionType -> + QuestionRoot -> Page.Questions.QuestionRoot.viewList Page.Questions.QuestionRoot.clsList ScoreBoard -> diff --git a/src/Page/Questions/QuestionList.elm b/src/Page/Questions/QuestionList.elm index d539c8a..7fcfa3e 100644 --- a/src/Page/Questions/QuestionList.elm +++ b/src/Page/Questions/QuestionList.elm @@ -1,6 +1,5 @@ module Page.Questions.QuestionList exposing (clsList, viewList) -import Codeschool.Model exposing (Model) import Data.Question exposing (..) import Html exposing (..) import Html.Attributes exposing (..) From 8be7f9605c16e7300467be6dd7d0c05a538a51f1 Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Tue, 3 Oct 2017 17:17:27 -0300 Subject: [PATCH 13/44] Fix errors of alignment and names. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Henrique Egewarth Signed-off-by: Gustavo Moreira Signed-off-by: isaque alves de lima --- src/Page/Questions/QuestionList.elm | 9 ++++++++- src/Page/Questions/QuestionRoot.elm | 2 +- src/scss/6_components/pages/_question.scss | 11 ++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Page/Questions/QuestionList.elm b/src/Page/Questions/QuestionList.elm index 7fcfa3e..7ae0b79 100644 --- a/src/Page/Questions/QuestionList.elm +++ b/src/Page/Questions/QuestionList.elm @@ -79,7 +79,14 @@ questionThree = , icon = "loop" } +questionFour : QuestionInfo +questionFour = + { questionName = "Questão dificil" + , shortDescription = "Essa é hard" + , icon = "loop" + } + clsList : List QuestionInfo clsList = - [ questionOne, questionTwo, questionThree ] + [ questionOne, questionTwo, questionThree, questionFour ] diff --git a/src/Page/Questions/QuestionRoot.elm b/src/Page/Questions/QuestionRoot.elm index 327b0a4..7ae5de3 100644 --- a/src/Page/Questions/QuestionRoot.elm +++ b/src/Page/Questions/QuestionRoot.elm @@ -49,7 +49,7 @@ viewList m = fab_ :: listing in div [] - [ simpleHero "Type of Questions" "See all questions available for you" "simple-hero__page-blue" + [ simpleHero "Category of Questions" "See all questions available for you" "simple-hero__page-blue" , div [] children ] diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 0468158..7830cf3 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -42,13 +42,14 @@ .question-card { @extend .question-info-card; - width: 100%; + width: 40% !important; } .question-info-list { display: flex; flex-wrap: wrap; justify-content: space-between; + text-align: center; } @media (max-width: $breakpoint-large-screen) { @@ -73,21 +74,21 @@ align-items: center; flex-direction: column; width: 75%; - margin: 0px auto; + margin: 3%; margin-top: 25px; } .select-language { width: 300px; margin-top: 50px; margin-bottom: 10px; - margin-left: 10%; + margin-left: 3%; } .item-question { width: 90%; height: 30vw; margin: 0 auto; margin-right: 5%; - margin-left: 5%; + margin-left: 1.6%; } .send-button { @@ -99,6 +100,6 @@ border-radius: 5px; width: 20%; margin-right: 5%; - margin-left: 70%; + margin-left: 64.2%; } From 9271c81a43e1baec71826b5e2f6bd9dca64f6da7 Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Thu, 5 Oct 2017 16:23:05 -0300 Subject: [PATCH 14/44] Fixing css identation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Henrique Egewarth Signed-off-by: Gustavo Moreira Signed-off-by: isaque alves de lima --- src/scss/6_components/pages/_question.scss | 69 +++++++++++----------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 7830cf3..01947e8 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -16,22 +16,22 @@ padding: 20px; &__title { - position: relative; - align-self: center; - color: #007474; - font-family: 'Amatic SC'; - padding-bottom: 10px; + position: relative; + align-self: center; + color: #007474; + font-family: 'Amatic SC'; + padding-bottom: 10px; } &__description { - text-align: center; - word-wrap: break-word; - width: 95%; + text-align: center; + word-wrap: break-word; + width: 95%; } &__icon { - align-self: center; - font-size: 100px; + align-self: center; + font-size: 100px; } &:hover { @@ -41,7 +41,7 @@ } .question-card { - @extend .question-info-card; + @extend .question-info-card; width: 40% !important; } @@ -53,36 +53,39 @@ } @media (max-width: $breakpoint-large-screen) { - .question-info-list { - display: flex; - } + .question-info-list { + display: flex; + } - .question-info-card { - flex: 1; - min-width: 15em; - } + .question-info-card { + flex: 1; + min-width: 15em; + } - .question-card { - flex: 1; - min-width: 15em; - } + .question-card { + flex: 1; + min-width: 15em; + } } + .question-description { - display: flex; - justify-content: center; - align-items: center; - flex-direction: column; - width: 75%; - margin: 3%; - margin-top: 25px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + width: 75%; + margin: 3%; + margin-top: 25px; } + .select-language { - width: 300px; - margin-top: 50px; - margin-bottom: 10px; - margin-left: 3%; + width: 300px; + margin-top: 50px; + margin-bottom: 10px; + margin-left: 3%; } + .item-question { width: 90%; height: 30vw; From 35b50089a6298b1b690a2420e63fc96ef1404cd9 Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Tue, 10 Oct 2017 16:23:57 -0300 Subject: [PATCH 15/44] Working in progress --- src/Page/Questions/QuestionRoot.elm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Page/Questions/QuestionRoot.elm b/src/Page/Questions/QuestionRoot.elm index 7ae5de3..8d5d3f0 100644 --- a/src/Page/Questions/QuestionRoot.elm +++ b/src/Page/Questions/QuestionRoot.elm @@ -64,6 +64,11 @@ questionInfo cls = , p [ class "question-info-card__description" ] [ text cls.shortDescription ] + , div [ class "classroom-info-card__toolbar" ] + [ button + [ attribute "raised" "raised" ] + [ text "Go" ] + ] ] @@ -72,6 +77,11 @@ questionOne = { questionName = "Basic" , shortDescription = "Elementary programming problems." , icon = "sentiment_very_satisfied" + , div [ class "classroom-info-card__toolbar" ] + [ button + [ attribute "raised" "raised" ] + [ text "Go" ] + ] } From f92e380e984e31c2cb84ef2dbc38466668fb6de2 Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Wed, 11 Oct 2017 09:37:54 -0300 Subject: [PATCH 16/44] Creating link do questions list --- src/Page/Questions/QuestionRoot.elm | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/Page/Questions/QuestionRoot.elm b/src/Page/Questions/QuestionRoot.elm index 8d5d3f0..28c82c9 100644 --- a/src/Page/Questions/QuestionRoot.elm +++ b/src/Page/Questions/QuestionRoot.elm @@ -3,23 +3,24 @@ module Page.Questions.QuestionRoot exposing (clsList, viewDetail, viewList) -- import Codeschool.Msg exposing (..) -- import Data.User exposing (User) -import Codeschool.Model exposing (Model) +import Codeschool.Model exposing (..) import Data.Question exposing (..) import Html exposing (..) import Html.Attributes exposing (..) import Ui.Generic exposing (container, date, emoticon) import Ui.Parts exposing (promoSimple, promoTable, simpleHero) - +import Html.Events exposing (..) +import Codeschool.Model exposing (..) +import Codeschool.Msg exposing (..) -- import Html.Events exposing (..) -viewDetail : Model -> Html msg +viewDetail : Model -> Html Msg viewDetail m = div [] [ text "#teste" ] - -viewList : List QuestionInfo -> Html msg +viewList : List QuestionInfo -> Html Msg viewList m = let -- testing if there are no questions @@ -54,7 +55,7 @@ viewList m = ] -questionInfo : QuestionInfo -> Html msg +questionInfo : QuestionInfo -> Html Msg questionInfo cls = div [ class "question-info-card" ] [ Ui.Generic.icon [ class "question-info-card__icon" ] cls.icon @@ -64,11 +65,7 @@ questionInfo cls = , p [ class "question-info-card__description" ] [ text cls.shortDescription ] - , div [ class "classroom-info-card__toolbar" ] - [ button - [ attribute "raised" "raised" ] - [ text "Go" ] - ] + , span [ onClick (ChangeRoute (QuestionList "questions")), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Acessar"] ] ] @@ -77,11 +74,6 @@ questionOne = { questionName = "Basic" , shortDescription = "Elementary programming problems." , icon = "sentiment_very_satisfied" - , div [ class "classroom-info-card__toolbar" ] - [ button - [ attribute "raised" "raised" ] - [ text "Go" ] - ] } From fae2e3b8c89b3662f4d89e3966cf79c879321bbc Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Tue, 17 Oct 2017 16:22:20 -0200 Subject: [PATCH 17/44] Finishing questions slug links --- src/Codeschool/Routing.elm | 4 ++-- src/Page/Questions/QuestionList.elm | 8 ++++++-- src/Page/Questions/QuestionRoot.elm | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Codeschool/Routing.elm b/src/Codeschool/Routing.elm index d59a722..483f3a7 100644 --- a/src/Codeschool/Routing.elm +++ b/src/Codeschool/Routing.elm @@ -75,8 +75,8 @@ baseReverse route = QuestionList st -> "questions/" ++ st - Question a b -> - "code/" ++ a ++ "/" ++ b + Question questionList question -> + "questions/" ++ questionList ++ "/" ++ question Social -> "social" diff --git a/src/Page/Questions/QuestionList.elm b/src/Page/Questions/QuestionList.elm index 7ae0b79..3b0e676 100644 --- a/src/Page/Questions/QuestionList.elm +++ b/src/Page/Questions/QuestionList.elm @@ -5,11 +5,14 @@ import Html exposing (..) import Html.Attributes exposing (..) import Ui.Generic exposing (container, date, emoticon) import Ui.Parts exposing (promoSimple, promoTable, simpleHero) +import Html.Events exposing (..) +import Codeschool.Model exposing (..) +import Codeschool.Msg exposing (..) questions_type = "Basic questions" questions_type_description = "Easy Easy Maaann, mostly basic questions" -viewList : List QuestionInfo -> Html msg +viewList : List QuestionInfo -> Html Msg viewList m = let -- testing if there are no questions @@ -44,7 +47,7 @@ viewList m = ] -questionInfo : QuestionInfo -> Html msg +questionInfo : QuestionInfo -> Html Msg questionInfo cls = div [ class "question-card" ] [ Ui.Generic.icon [ class "question-info-card__icon" ] cls.icon @@ -54,6 +57,7 @@ questionInfo cls = , p [ class "question-card__description" ] [ text cls.shortDescription ] + , span [ onClick (ChangeRoute ( Question "base" "code" )), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Acessar"] ] ] diff --git a/src/Page/Questions/QuestionRoot.elm b/src/Page/Questions/QuestionRoot.elm index 28c82c9..8a729f3 100644 --- a/src/Page/Questions/QuestionRoot.elm +++ b/src/Page/Questions/QuestionRoot.elm @@ -65,7 +65,7 @@ questionInfo cls = , p [ class "question-info-card__description" ] [ text cls.shortDescription ] - , span [ onClick (ChangeRoute (QuestionList "questions")), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Acessar"] ] + , span [ onClick (ChangeRoute (QuestionList "base")), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Acessar"] ] ] From 5662878bd27c9124257516a8685e1d0196616c27 Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Thu, 5 Oct 2017 17:06:38 -0300 Subject: [PATCH 18/44] Changing pages structural colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Henrique Egewarth egewarth@gmail.com Signed-off-by: Gustavo Moreira gustavomn93@gmail.com Signed-off-by: isaque alves de lima isaquealvesdl@gmail.com --- src/Page/Classroom.elm | 4 ++-- src/Page/Questions/Code.elm | 2 +- src/Page/Questions/QuestionList.elm | 2 +- src/Page/Questions/QuestionRoot.elm | 2 +- src/Page/Social.elm | 2 +- src/scss/1_settings/_colors.scss | 4 ++++ src/scss/6_components/_obj-hero.scss | 16 ++++++++-------- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Page/Classroom.elm b/src/Page/Classroom.elm index c5bb218..fd79131 100644 --- a/src/Page/Classroom.elm +++ b/src/Page/Classroom.elm @@ -44,7 +44,7 @@ classroomList lst = fab_ :: listing in div [ class "classroom-page" ] - [ simpleHero "List of Classrooms" "See all classrooms you are enrolled" "simple-hero__page-red" + [ simpleHero "List of Classrooms" "See all classrooms you are enrolled" "simple-hero__page-green-sea" , div [ class "container" ] children ] @@ -80,7 +80,7 @@ classroomInfo cls = classroom : Classroom -> Html msg classroom cls = div [] - [ simpleHero cls.name cls.shortDescription "simple-hero__page-red" + [ simpleHero cls.name cls.shortDescription "simple-hero__page-green-sea" , div [ class "container" ] [ h2 [] [ text "What brings you here today?" ] , promoTable diff --git a/src/Page/Questions/Code.elm b/src/Page/Questions/Code.elm index 9e0ce11..3514cdc 100644 --- a/src/Page/Questions/Code.elm +++ b/src/Page/Questions/Code.elm @@ -18,7 +18,7 @@ import Ui.Parts exposing (promoSimple, promoTable, simpleHero) view : Model -> Html msg view m = div [] - [ simpleHero "Titulo da questão" "" "simple-hero__page-blue" + [ simpleHero "Titulo da questão" "" "simple-hero__page-emerald" , div [ class "question-description" ] [ text """ diff --git a/src/Page/Questions/QuestionList.elm b/src/Page/Questions/QuestionList.elm index 3b0e676..cb350b3 100644 --- a/src/Page/Questions/QuestionList.elm +++ b/src/Page/Questions/QuestionList.elm @@ -42,7 +42,7 @@ viewList m = fab_ :: listing in div [] - [ simpleHero questions_type questions_type_description "simple-hero__page-blue" + [ simpleHero questions_type questions_type_description "simple-hero__page-emerald" , div [] children ] diff --git a/src/Page/Questions/QuestionRoot.elm b/src/Page/Questions/QuestionRoot.elm index 8a729f3..2a5e2ee 100644 --- a/src/Page/Questions/QuestionRoot.elm +++ b/src/Page/Questions/QuestionRoot.elm @@ -50,7 +50,7 @@ viewList m = fab_ :: listing in div [] - [ simpleHero "Category of Questions" "See all questions available for you" "simple-hero__page-blue" + [ simpleHero "Category of Questions" "See all questions available for you" "simple-hero__page-emerald" , div [] children ] diff --git a/src/Page/Social.elm b/src/Page/Social.elm index 517a9a8..c8e35de 100644 --- a/src/Page/Social.elm +++ b/src/Page/Social.elm @@ -10,7 +10,7 @@ import Ui.Parts exposing (promoSimple, promoTable, simpleHero) view : Model -> Html msg view m = div [] - [ simpleHero "Social" "" "simple-hero__page-orange" + [ simpleHero "Social" "" "simple-hero__page-blue" , container [] [ promoTable ( promoSimple "record_voice_over" diff --git a/src/scss/1_settings/_colors.scss b/src/scss/1_settings/_colors.scss index 14fdc02..d9b7c3d 100644 --- a/src/scss/1_settings/_colors.scss +++ b/src/scss/1_settings/_colors.scss @@ -20,6 +20,10 @@ $color-grey-2: #666; $color-grey-3: #d9d9d9; $color-grey-4: #e6e6e6; $color-grey-5: #fafafa; +$color-nephiritis: #27ae60; +$color-green-sea: #16a085; +$color-emerald: #2ecc71; +$color-peter-rever: #3498db; // Colors of styled elements and semantic names $color-thead-bg: $color-grey-5; diff --git a/src/scss/6_components/_obj-hero.scss b/src/scss/6_components/_obj-hero.scss index 80f5eb7..a34d05f 100644 --- a/src/scss/6_components/_obj-hero.scss +++ b/src/scss/6_components/_obj-hero.scss @@ -1,5 +1,5 @@ .simple-hero { - background-color: $color-salmon; + background-color: $color-nephiritis; width: 100%; color: white; @@ -14,17 +14,17 @@ color: lighten($color-primary-tint, 0.9); } - &__page-red { - background-color: $color-salmon; + &__page-green-sea { + background-color: $color-green-sea; color: white; } - &__page-blue { - background-color: $color-primary-tint; + &__page-emerald { + background-color: $color-emerald; } - &__page-orange { - background-color: #ce6b14; + &__page-blue { + background-color: $color-peter-rever; } } -// BEM: Block, Element, Modifier \ No newline at end of file +// BEM: Block, Element, Modifier From 41249075ff6fdcd8e3c0b7afbb13496578869154 Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Thu, 5 Oct 2017 17:16:14 -0300 Subject: [PATCH 19/44] Fixing fonts style and colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Henrique Egewarth Signed-off-by: Gustavo Moreira Signed-off-by: isaque alves de lima --- src/scss/6_components/_obj-hero.scss | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/scss/6_components/_obj-hero.scss b/src/scss/6_components/_obj-hero.scss index a34d05f..ba1c0fb 100644 --- a/src/scss/6_components/_obj-hero.scss +++ b/src/scss/6_components/_obj-hero.scss @@ -8,10 +8,14 @@ font-family: $amatic-sc; font-weight: bold; font-size: 3.2em; + color: $color-dark-gray; } - &__description > *:nth-child(odd) { - color: lighten($color-primary-tint, 0.9); + &__description { + font-family: $amatic-sc; + font-weight: bold; + font-size: 1.5em; + color: $color-dark-gray; } &__page-green-sea { From 555f7e92b6aeca04785b24e2593c0ee68f6cefaf Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Thu, 5 Oct 2017 17:51:39 -0300 Subject: [PATCH 20/44] Correcting css in header and change font of language --- src/scss/6_components/_layout-header.scss | 6 +++--- src/scss/6_components/_obj-hero.scss | 3 +++ src/scss/6_components/_obj-promo.scss | 1 + src/scss/6_components/pages/_question.scss | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/scss/6_components/_layout-header.scss b/src/scss/6_components/_layout-header.scss index 5d347ba..ed84431 100644 --- a/src/scss/6_components/_layout-header.scss +++ b/src/scss/6_components/_layout-header.scss @@ -15,8 +15,9 @@ header { .page-header { margin: 0; padding: 0; - padding-right: 20px; - padding-top: 15px; + padding-right: 10px; + padding-left: 10px; + padding-top: 10px; background-color: #fafafa; width: 100%; height: 110px; @@ -41,7 +42,6 @@ header { font-weight: bold; color: black; height: 100%; - width: 150px; align-self: flex-start; background-color: #fafafa; margin-right: 3%; diff --git a/src/scss/6_components/_obj-hero.scss b/src/scss/6_components/_obj-hero.scss index ba1c0fb..aab6f1f 100644 --- a/src/scss/6_components/_obj-hero.scss +++ b/src/scss/6_components/_obj-hero.scss @@ -20,15 +20,18 @@ &__page-green-sea { background-color: $color-green-sea; + font-family: $amatic-sc; color: white; } &__page-emerald { background-color: $color-emerald; + font-family: $amatic-sc; } &__page-blue { background-color: $color-peter-rever; + font-family: $amatic-sc; } } // BEM: Block, Element, Modifier diff --git a/src/scss/6_components/_obj-promo.scss b/src/scss/6_components/_obj-promo.scss index 22c05db..dc511dc 100644 --- a/src/scss/6_components/_obj-promo.scss +++ b/src/scss/6_components/_obj-promo.scss @@ -8,6 +8,7 @@ padding: 20px; vertical-align: center; text-align: center; + font-family: $amatic-sc; > i { font-size: 4em; diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 01947e8..866c471 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -1,6 +1,5 @@ .question-info-card { @extend .paper-flat; - padding: 0; background: #fafafa; border: 1px solid rgba(0, 0, 0, 0.3); @@ -25,6 +24,8 @@ &__description { text-align: center; + font-family: $amatic-sc; + font-size: 12; word-wrap: break-word; width: 95%; } From 9ef5de23877bffa92d1164e7cf3b280a472d55c4 Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Tue, 10 Oct 2017 18:33:25 -0300 Subject: [PATCH 21/44] Correcting source and presentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Henrique Egewarth Signed-off-by: isaque alves de lima --- src/scss/6_components/_layout-sidebar.scss | 6 +++++- src/scss/6_components/_obj-promo.scss | 6 +++++- src/scss/6_components/pages/_question.scss | 18 ++++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/scss/6_components/_layout-sidebar.scss b/src/scss/6_components/_layout-sidebar.scss index 2b26853..4f01ca6 100644 --- a/src/scss/6_components/_layout-sidebar.scss +++ b/src/scss/6_components/_layout-sidebar.scss @@ -10,6 +10,7 @@ $barcolor: #aaa; left: 0; background: $barcolor; border-right: 1px solid darken(#666, 0.05); + font-weight: bold; &__icon { color: #eee; @@ -34,6 +35,9 @@ $barcolor: #aaa; opacity: 0; position: absolute; left: 45px; + font-weight: bold; + font-size: 14; + font-family: $amatic-sc; margin-top: 20px; color: white; height: 60px; @@ -71,7 +75,7 @@ $barcolor: #aaa; &__text { opacity: 1; position: relative; - font-weight: 500; + font-weight: bold; left: auto; margin-top: 0px; color: black; diff --git a/src/scss/6_components/_obj-promo.scss b/src/scss/6_components/_obj-promo.scss index dc511dc..c32e4d8 100644 --- a/src/scss/6_components/_obj-promo.scss +++ b/src/scss/6_components/_obj-promo.scss @@ -9,7 +9,8 @@ vertical-align: center; text-align: center; font-family: $amatic-sc; - + font-weight: bold; + > i { font-size: 4em; color: $color-teal-darker; @@ -21,6 +22,9 @@ font-weight: bold; color: $color-teal-darker; } + > text { + font-weight: bold; + } } .promo-simple:hover { diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 866c471..1d2b838 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -13,26 +13,34 @@ justify-content: space-between; width: 30%; padding: 20px; + font-family: $amatic-sc; + + > h1 { + font-family: $amatic-sc; + font-weight: bold; + color: $color-teal-darker; + } &__title { position: relative; align-self: center; color: #007474; - font-family: 'Amatic SC'; padding-bottom: 10px; } &__description { text-align: center; - font-family: $amatic-sc; - font-size: 12; + font-size: 14; word-wrap: break-word; width: 95%; + font-weight: bold; } &__icon { align-self: center; - font-size: 100px; + font-size: 4em; + color: $color-teal-darker; + } &:hover { @@ -51,6 +59,8 @@ flex-wrap: wrap; justify-content: space-between; text-align: center; + font-weight: bold; + } @media (max-width: $breakpoint-large-screen) { From c7bcd85c46fd852de3f054873ef844079fe574c2 Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Tue, 17 Oct 2017 17:59:56 -0200 Subject: [PATCH 22/44] Correcting font, buttons and alignment. --- src/Page/Questions/QuestionRoot.elm | 2 +- src/scss/3_generic/_normalize.scss | 3 ++ src/scss/6_components/_obj-promo.scss | 3 +- src/scss/6_components/pages/_question.scss | 22 ++++++++++- src/scss/6_components/pages/_register.scss | 45 +++++++++++++--------- 5 files changed, 54 insertions(+), 21 deletions(-) diff --git a/src/Page/Questions/QuestionRoot.elm b/src/Page/Questions/QuestionRoot.elm index 2a5e2ee..b775f20 100644 --- a/src/Page/Questions/QuestionRoot.elm +++ b/src/Page/Questions/QuestionRoot.elm @@ -65,7 +65,7 @@ questionInfo cls = , p [ class "question-info-card__description" ] [ text cls.shortDescription ] - , span [ onClick (ChangeRoute (QuestionList "base")), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Acessar"] ] + , span [ onClick (ChangeRoute (QuestionList "base")), class "access-button" ] [ h1 [class "access-button__fonts"] [text "Acessar"] ] ] diff --git a/src/scss/3_generic/_normalize.scss b/src/scss/3_generic/_normalize.scss index 2722ed6..2c7bb97 100644 --- a/src/scss/3_generic/_normalize.scss +++ b/src/scss/3_generic/_normalize.scss @@ -197,6 +197,9 @@ input::-moz-focus-inner { input { line-height: normal; + font-family: "Amatic SC"; + font-size: 1.2em; + font-weight: bold; } input[type="checkbox"], diff --git a/src/scss/6_components/_obj-promo.scss b/src/scss/6_components/_obj-promo.scss index c32e4d8..fd622cd 100644 --- a/src/scss/6_components/_obj-promo.scss +++ b/src/scss/6_components/_obj-promo.scss @@ -9,8 +9,9 @@ vertical-align: center; text-align: center; font-family: $amatic-sc; + font-size: 1.2em; font-weight: bold; - + > i { font-size: 4em; color: $color-teal-darker; diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 1d2b838..43ed362 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -14,7 +14,6 @@ width: 30%; padding: 20px; font-family: $amatic-sc; - > h1 { font-family: $amatic-sc; font-weight: bold; @@ -34,6 +33,7 @@ word-wrap: break-word; width: 95%; font-weight: bold; + font-size: 1.2em; } &__icon { @@ -115,5 +115,25 @@ width: 20%; margin-right: 5%; margin-left: 64.2%; +} +.access-button { + width: 10px; + height: 50px; + margin: 15px auto; + background-color: $color-green; + color: white; + border-radius: 5px; + width: 20%; + + &__fonts { + font-family: $amatic-sc; + font-weight: bold; + margin-bottom: 3px; + font-size: 1.2em; + font-weight: 500; + color: black; + margin-bottom: 10px; + margin-top: 10px; + } } diff --git a/src/scss/6_components/pages/_register.scss b/src/scss/6_components/pages/_register.scss index d6e41a1..826aba0 100644 --- a/src/scss/6_components/pages/_register.scss +++ b/src/scss/6_components/pages/_register.scss @@ -3,57 +3,66 @@ justify-content: center; align-items: center; flex-direction: column; - width: 50%; + width: 75%; margin: 0px auto; } .item-form { - width: 300px; + width: 400px; margin: 10px; -} + font-family: "Amatic SC"; + font-size: 1.3em; + font-weight: bold; +} .select-item { - width: 300px; + width: 300px; } .disabled-item { - display: none; + display: none; } +.date-form { + display: flex; + flex-direction: row; + width: 300px; + margin: 10px; + justify-content: space-between; + font-family: "Amatic SC"; + font-size: 1.2em; + font-weight: bold; -.date-form { - display: flex; - flex-direction: row; - width: 300px; - margin: 10px; - justify-content: space-between; } .date-month { - width: 90px; + width: 90px; } .date-item { - width: 90px; - height: 47px; - align-self: center; + width: 90px; + height: 47px; + align-self: center; } .form-title { font-family: "Amatic SC"; font-size: 3.5em; font-weight: bold; - margin-right: 20%; } .submit-button { width: 30%; - height: 40px; + height: 50px; margin: 10px; - background-color: $color-teal; + background-color: $color-green; color: white; border-radius: 5px; width: 50%; + font-family: "Amatic SC"; + font-size: 1.2em; + font-weight: bold; + } From 7dc02a3517b62376ab79726da8e1c87d9dddf1c0 Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Wed, 18 Oct 2017 14:48:57 -0200 Subject: [PATCH 23/44] Adding the button in QuestionList. --- src/Page/Questions/QuestionList.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Page/Questions/QuestionList.elm b/src/Page/Questions/QuestionList.elm index cb350b3..a5296bc 100644 --- a/src/Page/Questions/QuestionList.elm +++ b/src/Page/Questions/QuestionList.elm @@ -57,7 +57,7 @@ questionInfo cls = , p [ class "question-card__description" ] [ text cls.shortDescription ] - , span [ onClick (ChangeRoute ( Question "base" "code" )), class "mobile-button__item" ] [ h1 [class "mobile-button__fonts"] [text "Acessar"] ] + , span [ onClick (ChangeRoute ( Question "base" "code" )), class "access-button" ] [ h1 [class "access-button__fonts"] [text "Acessar"] ] ] From ba7ec9ef797775ef47283b43412ba20c0657c79d Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Thu, 19 Oct 2017 17:39:18 -0200 Subject: [PATCH 24/44] Changing button on questions to onClick in intire div --- src/Page/Questions/QuestionList.elm | 3 +-- src/Page/Questions/QuestionRoot.elm | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Page/Questions/QuestionList.elm b/src/Page/Questions/QuestionList.elm index a5296bc..d4c0d1c 100644 --- a/src/Page/Questions/QuestionList.elm +++ b/src/Page/Questions/QuestionList.elm @@ -49,7 +49,7 @@ viewList m = questionInfo : QuestionInfo -> Html Msg questionInfo cls = - div [ class "question-card" ] + div [ class "question-card", onClick (ChangeRoute ( Question "base" "code" )) ] [ Ui.Generic.icon [ class "question-info-card__icon" ] cls.icon , h1 [ class "question-card__title" ] [ text cls.questionName @@ -57,7 +57,6 @@ questionInfo cls = , p [ class "question-card__description" ] [ text cls.shortDescription ] - , span [ onClick (ChangeRoute ( Question "base" "code" )), class "access-button" ] [ h1 [class "access-button__fonts"] [text "Acessar"] ] ] diff --git a/src/Page/Questions/QuestionRoot.elm b/src/Page/Questions/QuestionRoot.elm index b775f20..3680482 100644 --- a/src/Page/Questions/QuestionRoot.elm +++ b/src/Page/Questions/QuestionRoot.elm @@ -57,7 +57,7 @@ viewList m = questionInfo : QuestionInfo -> Html Msg questionInfo cls = - div [ class "question-info-card" ] + div [ class "question-info-card", onClick (ChangeRoute (QuestionList "base")) ] [ Ui.Generic.icon [ class "question-info-card__icon" ] cls.icon , h1 [ class "question-info-card__title" ] [ text cls.questionName @@ -65,7 +65,6 @@ questionInfo cls = , p [ class "question-info-card__description" ] [ text cls.shortDescription ] - , span [ onClick (ChangeRoute (QuestionList "base")), class "access-button" ] [ h1 [class "access-button__fonts"] [text "Acessar"] ] ] From e9071ee3b8199178a6a7841d034567f17e9eca92 Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Thu, 19 Oct 2017 17:48:33 -0200 Subject: [PATCH 25/44] Making adjustments. --- src/scss/6_components/_layout-sidebar.scss | 4 ++-- src/scss/6_components/_obj-hero.scss | 5 ++--- src/scss/6_components/_obj-promo.scss | 3 --- src/scss/6_components/pages/_question.scss | 8 ++++---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/scss/6_components/_layout-sidebar.scss b/src/scss/6_components/_layout-sidebar.scss index 4f01ca6..e0c37df 100644 --- a/src/scss/6_components/_layout-sidebar.scss +++ b/src/scss/6_components/_layout-sidebar.scss @@ -36,9 +36,9 @@ $barcolor: #aaa; position: absolute; left: 45px; font-weight: bold; - font-size: 14; + font-size: 1.4em; font-family: $amatic-sc; - margin-top: 20px; + margin-top: 10px; color: white; height: 60px; } diff --git a/src/scss/6_components/_obj-hero.scss b/src/scss/6_components/_obj-hero.scss index aab6f1f..9473fc2 100644 --- a/src/scss/6_components/_obj-hero.scss +++ b/src/scss/6_components/_obj-hero.scss @@ -12,9 +12,8 @@ } &__description { - font-family: $amatic-sc; - font-weight: bold; - font-size: 1.5em; + font-family: $roboto; + font-size: 1.3em; color: $color-dark-gray; } diff --git a/src/scss/6_components/_obj-promo.scss b/src/scss/6_components/_obj-promo.scss index fd622cd..f1330e7 100644 --- a/src/scss/6_components/_obj-promo.scss +++ b/src/scss/6_components/_obj-promo.scss @@ -8,9 +8,6 @@ padding: 20px; vertical-align: center; text-align: center; - font-family: $amatic-sc; - font-size: 1.2em; - font-weight: bold; > i { font-size: 4em; diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 43ed362..7f88493 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -13,7 +13,6 @@ justify-content: space-between; width: 30%; padding: 20px; - font-family: $amatic-sc; > h1 { font-family: $amatic-sc; font-weight: bold; @@ -32,8 +31,8 @@ font-size: 14; word-wrap: break-word; width: 95%; - font-weight: bold; - font-size: 1.2em; + font-weight: normal; + font-size: 1.0em; } &__icon { @@ -59,7 +58,8 @@ flex-wrap: wrap; justify-content: space-between; text-align: center; - font-weight: bold; + padding-left: 50px; + padding-right: 50px; } From f36bfa6ab2820733d45509d8165eedb356fdef95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Henrique=20Egewarth?= Date: Tue, 10 Oct 2017 19:42:03 -0300 Subject: [PATCH 26/44] Function to parsing markdown (received from django api) to html (used in elm) - Working in progress MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Henrique Egewarth Signed-off-by: isaque alves de lima Signed-off-by: Gustavo Moreira --- elm-package.json | 1 + src/Codeschool/Model.elm | 2 ++ src/Codeschool/Msg.elm | 15 +++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/elm-package.json b/elm-package.json index 5c87acc..10c39eb 100644 --- a/elm-package.json +++ b/elm-package.json @@ -14,6 +14,7 @@ "elm-lang/html": "2.0.0 <= v < 3.0.0", "elm-lang/http": "1.0.0 <= v < 2.0.0", "elm-lang/navigation": "2.1.0 <= v < 3.0.0", + "evancz/elm-markdown" : "2.0.0 <= v < 3.0.2", "evancz/url-parser": "2.0.1 <= v < 3.0.0", "iosphere/elm-toast": "1.0.0 <= v < 2.0.0", "krisajenkins/remotedata": "4.3.0 <= v < 5.0.0" diff --git a/src/Codeschool/Model.elm b/src/Codeschool/Model.elm index d212cd9..f0ddb69 100644 --- a/src/Codeschool/Model.elm +++ b/src/Codeschool/Model.elm @@ -33,6 +33,7 @@ type alias Model = , toast : Toast String , auth : Auth , isLogged : Bool + , markdownTest : String } @@ -54,6 +55,7 @@ init = , toast = Toast.initWithTransitionDelay (Time.second * 1.5) , auth = emptyAuth , isLogged = False + , markdownTest = "" } diff --git a/src/Codeschool/Msg.elm b/src/Codeschool/Msg.elm index c37aafe..eea4c5d 100644 --- a/src/Codeschool/Msg.elm +++ b/src/Codeschool/Msg.elm @@ -3,6 +3,8 @@ module Codeschool.Msg exposing (..) {-| Main page messages and update function -} +import Markdown exposing (..) +import Html exposing (..) import Codeschool.Model exposing (Model, Route) import Codeschool.Routing exposing (parseLocation, reverse) import Data.Date exposing (..) @@ -197,6 +199,19 @@ withElement el lst = else el :: lst +-- Isso funciona +toHtmlString markdownTxt = + Markdown.toHtml [] markdownTxt + +-- Testes para adequar a função ao contexto +-- toHtmlString : String -> Html +-- toHtmlString markdownTxt = +-- Markdown.toHtml [] markdownTxt + +-- toHtmlString markdownTxt = +-- Markdown.toHtml [] markdownTxt + +-- function toHtmlString(markdownTest:List (Attribute markdownTest), a: String): Html dateUserUpdate : ProfileForm -> Date -> ProfileForm dateUserUpdate profile date = From 7e837dff2a8fbf4a32cb3e7fad526840d25cfcc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Henrique=20Egewarth?= Date: Tue, 17 Oct 2017 18:02:18 -0200 Subject: [PATCH 27/44] Adding struct CodeQuestion to contain the information of the questions --- src/Codeschool/Model.elm | 2 -- src/Data/Question.elm | 47 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/Codeschool/Model.elm b/src/Codeschool/Model.elm index f0ddb69..d212cd9 100644 --- a/src/Codeschool/Model.elm +++ b/src/Codeschool/Model.elm @@ -33,7 +33,6 @@ type alias Model = , toast : Toast String , auth : Auth , isLogged : Bool - , markdownTest : String } @@ -55,7 +54,6 @@ init = , toast = Toast.initWithTransitionDelay (Time.second * 1.5) , auth = emptyAuth , isLogged = False - , markdownTest = "" } diff --git a/src/Data/Question.elm b/src/Data/Question.elm index 1d933e8..57820b3 100644 --- a/src/Data/Question.elm +++ b/src/Data/Question.elm @@ -6,7 +6,52 @@ module Data.Question exposing (..) {-| Represents the reduced information about a question that is shown on listings -} type alias QuestionInfo = - { questionName : String + { title : String , shortDescription : String , icon : String + , slug : String + } + +type alias CodeQuestion = + { questionInfo : QuestionInfo + , description : String + , acceptedLanguages : List ProgrammingLanguage + , selectedLanguage : String + , answer : String + } + +type ProgrammingLanguage + = Java | C | Cpp | Python2 | Python + +programmingLanguageName : ProgrammingLanguage -> String +programmingLanguageName lang = + case lang of + Cpp -> "C++" + Python2 -> "Python 2.7" + Java -> "Java 8" + _ -> toString lang + +--FIXME : apagar quando API estiver pronta +questionInfoExample : QuestionInfo +questionInfoExample = + { title = "Functions" + , shortDescription = "Organize code using functions." + , icon = "functions" + , slug = "functions" + } + +codeQuestionExample : CodeQuestion +codeQuestionExample = + { questionInfo = questionInfoExample + , description = " Codifique um software receba o ano de nascimento de uma"++ + "pessoa e o ano atual. Calcule e mostre:"++ + "a) A idade dessa pessoa."++ + "b) Quantos anos essa pessoa terá em 2018."++ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"++ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"++ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"++ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa." + , acceptedLanguages = [Java, C, Cpp, Python2, Python] + , selectedLanguage = "" + , answer = "" } From d64ad7cba05fcda70fd76745de4d8bdf405d0dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Henrique=20Egewarth?= Date: Tue, 17 Oct 2017 18:03:10 -0200 Subject: [PATCH 28/44] Renaming quantionName to title --- src/Page/Questions/QuestionList.elm | 14 +++++++++----- src/Page/Questions/QuestionRoot.elm | 20 +++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Page/Questions/QuestionList.elm b/src/Page/Questions/QuestionList.elm index d4c0d1c..5ed2224 100644 --- a/src/Page/Questions/QuestionList.elm +++ b/src/Page/Questions/QuestionList.elm @@ -52,7 +52,7 @@ questionInfo cls = div [ class "question-card", onClick (ChangeRoute ( Question "base" "code" )) ] [ Ui.Generic.icon [ class "question-info-card__icon" ] cls.icon , h1 [ class "question-card__title" ] - [ text cls.questionName + [ text cls.title ] , p [ class "question-card__description" ] [ text cls.shortDescription @@ -62,31 +62,35 @@ questionInfo cls = questionOne : QuestionInfo questionOne = - { questionName = "Questão mais facil" + { title = "Questão mais facil" , shortDescription = "Questão mais facil, se n conseguir fazer vaza." , icon = "sentiment_very_satisfied" + , slug = "veryeasy" } questionTwo : QuestionInfo questionTwo = - { questionName = "Segunda mais facil" + { title = "Segunda mais facil" , shortDescription = "Questão facil também." , icon = "code" + , slug = "easy" } questionThree : QuestionInfo questionThree = - { questionName = "Questão dificil" + { title = "Questão dificil" , shortDescription = "Essa é hard" , icon = "loop" + , slug = "hard" } questionFour : QuestionInfo questionFour = - { questionName = "Questão dificil" + { title = "Questão dificil" , shortDescription = "Essa é hard" , icon = "loop" + , slug = "hard2" } diff --git a/src/Page/Questions/QuestionRoot.elm b/src/Page/Questions/QuestionRoot.elm index 3680482..7f3a66a 100644 --- a/src/Page/Questions/QuestionRoot.elm +++ b/src/Page/Questions/QuestionRoot.elm @@ -60,7 +60,7 @@ questionInfo cls = div [ class "question-info-card", onClick (ChangeRoute (QuestionList "base")) ] [ Ui.Generic.icon [ class "question-info-card__icon" ] cls.icon , h1 [ class "question-info-card__title" ] - [ text cls.questionName + [ text cls.title ] , p [ class "question-info-card__description" ] [ text cls.shortDescription @@ -70,45 +70,51 @@ questionInfo cls = questionOne : QuestionInfo questionOne = - { questionName = "Basic" + { title = "Basic" , shortDescription = "Elementary programming problems." , icon = "sentiment_very_satisfied" + , slug = "basic" } questionTwo : QuestionInfo questionTwo = - { questionName = "Conditionals" + { title = "Conditionals" , shortDescription = "Conditional flow control (if/else)." , icon = "code" + , slug = "conditionals" } questionThree : QuestionInfo questionThree = - { questionName = "Loops" + { title = "Loops" , shortDescription = "Iterations with for/while commands" , icon = "loop" + , slug = "loops" } questionFour : QuestionInfo questionFour = - { questionName = "Functions" + { title = "Functions" , shortDescription = "Organize code using functions." , icon = "functions" + , slug = "functions" } questionFive : QuestionInfo questionFive = - { questionName = "Files" + { title = "Files" , shortDescription = "Open, process and write files." , icon = "insert_drive_file" + , slug = "files" } questionSix : QuestionInfo questionSix = - { questionName = "Lists" + { title = "Lists" , shortDescription = "Linear data structures." , icon = "list" + , slug = "list" } clsList : List QuestionInfo From 75680522d01112a930775f2410190b3d29d666a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Henrique=20Egewarth?= Date: Tue, 31 Oct 2017 17:07:01 -0200 Subject: [PATCH 29/44] Creating function markdownToHtml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gustavo Moreira Signed-off-by: João Henrique Egewarth --- src/Codeschool/Model.elm | 8 +++++++ src/Codeschool/Msg.elm | 10 -------- src/Codeschool/View.elm | 4 ++-- src/Page/Questions/Code.elm | 46 ++++++++++++++++++++++++------------- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/Codeschool/Model.elm b/src/Codeschool/Model.elm index d212cd9..b24cd7a 100644 --- a/src/Codeschool/Model.elm +++ b/src/Codeschool/Model.elm @@ -33,6 +33,7 @@ type alias Model = , toast : Toast String , auth : Auth , isLogged : Bool + , markdownToString : String } @@ -54,6 +55,13 @@ init = , toast = Toast.initWithTransitionDelay (Time.second * 1.5) , auth = emptyAuth , isLogged = False + , markdownToString = """ + # Basic + Codifique um software receba o ano de nascimento de uma + pessoa e o ano atual. Calcule e mostre: + - a) A idade dessa pessoa. + - b) Quantos anos essa pessoa terá em 2018. + """ } diff --git a/src/Codeschool/Msg.elm b/src/Codeschool/Msg.elm index eea4c5d..505a163 100644 --- a/src/Codeschool/Msg.elm +++ b/src/Codeschool/Msg.elm @@ -199,19 +199,9 @@ withElement el lst = else el :: lst --- Isso funciona toHtmlString markdownTxt = Markdown.toHtml [] markdownTxt --- Testes para adequar a função ao contexto --- toHtmlString : String -> Html --- toHtmlString markdownTxt = --- Markdown.toHtml [] markdownTxt - --- toHtmlString markdownTxt = --- Markdown.toHtml [] markdownTxt - --- function toHtmlString(markdownTest:List (Attribute markdownTest), a: String): Html dateUserUpdate : ProfileForm -> Date -> ProfileForm dateUserUpdate profile date = diff --git a/src/Codeschool/View.elm b/src/Codeschool/View.elm index ca4552a..9b07bf2 100644 --- a/src/Codeschool/View.elm +++ b/src/Codeschool/View.elm @@ -22,7 +22,7 @@ import Page.Actions import Page.Register import Page.Login import Ui.Layout - +import Data.Question exposing (..) getRouteView : Model -> Html Msg getRouteView model = @@ -55,7 +55,7 @@ getRouteView model = Page.Questions.QuestionList.viewList Page.Questions.QuestionList.clsList Question string slug -> - Page.Questions.Code.view model + Page.Questions.Code.viewDetail Page.Questions.Code.question QuestionRoot -> Page.Questions.QuestionRoot.viewList Page.Questions.QuestionRoot.clsList diff --git a/src/Page/Questions/Code.elm b/src/Page/Questions/Code.elm index 3514cdc..6e897d8 100644 --- a/src/Page/Questions/Code.elm +++ b/src/Page/Questions/Code.elm @@ -1,33 +1,30 @@ -module Page.Questions.Code exposing (view) +module Page.Questions.Code exposing (viewDetail, question) -- import Codeschool.Msg exposing (..) -- import Data.User exposing (User) -import Codeschool.Model exposing (Model) +import Codeschool.Msg exposing (..) +import Data.Question exposing (..) import Html exposing (..) import Html.Attributes exposing (..) -import Ui.Generic exposing (container, icon) +-- import Ui.Generic exposing (container, icon) import Ui.Parts exposing (promoSimple, promoTable, simpleHero) - -- import Html.Attributes exposing (..) -- import Html.Events exposing (..) - -view : Model -> Html msg -view m = +viewDetail : CodeQuestion -> Html msg +viewDetail cls = div [] - [ simpleHero "Titulo da questão" "" "simple-hero__page-emerald" + [ simpleHero question.questionInfo.title "" "simple-hero__page-blue" , div [ class "question-description" ] - [ text - """ - Codifique um software receba o ano de nascimento de uma pessoa e o ano atual. Calcule e mostre: - a) A idade dessa pessoa. - b) Quantos anos essa pessoa terá em 2018.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaa - """ + [ + Codeschool.Msg.toHtmlString """# Basic +Codifique um software receba o ano de nascimento de uma +pessoa e o ano atual. Calcule e mostre: +- a) A idade dessa pessoa. +- b) Quantos anos essa pessoa terá em 2018.""" ] , select [ class "select-language" ] [ option [ value "", disabled True, selected True, class "disabled-item" ] [ text "Select language" ] @@ -42,3 +39,20 @@ view m = ] , button [ class "send-button" ] [ text "Send to evaluation" ] ] + +question : CodeQuestion +question = + { questionInfo = questionInfoExample + , description = + """Codifique um software receba o ano de nascimento de uma + pessoa e o ano atual. Calcule e mostre: + a) A idade dessa pessoa. + b) Quantos anos essa pessoa terá em 2018. + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.""" + , acceptedLanguages = [Java, C, Cpp, Python2, Python] + , selectedLanguage = "" + , answer = "" + } From 29cdbca218b72dd0e42988e53220bf4e5b584825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ara=C3=BAjo?= Date: Thu, 9 Nov 2017 17:12:24 -0200 Subject: [PATCH 30/44] Fixing code clean issues --- src/App.elm | 3 ++- src/Codeschool/Assets.elm | 2 +- src/Codeschool/View.elm | 1 - src/Data/Date.elm | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.elm b/src/App.elm index 6b72b08..fbc78e5 100644 --- a/src/App.elm +++ b/src/App.elm @@ -1,6 +1,7 @@ -module App exposing (..) +module App exposing (main) import Codeschool.Main as Main +main : Program String Main.Model Main.Msg main = Main.mainWithFlags diff --git a/src/Codeschool/Assets.elm b/src/Codeschool/Assets.elm index 8c6dd7c..cdb0807 100644 --- a/src/Codeschool/Assets.elm +++ b/src/Codeschool/Assets.elm @@ -1,4 +1,4 @@ -module Codeschool.Assets exposing (..) +module Codeschool.Assets exposing (url) {-| Server-side assets. Controls where information is obtained on the server. -} diff --git a/src/Codeschool/View.elm b/src/Codeschool/View.elm index 9b07bf2..2cee27b 100644 --- a/src/Codeschool/View.elm +++ b/src/Codeschool/View.elm @@ -22,7 +22,6 @@ import Page.Actions import Page.Register import Page.Login import Ui.Layout -import Data.Question exposing (..) getRouteView : Model -> Html Msg getRouteView model = diff --git a/src/Data/Date.elm b/src/Data/Date.elm index a01cdc8..282ca6c 100644 --- a/src/Data/Date.elm +++ b/src/Data/Date.elm @@ -1,4 +1,4 @@ -module Data.Date exposing (..) +module Data.Date exposing (Date, testDate, dateDecoder, toJson) {-| Represents date objects in Elm -} From 6d2e4de2dbbf78c0b0560d6a07b93ebc4dd5f450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Henrique=20Egewarth?= Date: Thu, 9 Nov 2017 17:11:10 -0200 Subject: [PATCH 31/44] Code clean Fix elm analyse issues --- src/Data/User.elm | 2 +- src/Forms/Contrib/FieldForm.elm | 2 +- src/Forms/Contrib/LoginForm.elm | 2 +- src/Forms/Examples/AppForms.elm | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Data/User.elm b/src/Data/User.elm index 083c743..cf0f67f 100644 --- a/src/Data/User.elm +++ b/src/Data/User.elm @@ -3,7 +3,7 @@ module Data.User exposing (..) {-| Represents user objects in Elm -} import Json.Decode as Dec exposing (..) -import Json.Decode.Pipeline exposing (decode, required, optional) +import Json.Decode.Pipeline exposing (decode, required) -- Logged User type type alias LoggedUser = diff --git a/src/Forms/Contrib/FieldForm.elm b/src/Forms/Contrib/FieldForm.elm index aeb2c16..787f5f7 100644 --- a/src/Forms/Contrib/FieldForm.elm +++ b/src/Forms/Contrib/FieldForm.elm @@ -1,6 +1,6 @@ module Forms.Contrib.FieldForm exposing - ( FieldFields(..) + ( FieldFields(field) , FieldForm , FieldFormMsg , field diff --git a/src/Forms/Contrib/LoginForm.elm b/src/Forms/Contrib/LoginForm.elm index ae423ff..cb66cd5 100644 --- a/src/Forms/Contrib/LoginForm.elm +++ b/src/Forms/Contrib/LoginForm.elm @@ -1,6 +1,6 @@ module Forms.Contrib.LoginForm exposing - ( LoginFields(..) + ( LoginFields(login, loginByEmail, loginByUsername) , LoginForm , LoginFormMsg , LoginFormTypes diff --git a/src/Forms/Examples/AppForms.elm b/src/Forms/Examples/AppForms.elm index c9ecb20..7626b95 100644 --- a/src/Forms/Examples/AppForms.elm +++ b/src/Forms/Examples/AppForms.elm @@ -6,7 +6,7 @@ import Forms.Form as Form exposing (..) import Forms.JsonDecode exposing (..) import Forms.Validation exposing (..) import Forms.Types exposing (..) -import Html exposing (Html, code, div, h2, pre, text) +import Html exposing (Html, div, h2, text) import Html.Attributes exposing (style) From 0f49946c622ece1557474721ba2fe19d39358431 Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Thu, 9 Nov 2017 17:12:28 -0200 Subject: [PATCH 32/44] Fixing code clean issues --- src/Forms/JsonDecode.elm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Forms/JsonDecode.elm b/src/Forms/JsonDecode.elm index ef3ee43..1704372 100644 --- a/src/Forms/JsonDecode.elm +++ b/src/Forms/JsonDecode.elm @@ -12,8 +12,8 @@ import Forms.Types ) import Forms.Validation as Validation exposing (Validation(..), Validator(..)) import Forms.Value as Value exposing (Value(..), jsonDecoder) -import Json.Decode as JD exposing (Decoder, andThen, bool, fail, float, int, list, nullable, oneOf, string, succeed, value) -import Json.Decode.Pipeline as Pipeline exposing (decode, hardcoded, optional, required) +import Json.Decode as JD exposing (Decoder, andThen, bool, fail, list, nullable, string, succeed) +import Json.Decode.Pipeline as Pipeline exposing (optional, required) import Maybe @@ -102,11 +102,11 @@ validator = Validation.fromInfo ( name, msg, opts ) in case val of - Ok x -> - succeed x + Ok y -> + succeed y Err _ -> - fail ("invalid validator: " ++ toString x) + fail ("invalid validator: " ++ toString y) in JD.keyValuePairs jsonDecoder |> andThen convert From d8bbe8f7ce6f17785d64cf297f5452e6f2f440e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ara=C3=BAjo?= Date: Tue, 14 Nov 2017 17:32:58 -0200 Subject: [PATCH 33/44] Adding ace editor to project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: isaque alves de lima Signed-off-by: Gabriel Araújo Signed-off-by: Gustavo Moreira --- elm-package.json | 6 +++++- package.json | 1 - public/index.html | 2 ++ src/Page/Questions/Code.elm | 15 ++++++++++++--- src/scss/6_components/pages/_question.scss | 8 +++++++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/elm-package.json b/elm-package.json index 10c39eb..34290c9 100644 --- a/elm-package.json +++ b/elm-package.json @@ -17,7 +17,11 @@ "evancz/elm-markdown" : "2.0.0 <= v < 3.0.2", "evancz/url-parser": "2.0.1 <= v < 3.0.0", "iosphere/elm-toast": "1.0.0 <= v < 2.0.0", - "krisajenkins/remotedata": "4.3.0 <= v < 5.0.0" + "krisajenkins/remotedata": "4.3.0 <= v < 5.0.0", + "DenisKolodin/elm-ace": "2.3.0 <= v <= 2.3.0" + }, + "dependency-sources": { + "DenisKolodin/elm-ace": "https://github.com/DenisKolodin/elm-ace.git" }, "elm-version": "0.18.0 <= v < 0.19.0" } diff --git a/package.json b/package.json index 9a9d787..1973181 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ }, "author": "", "license": "GPL-3.0", - "dependencies": {}, "devDependencies": { "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.28.4", diff --git a/public/index.html b/public/index.html index 1eb54d9..cb3e44f 100644 --- a/public/index.html +++ b/public/index.html @@ -13,6 +13,8 @@ + diff --git a/src/Page/Questions/Code.elm b/src/Page/Questions/Code.elm index 6e897d8..b420475 100644 --- a/src/Page/Questions/Code.elm +++ b/src/Page/Questions/Code.elm @@ -11,7 +11,8 @@ import Html.Attributes exposing (..) import Ui.Parts exposing (promoSimple, promoTable, simpleHero) -- import Html.Attributes exposing (..) --- import Html.Events exposing (..) +import Html.Events exposing (..) +import Ace viewDetail : CodeQuestion -> Html msg @@ -35,8 +36,7 @@ pessoa e o ano atual. Calcule e mostre: , option [ value "Java" ] [ text "Java" ] ] , div [ class "item-question" ] - [ textarea [ class "item-question", maxlength 1000, placeholder "Insert your code" ] [] - ] + [ aceEditor] , button [ class "send-button" ] [ text "Send to evaluation" ] ] @@ -56,3 +56,12 @@ question = , selectedLanguage = "" , answer = "" } + + +aceEditor : Html msg +aceEditor = + Ace.toHtml + [ Ace.theme "monokai" + , Ace.mode "lua" + , Ace.value "" + ] [] \ No newline at end of file diff --git a/src/scss/6_components/pages/_question.scss b/src/scss/6_components/pages/_question.scss index 7f88493..2837212 100644 --- a/src/scss/6_components/pages/_question.scss +++ b/src/scss/6_components/pages/_question.scss @@ -102,7 +102,12 @@ height: 30vw; margin: 0 auto; margin-right: 5%; - margin-left: 1.6%; + margin-left: 3%; + + .ace_editor { + width: 100%; + height: 400px; + } } .send-button { @@ -113,6 +118,7 @@ color: white; border-radius: 5px; width: 20%; + margin-top: 30px; margin-right: 5%; margin-left: 64.2%; } From 6ddafbbbf364ab9e4f916dc276a3db88f9f3f0e0 Mon Sep 17 00:00:00 2001 From: isaque alves de lima Date: Tue, 28 Nov 2017 16:29:54 -0200 Subject: [PATCH 34/44] working in the editor's language --- package.json | 3 + public/lib/ace/ace.js | 132 + public/lib/ace/anchor.js | 227 + public/lib/ace/anchor_test.js | 223 + public/lib/ace/apply_delta.js | 108 + public/lib/ace/autocomplete.js | 510 + public/lib/ace/autocomplete/popup.js | 348 + public/lib/ace/autocomplete/text_completer.js | 78 + public/lib/ace/autocomplete/util.js | 89 + public/lib/ace/background_tokenizer.js | 251 + public/lib/ace/background_tokenizer_test.js | 152 + public/lib/ace/bidihandler.js | 338 + public/lib/ace/commands/command_manager.js | 121 + .../lib/ace/commands/command_manager_test.js | 208 + public/lib/ace/commands/default_commands.js | 757 + .../commands/incremental_search_commands.js | 214 + .../lib/ace/commands/multi_select_commands.js | 113 + public/lib/ace/commands/occur_commands.js | 110 + public/lib/ace/config.js | 202 + public/lib/ace/config_test.js | 135 + .../css/codefolding-fold-button-states.png | Bin 0 -> 759 bytes public/lib/ace/css/editor.css | 463 + public/lib/ace/css/expand-marker.png | Bin 0 -> 290 bytes public/lib/ace/document.js | 692 + public/lib/ace/document_test.js | 335 + public/lib/ace/edit_session.js | 2600 + public/lib/ace/edit_session/bracket_match.js | 221 + public/lib/ace/edit_session/fold.js | 140 + public/lib/ace/edit_session/fold_line.js | 269 + public/lib/ace/edit_session/folding.js | 869 + public/lib/ace/edit_session_test.js | 1087 + public/lib/ace/editor.js | 2705 + public/lib/ace/editor_change_document_test.js | 188 + .../editor_highlight_selected_word_test.js | 223 + public/lib/ace/editor_navigation_test.js | 187 + public/lib/ace/editor_text_edit_test.js | 563 + public/lib/ace/ext/beautify.js | 57 + public/lib/ace/ext/beautify/php_rules.js | 366 + public/lib/ace/ext/elastic_tabstops_lite.js | 318 + public/lib/ace/ext/emmet.js | 463 + public/lib/ace/ext/error_marker.js | 217 + public/lib/ace/ext/keybinding_menu.js | 86 + public/lib/ace/ext/language_tools.js | 209 + public/lib/ace/ext/linking.js | 87 + .../ext/menu_tools/add_editor_menu_options.js | 109 + .../ace/ext/menu_tools/element_generator.js | 148 + .../ext/menu_tools/generate_settings_menu.js | 264 + .../get_editor_keyboard_shortcuts.js | 91 + .../ace/ext/menu_tools/get_set_functions.js | 141 + public/lib/ace/ext/menu_tools/overlay_page.js | 116 + .../lib/ace/ext/menu_tools/settings_menu.css | 48 + public/lib/ace/ext/modelist.js | 220 + public/lib/ace/ext/searchbox.css | 162 + public/lib/ace/ext/searchbox.js | 399 + public/lib/ace/ext/settings_menu.js | 76 + public/lib/ace/ext/spellcheck.js | 69 + public/lib/ace/ext/split.js | 40 + public/lib/ace/ext/static.css | 38 + public/lib/ace/ext/static_highlight.js | 191 + public/lib/ace/ext/static_highlight_test.js | 101 + public/lib/ace/ext/statusbar.js | 50 + public/lib/ace/ext/textarea.js | 521 + public/lib/ace/ext/themelist.js | 104 + public/lib/ace/ext/whitespace.js | 243 + public/lib/ace/ext/whitespace_test.js | 206 + public/lib/ace/incremental_search.js | 317 + public/lib/ace/incremental_search_test.js | 213 + public/lib/ace/keyboard/emacs.js | 666 + public/lib/ace/keyboard/emacs_test.js | 173 + public/lib/ace/keyboard/hash_handler.js | 256 + public/lib/ace/keyboard/keybinding.js | 152 + public/lib/ace/keyboard/keybinding_test.js | 69 + public/lib/ace/keyboard/state_handler.js | 249 + public/lib/ace/keyboard/textarea.js | 88 + public/lib/ace/keyboard/textinput.js | 480 + public/lib/ace/keyboard/textinput_ios.js | 530 + public/lib/ace/keyboard/vim.js | 6249 + public/lib/ace/keyboard/vim_test.js | 4122 + public/lib/ace/layer/cursor.js | 243 + public/lib/ace/layer/font_metrics.js | 176 + public/lib/ace/layer/gutter.js | 285 + public/lib/ace/layer/marker.js | 262 + public/lib/ace/layer/text.js | 579 + public/lib/ace/layer/text_test.js | 126 + public/lib/ace/lib/app_config.js | 157 + public/lib/ace/lib/bidiutil.js | 406 + public/lib/ace/lib/dom.js | 286 + public/lib/ace/lib/es5-shim.js | 1062 + public/lib/ace/lib/event.js | 400 + public/lib/ace/lib/event_emitter.js | 155 + public/lib/ace/lib/event_emitter_test.js | 65 + public/lib/ace/lib/fixoldbrowsers.js | 19 + public/lib/ace/lib/keys.js | 163 + public/lib/ace/lib/lang.js | 223 + public/lib/ace/lib/net.js | 51 + public/lib/ace/lib/oop.js | 57 + public/lib/ace/lib/regexp.js | 113 + public/lib/ace/lib/useragent.js | 108 + public/lib/ace/line_widgets.js | 386 + public/lib/ace/mode/_test/Readme.md | 9 + .../ace/mode/_test/highlight_rules_test.js | 250 + public/lib/ace/mode/_test/package.json | 8 + public/lib/ace/mode/_test/text_asciidoc.txt | 111 + public/lib/ace/mode/_test/text_coffee.txt | 57 + public/lib/ace/mode/_test/text_coldfusion.txt | 8 + public/lib/ace/mode/_test/text_curly.txt | 9 + public/lib/ace/mode/_test/text_ejs.txt | 39 + public/lib/ace/mode/_test/text_gobstones.txt | 19 + public/lib/ace/mode/_test/text_html.txt | 10 + public/lib/ace/mode/_test/text_javascript.txt | 100 + public/lib/ace/mode/_test/text_livescript.txt | 1 + public/lib/ace/mode/_test/text_lucene.txt | 16 + public/lib/ace/mode/_test/text_markdown.txt | 22 + public/lib/ace/mode/_test/text_php.txt | 24 + public/lib/ace/mode/_test/text_ruby.txt | 34 + public/lib/ace/mode/_test/text_rust.txt | 36 + public/lib/ace/mode/_test/text_wollok.txt | 28 + public/lib/ace/mode/_test/text_xml.txt | 7 + public/lib/ace/mode/_test/tokens_abap.json | 213 + public/lib/ace/mode/_test/tokens_abc.json | 2207 + .../ace/mode/_test/tokens_actionscript.json | 263 + public/lib/ace/mode/_test/tokens_ada.json | 39 + .../lib/ace/mode/_test/tokens_asciidoc.json | 422 + .../ace/mode/_test/tokens_assembly_x86.json | 114 + .../lib/ace/mode/_test/tokens_autohotkey.json | 261 + .../lib/ace/mode/_test/tokens_batchfile.json | 70 + .../lib/ace/mode/_test/tokens_c9search.json | 131 + public/lib/ace/mode/_test/tokens_c_cpp.json | 201 + public/lib/ace/mode/_test/tokens_cirru.json | 267 + public/lib/ace/mode/_test/tokens_clojure.json | 162 + public/lib/ace/mode/_test/tokens_cobol.json | 4 + public/lib/ace/mode/_test/tokens_coffee.json | 545 + .../lib/ace/mode/_test/tokens_coldfusion.json | 61 + public/lib/ace/mode/_test/tokens_csharp.json | 31 + .../mode/_test/tokens_csound_document.json | 92 + .../mode/_test/tokens_csound_orchestra.json | 514 + .../ace/mode/_test/tokens_csound_score.json | 158 + public/lib/ace/mode/_test/tokens_css.json | 221 + public/lib/ace/mode/_test/tokens_curly.json | 56 + public/lib/ace/mode/_test/tokens_d.json | 111 + public/lib/ace/mode/_test/tokens_dart.json | 368 + public/lib/ace/mode/_test/tokens_diff.json | 262 + public/lib/ace/mode/_test/tokens_dot.json | 2254 + public/lib/ace/mode/_test/tokens_drools.json | 935 + public/lib/ace/mode/_test/tokens_eiffel.json | 141 + public/lib/ace/mode/_test/tokens_ejs.json | 296 + public/lib/ace/mode/_test/tokens_elixir.json | 196 + public/lib/ace/mode/_test/tokens_elm.json | 198 + public/lib/ace/mode/_test/tokens_erlang.json | 166 + public/lib/ace/mode/_test/tokens_forth.json | 219 + public/lib/ace/mode/_test/tokens_fortran.json | 219 + public/lib/ace/mode/_test/tokens_ftl.json | 341 + public/lib/ace/mode/_test/tokens_gcode.json | 296 + public/lib/ace/mode/_test/tokens_gherkin.json | 142 + .../lib/ace/mode/_test/tokens_gitignore.json | 33 + public/lib/ace/mode/_test/tokens_glsl.json | 127 + .../lib/ace/mode/_test/tokens_gobstones.json | 113 + public/lib/ace/mode/_test/tokens_golang.json | 256 + public/lib/ace/mode/_test/tokens_groovy.json | 410 + public/lib/ace/mode/_test/tokens_haml.json | 259 + .../lib/ace/mode/_test/tokens_handlebars.json | 81 + public/lib/ace/mode/_test/tokens_haskell.json | 156 + public/lib/ace/mode/_test/tokens_haxe.json | 143 + public/lib/ace/mode/_test/tokens_html.json | 63 + .../ace/mode/_test/tokens_html_elixir.json | 294 + .../lib/ace/mode/_test/tokens_html_ruby.json | 257 + public/lib/ace/mode/_test/tokens_ini.json | 23 + public/lib/ace/mode/_test/tokens_io.json | 49 + public/lib/ace/mode/_test/tokens_jack.json | 1786 + public/lib/ace/mode/_test/tokens_jade.json | 187 + public/lib/ace/mode/_test/tokens_java.json | 95 + .../lib/ace/mode/_test/tokens_javascript.json | 736 + public/lib/ace/mode/_test/tokens_json.json | 412 + public/lib/ace/mode/_test/tokens_jsoniq.json | 4 + public/lib/ace/mode/_test/tokens_jsp.json | 435 + public/lib/ace/mode/_test/tokens_jsx.json | 51 + public/lib/ace/mode/_test/tokens_julia.json | 111 + public/lib/ace/mode/_test/tokens_latex.json | 127 + public/lib/ace/mode/_test/tokens_less.json | 224 + public/lib/ace/mode/_test/tokens_liquid.json | 551 + public/lib/ace/mode/_test/tokens_lisp.json | 248 + .../lib/ace/mode/_test/tokens_livescript.json | 6 + public/lib/ace/mode/_test/tokens_logiql.json | 190 + public/lib/ace/mode/_test/tokens_lsl.json | 503 + public/lib/ace/mode/_test/tokens_lua.json | 348 + public/lib/ace/mode/_test/tokens_luapage.json | 651 + public/lib/ace/mode/_test/tokens_lucene.json | 92 + .../lib/ace/mode/_test/tokens_markdown.json | 114 + public/lib/ace/mode/_test/tokens_mask.json | 302 + public/lib/ace/mode/_test/tokens_matlab.json | 90 + public/lib/ace/mode/_test/tokens_maze.json | 241 + public/lib/ace/mode/_test/tokens_mel.json | 255 + .../lib/ace/mode/_test/tokens_mushcode.json | 790 + public/lib/ace/mode/_test/tokens_mysql.json | 4 + public/lib/ace/mode/_test/tokens_nix.json | 360 + public/lib/ace/mode/_test/tokens_nsis.json | 133 + .../lib/ace/mode/_test/tokens_objectivec.json | 798 + public/lib/ace/mode/_test/tokens_ocaml.json | 200 + public/lib/ace/mode/_test/tokens_pascal.json | 297 + public/lib/ace/mode/_test/tokens_perl.json | 227 + public/lib/ace/mode/_test/tokens_pgsql.json | 889 + public/lib/ace/mode/_test/tokens_php.json | 171 + .../lib/ace/mode/_test/tokens_powershell.json | 184 + public/lib/ace/mode/_test/tokens_praat.json | 955 + public/lib/ace/mode/_test/tokens_prolog.json | 245 + .../lib/ace/mode/_test/tokens_properties.json | 68 + .../lib/ace/mode/_test/tokens_protobuf.json | 136 + public/lib/ace/mode/_test/tokens_python.json | 152 + public/lib/ace/mode/_test/tokens_r.json | 235 + public/lib/ace/mode/_test/tokens_razor.json | 17 + public/lib/ace/mode/_test/tokens_rdoc.json | 441 + public/lib/ace/mode/_test/tokens_rhtml.json | 106 + public/lib/ace/mode/_test/tokens_ruby.json | 242 + public/lib/ace/mode/_test/tokens_rust.json | 299 + public/lib/ace/mode/_test/tokens_sass.json | 229 + public/lib/ace/mode/_test/tokens_scad.json | 194 + public/lib/ace/mode/_test/tokens_scala.json | 542 + public/lib/ace/mode/_test/tokens_scheme.json | 216 + public/lib/ace/mode/_test/tokens_scss.json | 123 + public/lib/ace/mode/_test/tokens_sh.json | 397 + public/lib/ace/mode/_test/tokens_sjs.json | 276 + public/lib/ace/mode/_test/tokens_smarty.json | 98 + .../lib/ace/mode/_test/tokens_snippets.json | 159 + .../ace/mode/_test/tokens_soy_template.json | 286 + public/lib/ace/mode/_test/tokens_space.json | 322 + public/lib/ace/mode/_test/tokens_sql.json | 54 + .../lib/ace/mode/_test/tokens_sqlserver.json | 457 + public/lib/ace/mode/_test/tokens_stylus.json | 271 + public/lib/ace/mode/_test/tokens_svg.json | 685 + public/lib/ace/mode/_test/tokens_swift.json | 171 + public/lib/ace/mode/_test/tokens_tcl.json | 385 + public/lib/ace/mode/_test/tokens_tex.json | 129 + public/lib/ace/mode/_test/tokens_text.json | 29 + public/lib/ace/mode/_test/tokens_textile.json | 113 + public/lib/ace/mode/_test/tokens_toml.json | 131 + public/lib/ace/mode/_test/tokens_tsx.json | 30 + public/lib/ace/mode/_test/tokens_twig.json | 288 + .../lib/ace/mode/_test/tokens_typescript.json | 563 + public/lib/ace/mode/_test/tokens_vala.json | 158 + .../lib/ace/mode/_test/tokens_vbscript.json | 255 + .../lib/ace/mode/_test/tokens_velocity.json | 287 + public/lib/ace/mode/_test/tokens_verilog.json | 113 + public/lib/ace/mode/_test/tokens_vhdl.json | 271 + public/lib/ace/mode/_test/tokens_wollok.json | 209 + public/lib/ace/mode/_test/tokens_xml.json | 43 + public/lib/ace/mode/_test/tokens_xquery.json | 44 + public/lib/ace/mode/_test/tokens_yaml.json | 167 + public/lib/ace/mode/abap.js | 61 + public/lib/ace/mode/abap_highlight_rules.js | 134 + public/lib/ace/mode/abc.js | 58 + public/lib/ace/mode/abc_highlight_rules.js | 114 + public/lib/ace/mode/actionscript.js | 58 + .../ace/mode/actionscript_highlight_rules.js | 141 + public/lib/ace/mode/ada.js | 54 + public/lib/ace/mode/ada_highlight_rules.js | 93 + public/lib/ace/mode/apache_conf.js | 62 + .../ace/mode/apache_conf_highlight_rules.js | 231 + public/lib/ace/mode/applescript.js | 54 + .../ace/mode/applescript_highlight_rules.js | 139 + public/lib/ace/mode/asciidoc.js | 64 + .../lib/ace/mode/asciidoc_highlight_rules.js | 234 + public/lib/ace/mode/assembly_x86.js | 57 + .../ace/mode/assembly_x86_highlight_rules.js | 114 + public/lib/ace/mode/autohotkey.js | 57 + .../ace/mode/autohotkey_highlight_rules.js | 107 + public/lib/ace/mode/batchfile.js | 62 + .../lib/ace/mode/batchfile_highlight_rules.js | 97 + public/lib/ace/mode/behaviour.js | 90 + .../lib/ace/mode/behaviour/behaviour_test.js | 212 + public/lib/ace/mode/behaviour/css.js | 108 + public/lib/ace/mode/behaviour/cstyle.js | 400 + public/lib/ace/mode/behaviour/html.js | 46 + public/lib/ace/mode/behaviour/xml.js | 208 + public/lib/ace/mode/behaviour/xquery.js | 92 + public/lib/ace/mode/bro.js | 58 + public/lib/ace/mode/bro_highlight_rules.js | 204 + public/lib/ace/mode/c9search.js | 67 + .../lib/ace/mode/c9search_highlight_rules.js | 193 + public/lib/ace/mode/c_cpp.js | 101 + public/lib/ace/mode/c_cpp_highlight_rules.js | 199 + public/lib/ace/mode/cirru.js | 52 + public/lib/ace/mode/cirru_highlight_rules.js | 125 + public/lib/ace/mode/clojure.js | 129 + .../lib/ace/mode/clojure_highlight_rules.js | 200 + public/lib/ace/mode/cobol.js | 53 + public/lib/ace/mode/cobol_highlight_rules.js | 100 + public/lib/ace/mode/coffee.js | 116 + public/lib/ace/mode/coffee/coffee.js | 15 + public/lib/ace/mode/coffee/parser_test.js | 89 + public/lib/ace/mode/coffee_highlight_rules.js | 232 + public/lib/ace/mode/coffee_worker.js | 73 + public/lib/ace/mode/coldfusion.js | 61 + .../ace/mode/coldfusion_highlight_rules.js | 86 + public/lib/ace/mode/coldfusion_test.js | 67 + public/lib/ace/mode/csharp.js | 61 + public/lib/ace/mode/csharp_highlight_rules.js | 98 + public/lib/ace/mode/csound_document.js | 14 + .../mode/csound_document_highlight_rules.js | 66 + public/lib/ace/mode/csound_orchestra.js | 21 + .../mode/csound_orchestra_highlight_rules.js | 1920 + .../csound_preprocessor_highlight_rules.js | 295 + public/lib/ace/mode/csound_score.js | 21 + .../ace/mode/csound_score_highlight_rules.js | 156 + public/lib/ace/mode/css.js | 106 + public/lib/ace/mode/css/csslint.js | 9629 ++ public/lib/ace/mode/css_completions.js | 213 + public/lib/ace/mode/css_highlight_rules.js | 227 + public/lib/ace/mode/css_test.js | 78 + public/lib/ace/mode/css_worker.js | 100 + public/lib/ace/mode/css_worker_test.js | 68 + public/lib/ace/mode/curly.js | 62 + public/lib/ace/mode/curly_highlight_rules.js | 66 + public/lib/ace/mode/d.js | 57 + public/lib/ace/mode/d_highlight_rules.js | 334 + public/lib/ace/mode/dart.js | 62 + public/lib/ace/mode/dart_highlight_rules.js | 184 + public/lib/ace/mode/diff.js | 52 + public/lib/ace/mode/diff_highlight_rules.js | 108 + public/lib/ace/mode/django.js | 114 + .../ace/mode/doc_comment_highlight_rules.js | 79 + public/lib/ace/mode/dockerfile.js | 52 + .../ace/mode/dockerfile_highlight_rules.js | 57 + public/lib/ace/mode/dot.js | 56 + public/lib/ace/mode/dot_highlight_rules.js | 123 + public/lib/ace/mode/drools.js | 55 + public/lib/ace/mode/drools_highlight_rules.js | 261 + public/lib/ace/mode/eiffel.js | 52 + public/lib/ace/mode/eiffel_highlight_rules.js | 136 + public/lib/ace/mode/ejs.js | 97 + public/lib/ace/mode/elixir.js | 58 + public/lib/ace/mode/elixir_highlight_rules.js | 433 + public/lib/ace/mode/elm.js | 58 + public/lib/ace/mode/elm_highlight_rules.js | 167 + public/lib/ace/mode/erlang.js | 57 + public/lib/ace/mode/erlang_highlight_rules.js | 876 + public/lib/ace/mode/folding/asciidoc.js | 142 + public/lib/ace/mode/folding/c9search.js | 83 + public/lib/ace/mode/folding/coffee.js | 120 + public/lib/ace/mode/folding/coffee_test.js | 101 + public/lib/ace/mode/folding/csharp.js | 137 + public/lib/ace/mode/folding/cstyle.js | 192 + public/lib/ace/mode/folding/cstyle_test.js | 109 + public/lib/ace/mode/folding/diff.js | 69 + public/lib/ace/mode/folding/drools.js | 49 + public/lib/ace/mode/folding/fold_mode.js | 120 + public/lib/ace/mode/folding/haskell_cabal.js | 115 + public/lib/ace/mode/folding/html.js | 48 + public/lib/ace/mode/folding/html_test.js | 186 + public/lib/ace/mode/folding/ini.js | 80 + public/lib/ace/mode/folding/latex.js | 180 + public/lib/ace/mode/folding/lua.js | 163 + public/lib/ace/mode/folding/markdown.js | 125 + public/lib/ace/mode/folding/mixed.js | 83 + public/lib/ace/mode/folding/pythonic.js | 58 + public/lib/ace/mode/folding/pythonic_test.js | 98 + public/lib/ace/mode/folding/sqlserver.js | 111 + public/lib/ace/mode/folding/velocity.js | 120 + public/lib/ace/mode/folding/xml.js | 286 + public/lib/ace/mode/folding/xml_test.js | 110 + public/lib/ace/mode/forth.js | 58 + public/lib/ace/mode/forth_highlight_rules.js | 164 + public/lib/ace/mode/fortran.js | 113 + .../lib/ace/mode/fortran_highlight_rules.js | 233 + public/lib/ace/mode/ftl.js | 50 + public/lib/ace/mode/ftl_highlight_rules.js | 194 + public/lib/ace/mode/gcode.js | 52 + public/lib/ace/mode/gcode_highlight_rules.js | 94 + public/lib/ace/mode/gherkin.js | 81 + .../lib/ace/mode/gherkin_highlight_rules.js | 150 + public/lib/ace/mode/gitignore.js | 21 + .../lib/ace/mode/gitignore_highlight_rules.js | 31 + public/lib/ace/mode/glsl.js | 56 + public/lib/ace/mode/glsl_highlight_rules.js | 81 + public/lib/ace/mode/gobstones.js | 26 + .../lib/ace/mode/gobstones_highlight_rules.js | 111 + public/lib/ace/mode/golang.js | 56 + public/lib/ace/mode/golang_highlight_rules.js | 119 + public/lib/ace/mode/graphqlschema.js | 51 + .../ace/mode/graphqlschema_highlight_rules.js | 74 + public/lib/ace/mode/groovy.js | 24 + public/lib/ace/mode/groovy_highlight_rules.js | 172 + public/lib/ace/mode/haml.js | 62 + public/lib/ace/mode/haml_highlight_rules.js | 145 + public/lib/ace/mode/handlebars.js | 26 + .../ace/mode/handlebars_highlight_rules.js | 72 + public/lib/ace/mode/haskell.js | 63 + public/lib/ace/mode/haskell_cabal.js | 61 + .../ace/mode/haskell_cabal_highlight_rules.js | 68 + .../lib/ace/mode/haskell_highlight_rules.js | 246 + public/lib/ace/mode/haxe.js | 56 + public/lib/ace/mode/haxe_highlight_rules.js | 97 + public/lib/ace/mode/hjson.js | 52 + public/lib/ace/mode/hjson_highlight_rules.js | 221 + public/lib/ace/mode/html.js | 106 + public/lib/ace/mode/html/saxparser.js | 10430 ++ public/lib/ace/mode/html_completions.js | 359 + public/lib/ace/mode/html_elixir.js | 59 + .../ace/mode/html_elixir_highlight_rules.js | 84 + public/lib/ace/mode/html_highlight_rules.js | 111 + public/lib/ace/mode/html_ruby.js | 59 + .../lib/ace/mode/html_ruby_highlight_rules.js | 84 + public/lib/ace/mode/html_test.js | 67 + public/lib/ace/mode/html_worker.js | 92 + public/lib/ace/mode/ini.js | 54 + public/lib/ace/mode/ini_highlight_rules.js | 112 + public/lib/ace/mode/io.js | 58 + public/lib/ace/mode/io_highlight_rules.js | 120 + public/lib/ace/mode/jack.js | 79 + public/lib/ace/mode/jack_highlight_rules.js | 142 + public/lib/ace/mode/jade.js | 57 + public/lib/ace/mode/jade_highlight_rules.js | 343 + public/lib/ace/mode/java.js | 24 + public/lib/ace/mode/java_highlight_rules.js | 127 + public/lib/ace/mode/javascript.js | 116 + public/lib/ace/mode/javascript/jshint.js | 12375 ++ .../ace/mode/javascript_highlight_rules.js | 527 + public/lib/ace/mode/javascript_test.js | 213 + public/lib/ace/mode/javascript_worker.js | 185 + public/lib/ace/mode/javascript_worker_test.js | 106 + .../lib/ace/mode/js_regex_highlight_rules.js | 94 + public/lib/ace/mode/json.js | 93 + public/lib/ace/mode/json/json_parse.js | 346 + public/lib/ace/mode/json_highlight_rules.js | 108 + public/lib/ace/mode/json_worker.js | 67 + public/lib/ace/mode/json_worker_test.js | 102 + public/lib/ace/mode/jsoniq.js | 203 + public/lib/ace/mode/jsp.js | 55 + public/lib/ace/mode/jsp_highlight_rules.js | 91 + public/lib/ace/mode/jssm.js | 58 + public/lib/ace/mode/jssm_highlight_rules.js | 193 + public/lib/ace/mode/jsx.js | 56 + public/lib/ace/mode/jsx_highlight_rules.js | 119 + public/lib/ace/mode/julia.js | 63 + public/lib/ace/mode/julia_highlight_rules.js | 170 + public/lib/ace/mode/kotlin.js | 58 + public/lib/ace/mode/kotlin_highlight_rules.js | 663 + public/lib/ace/mode/latex.js | 43 + public/lib/ace/mode/latex_highlight_rules.js | 105 + public/lib/ace/mode/less.js | 92 + public/lib/ace/mode/less_highlight_rules.js | 170 + public/lib/ace/mode/liquid.js | 82 + public/lib/ace/mode/liquid_highlight_rules.js | 131 + public/lib/ace/mode/lisp.js | 57 + public/lib/ace/mode/lisp_highlight_rules.js | 124 + public/lib/ace/mode/livescript.js | 231 + public/lib/ace/mode/logiql.js | 139 + public/lib/ace/mode/logiql_highlight_rules.js | 119 + public/lib/ace/mode/logiql_test.js | 98 + public/lib/ace/mode/lsl.js | 92 + public/lib/ace/mode/lsl_highlight_rules.js | 122 + public/lib/ace/mode/lua.js | 169 + public/lib/ace/mode/lua/luaparse.js | 1989 + public/lib/ace/mode/lua_highlight_rules.js | 190 + public/lib/ace/mode/lua_worker.js | 70 + public/lib/ace/mode/luapage.js | 24 + .../lib/ace/mode/luapage_highlight_rules.js | 49 + public/lib/ace/mode/lucene.js | 20 + public/lib/ace/mode/lucene_highlight_rules.js | 49 + public/lib/ace/mode/makefile.js | 59 + .../lib/ace/mode/makefile_highlight_rules.js | 75 + public/lib/ace/mode/markdown.js | 77 + .../lib/ace/mode/markdown_highlight_rules.js | 228 + public/lib/ace/mode/mask.js | 84 + public/lib/ace/mode/mask_highlight_rules.js | 309 + public/lib/ace/mode/matching_brace_outdent.js | 69 + .../lib/ace/mode/matching_parens_outdent.js | 74 + public/lib/ace/mode/matlab.js | 55 + public/lib/ace/mode/matlab_highlight_rules.js | 262 + public/lib/ace/mode/maze.js | 53 + public/lib/ace/mode/maze_highlight_rules.js | 154 + public/lib/ace/mode/mel.js | 56 + public/lib/ace/mode/mel_highlight_rules.js | 133 + public/lib/ace/mode/mushcode.js | 116 + .../lib/ace/mode/mushcode_highlight_rules.js | 569 + public/lib/ace/mode/mysql.js | 51 + public/lib/ace/mode/mysql_highlight_rules.js | 122 + public/lib/ace/mode/nix.js | 63 + public/lib/ace/mode/nix_highlight_rules.js | 118 + public/lib/ace/mode/nsis.js | 57 + public/lib/ace/mode/nsis_highlight_rules.js | 173 + public/lib/ace/mode/objectivec.js | 62 + .../ace/mode/objectivec_highlight_rules.js | 330 + public/lib/ace/mode/ocaml.js | 98 + public/lib/ace/mode/ocaml_highlight_rules.js | 336 + public/lib/ace/mode/pascal.js | 68 + public/lib/ace/mode/pascal_highlight_rules.js | 127 + public/lib/ace/mode/perl.js | 90 + public/lib/ace/mode/perl_highlight_rules.js | 165 + public/lib/ace/mode/pgsql.js | 59 + public/lib/ace/mode/pgsql_highlight_rules.js | 616 + public/lib/ace/mode/php.js | 167 + public/lib/ace/mode/php/php.js | 2275 + public/lib/ace/mode/php_completions.js | 9400 ++ public/lib/ace/mode/php_highlight_rules.js | 1100 + public/lib/ace/mode/php_test.js | 65 + public/lib/ace/mode/php_worker.js | 77 + public/lib/ace/mode/pig.js | 58 + public/lib/ace/mode/pig_highlight_rules.js | 178 + public/lib/ace/mode/plain_text.js | 55 + public/lib/ace/mode/plain_text_test.js | 56 + public/lib/ace/mode/powershell.js | 61 + .../ace/mode/powershell_highlight_rules.js | 259 + public/lib/ace/mode/praat.js | 84 + public/lib/ace/mode/praat_highlight_rules.js | 269 + public/lib/ace/mode/prolog.js | 62 + public/lib/ace/mode/prolog_highlight_rules.js | 238 + public/lib/ace/mode/properties.js | 49 + .../ace/mode/properties_highlight_rules.js | 86 + public/lib/ace/mode/protobuf.js | 63 + .../lib/ace/mode/protobuf_highlight_rules.js | 65 + public/lib/ace/mode/python.js | 114 + public/lib/ace/mode/python_highlight_rules.js | 191 + public/lib/ace/mode/python_test.js | 79 + public/lib/ace/mode/r.js | 153 + public/lib/ace/mode/r_highlight_rules.js | 208 + public/lib/ace/mode/razor.js | 33 + public/lib/ace/mode/razor_completions.js | 112 + public/lib/ace/mode/razor_highlight_rules.js | 160 + public/lib/ace/mode/rdoc.js | 61 + public/lib/ace/mode/rdoc_highlight_rules.js | 119 + public/lib/ace/mode/red.js | 98 + public/lib/ace/mode/red_highlight_rules.js | 233 + public/lib/ace/mode/rhtml.js | 87 + public/lib/ace/mode/rhtml_highlight_rules.js | 66 + public/lib/ace/mode/rst.js | 51 + public/lib/ace/mode/rst_highlight_rules.js | 296 + public/lib/ace/mode/ruby.js | 100 + public/lib/ace/mode/ruby_highlight_rules.js | 331 + public/lib/ace/mode/ruby_test.js | 77 + public/lib/ace/mode/rust.js | 59 + public/lib/ace/mode/rust_highlight_rules.js | 147 + public/lib/ace/mode/sass.js | 53 + public/lib/ace/mode/sass_highlight_rules.js | 79 + public/lib/ace/mode/scad.js | 98 + public/lib/ace/mode/scad_highlight_rules.js | 141 + public/lib/ace/mode/scala.js | 24 + public/lib/ace/mode/scala_highlight_rules.js | 165 + public/lib/ace/mode/scheme.js | 134 + public/lib/ace/mode/scheme_highlight_rules.js | 123 + public/lib/ace/mode/scss.js | 84 + public/lib/ace/mode/scss_highlight_rules.js | 317 + public/lib/ace/mode/sh.js | 116 + public/lib/ace/mode/sh_highlight_rules.js | 249 + public/lib/ace/mode/sjs.js | 56 + public/lib/ace/mode/sjs_highlight_rules.js | 233 + public/lib/ace/mode/smarty.js | 51 + public/lib/ace/mode/smarty_highlight_rules.js | 139 + public/lib/ace/mode/snippets.js | 114 + public/lib/ace/mode/soy_template.js | 52 + .../ace/mode/soy_template_highlight_rules.js | 355 + public/lib/ace/mode/space.js | 22 + public/lib/ace/mode/space_highlight_rules.js | 56 + public/lib/ace/mode/sparql.js | 57 + public/lib/ace/mode/sparql_highlight_rules.js | 190 + public/lib/ace/mode/sql.js | 53 + public/lib/ace/mode/sql_highlight_rules.js | 110 + public/lib/ace/mode/sqlserver.js | 62 + .../lib/ace/mode/sqlserver_highlight_rules.js | 232 + public/lib/ace/mode/stylus.js | 63 + public/lib/ace/mode/stylus_highlight_rules.js | 164 + public/lib/ace/mode/svg.js | 69 + public/lib/ace/mode/svg_highlight_rules.js | 49 + public/lib/ace/mode/swift.js | 61 + public/lib/ace/mode/swift_highlight_rules.js | 196 + public/lib/ace/mode/tcl.js | 85 + public/lib/ace/mode/tcl_highlight_rules.js | 172 + public/lib/ace/mode/tex.js | 70 + public/lib/ace/mode/tex_highlight_rules.js | 127 + public/lib/ace/mode/text.js | 385 + public/lib/ace/mode/text_highlight_rules.js | 239 + public/lib/ace/mode/text_test.js | 64 + public/lib/ace/mode/textile.js | 68 + .../lib/ace/mode/textile_highlight_rules.js | 93 + public/lib/ace/mode/toml.js | 57 + public/lib/ace/mode/toml_highlight_rules.js | 107 + public/lib/ace/mode/tsx.js | 52 + public/lib/ace/mode/turtle.js | 57 + public/lib/ace/mode/turtle_highlight_rules.js | 166 + public/lib/ace/mode/twig.js | 81 + public/lib/ace/mode/twig_highlight_rules.js | 166 + public/lib/ace/mode/typescript.js | 62 + .../ace/mode/typescript_highlight_rules.js | 98 + public/lib/ace/mode/vala.js | 105 + public/lib/ace/mode/vala_highlight_rules.js | 457 + public/lib/ace/mode/vbscript.js | 61 + .../lib/ace/mode/vbscript_highlight_rules.js | 222 + public/lib/ace/mode/velocity.js | 58 + .../lib/ace/mode/velocity_highlight_rules.js | 177 + public/lib/ace/mode/verilog.js | 55 + .../lib/ace/mode/verilog_highlight_rules.js | 109 + public/lib/ace/mode/vhdl.js | 52 + public/lib/ace/mode/vhdl_highlight_rules.js | 115 + public/lib/ace/mode/wollok.js | 25 + public/lib/ace/mode/wollok_highlight_rules.js | 96 + public/lib/ace/mode/xml.js | 75 + public/lib/ace/mode/xml/dom-parser.js | 260 + public/lib/ace/mode/xml/dom.js | 1138 + public/lib/ace/mode/xml/sax.js | 592 + public/lib/ace/mode/xml_highlight_rules.js | 238 + public/lib/ace/mode/xml_test.js | 75 + public/lib/ace/mode/xml_worker.js | 92 + public/lib/ace/mode/xquery.js | 216 + public/lib/ace/mode/xquery/Readme.md | 1 + public/lib/ace/mode/xquery/jsoniq_lexer.js | 4469 + public/lib/ace/mode/xquery/xqlint.js | 99801 ++++++++++++++++ public/lib/ace/mode/xquery/xquery_lexer.js | 4438 + public/lib/ace/mode/xquery_worker.js | 116 + public/lib/ace/mode/yaml.js | 79 + public/lib/ace/mode/yaml_highlight_rules.js | 148 + public/lib/ace/model/editor.js | 62 + .../lib/ace/mouse/default_gutter_handler.js | 183 + public/lib/ace/mouse/default_handlers.js | 329 + public/lib/ace/mouse/dragdrop_handler.js | 428 + public/lib/ace/mouse/fold_handler.js | 93 + public/lib/ace/mouse/mouse_event.js | 129 + public/lib/ace/mouse/mouse_handler.js | 213 + public/lib/ace/mouse/mouse_handler_test.js | 77 + public/lib/ace/mouse/multi_select_handler.js | 211 + public/lib/ace/multi_select.js | 982 + public/lib/ace/multi_select_test.js | 285 + public/lib/ace/occur.js | 193 + public/lib/ace/occur_test.js | 154 + public/lib/ace/placeholder.js | 262 + public/lib/ace/placeholder_test.js | 157 + public/lib/ace/range.js | 549 + public/lib/ace/range_list.js | 239 + public/lib/ace/range_list_test.js | 182 + public/lib/ace/range_test.js | 191 + public/lib/ace/renderloop.js | 75 + public/lib/ace/requirejs/text.js | 52 + public/lib/ace/requirejs/text_build.js | 60 + public/lib/ace/scrollbar.js | 286 + public/lib/ace/search.js | 407 + public/lib/ace/search_highlight.js | 82 + public/lib/ace/search_test.js | 525 + public/lib/ace/selection.js | 994 + public/lib/ace/selection_test.js | 480 + public/lib/ace/snippets.js | 954 + public/lib/ace/snippets/_.snippets | 240 + public/lib/ace/snippets/_all_modes.js | 7 + public/lib/ace/snippets/_all_modes.snippets | 0 public/lib/ace/snippets/abap.js | 7 + public/lib/ace/snippets/abap.snippets | 0 public/lib/ace/snippets/abc.js | 7 + public/lib/ace/snippets/abc.snippets | 31 + public/lib/ace/snippets/actionscript.js | 7 + public/lib/ace/snippets/actionscript.snippets | 157 + public/lib/ace/snippets/ada.js | 7 + public/lib/ace/snippets/ada.snippets | 0 public/lib/ace/snippets/all_modes.js | 7 + public/lib/ace/snippets/all_modes.snippets | 0 public/lib/ace/snippets/apache.snippets | 35 + public/lib/ace/snippets/apache_conf.js | 7 + public/lib/ace/snippets/apache_conf.snippets | 0 public/lib/ace/snippets/applescript.js | 7 + public/lib/ace/snippets/applescript.snippets | 0 public/lib/ace/snippets/asciidoc.js | 7 + public/lib/ace/snippets/asciidoc.snippets | 0 public/lib/ace/snippets/assembly_x86.js | 7 + public/lib/ace/snippets/assembly_x86.snippets | 0 public/lib/ace/snippets/autohotkey.js | 7 + public/lib/ace/snippets/autohotkey.snippets | 0 public/lib/ace/snippets/autoit.snippets | 66 + public/lib/ace/snippets/batchfile.js | 7 + public/lib/ace/snippets/batchfile.snippets | 0 public/lib/ace/snippets/bro.js | 7 + public/lib/ace/snippets/c.snippets | 235 + public/lib/ace/snippets/c9search.js | 7 + public/lib/ace/snippets/c9search.snippets | 0 public/lib/ace/snippets/c_cpp.js | 7 + public/lib/ace/snippets/c_cpp.snippets | 131 + public/lib/ace/snippets/chef.snippets | 204 + public/lib/ace/snippets/cirru.js | 7 + public/lib/ace/snippets/cirru.snippets | 0 public/lib/ace/snippets/clojure.js | 7 + public/lib/ace/snippets/clojure.snippets | 90 + public/lib/ace/snippets/cmake.snippets | 58 + public/lib/ace/snippets/cobol.js | 7 + public/lib/ace/snippets/cobol.snippets | 0 public/lib/ace/snippets/coffee.js | 7 + public/lib/ace/snippets/coffee.snippets | 95 + public/lib/ace/snippets/coldfusion.js | 7 + public/lib/ace/snippets/coldfusion.snippets | 0 public/lib/ace/snippets/cs.snippets | 374 + public/lib/ace/snippets/csharp.js | 7 + public/lib/ace/snippets/csharp.snippets | 0 public/lib/ace/snippets/csound_document.js | 7 + .../lib/ace/snippets/csound_document.snippets | 10 + public/lib/ace/snippets/csound_orchestra.js | 7 + .../ace/snippets/csound_orchestra.snippets | 47 + public/lib/ace/snippets/csound_score.js | 7 + public/lib/ace/snippets/csound_score.snippets | 0 public/lib/ace/snippets/css.js | 7 + public/lib/ace/snippets/css.snippets | 967 + public/lib/ace/snippets/curly.js | 7 + public/lib/ace/snippets/curly.snippets | 0 public/lib/ace/snippets/d.js | 7 + public/lib/ace/snippets/d.snippets | 0 public/lib/ace/snippets/dart.js | 7 + public/lib/ace/snippets/dart.snippets | 83 + public/lib/ace/snippets/diff.js | 7 + public/lib/ace/snippets/diff.snippets | 11 + public/lib/ace/snippets/django.js | 7 + public/lib/ace/snippets/django.snippets | 108 + public/lib/ace/snippets/dockerfile.js | 7 + public/lib/ace/snippets/dockerfile.snippets | 0 public/lib/ace/snippets/dot.js | 7 + public/lib/ace/snippets/dot.snippets | 0 public/lib/ace/snippets/drools.js | 7 + public/lib/ace/snippets/drools.snippets | 19 + public/lib/ace/snippets/dummy.js | 7 + public/lib/ace/snippets/dummy_syntax.js | 7 + public/lib/ace/snippets/eiffel.js | 7 + public/lib/ace/snippets/eiffel.snippets | 0 public/lib/ace/snippets/ejs.js | 7 + public/lib/ace/snippets/ejs.snippets | 0 public/lib/ace/snippets/elixir.js | 7 + public/lib/ace/snippets/elixir.snippets | 0 public/lib/ace/snippets/elm.js | 7 + public/lib/ace/snippets/elm.snippets | 0 public/lib/ace/snippets/erlang.js | 7 + public/lib/ace/snippets/erlang.snippets | 160 + public/lib/ace/snippets/eruby.snippets | 113 + public/lib/ace/snippets/falcon.snippets | 71 + public/lib/ace/snippets/forth.js | 7 + public/lib/ace/snippets/forth.snippets | 0 public/lib/ace/snippets/ftl.js | 7 + public/lib/ace/snippets/ftl.snippets | 0 public/lib/ace/snippets/gcode.js | 7 + public/lib/ace/snippets/gcode.snippets | 0 public/lib/ace/snippets/gherkin.js | 7 + public/lib/ace/snippets/gherkin.snippets | 0 public/lib/ace/snippets/gitignore.js | 7 + public/lib/ace/snippets/gitignore.snippets | 0 public/lib/ace/snippets/glsl.js | 7 + public/lib/ace/snippets/glsl.snippets | 0 public/lib/ace/snippets/go.snippets | 201 + public/lib/ace/snippets/gobstones.js | 7 + public/lib/ace/snippets/gobstones.snippets | 34 + public/lib/ace/snippets/golang.js | 7 + public/lib/ace/snippets/golang.snippets | 0 public/lib/ace/snippets/graphqlschema.js | 7 + .../lib/ace/snippets/graphqlschema.snippets | 32 + public/lib/ace/snippets/groovy.js | 7 + public/lib/ace/snippets/groovy.snippets | 0 public/lib/ace/snippets/haml.js | 7 + public/lib/ace/snippets/haml.snippets | 20 + public/lib/ace/snippets/handlebars.js | 7 + public/lib/ace/snippets/handlebars.snippets | 0 public/lib/ace/snippets/haskell.js | 7 + public/lib/ace/snippets/haskell.snippets | 82 + public/lib/ace/snippets/haxe.js | 7 + public/lib/ace/snippets/haxe.snippets | 0 public/lib/ace/snippets/hjson.js | 7 + public/lib/ace/snippets/html.js | 7 + public/lib/ace/snippets/html.snippets | 855 + public/lib/ace/snippets/html_elixir.js | 7 + public/lib/ace/snippets/html_elixir.snippets | 0 public/lib/ace/snippets/html_ruby.js | 7 + public/lib/ace/snippets/html_ruby.snippets | 0 public/lib/ace/snippets/htmldjango.snippets | 136 + public/lib/ace/snippets/htmltornado.snippets | 55 + public/lib/ace/snippets/ini.js | 7 + public/lib/ace/snippets/ini.snippets | 0 public/lib/ace/snippets/io.js | 69 + public/lib/ace/snippets/io.snippets | 0 public/lib/ace/snippets/jack.js | 7 + public/lib/ace/snippets/jack.snippets | 0 public/lib/ace/snippets/jade.js | 7 + public/lib/ace/snippets/jade.snippets | 0 public/lib/ace/snippets/java.js | 7 + public/lib/ace/snippets/java.snippets | 240 + .../ace/snippets/javascript-jquery.snippets | 589 + public/lib/ace/snippets/javascript.js | 7 + public/lib/ace/snippets/javascript.snippets | 195 + public/lib/ace/snippets/json.js | 7 + public/lib/ace/snippets/json.snippets | 0 public/lib/ace/snippets/jsoniq.js | 7 + public/lib/ace/snippets/jsoniq.snippets | 61 + public/lib/ace/snippets/jsp.js | 7 + public/lib/ace/snippets/jsp.snippets | 99 + public/lib/ace/snippets/jssm.js | 7 + public/lib/ace/snippets/jssm.snippets | 0 public/lib/ace/snippets/jsx.js | 7 + public/lib/ace/snippets/jsx.snippets | 0 public/lib/ace/snippets/julia.js | 7 + public/lib/ace/snippets/julia.snippets | 0 public/lib/ace/snippets/kotlin.js | 7 + public/lib/ace/snippets/latex.js | 7 + public/lib/ace/snippets/latex.snippets | 0 public/lib/ace/snippets/ledger.snippets | 5 + public/lib/ace/snippets/less.js | 7 + public/lib/ace/snippets/less.snippets | 0 public/lib/ace/snippets/liquid.js | 7 + public/lib/ace/snippets/liquid.snippets | 0 public/lib/ace/snippets/lisp.js | 7 + public/lib/ace/snippets/lisp.snippets | 0 public/lib/ace/snippets/livescript.js | 7 + public/lib/ace/snippets/livescript.snippets | 0 public/lib/ace/snippets/logiql.js | 7 + public/lib/ace/snippets/logiql.snippets | 0 public/lib/ace/snippets/lsl.js | 7 + public/lib/ace/snippets/lsl.snippets | 1232 + public/lib/ace/snippets/lua.js | 7 + public/lib/ace/snippets/lua.snippets | 21 + public/lib/ace/snippets/luapage.js | 7 + public/lib/ace/snippets/luapage.snippets | 0 public/lib/ace/snippets/lucene.js | 7 + public/lib/ace/snippets/lucene.snippets | 0 public/lib/ace/snippets/makefile.js | 7 + public/lib/ace/snippets/makefile.snippets | 4 + public/lib/ace/snippets/mako.snippets | 54 + public/lib/ace/snippets/markdown.js | 7 + public/lib/ace/snippets/markdown.snippets | 88 + public/lib/ace/snippets/matlab.js | 7 + public/lib/ace/snippets/matlab.snippets | 0 public/lib/ace/snippets/maze.js | 7 + public/lib/ace/snippets/maze.snippets | 9 + public/lib/ace/snippets/mel.js | 7 + public/lib/ace/snippets/mel.snippets | 0 public/lib/ace/snippets/mushcode.js | 7 + public/lib/ace/snippets/mushcode.snippets | 0 .../lib/ace/snippets/mushcode_high_rules.js | 7 + .../ace/snippets/mushcode_high_rules.snippets | 0 public/lib/ace/snippets/mysql.js | 7 + public/lib/ace/snippets/mysql.snippets | 0 public/lib/ace/snippets/nix.js | 7 + public/lib/ace/snippets/nix.snippets | 0 public/lib/ace/snippets/nsis.js | 7 + public/lib/ace/snippets/objc.snippets | 247 + public/lib/ace/snippets/objectivec.js | 7 + public/lib/ace/snippets/objectivec.snippets | 0 public/lib/ace/snippets/ocaml.js | 7 + public/lib/ace/snippets/ocaml.snippets | 0 public/lib/ace/snippets/pascal.js | 7 + public/lib/ace/snippets/pascal.snippets | 0 public/lib/ace/snippets/perl.js | 7 + public/lib/ace/snippets/perl.snippets | 347 + public/lib/ace/snippets/pgsql.js | 7 + public/lib/ace/snippets/pgsql.snippets | 0 public/lib/ace/snippets/php.js | 7 + public/lib/ace/snippets/php.snippets | 377 + public/lib/ace/snippets/plain_text.js | 7 + public/lib/ace/snippets/plain_text.snippets | 0 public/lib/ace/snippets/powershell.js | 7 + public/lib/ace/snippets/powershell.snippets | 0 public/lib/ace/snippets/praat.js | 7 + public/lib/ace/snippets/praat.snippets | 0 public/lib/ace/snippets/prolog.js | 7 + public/lib/ace/snippets/prolog.snippets | 0 public/lib/ace/snippets/properties.js | 7 + public/lib/ace/snippets/properties.snippets | 0 public/lib/ace/snippets/protobuf.js | 7 + public/lib/ace/snippets/protobuf.snippets | 0 public/lib/ace/snippets/python.js | 7 + public/lib/ace/snippets/python.snippets | 158 + public/lib/ace/snippets/r.js | 7 + public/lib/ace/snippets/r.snippets | 121 + public/lib/ace/snippets/razor.js | 7 + public/lib/ace/snippets/razor.snippets | 4 + public/lib/ace/snippets/rdoc.js | 7 + public/lib/ace/snippets/rdoc.snippets | 0 public/lib/ace/snippets/red.js | 7 + public/lib/ace/snippets/red.snippets | 1 + public/lib/ace/snippets/rhtml.js | 7 + public/lib/ace/snippets/rhtml.snippets | 0 public/lib/ace/snippets/rst.snippets | 22 + public/lib/ace/snippets/ruby.js | 7 + public/lib/ace/snippets/ruby.snippets | 928 + public/lib/ace/snippets/rust.js | 7 + public/lib/ace/snippets/rust.snippets | 0 public/lib/ace/snippets/sass.js | 7 + public/lib/ace/snippets/sass.snippets | 0 public/lib/ace/snippets/scad.js | 7 + public/lib/ace/snippets/scad.snippets | 0 public/lib/ace/snippets/scala.js | 7 + public/lib/ace/snippets/scala.snippets | 0 public/lib/ace/snippets/scheme.js | 7 + public/lib/ace/snippets/scheme.snippets | 0 public/lib/ace/snippets/scss.js | 7 + public/lib/ace/snippets/scss.snippets | 0 public/lib/ace/snippets/sh.js | 7 + public/lib/ace/snippets/sh.snippets | 83 + public/lib/ace/snippets/sjs.js | 7 + public/lib/ace/snippets/sjs.snippets | 0 public/lib/ace/snippets/smarty.js | 7 + public/lib/ace/snippets/smarty.snippets | 0 public/lib/ace/snippets/snippets.js | 7 + public/lib/ace/snippets/snippets.snippets | 9 + public/lib/ace/snippets/soy_template.js | 7 + public/lib/ace/snippets/soy_template.snippets | 0 public/lib/ace/snippets/space.js | 7 + public/lib/ace/snippets/space.snippets | 0 public/lib/ace/snippets/sparql.js | 7 + public/lib/ace/snippets/sql.js | 7 + public/lib/ace/snippets/sql.snippets | 26 + public/lib/ace/snippets/sqlserver.js | 7 + public/lib/ace/snippets/sqlserver.snippets | 70 + public/lib/ace/snippets/stylus.js | 7 + public/lib/ace/snippets/stylus.snippets | 0 public/lib/ace/snippets/svg.js | 7 + public/lib/ace/snippets/svg.snippets | 0 public/lib/ace/snippets/tcl.js | 7 + public/lib/ace/snippets/tcl.snippets | 92 + public/lib/ace/snippets/tex.js | 7 + public/lib/ace/snippets/tex.snippets | 191 + public/lib/ace/snippets/text.js | 7 + public/lib/ace/snippets/text.snippets | 0 public/lib/ace/snippets/textile.js | 7 + public/lib/ace/snippets/textile.snippets | 30 + public/lib/ace/snippets/tmsnippet.snippets | 0 public/lib/ace/snippets/toml.js | 7 + public/lib/ace/snippets/toml.snippets | 0 public/lib/ace/snippets/turtle.js | 7 + public/lib/ace/snippets/twig.js | 7 + public/lib/ace/snippets/twig.snippets | 0 public/lib/ace/snippets/typescript.js | 7 + public/lib/ace/snippets/typescript.snippets | 0 public/lib/ace/snippets/vala.js | 195 + public/lib/ace/snippets/vala.snippets | 0 public/lib/ace/snippets/vbscript.js | 7 + public/lib/ace/snippets/vbscript.snippets | 0 public/lib/ace/snippets/velocity.js | 8 + public/lib/ace/snippets/velocity.snippets | 28 + public/lib/ace/snippets/verilog.js | 7 + public/lib/ace/snippets/verilog.snippets | 0 public/lib/ace/snippets/vhdl.js | 7 + public/lib/ace/snippets/vhdl.snippets | 0 public/lib/ace/snippets/wollok.js | 7 + public/lib/ace/snippets/wollok.snippets | 85 + public/lib/ace/snippets/xml.js | 7 + public/lib/ace/snippets/xml.snippets | 0 public/lib/ace/snippets/xquery.js | 7 + public/lib/ace/snippets/xquery.snippets | 61 + public/lib/ace/snippets/xslt.snippets | 97 + public/lib/ace/snippets/yaml.js | 7 + public/lib/ace/snippets/yaml.snippets | 0 public/lib/ace/snippets_test.js | 137 + public/lib/ace/split.js | 373 + public/lib/ace/test/all.js | 35 + public/lib/ace/test/all_browser.js | 168 + public/lib/ace/test/assertions.js | 56 + public/lib/ace/test/asyncjs/assert.js | 313 + public/lib/ace/test/asyncjs/async.js | 529 + public/lib/ace/test/asyncjs/index.js | 13 + public/lib/ace/test/asyncjs/test.js | 195 + public/lib/ace/test/asyncjs/utils.js | 65 + public/lib/ace/test/benchmark.js | 78 + public/lib/ace/test/mockdom.js | 10 + public/lib/ace/test/mockrenderer.js | 210 + public/lib/ace/test/tests.html | 46 + public/lib/ace/theme/ambiance.css | 221 + public/lib/ace/theme/ambiance.js | 33 + public/lib/ace/theme/chaos.css | 154 + public/lib/ace/theme/chaos.js | 33 + public/lib/ace/theme/chrome.css | 154 + public/lib/ace/theme/chrome.js | 39 + public/lib/ace/theme/clouds.css | 111 + public/lib/ace/theme/clouds.js | 39 + public/lib/ace/theme/clouds_midnight.css | 112 + public/lib/ace/theme/clouds_midnight.js | 39 + public/lib/ace/theme/cobalt.css | 133 + public/lib/ace/theme/cobalt.js | 39 + public/lib/ace/theme/crimson_editor.css | 143 + public/lib/ace/theme/crimson_editor.js | 39 + public/lib/ace/theme/dawn.css | 126 + public/lib/ace/theme/dawn.js | 39 + public/lib/ace/theme/dracula.css | 153 + public/lib/ace/theme/dracula.js | 39 + public/lib/ace/theme/dreamweaver.css | 176 + public/lib/ace/theme/dreamweaver.js | 38 + public/lib/ace/theme/eclipse.css | 113 + public/lib/ace/theme/eclipse.js | 41 + public/lib/ace/theme/github.css | 124 + public/lib/ace/theme/github.js | 39 + public/lib/ace/theme/gob.css | 130 + public/lib/ace/theme/gob.js | 39 + public/lib/ace/theme/gruvbox.css | 95 + public/lib/ace/theme/gruvbox.js | 33 + public/lib/ace/theme/idle_fingers.css | 112 + public/lib/ace/theme/idle_fingers.js | 39 + public/lib/ace/theme/iplastic.css | 140 + public/lib/ace/theme/iplastic.js | 40 + public/lib/ace/theme/katzenmilch.css | 143 + public/lib/ace/theme/katzenmilch.js | 39 + public/lib/ace/theme/kr_theme.css | 123 + public/lib/ace/theme/kr_theme.js | 39 + public/lib/ace/theme/kuroir.css | 70 + public/lib/ace/theme/kuroir.js | 39 + public/lib/ace/theme/merbivore.css | 109 + public/lib/ace/theme/merbivore.js | 39 + public/lib/ace/theme/merbivore_soft.css | 110 + public/lib/ace/theme/merbivore_soft.js | 39 + public/lib/ace/theme/mono_industrial.css | 125 + public/lib/ace/theme/mono_industrial.js | 39 + public/lib/ace/theme/monokai.css | 121 + public/lib/ace/theme/monokai.js | 39 + public/lib/ace/theme/pastel_on_dark.css | 128 + public/lib/ace/theme/pastel_on_dark.js | 39 + public/lib/ace/theme/solarized_dark.css | 100 + public/lib/ace/theme/solarized_dark.js | 39 + public/lib/ace/theme/solarized_light.css | 105 + public/lib/ace/theme/solarized_light.js | 39 + public/lib/ace/theme/sqlserver.css | 167 + public/lib/ace/theme/sqlserver.js | 39 + public/lib/ace/theme/terminal.css | 131 + public/lib/ace/theme/terminal.js | 39 + public/lib/ace/theme/textmate.css | 154 + public/lib/ace/theme/textmate.js | 40 + public/lib/ace/theme/tomorrow.css | 124 + public/lib/ace/theme/tomorrow.js | 39 + public/lib/ace/theme/tomorrow_night.css | 124 + public/lib/ace/theme/tomorrow_night.js | 39 + public/lib/ace/theme/tomorrow_night_blue.css | 121 + public/lib/ace/theme/tomorrow_night_blue.js | 39 + .../lib/ace/theme/tomorrow_night_bright.css | 140 + public/lib/ace/theme/tomorrow_night_bright.js | 39 + .../lib/ace/theme/tomorrow_night_eighties.css | 124 + .../lib/ace/theme/tomorrow_night_eighties.js | 39 + public/lib/ace/theme/twilight.css | 127 + public/lib/ace/theme/twilight.js | 39 + public/lib/ace/theme/vibrant_ink.css | 109 + public/lib/ace/theme/vibrant_ink.js | 39 + public/lib/ace/theme/xcode.css | 102 + public/lib/ace/theme/xcode.js | 39 + public/lib/ace/token_iterator.js | 168 + public/lib/ace/token_iterator_test.js | 212 + public/lib/ace/tokenizer.js | 369 + public/lib/ace/tokenizer_dev.js | 185 + public/lib/ace/tokenizer_test.js | 97 + public/lib/ace/tooltip.js | 145 + public/lib/ace/undomanager.js | 215 + public/lib/ace/unicode.js | 107 + public/lib/ace/virtual_renderer.js | 1772 + public/lib/ace/virtual_renderer_test.js | 113 + public/lib/ace/worker/mirror.js | 62 + public/lib/ace/worker/worker.js | 218 + public/lib/ace/worker/worker_client.js | 257 + public/lib/ace/worker/worker_test.js | 125 + src/Page/Questions/Code.elm | 85 +- src/scss/6_components/pages/_question.scss | 5 +- 1041 files changed, 312113 insertions(+), 27 deletions(-) create mode 100644 public/lib/ace/ace.js create mode 100644 public/lib/ace/anchor.js create mode 100644 public/lib/ace/anchor_test.js create mode 100644 public/lib/ace/apply_delta.js create mode 100644 public/lib/ace/autocomplete.js create mode 100644 public/lib/ace/autocomplete/popup.js create mode 100644 public/lib/ace/autocomplete/text_completer.js create mode 100644 public/lib/ace/autocomplete/util.js create mode 100644 public/lib/ace/background_tokenizer.js create mode 100644 public/lib/ace/background_tokenizer_test.js create mode 100644 public/lib/ace/bidihandler.js create mode 100644 public/lib/ace/commands/command_manager.js create mode 100644 public/lib/ace/commands/command_manager_test.js create mode 100644 public/lib/ace/commands/default_commands.js create mode 100644 public/lib/ace/commands/incremental_search_commands.js create mode 100644 public/lib/ace/commands/multi_select_commands.js create mode 100644 public/lib/ace/commands/occur_commands.js create mode 100644 public/lib/ace/config.js create mode 100644 public/lib/ace/config_test.js create mode 100644 public/lib/ace/css/codefolding-fold-button-states.png create mode 100644 public/lib/ace/css/editor.css create mode 100644 public/lib/ace/css/expand-marker.png create mode 100644 public/lib/ace/document.js create mode 100644 public/lib/ace/document_test.js create mode 100644 public/lib/ace/edit_session.js create mode 100644 public/lib/ace/edit_session/bracket_match.js create mode 100644 public/lib/ace/edit_session/fold.js create mode 100644 public/lib/ace/edit_session/fold_line.js create mode 100644 public/lib/ace/edit_session/folding.js create mode 100644 public/lib/ace/edit_session_test.js create mode 100644 public/lib/ace/editor.js create mode 100644 public/lib/ace/editor_change_document_test.js create mode 100644 public/lib/ace/editor_highlight_selected_word_test.js create mode 100644 public/lib/ace/editor_navigation_test.js create mode 100644 public/lib/ace/editor_text_edit_test.js create mode 100644 public/lib/ace/ext/beautify.js create mode 100644 public/lib/ace/ext/beautify/php_rules.js create mode 100644 public/lib/ace/ext/elastic_tabstops_lite.js create mode 100644 public/lib/ace/ext/emmet.js create mode 100644 public/lib/ace/ext/error_marker.js create mode 100644 public/lib/ace/ext/keybinding_menu.js create mode 100644 public/lib/ace/ext/language_tools.js create mode 100644 public/lib/ace/ext/linking.js create mode 100644 public/lib/ace/ext/menu_tools/add_editor_menu_options.js create mode 100644 public/lib/ace/ext/menu_tools/element_generator.js create mode 100644 public/lib/ace/ext/menu_tools/generate_settings_menu.js create mode 100644 public/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js create mode 100644 public/lib/ace/ext/menu_tools/get_set_functions.js create mode 100644 public/lib/ace/ext/menu_tools/overlay_page.js create mode 100644 public/lib/ace/ext/menu_tools/settings_menu.css create mode 100644 public/lib/ace/ext/modelist.js create mode 100644 public/lib/ace/ext/searchbox.css create mode 100644 public/lib/ace/ext/searchbox.js create mode 100644 public/lib/ace/ext/settings_menu.js create mode 100644 public/lib/ace/ext/spellcheck.js create mode 100644 public/lib/ace/ext/split.js create mode 100644 public/lib/ace/ext/static.css create mode 100644 public/lib/ace/ext/static_highlight.js create mode 100644 public/lib/ace/ext/static_highlight_test.js create mode 100644 public/lib/ace/ext/statusbar.js create mode 100644 public/lib/ace/ext/textarea.js create mode 100644 public/lib/ace/ext/themelist.js create mode 100644 public/lib/ace/ext/whitespace.js create mode 100644 public/lib/ace/ext/whitespace_test.js create mode 100644 public/lib/ace/incremental_search.js create mode 100644 public/lib/ace/incremental_search_test.js create mode 100644 public/lib/ace/keyboard/emacs.js create mode 100644 public/lib/ace/keyboard/emacs_test.js create mode 100644 public/lib/ace/keyboard/hash_handler.js create mode 100644 public/lib/ace/keyboard/keybinding.js create mode 100644 public/lib/ace/keyboard/keybinding_test.js create mode 100644 public/lib/ace/keyboard/state_handler.js create mode 100644 public/lib/ace/keyboard/textarea.js create mode 100644 public/lib/ace/keyboard/textinput.js create mode 100644 public/lib/ace/keyboard/textinput_ios.js create mode 100644 public/lib/ace/keyboard/vim.js create mode 100644 public/lib/ace/keyboard/vim_test.js create mode 100644 public/lib/ace/layer/cursor.js create mode 100644 public/lib/ace/layer/font_metrics.js create mode 100644 public/lib/ace/layer/gutter.js create mode 100644 public/lib/ace/layer/marker.js create mode 100644 public/lib/ace/layer/text.js create mode 100644 public/lib/ace/layer/text_test.js create mode 100644 public/lib/ace/lib/app_config.js create mode 100644 public/lib/ace/lib/bidiutil.js create mode 100644 public/lib/ace/lib/dom.js create mode 100644 public/lib/ace/lib/es5-shim.js create mode 100644 public/lib/ace/lib/event.js create mode 100644 public/lib/ace/lib/event_emitter.js create mode 100644 public/lib/ace/lib/event_emitter_test.js create mode 100644 public/lib/ace/lib/fixoldbrowsers.js create mode 100644 public/lib/ace/lib/keys.js create mode 100644 public/lib/ace/lib/lang.js create mode 100644 public/lib/ace/lib/net.js create mode 100644 public/lib/ace/lib/oop.js create mode 100644 public/lib/ace/lib/regexp.js create mode 100644 public/lib/ace/lib/useragent.js create mode 100644 public/lib/ace/line_widgets.js create mode 100644 public/lib/ace/mode/_test/Readme.md create mode 100644 public/lib/ace/mode/_test/highlight_rules_test.js create mode 100644 public/lib/ace/mode/_test/package.json create mode 100644 public/lib/ace/mode/_test/text_asciidoc.txt create mode 100644 public/lib/ace/mode/_test/text_coffee.txt create mode 100644 public/lib/ace/mode/_test/text_coldfusion.txt create mode 100644 public/lib/ace/mode/_test/text_curly.txt create mode 100644 public/lib/ace/mode/_test/text_ejs.txt create mode 100644 public/lib/ace/mode/_test/text_gobstones.txt create mode 100644 public/lib/ace/mode/_test/text_html.txt create mode 100644 public/lib/ace/mode/_test/text_javascript.txt create mode 100644 public/lib/ace/mode/_test/text_livescript.txt create mode 100644 public/lib/ace/mode/_test/text_lucene.txt create mode 100644 public/lib/ace/mode/_test/text_markdown.txt create mode 100644 public/lib/ace/mode/_test/text_php.txt create mode 100644 public/lib/ace/mode/_test/text_ruby.txt create mode 100644 public/lib/ace/mode/_test/text_rust.txt create mode 100644 public/lib/ace/mode/_test/text_wollok.txt create mode 100644 public/lib/ace/mode/_test/text_xml.txt create mode 100644 public/lib/ace/mode/_test/tokens_abap.json create mode 100644 public/lib/ace/mode/_test/tokens_abc.json create mode 100644 public/lib/ace/mode/_test/tokens_actionscript.json create mode 100644 public/lib/ace/mode/_test/tokens_ada.json create mode 100644 public/lib/ace/mode/_test/tokens_asciidoc.json create mode 100644 public/lib/ace/mode/_test/tokens_assembly_x86.json create mode 100644 public/lib/ace/mode/_test/tokens_autohotkey.json create mode 100644 public/lib/ace/mode/_test/tokens_batchfile.json create mode 100644 public/lib/ace/mode/_test/tokens_c9search.json create mode 100644 public/lib/ace/mode/_test/tokens_c_cpp.json create mode 100644 public/lib/ace/mode/_test/tokens_cirru.json create mode 100644 public/lib/ace/mode/_test/tokens_clojure.json create mode 100644 public/lib/ace/mode/_test/tokens_cobol.json create mode 100644 public/lib/ace/mode/_test/tokens_coffee.json create mode 100644 public/lib/ace/mode/_test/tokens_coldfusion.json create mode 100644 public/lib/ace/mode/_test/tokens_csharp.json create mode 100644 public/lib/ace/mode/_test/tokens_csound_document.json create mode 100644 public/lib/ace/mode/_test/tokens_csound_orchestra.json create mode 100644 public/lib/ace/mode/_test/tokens_csound_score.json create mode 100644 public/lib/ace/mode/_test/tokens_css.json create mode 100644 public/lib/ace/mode/_test/tokens_curly.json create mode 100644 public/lib/ace/mode/_test/tokens_d.json create mode 100644 public/lib/ace/mode/_test/tokens_dart.json create mode 100644 public/lib/ace/mode/_test/tokens_diff.json create mode 100644 public/lib/ace/mode/_test/tokens_dot.json create mode 100644 public/lib/ace/mode/_test/tokens_drools.json create mode 100644 public/lib/ace/mode/_test/tokens_eiffel.json create mode 100644 public/lib/ace/mode/_test/tokens_ejs.json create mode 100644 public/lib/ace/mode/_test/tokens_elixir.json create mode 100644 public/lib/ace/mode/_test/tokens_elm.json create mode 100644 public/lib/ace/mode/_test/tokens_erlang.json create mode 100644 public/lib/ace/mode/_test/tokens_forth.json create mode 100644 public/lib/ace/mode/_test/tokens_fortran.json create mode 100644 public/lib/ace/mode/_test/tokens_ftl.json create mode 100644 public/lib/ace/mode/_test/tokens_gcode.json create mode 100644 public/lib/ace/mode/_test/tokens_gherkin.json create mode 100644 public/lib/ace/mode/_test/tokens_gitignore.json create mode 100644 public/lib/ace/mode/_test/tokens_glsl.json create mode 100644 public/lib/ace/mode/_test/tokens_gobstones.json create mode 100644 public/lib/ace/mode/_test/tokens_golang.json create mode 100644 public/lib/ace/mode/_test/tokens_groovy.json create mode 100644 public/lib/ace/mode/_test/tokens_haml.json create mode 100644 public/lib/ace/mode/_test/tokens_handlebars.json create mode 100644 public/lib/ace/mode/_test/tokens_haskell.json create mode 100644 public/lib/ace/mode/_test/tokens_haxe.json create mode 100644 public/lib/ace/mode/_test/tokens_html.json create mode 100644 public/lib/ace/mode/_test/tokens_html_elixir.json create mode 100644 public/lib/ace/mode/_test/tokens_html_ruby.json create mode 100644 public/lib/ace/mode/_test/tokens_ini.json create mode 100644 public/lib/ace/mode/_test/tokens_io.json create mode 100644 public/lib/ace/mode/_test/tokens_jack.json create mode 100644 public/lib/ace/mode/_test/tokens_jade.json create mode 100644 public/lib/ace/mode/_test/tokens_java.json create mode 100644 public/lib/ace/mode/_test/tokens_javascript.json create mode 100644 public/lib/ace/mode/_test/tokens_json.json create mode 100644 public/lib/ace/mode/_test/tokens_jsoniq.json create mode 100644 public/lib/ace/mode/_test/tokens_jsp.json create mode 100644 public/lib/ace/mode/_test/tokens_jsx.json create mode 100644 public/lib/ace/mode/_test/tokens_julia.json create mode 100644 public/lib/ace/mode/_test/tokens_latex.json create mode 100644 public/lib/ace/mode/_test/tokens_less.json create mode 100644 public/lib/ace/mode/_test/tokens_liquid.json create mode 100644 public/lib/ace/mode/_test/tokens_lisp.json create mode 100644 public/lib/ace/mode/_test/tokens_livescript.json create mode 100644 public/lib/ace/mode/_test/tokens_logiql.json create mode 100644 public/lib/ace/mode/_test/tokens_lsl.json create mode 100644 public/lib/ace/mode/_test/tokens_lua.json create mode 100644 public/lib/ace/mode/_test/tokens_luapage.json create mode 100644 public/lib/ace/mode/_test/tokens_lucene.json create mode 100644 public/lib/ace/mode/_test/tokens_markdown.json create mode 100644 public/lib/ace/mode/_test/tokens_mask.json create mode 100644 public/lib/ace/mode/_test/tokens_matlab.json create mode 100644 public/lib/ace/mode/_test/tokens_maze.json create mode 100644 public/lib/ace/mode/_test/tokens_mel.json create mode 100644 public/lib/ace/mode/_test/tokens_mushcode.json create mode 100644 public/lib/ace/mode/_test/tokens_mysql.json create mode 100644 public/lib/ace/mode/_test/tokens_nix.json create mode 100644 public/lib/ace/mode/_test/tokens_nsis.json create mode 100644 public/lib/ace/mode/_test/tokens_objectivec.json create mode 100644 public/lib/ace/mode/_test/tokens_ocaml.json create mode 100644 public/lib/ace/mode/_test/tokens_pascal.json create mode 100644 public/lib/ace/mode/_test/tokens_perl.json create mode 100644 public/lib/ace/mode/_test/tokens_pgsql.json create mode 100644 public/lib/ace/mode/_test/tokens_php.json create mode 100644 public/lib/ace/mode/_test/tokens_powershell.json create mode 100644 public/lib/ace/mode/_test/tokens_praat.json create mode 100644 public/lib/ace/mode/_test/tokens_prolog.json create mode 100644 public/lib/ace/mode/_test/tokens_properties.json create mode 100644 public/lib/ace/mode/_test/tokens_protobuf.json create mode 100644 public/lib/ace/mode/_test/tokens_python.json create mode 100644 public/lib/ace/mode/_test/tokens_r.json create mode 100644 public/lib/ace/mode/_test/tokens_razor.json create mode 100644 public/lib/ace/mode/_test/tokens_rdoc.json create mode 100644 public/lib/ace/mode/_test/tokens_rhtml.json create mode 100644 public/lib/ace/mode/_test/tokens_ruby.json create mode 100644 public/lib/ace/mode/_test/tokens_rust.json create mode 100644 public/lib/ace/mode/_test/tokens_sass.json create mode 100644 public/lib/ace/mode/_test/tokens_scad.json create mode 100644 public/lib/ace/mode/_test/tokens_scala.json create mode 100644 public/lib/ace/mode/_test/tokens_scheme.json create mode 100644 public/lib/ace/mode/_test/tokens_scss.json create mode 100644 public/lib/ace/mode/_test/tokens_sh.json create mode 100644 public/lib/ace/mode/_test/tokens_sjs.json create mode 100644 public/lib/ace/mode/_test/tokens_smarty.json create mode 100644 public/lib/ace/mode/_test/tokens_snippets.json create mode 100644 public/lib/ace/mode/_test/tokens_soy_template.json create mode 100644 public/lib/ace/mode/_test/tokens_space.json create mode 100644 public/lib/ace/mode/_test/tokens_sql.json create mode 100644 public/lib/ace/mode/_test/tokens_sqlserver.json create mode 100644 public/lib/ace/mode/_test/tokens_stylus.json create mode 100644 public/lib/ace/mode/_test/tokens_svg.json create mode 100644 public/lib/ace/mode/_test/tokens_swift.json create mode 100644 public/lib/ace/mode/_test/tokens_tcl.json create mode 100644 public/lib/ace/mode/_test/tokens_tex.json create mode 100644 public/lib/ace/mode/_test/tokens_text.json create mode 100644 public/lib/ace/mode/_test/tokens_textile.json create mode 100644 public/lib/ace/mode/_test/tokens_toml.json create mode 100644 public/lib/ace/mode/_test/tokens_tsx.json create mode 100644 public/lib/ace/mode/_test/tokens_twig.json create mode 100644 public/lib/ace/mode/_test/tokens_typescript.json create mode 100644 public/lib/ace/mode/_test/tokens_vala.json create mode 100644 public/lib/ace/mode/_test/tokens_vbscript.json create mode 100644 public/lib/ace/mode/_test/tokens_velocity.json create mode 100644 public/lib/ace/mode/_test/tokens_verilog.json create mode 100644 public/lib/ace/mode/_test/tokens_vhdl.json create mode 100644 public/lib/ace/mode/_test/tokens_wollok.json create mode 100644 public/lib/ace/mode/_test/tokens_xml.json create mode 100644 public/lib/ace/mode/_test/tokens_xquery.json create mode 100644 public/lib/ace/mode/_test/tokens_yaml.json create mode 100644 public/lib/ace/mode/abap.js create mode 100644 public/lib/ace/mode/abap_highlight_rules.js create mode 100644 public/lib/ace/mode/abc.js create mode 100644 public/lib/ace/mode/abc_highlight_rules.js create mode 100644 public/lib/ace/mode/actionscript.js create mode 100644 public/lib/ace/mode/actionscript_highlight_rules.js create mode 100644 public/lib/ace/mode/ada.js create mode 100644 public/lib/ace/mode/ada_highlight_rules.js create mode 100644 public/lib/ace/mode/apache_conf.js create mode 100644 public/lib/ace/mode/apache_conf_highlight_rules.js create mode 100644 public/lib/ace/mode/applescript.js create mode 100644 public/lib/ace/mode/applescript_highlight_rules.js create mode 100644 public/lib/ace/mode/asciidoc.js create mode 100644 public/lib/ace/mode/asciidoc_highlight_rules.js create mode 100644 public/lib/ace/mode/assembly_x86.js create mode 100644 public/lib/ace/mode/assembly_x86_highlight_rules.js create mode 100644 public/lib/ace/mode/autohotkey.js create mode 100644 public/lib/ace/mode/autohotkey_highlight_rules.js create mode 100644 public/lib/ace/mode/batchfile.js create mode 100644 public/lib/ace/mode/batchfile_highlight_rules.js create mode 100644 public/lib/ace/mode/behaviour.js create mode 100644 public/lib/ace/mode/behaviour/behaviour_test.js create mode 100644 public/lib/ace/mode/behaviour/css.js create mode 100644 public/lib/ace/mode/behaviour/cstyle.js create mode 100644 public/lib/ace/mode/behaviour/html.js create mode 100644 public/lib/ace/mode/behaviour/xml.js create mode 100644 public/lib/ace/mode/behaviour/xquery.js create mode 100644 public/lib/ace/mode/bro.js create mode 100644 public/lib/ace/mode/bro_highlight_rules.js create mode 100644 public/lib/ace/mode/c9search.js create mode 100644 public/lib/ace/mode/c9search_highlight_rules.js create mode 100644 public/lib/ace/mode/c_cpp.js create mode 100644 public/lib/ace/mode/c_cpp_highlight_rules.js create mode 100644 public/lib/ace/mode/cirru.js create mode 100644 public/lib/ace/mode/cirru_highlight_rules.js create mode 100644 public/lib/ace/mode/clojure.js create mode 100644 public/lib/ace/mode/clojure_highlight_rules.js create mode 100644 public/lib/ace/mode/cobol.js create mode 100644 public/lib/ace/mode/cobol_highlight_rules.js create mode 100644 public/lib/ace/mode/coffee.js create mode 100644 public/lib/ace/mode/coffee/coffee.js create mode 100644 public/lib/ace/mode/coffee/parser_test.js create mode 100644 public/lib/ace/mode/coffee_highlight_rules.js create mode 100644 public/lib/ace/mode/coffee_worker.js create mode 100644 public/lib/ace/mode/coldfusion.js create mode 100644 public/lib/ace/mode/coldfusion_highlight_rules.js create mode 100644 public/lib/ace/mode/coldfusion_test.js create mode 100644 public/lib/ace/mode/csharp.js create mode 100644 public/lib/ace/mode/csharp_highlight_rules.js create mode 100644 public/lib/ace/mode/csound_document.js create mode 100644 public/lib/ace/mode/csound_document_highlight_rules.js create mode 100644 public/lib/ace/mode/csound_orchestra.js create mode 100644 public/lib/ace/mode/csound_orchestra_highlight_rules.js create mode 100644 public/lib/ace/mode/csound_preprocessor_highlight_rules.js create mode 100644 public/lib/ace/mode/csound_score.js create mode 100644 public/lib/ace/mode/csound_score_highlight_rules.js create mode 100644 public/lib/ace/mode/css.js create mode 100644 public/lib/ace/mode/css/csslint.js create mode 100644 public/lib/ace/mode/css_completions.js create mode 100644 public/lib/ace/mode/css_highlight_rules.js create mode 100644 public/lib/ace/mode/css_test.js create mode 100644 public/lib/ace/mode/css_worker.js create mode 100644 public/lib/ace/mode/css_worker_test.js create mode 100644 public/lib/ace/mode/curly.js create mode 100644 public/lib/ace/mode/curly_highlight_rules.js create mode 100644 public/lib/ace/mode/d.js create mode 100644 public/lib/ace/mode/d_highlight_rules.js create mode 100644 public/lib/ace/mode/dart.js create mode 100644 public/lib/ace/mode/dart_highlight_rules.js create mode 100644 public/lib/ace/mode/diff.js create mode 100644 public/lib/ace/mode/diff_highlight_rules.js create mode 100644 public/lib/ace/mode/django.js create mode 100644 public/lib/ace/mode/doc_comment_highlight_rules.js create mode 100644 public/lib/ace/mode/dockerfile.js create mode 100644 public/lib/ace/mode/dockerfile_highlight_rules.js create mode 100644 public/lib/ace/mode/dot.js create mode 100644 public/lib/ace/mode/dot_highlight_rules.js create mode 100644 public/lib/ace/mode/drools.js create mode 100644 public/lib/ace/mode/drools_highlight_rules.js create mode 100644 public/lib/ace/mode/eiffel.js create mode 100644 public/lib/ace/mode/eiffel_highlight_rules.js create mode 100644 public/lib/ace/mode/ejs.js create mode 100644 public/lib/ace/mode/elixir.js create mode 100644 public/lib/ace/mode/elixir_highlight_rules.js create mode 100644 public/lib/ace/mode/elm.js create mode 100644 public/lib/ace/mode/elm_highlight_rules.js create mode 100644 public/lib/ace/mode/erlang.js create mode 100644 public/lib/ace/mode/erlang_highlight_rules.js create mode 100644 public/lib/ace/mode/folding/asciidoc.js create mode 100644 public/lib/ace/mode/folding/c9search.js create mode 100644 public/lib/ace/mode/folding/coffee.js create mode 100644 public/lib/ace/mode/folding/coffee_test.js create mode 100644 public/lib/ace/mode/folding/csharp.js create mode 100644 public/lib/ace/mode/folding/cstyle.js create mode 100644 public/lib/ace/mode/folding/cstyle_test.js create mode 100644 public/lib/ace/mode/folding/diff.js create mode 100644 public/lib/ace/mode/folding/drools.js create mode 100644 public/lib/ace/mode/folding/fold_mode.js create mode 100644 public/lib/ace/mode/folding/haskell_cabal.js create mode 100644 public/lib/ace/mode/folding/html.js create mode 100644 public/lib/ace/mode/folding/html_test.js create mode 100644 public/lib/ace/mode/folding/ini.js create mode 100644 public/lib/ace/mode/folding/latex.js create mode 100644 public/lib/ace/mode/folding/lua.js create mode 100644 public/lib/ace/mode/folding/markdown.js create mode 100644 public/lib/ace/mode/folding/mixed.js create mode 100644 public/lib/ace/mode/folding/pythonic.js create mode 100644 public/lib/ace/mode/folding/pythonic_test.js create mode 100644 public/lib/ace/mode/folding/sqlserver.js create mode 100644 public/lib/ace/mode/folding/velocity.js create mode 100644 public/lib/ace/mode/folding/xml.js create mode 100644 public/lib/ace/mode/folding/xml_test.js create mode 100644 public/lib/ace/mode/forth.js create mode 100644 public/lib/ace/mode/forth_highlight_rules.js create mode 100644 public/lib/ace/mode/fortran.js create mode 100644 public/lib/ace/mode/fortran_highlight_rules.js create mode 100644 public/lib/ace/mode/ftl.js create mode 100644 public/lib/ace/mode/ftl_highlight_rules.js create mode 100644 public/lib/ace/mode/gcode.js create mode 100644 public/lib/ace/mode/gcode_highlight_rules.js create mode 100644 public/lib/ace/mode/gherkin.js create mode 100644 public/lib/ace/mode/gherkin_highlight_rules.js create mode 100644 public/lib/ace/mode/gitignore.js create mode 100644 public/lib/ace/mode/gitignore_highlight_rules.js create mode 100644 public/lib/ace/mode/glsl.js create mode 100644 public/lib/ace/mode/glsl_highlight_rules.js create mode 100644 public/lib/ace/mode/gobstones.js create mode 100644 public/lib/ace/mode/gobstones_highlight_rules.js create mode 100644 public/lib/ace/mode/golang.js create mode 100644 public/lib/ace/mode/golang_highlight_rules.js create mode 100644 public/lib/ace/mode/graphqlschema.js create mode 100644 public/lib/ace/mode/graphqlschema_highlight_rules.js create mode 100644 public/lib/ace/mode/groovy.js create mode 100644 public/lib/ace/mode/groovy_highlight_rules.js create mode 100644 public/lib/ace/mode/haml.js create mode 100644 public/lib/ace/mode/haml_highlight_rules.js create mode 100644 public/lib/ace/mode/handlebars.js create mode 100644 public/lib/ace/mode/handlebars_highlight_rules.js create mode 100644 public/lib/ace/mode/haskell.js create mode 100644 public/lib/ace/mode/haskell_cabal.js create mode 100644 public/lib/ace/mode/haskell_cabal_highlight_rules.js create mode 100644 public/lib/ace/mode/haskell_highlight_rules.js create mode 100644 public/lib/ace/mode/haxe.js create mode 100644 public/lib/ace/mode/haxe_highlight_rules.js create mode 100644 public/lib/ace/mode/hjson.js create mode 100644 public/lib/ace/mode/hjson_highlight_rules.js create mode 100644 public/lib/ace/mode/html.js create mode 100644 public/lib/ace/mode/html/saxparser.js create mode 100644 public/lib/ace/mode/html_completions.js create mode 100644 public/lib/ace/mode/html_elixir.js create mode 100644 public/lib/ace/mode/html_elixir_highlight_rules.js create mode 100644 public/lib/ace/mode/html_highlight_rules.js create mode 100644 public/lib/ace/mode/html_ruby.js create mode 100644 public/lib/ace/mode/html_ruby_highlight_rules.js create mode 100644 public/lib/ace/mode/html_test.js create mode 100644 public/lib/ace/mode/html_worker.js create mode 100644 public/lib/ace/mode/ini.js create mode 100644 public/lib/ace/mode/ini_highlight_rules.js create mode 100644 public/lib/ace/mode/io.js create mode 100644 public/lib/ace/mode/io_highlight_rules.js create mode 100644 public/lib/ace/mode/jack.js create mode 100644 public/lib/ace/mode/jack_highlight_rules.js create mode 100644 public/lib/ace/mode/jade.js create mode 100644 public/lib/ace/mode/jade_highlight_rules.js create mode 100644 public/lib/ace/mode/java.js create mode 100644 public/lib/ace/mode/java_highlight_rules.js create mode 100644 public/lib/ace/mode/javascript.js create mode 100644 public/lib/ace/mode/javascript/jshint.js create mode 100644 public/lib/ace/mode/javascript_highlight_rules.js create mode 100644 public/lib/ace/mode/javascript_test.js create mode 100644 public/lib/ace/mode/javascript_worker.js create mode 100644 public/lib/ace/mode/javascript_worker_test.js create mode 100644 public/lib/ace/mode/js_regex_highlight_rules.js create mode 100644 public/lib/ace/mode/json.js create mode 100644 public/lib/ace/mode/json/json_parse.js create mode 100644 public/lib/ace/mode/json_highlight_rules.js create mode 100644 public/lib/ace/mode/json_worker.js create mode 100644 public/lib/ace/mode/json_worker_test.js create mode 100644 public/lib/ace/mode/jsoniq.js create mode 100644 public/lib/ace/mode/jsp.js create mode 100644 public/lib/ace/mode/jsp_highlight_rules.js create mode 100644 public/lib/ace/mode/jssm.js create mode 100644 public/lib/ace/mode/jssm_highlight_rules.js create mode 100644 public/lib/ace/mode/jsx.js create mode 100644 public/lib/ace/mode/jsx_highlight_rules.js create mode 100644 public/lib/ace/mode/julia.js create mode 100644 public/lib/ace/mode/julia_highlight_rules.js create mode 100644 public/lib/ace/mode/kotlin.js create mode 100644 public/lib/ace/mode/kotlin_highlight_rules.js create mode 100644 public/lib/ace/mode/latex.js create mode 100644 public/lib/ace/mode/latex_highlight_rules.js create mode 100644 public/lib/ace/mode/less.js create mode 100644 public/lib/ace/mode/less_highlight_rules.js create mode 100644 public/lib/ace/mode/liquid.js create mode 100644 public/lib/ace/mode/liquid_highlight_rules.js create mode 100644 public/lib/ace/mode/lisp.js create mode 100644 public/lib/ace/mode/lisp_highlight_rules.js create mode 100644 public/lib/ace/mode/livescript.js create mode 100644 public/lib/ace/mode/logiql.js create mode 100644 public/lib/ace/mode/logiql_highlight_rules.js create mode 100644 public/lib/ace/mode/logiql_test.js create mode 100644 public/lib/ace/mode/lsl.js create mode 100644 public/lib/ace/mode/lsl_highlight_rules.js create mode 100644 public/lib/ace/mode/lua.js create mode 100644 public/lib/ace/mode/lua/luaparse.js create mode 100644 public/lib/ace/mode/lua_highlight_rules.js create mode 100644 public/lib/ace/mode/lua_worker.js create mode 100644 public/lib/ace/mode/luapage.js create mode 100644 public/lib/ace/mode/luapage_highlight_rules.js create mode 100644 public/lib/ace/mode/lucene.js create mode 100644 public/lib/ace/mode/lucene_highlight_rules.js create mode 100644 public/lib/ace/mode/makefile.js create mode 100644 public/lib/ace/mode/makefile_highlight_rules.js create mode 100644 public/lib/ace/mode/markdown.js create mode 100644 public/lib/ace/mode/markdown_highlight_rules.js create mode 100644 public/lib/ace/mode/mask.js create mode 100644 public/lib/ace/mode/mask_highlight_rules.js create mode 100644 public/lib/ace/mode/matching_brace_outdent.js create mode 100644 public/lib/ace/mode/matching_parens_outdent.js create mode 100644 public/lib/ace/mode/matlab.js create mode 100644 public/lib/ace/mode/matlab_highlight_rules.js create mode 100644 public/lib/ace/mode/maze.js create mode 100644 public/lib/ace/mode/maze_highlight_rules.js create mode 100644 public/lib/ace/mode/mel.js create mode 100644 public/lib/ace/mode/mel_highlight_rules.js create mode 100644 public/lib/ace/mode/mushcode.js create mode 100644 public/lib/ace/mode/mushcode_highlight_rules.js create mode 100644 public/lib/ace/mode/mysql.js create mode 100644 public/lib/ace/mode/mysql_highlight_rules.js create mode 100644 public/lib/ace/mode/nix.js create mode 100644 public/lib/ace/mode/nix_highlight_rules.js create mode 100644 public/lib/ace/mode/nsis.js create mode 100644 public/lib/ace/mode/nsis_highlight_rules.js create mode 100644 public/lib/ace/mode/objectivec.js create mode 100644 public/lib/ace/mode/objectivec_highlight_rules.js create mode 100644 public/lib/ace/mode/ocaml.js create mode 100644 public/lib/ace/mode/ocaml_highlight_rules.js create mode 100644 public/lib/ace/mode/pascal.js create mode 100644 public/lib/ace/mode/pascal_highlight_rules.js create mode 100644 public/lib/ace/mode/perl.js create mode 100644 public/lib/ace/mode/perl_highlight_rules.js create mode 100755 public/lib/ace/mode/pgsql.js create mode 100755 public/lib/ace/mode/pgsql_highlight_rules.js create mode 100644 public/lib/ace/mode/php.js create mode 100644 public/lib/ace/mode/php/php.js create mode 100644 public/lib/ace/mode/php_completions.js create mode 100644 public/lib/ace/mode/php_highlight_rules.js create mode 100644 public/lib/ace/mode/php_test.js create mode 100644 public/lib/ace/mode/php_worker.js create mode 100644 public/lib/ace/mode/pig.js create mode 100644 public/lib/ace/mode/pig_highlight_rules.js create mode 100644 public/lib/ace/mode/plain_text.js create mode 100644 public/lib/ace/mode/plain_text_test.js create mode 100644 public/lib/ace/mode/powershell.js create mode 100644 public/lib/ace/mode/powershell_highlight_rules.js create mode 100644 public/lib/ace/mode/praat.js create mode 100644 public/lib/ace/mode/praat_highlight_rules.js create mode 100644 public/lib/ace/mode/prolog.js create mode 100644 public/lib/ace/mode/prolog_highlight_rules.js create mode 100644 public/lib/ace/mode/properties.js create mode 100644 public/lib/ace/mode/properties_highlight_rules.js create mode 100644 public/lib/ace/mode/protobuf.js create mode 100644 public/lib/ace/mode/protobuf_highlight_rules.js create mode 100644 public/lib/ace/mode/python.js create mode 100644 public/lib/ace/mode/python_highlight_rules.js create mode 100644 public/lib/ace/mode/python_test.js create mode 100644 public/lib/ace/mode/r.js create mode 100644 public/lib/ace/mode/r_highlight_rules.js create mode 100644 public/lib/ace/mode/razor.js create mode 100644 public/lib/ace/mode/razor_completions.js create mode 100644 public/lib/ace/mode/razor_highlight_rules.js create mode 100644 public/lib/ace/mode/rdoc.js create mode 100644 public/lib/ace/mode/rdoc_highlight_rules.js create mode 100644 public/lib/ace/mode/red.js create mode 100644 public/lib/ace/mode/red_highlight_rules.js create mode 100644 public/lib/ace/mode/rhtml.js create mode 100644 public/lib/ace/mode/rhtml_highlight_rules.js create mode 100644 public/lib/ace/mode/rst.js create mode 100644 public/lib/ace/mode/rst_highlight_rules.js create mode 100644 public/lib/ace/mode/ruby.js create mode 100644 public/lib/ace/mode/ruby_highlight_rules.js create mode 100644 public/lib/ace/mode/ruby_test.js create mode 100644 public/lib/ace/mode/rust.js create mode 100644 public/lib/ace/mode/rust_highlight_rules.js create mode 100644 public/lib/ace/mode/sass.js create mode 100644 public/lib/ace/mode/sass_highlight_rules.js create mode 100644 public/lib/ace/mode/scad.js create mode 100644 public/lib/ace/mode/scad_highlight_rules.js create mode 100644 public/lib/ace/mode/scala.js create mode 100644 public/lib/ace/mode/scala_highlight_rules.js create mode 100644 public/lib/ace/mode/scheme.js create mode 100644 public/lib/ace/mode/scheme_highlight_rules.js create mode 100644 public/lib/ace/mode/scss.js create mode 100644 public/lib/ace/mode/scss_highlight_rules.js create mode 100644 public/lib/ace/mode/sh.js create mode 100644 public/lib/ace/mode/sh_highlight_rules.js create mode 100644 public/lib/ace/mode/sjs.js create mode 100644 public/lib/ace/mode/sjs_highlight_rules.js create mode 100644 public/lib/ace/mode/smarty.js create mode 100644 public/lib/ace/mode/smarty_highlight_rules.js create mode 100644 public/lib/ace/mode/snippets.js create mode 100644 public/lib/ace/mode/soy_template.js create mode 100644 public/lib/ace/mode/soy_template_highlight_rules.js create mode 100644 public/lib/ace/mode/space.js create mode 100644 public/lib/ace/mode/space_highlight_rules.js create mode 100644 public/lib/ace/mode/sparql.js create mode 100644 public/lib/ace/mode/sparql_highlight_rules.js create mode 100644 public/lib/ace/mode/sql.js create mode 100644 public/lib/ace/mode/sql_highlight_rules.js create mode 100644 public/lib/ace/mode/sqlserver.js create mode 100644 public/lib/ace/mode/sqlserver_highlight_rules.js create mode 100644 public/lib/ace/mode/stylus.js create mode 100644 public/lib/ace/mode/stylus_highlight_rules.js create mode 100644 public/lib/ace/mode/svg.js create mode 100644 public/lib/ace/mode/svg_highlight_rules.js create mode 100644 public/lib/ace/mode/swift.js create mode 100644 public/lib/ace/mode/swift_highlight_rules.js create mode 100644 public/lib/ace/mode/tcl.js create mode 100644 public/lib/ace/mode/tcl_highlight_rules.js create mode 100644 public/lib/ace/mode/tex.js create mode 100644 public/lib/ace/mode/tex_highlight_rules.js create mode 100644 public/lib/ace/mode/text.js create mode 100644 public/lib/ace/mode/text_highlight_rules.js create mode 100644 public/lib/ace/mode/text_test.js create mode 100644 public/lib/ace/mode/textile.js create mode 100644 public/lib/ace/mode/textile_highlight_rules.js create mode 100644 public/lib/ace/mode/toml.js create mode 100644 public/lib/ace/mode/toml_highlight_rules.js create mode 100644 public/lib/ace/mode/tsx.js create mode 100644 public/lib/ace/mode/turtle.js create mode 100644 public/lib/ace/mode/turtle_highlight_rules.js create mode 100644 public/lib/ace/mode/twig.js create mode 100644 public/lib/ace/mode/twig_highlight_rules.js create mode 100644 public/lib/ace/mode/typescript.js create mode 100644 public/lib/ace/mode/typescript_highlight_rules.js create mode 100644 public/lib/ace/mode/vala.js create mode 100644 public/lib/ace/mode/vala_highlight_rules.js create mode 100644 public/lib/ace/mode/vbscript.js create mode 100644 public/lib/ace/mode/vbscript_highlight_rules.js create mode 100644 public/lib/ace/mode/velocity.js create mode 100644 public/lib/ace/mode/velocity_highlight_rules.js create mode 100644 public/lib/ace/mode/verilog.js create mode 100644 public/lib/ace/mode/verilog_highlight_rules.js create mode 100644 public/lib/ace/mode/vhdl.js create mode 100644 public/lib/ace/mode/vhdl_highlight_rules.js create mode 100644 public/lib/ace/mode/wollok.js create mode 100644 public/lib/ace/mode/wollok_highlight_rules.js create mode 100644 public/lib/ace/mode/xml.js create mode 100644 public/lib/ace/mode/xml/dom-parser.js create mode 100644 public/lib/ace/mode/xml/dom.js create mode 100644 public/lib/ace/mode/xml/sax.js create mode 100644 public/lib/ace/mode/xml_highlight_rules.js create mode 100644 public/lib/ace/mode/xml_test.js create mode 100644 public/lib/ace/mode/xml_worker.js create mode 100644 public/lib/ace/mode/xquery.js create mode 100644 public/lib/ace/mode/xquery/Readme.md create mode 100644 public/lib/ace/mode/xquery/jsoniq_lexer.js create mode 100644 public/lib/ace/mode/xquery/xqlint.js create mode 100644 public/lib/ace/mode/xquery/xquery_lexer.js create mode 100644 public/lib/ace/mode/xquery_worker.js create mode 100644 public/lib/ace/mode/yaml.js create mode 100644 public/lib/ace/mode/yaml_highlight_rules.js create mode 100644 public/lib/ace/model/editor.js create mode 100644 public/lib/ace/mouse/default_gutter_handler.js create mode 100644 public/lib/ace/mouse/default_handlers.js create mode 100644 public/lib/ace/mouse/dragdrop_handler.js create mode 100644 public/lib/ace/mouse/fold_handler.js create mode 100644 public/lib/ace/mouse/mouse_event.js create mode 100644 public/lib/ace/mouse/mouse_handler.js create mode 100644 public/lib/ace/mouse/mouse_handler_test.js create mode 100644 public/lib/ace/mouse/multi_select_handler.js create mode 100644 public/lib/ace/multi_select.js create mode 100644 public/lib/ace/multi_select_test.js create mode 100644 public/lib/ace/occur.js create mode 100644 public/lib/ace/occur_test.js create mode 100644 public/lib/ace/placeholder.js create mode 100644 public/lib/ace/placeholder_test.js create mode 100644 public/lib/ace/range.js create mode 100644 public/lib/ace/range_list.js create mode 100644 public/lib/ace/range_list_test.js create mode 100644 public/lib/ace/range_test.js create mode 100644 public/lib/ace/renderloop.js create mode 100644 public/lib/ace/requirejs/text.js create mode 100644 public/lib/ace/requirejs/text_build.js create mode 100644 public/lib/ace/scrollbar.js create mode 100644 public/lib/ace/search.js create mode 100644 public/lib/ace/search_highlight.js create mode 100644 public/lib/ace/search_test.js create mode 100644 public/lib/ace/selection.js create mode 100644 public/lib/ace/selection_test.js create mode 100644 public/lib/ace/snippets.js create mode 100644 public/lib/ace/snippets/_.snippets create mode 100644 public/lib/ace/snippets/_all_modes.js create mode 100644 public/lib/ace/snippets/_all_modes.snippets create mode 100644 public/lib/ace/snippets/abap.js create mode 100644 public/lib/ace/snippets/abap.snippets create mode 100644 public/lib/ace/snippets/abc.js create mode 100644 public/lib/ace/snippets/abc.snippets create mode 100644 public/lib/ace/snippets/actionscript.js create mode 100644 public/lib/ace/snippets/actionscript.snippets create mode 100644 public/lib/ace/snippets/ada.js create mode 100644 public/lib/ace/snippets/ada.snippets create mode 100644 public/lib/ace/snippets/all_modes.js create mode 100644 public/lib/ace/snippets/all_modes.snippets create mode 100644 public/lib/ace/snippets/apache.snippets create mode 100644 public/lib/ace/snippets/apache_conf.js create mode 100644 public/lib/ace/snippets/apache_conf.snippets create mode 100644 public/lib/ace/snippets/applescript.js create mode 100644 public/lib/ace/snippets/applescript.snippets create mode 100644 public/lib/ace/snippets/asciidoc.js create mode 100644 public/lib/ace/snippets/asciidoc.snippets create mode 100644 public/lib/ace/snippets/assembly_x86.js create mode 100644 public/lib/ace/snippets/assembly_x86.snippets create mode 100644 public/lib/ace/snippets/autohotkey.js create mode 100644 public/lib/ace/snippets/autohotkey.snippets create mode 100644 public/lib/ace/snippets/autoit.snippets create mode 100644 public/lib/ace/snippets/batchfile.js create mode 100644 public/lib/ace/snippets/batchfile.snippets create mode 100644 public/lib/ace/snippets/bro.js create mode 100644 public/lib/ace/snippets/c.snippets create mode 100644 public/lib/ace/snippets/c9search.js create mode 100644 public/lib/ace/snippets/c9search.snippets create mode 100644 public/lib/ace/snippets/c_cpp.js create mode 100644 public/lib/ace/snippets/c_cpp.snippets create mode 100644 public/lib/ace/snippets/chef.snippets create mode 100644 public/lib/ace/snippets/cirru.js create mode 100644 public/lib/ace/snippets/cirru.snippets create mode 100644 public/lib/ace/snippets/clojure.js create mode 100644 public/lib/ace/snippets/clojure.snippets create mode 100644 public/lib/ace/snippets/cmake.snippets create mode 100644 public/lib/ace/snippets/cobol.js create mode 100644 public/lib/ace/snippets/cobol.snippets create mode 100644 public/lib/ace/snippets/coffee.js create mode 100644 public/lib/ace/snippets/coffee.snippets create mode 100644 public/lib/ace/snippets/coldfusion.js create mode 100644 public/lib/ace/snippets/coldfusion.snippets create mode 100644 public/lib/ace/snippets/cs.snippets create mode 100644 public/lib/ace/snippets/csharp.js create mode 100644 public/lib/ace/snippets/csharp.snippets create mode 100644 public/lib/ace/snippets/csound_document.js create mode 100644 public/lib/ace/snippets/csound_document.snippets create mode 100644 public/lib/ace/snippets/csound_orchestra.js create mode 100644 public/lib/ace/snippets/csound_orchestra.snippets create mode 100644 public/lib/ace/snippets/csound_score.js create mode 100644 public/lib/ace/snippets/csound_score.snippets create mode 100644 public/lib/ace/snippets/css.js create mode 100644 public/lib/ace/snippets/css.snippets create mode 100644 public/lib/ace/snippets/curly.js create mode 100644 public/lib/ace/snippets/curly.snippets create mode 100644 public/lib/ace/snippets/d.js create mode 100644 public/lib/ace/snippets/d.snippets create mode 100644 public/lib/ace/snippets/dart.js create mode 100644 public/lib/ace/snippets/dart.snippets create mode 100644 public/lib/ace/snippets/diff.js create mode 100644 public/lib/ace/snippets/diff.snippets create mode 100644 public/lib/ace/snippets/django.js create mode 100644 public/lib/ace/snippets/django.snippets create mode 100644 public/lib/ace/snippets/dockerfile.js create mode 100644 public/lib/ace/snippets/dockerfile.snippets create mode 100644 public/lib/ace/snippets/dot.js create mode 100644 public/lib/ace/snippets/dot.snippets create mode 100644 public/lib/ace/snippets/drools.js create mode 100644 public/lib/ace/snippets/drools.snippets create mode 100644 public/lib/ace/snippets/dummy.js create mode 100644 public/lib/ace/snippets/dummy_syntax.js create mode 100644 public/lib/ace/snippets/eiffel.js create mode 100644 public/lib/ace/snippets/eiffel.snippets create mode 100644 public/lib/ace/snippets/ejs.js create mode 100644 public/lib/ace/snippets/ejs.snippets create mode 100644 public/lib/ace/snippets/elixir.js create mode 100644 public/lib/ace/snippets/elixir.snippets create mode 100644 public/lib/ace/snippets/elm.js create mode 100644 public/lib/ace/snippets/elm.snippets create mode 100644 public/lib/ace/snippets/erlang.js create mode 100644 public/lib/ace/snippets/erlang.snippets create mode 100644 public/lib/ace/snippets/eruby.snippets create mode 100644 public/lib/ace/snippets/falcon.snippets create mode 100644 public/lib/ace/snippets/forth.js create mode 100644 public/lib/ace/snippets/forth.snippets create mode 100644 public/lib/ace/snippets/ftl.js create mode 100644 public/lib/ace/snippets/ftl.snippets create mode 100644 public/lib/ace/snippets/gcode.js create mode 100644 public/lib/ace/snippets/gcode.snippets create mode 100644 public/lib/ace/snippets/gherkin.js create mode 100644 public/lib/ace/snippets/gherkin.snippets create mode 100644 public/lib/ace/snippets/gitignore.js create mode 100644 public/lib/ace/snippets/gitignore.snippets create mode 100644 public/lib/ace/snippets/glsl.js create mode 100644 public/lib/ace/snippets/glsl.snippets create mode 100644 public/lib/ace/snippets/go.snippets create mode 100644 public/lib/ace/snippets/gobstones.js create mode 100644 public/lib/ace/snippets/gobstones.snippets create mode 100644 public/lib/ace/snippets/golang.js create mode 100644 public/lib/ace/snippets/golang.snippets create mode 100644 public/lib/ace/snippets/graphqlschema.js create mode 100644 public/lib/ace/snippets/graphqlschema.snippets create mode 100644 public/lib/ace/snippets/groovy.js create mode 100644 public/lib/ace/snippets/groovy.snippets create mode 100644 public/lib/ace/snippets/haml.js create mode 100644 public/lib/ace/snippets/haml.snippets create mode 100644 public/lib/ace/snippets/handlebars.js create mode 100644 public/lib/ace/snippets/handlebars.snippets create mode 100644 public/lib/ace/snippets/haskell.js create mode 100644 public/lib/ace/snippets/haskell.snippets create mode 100644 public/lib/ace/snippets/haxe.js create mode 100644 public/lib/ace/snippets/haxe.snippets create mode 100644 public/lib/ace/snippets/hjson.js create mode 100644 public/lib/ace/snippets/html.js create mode 100644 public/lib/ace/snippets/html.snippets create mode 100644 public/lib/ace/snippets/html_elixir.js create mode 100644 public/lib/ace/snippets/html_elixir.snippets create mode 100644 public/lib/ace/snippets/html_ruby.js create mode 100644 public/lib/ace/snippets/html_ruby.snippets create mode 100644 public/lib/ace/snippets/htmldjango.snippets create mode 100644 public/lib/ace/snippets/htmltornado.snippets create mode 100644 public/lib/ace/snippets/ini.js create mode 100644 public/lib/ace/snippets/ini.snippets create mode 100644 public/lib/ace/snippets/io.js create mode 100644 public/lib/ace/snippets/io.snippets create mode 100644 public/lib/ace/snippets/jack.js create mode 100644 public/lib/ace/snippets/jack.snippets create mode 100644 public/lib/ace/snippets/jade.js create mode 100644 public/lib/ace/snippets/jade.snippets create mode 100644 public/lib/ace/snippets/java.js create mode 100644 public/lib/ace/snippets/java.snippets create mode 100644 public/lib/ace/snippets/javascript-jquery.snippets create mode 100644 public/lib/ace/snippets/javascript.js create mode 100644 public/lib/ace/snippets/javascript.snippets create mode 100644 public/lib/ace/snippets/json.js create mode 100644 public/lib/ace/snippets/json.snippets create mode 100644 public/lib/ace/snippets/jsoniq.js create mode 100644 public/lib/ace/snippets/jsoniq.snippets create mode 100644 public/lib/ace/snippets/jsp.js create mode 100644 public/lib/ace/snippets/jsp.snippets create mode 100644 public/lib/ace/snippets/jssm.js create mode 100644 public/lib/ace/snippets/jssm.snippets create mode 100644 public/lib/ace/snippets/jsx.js create mode 100644 public/lib/ace/snippets/jsx.snippets create mode 100644 public/lib/ace/snippets/julia.js create mode 100644 public/lib/ace/snippets/julia.snippets create mode 100644 public/lib/ace/snippets/kotlin.js create mode 100644 public/lib/ace/snippets/latex.js create mode 100644 public/lib/ace/snippets/latex.snippets create mode 100644 public/lib/ace/snippets/ledger.snippets create mode 100644 public/lib/ace/snippets/less.js create mode 100644 public/lib/ace/snippets/less.snippets create mode 100644 public/lib/ace/snippets/liquid.js create mode 100644 public/lib/ace/snippets/liquid.snippets create mode 100644 public/lib/ace/snippets/lisp.js create mode 100644 public/lib/ace/snippets/lisp.snippets create mode 100644 public/lib/ace/snippets/livescript.js create mode 100644 public/lib/ace/snippets/livescript.snippets create mode 100644 public/lib/ace/snippets/logiql.js create mode 100644 public/lib/ace/snippets/logiql.snippets create mode 100644 public/lib/ace/snippets/lsl.js create mode 100644 public/lib/ace/snippets/lsl.snippets create mode 100644 public/lib/ace/snippets/lua.js create mode 100644 public/lib/ace/snippets/lua.snippets create mode 100644 public/lib/ace/snippets/luapage.js create mode 100644 public/lib/ace/snippets/luapage.snippets create mode 100644 public/lib/ace/snippets/lucene.js create mode 100644 public/lib/ace/snippets/lucene.snippets create mode 100644 public/lib/ace/snippets/makefile.js create mode 100644 public/lib/ace/snippets/makefile.snippets create mode 100644 public/lib/ace/snippets/mako.snippets create mode 100644 public/lib/ace/snippets/markdown.js create mode 100644 public/lib/ace/snippets/markdown.snippets create mode 100644 public/lib/ace/snippets/matlab.js create mode 100644 public/lib/ace/snippets/matlab.snippets create mode 100644 public/lib/ace/snippets/maze.js create mode 100644 public/lib/ace/snippets/maze.snippets create mode 100644 public/lib/ace/snippets/mel.js create mode 100644 public/lib/ace/snippets/mel.snippets create mode 100644 public/lib/ace/snippets/mushcode.js create mode 100644 public/lib/ace/snippets/mushcode.snippets create mode 100644 public/lib/ace/snippets/mushcode_high_rules.js create mode 100644 public/lib/ace/snippets/mushcode_high_rules.snippets create mode 100644 public/lib/ace/snippets/mysql.js create mode 100644 public/lib/ace/snippets/mysql.snippets create mode 100644 public/lib/ace/snippets/nix.js create mode 100644 public/lib/ace/snippets/nix.snippets create mode 100644 public/lib/ace/snippets/nsis.js create mode 100644 public/lib/ace/snippets/objc.snippets create mode 100644 public/lib/ace/snippets/objectivec.js create mode 100644 public/lib/ace/snippets/objectivec.snippets create mode 100644 public/lib/ace/snippets/ocaml.js create mode 100644 public/lib/ace/snippets/ocaml.snippets create mode 100644 public/lib/ace/snippets/pascal.js create mode 100644 public/lib/ace/snippets/pascal.snippets create mode 100644 public/lib/ace/snippets/perl.js create mode 100644 public/lib/ace/snippets/perl.snippets create mode 100644 public/lib/ace/snippets/pgsql.js create mode 100644 public/lib/ace/snippets/pgsql.snippets create mode 100644 public/lib/ace/snippets/php.js create mode 100644 public/lib/ace/snippets/php.snippets create mode 100644 public/lib/ace/snippets/plain_text.js create mode 100644 public/lib/ace/snippets/plain_text.snippets create mode 100644 public/lib/ace/snippets/powershell.js create mode 100644 public/lib/ace/snippets/powershell.snippets create mode 100644 public/lib/ace/snippets/praat.js create mode 100644 public/lib/ace/snippets/praat.snippets create mode 100644 public/lib/ace/snippets/prolog.js create mode 100644 public/lib/ace/snippets/prolog.snippets create mode 100644 public/lib/ace/snippets/properties.js create mode 100644 public/lib/ace/snippets/properties.snippets create mode 100644 public/lib/ace/snippets/protobuf.js create mode 100644 public/lib/ace/snippets/protobuf.snippets create mode 100644 public/lib/ace/snippets/python.js create mode 100644 public/lib/ace/snippets/python.snippets create mode 100644 public/lib/ace/snippets/r.js create mode 100644 public/lib/ace/snippets/r.snippets create mode 100644 public/lib/ace/snippets/razor.js create mode 100644 public/lib/ace/snippets/razor.snippets create mode 100644 public/lib/ace/snippets/rdoc.js create mode 100644 public/lib/ace/snippets/rdoc.snippets create mode 100644 public/lib/ace/snippets/red.js create mode 100644 public/lib/ace/snippets/red.snippets create mode 100644 public/lib/ace/snippets/rhtml.js create mode 100644 public/lib/ace/snippets/rhtml.snippets create mode 100644 public/lib/ace/snippets/rst.snippets create mode 100644 public/lib/ace/snippets/ruby.js create mode 100644 public/lib/ace/snippets/ruby.snippets create mode 100644 public/lib/ace/snippets/rust.js create mode 100644 public/lib/ace/snippets/rust.snippets create mode 100644 public/lib/ace/snippets/sass.js create mode 100644 public/lib/ace/snippets/sass.snippets create mode 100644 public/lib/ace/snippets/scad.js create mode 100644 public/lib/ace/snippets/scad.snippets create mode 100644 public/lib/ace/snippets/scala.js create mode 100644 public/lib/ace/snippets/scala.snippets create mode 100644 public/lib/ace/snippets/scheme.js create mode 100644 public/lib/ace/snippets/scheme.snippets create mode 100644 public/lib/ace/snippets/scss.js create mode 100644 public/lib/ace/snippets/scss.snippets create mode 100644 public/lib/ace/snippets/sh.js create mode 100644 public/lib/ace/snippets/sh.snippets create mode 100644 public/lib/ace/snippets/sjs.js create mode 100644 public/lib/ace/snippets/sjs.snippets create mode 100644 public/lib/ace/snippets/smarty.js create mode 100644 public/lib/ace/snippets/smarty.snippets create mode 100644 public/lib/ace/snippets/snippets.js create mode 100644 public/lib/ace/snippets/snippets.snippets create mode 100644 public/lib/ace/snippets/soy_template.js create mode 100644 public/lib/ace/snippets/soy_template.snippets create mode 100644 public/lib/ace/snippets/space.js create mode 100644 public/lib/ace/snippets/space.snippets create mode 100644 public/lib/ace/snippets/sparql.js create mode 100644 public/lib/ace/snippets/sql.js create mode 100644 public/lib/ace/snippets/sql.snippets create mode 100644 public/lib/ace/snippets/sqlserver.js create mode 100644 public/lib/ace/snippets/sqlserver.snippets create mode 100644 public/lib/ace/snippets/stylus.js create mode 100644 public/lib/ace/snippets/stylus.snippets create mode 100644 public/lib/ace/snippets/svg.js create mode 100644 public/lib/ace/snippets/svg.snippets create mode 100644 public/lib/ace/snippets/tcl.js create mode 100644 public/lib/ace/snippets/tcl.snippets create mode 100644 public/lib/ace/snippets/tex.js create mode 100644 public/lib/ace/snippets/tex.snippets create mode 100644 public/lib/ace/snippets/text.js create mode 100644 public/lib/ace/snippets/text.snippets create mode 100644 public/lib/ace/snippets/textile.js create mode 100644 public/lib/ace/snippets/textile.snippets create mode 100644 public/lib/ace/snippets/tmsnippet.snippets create mode 100644 public/lib/ace/snippets/toml.js create mode 100644 public/lib/ace/snippets/toml.snippets create mode 100644 public/lib/ace/snippets/turtle.js create mode 100644 public/lib/ace/snippets/twig.js create mode 100644 public/lib/ace/snippets/twig.snippets create mode 100644 public/lib/ace/snippets/typescript.js create mode 100644 public/lib/ace/snippets/typescript.snippets create mode 100644 public/lib/ace/snippets/vala.js create mode 100644 public/lib/ace/snippets/vala.snippets create mode 100644 public/lib/ace/snippets/vbscript.js create mode 100644 public/lib/ace/snippets/vbscript.snippets create mode 100644 public/lib/ace/snippets/velocity.js create mode 100644 public/lib/ace/snippets/velocity.snippets create mode 100644 public/lib/ace/snippets/verilog.js create mode 100644 public/lib/ace/snippets/verilog.snippets create mode 100644 public/lib/ace/snippets/vhdl.js create mode 100644 public/lib/ace/snippets/vhdl.snippets create mode 100644 public/lib/ace/snippets/wollok.js create mode 100644 public/lib/ace/snippets/wollok.snippets create mode 100644 public/lib/ace/snippets/xml.js create mode 100644 public/lib/ace/snippets/xml.snippets create mode 100644 public/lib/ace/snippets/xquery.js create mode 100644 public/lib/ace/snippets/xquery.snippets create mode 100644 public/lib/ace/snippets/xslt.snippets create mode 100644 public/lib/ace/snippets/yaml.js create mode 100644 public/lib/ace/snippets/yaml.snippets create mode 100644 public/lib/ace/snippets_test.js create mode 100644 public/lib/ace/split.js create mode 100644 public/lib/ace/test/all.js create mode 100644 public/lib/ace/test/all_browser.js create mode 100644 public/lib/ace/test/assertions.js create mode 100644 public/lib/ace/test/asyncjs/assert.js create mode 100644 public/lib/ace/test/asyncjs/async.js create mode 100644 public/lib/ace/test/asyncjs/index.js create mode 100644 public/lib/ace/test/asyncjs/test.js create mode 100644 public/lib/ace/test/asyncjs/utils.js create mode 100644 public/lib/ace/test/benchmark.js create mode 100644 public/lib/ace/test/mockdom.js create mode 100644 public/lib/ace/test/mockrenderer.js create mode 100644 public/lib/ace/test/tests.html create mode 100644 public/lib/ace/theme/ambiance.css create mode 100644 public/lib/ace/theme/ambiance.js create mode 100644 public/lib/ace/theme/chaos.css create mode 100644 public/lib/ace/theme/chaos.js create mode 100644 public/lib/ace/theme/chrome.css create mode 100644 public/lib/ace/theme/chrome.js create mode 100644 public/lib/ace/theme/clouds.css create mode 100644 public/lib/ace/theme/clouds.js create mode 100644 public/lib/ace/theme/clouds_midnight.css create mode 100644 public/lib/ace/theme/clouds_midnight.js create mode 100644 public/lib/ace/theme/cobalt.css create mode 100644 public/lib/ace/theme/cobalt.js create mode 100644 public/lib/ace/theme/crimson_editor.css create mode 100644 public/lib/ace/theme/crimson_editor.js create mode 100644 public/lib/ace/theme/dawn.css create mode 100644 public/lib/ace/theme/dawn.js create mode 100644 public/lib/ace/theme/dracula.css create mode 100644 public/lib/ace/theme/dracula.js create mode 100644 public/lib/ace/theme/dreamweaver.css create mode 100644 public/lib/ace/theme/dreamweaver.js create mode 100644 public/lib/ace/theme/eclipse.css create mode 100644 public/lib/ace/theme/eclipse.js create mode 100644 public/lib/ace/theme/github.css create mode 100644 public/lib/ace/theme/github.js create mode 100644 public/lib/ace/theme/gob.css create mode 100644 public/lib/ace/theme/gob.js create mode 100644 public/lib/ace/theme/gruvbox.css create mode 100644 public/lib/ace/theme/gruvbox.js create mode 100644 public/lib/ace/theme/idle_fingers.css create mode 100644 public/lib/ace/theme/idle_fingers.js create mode 100644 public/lib/ace/theme/iplastic.css create mode 100644 public/lib/ace/theme/iplastic.js create mode 100644 public/lib/ace/theme/katzenmilch.css create mode 100644 public/lib/ace/theme/katzenmilch.js create mode 100644 public/lib/ace/theme/kr_theme.css create mode 100644 public/lib/ace/theme/kr_theme.js create mode 100644 public/lib/ace/theme/kuroir.css create mode 100644 public/lib/ace/theme/kuroir.js create mode 100644 public/lib/ace/theme/merbivore.css create mode 100644 public/lib/ace/theme/merbivore.js create mode 100644 public/lib/ace/theme/merbivore_soft.css create mode 100644 public/lib/ace/theme/merbivore_soft.js create mode 100644 public/lib/ace/theme/mono_industrial.css create mode 100644 public/lib/ace/theme/mono_industrial.js create mode 100644 public/lib/ace/theme/monokai.css create mode 100644 public/lib/ace/theme/monokai.js create mode 100644 public/lib/ace/theme/pastel_on_dark.css create mode 100644 public/lib/ace/theme/pastel_on_dark.js create mode 100644 public/lib/ace/theme/solarized_dark.css create mode 100644 public/lib/ace/theme/solarized_dark.js create mode 100644 public/lib/ace/theme/solarized_light.css create mode 100644 public/lib/ace/theme/solarized_light.js create mode 100644 public/lib/ace/theme/sqlserver.css create mode 100644 public/lib/ace/theme/sqlserver.js create mode 100644 public/lib/ace/theme/terminal.css create mode 100644 public/lib/ace/theme/terminal.js create mode 100644 public/lib/ace/theme/textmate.css create mode 100644 public/lib/ace/theme/textmate.js create mode 100644 public/lib/ace/theme/tomorrow.css create mode 100644 public/lib/ace/theme/tomorrow.js create mode 100644 public/lib/ace/theme/tomorrow_night.css create mode 100644 public/lib/ace/theme/tomorrow_night.js create mode 100644 public/lib/ace/theme/tomorrow_night_blue.css create mode 100644 public/lib/ace/theme/tomorrow_night_blue.js create mode 100644 public/lib/ace/theme/tomorrow_night_bright.css create mode 100644 public/lib/ace/theme/tomorrow_night_bright.js create mode 100644 public/lib/ace/theme/tomorrow_night_eighties.css create mode 100644 public/lib/ace/theme/tomorrow_night_eighties.js create mode 100644 public/lib/ace/theme/twilight.css create mode 100644 public/lib/ace/theme/twilight.js create mode 100644 public/lib/ace/theme/vibrant_ink.css create mode 100644 public/lib/ace/theme/vibrant_ink.js create mode 100644 public/lib/ace/theme/xcode.css create mode 100644 public/lib/ace/theme/xcode.js create mode 100644 public/lib/ace/token_iterator.js create mode 100644 public/lib/ace/token_iterator_test.js create mode 100644 public/lib/ace/tokenizer.js create mode 100644 public/lib/ace/tokenizer_dev.js create mode 100644 public/lib/ace/tokenizer_test.js create mode 100644 public/lib/ace/tooltip.js create mode 100644 public/lib/ace/undomanager.js create mode 100644 public/lib/ace/unicode.js create mode 100644 public/lib/ace/virtual_renderer.js create mode 100644 public/lib/ace/virtual_renderer_test.js create mode 100644 public/lib/ace/worker/mirror.js create mode 100644 public/lib/ace/worker/worker.js create mode 100644 public/lib/ace/worker/worker_client.js create mode 100644 public/lib/ace/worker/worker_test.js diff --git a/package.json b/package.json index 1973181..576dbcc 100644 --- a/package.json +++ b/package.json @@ -26,5 +26,8 @@ "postinstall": "./node_modules/elm/binwrappers/elm-package install -y", "build": "export ELM_PROD_ENV=true && webpack", "dev": "export ELM_PROD_ENV=false && webpack-dev-server" + }, + "dependencies": { + "elm-github-install": "^1.6.1" } } diff --git a/public/lib/ace/ace.js b/public/lib/ace/ace.js new file mode 100644 index 0000000..3fa17cf --- /dev/null +++ b/public/lib/ace/ace.js @@ -0,0 +1,132 @@ +/* ***** 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 ***** */ + +/** + * The main class required to set up an Ace instance in the browser. + * + * @class Ace + **/ + +define(function(require, exports, module) { +"use strict"; + +require("./lib/fixoldbrowsers"); + +var dom = require("./lib/dom"); +var event = require("./lib/event"); + +var Editor = require("./editor").Editor; +var EditSession = require("./edit_session").EditSession; +var UndoManager = require("./undomanager").UndoManager; +var Renderer = require("./virtual_renderer").VirtualRenderer; + +// The following require()s are for inclusion in the built ace file +require("./worker/worker_client"); +require("./keyboard/hash_handler"); +require("./placeholder"); +require("./multi_select"); +require("./mode/folding/fold_mode"); +require("./theme/textmate"); +require("./ext/error_marker"); + +exports.config = require("./config"); + +/** + * Provides access to require in packed noconflict mode + * @param {String} moduleName + * @returns {Object} + **/ +exports.require = require; + +if (typeof define === "function") + exports.define = define; + +/** + * Embeds the Ace editor into the DOM, at the element provided by `el`. + * @param {String | DOMElement} el Either the id of an element, or the element itself + * + **/ +exports.edit = function(el) { + if (typeof el == "string") { + var _id = el; + el = document.getElementById(_id); + if (!el) + throw new Error("ace.edit can't find div #" + _id); + } + + if (el && el.env && el.env.editor instanceof Editor) + return el.env.editor; + + 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 if (el) { + value = dom.getInnerText(el); + el.innerHTML = ""; + } + + var doc = exports.createEditSession(value); + + var editor = new Editor(new Renderer(el)); + editor.setSession(doc); + + var env = { + document: doc, + 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 + }); + editor.container.env = editor.env = env; + return editor; +}; + +/** + * Creates a new [[EditSession]], and returns the associated [[Document]]. + * @param {Document | String} text {:textParam} + * @param {TextMode} mode {:modeParam} + * + **/ +exports.createEditSession = function(text, mode) { + var doc = new EditSession(text, mode); + doc.setUndoManager(new UndoManager()); + return doc; +}; +exports.EditSession = EditSession; +exports.UndoManager = UndoManager; +exports.version = "1.2.9"; +}); diff --git a/public/lib/ace/anchor.js b/public/lib/ace/anchor.js new file mode 100644 index 0000000..39b78e0 --- /dev/null +++ b/public/lib/ace/anchor.js @@ -0,0 +1,227 @@ +/* ***** 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 oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; + +/** + * + * 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 + **/ + +/** + * Creates a new `Anchor` and associates it with a document. + * + * @param {Document} doc The document to associate with the anchor + * @param {Number} row The starting row position + * @param {Number} column The starting column position + * + * @constructor + **/ + +var Anchor = exports.Anchor = function(doc, row, column) { + this.$onChange = this.onChange.bind(this); + this.attach(doc); + + if (typeof column == "undefined") + this.setPosition(row.row, row.column); + else + this.setPosition(row, column); +}; + +(function() { + + oop.implement(this, EventEmitter); + + /** + * Returns an object identifying the `row` and `column` position of the current anchor. + * @returns {Object} + **/ + this.getPosition = function() { + return this.$clipPositionToDocument(this.row, this.column); + }; + + /** + * + * Returns the current document. + * @returns {Document} + **/ + this.getDocument = function() { + return this.document; + }; + + /** + * experimental: allows anchor to stick to the next on the left + */ + this.$insertRight = false; + /** + * Fires whenever the anchor position changes. + * + * Both of these objects have a `row` and `column` property corresponding to the position. + * + * Events that can trigger this function include [[Anchor.setPosition `setPosition()`]]. + * + * @event change + * @param {Object} e An object containing information about the anchor position. It has two properties: + * - `old`: An object describing the old Anchor position + * - `value`: An object describing the new Anchor position + * + **/ + this.onChange = function(delta) { + if (delta.start.row == delta.end.row && delta.start.row != this.row) + return; + + if (delta.start.row > this.row) + return; + + 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. + * @param {Number} row The row index to move the anchor to + * @param {Number} column The column index to move the anchor to + * @param {Boolean} noClip Identifies if you want the position to be clipped + * + **/ + this.setPosition = function(row, column, noClip) { + var pos; + if (noClip) { + pos = { + row: row, + column: column + }; + } else { + pos = this.$clipPositionToDocument(row, column); + } + + if (this.row == pos.row && this.column == pos.column) + return; + + var old = { + row: this.row, + column: this.column + }; + + this.row = pos.row; + this.column = pos.column; + this._signal("change", { + old: old, + value: pos + }); + }; + + /** + * When called, the `"change"` event listener is removed. + * + **/ + this.detach = function() { + this.document.removeEventListener("change", this.$onChange); + }; + this.attach = function(doc) { + this.document = doc || this.document; + this.document.on("change", this.$onChange); + }; + + /** + * Clips the anchor position to the specified row and column. + * @param {Number} row The row index to clip the anchor to + * @param {Number} column The column index to clip the anchor to + * + **/ + this.$clipPositionToDocument = function(row, column) { + var pos = {}; + + if (row >= this.document.getLength()) { + pos.row = Math.max(0, this.document.getLength() - 1); + pos.column = this.document.getLine(pos.row).length; + } + else if (row < 0) { + pos.row = 0; + pos.column = 0; + } + else { + pos.row = row; + pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column)); + } + + if (column < 0) + pos.column = 0; + + return pos; + }; + +}).call(Anchor.prototype); + +}); diff --git a/public/lib/ace/anchor_test.js b/public/lib/ace/anchor_test.js new file mode 100644 index 0000000..4920839 --- /dev/null +++ b/public/lib/ace/anchor_test.js @@ -0,0 +1,223 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { +"use strict"; + +var Document = require("./document").Document; +var Anchor = require("./anchor").Anchor; +var Range = require("./range").Range; +var assert = require("./test/assertions"); + +module.exports = { + + "test create anchor" : function() { + var doc = new Document("juhu"); + var anchor = new Anchor(doc, 0, 0); + + assert.position(anchor.getPosition(), 0, 0); + assert.equal(anchor.getDocument(), doc); + }, + + "test insert text in same row before cursor should move anchor column": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + + doc.insert({row: 1, column: 1}, "123"); + assert.position(anchor.getPosition(), 1, 7); + }, + + "test insert text at anchor should not move anchor when insertRight is true": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + anchor.$insertRight = true; + + doc.insert({row: 1, column: 4}, "123"); + assert.position(anchor.getPosition(), 1, 4); + }, + + "test insert lines before cursor should move anchor row": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + + doc.insertFullLines(1, ["123", "456"]); + assert.position(anchor.getPosition(), 3, 4); + }, + + "test insert lines at anchor position should move anchor down": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 0); + + doc.insertLines(1, ["line"]); + assert.position(anchor.getPosition(), 2, 0); + }, + + "test insert lines at anchor position should not move anchor down when insertRight is true and column is 0": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 0); + anchor.$insertRight = true; + + doc.insertLines(1, ["line"]); + assert.position(anchor.getPosition(), 1, 0); + }, + + "test insert lines at anchor row should move anchor down when column > 0": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 2); + anchor.$insertRight = true; + + doc.insertLines(1, ["line"]); + assert.position(anchor.getPosition(), 2, 2); + }, + + "test insert new line before cursor should move anchor column": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + + doc.insertMergedLines({row: 0, column: 0}, ['', '']); + assert.position(anchor.getPosition(), 2, 4); + }, + + "test insert new line in anchor line before anchor should move anchor column and row": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + + doc.insertMergedLines({row: 1, column: 2}, ['', '']); + assert.position(anchor.getPosition(), 2, 2); + }, + + "test delete text in anchor line before anchor should move anchor column": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + + doc.remove(new Range(1, 1, 1, 3)); + assert.position(anchor.getPosition(), 1, 2); + }, + + "test remove range which contains the anchor should move the anchor to the start of the range": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 0, 3); + + doc.remove(new Range(0, 1, 1, 3)); + assert.position(anchor.getPosition(), 0, 1); + }, + + "test delete character before the anchor should have no effect": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + + doc.remove(new Range(1, 4, 1, 5)); + assert.position(anchor.getPosition(), 1, 4); + }, + + "test delete lines in anchor line before anchor should move anchor row": function() { + var doc = new Document("juhu\n1\n2\nkinners"); + var anchor = new Anchor(doc, 3, 4); + + doc.removeFullLines(1, 2); + assert.position(anchor.getPosition(), 1, 4); + }, + + "test remove new line before the cursor": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + + doc.removeNewLine(0); + assert.position(anchor.getPosition(), 0, 8); + }, + + "test delete range which contains the anchor should move anchor to the end of the range": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + + doc.remove(new Range(0, 2, 1, 2)); + assert.position(anchor.getPosition(), 0, 4); + }, + + "test delete line which contains the anchor should move anchor to the end of the range": function() { + var doc = new Document("juhu\nkinners\n123"); + var anchor = new Anchor(doc, 1, 5); + + doc.removeFullLines(1, 1); + assert.position(anchor.getPosition(), 1, 0); + }, + + "test remove after the anchor should have no effect": function() { + var doc = new Document("juhu\nkinners\n123"); + var anchor = new Anchor(doc, 1, 2); + + doc.remove(new Range(1, 4, 2, 2)); + assert.position(anchor.getPosition(), 1, 2); + }, + + "test anchor changes triggered by document changes should emit change event": function(next) { + var doc = new Document("juhu\nkinners\n123"); + var anchor = new Anchor(doc, 1, 5); + + anchor.on("change", function(e) { + assert.position(anchor.getPosition(), 0, 0); + next(); + }); + + doc.remove(new Range(0, 0, 2, 1)); + }, + + "test only fire change event if position changes": function() { + var doc = new Document("juhu\nkinners\n123"); + var anchor = new Anchor(doc, 1, 5); + + anchor.on("change", function(e) { + assert.fail(); + }); + + doc.remove(new Range(2, 0, 2, 1)); + }, + + "test insert/remove lines at the end of the document": function() { + var doc = new Document("juhu\nkinners\n123"); + var anchor = new Anchor(doc, 2, 4); + + doc.removeFullLines(0, 3); + assert.position(anchor.getPosition(), 0, 0); + doc.insertFullLines(0, ["a", "b", "c"]); + assert.position(anchor.getPosition(), 3, 0); + assert.equal(doc.getValue(), "a\nb\nc\n"); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/apply_delta.js b/public/lib/ace/apply_delta.js new file mode 100644 index 0000000..7c2f158 --- /dev/null +++ b/public/lib/ace/apply_delta.js @@ -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; + } +}; +}); diff --git a/public/lib/ace/autocomplete.js b/public/lib/ace/autocomplete.js new file mode 100644 index 0000000..00ddde5 --- /dev/null +++ b/public/lib/ace/autocomplete.js @@ -0,0 +1,510 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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("./keyboard/hash_handler").HashHandler; +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 = false; + this.autoSelect = true; + this.exactMatch = false; + this.gatherCompletionsId = 0; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys(this.commands); + + this.blurListener = this.blurListener.bind(this); + this.changeListener = this.changeListener.bind(this); + this.mousedownListener = this.mousedownListener.bind(this); + this.mousewheelListener = this.mousewheelListener.bind(this); + + this.changeTimer = lang.delayedCall(function() { + this.updateCompletions(true); + }.bind(this)); + + this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50); +}; + +(function() { + + this.$init = function() { + this.popup = new AcePopup(document.body || document.documentElement); + this.popup.on("click", function(e) { + this.insertMatch(); + 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) { + if (!this.popup) + this.$init(); + + this.popup.autoSelect = this.autoSelect; + + this.popup.setData(this.completions.filtered); + + editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + + var renderer = editor.renderer; + this.popup.setRow(this.autoSelect ? 0 : -1); + if (!keepPopupPosition) { + this.popup.setTheme(editor.getTheme()); + this.popup.setFontSize(editor.getFontSize()); + + var lineHeight = renderer.layerConfig.lineHeight; + + var pos = renderer.$cursorLayer.getPixelPosition(this.base, true); + pos.left -= this.popup.getTextLeftOffset(); + + var rect = editor.container.getBoundingClientRect(); + pos.top += rect.top - renderer.layerConfig.offset; + pos.left += rect.left - editor.renderer.scrollLeft; + pos.left += renderer.gutterWidth; + + this.popup.show(pos, lineHeight); + } else if (keepPopupPosition && !prefix) { + this.detach(); + } + }; + + this.detach = function() { + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.off("changeSelection", this.changeListener); + this.editor.off("blur", this.blurListener); + this.editor.off("mousedown", this.mousedownListener); + this.editor.off("mousewheel", this.mousewheelListener); + this.changeTimer.cancel(); + this.hideDocTooltip(); + + 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; + }; + + this.changeListener = function(e) { + var cursor = this.editor.selection.lead; + if (cursor.row != this.base.row || cursor.column < this.base.column) { + this.detach(); + } + if (this.activated) + this.changeTimer.schedule(); + else + this.detach(); + }; + + 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; + var text = this.editor.textInput.getElement(); + var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget); + 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) { + this.detach(); + }; + + this.mousewheelListener = function(e) { + this.detach(); + }; + + this.goTo = function(where) { + var row = this.popup.getRow(); + var max = this.popup.session.getLength() - 1; + + switch(where) { + case "up": row = row <= 0 ? max : row - 1; break; + case "down": row = row >= max ? -1 : row + 1; break; + case "start": row = 0; break; + case "end": row = max; break; + } + + this.popup.setRow(row); + }; + + this.insertMatch = function(data, options) { + if (!data) + data = this.popup.getData(this.popup.getRow()); + if (!data) + return false; + + if (data.completer && data.completer.insertMatch) { + data.completer.insertMatch(this.editor, data); + } else { + // TODO add support for options.deleteSuffix + if (this.completions.filterText) { + var ranges = this.editor.selection.getAllRanges(); + for (var i = 0, range; range = ranges[i]; i++) { + range.start.column -= this.completions.filterText.length; + this.editor.session.remove(range); + } + } + if (data.snippet) + snippetManager.insertSnippet(this.editor, data.snippet); + else + this.editor.execCommand("insertstring", data.value || data); + } + this.detach(); + }; + + + this.commands = { + "Up": function(editor) { editor.completer.goTo("up"); }, + "Down": function(editor) { editor.completer.goTo("down"); }, + "Ctrl-Up|Ctrl-Home": function(editor) { editor.completer.goTo("start"); }, + "Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); }, + + "Esc": function(editor) { editor.completer.detach(); }, + "Return": function(editor) { return editor.completer.insertMatch(); }, + "Shift-Return": function(editor) { editor.completer.insertMatch(null, {deleteSuffix: true}); }, + "Tab": function(editor) { + var result = editor.completer.insertMatch(); + if (!result && !editor.tabstopManager) + editor.completer.goTo("down"); + else + return result; + }, + + "PageUp": function(editor) { editor.completer.popup.gotoPageUp(); }, + "PageDown": function(editor) { editor.completer.popup.gotoPageDown(); } + }; + + this.gatherCompletions = function(editor, callback) { + var session = editor.getSession(); + var pos = editor.getCursorPosition(); + + var prefix = util.getCompletionPrefix(editor); + + this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); + this.base.$insertRight = true; + + var matches = []; + var total = editor.completers.length; + editor.completers.forEach(function(completer, i) { + completer.getCompletions(editor, session, pos, prefix, function(err, results) { + if (!err && results) + matches = matches.concat(results); + // Fetch prefix again, because they may have changed by now + callback(null, { + prefix: util.getCompletionPrefix(editor), + matches: matches, + finished: (--total === 0) + }); + }); + }); + return true; + }; + + this.showPopup = function(editor) { + if (this.editor) + this.detach(); + + this.activated = true; + + this.editor = editor; + if (editor.completer != this) { + if (editor.completer) + editor.completer.detach(); + editor.completer = this; + } + + editor.on("changeSelection", this.changeListener); + editor.on("blur", this.blurListener); + editor.on("mousedown", this.mousedownListener); + editor.on("mousewheel", this.mousewheelListener); + + this.updateCompletions(); + }; + + this.updateCompletions = function(keepPopupPosition) { + if (keepPopupPosition && this.base && this.completions) { + var pos = this.editor.getCursorPosition(); + var prefix = this.editor.session.getTextRange({start: this.base, end: pos}); + if (prefix == this.completions.filterText) + return; + this.completions.setFilter(prefix); + if (!this.completions.filtered.length) + return this.detach(); + if (this.completions.filtered.length == 1 + && this.completions.filtered[0].value == prefix + && !this.completions.filtered[0].snippet) + return this.detach(); + this.openPopup(this.editor, prefix, keepPopupPosition); + return; + } + + // Save current gatherCompletions session, session is close when a match is insert + var _id = this.gatherCompletionsId; + this.gatherCompletions(this.editor, function(err, results) { + // Only detach if result gathering is finished + var detachIfFinished = function() { + if (!results.finished) return; + return this.detach(); + }.bind(this); + + var prefix = results.prefix; + var matches = results && results.matches; + + if (!matches || !matches.length) + return detachIfFinished(); + + // Wrong prefix or wrong session -> ignore + if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) + return; + + this.completions = new FilteredList(matches); + + if (this.exactMatch) + this.completions.exactMatch = true; + + this.completions.setFilter(prefix); + var filtered = this.completions.filtered; + + // No results + if (!filtered.length) + return detachIfFinished(); + + // One result equals to the prefix + if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) + return detachIfFinished(); + + // Autoinsert if one result + if (this.autoInsert && filtered.length == 1 && results.finished) + return this.insertMatch(filtered[0]); + + this.openPopup(this.editor, prefix, keepPopupPosition); + }.bind(this)); + }; + + this.cancelContextMenu = function() { + 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); + this.tooltipNode.onclick = this.onTooltipClick.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); + }; + + this.onTooltipClick = function(e) { + var a = e.target; + while (a && a != this.tooltipNode) { + if (a.nodeName == "A" && a.href) { + a.rel = "noreferrer"; + a.target = "_blank"; + break; + } + a = a.parentNode; + } + }; + +}).call(Autocomplete.prototype); + +Autocomplete.startCommand = { + name: "startAutocomplete", + exec: function(editor) { + if (!editor.completer) + editor.completer = new Autocomplete(); + editor.completer.autoInsert = false; + editor.completer.autoSelect = true; + editor.completer.showPopup(editor); + // 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) { + this.all = array; + this.filtered = array; + this.filterText = filterText || ""; + this.exactMatch = false; +}; +(function(){ + this.setFilter = function(str) { + if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0) + var matches = this.filtered; + else + var matches = this.all; + + this.filterText = str; + matches = this.filterCompletions(matches, this.filterText); + matches = matches.sort(function(a, b) { + return b.exactMatch - a.exactMatch || b.score - a.score; + }); + + // make unique + var prev = null; + matches = matches.filter(function(item){ + var caption = item.snippet || item.caption || item.value; + if (caption === prev) return false; + prev = caption; + return true; + }); + + this.filtered = matches; + }; + this.filterCompletions = function(items, needle) { + var results = []; + var upper = needle.toUpperCase(); + var lower = needle.toLowerCase(); + loop: for (var i = 0, item; item = items[i]; i++) { + var caption = item.value || item.caption || item.snippet; + if (!caption) continue; + var lastIndex = -1; + var matchMask = 0; + var penalty = 0; + var index, distance; + + if (this.exactMatch) { + if (needle !== caption.substr(0, needle.length)) + continue loop; + }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; + } + } + item.matchMask = matchMask; + item.exactMatch = penalty ? 0 : 1; + item.score = (item.score || 0) - penalty; + results.push(item); + } + return results; + }; +}).call(FilteredList.prototype); + +exports.Autocomplete = Autocomplete; +exports.FilteredList = FilteredList; + +}); diff --git a/public/lib/ace/autocomplete/popup.js b/public/lib/ace/autocomplete/popup.js new file mode 100644 index 0000000..bab57b4 --- /dev/null +++ b/public/lib/ace/autocomplete/popup.js @@ -0,0 +1,348 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 Renderer = require("../virtual_renderer").VirtualRenderer; +var Editor = require("../editor").Editor; +var Range = require("../range").Range; +var event = require("../lib/event"); +var lang = require("../lib/lang"); +var dom = require("../lib/dom"); + +var $singleLineEditor = function(el) { + var renderer = new Renderer(el); + + renderer.$maxLines = 4; + + var editor = new Editor(renderer); + + editor.setHighlightActiveLine(false); + editor.setShowPrintMargin(false); + editor.renderer.setShowGutter(false); + editor.renderer.setHighlightGutterLine(false); + + editor.$mouseHandler.$focusWaitTimout = 0; + editor.$highlightTagPending = true; + + return editor; +}; + +var AcePopup = function(parentNode) { + var el = dom.createElement("div"); + var popup = new $singleLineEditor(el); + + if (parentNode) + parentNode.appendChild(el); + el.style.display = "none"; + popup.renderer.content.style.cursor = "default"; + popup.renderer.setStyle("ace_autocomplete"); + + popup.setOption("displayIndentGuides", false); + popup.setOption("dragDelay", 150); + + var noop = function(){}; + + popup.focus = noop; + popup.$isFocused = true; + + popup.renderer.$cursorLayer.restartTimer = noop; + popup.renderer.$cursorLayer.element.style.opacity = 0; + + popup.renderer.$maxLines = 8; + popup.renderer.$keepTextAreaAtCursor = false; + + popup.setHighlightActiveLine(false); + // set default highlight color + popup.session.highlight(""); + popup.session.$searchHighlight.clazz = "ace_highlight-marker"; + + popup.on("mousedown", function(e) { + var pos = e.getDocumentPosition(); + popup.selection.moveToPosition(pos); + selectionMarker.start.row = selectionMarker.end.row = pos.row; + e.stop(); + }); + + var lastMouseEvent; + var hoverMarker = new Range(-1,0,-1,Infinity); + var selectionMarker = new Range(-1,0,-1,Infinity); + selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine"); + popup.setSelectOnHover = function(val) { + if (!val) { + hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine"); + } else if (hoverMarker.id) { + popup.session.removeMarker(hoverMarker.id); + hoverMarker.id = null; + } + }; + popup.setSelectOnHover(false); + popup.on("mousemove", function(e) { + if (!lastMouseEvent) { + lastMouseEvent = e; + return; + } + if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) { + return; + } + lastMouseEvent = e; + lastMouseEvent.scrollTop = popup.renderer.scrollTop; + var row = lastMouseEvent.getDocumentPosition().row; + if (hoverMarker.start.row != row) { + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row); + } + }); + popup.renderer.on("beforeRender", function() { + if (lastMouseEvent && hoverMarker.start.row != -1) { + lastMouseEvent.$pos = null; + var row = lastMouseEvent.getDocumentPosition().row; + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row, true); + } + }); + popup.renderer.on("afterRender", function() { + var row = popup.getRow(); + var t = popup.renderer.$textLayer; + var selected = t.element.childNodes[row - t.config.firstRow]; + if (selected == t.selectedNode) + return; + if (t.selectedNode) + dom.removeCssClass(t.selectedNode, "ace_selected"); + t.selectedNode = selected; + if (selected) + dom.addCssClass(selected, "ace_selected"); + }); + var hideHoverMarker = function() { setHoverMarker(-1); }; + var setHoverMarker = function(row, suppressRedraw) { + if (row !== hoverMarker.start.row) { + hoverMarker.start.row = hoverMarker.end.row = row; + if (!suppressRedraw) + popup.session._emit("changeBackMarker"); + popup._emit("changeHoverMarker"); + } + }; + popup.getHoveredRow = function() { + return hoverMarker.start.row; + }; + + event.addListener(popup.container, "mouseout", hideHoverMarker); + popup.on("hide", hideHoverMarker); + popup.on("changeSelection", hideHoverMarker); + + popup.session.doc.getLength = function() { + return popup.data.length; + }; + popup.session.doc.getLine = function(i) { + var data = popup.data[i]; + if (typeof data == "string") + return data; + return (data && data.value) || ""; + }; + + var bgTokenizer = popup.session.bgTokenizer; + 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.name; + + var last = -1; + var flag, c; + for (var i = 0; i < data.caption.length; i++) { + c = data.caption[i]; + flag = data.matchMask & (1 << i) ? 1 : 0; + if (last !== flag) { + tokens.push({type: data.className || "" + ( flag ? "completion-highlight" : ""), value: c}); + last = flag; + } else { + tokens[tokens.length - 1].value += c; + } + } + + if (data.meta) { + var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth; + 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; + }; + bgTokenizer.$updateOnChange = noop; + bgTokenizer.start = noop; + + popup.session.$computeWidth = function() { + return this.screenWidth = 0; + }; + + popup.$blockScrolling = Infinity; + + // public + popup.isOpen = false; + popup.isTopdown = false; + popup.autoSelect = true; + + popup.data = []; + popup.setData = function(list) { + popup.setValue(lang.stringRepeat("\n", list.length), -1); + popup.data = list || []; + popup.setRow(0); + }; + popup.getData = function(row) { + return popup.data[row]; + }; + + popup.getRow = function() { + return selectionMarker.start.row; + }; + popup.setRow = function(line) { + line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length, line)); + if (selectionMarker.start.row != line) { + popup.selection.clearSelection(); + selectionMarker.start.row = selectionMarker.end.row = line || 0; + popup.session._emit("changeBackMarker"); + popup.moveCursorTo(line || 0, 0); + if (popup.isOpen) + popup._signal("select"); + } + }; + + popup.on("changeSelection", function() { + if (popup.isOpen) + popup.setRow(popup.selection.lead.row); + popup.renderer.scrollCursorIntoView(); + }); + + popup.hide = function() { + this.container.style.display = "none"; + this._signal("hide"); + popup.isOpen = false; + }; + popup.show = function(pos, lineHeight, topdownOnly) { + var el = this.container; + var screenHeight = window.innerHeight; + var screenWidth = window.innerWidth; + var renderer = this.renderer; + // var maxLines = Math.min(renderer.$maxLines, this.session.getLength()); + var maxH = renderer.$maxLines * lineHeight * 1.4; + var top = pos.top + this.$borderSize; + var allowTopdown = top > screenHeight / 2 && !topdownOnly; + if (allowTopdown && top + lineHeight + maxH > screenHeight) { + renderer.$maxPixelHeight = top - 2 * this.$borderSize; + el.style.top = ""; + el.style.bottom = screenHeight - top + "px"; + popup.isTopdown = false; + } else { + top += lineHeight; + renderer.$maxPixelHeight = screenHeight - top - 0.2 * lineHeight; + el.style.top = top + "px"; + el.style.bottom = ""; + popup.isTopdown = true; + } + + el.style.display = ""; + this.renderer.$textLayer.checkForSizeChanges(); + + var left = pos.left; + if (left + el.offsetWidth > screenWidth) + left = screenWidth - el.offsetWidth; + + el.style.left = left + "px"; + + this._signal("show"); + lastMouseEvent = null; + popup.isOpen = true; + }; + + popup.getTextLeftOffset = function() { + return this.$borderSize + this.renderer.$padding + this.$imageSize; + }; + + popup.$imageSize = 0; + popup.$borderSize = 1; + + return popup; +}; + +dom.importCssString("\ +.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\ + background-color: #CAD6FA;\ + z-index: 1;\ +}\ +.ace_editor.ace_autocomplete .ace_line-hover {\ + border: 1px solid #abbffe;\ + margin-top: -1px;\ + background: rgba(233,233,253,0.4);\ +}\ +.ace_editor.ace_autocomplete .ace_line-hover {\ + position: absolute;\ + z-index: 2;\ +}\ +.ace_editor.ace_autocomplete .ace_scroller {\ + background: none;\ + border: none;\ + box-shadow: none;\ +}\ +.ace_rightAlignedText {\ + color: gray;\ + display: inline-block;\ + position: absolute;\ + right: 4px;\ + text-align: right;\ + z-index: -1;\ +}\ +.ace_editor.ace_autocomplete .ace_completion-highlight{\ + color: #000;\ + text-shadow: 0 0 0.01em;\ +}\ +.ace_editor.ace_autocomplete {\ + width: 280px;\ + z-index: 200000;\ + background: #fbfbfb;\ + color: #444;\ + border: 1px lightgray solid;\ + position: fixed;\ + box-shadow: 2px 3px 5px rgba(0,0,0,.2);\ + line-height: 1.4;\ +}"); + +exports.AcePopup = AcePopup; + +}); diff --git a/public/lib/ace/autocomplete/text_completer.js b/public/lib/ace/autocomplete/text_completer.js new file mode 100644 index 0000000..6d4b8d2 --- /dev/null +++ b/public/lib/ace/autocomplete/text_completer.js @@ -0,0 +1,78 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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) { + var Range = require("../range").Range; + + var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/; + + function getWordIndex(doc, pos) { + var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos)); + return textBefore.split(splitRegex).length - 1; + } + + /** + * Does a distance analysis of the word `prefix` at position `pos` in `doc`. + * @return Map + */ + function wordDistance(doc, pos) { + var prefixPos = getWordIndex(doc, pos); + var words = doc.getValue().split(splitRegex); + var wordScores = Object.create(null); + + var currentWord = words[prefixPos]; + + words.forEach(function(word, idx) { + if (!word || word === currentWord) return; + + var distance = Math.abs(prefixPos - idx); + var score = words.length - distance; + if (wordScores[word]) { + wordScores[word] = Math.max(score, wordScores[word]); + } else { + wordScores[word] = score; + } + }); + return wordScores; + } + + exports.getCompletions = function(editor, session, pos, prefix, callback) { + var wordScore = wordDistance(session, pos); + var wordList = Object.keys(wordScore); + callback(null, wordList.map(function(word) { + return { + caption: word, + value: word, + score: wordScore[word], + meta: "local" + }; + })); + }; +}); diff --git a/public/lib/ace/autocomplete/util.js b/public/lib/ace/autocomplete/util.js new file mode 100644 index 0000000..7e1d7f5 --- /dev/null +++ b/public/lib/ace/autocomplete/util.js @@ -0,0 +1,89 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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"; + +exports.parForEach = function(array, fn, callback) { + var completed = 0; + var arLength = array.length; + if (arLength === 0) + callback(); + for (var i = 0; i < arLength; i++) { + fn(array[i], function(result, err) { + completed++; + if (completed === arLength) + callback(result, err); + }); + } +}; + +var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\uFFFF]/; + +exports.retrievePrecedingIdentifier = function(text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos-1; i >= 0; i--) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf.reverse().join(""); +}; + +exports.retrieveFollowingIdentifier = function(text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos; i < text.length; i++) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf; +}; + +exports.getCompletionPrefix = function (editor) { + var pos = editor.getCursorPosition(); + var line = editor.session.getLine(pos.row); + var prefix; + editor.completers.forEach(function(completer) { + if (completer.identifierRegexps) { + completer.identifierRegexps.forEach(function(identifierRegex) { + if (!prefix && identifierRegex) + prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex); + }.bind(this)); + } + }.bind(this)); + return prefix || this.retrievePrecedingIdentifier(line, pos.column); +}; + +}); diff --git a/public/lib/ace/background_tokenizer.js b/public/lib/ace/background_tokenizer.js new file mode 100644 index 0000000..8946342 --- /dev/null +++ b/public/lib/ace/background_tokenizer.js @@ -0,0 +1,251 @@ +/* ***** 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 oop = require("./lib/oop"); +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. + * + * @class BackgroundTokenizer + **/ + +/** + * Creates a new `BackgroundTokenizer` object. + * @param {Tokenizer} tokenizer The tokenizer to use + * @param {Editor} editor The editor to associate with + * + * @constructor + **/ + +var BackgroundTokenizer = function(tokenizer, editor) { + this.running = false; + this.lines = []; + this.states = []; + this.currentLine = 0; + this.tokenizer = tokenizer; + + var self = this; + + this.$worker = function() { + if (!self.running) { return; } + + var workerStart = new Date(); + var currentLine = self.currentLine; + var endLine = -1; + var doc = self.doc; + + var startLine = currentLine; + while (self.lines[currentLine]) + currentLine++; + + var len = doc.getLength(); + var processedLines = 0; + self.running = false; + while (currentLine < len) { + self.$tokenizeRow(currentLine); + endLine = currentLine; + do { + currentLine++; + } while (self.lines[currentLine]); + + // only check every 5 lines + processedLines ++; + if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) { + self.running = setTimeout(self.$worker, 20); + break; + } + } + self.currentLine = currentLine; + + if (endLine == -1) + endLine = currentLine; + + if (startLine <= endLine) + self.fireUpdateEvent(startLine, endLine); + }; +}; + +(function(){ + + oop.implement(this, EventEmitter); + + /** + * Sets a new tokenizer for this object. + * + * @param {Tokenizer} tokenizer The new tokenizer to use + * + **/ + this.setTokenizer = function(tokenizer) { + this.tokenizer = tokenizer; + this.lines = []; + this.states = []; + + this.start(0); + }; + + /** + * Sets a new document to associate with this object. + * @param {Document} doc The new document to associate with + **/ + this.setDocument = function(doc) { + this.doc = doc; + this.lines = []; + this.states = []; + + this.stop(); + }; + + /** + * Fires whenever the background tokeniziers between a range of rows are going to be updated. + * + * @event update + * @param {Object} e An object containing two properties, `first` and `last`, which indicate the rows of the region being updated. + * + **/ + /** + * Emits the `'update'` event. `firstRow` and `lastRow` are used to define the boundaries of the region to be updated. + * @param {Number} firstRow The starting row region + * @param {Number} lastRow The final row region + * + **/ + this.fireUpdateEvent = function(firstRow, lastRow) { + var data = { + first: firstRow, + last: lastRow + }; + this._signal("update", {data: data}); + }; + + /** + * Starts tokenizing at the row indicated. + * + * @param {Number} startRow The row to start at + * + **/ + this.start = function(startRow) { + this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength()); + + // remove all cached items below this line + this.lines.splice(this.currentLine, this.lines.length); + this.states.splice(this.currentLine, this.states.length); + + this.stop(); + // pretty long delay to prevent the tokenizer from interfering with the user + this.running = setTimeout(this.$worker, 700); + }; + + this.scheduleStart = function() { + if (!this.running) + this.running = setTimeout(this.$worker, 700); + }; + + this.$updateOnChange = function(delta) { + var startRow = delta.start.row; + var len = delta.end.row - startRow; + + if (len === 0) { + this.lines[startRow] = null; + } else if (delta.action == "remove") { + this.lines.splice(startRow, len + 1, null); + this.states.splice(startRow, len + 1, null); + } else { + var args = Array(len + 1); + args.unshift(startRow, 1); + this.lines.splice.apply(this.lines, args); + this.states.splice.apply(this.states, args); + } + + this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength()); + + this.stop(); + }; + + /** + * Stops tokenizing. + * + **/ + this.stop = function() { + if (this.running) + clearTimeout(this.running); + this.running = false; + }; + + /** + * Gives list of tokens of the row. (tokens are cached) + * + * @param {Number} row The row to get tokens at + * + * + * + **/ + this.getTokens = function(row) { + return this.lines[row] || this.$tokenizeRow(row); + }; + + /** + * [Returns the state of tokenization at the end of a row.]{: #BackgroundTokenizer.getState} + * + * @param {Number} row The row to get state at + **/ + this.getState = function(row) { + if (this.currentLine == row) + this.$tokenizeRow(row); + return this.states[row] || "start"; + }; + + this.$tokenizeRow = function(row) { + var line = this.doc.getLine(row); + var state = this.states[row - 1]; + + var data = this.tokenizer.getLineTokens(line, state, row); + + if (this.states[row] + "" !== data.state + "") { + this.states[row] = data.state; + this.lines[row + 1] = null; + if (this.currentLine > row + 1) + this.currentLine = row + 1; + } else if (this.currentLine == row) { + this.currentLine = row + 1; + } + + return this.lines[row] = data.tokens; + }; + +}).call(BackgroundTokenizer.prototype); + +exports.BackgroundTokenizer = BackgroundTokenizer; +}); diff --git a/public/lib/ace/background_tokenizer_test.js b/public/lib/ace/background_tokenizer_test.js new file mode 100644 index 0000000..d5267bc --- /dev/null +++ b/public/lib/ace/background_tokenizer_test.js @@ -0,0 +1,152 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { +"use strict"; + +var EditSession = require("./edit_session").EditSession; +var JavaScriptMode = require("./mode/javascript").Mode; +var LuaMode = require("./mode/lua").Mode; +var Range = require("./range").Range; +var assert = require("./test/assertions"); + +function forceTokenize(session, startLine) { + for (var i = startLine || 0, l = session.getLength(); i < l; i++) + session.getTokens(i); +} + +function testStates(session, states) { + for (var i = 0, l = session.getLength(); i < l; i++) + assert.equal(session.bgTokenizer.states[i], states[i]); + assert.ok(l == states.length); +} + +module.exports = { + + "test background tokenizer update on session change" : function() { + var doc = new EditSession([ + "/*", + "*/", + "var juhu" + ]); + doc.setMode("./mode/javascript"); + + forceTokenize(doc); + testStates(doc, ["comment1", "start", "no_regex"]); + + doc.remove(new Range(0,2,1,2)); + testStates(doc, [null, "no_regex"]); + + forceTokenize(doc); + testStates(doc, ["comment1", "comment1"]); + + doc.insert({row:0, column:2}, "\n*/"); + testStates(doc, [undefined, undefined, "comment1"]); + + forceTokenize(doc); + testStates(doc, ["comment1", "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 = "comment1"; + 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"]); + }, + "test background tokenizer sends update event 2" : function(next) { + var doc = new EditSession([ + "-[[", + "juhu", + "kinners]]--", + "" + ]); + doc.setMode("./mode/lua"); + forceTokenize(doc); + var string = "bracketedString,2,start"; + var comment = "bracketedComment,2,start"; + testStates(doc, [string, string, "start", "start"]); + + doc.insert({row:0, column:0}, "-"); + forceTokenize(doc); + doc.bgTokenizer.once("update", function(e) { + assert.equal([0, 4] + "", [e.data.first, e.data.last] + ""); + testStates(doc, [comment, comment, "start", "start"]); + next(); + }); + doc.bgTokenizer.running = 1; + doc.bgTokenizer.$worker(); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/bidihandler.js b/public/lib/ace/bidihandler.js new file mode 100644 index 0000000..374e0bf --- /dev/null +++ b/public/lib/ace/bidihandler.js @@ -0,0 +1,338 @@ +/* ***** 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 bidiUtil = require("./lib/bidiutil"); +var lang = require("./lib/lang"); +var useragent = require("./lib/useragent"); +var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; + +/** + * This object is used to ensure Bi-Directional support (for languages with text flowing from right to left, like Arabic or Hebrew) + * including correct caret positioning, text selection mouse and keyboard arrows functioning + * @class BidiHandler + **/ + +/** + * Creates a new `BidiHandler` object + * @param {EditSession} session The session to use + * + * @constructor + **/ +var BidiHandler = function(session) { + this.session = session; + this.bidiMap = {}; + /* current screen row */ + this.currentRow = null; + this.bidiUtil = bidiUtil; + /* Arabic/Hebrew character width differs from regular character width */ + this.charWidths = []; + this.EOL = "\xAC"; + this.showInvisibles = true; + this.isRtlDir = false; + this.line = ""; + this.wrapIndent = 0; + this.isLastRow = false; + this.EOF = "\xB6"; + this.seenBidi = false; +}; + +(function() { + /** + * Returns 'true' if row contains Bidi characters, in such case + * creates Bidi map to be used in operations related to selection + * (keyboard arrays, mouse click, select) + * @param {Number} the screen row to be checked + * @param {Number} the document row to be checked [optional] + * @param {Number} the wrapped screen line index [ optional] + **/ + this.isBidiRow = function(screenRow, docRow, splitIndex) { + if (!this.seenBidi) + return false; + if (screenRow !== this.currentRow) { + this.currentRow = screenRow; + this.updateRowLine(docRow, splitIndex); + this.updateBidiMap(); + } + return this.bidiMap.bidiLevels; + }; + + this.onChange = function(delta) { + if (!this.seenBidi) { + if (delta.action == "insert" && bidiRE.test(delta.lines.join("\n"))) { + this.seenBidi = true; + this.currentRow = null; + } + } + else { + this.currentRow = null; + } + }; + + this.getDocumentRow = function() { + var docRow = 0; + var rowCache = this.session.$screenRowCache; + if (rowCache.length) { + var index = this.session.$getRowCacheIndex(rowCache, this.currentRow); + if (index >= 0) + docRow = this.session.$docRowCache[index]; + } + + return docRow; + }; + + this.getSplitIndex = function() { + var splitIndex = 0; + var rowCache = this.session.$screenRowCache; + if (rowCache.length) { + var currentIndex, prevIndex = this.session.$getRowCacheIndex(rowCache, this.currentRow); + while (this.currentRow - splitIndex > 0) { + currentIndex = this.session.$getRowCacheIndex(rowCache, this.currentRow - splitIndex - 1); + if (currentIndex !== prevIndex) + break; + + prevIndex = currentIndex; + splitIndex++; + } + } + + return splitIndex; + }; + + this.updateRowLine = function(docRow, splitIndex) { + if (docRow === undefined) + docRow = this.getDocumentRow(); + + this.wrapIndent = 0; + this.isLastRow = (docRow === this.session.getLength() - 1); + this.line = this.session.getLine(docRow); + if (this.session.$useWrapMode) { + var splits = this.session.$wrapData[docRow]; + if (splits) { + if (splitIndex === undefined) + splitIndex = this.getSplitIndex(); + + if(splitIndex > 0 && splits.length) { + this.wrapIndent = splits.indent; + this.line = (splitIndex < splits.length) ? + this.line.substring(splits[splitIndex - 1], splits[splits.length - 1]) : + this.line.substring(splits[splits.length - 1]); + } else { + this.line = this.line.substring(0, splits[splitIndex]); + } + } + } + + /* replace tab and wide characters by commensurate spaces */ + var session = this.session, shift = 0, size; + this.line = this.line.replace(/\t|[\u1100-\u2029, \u202F-\uFFE6]/g, function(ch, i){ + if (ch === '\t' || session.isFullWidth(ch.charCodeAt(0))) { + size = (ch === '\t') ? session.getScreenTabSize(i + shift) : 2; + shift += size - 1; + return lang.stringRepeat(bidiUtil.DOT, size); + } + return ch; + }); + }; + + this.updateBidiMap = function() { + var textCharTypes = [], endOfLine = this.isLastRow ? this.EOF : this.EOL; + var line = this.line + (this.showInvisibles ? endOfLine : bidiUtil.DOT); + if (bidiUtil.hasBidiCharacters(line, textCharTypes)) { + this.bidiMap = bidiUtil.doBidiReorder(line, textCharTypes, this.isRtlDir); + } else { + this.bidiMap = {}; + } + }; + + /** + * Resets stored info related to current screen row + **/ + this.markAsDirty = function() { + this.currentRow = null; + }; + + /** + * Updates array of character widths + * @param {Object} font metrics + * + **/ + this.updateCharacterWidths = function(fontMetrics) { + if (!this.seenBidi) + return; + if (this.characterWidth === fontMetrics.$characterSize.width) + return; + + var characterWidth = this.characterWidth = fontMetrics.$characterSize.width; + var bidiCharWidth = fontMetrics.$measureCharWidth("\u05d4"); + + this.charWidths[bidiUtil.L] = this.charWidths[bidiUtil.EN] = this.charWidths[bidiUtil.ON_R] = characterWidth; + this.charWidths[bidiUtil.R] = this.charWidths[bidiUtil.AN] = bidiCharWidth; + this.charWidths[bidiUtil.R_H] = useragent.isChrome ? bidiCharWidth : bidiCharWidth * 0.45; + this.charWidths[bidiUtil.B] = 0; + + this.currentRow = null; + }; + + this.getShowInvisibles = function() { + return this.showInvisibles; + }; + + this.setShowInvisibles = function(showInvisibles) { + this.showInvisibles = showInvisibles; + this.currentRow = null; + }; + + this.setEolChar = function(eolChar) { + this.EOL = eolChar; + }; + + this.setTextDir = function(isRtlDir) { + this.isRtlDir = isRtlDir; + }; + + /** + * Returns offset of character at position defined by column. + * @param {Number} the screen column position + * + * @return {int} horizontal pixel offset of given screen column + **/ + this.getPosLeft = function(col) { + col -= this.wrapIndent; + var visualIdx = bidiUtil.getVisualFromLogicalIdx(col > 0 ? col - 1 : 0, this.bidiMap), + levels = this.bidiMap.bidiLevels, left = 0; + + if (col === 0 && levels[visualIdx] % 2 !== 0) + visualIdx++; + + for (var i = 0; i < visualIdx; i++) { + left += this.charWidths[levels[i]]; + } + + if (col !== 0 && levels[visualIdx] % 2 === 0) + left += this.charWidths[levels[visualIdx]]; + + if (this.wrapIndent) + left += this.wrapIndent * this.charWidths[bidiUtil.L]; + + return left; + }; + + /** + * Returns 'selections' - array of objects defining set of selection rectangles + * @param {Number} the start column position + * @param {Number} the end column position + * + * @return {Array of Objects} Each object contains 'left' and 'width' values defining selection rectangle. + **/ + this.getSelections = function(startCol, endCol) { + var map = this.bidiMap, levels = map.bidiLevels, level, offset = this.wrapIndent * this.charWidths[bidiUtil.L], selections = [], + selColMin = Math.min(startCol, endCol) - this.wrapIndent, selColMax = Math.max(startCol, endCol) - this.wrapIndent, + isSelected = false, isSelectedPrev = false, selectionStart = 0; + + for (var logIdx, visIdx = 0; visIdx < levels.length; visIdx++) { + logIdx = map.logicalFromVisual[visIdx]; + level = levels[visIdx]; + isSelected = (logIdx >= selColMin) && (logIdx < selColMax); + if (isSelected && !isSelectedPrev) { + selectionStart = offset; + } else if (!isSelected && isSelectedPrev) { + selections.push({left: selectionStart, width: offset - selectionStart}); + } + offset += this.charWidths[level]; + isSelectedPrev = isSelected; + } + + if (isSelected && (visIdx === levels.length)) { + selections.push({left: selectionStart, width: offset - selectionStart}); + } + + return selections; + }; + + /** + * Converts character coordinates on the screen to respective document column number + * @param {int} character horizontal offset + * + * @return {Number} screen column number corresponding to given pixel offset + **/ + this.offsetToCol = function(posX) { + var logicalIdx = 0, posX = Math.max(posX, 0), + offset = 0, visualIdx = 0, levels = this.bidiMap.bidiLevels, + charWidth = this.charWidths[levels[visualIdx]]; + + if (this.wrapIndent) { + posX -= this.wrapIndent * this.charWidths[bidiUtil.L]; + } + + while(posX > offset + charWidth/2) { + offset += charWidth; + if(visualIdx === levels.length - 1) { + /* quit when we on the right of the last character, flag this by charWidth = 0 */ + charWidth = 0; + break; + } + charWidth = this.charWidths[levels[++visualIdx]]; + } + + if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && (levels[visualIdx] % 2 === 0)){ + /* Bidi character on the left and None Bidi character on the right */ + if(posX < offset) + visualIdx--; + logicalIdx = this.bidiMap.logicalFromVisual[visualIdx]; + + } else if (visualIdx > 0 && (levels[visualIdx - 1] % 2 === 0) && (levels[visualIdx] % 2 !== 0)){ + /* None Bidi character on the left and Bidi character on the right */ + logicalIdx = 1 + ((posX > offset) ? this.bidiMap.logicalFromVisual[visualIdx] + : this.bidiMap.logicalFromVisual[visualIdx - 1]); + + } else if ((this.isRtlDir && visualIdx === levels.length - 1 && charWidth === 0 && (levels[visualIdx - 1] % 2 === 0)) + || (!this.isRtlDir && visualIdx === 0 && (levels[visualIdx] % 2 !== 0))){ + /* To the right of last character, which is None Bidi, in RTL direction or */ + /* to the left of first Bidi character, in LTR direction */ + logicalIdx = 1 + this.bidiMap.logicalFromVisual[visualIdx]; + } else { + /* Tweak visual position when Bidi character on the left in order to map it to corresponding logical position */ + if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && charWidth !== 0) + visualIdx--; + + /* Regular case */ + logicalIdx = this.bidiMap.logicalFromVisual[visualIdx]; + } + + return (logicalIdx + this.wrapIndent); + }; + +}).call(BidiHandler.prototype); + +exports.BidiHandler = BidiHandler; +}); diff --git a/public/lib/ace/commands/command_manager.js b/public/lib/ace/commands/command_manager.js new file mode 100644 index 0000000..dd68c63 --- /dev/null +++ b/public/lib/ace/commands/command_manager.js @@ -0,0 +1,121 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +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 {Array} commands A list of commands + * + **/ + +var CommandManager = function(platform, commands) { + 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, MultiHashHandler); + +(function() { + + oop.implement(this, EventEmitter); + + this.exec = function(command, editor, args) { + 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) + return false; + + if (editor && editor.$readOnly && !command.readOnly) + return false; + + if (command.isAvailable && !command.isAvailable(editor)) + return false; + + var e = {editor: editor, command: command, args: args}; + e.returnValue = this._emit("exec", e); + this._signal("afterExec", e); + + return e.returnValue === false ? false : true; + }; + + this.toggleRecording = function(editor) { + if (this.$inReplay) + return; + + editor && editor._emit("changeStatus"); + if (this.recording) { + this.macro.pop(); + this.removeEventListener("exec", this.$addCommandToMacro); + + if (!this.macro.length) + this.macro = this.oldMacro; + + return this.recording = false; + } + if (!this.$addCommandToMacro) { + this.$addCommandToMacro = function(e) { + this.macro.push([e.command, e.args]); + }.bind(this); + } + + this.oldMacro = this.macro; + this.macro = []; + this.on("exec", this.$addCommandToMacro); + return this.recording = true; + }; + + this.replay = function(editor) { + if (this.$inReplay || !this.macro) + return; + + if (this.recording) + return this.toggleRecording(editor); + + try { + this.$inReplay = true; + this.macro.forEach(function(x) { + if (typeof x == "string") + this.exec(x, editor); + else + this.exec(x[0], editor, x[1]); + }, this); + } finally { + this.$inReplay = false; + } + }; + + this.trimMacro = function(m) { + return m.map(function(x){ + if (typeof x[0] != "string") + x[0] = x[0].name; + if (!x[1]) + x = x[0]; + return x; + }); + }; + +}).call(CommandManager.prototype); + +exports.CommandManager = CommandManager; + +}); diff --git a/public/lib/ace/commands/command_manager_test.js b/public/lib/ace/commands/command_manager_test.js new file mode 100644 index 0000000..7e3269b --- /dev/null +++ b/public/lib/ace/commands/command_manager_test.js @@ -0,0 +1,208 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { +"use strict"; + +var CommandManager = require("./command_manager").CommandManager; +var keys = require("../lib/keys"); +var assert = require("../test/assertions"); + +module.exports = { + + setUp: function() { + this.command = { + name: "gotoline", + bindKey: { + mac: "Command-L", + win: "Ctrl-L" + }, + called: false, + available: true, + exec: function(editor) { this.called = true; }, + isAvailable: function(editor) { return this.available; } + }; + + this.cm = new CommandManager("mac", [this.command]); + }, + + "test: register command": function() { + this.cm.exec("gotoline"); + assert.ok(this.command.called); + }, + + "test: mac hotkeys": function() { + var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "l"); + assert.equal(command, this.command); + + var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "l"); + assert.equal(command, undefined); + }, + + "test: win hotkeys": function() { + var cm = new CommandManager("win", [this.command]); + + var command = cm.findKeyCommand(keys.KEY_MODS.command, "l"); + assert.equal(command, undefined); + + var command = cm.findKeyCommand(keys.KEY_MODS.ctrl, "l"); + assert.equal(command, this.command); + }, + + "test: command isAvailable": function() { + this.command.available = false; + + this.cm.exec("gotoline"); + assert.ok(!this.command.called); + }, + + "test: remove command by object": function() { + this.cm.removeCommand(this.command); + + this.cm.exec("gotoline"); + assert.ok(!this.command.called); + + var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "l"); + assert.equal(command, null); + }, + + "test: remove command by name": function() { + this.cm.removeCommand("gotoline"); + + this.cm.exec("gotoline"); + assert.ok(!this.command.called); + + var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "l"); + assert.equal(command, null); + }, + + "test: adding a new command with the same name as an existing one should remove the old one first": function() { + var command = { + name: "gotoline", + bindKey: { + mac: "Command-L", + win: "Ctrl-L" + }, + called: false, + exec: function(editor) { this.called = true; } + }; + this.cm.addCommand(command); + + this.cm.exec("gotoline"); + assert.ok(command.called); + assert.ok(!this.command.called); + + assert.equal(this.cm.findKeyCommand(keys.KEY_MODS.command, "l"), command); + }, + + "test: adding commands and recording a macro": function() { + var called = ""; + this.cm.addCommands({ + togglerecording: function(editor) { + editor.cm.toggleRecording(editor); + }, + replay: function(editor) { + editor.cm.replay(); + }, + cm1: function(editor, arg) { + called += "1" + (arg || ""); + }, + cm2: function(editor) { + called += "2"; + } + }); + + + var statusUpdateEmitted = false; + this._emit = function() {statusUpdateEmitted = true;}; + + this.cm.exec("togglerecording", this); + assert.ok(this.cm.recording); + assert.ok(statusUpdateEmitted); + + this.cm.exec("cm1", this, "-"); + this.cm.exec("cm2"); + this.cm.exec("replay", this); + assert.ok(!this.cm.recording); + assert.equal(called, "1-2"); + + called = ""; + this.cm.exec("replay", this); + assert.equal(called, "1-2"); + }, + + "test: bindkeys": function() { + this.cm.bindKeys({ + "Ctrl-L|Command-C": "cm1", + "Ctrl-R": "cm2" + }); + + var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "c"); + assert.equal(command, "cm1"); + + var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "r"); + assert.equal(command, "cm2"); + + this.cm.bindKeys({ + "Ctrl-R": null + }); + + var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "r"); + assert.equal(command, null); + }, + + "test: binding keys without modifiers": function() { + this.cm.bindKeys({ + "R": "cm1", + "Shift-r": "cm2", + "Return": "cm4", + "Enter": "cm3" + }); + + var command = this.cm.findKeyCommand(-1, "r"); + assert.equal(command, "cm1"); + + var command = this.cm.findKeyCommand(-1, "R"); + assert.equal(command, "cm2"); + + var command = this.cm.findKeyCommand(0, "return"); + assert.equal(command + "", ["cm4", "cm3"] + ""); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/commands/default_commands.js b/public/lib/ace/commands/default_commands.js new file mode 100644 index 0000000..e5c9439 --- /dev/null +++ b/public/lib/ace/commands/default_commands.js @@ -0,0 +1,757 @@ +/* ***** 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 lang = require("../lib/lang"); +var config = require("../config"); +var Range = require("../range").Range; + +function bindKey(win, mac) { + return {win: win, mac: mac}; +} + +/* + multiSelectAction: "forEach"|"forEachLine"|function|undefined, + scrollIntoView: true|"cursor"|"center"|"selectionPart" +*/ +exports.commands = [{ + name: "showSettingsMenu", + bindKey: bindKey("Ctrl-,", "Command-,"), + exec: function(editor) { + config.loadModule("ace/ext/settings_menu", function(module) { + module.init(editor); + editor.showSettingsMenu(); + }); + }, + readOnly: true +}, { + name: "goToNextError", + bindKey: bindKey("Alt-E", "F4"), + exec: function(editor) { + config.loadModule("ace/ext/error_marker", function(module) { + module.showErrorMarker(editor, 1); + }); + }, + scrollIntoView: "animate", + readOnly: true +}, { + name: "goToPreviousError", + bindKey: bindKey("Alt-Shift-E", "Shift-F4"), + exec: function(editor) { + config.loadModule("ace/ext/error_marker", function(module) { + module.showErrorMarker(editor, -1); + }); + }, + scrollIntoView: "animate", + readOnly: true +}, { + name: "selectall", + bindKey: bindKey("Ctrl-A", "Command-A"), + exec: function(editor) { editor.selectAll(); }, + readOnly: true +}, { + name: "centerselection", + bindKey: bindKey(null, "Ctrl-L"), + exec: function(editor) { editor.centerSelection(); }, + readOnly: true +}, { + name: "gotoline", + bindKey: bindKey("Ctrl-L", "Command-L"), + exec: function(editor) { + var line = parseInt(prompt("Enter line number:"), 10); + if (!isNaN(line)) { + editor.gotoLine(line); + } + }, + readOnly: true +}, { + 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(null, "Ctrl-Command-Option-0"), + exec: function(editor) { editor.session.foldAll(); }, + scrollIntoView: "center", + readOnly: true +}, { + name: "foldOther", + bindKey: bindKey("Alt-0", "Command-Option-0"), + exec: function(editor) { + editor.session.foldAll(); + editor.session.unfold(editor.selection.getAllRanges()); + }, + scrollIntoView: "center", + readOnly: true +}, { + name: "unfoldall", + bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"), + exec: function(editor) { editor.session.unfold(); }, + scrollIntoView: "center", + readOnly: true +}, { + name: "findnext", + bindKey: bindKey("Ctrl-K", "Command-G"), + exec: function(editor) { editor.findNext(); }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: true +}, { + name: "findprevious", + bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), + exec: function(editor) { editor.findPrevious(); }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: true +}, { + name: "selectOrFindNext", + bindKey: bindKey("Alt-K", "Ctrl-G"), + exec: function(editor) { + if (editor.selection.isEmpty()) + editor.selection.selectWord(); + else + editor.findNext(); + }, + readOnly: true +}, { + name: "selectOrFindPrevious", + bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"), + exec: function(editor) { + if (editor.selection.isEmpty()) + editor.selection.selectWord(); + else + editor.findPrevious(); + }, + readOnly: true +}, { + name: "find", + bindKey: bindKey("Ctrl-F", "Command-F"), + exec: function(editor) { + config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor);}); + }, + readOnly: true +}, { + name: "overwrite", + bindKey: "Insert", + exec: function(editor) { editor.toggleOverwrite(); }, + readOnly: true +}, { + name: "selecttostart", + bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Home|Command-Shift-Up"), + exec: function(editor) { editor.getSelection().selectFileStart(); }, + multiSelectAction: "forEach", + readOnly: true, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" +}, { + name: "gotostart", + bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"), + exec: function(editor) { editor.navigateFileStart(); }, + multiSelectAction: "forEach", + readOnly: true, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" +}, { + name: "selectup", + bindKey: bindKey("Shift-Up", "Shift-Up|Ctrl-Shift-P"), + 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", + bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-End|Command-Shift-Down"), + exec: function(editor) { editor.getSelection().selectFileEnd(); }, + multiSelectAction: "forEach", + readOnly: true, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" +}, { + name: "gotoend", + bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"), + exec: function(editor) { editor.navigateFileEnd(); }, + multiSelectAction: "forEach", + readOnly: true, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" +}, { + name: "selectdown", + bindKey: bindKey("Shift-Down", "Shift-Down|Ctrl-Shift-N"), + exec: function(editor) { editor.getSelection().selectDown(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "golinedown", + bindKey: bindKey("Down", "Down|Ctrl-N"), + exec: function(editor, args) { editor.navigateDown(args.times); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "selectwordleft", + bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"), + exec: function(editor) { editor.getSelection().selectWordLeft(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "gotowordleft", + bindKey: bindKey("Ctrl-Left", "Option-Left"), + exec: function(editor) { editor.navigateWordLeft(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "selecttolinestart", + bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left|Ctrl-Shift-A"), + exec: function(editor) { editor.getSelection().selectLineStart(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "gotolinestart", + bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"), + exec: function(editor) { editor.navigateLineStart(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "selectleft", + bindKey: bindKey("Shift-Left", "Shift-Left|Ctrl-Shift-B"), + exec: function(editor) { editor.getSelection().selectLeft(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "gotoleft", + bindKey: bindKey("Left", "Left|Ctrl-B"), + exec: function(editor, args) { editor.navigateLeft(args.times); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "selectwordright", + bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"), + exec: function(editor) { editor.getSelection().selectWordRight(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "gotowordright", + bindKey: bindKey("Ctrl-Right", "Option-Right"), + exec: function(editor) { editor.navigateWordRight(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "selecttolineend", + bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right|Shift-End|Ctrl-Shift-E"), + exec: function(editor) { editor.getSelection().selectLineEnd(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "gotolineend", + bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"), + exec: function(editor) { editor.navigateLineEnd(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "selectright", + bindKey: bindKey("Shift-Right", "Shift-Right"), + exec: function(editor) { editor.getSelection().selectRight(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "gotoright", + bindKey: bindKey("Right", "Right|Ctrl-F"), + exec: function(editor, args) { editor.navigateRight(args.times); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "selectpagedown", + bindKey: "Shift-PageDown", + exec: function(editor) { editor.selectPageDown(); }, + readOnly: true +}, { + name: "pagedown", + bindKey: bindKey(null, "Option-PageDown"), + exec: function(editor) { editor.scrollPageDown(); }, + readOnly: true +}, { + name: "gotopagedown", + bindKey: bindKey("PageDown", "PageDown|Ctrl-V"), + exec: function(editor) { editor.gotoPageDown(); }, + readOnly: true +}, { + name: "selectpageup", + bindKey: "Shift-PageUp", + exec: function(editor) { editor.selectPageUp(); }, + readOnly: true +}, { + name: "pageup", + bindKey: bindKey(null, "Option-PageUp"), + exec: function(editor) { editor.scrollPageUp(); }, + readOnly: true +}, { + name: "gotopageup", + bindKey: "PageUp", + exec: function(editor) { editor.gotoPageUp(); }, + readOnly: true +}, { + name: "scrollup", + bindKey: bindKey("Ctrl-Up", null), + exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); }, + readOnly: true +}, { + name: "scrolldown", + bindKey: bindKey("Ctrl-Down", null), + exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); }, + readOnly: true +}, { + name: "selectlinestart", + bindKey: "Shift-Home", + exec: function(editor) { editor.getSelection().selectLineStart(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "selectlineend", + bindKey: "Shift-End", + exec: function(editor) { editor.getSelection().selectLineEnd(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "togglerecording", + bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"), + exec: function(editor) { editor.commands.toggleRecording(editor); }, + readOnly: true +}, { + name: "replaymacro", + bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"), + exec: function(editor) { editor.commands.replay(editor); }, + readOnly: true +}, { + name: "jumptomatching", + bindKey: bindKey("Ctrl-P", "Ctrl-P"), + exec: function(editor) { editor.jumpToMatching(); }, + multiSelectAction: "forEach", + scrollIntoView: "animate", + readOnly: true +}, { + name: "selecttomatching", + 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 +{ + name: "cut", + exec: function(editor) { + var range = editor.getSelectionRange(); + editor._emit("cut", range); + + if (!editor.selection.isEmpty()) { + editor.session.remove(range); + editor.clearSelection(); + } + }, + scrollIntoView: "cursor", + multiSelectAction: "forEach" +}, { + name: "paste", + exec: function(editor, args) { + editor.$handlePaste(args); + }, + scrollIntoView: "cursor" +}, { + name: "removeline", + bindKey: bindKey("Ctrl-D", "Command-D"), + exec: function(editor) { editor.removeLines(); }, + scrollIntoView: "cursor", + multiSelectAction: "forEachLine" +}, { + name: "duplicateSelection", + bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"), + exec: function(editor) { editor.duplicateSelection(); }, + scrollIntoView: "cursor", + multiSelectAction: "forEach" +}, { + name: "sortlines", + bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"), + exec: function(editor) { editor.sortLines(); }, + scrollIntoView: "selection", + multiSelectAction: "forEachLine" +}, { + name: "togglecomment", + bindKey: bindKey("Ctrl-/", "Command-/"), + exec: function(editor) { editor.toggleCommentLines(); }, + multiSelectAction: "forEachLine", + scrollIntoView: "selectionPart" +}, { + name: "toggleBlockComment", + bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"), + exec: function(editor) { editor.toggleBlockComment(); }, + multiSelectAction: "forEach", + scrollIntoView: "selectionPart" +}, { + 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", + bindKey: bindKey("Ctrl-H", "Command-Option-F"), + exec: function(editor) { + config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true);}); + } +}, { + name: "undo", + bindKey: bindKey("Ctrl-Z", "Command-Z"), + exec: function(editor) { editor.undo(); } +}, { + name: "redo", + bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"), + exec: function(editor) { editor.redo(); } +}, { + name: "copylinesup", + bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"), + exec: function(editor) { editor.copyLinesUp(); }, + scrollIntoView: "cursor" +}, { + name: "movelinesup", + bindKey: bindKey("Alt-Up", "Option-Up"), + exec: function(editor) { editor.moveLinesUp(); }, + scrollIntoView: "cursor" +}, { + name: "copylinesdown", + bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"), + exec: function(editor) { editor.copyLinesDown(); }, + scrollIntoView: "cursor" +}, { + name: "movelinesdown", + bindKey: bindKey("Alt-Down", "Option-Down"), + exec: function(editor) { editor.moveLinesDown(); }, + scrollIntoView: "cursor" +}, { + name: "del", + bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"), + exec: function(editor) { editor.remove("right"); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "backspace", + bindKey: bindKey( + "Shift-Backspace|Backspace", + "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H" + ), + exec: function(editor) { editor.remove("left"); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "cut_or_delete", + bindKey: bindKey("Shift-Delete", null), + exec: function(editor) { + if (editor.selection.isEmpty()) { + editor.remove("left"); + } else { + return false; + } + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "removetolinestart", + bindKey: bindKey("Alt-Backspace", "Command-Backspace"), + exec: function(editor) { editor.removeToLineStart(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "removetolineend", + bindKey: bindKey("Alt-Delete", "Ctrl-K|Command-Delete"), + exec: function(editor) { editor.removeToLineEnd(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "removetolinestarthard", + bindKey: bindKey("Ctrl-Shift-Backspace", null), + exec: function(editor) { + var range = editor.selection.getRange(); + range.start.column = 0; + editor.session.remove(range); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "removetolineendhard", + bindKey: bindKey("Ctrl-Shift-Delete", null), + exec: function(editor) { + var range = editor.selection.getRange(); + range.end.column = Number.MAX_VALUE; + editor.session.remove(range); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "removewordleft", + bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"), + exec: function(editor) { editor.removeWordLeft(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "removewordright", + bindKey: bindKey("Ctrl-Delete", "Alt-Delete"), + exec: function(editor) { editor.removeWordRight(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "outdent", + bindKey: bindKey("Shift-Tab", "Shift-Tab"), + exec: function(editor) { editor.blockOutdent(); }, + multiSelectAction: "forEach", + scrollIntoView: "selectionPart" +}, { + name: "indent", + bindKey: bindKey("Tab", "Tab"), + exec: function(editor) { editor.indent(); }, + multiSelectAction: "forEach", + scrollIntoView: "selectionPart" +}, { + name: "blockoutdent", + bindKey: bindKey("Ctrl-[", "Ctrl-["), + exec: function(editor) { editor.blockOutdent(); }, + multiSelectAction: "forEachLine", + scrollIntoView: "selectionPart" +}, { + name: "blockindent", + bindKey: bindKey("Ctrl-]", "Ctrl-]"), + exec: function(editor) { editor.blockIndent(); }, + multiSelectAction: "forEachLine", + scrollIntoView: "selectionPart" +}, { + name: "insertstring", + exec: function(editor, str) { editor.insert(str); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "inserttext", + exec: function(editor, args) { + editor.insert(lang.stringRepeat(args.text || "", args.times || 1)); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "splitline", + bindKey: bindKey(null, "Ctrl-O"), + exec: function(editor) { editor.splitLine(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "transposeletters", + bindKey: bindKey("Alt-Shift-X", "Ctrl-T"), + exec: function(editor) { editor.transposeLetters(); }, + multiSelectAction: function(editor) {editor.transposeSelections(1); }, + scrollIntoView: "cursor" +}, { + name: "touppercase", + bindKey: bindKey("Ctrl-U", "Ctrl-U"), + exec: function(editor) { editor.toUpperCase(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "tolowercase", + bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"), + exec: function(editor) { editor.toLowerCase(); }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "expandtoline", + bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"), + exec: function(editor) { + var range = editor.selection.getRange(); + + range.start.column = range.end.column = 0; + range.end.row++; + editor.selection.setRange(range, false); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "joinlines", + bindKey: bindKey(null, null), + exec: function(editor) { + 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 selectedText = editor.session.doc.getTextRange(editor.selection.getRange()); + var selectedCount = selectedText.replace(/\n\s*/, " ").length; + var insertLine = editor.session.doc.getLine(selectionStart.row); + + for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) { + var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i))); + if (curLine.length !== 0) { + curLine = " " + curLine; + } + insertLine += curLine; + } + + if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) { + // Don't insert a newline at the end of the document + insertLine += editor.session.doc.getNewLineCharacter(); + } + + editor.clearSelection(); + editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine); + + if (selectedCount > 0) { + // Select the text that was previously selected + editor.selection.moveCursorTo(selectionStart.row, selectionStart.column); + editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount); + } else { + // If the joined line had something in it, start the cursor at that something + firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol; + editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol); + } + }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "invertSelection", + bindKey: bindKey(null, null), + exec: function(editor) { + var endRow = editor.session.doc.getLength() - 1; + var endCol = editor.session.doc.getLine(endRow).length; + var ranges = editor.selection.rangeList.ranges; + var newRanges = []; + + // If multiple selections don't exist, rangeList will return 0 so replace with single range + if (ranges.length < 1) { + ranges = [editor.selection.getRange()]; + } + + for (var i = 0; i < ranges.length; i++) { + if (i == (ranges.length - 1)) { + // The last selection must connect to the end of the document, unless it already does + if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) { + newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol)); + } + } + + if (i === 0) { + // The first selection must connect to the start of the document, unless it already does + if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) { + newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column)); + } + } else { + newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column)); + } + } + + editor.exitMultiSelectMode(); + editor.clearSelection(); + + for(var i = 0; i < newRanges.length; i++) { + editor.selection.addRange(newRanges[i], false); + } + }, + readOnly: true, + scrollIntoView: "none" +}]; + +}); diff --git a/public/lib/ace/commands/incremental_search_commands.js b/public/lib/ace/commands/incremental_search_commands.js new file mode 100644 index 0000000..1954866 --- /dev/null +++ b/public/lib/ace/commands/incremental_search_commands.js @@ -0,0 +1,214 @@ +/* ***** 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) { + +var config = require("../config"); +var oop = require("../lib/oop"); +var HashHandler = require("../keyboard/hash_handler").HashHandler; +var occurStartCommand = require("./occur_commands").occurStartCommand; + +// These commands can be installed in a normal key handler to start iSearch: +exports.iSearchStartCommands = [{ + name: "iSearch", + bindKey: {win: "Ctrl-F", mac: "Command-F"}, + exec: function(editor, options) { + config.loadModule(["core", "ace/incremental_search"], function(e) { + var iSearch = e.iSearch = e.iSearch || new e.IncrementalSearch(); + iSearch.activate(editor, options.backwards); + if (options.jumpToFirstMatch) iSearch.next(options); + }); + }, + readOnly: true +}, { + name: "iSearchBackwards", + exec: function(editor, jumpToNext) { editor.execCommand('iSearch', {backwards: true}); }, + readOnly: true +}, { + name: "iSearchAndGo", + bindKey: {win: "Ctrl-K", mac: "Command-G"}, + exec: function(editor, jumpToNext) { editor.execCommand('iSearch', {jumpToFirstMatch: true, useCurrentOrPrevSearch: true}); }, + readOnly: true +}, { + name: "iSearchBackwardsAndGo", + bindKey: {win: "Ctrl-Shift-K", mac: "Command-Shift-G"}, + exec: function(editor) { editor.execCommand('iSearch', {jumpToFirstMatch: true, backwards: true, useCurrentOrPrevSearch: true}); }, + readOnly: true +}]; + +// These commands are only available when incremental search mode is active: +exports.iSearchCommands = [{ + name: "restartSearch", + bindKey: {win: "Ctrl-F", mac: "Command-F"}, + exec: function(iSearch) { + iSearch.cancelSearch(true); + } +}, { + name: "searchForward", + bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"}, + exec: function(iSearch, options) { + options.useCurrentOrPrevSearch = true; + iSearch.next(options); + } +}, { + name: "searchBackward", + bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"}, + exec: function(iSearch, options) { + options.useCurrentOrPrevSearch = true; + options.backwards = true; + iSearch.next(options); + } +}, { + name: "extendSearchTerm", + exec: function(iSearch, string) { + iSearch.addString(string); + } +}, { + name: "extendSearchTermSpace", + bindKey: "space", + exec: function(iSearch) { iSearch.addString(' '); } +}, { + name: "shrinkSearchTerm", + bindKey: "backspace", + exec: function(iSearch) { + iSearch.removeChar(); + } +}, { + name: 'confirmSearch', + bindKey: 'return', + exec: function(iSearch) { iSearch.deactivate(); } +}, { + name: 'cancelSearch', + bindKey: 'esc|Ctrl-G', + exec: function(iSearch) { iSearch.deactivate(true); } +}, { + name: 'occurisearch', + bindKey: 'Ctrl-O', + exec: function(iSearch) { + var options = oop.mixin({}, iSearch.$options); + iSearch.deactivate(); + occurStartCommand.exec(iSearch.$editor, options); + } +}, { + name: "yankNextWord", + bindKey: "Ctrl-w", + exec: function(iSearch) { + var ed = iSearch.$editor, + range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }), + string = ed.session.getTextRange(range); + iSearch.addString(string); + } +}, { + name: "yankNextChar", + bindKey: "Ctrl-Alt-y", + exec: function(iSearch) { + var ed = iSearch.$editor, + range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }), + string = ed.session.getTextRange(range); + iSearch.addString(string); + } +}, { + name: 'recenterTopBottom', + bindKey: 'Ctrl-l', + 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; +} + +oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); + +(function() { + + this.attach = function(editor) { + var iSearch = this.$iSearch; + HashHandler.call(this, exports.iSearchCommands, editor.commands.platform); + this.$commandExecHandler = editor.commands.addEventListener('exec', function(e) { + if (!e.command.isIncrementalSearchCommand) + return iSearch.deactivate(); + e.stopPropagation(); + e.preventDefault(); + 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) { + if (((hashId === 1/*ctrl*/ || hashId === 8/*command*/) && key === 'v') + || (hashId === 1/*ctrl*/ && key === 'y')) return null; + var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode); + if (cmd.command) { return cmd; } + if (hashId == -1) { + var extendCmd = this.commands.extendSearchTerm; + if (extendCmd) { return {command: extendCmd, args: key}; } + } + return false; + }; + +}).call(IncrementalSearchKeyboardHandler.prototype); + + +exports.IncrementalSearchKeyboardHandler = IncrementalSearchKeyboardHandler; + +}); diff --git a/public/lib/ace/commands/multi_select_commands.js b/public/lib/ace/commands/multi_select_commands.js new file mode 100644 index 0000000..26adc83 --- /dev/null +++ b/public/lib/ace/commands/multi_select_commands.js @@ -0,0 +1,113 @@ +/* ***** 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) { + +// commands to enter multiselect mode +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", + exec: function(editor) { editor.multiSelect.splitIntoLines(); }, + bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"}, + readOnly: true +}, { + name: "alignCursors", + exec: function(editor) { editor.alignCursors(); }, + 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 +}]; + +// commands active only in multiselect mode +exports.multiSelectCommands = [{ + name: "singleSelection", + bindKey: "esc", + exec: function(editor) { editor.exitMultiSelectMode(); }, + scrollIntoView: "cursor", + readOnly: true, + isAvailable: function(editor) {return editor && editor.inMultiSelectMode;} +}]; + +var HashHandler = require("../keyboard/hash_handler").HashHandler; +exports.keyboardHandler = new HashHandler(exports.multiSelectCommands); + +}); diff --git a/public/lib/ace/commands/occur_commands.js b/public/lib/ace/commands/occur_commands.js new file mode 100644 index 0000000..fd65648 --- /dev/null +++ b/public/lib/ace/commands/occur_commands.js @@ -0,0 +1,110 @@ +/* ***** 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) { + +var config = require("../config"), + Occur = require("../occur").Occur; + +// These commands can be installed in a normal command handler to start occur: +var occurStartCommand = { + name: "occur", + exec: function(editor, options) { + var alreadyInOccur = !!editor.session.$occur; + var occurSessionActive = new Occur().enter(editor, options); + if (occurSessionActive && !alreadyInOccur) + OccurKeyboardHandler.installIn(editor); + }, + readOnly: true +}; + +var occurCommands = [{ + name: "occurexit", + bindKey: 'esc|Ctrl-G', + exec: function(editor) { + var occur = editor.session.$occur; + if (!occur) return; + occur.exit(editor, {}); + if (!editor.session.$occur) OccurKeyboardHandler.uninstallFrom(editor); + }, + readOnly: true +}, { + name: "occuraccept", + bindKey: 'enter', + exec: function(editor) { + var occur = editor.session.$occur; + if (!occur) return; + occur.exit(editor, {translatePosition: true}); + if (!editor.session.$occur) OccurKeyboardHandler.uninstallFrom(editor); + }, + readOnly: true +}]; + +var HashHandler = require("../keyboard/hash_handler").HashHandler; +var oop = require("../lib/oop"); + + +function OccurKeyboardHandler() {} + +oop.inherits(OccurKeyboardHandler, HashHandler); + +(function() { + + this.isOccurHandler = true; + + this.attach = function(editor) { + HashHandler.call(this, occurCommands, editor.commands.platform); + this.$editor = editor; + }; + + var handleKeyboard$super = this.handleKeyboard; + this.handleKeyboard = function(data, hashId, key, keyCode) { + var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode); + return (cmd && cmd.command) ? cmd : undefined; + }; + +}).call(OccurKeyboardHandler.prototype); + +OccurKeyboardHandler.installIn = function(editor) { + var handler = new this(); + editor.keyBinding.addKeyboardHandler(handler); + editor.commands.addCommands(occurCommands); +}; + +OccurKeyboardHandler.uninstallFrom = function(editor) { + editor.commands.removeCommands(occurCommands); + var handler = editor.getKeyboardHandler(); + if (handler.isOccurHandler) + editor.keyBinding.removeKeyboardHandler(handler); +}; + +exports.occurStartCommand = occurStartCommand; + +}); diff --git a/public/lib/ace/config.js b/public/lib/ace/config.js new file mode 100644 index 0000000..7122708 --- /dev/null +++ b/public/lib/ace/config.js @@ -0,0 +1,202 @@ +/* ***** 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) { +"no use strict"; + +var lang = require("./lib/lang"); +var oop = require("./lib/oop"); +var net = require("./lib/net"); +var AppConfig = require("./lib/app_config").AppConfig; + +module.exports = exports = new AppConfig(); + +var global = (function() { + return this || typeof window != "undefined" && window; +})(); + +var options = { + packaged: false, + workerPath: null, + modePath: null, + themePath: null, + basePath: "", + suffix: ".js", + $moduleUrls: {} +}; + +exports.get = function(key) { + if (!options.hasOwnProperty(key)) + throw new Error("Unknown config key: " + key); + + return options[key]; +}; + +exports.set = function(key, value) { + if (!options.hasOwnProperty(key)) + throw new Error("Unknown config key: " + key); + + options[key] = value; +}; + +exports.all = function() { + return lang.copyObject(options); +}; + +// module loading +exports.moduleUrl = function(name, component) { + if (options.$moduleUrls[name]) + return options.$moduleUrls[name]; + + var parts = name.split("/"); + component = component || parts[parts.length - 2] || ""; + + // todo make this configurable or get rid of '-' + var sep = component == "snippets" ? "/" : "-"; + var base = parts[parts.length - 1]; + if (component == "worker" && sep == "-") { + var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g"); + base = base.replace(re, ""); + } + + if ((!base || base == component) && parts.length > 1) + base = parts[parts.length - 2]; + var path = options[component + "Path"]; + if (path == null) { + path = options.basePath; + } else if (sep == "/") { + component = sep = ""; + } + if (path && path.slice(-1) != "/") + path += "/"; + return path + component + sep + base + this.get("suffix"); +}; + +exports.setModuleUrl = function(name, subst) { + return options.$moduleUrls[name] = subst; +}; + +exports.$loading = {}; +exports.loadModule = function(moduleName, onLoad) { + var module, moduleType; + if (Array.isArray(moduleName)) { + moduleType = moduleName[0]; + moduleName = moduleName[1]; + } + + try { + module = require(moduleName); + } catch (e) {} + // require(moduleName) can return empty object if called after require([moduleName], callback) + if (module && !exports.$loading[moduleName]) + return onLoad && onLoad(module); + + if (!exports.$loading[moduleName]) + exports.$loading[moduleName] = []; + + exports.$loading[moduleName].push(onLoad); + + if (exports.$loading[moduleName].length > 1) + return; + + var afterLoad = function() { + require([moduleName], function(module) { + exports._emit("load.module", {name: moduleName, module: module}); + var listeners = exports.$loading[moduleName]; + exports.$loading[moduleName] = null; + listeners.forEach(function(onLoad) { + onLoad && onLoad(module); + }); + }); + }; + + if (!exports.get("packaged")) + return afterLoad(); + net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad); +}; + +// initialization +function init(packaged) { + if (!global || !global.document) + return; + + options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged); + + var scriptOptions = {}; + var scriptUrl = ""; + + // 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*-{@IKxT-e*Hm6e;L;i*OLTOK@PW z(cUAx#7p88gBpFzp_4YyZns0z>9j%hPvRGY8hy-Fqg(NK{QY1sD9z{d?~BFa2ZI`Y z%%PJq;dZ;7Xs3y)6iGS_ZBOgI>5vFcGxoaJ&kHv=tJJGU51D;~#PhO{v7iEBnR;cGM+2Mn~M(dZl340MK#*uV-C zw;3|<5vv~6#It6z>0!t~6{{ZTq(0Hh%gcSbg?H%srU=ZT^LRX`)oS&y)oKaB96Biz z^?Lo#<#OTW+Z2I0boAz*hr{8cPN#D$0(0o3Ow4Ap1N=+7-F}~Hiyrhbhi)>NJob9M zzDOi;)a&(pdeFxlI@zOq^ZNSwHN9j{mL28jV-6jlQ}s=)T~3zI@E|mjl2nm2yv(p1DzpN=@EsRWm-|FS*8_+8l0fTVo_mGi$V>3 zYGth!wJ6k3hWMh@q85c3m;m`qCc~LxWvD@zf%b1g4Z;kxW}${n=rV;k)Bv+kqs1iD ph!KYx#yr$8>rk@}HUCwp`3*kwRI8RHvCaSh002ovPDHLkV1gg!UI_pI literal 0 HcmV?d00001 diff --git a/public/lib/ace/css/editor.css b/public/lib/ace/css/editor.css new file mode 100644 index 0000000..03b3af5 --- /dev/null +++ b/public/lib/ace/css/editor.css @@ -0,0 +1,463 @@ +.ace_editor { + position: relative; + overflow: hidden; + font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; + direction: ltr; + text-align: left; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} + +.ace_scroller { + position: absolute; + overflow: hidden; + top: 0; + bottom: 0; + background-color: inherit; + -ms-user-select: none; + -moz-user-select: none; + -webkit-user-select: none; + user-select: none; + cursor: text; +} + +.ace_content { + position: absolute; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + min-width: 100%; +} + +.ace_dragging .ace_scroller:before{ + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + content: ''; + background: rgba(250, 250, 250, 0.01); + z-index: 1000; +} +.ace_dragging.ace_dark .ace_scroller:before{ + background: rgba(0, 0, 0, 0.01); +} + +.ace_selecting, .ace_selecting * { + cursor: text !important; +} + +.ace_gutter { + position: absolute; + overflow : hidden; + width: auto; + top: 0; + bottom: 0; + left: 0; + cursor: default; + z-index: 4; + -ms-user-select: none; + -moz-user-select: none; + -webkit-user-select: none; + user-select: none; +} + +.ace_gutter-active-line { + position: absolute; + left: 0; + right: 0; +} + +.ace_scroller.ace_scroll-left { + box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset; +} + +.ace_gutter-cell { + padding-left: 19px; + padding-right: 6px; + background-repeat: no-repeat; +} + +.ace_gutter-cell.ace_error { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg=="); + background-repeat: no-repeat; + background-position: 2px center; +} + +.ace_gutter-cell.ace_warning { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg=="); + background-position: 2px center; +} + +.ace_gutter-cell.ace_info { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII="); + background-position: 2px center; +} +.ace_dark .ace_gutter-cell.ace_info { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC"); +} + +.ace_scrollbar { + position: absolute; + right: 0; + bottom: 0; + z-index: 6; +} + +.ace_scrollbar-inner { + position: absolute; + cursor: text; + left: 0; + top: 0; +} + +.ace_scrollbar-v{ + overflow-x: hidden; + overflow-y: scroll; + top: 0; +} + +.ace_scrollbar-h { + overflow-x: scroll; + overflow-y: hidden; + left: 0; +} + +.ace_print-margin { + position: absolute; + height: 100%; +} + +.ace_text-input { + position: absolute; + z-index: 0; + width: 0.5em; + height: 1em; + opacity: 0; + background: transparent; + -moz-appearance: none; + appearance: none; + border: none; + resize: none; + outline: none; + overflow: hidden; + font: inherit; + padding: 0 1px; + margin: 0 -1px; + text-indent: -1em; + -ms-user-select: text; + -moz-user-select: text; + -webkit-user-select: text; + user-select: text; + /*with `pre-line` chrome inserts   instead of space*/ + white-space: pre!important; +} + +.ace_text-input.ace_composition { + background: inherit; + color: inherit; + z-index: 1000; + opacity: 1; + text-indent: 0; +} + +.ace_layer { + 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%; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + /* setting pointer-events: auto; on node under the mouse, which changes + during scroll, will break mouse wheel scrolling in Safari */ + pointer-events: none; +} + +.ace_gutter-layer { + position: relative; + width: auto; + text-align: right; + pointer-events: auto; +} + +.ace_text-layer { + font: inherit !important; +} + +.ace_cjk { + display: inline-block; + text-align: center; +} + +.ace_cursor-layer { + z-index: 4; +} + +.ace_cursor { + z-index: 4; + position: absolute; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + border-left: 2px solid; + /* workaround for smooth cursor repaintng whole screen in chrome */ + transform: translatez(0); +} + +.ace_multiselect .ace_cursor { + border-left-width: 1px; +} + +.ace_slim-cursors .ace_cursor { + border-left-width: 1px; +} + +.ace_overwrite-cursors .ace_cursor { + border-left-width: 0; + border-bottom: 1px solid; +} + +.ace_hidden-cursors .ace_cursor { + opacity: 0.2; +} + +.ace_smooth-blinking .ace_cursor { + -webkit-transition: opacity 0.18s; + transition: opacity 0.18s; +} + +.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack { + position: absolute; + z-index: 3; +} + +.ace_marker-layer .ace_selection { + position: absolute; + z-index: 5; +} + +.ace_marker-layer .ace_bracket { + position: absolute; + z-index: 6; +} + +.ace_marker-layer .ace_active-line { + position: absolute; + z-index: 2; +} + +.ace_marker-layer .ace_selected-word { + position: absolute; + z-index: 4; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +.ace_line .ace_fold { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + + display: inline-block; + height: 11px; + margin-top: -2px; + vertical-align: middle; + + background-image: + url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="), + url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII="); + background-repeat: no-repeat, repeat-x; + background-position: center center, top left; + color: transparent; + + border: 1px solid black; + border-radius: 2px; + + cursor: pointer; + pointer-events: auto; +} + +.ace_dark .ace_fold { +} + +.ace_fold:hover{ + background-image: + url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="), + url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC"); +} + +.ace_tooltip { + background-color: #FFF; + background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1)); + background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1)); + border: 1px solid gray; + border-radius: 1px; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); + color: black; + max-width: 100%; + padding: 3px 4px; + position: fixed; + z-index: 999999; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + cursor: default; + white-space: pre; + word-wrap: break-word; + line-height: normal; + font-style: normal; + font-weight: normal; + letter-spacing: normal; + pointer-events: none; +} + +.ace_folding-enabled > .ace_gutter-cell { + padding-right: 13px; +} + +.ace_fold-widget { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + + margin: 0 -12px 0 1px; + display: none; + width: 11px; + vertical-align: top; + + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg=="); + background-repeat: no-repeat; + background-position: center; + + border-radius: 3px; + + border: 1px solid transparent; + cursor: pointer; +} + +.ace_folding-enabled .ace_fold-widget { + display: inline-block; +} + +.ace_fold-widget.ace_end { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg=="); +} + +.ace_fold-widget.ace_closed { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA=="); +} + +.ace_fold-widget:hover { + border: 1px solid rgba(0, 0, 0, 0.3); + background-color: rgba(255, 255, 255, 0.2); + 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); + box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8); +} +/** + * Dark version for fold widgets + */ +.ace_dark .ace_fold-widget { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC"); +} +.ace_dark .ace_fold-widget.ace_end { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg=="); +} +.ace_dark .ace_fold-widget.ace_closed { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg=="); +} +.ace_dark .ace_fold-widget:hover { + box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); + background-color: rgba(255, 255, 255, 0.1); +} +.ace_dark .ace_fold-widget:active { + box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); +} + +.ace_fold-widget.ace_invalid { + background-color: #FFB4B4; + border-color: #DE5555; +} + +.ace_fade-fold-widgets .ace_fold-widget { + -webkit-transition: opacity 0.4s ease 0.05s; + transition: opacity 0.4s ease 0.05s; + opacity: 0; +} + +.ace_fade-fold-widgets:hover .ace_fold-widget { + -webkit-transition: opacity 0.05s ease 0.05s; + transition: opacity 0.05s ease 0.05s; + opacity:1; +} + +.ace_underline { + text-decoration: underline; +} + +.ace_bold { + font-weight: bold; +} + +.ace_nobold .ace_bold { + font-weight: normal; +} + +.ace_italic { + font-style: italic; +} + + +.ace_error-marker { + background-color: rgba(255, 0, 0,0.2); + position: absolute; + z-index: 9; +} + +.ace_highlight-marker { + background-color: rgba(255, 255, 0,0.2); + 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<yUwf>u=@1 zY#$jHaV+ZCAtV^WB3Kyv<$w6rgPN^}mk4&16mz$?oHnuK^xU*br+VqTIh{}QCzbwQ z#1x(MbFxM9Gg0O2k3UQ29cYXAr*Lnob`1;br1jm literal 0 HcmV?d00001 diff --git a/public/lib/ace/document.js b/public/lib/ace/document.js new file mode 100644 index 0000000..245f66b --- /dev/null +++ b/public/lib/ace/document.js @@ -0,0 +1,692 @@ +/* ***** 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 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(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 (textOrLines.length === 0) { + this.$lines = [""]; + } else if (Array.isArray(textOrLines)) { + this.insertMergedLines({row: 0, column: 0}, textOrLines); + } else { + this.insert({row: 0, column:0}, textOrLines); + } +}; + +(function() { + + oop.implement(this, EventEmitter); + + /** + * Replaces all the lines in the current `Document` with the value of `text`. + * + * @param {String} text The text to use + **/ + this.setValue = function(text) { + var len = this.getLength() - 1; + this.remove(new Range(0, 0, len, this.getLine(len).length)); + this.insert({row: 0, column: 0}, text); + }; + + /** + * Returns all the lines in the document as a single string, joined by the new line character. + **/ + this.getValue = function() { + return this.getAllLines().join(this.getNewLineCharacter()); + }; + + /** + * Creates a new `Anchor` to define a floating point in the document. + * @param {Number} row The row number to use + * @param {Number} column The column number to use + * + **/ + this.createAnchor = function(row, column) { + return new Anchor(this, row, column); + }; + + /** + * Splits a string of text on any newline (`\n`) or carriage-return (`\r`) characters. + * + * @method $split + * @param {String} text The text to work with + * @returns {String} A String array, with each index containing a piece of the original `text` string. + * + **/ + + // check for IE split bug + if ("aaa".split(/a/).length === 0) { + this.$split = function(text) { + return text.replace(/\r\n|\r/g, "\n").split("\n"); + }; + } else { + this.$split = function(text) { + return text.split(/\r\n|\r|\n/); + }; + } + + + this.$detectNewLine = function(text) { + var match = text.match(/^.*?(\r\n|\r|\n)/m); + this.$autoNewLine = match ? match[1] : "\n"; + this._signal("changeNewLineMode"); + }; + + /** + * Returns the newline character that's being used, depending on the value of `newLineMode`. + * @returns {String} If `newLineMode == windows`, `\r\n` is returned. + * If `newLineMode == unix`, `\n` is returned. + * If `newLineMode == auto`, the value of `autoNewLine` is returned. + * + **/ + this.getNewLineCharacter = function() { + switch (this.$newLineMode) { + case "windows": + return "\r\n"; + case "unix": + return "\n"; + default: + return this.$autoNewLine || "\n"; + } + }; + + this.$autoNewLine = ""; + this.$newLineMode = "auto"; + /** + * [Sets the new line mode.]{: #Document.setNewLineMode.desc} + * @param {String} newLineMode [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param} + * + **/ + this.setNewLineMode = function(newLineMode) { + if (this.$newLineMode === newLineMode) + return; + + this.$newLineMode = newLineMode; + this._signal("changeNewLineMode"); + }; + + /** + * [Returns the type of newlines being used; either `windows`, `unix`, or `auto`]{: #Document.getNewLineMode} + * @returns {String} + **/ + this.getNewLineMode = function() { + return this.$newLineMode; + }; + + /** + * Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`). + * @param {String} text The text to check + * + **/ + this.isNewLine = function(text) { + return (text == "\r\n" || text == "\r" || text == "\n"); + }; + + /** + * Returns a verbatim copy of the given line as it is in the document + * @param {Number} row The row index to retrieve + * + **/ + this.getLine = function(row) { + return this.$lines[row] || ""; + }; + + /** + * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`. + * @param {Number} firstRow The first row index to retrieve + * @param {Number} lastRow The final row index to retrieve + * + **/ + this.getLines = function(firstRow, lastRow) { + return this.$lines.slice(firstRow, lastRow + 1); + }; + + /** + * Returns all lines in the document as string array. + **/ + this.getAllLines = function() { + return this.getLines(0, this.getLength()); + }; + + /** + * Returns the number of rows in the document. + **/ + this.getLength = function() { + return this.$lines.length; + }; + + /** + * Returns all the text within `range` as a single string. + * @param {Range} range The range to work with. + * + * @returns {String} + **/ + this.getTextRange = function(range) { + 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); + } + return lines; + }; + + // 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, ["", ""]); + }; + + /** + * Inserts a block of `text` at the indicated `position`. + * @param {Object} position The position to start inserting at; it's an object that looks like `{ row: row, column: column}` + * @param {String} text A chunk of text to insert + * @returns {Object} The position ({row, column}) of the last line of `text`. If the length of `text` is 0, this function simply returns `position`. + * + **/ + this.insert = function(position, text) { + // Only detect new lines if the document has no line break yet. + if (this.getLength() <= 1) + this.$detectNewLine(text); + + 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: + * + * * `"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 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: + * ``` + * {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.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); + }; + + /** + * 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 + }); + + return this.clonePos(end); + }; + + /** + * Removes the `range` from the document. + * @param {Range} range A specified Range to remove + * @returns {Object} Returns the new `start` property of the range, which contains `startRow` and `startColumn`. If `range` is empty, this function returns the unmodified value of `range.start`. + * + **/ + this.remove = function(range) { + 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 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.
If `startColumn` is equal to `endColumn`, this function returns nothing. + * + **/ + this.removeInLine = function(row, startColumn, endColumn) { + 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. + * @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.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. + * @param {Number} row The row to check + * + **/ + this.removeNewLine = function(row) { + 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: ["", ""] + }); + } + }; + + /** + * Replaces a range in the document with the new `text`. + * @param {Range} range A specified Range to replace + * @param {String} text The new text to use as a replacement + * @returns {Object} Returns an object containing the final row and column, like this: + * {row: endRow, column: 0} + * If the text and range are empty, this function returns an object containing the current `range.start` value. + * If the text is the exact same as what currently exists, this function returns an object containing the current `range.end` value. + * + **/ + this.replace = function(range, text) { + if (!(range instanceof Range)) + range = Range.fromPoints(range.start, range.end); + if (text.length === 0 && range.isEmpty()) + return range.start; + + // Shortcut: If the text we want to insert is the same as it is already + // in the document, we don't have to replace anything. + if (text == this.getTextRange(range)) + return range.end; + + this.remove(range); + var end; + if (text) { + end = this.insert(range.start, text); + } + else { + end = range.start; + } + + return end; + }; + + /** + * 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=0; i--) { + 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. + * + * Index refers to the "absolute position" of a character in the document. For example: + * + * ```javascript + * var x = 0; // 10 characters, plus one for newline + * var y = -1; + * ``` + * + * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second. + * + * @param {Number} index An index to convert + * @param {Number} startRow=0 The row from which to start the conversion + * @returns {Object} A `{row, column}` object of the `index` position + */ + this.indexToPosition = function(index, startRow) { + var lines = this.$lines || this.getAllLines(); + var newlineLength = this.getNewLineCharacter().length; + for (var i = startRow || 0, l = lines.length; i < l; i++) { + index -= lines[i].length + newlineLength; + if (index < 0) + return {row: i, column: index + lines[i].length + newlineLength}; + } + return {row: l-1, column: lines[l-1].length}; + }; + + /** + * Converts the `{row, column}` position in a document to the character's index. + * + * Index refers to the "absolute position" of a character in the document. For example: + * + * ```javascript + * var x = 0; // 10 characters, plus one for newline + * var y = -1; + * ``` + * + * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second. + * + * @param {Object} pos The `{row, column}` to convert + * @param {Number} startRow=0 The row from which to start the conversion + * @returns {Number} The index position in the document + */ + this.positionToIndex = function(pos, startRow) { + var lines = this.$lines || this.getAllLines(); + var newlineLength = this.getNewLineCharacter().length; + var index = 0; + var row = Math.min(pos.row, lines.length); + for (var i = startRow || 0; i < row; ++i) + index += lines[i].length + newlineLength; + + return index + pos.column; + }; + +}).call(Document.prototype); + +exports.Document = Document; +}); diff --git a/public/lib/ace/document_test.js b/public/lib/ace/document_test.js new file mode 100644 index 0000000..3004847 --- /dev/null +++ b/public/lib/ace/document_test.js @@ -0,0 +1,335 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("./test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +var Document = require("./document").Document; +var Range = require("./range").Range; +var assert = require("./test/assertions"); + +module.exports = { + + "test: insert text in line" : function() { + var doc = new Document(["12", "34"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.insert({row: 0, column: 1}, "juhu"); + assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n")); + }, + + "test: insert new line" : function() { + var doc = new Document(["12", "34"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.insertMergedLines({row: 0, column: 1}, ['', '']); + assert.equal(doc.getValue(), ["1", "2", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["1", "2", "34"].join("\n")); + }, + + "test: insert lines at the beginning" : function() { + var doc = new Document(["12", "34"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.insertFullLines(0, ["aa", "bb"]); + assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n")); + }, + + "test: insert lines at the end" : function() { + var doc = new Document(["12", "34"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.insertFullLines(2, ["aa", "bb"]); + assert.equal(doc.getValue(), ["12", "34", "aa", "bb"].join("\n")); + }, + + "test: insert lines in the middle" : function() { + var doc = new Document(["12", "34"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.insertFullLines(1, ["aa", "bb"]); + assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n")); + }, + + "test: insert multi line string at the start" : function() { + var doc = new Document(["12", "34"]); + + var deltas = []; + 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")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n")); + }, + + "test: insert multi line string at the end" : function() { + var doc = new Document(["12", "34"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.insert({row: 1, column: 2}, "aa\nbb\ncc"); + assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n")); + }, + + "test: insert multi line string in the middle" : function() { + var doc = new Document(["12", "34"]); + + var deltas = []; + 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")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n")); + }, + + "test: delete in line" : function() { + var doc = new Document(["1234", "5678"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.remove(new Range(0, 1, 0, 3)); + assert.equal(doc.getValue(), ["14", "5678"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["1234", "5678"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["14", "5678"].join("\n")); + }, + + "test: delete new line" : function() { + var doc = new Document(["1234", "5678"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.remove(new Range(0, 4, 1, 0)); + assert.equal(doc.getValue(), ["12345678"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["1234", "5678"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["12345678"].join("\n")); + }, + + "test: delete multi line range line" : function() { + var doc = new Document(["1234", "5678", "abcd"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.remove(new Range(0, 2, 2, 2)); + assert.equal(doc.getValue(), ["12cd"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["1234", "5678", "abcd"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["12cd"].join("\n")); + }, + + "test: delete full lines" : function() { + var doc = new Document(["1234", "5678", "abcd"]); + + var deltas = []; + doc.on("change", function(e) { deltas.push(e); }); + + doc.remove(new Range(1, 0, 3, 0)); + assert.equal(doc.getValue(), ["1234", ""].join("\n")); + }, + + "test: remove lines should return the removed lines" : function() { + var doc = new Document(["1234", "5678", "abcd"]); + + var removed = doc.removeFullLines(1, 2); + assert.equal(removed.join("\n"), ["5678", "abcd"].join("\n")); + }, + + "test: should handle unix style new lines" : function() { + var doc = new Document(["1", "2", "3"]); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\n")); + }, + + "test: should handle windows style new lines" : function() { + var doc = new Document(["1", "2", "3"].join("\r\n")); + + doc.setNewLineMode("unix"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\n")); + }, + + "test: set new line mode to 'windows' should use '\\r\\n' as new lines": function() { + var doc = new Document(["1", "2", "3"].join("\n")); + doc.setNewLineMode("windows"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n")); + }, + + "test: set new line mode to 'unix' should use '\\n' as new lines": function() { + var doc = new Document(["1", "2", "3"].join("\r\n")); + + doc.setNewLineMode("unix"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\n")); + }, + + "test: set new line mode to 'auto' should detect the incoming nl type": function() { + var doc = new Document(["1", "2", "3"].join("\n")); + + doc.setNewLineMode("auto"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\n")); + + var doc = new Document(["1", "2", "3"].join("\r\n")); + + doc.setNewLineMode("auto"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n")); + + doc.replace(new Range(0, 0, 2, 1), ["4", "5", "6"].join("\n")); + assert.equal(["4", "5", "6"].join("\n"), doc.getValue()); + }, + + "test: set value": function() { + var doc = new Document("1"); + assert.equal("1", doc.getValue()); + + doc.setValue(doc.getValue()); + assert.equal("1", doc.getValue()); + + var doc = new Document("1\n2"); + assert.equal("1\n2", doc.getValue()); + + doc.setValue(doc.getValue()); + assert.equal("1\n2", doc.getValue()); + }, + + "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"); + } + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/edit_session.js b/public/lib/ace/edit_session.js new file mode 100644 index 0000000..2d8593a --- /dev/null +++ b/public/lib/ace/edit_session.js @@ -0,0 +1,2600 @@ +/* ***** 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 oop = require("./lib/oop"); +var lang = require("./lib/lang"); +var BidiHandler = require("./bidihandler").BidiHandler; +var config = require("./config"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var Selection = require("./selection").Selection; +var TextMode = require("./mode/text").Mode; +var Range = require("./range").Range; +var Document = require("./document").Document; +var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer; +var SearchHighlight = require("./search_highlight").SearchHighlight; + +/** + * Stores all the data about [[Editor `Editor`]] state providing easy way to change editors state. + * + * `EditSession` can be attached to only one [[Document `Document`]]. Same `Document` can be attached to several `EditSession`s. + * @class EditSession + **/ + +//{ events +/** + * + * Emitted when the document changes. + * @event change + * @param {Object} e An object containing a `delta` of information about the change. + **/ +/** + * Emitted when the tab size changes, via [[EditSession.setTabSize]]. + * + * @event changeTabSize + **/ +/** + * Emitted when the ability to overwrite text changes, via [[EditSession.setOverwrite]]. + * + * @event changeOverwrite + **/ +/** + * Emitted when the gutter changes, either by setting or removing breakpoints, or when the gutter decorations change. + * + * @event changeBreakpoint + **/ +/** + * Emitted when a front marker changes. + * + * @event changeFrontMarker + **/ +/** + * Emitted when a back marker changes. + * + * @event changeBackMarker + **/ +/** + * Emitted when an annotation changes, like through [[EditSession.setAnnotations]]. + * + * @event changeAnnotation + **/ +/** + * Emitted when a background tokenizer asynchronously processes new rows. + * @event tokenizerUpdate + * + * @param {Object} e An object containing one property, `"data"`, that contains information about the changing rows + * + **/ +/** + * Emitted when the current mode changes. + * + * @event changeMode + * + **/ +/** + * Emitted when the wrap mode changes. + * + * @event changeWrapMode + * + **/ +/** + * Emitted when the wrapping limit changes. + * + * @event changeWrapLimit + * + **/ +/** + * Emitted when a code fold is added or removed. + * + * @event changeFold + * + **/ + /** + * Emitted when the scroll top changes. + * @event changeScrollTop + * + * @param {Number} scrollTop The new scroll top value + **/ +/** + * Emitted when the scroll left changes. + * @event changeScrollLeft + * + * @param {Number} scrollLeft The new scroll left value + **/ +//} + +/** + * Sets up a new `EditSession` and associates it with the given `Document` and `TextMode`. + * @param {Document | String} text [If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text]{: #textParam} + * @param {TextMode} mode [The initial language mode to use for the document]{: #modeParam} + * + * @constructor + **/ + +var EditSession = function(text, mode) { + this.$breakpoints = []; + this.$decorations = []; + this.$frontMarkers = {}; + this.$backMarkers = {}; + this.$markerId = 1; + this.$undoSelect = true; + + this.$foldData = []; + this.id = "session" + (++EditSession.$uid); + this.$foldData.toString = function() { + return this.join("\n"); + }; + this.on("changeFold", this.onChangeFold.bind(this)); + this.$onChange = this.onChange.bind(this); + + if (typeof text != "object" || !text.getLine) + text = new Document(text); + + this.$bidiHandler = new BidiHandler(this); + this.setDocument(text); + this.selection = new Selection(this); + + config.resetOptions(this); + this.setMode(mode); + config._signal("session", this); +}; + + +EditSession.$uid = 0; + +(function() { + + oop.implement(this, EventEmitter); + + /** + * Sets the `EditSession` to point to a new `Document`. If a `BackgroundTokenizer` exists, it also points to `doc`. + * + * @param {Document} doc The new `Document` to use + * + **/ + this.setDocument = function(doc) { + if (this.doc) + this.doc.removeListener("change", this.$onChange); + + this.doc = doc; + doc.on("change", this.$onChange); + + if (this.bgTokenizer) + this.bgTokenizer.setDocument(this.getDocument()); + + this.resetCaches(); + }; + + /** + * Returns the `Document` associated with this session. + * @return {Document} + **/ + this.getDocument = function() { + return this.doc; + }; + + /** + * @param {Number} row The row to work with + * + **/ + this.$resetRowCache = function(docRow) { + if (!docRow) { + this.$docRowCache = []; + this.$screenRowCache = []; + return; + } + var l = this.$docRowCache.length; + var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1; + if (l > i) { + this.$docRowCache.splice(i, l); + this.$screenRowCache.splice(i, l); + } + }; + + this.$getRowCacheIndex = function(cacheArray, val) { + var low = 0; + var hi = cacheArray.length - 1; + + while (low <= hi) { + var mid = (low + hi) >> 1; + var c = cacheArray[mid]; + + if (val > c) + low = mid + 1; + else if (val < c) + hi = mid - 1; + else + return mid; + } + + return low -1; + }; + + this.resetCaches = function() { + this.$modified = true; + this.$wrapData = []; + this.$rowLengthCache = []; + this.$resetRowCache(0); + if (this.bgTokenizer) + this.bgTokenizer.start(0); + }; + + this.onChangeFold = function(e) { + var fold = e.data; + this.$resetRowCache(fold.start.row); + }; + + this.onChange = function(delta) { + this.$modified = true; + this.$bidiHandler.onChange(delta); + this.$resetRowCache(delta.start.row); + + var removedFolds = this.$updateInternalDataOnChange(delta); + if (!this.$fromUndo && this.$undoManager && !delta.ignore) { + this.$deltasDoc.push(delta); + if (removedFolds && removedFolds.length != 0) { + this.$deltasFold.push({ + action: "removeFolds", + folds: removedFolds + }); + } + + this.$informUndoManager.schedule(); + } + + 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); + this.selection.moveTo(0, 0); + + this.$resetRowCache(0); + this.$deltas = []; + this.$deltasDoc = []; + this.$deltasFold = []; + this.setUndoManager(this.$undoManager); + this.getUndoManager().reset(); + }; + + /** + * Returns the current [[Document `Document`]] as a string. + * @method toString + * @returns {String} + * @alias EditSession.getValue + * + **/ + + /** + * Returns the current [[Document `Document`]] as a string. + * @method getValue + * @returns {String} + * @alias EditSession.toString + **/ + this.getValue = + this.toString = function() { + return this.doc.getValue(); + }; + + /** + * Returns selection object. + **/ + this.getSelection = function() { + return this.selection; + }; + + /** + * {:BackgroundTokenizer.getState} + * @param {Number} row The row to start at + * + * @related BackgroundTokenizer.getState + **/ + this.getState = function(row) { + return this.bgTokenizer.getState(row); + }; + + /** + * Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows. + * @param {Number} row The row to start at + * + * + * + **/ + this.getTokens = function(row) { + return this.bgTokenizer.getTokens(row); + }; + + /** + * Returns an object indicating the token at the current row. The object has two properties: `index` and `start`. + * @param {Number} row The row number to retrieve from + * @param {Number} column The column number to retrieve from + * + * + **/ + this.getTokenAt = function(row, column) { + var tokens = this.bgTokenizer.getTokens(row); + var token, c = 0; + if (column == null) { + var i = tokens.length - 1; + c = this.getLine(row).length; + } else { + for (var i = 0; i < tokens.length; i++) { + c += tokens[i].value.length; + if (c >= column) + break; + } + } + token = tokens[i]; + if (!token) + return null; + token.index = i; + token.start = c - token.value.length; + return token; + }; + + /** + * Sets the undo manager. + * @param {UndoManager} undoManager The new undo manager + * + * + **/ + this.setUndoManager = function(undoManager) { + this.$undoManager = undoManager; + this.$deltas = []; + this.$deltasDoc = []; + this.$deltasFold = []; + + if (this.$informUndoManager) + this.$informUndoManager.cancel(); + + if (undoManager) { + var self = this; + + this.$syncInformUndoManager = function() { + self.$informUndoManager.cancel(); + + if (self.$deltasFold.length) { + self.$deltas.push({ + group: "fold", + deltas: self.$deltasFold + }); + self.$deltasFold = []; + } + + if (self.$deltasDoc.length) { + self.$deltas.push({ + group: "doc", + deltas: self.$deltasDoc + }); + self.$deltasDoc = []; + } + + if (self.$deltas.length > 0) { + undoManager.execute({ + action: "aceupdate", + args: [self.$deltas, self], + merge: self.mergeUndoDeltas + }); + } + self.mergeUndoDeltas = false; + self.$deltas = []; + }; + this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager); + } + }; + + /** + * starts a new group in undo history + **/ + this.markUndoGroup = function() { + if (this.$syncInformUndoManager) + this.$syncInformUndoManager(); + }; + + this.$defaultUndoManager = { + undo: function() {}, + redo: function() {}, + reset: function() {} + }; + + /** + * Returns the current undo manager. + **/ + this.getUndoManager = function() { + return this.$undoManager || this.$defaultUndoManager; + }; + + /** + * Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize `getTabSize()`]]); otherwise it's simply `'\t'`. + **/ + this.getTabString = function() { + if (this.getUseSoftTabs()) { + return lang.stringRepeat(" ", this.getTabSize()); + } else { + return "\t"; + } + }; + + /** + * Pass `true` to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character (`'\t'`). + * @param {Boolean} useSoftTabs Value indicating whether or not to use soft tabs + **/ + this.setUseSoftTabs = function(val) { + this.setOption("useSoftTabs", val); + }; + /** + * Returns `true` if soft tabs are being used, `false` otherwise. + * @returns {Boolean} + **/ + this.getUseSoftTabs = function() { + // todo might need more general way for changing settings from mode, but this is ok for now + return this.$useSoftTabs && !this.$mode.$indentWithTabs; + }; + /** + * Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event. + * @param {Number} tabSize The new tab size + **/ + this.setTabSize = function(tabSize) { + this.setOption("tabSize", tabSize); + }; + /** + * Returns the current tab size. + **/ + this.getTabSize = function() { + return this.$tabSize; + }; + + /** + * Returns `true` if the character at the position is a soft tab. + * @param {Object} position The position to check + * + **/ + this.isTabStop = function(position) { + return this.$useSoftTabs && (position.column % this.$tabSize === 0); + }; + + /** + * Set whether keyboard navigation of soft tabs moves the cursor within the soft tab, rather than over + * @param {Boolean} navigateWithinSoftTabs Value indicating whether or not to navigate within soft tabs + **/ + this.setNavigateWithinSoftTabs = function (navigateWithinSoftTabs) { + this.setOption("navigateWithinSoftTabs", navigateWithinSoftTabs); + }; + /** + * Returns `true` if keyboard navigation moves the cursor within soft tabs, `false` if it moves the cursor over soft tabs. + * @returns {Boolean} + **/ + this.getNavigateWithinSoftTabs = function() { + return this.$navigateWithinSoftTabs; + }; + + this.$overwrite = false; + /** + * Pass in `true` to enable overwrites in your session, or `false` to disable. + * + * If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emits the `changeOverwrite` event. + * + * @param {Boolean} overwrite Defines whether or not to set overwrites + * + * + **/ + this.setOverwrite = function(overwrite) { + this.setOption("overwrite", overwrite); + }; + + /** + * Returns `true` if overwrites are enabled; `false` otherwise. + **/ + this.getOverwrite = function() { + return this.$overwrite; + }; + + /** + * Sets the value of overwrite to the opposite of whatever it currently is. + **/ + this.toggleOverwrite = function() { + this.setOverwrite(!this.$overwrite); + }; + + /** + * Adds `className` to the `row`, to be used for CSS stylings and whatnot. + * @param {Number} row The row number + * @param {String} className The class to add + * + **/ + this.addGutterDecoration = function(row, className) { + if (!this.$decorations[row]) + this.$decorations[row] = ""; + this.$decorations[row] += " " + className; + this._signal("changeBreakpoint", {}); + }; + + /** + * Removes `className` from the `row`. + * @param {Number} row The row number + * @param {String} className The class to add + * + **/ + this.removeGutterDecoration = function(row, className) { + this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, ""); + this._signal("changeBreakpoint", {}); + }; + + /** + * Returns an array of strings, indicating the breakpoint class (if any) applied to each row. + * @returns {[String]} + **/ + this.getBreakpoints = function() { + return this.$breakpoints; + }; + + /** + * Sets a breakpoint on every row number given by `rows`. This function also emites the `'changeBreakpoint'` event. + * @param {Array} rows An array of row indices + * + **/ + this.setBreakpoints = function(rows) { + this.$breakpoints = []; + for (var i=0; i 0) + inToken = !!line.charAt(column - 1).match(this.tokenRe); + + if (!inToken) + inToken = !!line.charAt(column).match(this.tokenRe); + + if (inToken) + var re = this.tokenRe; + else if (/^\s+$/.test(line.slice(column-1, column+1))) + var re = /\s/; + else + var re = this.nonTokenRe; + + var start = column; + if (start > 0) { + do { + start--; + } + while (start >= 0 && line.charAt(start).match(re)); + start++; + } + + var end = column; + while (end < line.length && line.charAt(end).match(re)) { + end++; + } + + return new Range(row, start, row, end); + }; + + /** + * Gets the range of a word, including its right whitespace. + * @param {Number} row The row number to start from + * @param {Number} column The column number to start from + * + * @return {Range} + **/ + this.getAWordRange = function(row, column) { + var wordRange = this.getWordRange(row, column); + var line = this.getLine(wordRange.end.row); + + while (line.charAt(wordRange.end.column).match(/[ \t]/)) { + wordRange.end.column += 1; + } + return wordRange; + }; + + /** + * {:Document.setNewLineMode.desc} + * @param {String} newLineMode {:Document.setNewLineMode.param} + * + * + * @related Document.setNewLineMode + **/ + this.setNewLineMode = function(newLineMode) { + this.doc.setNewLineMode(newLineMode); + }; + + /** + * + * Returns the current new line mode. + * @returns {String} + * @related Document.getNewLineMode + **/ + this.getNewLineMode = function() { + return this.doc.getNewLineMode(); + }; + + /** + * Identifies if you want to use a worker for the `EditSession`. + * @param {Boolean} useWorker Set to `true` to use a worker + * + **/ + this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); }; + + /** + * Returns `true` if workers are being used. + **/ + this.getUseWorker = function() { return this.$useWorker; }; + + /** + * Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start `BackgroundTokenizer.start ()`]] to all the rows; it also emits the `'tokenizerUpdate'` event. + **/ + this.onReloadTokenizer = function(e) { + var rows = e.data; + this.bgTokenizer.start(rows.first); + this._signal("tokenizerUpdate", e); + }; + + this.$modes = {}; + + /** + * Sets a new text mode for the `EditSession`. This method also emits the `'changeMode'` event. If a [[BackgroundTokenizer `BackgroundTokenizer`]] is set, the `'tokenizerUpdate'` event is also emitted. + * @param {TextMode} mode Set a new text mode + * @param {cb} optional callback + * + **/ + this.$mode = null; + this.$modeId = null; + this.setMode = function(mode, cb) { + if (mode && typeof mode === "object") { + if (mode.getTokenizer) + return this.$onChangeMode(mode); + var options = mode; + var path = options.path; + } else { + path = mode || "ace/mode/text"; + } + + // this is needed if ace isn't on require path (e.g tests in node) + if (!this.$modes["ace/mode/text"]) + this.$modes["ace/mode/text"] = new TextMode(); + + if (this.$modes[path] && !options) { + this.$onChangeMode(this.$modes[path]); + cb && cb(); + return; + } + // load on demand + this.$modeId = path; + config.loadModule(["mode", path], function(m) { + if (this.$modeId !== path) + return cb && cb(); + 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(); + }.bind(this)); + + // set mode to text until loading is finished + if (!this.$mode) + this.$onChangeMode(this.$modes["ace/mode/text"], true); + }; + + this.$onChangeMode = function(mode, $isPlaceholder) { + if (!$isPlaceholder) + this.$modeId = mode.$id; + if (this.$mode === mode) + return; + + this.$mode = mode; + + this.$stopWorker(); + + if (this.$useWorker) + this.$startWorker(); + + var tokenizer = mode.getTokenizer(); + + if(tokenizer.addEventListener !== undefined) { + var onReloadTokenizer = this.onReloadTokenizer.bind(this); + tokenizer.addEventListener("update", onReloadTokenizer); + } + + if (!this.bgTokenizer) { + this.bgTokenizer = new BackgroundTokenizer(tokenizer); + var _self = this; + this.bgTokenizer.addEventListener("update", function(e) { + _self._signal("tokenizerUpdate", e); + }); + } else { + this.bgTokenizer.setTokenizer(tokenizer); + } + + this.bgTokenizer.setDocument(this.getDocument()); + + this.tokenRe = mode.tokenRe; + this.nonTokenRe = mode.nonTokenRe; + + + 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); + this._emit("changeMode"); + } + }; + + this.$stopWorker = function() { + if (this.$worker) { + this.$worker.terminate(); + this.$worker = null; + } + }; + + this.$startWorker = function() { + try { + this.$worker = this.$mode.createWorker(this); + } catch (e) { + config.warn("Could not load worker", e); + this.$worker = null; + } + }; + + /** + * Returns the current text mode. + * @returns {TextMode} The current text mode + **/ + this.getMode = function() { + return this.$mode; + }; + + this.$scrollTop = 0; + /** + * This function sets the scroll top value. It also emits the `'changeScrollTop'` event. + * @param {Number} scrollTop The new scroll top value + * + **/ + this.setScrollTop = function(scrollTop) { + // TODO: should we force integer lineheight instead? scrollTop = Math.round(scrollTop); + if (this.$scrollTop === scrollTop || isNaN(scrollTop)) + return; + + this.$scrollTop = scrollTop; + this._signal("changeScrollTop", scrollTop); + }; + + /** + * [Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop} + * @returns {Number} + **/ + this.getScrollTop = function() { + return this.$scrollTop; + }; + + this.$scrollLeft = 0; + /** + * [Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft} + **/ + this.setScrollLeft = function(scrollLeft) { + // scrollLeft = Math.round(scrollLeft); + if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft)) + return; + + this.$scrollLeft = scrollLeft; + this._signal("changeScrollLeft", scrollLeft); + }; + + /** + * [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft} + * @returns {Number} + **/ + this.getScrollLeft = function() { + return this.$scrollLeft; + }; + + /** + * Returns the width of the screen. + * @returns {Number} + **/ + this.getScreenWidth = function() { + this.$computeWidth(); + if (this.lineWidgets) + return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth); + return this.screenWidth; + }; + + this.getLineWidgetMaxWidth = function() { + if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth; + var width = 0; + this.lineWidgets.forEach(function(w) { + if (w && w.screenWidth > width) + width = w.screenWidth; + }); + return this.lineWidgetWidth = width; + }; + + this.$computeWidth = function(force) { + if (this.$modified || force) { + this.$modified = false; + + if (this.$useWrapMode) + return this.screenWidth = this.$wrapLimit; + + var lines = this.doc.getAllLines(); + var cache = this.$rowLengthCache; + var longestScreenLine = 0; + var foldIndex = 0; + var foldLine = this.$foldData[foldIndex]; + var foldStart = foldLine ? foldLine.start.row : Infinity; + var len = lines.length; + + for (var i = 0; i < len; i++) { + if (i > foldStart) { + i = foldLine.end.row + 1; + if (i >= len) + break; + foldLine = this.$foldData[foldIndex++]; + foldStart = foldLine ? foldLine.start.row : Infinity; + } + + if (cache[i] == null) + cache[i] = this.$getStringScreenWidth(lines[i])[0]; + + if (cache[i] > longestScreenLine) + longestScreenLine = cache[i]; + } + this.screenWidth = longestScreenLine; + } + }; + + /** + * Returns a verbatim copy of the given line as it is in the document + * @param {Number} row The row to retrieve from + * + * @returns {String} + **/ + this.getLine = function(row) { + return this.doc.getLine(row); + }; + + /** + * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`. + * @param {Number} firstRow The first row index to retrieve + * @param {Number} lastRow The final row index to retrieve + * + * @returns {[String]} + * + **/ + this.getLines = function(firstRow, lastRow) { + return this.doc.getLines(firstRow, lastRow); + }; + + /** + * Returns the number of rows in the document. + * @returns {Number} + **/ + this.getLength = function() { + return this.doc.getLength(); + }; + + /** + * {:Document.getTextRange.desc} + * @param {Range} range The range to work with + * + * @returns {String} + **/ + this.getTextRange = function(range) { + return this.doc.getTextRange(range || this.selection.getRange()); + }; + + /** + * Inserts a block of `text` and the indicated `position`. + * @param {Object} position The position {row, column} to start inserting at + * @param {String} text A chunk of text to insert + * @returns {Object} The position of the last line of `text`. If the length of `text` is 0, this function simply returns `position`. + * + * + **/ + this.insert = function(position, text) { + return this.doc.insert(position, text); + }; + + /** + * Removes the `range` from the document. + * @param {Range} range A specified Range to remove + * @returns {Object} The new `start` property of the range, which contains `startRow` and `startColumn`. If `range` is empty, this function returns the unmodified value of `range.start`. + * + * @related Document.remove + * + **/ + 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. + * @param {Array} deltas An array of previous changes + * @param {Boolean} dontSelect [If `true`, doesn't select the range of where the change occured]{: #dontSelect} + * + * @returns {Range} + **/ + this.undoChanges = function(deltas, dontSelect) { + if (!deltas.length) + return; + + this.$fromUndo = true; + var lastUndoRange = null; + for (var i = deltas.length - 1; i != -1; i--) { + var delta = deltas[i]; + if (delta.group == "doc") { + this.doc.revertDeltas(delta.deltas); + lastUndoRange = + this.$getUndoSelection(delta.deltas, true, lastUndoRange); + } else { + delta.deltas.forEach(function(foldDelta) { + this.addFolds(foldDelta.folds); + }, this); + } + } + this.$fromUndo = false; + lastUndoRange && + this.$undoSelect && + !dontSelect && + this.selection.setSelectionRange(lastUndoRange); + return lastUndoRange; + }; + + /** + * Re-implements a previously undone change to your document. + * @param {Array} deltas An array of previous changes + * @param {Boolean} dontSelect {:dontSelect} + * + * @returns {Range} + **/ + this.redoChanges = function(deltas, dontSelect) { + if (!deltas.length) + return; + + this.$fromUndo = true; + var lastUndoRange = null; + for (var i = 0; i < deltas.length; i++) { + var delta = deltas[i]; + if (delta.group == "doc") { + this.doc.applyDeltas(delta.deltas); + lastUndoRange = + this.$getUndoSelection(delta.deltas, false, lastUndoRange); + } + } + this.$fromUndo = false; + lastUndoRange && + this.$undoSelect && + !dontSelect && + this.selection.setSelectionRange(lastUndoRange); + return lastUndoRange; + }; + + /** + * Enables or disables highlighting of the range where an undo occurred. + * @param {Boolean} enable If `true`, selects the range of the reinserted change + * + **/ + this.setUndoSelect = function(enable) { + this.$undoSelect = enable; + }; + + this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) { + function isInsert(delta) { + 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.start, delta.end); + lastDeltaIsInsert = true; + } else { + 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.start; + if (range.compare(point.row, point.column) == -1) { + range.setStart(point); + } + point = delta.end; + if (range.compare(point.row, point.column) == 1) { + range.setEnd(point); + } + lastDeltaIsInsert = true; + } else { + point = delta.start; + if (range.compare(point.row, point.column) == -1) { + range = Range.fromPoints(delta.start, delta.start); + } + lastDeltaIsInsert = false; + } + } + + // Check if this range and the last undo range has something in common. + // If true, merge the ranges. + if (lastUndoRange != null) { + if (Range.comparePoints(lastUndoRange.start, range.start) === 0) { + lastUndoRange.start.column += range.end.column - range.start.column; + lastUndoRange.end.column += range.end.column - range.start.column; + } + + var cmp = lastUndoRange.compareRange(range); + if (cmp == 1) { + range.setStart(lastUndoRange.start); + } else if (cmp == -1) { + range.setEnd(lastUndoRange.end); + } + } + + return range; + }; + + /** + * Replaces a range in the document with the new `text`. + * + * @param {Range} range A specified Range to replace + * @param {String} text The new text to use as a replacement + * @returns {Object} An object containing the final row and column, like this: + * ``` + * {row: endRow, column: 0} + * ``` + * If the text and range are empty, this function returns an object containing the current `range.start` value. + * If the text is the exact same as what currently exists, this function returns an object containing the current `range.end` value. + * + * @related Document.replace + **/ + this.replace = function(range, text) { + return this.doc.replace(range, text); + }; + + /** + * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this: + * ```json + * { row: newRowLocation, column: newColumnLocation } + * ``` + * @param {Range} fromRange The range of text you want moved within the document + * @param {Object} toPosition The location (row and column) where you want to move the text to + * @returns {Range} The new range where the text was moved to. + **/ + this.moveText = function(fromRange, toPosition, copy) { + var text = this.getTextRange(fromRange); + var folds = this.getFoldsInRange(fromRange); + + var toRange = Range.fromPoints(toPosition, toPosition); + if (!copy) { + this.remove(fromRange); + var rowDiff = fromRange.start.row - fromRange.end.row; + var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column; + if (collDiff) { + if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column) + toRange.start.column += collDiff; + if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column) + toRange.end.column += collDiff; + } + if (rowDiff && toRange.start.row >= fromRange.end.row) { + toRange.start.row += rowDiff; + toRange.end.row += rowDiff; + } + } + + toRange.end = this.insert(toRange.start, text); + if (folds.length) { + var oldStart = fromRange.start; + var newStart = toRange.start; + var rowDiff = newStart.row - oldStart.row; + var collDiff = newStart.column - oldStart.column; + this.addFolds(folds.map(function(x) { + x = x.clone(); + if (x.start.row == oldStart.row) + x.start.column += collDiff; + if (x.end.row == oldStart.row) + x.end.column += collDiff; + x.start.row += rowDiff; + x.end.row += rowDiff; + return x; + })); + } + + return toRange; + }; + + /** + * Indents all the rows, from `startRow` to `endRow` (inclusive), by prefixing each row with the token in `indentString`. + * + * If `indentString` contains the `'\t'` character, it's replaced by whatever is defined by [[EditSession.getTabString `getTabString()`]]. + * @param {Number} startRow Starting row + * @param {Number} endRow Ending row + * @param {String} indentString The indent token + * + * + **/ + this.indentRows = function(startRow, endRow, indentString) { + indentString = indentString.replace(/\t/g, this.getTabString()); + for (var row=startRow; row<=endRow; row++) + this.doc.insertInLine({row: row, column: 0}, indentString); + }; + + /** + * Outdents all the rows defined by the `start` and `end` properties of `range`. + * @param {Range} range A range of rows + * + **/ + this.outdentRows = function (range) { + var rowRange = range.collapseRows(); + var deleteRange = new Range(0, 0, 0, 0); + var size = this.getTabSize(); + + for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) { + var line = this.getLine(i); + + deleteRange.start.row = i; + deleteRange.end.row = i; + for (var j = 0; j < size; ++j) + if (line.charAt(j) != ' ') + break; + if (j < size && line.charAt(j) == '\t') { + deleteRange.start.column = j; + deleteRange.end.column = j + 1; + } else { + deleteRange.start.column = 0; + deleteRange.end.column = j; + } + this.remove(deleteRange); + } + }; + + this.$moveLines = function(firstRow, lastRow, dir) { + firstRow = this.getRowFoldStart(firstRow); + lastRow = this.getRowFoldEnd(lastRow); + if (dir < 0) { + var row = this.getRowFoldStart(firstRow + dir); + if (row < 0) return 0; + var diff = row-firstRow; + } else if (dir > 0) { + var row = this.getRowFoldEnd(lastRow + dir); + if (row > this.doc.getLength()-1) return 0; + var diff = row-lastRow; + } else { + firstRow = this.$clipRowToDocument(firstRow); + lastRow = this.$clipRowToDocument(lastRow); + var diff = lastRow - firstRow + 1; + } + + var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE); + var folds = this.getFoldsInRange(range).map(function(x){ + x = x.clone(); + x.start.row += diff; + x.end.row += diff; + return x; + }); + + var lines = dir == 0 + ? this.doc.getLines(firstRow, lastRow) + : this.doc.removeFullLines(firstRow, lastRow); + this.doc.insertFullLines(firstRow+diff, lines); + folds.length && this.addFolds(folds); + return diff; + }; + /** + * Shifts all the lines in the document up one, starting from `firstRow` and ending at `lastRow`. + * @param {Number} firstRow The starting row to move up + * @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. + * + **/ + this.moveLinesUp = function(firstRow, lastRow) { + return this.$moveLines(firstRow, lastRow, -1); + }; + + /** + * Shifts all the lines in the document down one, starting from `firstRow` and ending at `lastRow`. + * @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. + **/ + this.moveLinesDown = function(firstRow, lastRow) { + return this.$moveLines(firstRow, lastRow, 1); + }; + + /** + * Duplicates all the text between `firstRow` and `lastRow`. + * @param {Number} firstRow The starting row to duplicate + * @param {Number} lastRow The final row to duplicate + * @returns {Number} Returns the number of new rows added; in other words, `lastRow - firstRow + 1`. + * + * + **/ + this.duplicateLines = function(firstRow, lastRow) { + return this.$moveLines(firstRow, lastRow, 0); + }; + + + this.$clipRowToDocument = function(row) { + return Math.max(0, Math.min(row, this.doc.getLength()-1)); + }; + + this.$clipColumnToRow = function(row, column) { + if (column < 0) + return 0; + return Math.min(this.doc.getLine(row).length, column); + }; + + + this.$clipPositionToDocument = function(row, column) { + column = Math.max(0, column); + + if (row < 0) { + row = 0; + column = 0; + } else { + var len = this.doc.getLength(); + if (row >= len) { + row = len - 1; + column = this.doc.getLine(len-1).length; + } else { + column = Math.min(this.doc.getLine(row).length, column); + } + } + + return { + row: row, + column: column + }; + }; + + this.$clipRangeToDocument = function(range) { + if (range.start.row < 0) { + range.start.row = 0; + range.start.column = 0; + } else { + range.start.column = this.$clipColumnToRow( + range.start.row, + range.start.column + ); + } + + var len = this.doc.getLength() - 1; + if (range.end.row > len) { + range.end.row = len; + range.end.column = this.doc.getLine(len).length; + } else { + range.end.column = this.$clipColumnToRow( + range.end.row, + range.end.column + ); + } + return range; + }; + + // WRAPMODE + this.$wrapLimit = 80; + this.$useWrapMode = false; + this.$wrapLimitRange = { + min : null, + max : null + }; + + /** + * Sets whether or not line wrapping is enabled. If `useWrapMode` is different than the current value, the `'changeWrapMode'` event is emitted. + * @param {Boolean} useWrapMode Enable (or disable) wrap mode + * + **/ + this.setUseWrapMode = function(useWrapMode) { + if (useWrapMode != this.$useWrapMode) { + this.$useWrapMode = useWrapMode; + this.$modified = true; + this.$resetRowCache(0); + + // If wrapMode is activaed, the wrapData array has to be initialized. + if (useWrapMode) { + var len = this.getLength(); + this.$wrapData = Array(len); + this.$updateWrapData(0, len - 1); + } + + this._signal("changeWrapMode"); + } + }; + + /** + * Returns `true` if wrap mode is being used; `false` otherwise. + * @returns {Boolean} + **/ + this.getUseWrapMode = function() { + return this.$useWrapMode; + }; + + // Allow the wrap limit to move freely between min and max. Either + // parameter can be null to allow the wrap limit to be unconstrained + // in that direction. Or set both parameters to the same number to pin + // the limit to that value. + /** + * Sets the boundaries of wrap. Either value can be `null` to have an unconstrained wrap, or, they can be the same number to pin the limit. If the wrap limits for `min` or `max` are different, this method also emits the `'changeWrapMode'` event. + * @param {Number} min The minimum wrap value (the left side wrap) + * @param {Number} max The maximum wrap value (the right side wrap) + * + **/ + this.setWrapLimitRange = function(min, max) { + if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) { + this.$wrapLimitRange = { min: min, max: max }; + this.$modified = true; + this.$bidiHandler.markAsDirty(); + + // This will force a recalculation of the wrap limit + if (this.$useWrapMode) + this._signal("changeWrapMode"); + } + }; + + /** + * This should generally only be called by the renderer when a resize is detected. + * @param {Number} desiredLimit The new wrap limit + * @returns {Boolean} + * + * @private + **/ + this.adjustWrapLimit = function(desiredLimit, $printMargin) { + var limits = this.$wrapLimitRange; + if (limits.max < 0) + limits = {min: $printMargin, max: $printMargin}; + var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max); + if (wrapLimit != this.$wrapLimit && wrapLimit > 1) { + this.$wrapLimit = wrapLimit; + this.$modified = true; + if (this.$useWrapMode) { + this.$updateWrapData(0, this.getLength() - 1); + this.$resetRowCache(0); + this._signal("changeWrapLimit"); + } + return true; + } + return false; + }; + + this.$constrainWrapLimit = function(wrapLimit, min, max) { + if (min) + wrapLimit = Math.max(min, wrapLimit); + + if (max) + wrapLimit = Math.min(max, wrapLimit); + + return wrapLimit; + }; + + /** + * Returns the value of wrap limit. + * @returns {Number} The wrap limit. + **/ + this.getWrapLimit = function() { + return this.$wrapLimit; + }; + + /** + * Sets the line length for soft wrap in the editor. Lines will break + * at a minimum of the given length minus 20 chars and at a maximum + * of the given number of chars. + * @param {number} limit The maximum line length in chars, for soft wrapping lines. + */ + this.setWrapLimit = function (limit) { + this.setWrapLimitRange(limit, limit); + }; + + /** + * Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this: + * + * { min: wrapLimitRange_min, max: wrapLimitRange_max } + * + * @returns {Object} + **/ + this.getWrapLimitRange = function() { + // Avoid unexpected mutation by returning a copy + return { + min : this.$wrapLimitRange.min, + max : this.$wrapLimitRange.max + }; + }; + + this.$updateInternalDataOnChange = function(delta) { + var useWrapMode = this.$useWrapMode; + 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; + + this.$updating = true; + if (len != 0) { + if (action === "remove") { + this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len); + + var foldLines = this.$foldData; + removedFolds = this.getFoldsInRange(delta); + this.removeFolds(removedFolds); + + var foldLine = this.getFoldLine(end.row); + var idx = 0; + if (foldLine) { + foldLine.addRemoveChars(end.row, end.column, start.column - end.column); + foldLine.shiftRow(-len); + + var foldLineBefore = this.getFoldLine(firstRow); + if (foldLineBefore && foldLineBefore !== foldLine) { + foldLineBefore.merge(foldLine); + foldLine = foldLineBefore; + } + idx = foldLines.indexOf(foldLine) + 1; + } + + for (idx; idx < foldLines.length; idx++) { + var foldLine = foldLines[idx]; + if (foldLine.start.row >= end.row) { + foldLine.shiftRow(-len); + } + } + + lastRow = firstRow; + } else { + var args = Array(len); + args.unshift(firstRow, 0); + var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache; + arr.splice.apply(arr, args); + + // If some new line is added inside of a foldLine, then split + // the fold line up. + var foldLines = this.$foldData; + var foldLine = this.getFoldLine(firstRow); + var idx = 0; + if (foldLine) { + 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); + 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) { + foldLine.addRemoveChars(firstRow, 0, end.column - start.column); + foldLine.shiftRow(len); + } + // Nothing to do if the insert is after the foldLine. + idx = foldLines.indexOf(foldLine) + 1; + } + + for (idx; idx < foldLines.length; idx++) { + var foldLine = foldLines[idx]; + if (foldLine.start.row >= firstRow) { + foldLine.shiftRow(len); + } + } + } + } else { + // Realign folds. E.g. if you add some new chars before a fold, the + // fold should "move" to the right. + 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(delta); + this.removeFolds(removedFolds); + + len = -len; + } + var foldLine = this.getFoldLine(firstRow); + if (foldLine) { + foldLine.addRemoveChars(firstRow, start.column, len); + } + } + + if (useWrapMode && this.$wrapData.length != this.doc.getLength()) { + console.error("doc.getLength() and $wrapData.length have to be the same!"); + } + this.$updating = false; + + if (useWrapMode) + this.$updateWrapData(firstRow, lastRow); + else + this.$updateRowLengthCache(firstRow, lastRow); + + return removedFolds; + }; + + this.$updateRowLengthCache = function(firstRow, lastRow, b) { + this.$rowLengthCache[firstRow] = null; + this.$rowLengthCache[lastRow] = null; + }; + + this.$updateWrapData = function(firstRow, lastRow) { + var lines = this.doc.getAllLines(); + var tabSize = this.getTabSize(); + var wrapData = this.$wrapData; + var wrapLimit = this.$wrapLimit; + var tokens; + var foldLine; + + var row = firstRow; + lastRow = Math.min(lastRow, lines.length - 1); + while (row <= lastRow) { + foldLine = this.getFoldLine(row, foldLine); + if (!foldLine) { + tokens = this.$getDisplayTokens(lines[row]); + wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); + row ++; + } else { + tokens = []; + foldLine.walk(function(placeholder, row, column, lastColumn) { + var walkTokens; + if (placeholder != null) { + walkTokens = this.$getDisplayTokens( + placeholder, tokens.length); + walkTokens[0] = PLACEHOLDER_START; + for (var i = 1; i < walkTokens.length; i++) { + walkTokens[i] = PLACEHOLDER_BODY; + } + } else { + walkTokens = this.$getDisplayTokens( + lines[row].substring(lastColumn, column), + tokens.length); + } + tokens = tokens.concat(walkTokens); + }.bind(this), + foldLine.end.row, + lines[foldLine.end.row].length + 1 + ); + + wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); + row = foldLine.end.row + 1; + } + } + }; + + // "Tokens" + var CHAR = 1, + CHAR_EXT = 2, + PLACEHOLDER_START = 3, + PLACEHOLDER_BODY = 4, + PUNCTUATION = 9, + SPACE = 10, + TAB = 11, + TAB_SPACE = 12; + + + this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) { + if (tokens.length == 0) { + return []; + } + + var splits = []; + var displayLength = tokens.length; + var lastSplit = 0, lastDocSplit = 0; + + 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); + + // The document size is the current size - the extra width for tabs + // and multipleWidth characters. + var len = displayed.length; + displayed.join("") + // Get all the TAB_SPACEs. + .replace(/12/g, function() { + len -= 1; + }) + // Get all the CHAR_EXT/multipleWidth characters. + .replace(/2/g, function() { + len -= 1; + }); + + if (!splits.length) { + indent = getWrapIndent(); + splits.indent = indent; + } + lastDocSplit += len; + splits.push(lastDocSplit); + lastSplit = screenPos; + } + var indent = 0; + while (displayLength - lastSplit > wrapLimit - indent) { + // This is, where the split should be. + var split = lastSplit + wrapLimit - indent; + + // If there is a space or tab at this split position, then making + // a split is simple. + if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) { + /* disabled see https://github.com/ajaxorg/ace/issues/1186 + // Include all following spaces + tabs in this split as well. + while (tokens[split] >= SPACE) { + split ++; + } */ + addSplit(split); + continue; + } + + // === ELSE === + // Check if split is inside of a placeholder. Placeholder are + // not splitable. Therefore, seek the beginning of the placeholder + // and try to place the split before the placeholder's start. + if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) { + // Seek the start of the placeholder and do the split + // before the placeholder. By definition there always + // a PLACEHOLDER_START between split and lastSplit. + for (split; split != lastSplit - 1; split--) { + if (tokens[split] == PLACEHOLDER_START) { + // split++; << No incremental here as we want to + // have the position before the Placeholder. + break; + } + } + + // If the PLACEHOLDER_START is not the index of the + // last split, then we can do the split + if (split > lastSplit) { + addSplit(split); + continue; + } + + // If the PLACEHOLDER_START IS the index of the last + // split, then we have to place the split after the + // placeholder. So, let's seek for the end of the placeholder. + split = lastSplit + wrapLimit; + for (split; split < tokens.length; split++) { + if (tokens[split] != PLACEHOLDER_BODY) { + break; + } + } + + // If spilt == tokens.length, then the placeholder is the last + // thing in the line and adding a new split doesn't make sense. + if (split == tokens.length) { + break; // Breaks the while-loop. + } + + // Finally, add the split... + addSplit(split); + continue; + } + + // === ELSE === + // Search for the first non space/tab/placeholder/punctuation token backwards. + var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1); + while (split > minSplit && tokens[split] < PLACEHOLDER_START) { + split --; + } + if (isCode) { + while (split > minSplit && tokens[split] < PLACEHOLDER_START) { + split --; + } + while (split > minSplit && tokens[split] == PUNCTUATION) { + split --; + } + } else { + while (split > minSplit && tokens[split] < SPACE) { + split --; + } + } + // If we found one, then add the split. + if (split > minSplit) { + addSplit(++split); + continue; + } + + // === ELSE === + split = lastSplit + wrapLimit; + // The split is inside of a CHAR or CHAR_EXT token and no space + // around -> force a split. + if (tokens[split] == CHAR_EXT) + split--; + addSplit(split - indent); + } + return splits; + }; + + /** + * Given a string, returns an array of the display characters, including tabs and spaces. + * @param {String} str The string to check + * @param {Number} offset The value to start at + * + **/ + this.$getDisplayTokens = function(str, offset) { + var arr = []; + var tabSize; + offset = offset || 0; + + for (var i = 0; i < str.length; i++) { + var c = str.charCodeAt(i); + // Tab + if (c == 9) { + tabSize = this.getScreenTabSize(arr.length + offset); + arr.push(TAB); + for (var n = 1; n < tabSize; n++) { + arr.push(TAB_SPACE); + } + } + // Space + else if (c == 32) { + arr.push(SPACE); + } else if((c > 39 && c < 48) || (c > 57 && c < 64)) { + arr.push(PUNCTUATION); + } + // full width characters + else if (c >= 0x1100 && isFullWidth(c)) { + arr.push(CHAR, CHAR_EXT); + } else { + arr.push(CHAR); + } + } + return arr; + }; + + /** + * Calculates the width of the string `str` on the screen while assuming that the string starts at the first column on the screen. + * @param {String} str The string to calculate the screen width of + * @param {Number} maxScreenColumn + * @param {Number} screenColumn + * @returns {[Number]} Returns an `int[]` array with two elements:
+ * The first position indicates the number of columns for `str` on screen.
+ * The second value contains the position of the document column that this function read until. + * + **/ + this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) { + if (maxScreenColumn == 0) + return [0, 0]; + if (maxScreenColumn == null) + maxScreenColumn = Infinity; + screenColumn = screenColumn || 0; + + var c, column; + for (column = 0; column < str.length; column++) { + c = str.charCodeAt(column); + // tab + if (c == 9) { + screenColumn += this.getScreenTabSize(screenColumn); + } + // full width characters + else if (c >= 0x1100 && isFullWidth(c)) { + screenColumn += 2; + } else { + screenColumn += 1; + } + if (screenColumn > maxScreenColumn) { + break; + } + } + + return [screenColumn, column]; + }; + + this.lineWidgets = null; + /** + * Returns number of screenrows in a wrapped line. + * @param {Number} row The row number to check + * + * @returns {Number} + **/ + this.getRowLength = function(row) { + if (this.lineWidgets) + var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0; + else + h = 0; + if (!this.$useWrapMode || !this.$wrapData[row]) { + return 1 + h; + } else { + return this.$wrapData[row].length + 1 + h; + } + }; + this.getRowLineCount = function(row) { + if (!this.$useWrapMode || !this.$wrapData[row]) { + return 1; + } else { + return this.$wrapData[row].length + 1; + } + }; + + 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 + * @returns {Number} + * + * @related EditSession.documentToScreenColumn + **/ + this.getScreenLastRowColumn = function(screenRow) { + var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE); + return this.documentToScreenColumn(pos.row, pos.column); + }; + + /** + * For the given document row and column, this returns the column position of the last screen row. + * @param {Number} docRow + * + * @param {Number} docColumn + **/ + this.getDocumentLastRowColumn = function(docRow, docColumn) { + var screenRow = this.documentToScreenRow(docRow, docColumn); + return this.getScreenLastRowColumn(screenRow); + }; + + /** + * For the given document row and column, this returns the document position of the last row. + * @param {Number} docRow + * @param {Number} docColumn + * + **/ + this.getDocumentLastRowColumnPosition = function(docRow, docColumn) { + var screenRow = this.documentToScreenRow(docRow, docColumn); + return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10); + }; + + /** + * For the given row, this returns the split data. + * @returns {String} + **/ + this.getRowSplitData = function(row) { + if (!this.$useWrapMode) { + return undefined; + } else { + return this.$wrapData[row]; + } + }; + + /** + * The distance to the next tab stop at the specified screen column. + * @param {Number} screenColumn The screen column to check + * + * @returns {Number} + **/ + this.getScreenTabSize = function(screenColumn) { + return this.$tabSize - screenColumn % this.$tabSize; + }; + + + this.screenToDocumentRow = function(screenRow, screenColumn) { + return this.screenToDocumentPosition(screenRow, screenColumn).row; + }; + + + this.screenToDocumentColumn = function(screenRow, screenColumn) { + return this.screenToDocumentPosition(screenRow, screenColumn).column; + }; + + /** + * Converts characters coordinates on the screen to characters coordinates within the document. [This takes into account code folding, word wrap, tab size, and any other visual modifications.]{: #conversionConsiderations} + * @param {Number} screenRow The screen row to check + * @param {Number} screenColumn The screen column to check + * @param {int} screen character x-offset [optional] + * + * @returns {Object} The object returned has two properties: `row` and `column`. + * + * @related EditSession.documentToScreenPosition + **/ + this.screenToDocumentPosition = function(screenRow, screenColumn, offsetX) { + if (screenRow < 0) + return {row: 0, column: 0}; + + var line; + var docRow = 0; + var docColumn = 0; + var column; + var row = 0; + var rowLength = 0; + + var rowCache = this.$screenRowCache; + var i = this.$getRowCacheIndex(rowCache, screenRow); + var l = rowCache.length; + if (l && i >= 0) { + var row = rowCache[i]; + var docRow = this.$docRowCache[i]; + var doCache = screenRow > rowCache[l - 1]; + } else { + var doCache = !l; + } + + var maxRow = this.getLength() - 1; + var foldLine = this.getNextFoldLine(docRow); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (row <= screenRow) { + rowLength = this.getRowLength(docRow); + if (row + rowLength > screenRow || docRow >= maxRow) { + break; + } else { + row += rowLength; + docRow++; + if (docRow > foldStart) { + docRow = foldLine.end.row+1; + foldLine = this.getNextFoldLine(docRow, foldLine); + foldStart = foldLine ? foldLine.start.row : Infinity; + } + } + + if (doCache) { + this.$docRowCache.push(docRow); + this.$screenRowCache.push(row); + } + } + + if (foldLine && foldLine.start.row <= docRow) { + line = this.getFoldDisplayLine(foldLine); + docRow = foldLine.start.row; + } else if (row + rowLength <= screenRow || docRow > maxRow) { + // clip at the end of the document + return { + row: maxRow, + column: this.getLine(maxRow).length + }; + } else { + line = this.getLine(docRow); + foldLine = null; + } + var wrapIndent = 0, splitIndex = Math.floor(screenRow - row); + if (this.$useWrapMode) { + var splits = this.$wrapData[docRow]; + if (splits) { + column = splits[splitIndex]; + if(splitIndex > 0 && splits.length) { + wrapIndent = splits.indent; + docColumn = splits[splitIndex - 1] || splits[splits.length - 1]; + line = line.substring(docColumn); + } + } + } + + if (offsetX !== undefined && this.$bidiHandler.isBidiRow(row + splitIndex, docRow, splitIndex)) + screenColumn = this.$bidiHandler.offsetToCol(offsetX); + + 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. + if (this.$useWrapMode && docColumn >= column) + docColumn = column - 1; + + if (foldLine) + return foldLine.idxToPosition(docColumn); + + return {row: docRow, column: docColumn}; + }; + + /** + * Converts document coordinates to screen coordinates. {:conversionConsiderations} + * @param {Number} docRow The document row to check + * @param {Number} docColumn The document column to check + * @returns {Object} The object returned by this method has two properties: `row` and `column`. + * + * @related EditSession.screenToDocumentPosition + **/ + this.documentToScreenPosition = function(docRow, docColumn) { + // Normalize the passed in arguments. + if (typeof docColumn === "undefined") + var pos = this.$clipPositionToDocument(docRow.row, docRow.column); + else + pos = this.$clipPositionToDocument(docRow, docColumn); + + docRow = pos.row; + docColumn = pos.column; + + var screenRow = 0; + var foldStartRow = null; + var fold = null; + + // Clamp the docRow position in case it's inside of a folded block. + fold = this.getFoldAt(docRow, docColumn, 1); + if (fold) { + docRow = fold.start.row; + docColumn = fold.start.column; + } + + var rowEnd, row = 0; + + + var rowCache = this.$docRowCache; + var i = this.$getRowCacheIndex(rowCache, docRow); + var l = rowCache.length; + if (l && i >= 0) { + var row = rowCache[i]; + var screenRow = this.$screenRowCache[i]; + var doCache = docRow > rowCache[l - 1]; + } else { + var doCache = !l; + } + + var foldLine = this.getNextFoldLine(row); + var foldStart = foldLine ?foldLine.start.row :Infinity; + + while (row < docRow) { + if (row >= foldStart) { + rowEnd = foldLine.end.row + 1; + if (rowEnd > docRow) + break; + foldLine = this.getNextFoldLine(rowEnd, foldLine); + foldStart = foldLine ?foldLine.start.row :Infinity; + } + else { + rowEnd = row + 1; + } + + screenRow += this.getRowLength(row); + row = rowEnd; + + if (doCache) { + this.$docRowCache.push(row); + this.$screenRowCache.push(screenRow); + } + } + + // Calculate the text line that is displayed in docRow on the screen. + var textLine = ""; + // Check if the final row we want to reach is inside of a fold. + if (foldLine && row >= foldStart) { + textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn); + foldStartRow = foldLine.start.row; + } else { + 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]; + if (wrapRow) { + var screenRowOffset = 0; + while (textLine.length >= wrapRow[screenRowOffset]) { + screenRow ++; + screenRowOffset++; + } + textLine = textLine.substring( + wrapRow[screenRowOffset - 1] || 0, textLine.length + ); + wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0; + } + } + + return { + row: screenRow, + column: wrapIndent + this.$getStringScreenWidth(textLine)[0] + }; + }; + + /** + * For the given document row and column, returns the screen column. + * @param {Number} row + * @param {Number} docColumn + * @returns {Number} + * + **/ + this.documentToScreenColumn = function(row, docColumn) { + return this.documentToScreenPosition(row, docColumn).column; + }; + + /** + * For the given document row and column, returns the screen row. + * @param {Number} docRow + * @param {Number} docColumn + * + **/ + this.documentToScreenRow = function(docRow, docColumn) { + return this.documentToScreenPosition(docRow, docColumn).row; + }; + + /** + * Returns the length of the screen. + * @returns {Number} + **/ + this.getScreenLength = function() { + var screenRows = 0; + var fold = null; + if (!this.$useWrapMode) { + screenRows = this.getLength(); + + // Remove the folded lines again. + var foldData = this.$foldData; + for (var i = 0; i < foldData.length; i++) { + fold = foldData[i]; + screenRows -= fold.end.row - fold.start.row; + } + } else { + var lastRow = this.$wrapData.length; + var row = 0, i = 0; + var fold = this.$foldData[i++]; + var foldStart = fold ? fold.start.row :Infinity; + + while (row < lastRow) { + var splits = this.$wrapData[row]; + screenRows += splits ? splits.length + 1 : 1; + row ++; + if (row > foldStart) { + row = fold.end.row+1; + fold = this.$foldData[i++]; + foldStart = fold ?fold.start.row :Infinity; + } + } + } + + // todo + if (this.lineWidgets) + screenRows += this.$getWidgetScreenLength(); + + return screenRows; + }; + + /** + * @private + * + */ + this.$setFontMetrics = function(fm) { + if (!this.$enableVarChar) return; + this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) { + if (maxScreenColumn === 0) + return [0, 0]; + if (!maxScreenColumn) + maxScreenColumn = Infinity; + screenColumn = screenColumn || 0; + + var c, column; + for (column = 0; column < str.length; column++) { + c = str.charAt(column); + // tab + if (c === "\t") { + screenColumn += this.getScreenTabSize(screenColumn); + } else { + screenColumn += fm.getCharacterWidth(c); + } + if (screenColumn > maxScreenColumn) { + break; + } + } + + return [screenColumn, column]; + }; + }; + + this.destroy = function() { + if (this.bgTokenizer) { + this.bgTokenizer.setDocument(null); + this.bgTokenizer = null; + } + this.$stopWorker(); + }; + + this.isFullWidth = isFullWidth; + + // 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 + function isFullWidth(c) { + if (c < 0x1100) + return false; + return c >= 0x1100 && c <= 0x115F || + c >= 0x11A3 && c <= 0x11A7 || + c >= 0x11FA && c <= 0x11FF || + c >= 0x2329 && c <= 0x232A || + c >= 0x2E80 && c <= 0x2E99 || + c >= 0x2E9B && c <= 0x2EF3 || + c >= 0x2F00 && c <= 0x2FD5 || + c >= 0x2FF0 && c <= 0x2FFB || + c >= 0x3000 && c <= 0x303E || + c >= 0x3041 && c <= 0x3096 || + c >= 0x3099 && c <= 0x30FF || + c >= 0x3105 && c <= 0x312D || + c >= 0x3131 && c <= 0x318E || + c >= 0x3190 && c <= 0x31BA || + c >= 0x31C0 && c <= 0x31E3 || + c >= 0x31F0 && c <= 0x321E || + c >= 0x3220 && c <= 0x3247 || + c >= 0x3250 && c <= 0x32FE || + c >= 0x3300 && c <= 0x4DBF || + c >= 0x4E00 && c <= 0xA48C || + c >= 0xA490 && c <= 0xA4C6 || + c >= 0xA960 && c <= 0xA97C || + c >= 0xAC00 && c <= 0xD7A3 || + c >= 0xD7B0 && c <= 0xD7C6 || + c >= 0xD7CB && c <= 0xD7FB || + c >= 0xF900 && c <= 0xFAFF || + c >= 0xFE10 && c <= 0xFE19 || + c >= 0xFE30 && c <= 0xFE52 || + c >= 0xFE54 && c <= 0xFE66 || + c >= 0xFE68 && c <= 0xFE6B || + c >= 0xFF01 && c <= 0xFF60 || + c >= 0xFFE0 && c <= 0xFFE6; + } + +}).call(EditSession.prototype); + +require("./edit_session/folding").Folding.call(EditSession.prototype); +require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype); + + +config.defineOptions(EditSession.prototype, "session", { + wrap: { + set: function(value) { + if (!value || value == "off") + value = false; + else if (value == "free") + value = true; + else if (value == "printMargin") + value = -1; + else if (typeof value == "string") + value = parseInt(value, 10) || false; + + if (this.$wrap == value) + return; + this.$wrap = value; + if (!value) { + this.setUseWrapMode(false); + } else { + var col = typeof value == "number" ? value : null; + this.setWrapLimitRange(col, col); + this.setUseWrapMode(true); + } + }, + get: function() { + if (this.getUseWrapMode()) { + if (this.$wrap == -1) + return "printMargin"; + if (!this.getWrapLimitRange().min) + return "free"; + return this.$wrap; + } + return "off"; + }, + handlesSet: true + }, + wrapMethod: { + // code|text|auto + set: function(val) { + val = val == "auto" + ? this.$mode.type != "text" + : val != "text"; + if (val != this.$wrapAsCode) { + this.$wrapAsCode = val; + if (this.$useWrapMode) { + this.$modified = true; + this.$resetRowCache(0); + this.$updateWrapData(0, this.getLength() - 1); + } + } + }, + initialValue: "auto" + }, + indentedSoftWrap: { initialValue: true }, + firstLineNumber: { + set: function() {this._signal("changeBreakpoint");}, + initialValue: 1 + }, + useWorker: { + set: function(useWorker) { + this.$useWorker = useWorker; + + this.$stopWorker(); + if (useWorker) + this.$startWorker(); + }, + initialValue: true + }, + useSoftTabs: {initialValue: true}, + tabSize: { + set: function(tabSize) { + if (isNaN(tabSize) || this.$tabSize === tabSize) return; + + this.$modified = true; + this.$rowLengthCache = []; + this.$tabSize = tabSize; + this._signal("changeTabSize"); + }, + initialValue: 4, + handlesSet: true + }, + navigateWithinSoftTabs: {initialValue: false}, + overwrite: { + set: function(val) {this._signal("changeOverwrite");}, + initialValue: false + }, + newLineMode: { + set: function(val) {this.doc.setNewLineMode(val);}, + get: function() {return this.doc.getNewLineMode();}, + handlesSet: true + }, + mode: { + set: function(val) { this.setMode(val); }, + get: function() { return this.$modeId; } + } +}); + +exports.EditSession = EditSession; +}); diff --git a/public/lib/ace/edit_session/bracket_match.js b/public/lib/ace/edit_session/bracket_match.js new file mode 100644 index 0000000..62a8499 --- /dev/null +++ b/public/lib/ace/edit_session/bracket_match.js @@ -0,0 +1,221 @@ +/* ***** 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 TokenIterator = require("../token_iterator").TokenIterator; +var Range = require("../range").Range; + + +function BracketMatch() { + + this.findMatchingBracket = function(position, chr) { + if (position.column == 0) return null; + + var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1); + if (charBeforeCursor == "") return null; + + var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/); + if (!match) + return null; + + if (match[1]) + return this.$findClosingBracket(match[1], position); + else + return this.$findOpeningBracket(match[2], position); + }; + + this.getBracketRange = function(pos) { + var line = this.getLine(pos.row); + var before = true, range; + + var chr = line.charAt(pos.column-1); + var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); + if (!match) { + chr = line.charAt(pos.column); + pos = {row: pos.row, column: pos.column + 1}; + match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); + before = false; + } + if (!match) + return null; + + if (match[1]) { + var bracketPos = this.$findClosingBracket(match[1], pos); + if (!bracketPos) + return null; + range = Range.fromPoints(pos, bracketPos); + if (!before) { + range.end.column++; + range.start.column--; + } + range.cursor = range.end; + } else { + var bracketPos = this.$findOpeningBracket(match[2], pos); + if (!bracketPos) + return null; + range = Range.fromPoints(bracketPos, pos); + if (!before) { + range.start.column++; + range.end.column--; + } + range.cursor = range.start; + } + + return range; + }; + + this.$brackets = { + ")": "(", + "(": ")", + "]": "[", + "[": "]", + "{": "}", + "}": "{" + }; + + this.$findOpeningBracket = function(bracket, position, typeRe) { + var openBracket = this.$brackets[bracket]; + var depth = 1; + + var iterator = new TokenIterator(this, position.row, position.column); + var token = iterator.getCurrentToken(); + if (!token) + token = iterator.stepForward(); + if (!token) + return; + + if (!typeRe){ + typeRe = new RegExp( + "(\\.?" + + token.type.replace(".", "\\.").replace("rparen", ".paren") + .replace(/\b(?:end)\b/, "(?:start|begin|end)") + + ")+" + ); + } + + // Start searching in token, just before the character at position.column + var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2; + var value = token.value; + + while (true) { + + while (valueIndex >= 0) { + var chr = value.charAt(valueIndex); + if (chr == openBracket) { + depth -= 1; + if (depth == 0) { + return {row: iterator.getCurrentTokenRow(), + column: valueIndex + iterator.getCurrentTokenColumn()}; + } + } + else if (chr == bracket) { + depth += 1; + } + valueIndex -= 1; + } + + // Scan backward through the document, looking for the next token + // whose type matches typeRe + do { + token = iterator.stepBackward(); + } while (token && !typeRe.test(token.type)); + + if (token == null) + break; + + value = token.value; + valueIndex = value.length - 1; + } + + return null; + }; + + this.$findClosingBracket = function(bracket, position, typeRe) { + var closingBracket = this.$brackets[bracket]; + var depth = 1; + + var iterator = new TokenIterator(this, position.row, position.column); + var token = iterator.getCurrentToken(); + if (!token) + token = iterator.stepForward(); + if (!token) + return; + + if (!typeRe){ + typeRe = new RegExp( + "(\\.?" + + token.type.replace(".", "\\.").replace("lparen", ".paren") + .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)") + + ")+" + ); + } + + // Start searching in token, after the character at position.column + var valueIndex = position.column - iterator.getCurrentTokenColumn(); + + while (true) { + + var value = token.value; + var valueLength = value.length; + while (valueIndex < valueLength) { + var chr = value.charAt(valueIndex); + if (chr == closingBracket) { + depth -= 1; + if (depth == 0) { + return {row: iterator.getCurrentTokenRow(), + column: valueIndex + iterator.getCurrentTokenColumn()}; + } + } + else if (chr == bracket) { + depth += 1; + } + valueIndex += 1; + } + + // Scan forward through the document, looking for the next token + // whose type matches typeRe + do { + token = iterator.stepForward(); + } while (token && !typeRe.test(token.type)); + + if (token == null) + break; + + valueIndex = 0; + } + + return null; + }; +} +exports.BracketMatch = BracketMatch; + +}); diff --git a/public/lib/ace/edit_session/fold.js b/public/lib/ace/edit_session/fold.js new file mode 100644 index 0000000..55f71aa --- /dev/null +++ b/public/lib/ace/edit_session/fold.js @@ -0,0 +1,140 @@ +/* ***** 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 Range = require("../range").Range; +var RangeList = require("../range_list").RangeList; +var oop = require("../lib/oop"); +/* + * Simple fold-data struct. + **/ +var Fold = exports.Fold = function(range, placeholder) { + this.foldLine = null; + this.placeholder = placeholder; + this.range = range; + this.start = range.start; + this.end = range.end; + + this.sameRow = range.start.row == range.end.row; + this.subFolds = this.ranges = []; +}; + +oop.inherits(Fold, RangeList); + +(function() { + + this.toString = function() { + return '"' + this.placeholder + '" ' + this.range.toString(); + }; + + this.setFoldLine = function(foldLine) { + this.foldLine = foldLine; + this.subFolds.forEach(function(fold) { + fold.setFoldLine(foldLine); + }); + }; + + this.clone = function() { + var range = this.range.clone(); + var fold = new Fold(range, this.placeholder); + this.subFolds.forEach(function(subFold) { + fold.subFolds.push(subFold.clone()); + }); + fold.collapseChildren = this.collapseChildren; + return fold; + }; + + this.addSubFold = function(fold) { + if (this.range.isEqual(fold)) + return; + + if (!this.range.containsRange(fold)) + throw new Error("A fold can't intersect already existing fold" + fold.range + this.range); + + // transform fold to local coordinates + consumeRange(fold, this.start); + + var row = fold.start.row, column = fold.start.column; + for (var i = 0, cmp = -1; i < this.subFolds.length; i++) { + cmp = this.subFolds[i].range.compare(row, column); + if (cmp != 1) + break; + } + var afterStart = this.subFolds[i]; + + if (cmp == 0) + return afterStart.addSubFold(fold); + + // cmp == -1 + var row = fold.range.end.row, column = fold.range.end.column; + for (var j = i, cmp = -1; j < this.subFolds.length; j++) { + cmp = this.subFolds[j].range.compare(row, column); + if (cmp != 1) + break; + } + var afterEnd = this.subFolds[j]; + + if (cmp == 0) + throw new Error("A fold can't intersect already existing fold" + fold.range + this.range); + + var consumedFolds = this.subFolds.splice(i, j - i, fold); + fold.setFoldLine(this.foldLine); + + return fold; + }; + + this.restoreRange = function(range) { + return restoreRange(range, this.start); + }; + +}).call(Fold.prototype); + +function consumePoint(point, anchor) { + point.row -= anchor.row; + if (point.row == 0) + point.column -= anchor.column; +} +function consumeRange(range, anchor) { + consumePoint(range.start, anchor); + consumePoint(range.end, anchor); +} +function restorePoint(point, anchor) { + if (point.row == 0) + point.column += anchor.column; + point.row += anchor.row; +} +function restoreRange(range, anchor) { + restorePoint(range.start, anchor); + restorePoint(range.end, anchor); +} + +}); diff --git a/public/lib/ace/edit_session/fold_line.js b/public/lib/ace/edit_session/fold_line.js new file mode 100644 index 0000000..9d73154 --- /dev/null +++ b/public/lib/ace/edit_session/fold_line.js @@ -0,0 +1,269 @@ +/* ***** 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 Range = require("../range").Range; + +/* + * If an array is passed in, the folds are expected to be sorted already. + */ +function FoldLine(foldData, folds) { + this.foldData = foldData; + if (Array.isArray(folds)) { + this.folds = folds; + } else { + folds = this.folds = [ folds ]; + } + + 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; + this.end = this.range.end; + + this.folds.forEach(function(fold) { + fold.setFoldLine(this); + }, this); +} + +(function() { + /* + * Note: This doesn't update wrapData! + */ + this.shiftRow = function(shift) { + this.start.row += shift; + this.end.row += shift; + this.folds.forEach(function(fold) { + fold.start.row += shift; + fold.end.row += shift; + }); + }; + + this.addFold = function(fold) { + if (fold.sameRow) { + if (fold.start.row < this.startRow || fold.endRow > this.endRow) { + throw new Error("Can't add a fold to this FoldLine as it has no connection"); + } + this.folds.push(fold); + this.folds.sort(function(a, b) { + return -a.range.compareEnd(b.start.row, b.start.column); + }); + if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) { + this.end.row = fold.end.row; + this.end.column = fold.end.column; + } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) { + this.start.row = fold.start.row; + this.start.column = fold.start.column; + } + } else if (fold.start.row == this.end.row) { + this.folds.push(fold); + this.end.row = fold.end.row; + this.end.column = fold.end.column; + } else if (fold.end.row == this.start.row) { + this.folds.unshift(fold); + this.start.row = fold.start.row; + this.start.column = fold.start.column; + } else { + 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, + cmp, stop, isNewRow = true; + + if (endRow == null) { + endRow = this.end.row; + endColumn = this.end.column; + } + + for (var i = 0; i < folds.length; i++) { + fold = folds[i]; + + cmp = fold.range.compareStart(endRow, endColumn); + // This fold is after the endRow/Column. + if (cmp == -1) { + callback(null, endRow, endColumn, lastEnd, isNewRow); + return; + } + + stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow); + 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 (cmp == 0), then end here. + if (stop || cmp === 0) { + return; + } + + // Note the new lastEnd might not be on the same line. However, + // it's the callback's job to recognize this. + isNewRow = !fold.sameRow; + lastEnd = fold.end.column; + } + callback(null, endRow, endColumn, lastEnd, isNewRow); + }; + + this.getNextFoldTo = function(row, column) { + var fold, cmp; + for (var i = 0; i < this.folds.length; i++) { + fold = this.folds[i]; + cmp = fold.range.compareEnd(row, column); + if (cmp == -1) { + return { + fold: fold, + kind: "after" + }; + } else if (cmp === 0) { + return { + fold: fold, + kind: "inside" + }; + } + } + return null; + }; + + this.addRemoveChars = function(row, column, len) { + var ret = this.getNextFoldTo(row, column), + fold, folds; + if (ret) { + fold = ret.fold; + if (ret.kind == "inside" + && fold.start.column != column + && fold.start.row != row) + { + //throwing here breaks whole editor + //TODO: properly handle this + window.console && window.console.log(row, column, fold); + } else if (fold.start.row == row) { + folds = this.folds; + var i = folds.indexOf(fold); + if (i === 0) { + this.start.column += len; + } + for (i; i < folds.length; i++) { + fold = folds[i]; + fold.start.column += len; + if (!fold.sameRow) { + return; + } + fold.end.column += len; + } + this.end.column += len; + } + } + }; + + this.split = function(row, column) { + 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; + + var i = folds.indexOf(fold); + var foldBefore = folds[i - 1]; + this.end.row = foldBefore.end.row; + this.end.column = foldBefore.end.column; + + // Remove the folds after row/column and create a new FoldLine + // containing these removed folds. + folds = folds.splice(i, folds.length - i); + + var newFoldLine = new FoldLine(foldData, folds); + foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine); + return newFoldLine; + }; + + this.merge = function(foldLineNext) { + var folds = foldLineNext.folds; + for (var i = 0; i < folds.length; i++) { + this.addFold(folds[i]); + } + // Remove the foldLineNext - no longer needed, as + // it's merged now with foldLineNext. + var foldData = this.foldData; + foldData.splice(foldData.indexOf(foldLineNext), 1); + }; + + this.toString = function() { + var ret = [this.range.toString() + ": [" ]; + + this.folds.forEach(function(fold) { + ret.push(" " + fold.toString()); + }); + ret.push("]"); + return ret.join("\n"); + }; + + this.idxToPosition = function(idx) { + var lastFoldEndColumn = 0; + + for (var i = 0; i < this.folds.length; i++) { + var fold = this.folds[i]; + + idx -= fold.start.column - lastFoldEndColumn; + if (idx < 0) { + return { + row: fold.start.row, + column: fold.start.column + idx + }; + } + + idx -= fold.placeholder.length; + if (idx < 0) { + return fold.start; + } + + lastFoldEndColumn = fold.end.column; + } + + return { + row: this.end.row, + column: this.end.column + idx + }; + }; +}).call(FoldLine.prototype); + +exports.FoldLine = FoldLine; +}); diff --git a/public/lib/ace/edit_session/folding.js b/public/lib/ace/edit_session/folding.js new file mode 100644 index 0000000..0315f82 --- /dev/null +++ b/public/lib/ace/edit_session/folding.js @@ -0,0 +1,869 @@ +/* ***** 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 Range = require("../range").Range; +var FoldLine = require("./fold_line").FoldLine; +var Fold = require("./fold").Fold; +var TokenIterator = require("../token_iterator").TokenIterator; + +function Folding() { + /* + * Looks up a fold at a given row/column. Possible values for side: + * -1: ignore a fold if fold.start = row/column + * +1: ignore a fold if fold.end = row/column + */ + this.getFoldAt = function(row, column, side) { + var foldLine = this.getFoldLine(row); + if (!foldLine) + return null; + + var folds = foldLine.folds; + for (var i = 0; i < folds.length; i++) { + var fold = folds[i]; + if (fold.range.contains(row, column)) { + if (side == 1 && fold.range.isEnd(row, column)) { + continue; + } else if (side == -1 && fold.range.isStart(row, column)) { + continue; + } + return fold; + } + } + }; + + /* + * Returns all folds in the given range. Note, that this will return folds + * + */ + this.getFoldsInRange = function(range) { + var start = range.start; + var end = range.end; + var foldLines = this.$foldData; + var foundFolds = []; + + start.column += 1; + end.column -= 1; + + for (var i = 0; i < foldLines.length; i++) { + var cmp = foldLines[i].range.compareRange(range); + if (cmp == 2) { + // Range is before foldLine. No intersection. This means, + // there might be other foldLines that intersect. + continue; + } + else if (cmp == -2) { + // Range is after foldLine. There can't be any other foldLines then, + // so let's give up. + break; + } + + var folds = foldLines[i].folds; + for (var j = 0; j < folds.length; j++) { + var fold = folds[j]; + cmp = fold.range.compareRange(range); + if (cmp == -2) { + break; + } else if (cmp == 2) { + continue; + } else + // WTF-state: Can happen due to -1/+1 to start/end column. + if (cmp == 42) { + break; + } + foundFolds.push(fold); + } + } + start.column -= 1; + end.column += 1; + + return foundFolds; + }; + + this.getFoldsInRangeList = function(ranges) { + if (Array.isArray(ranges)) { + var folds = []; + ranges.forEach(function(range) { + folds = folds.concat(this.getFoldsInRange(range)); + }, this); + } else { + var folds = this.getFoldsInRange(ranges); + } + return folds; + }; + + /* + * Returns all folds in the document + */ + this.getAllFolds = function() { + var folds = []; + var foldLines = this.$foldData; + + for (var i = 0; i < foldLines.length; i++) + for (var j = 0; j < foldLines[i].folds.length; j++) + folds.push(foldLines[i].folds[j]); + + return folds; + }; + + /* + * Returns the string between folds at the given position. + * E.g. + * foob|arwolrd -> "bar" + * foobarwol|rd -> "world" + * foobarwolrd -> + * + * where | means the position of row/column + * + * The trim option determs if the return string should be trimed according + * to the "side" passed with the trim value: + * + * E.g. + * foob|arwolrd -trim=-1> "b" + * foobarwol|rd -trim=+1> "rld" + * fo|obarwolrd -trim=00> "foo" + */ + this.getFoldStringAt = function(row, column, trim, foldLine) { + foldLine = foldLine || this.getFoldLine(row); + if (!foldLine) + return null; + + var lastFold = { + end: { column: 0 } + }; + // TODO: Refactor to use getNextFoldTo function. + var str, fold; + for (var i = 0; i < foldLine.folds.length; i++) { + fold = foldLine.folds[i]; + var cmp = fold.range.compareEnd(row, column); + if (cmp == -1) { + str = this + .getLine(fold.start.row) + .substring(lastFold.end.column, fold.start.column); + break; + } + else if (cmp === 0) { + return null; + } + lastFold = fold; + } + if (!str) + str = this.getLine(fold.start.row).substring(lastFold.end.column); + + if (trim == -1) + return str.substring(0, column - lastFold.end.column); + else if (trim == 1) + return str.substring(column - lastFold.end.column); + else + return str; + }; + + this.getFoldLine = function(docRow, startFoldLine) { + var foldData = this.$foldData; + var i = 0; + if (startFoldLine) + i = foldData.indexOf(startFoldLine); + if (i == -1) + i = 0; + for (i; i < foldData.length; i++) { + var foldLine = foldData[i]; + if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) { + return foldLine; + } else if (foldLine.end.row > docRow) { + return null; + } + } + return null; + }; + + // returns the fold which starts after or contains docRow + this.getNextFoldLine = function(docRow, startFoldLine) { + var foldData = this.$foldData; + var i = 0; + if (startFoldLine) + i = foldData.indexOf(startFoldLine); + if (i == -1) + i = 0; + for (i; i < foldData.length; i++) { + var foldLine = foldData[i]; + if (foldLine.end.row >= docRow) { + return foldLine; + } + } + return null; + }; + + this.getFoldedRowCount = function(first, last) { + var foldData = this.$foldData, rowCount = last-first+1; + for (var i = 0; i < foldData.length; i++) { + var foldLine = foldData[i], + end = foldLine.end.row, + start = foldLine.start.row; + if (end >= last) { + if (start < last) { + if (start >= first) + rowCount -= last-start; + else + rowCount = 0; // in one fold + } + break; + } else if (end >= first){ + if (start >= first) // fold inside range + rowCount -= end-start; + else + rowCount -= end-first+1; + } + } + return rowCount; + }; + + this.$addFoldLine = function(foldLine) { + this.$foldData.push(foldLine); + this.$foldData.sort(function(a, b) { + return a.start.row - b.start.row; + }); + return foldLine; + }; + + /** + * Adds a new fold. + * + * @returns + * The new created Fold object or an existing fold object in case the + * passed in range fits an existing fold exactly. + */ + this.addFold = function(placeholder, range) { + var foldData = this.$foldData; + var added = false; + var fold; + + if (placeholder instanceof Fold) + fold = placeholder; + else { + fold = new Fold(range, placeholder); + fold.collapseChildren = range.collapseChildren; + } + this.$clipRangeToDocument(fold.range); + + var startRow = fold.start.row; + var startColumn = fold.start.column; + var endRow = fold.end.row; + var endColumn = fold.end.column; + + // --- Some checking --- + if (!(startRow < endRow || + startRow == endRow && startColumn <= endColumn - 2)) + throw new Error("The range has to be at least 2 characters width"); + + var startFold = this.getFoldAt(startRow, startColumn, 1); + var endFold = this.getFoldAt(endRow, endColumn, -1); + if (startFold && endFold == startFold) + return startFold.addSubFold(fold); + + 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) { + // Remove the folds from fold data. + this.removeFolds(folds); + // Add the removed folds as subfolds on the new fold. + folds.forEach(function(subFold) { + fold.addSubFold(subFold); + }); + } + + for (var i = 0; i < foldData.length; i++) { + var foldLine = foldData[i]; + if (endRow == foldLine.start.row) { + foldLine.addFold(fold); + added = true; + break; + } else if (startRow == foldLine.end.row) { + foldLine.addFold(fold); + added = true; + if (!fold.sameRow) { + // Check if we might have to merge two FoldLines. + var foldLineNext = foldData[i + 1]; + if (foldLineNext && foldLineNext.start.row == endRow) { + // We need to merge! + foldLine.merge(foldLineNext); + break; + } + } + break; + } else if (endRow <= foldLine.start.row) { + break; + } + } + + if (!added) + foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold)); + + if (this.$useWrapMode) + this.$updateWrapData(foldLine.start.row, foldLine.start.row); + else + this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row); + + // Notify that fold data has changed. + this.$modified = true; + this._signal("changeFold", { data: fold, action: "add" }); + + return fold; + }; + + this.addFolds = function(folds) { + folds.forEach(function(fold) { + this.addFold(fold); + }, this); + }; + + this.removeFold = function(fold) { + var foldLine = fold.foldLine; + var startRow = foldLine.start.row; + var endRow = foldLine.end.row; + + var foldLines = this.$foldData; + var folds = foldLine.folds; + // Simple case where there is only one fold in the FoldLine such that + // the entire fold line can get removed directly. + if (folds.length == 1) { + foldLines.splice(foldLines.indexOf(foldLine), 1); + } else + // If the fold is the last fold of the foldLine, just remove it. + if (foldLine.range.isEnd(fold.end.row, fold.end.column)) { + folds.pop(); + foldLine.end.row = folds[folds.length - 1].end.row; + foldLine.end.column = folds[folds.length - 1].end.column; + } else + // If the fold is the first fold of the foldLine, just remove it. + if (foldLine.range.isStart(fold.start.row, fold.start.column)) { + folds.shift(); + foldLine.start.row = folds[0].start.row; + foldLine.start.column = folds[0].start.column; + } else + // We know there are more then 2 folds and the fold is not at the edge. + // This means, the fold is somewhere in between. + // + // If the fold is in one row, we just can remove it. + if (fold.sameRow) { + folds.splice(folds.indexOf(fold), 1); + } else + // The fold goes over more then one row. This means remvoing this fold + // will cause the fold line to get splitted up. newFoldLine is the second part + { + var newFoldLine = foldLine.split(fold.start.row, fold.start.column); + folds = newFoldLine.folds; + folds.shift(); + newFoldLine.start.row = folds[0].start.row; + newFoldLine.start.column = folds[0].start.column; + } + + if (!this.$updating) { + if (this.$useWrapMode) + this.$updateWrapData(startRow, endRow); + else + this.$updateRowLengthCache(startRow, endRow); + } + + // Notify that fold data has changed. + this.$modified = true; + this._signal("changeFold", { data: fold, action: "remove" }); + }; + + this.removeFolds = function(folds) { + // We need to clone the folds array passed in as it might be the folds + // array of a fold line and as we call this.removeFold(fold), folds + // are removed from folds and changes the current index. + var cloneFolds = []; + for (var i = 0; i < folds.length; i++) { + cloneFolds.push(folds[i]); + } + + cloneFolds.forEach(function(fold) { + this.removeFold(fold); + }, this); + this.$modified = true; + }; + + this.expandFold = function(fold) { + this.removeFold(fold); + fold.subFolds.forEach(function(subFold) { + fold.restoreRange(subFold); + this.addFold(subFold); + }, this); + if (fold.collapseChildren > 0) { + this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1); + } + fold.subFolds = []; + }; + + this.expandFolds = function(folds) { + folds.forEach(function(fold) { + this.expandFold(fold); + }, this); + }; + + this.unfold = function(location, expandInner) { + var range, folds; + if (location == null) { + range = new Range(0, 0, this.getLength(), 0); + expandInner = true; + } else if (typeof location == "number") + range = new Range(location, 0, location, this.getLine(location).length); + else if ("row" in location) + range = Range.fromPoints(location, location); + else + range = location; + + folds = this.getFoldsInRangeList(range); + if (expandInner) { + this.removeFolds(folds); + } else { + var subFolds = folds; + // TODO: might be better to remove and add folds in one go instead of using + // expandFolds several times. + while (subFolds.length) { + this.expandFolds(subFolds); + subFolds = this.getFoldsInRangeList(range); + } + } + if (folds.length) + return folds; + }; + + /* + * Checks if a given documentRow is folded. This is true if there are some + * folded parts such that some parts of the line is still visible. + **/ + this.isRowFolded = function(docRow, startFoldRow) { + return !!this.getFoldLine(docRow, startFoldRow); + }; + + this.getRowFoldEnd = function(docRow, startFoldRow) { + var foldLine = this.getFoldLine(docRow, startFoldRow); + return foldLine ? foldLine.end.row : docRow; + }; + + this.getRowFoldStart = function(docRow, startFoldRow) { + var foldLine = this.getFoldLine(docRow, startFoldRow); + return foldLine ? foldLine.start.row : docRow; + }; + + this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) { + if (startRow == null) + startRow = foldLine.start.row; + if (startColumn == null) + startColumn = 0; + 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; + var textLine = ""; + + foldLine.walk(function(placeholder, row, column, lastColumn) { + if (row < startRow) + return; + if (row == startRow) { + if (column < startColumn) + return; + lastColumn = Math.max(startColumn, lastColumn); + } + + if (placeholder != null) { + textLine += placeholder; + } else { + textLine += doc.getLine(row).substring(lastColumn, column); + } + }, endRow, endColumn); + return textLine; + }; + + this.getDisplayLine = function(row, endColumn, startRow, startColumn) { + var foldLine = this.getFoldLine(row); + + if (!foldLine) { + var line; + line = this.doc.getLine(row); + return line.substring(startColumn || 0, endColumn || line.length); + } else { + return this.getFoldDisplayLine( + foldLine, row, endColumn, startRow, startColumn); + } + }; + + this.$cloneFoldData = function() { + var fd = []; + fd = this.$foldData.map(function(foldLine) { + var folds = foldLine.folds.map(function(fold) { + return fold.clone(); + }); + return new FoldLine(fd, folds); + }); + + return fd; + }; + + this.toggleFold = function(tryToUnfold) { + var selection = this.selection; + var range = selection.getRange(); + var fold; + var bracketPos; + + if (range.isEmpty()) { + var cursor = range.start; + fold = this.getFoldAt(cursor.row, cursor.column); + + if (fold) { + this.expandFold(fold); + return; + } else if (bracketPos = this.findMatchingBracket(cursor)) { + if (range.comparePoint(bracketPos) == 1) { + range.end = bracketPos; + } else { + range.start = bracketPos; + range.start.column++; + range.end.column--; + } + } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) { + if (range.comparePoint(bracketPos) == 1) + range.end = bracketPos; + else + range.start = bracketPos; + + range.start.column++; + } else { + range = this.getCommentFoldRange(cursor.row, cursor.column) || range; + } + } else { + var folds = this.getFoldsInRange(range); + if (tryToUnfold && folds.length) { + this.expandFolds(folds); + return; + } else if (folds.length == 1 ) { + fold = folds[0]; + } + } + + if (!fold) + fold = this.getFoldAt(range.start.row, range.start.column); + + if (fold && fold.range.toString() == range.toString()) { + this.expandFold(fold); + return; + } + + var placeholder = "..."; + if (!range.isMultiLine()) { + placeholder = this.getTextRange(range); + if (placeholder.length < 4) + return; + placeholder = placeholder.trim().substring(0, 2) + ".."; + } + + this.addFold(placeholder, range); + }; + + this.getCommentFoldRange = function(row, column, dir) { + var iterator = new TokenIterator(this, row, column); + var token = iterator.getCurrentToken(); + var type = token.type; + if (token && /^comment|string/.test(type)) { + type = type.match(/comment|string/)[0]; + if (type == "comment") + type += "|doc-start"; + var re = new RegExp(type); + var range = new Range(); + if (dir != 1) { + do { + token = iterator.stepBackward(); + } while (token && re.test(token.type)); + iterator.stepForward(); + } + + range.start.row = iterator.getCurrentTokenRow(); + range.start.column = iterator.getCurrentTokenColumn() + 2; + + iterator = new TokenIterator(this, row, column); + + if (dir != -1) { + var lastRow = -1; + do { + token = iterator.stepForward(); + if (lastRow == -1) { + var state = this.getState(iterator.$row); + if (!re.test(state)) + lastRow = iterator.$row; + } else if (iterator.$row > lastRow) { + break; + } + } while (token && re.test(token.type)); + token = iterator.stepBackward(); + } else + token = iterator.getCurrentToken(); + + range.end.row = iterator.getCurrentTokenRow(); + range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2; + return range; + } + }; + + this.foldAll = function(startRow, endRow, depth) { + if (depth == undefined) + depth = 100000; // JSON.stringify doesn't hanle Infinity + var foldWidgets = this.foldWidgets; + if (!foldWidgets) + return; // mode doesn't support folding + endRow = endRow || this.getLength(); + startRow = startRow || 0; + for (var row = startRow; row < endRow; row++) { + if (foldWidgets[row] == null) + foldWidgets[row] = this.getFoldWidget(row); + if (foldWidgets[row] != "start") + continue; + + var range = this.getFoldWidgetRange(row); + // sometimes range can be incompatible with existing fold + // TODO change addFold to return null istead of throwing + if (range && range.isMultiLine() + && range.end.row <= endRow + && range.start.row >= startRow + ) { + row = range.end.row; + try { + // addFold can change the range + var fold = this.addFold("...", range); + if (fold) + fold.collapseChildren = depth; + } catch(e) {} + } + } + }; + + // structured folding + this.$foldStyles = { + "manual": 1, + "markbegin": 1, + "markbeginend": 1 + }; + this.$foldStyle = "markbegin"; + this.setFoldStyle = function(style) { + if (!this.$foldStyles[style]) + throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]"); + + if (this.$foldStyle == style) + return; + + this.$foldStyle = style; + + if (style == "manual") + this.unfold(); + + // reset folding + var mode = this.$foldMode; + this.$setFolding(null); + this.$setFolding(mode); + }; + + this.$setFolding = function(foldMode) { + if (this.$foldMode == foldMode) + return; + + this.$foldMode = foldMode; + + this.off('change', this.$updateFoldWidgets); + this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets); + this._signal("changeAnnotation"); + + if (!foldMode || this.$foldStyle == "manual") { + this.foldWidgets = null; + return; + } + + this.foldWidgets = []; + this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle); + 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) { + var fw = this.foldWidgets; + if (!fw || (ignoreCurrent && fw[row])) + return {}; + + var i = row - 1, firstRange; + while (i >= 0) { + var c = fw[i]; + if (c == null) + c = fw[i] = this.getFoldWidget(i); + + if (c == "start") { + var range = this.getFoldWidgetRange(i); + if (!firstRange) + firstRange = range; + if (range && range.end.row >= row) + break; + } + i--; + } + + return { + range: i !== -1 && range, + firstRange: firstRange + }; + }; + + this.onFoldWidgetClick = function(row, e) { + e = e.domEvent; + var options = { + children: e.shiftKey, + all: e.ctrlKey || e.metaKey, + siblings: e.altKey + }; + + var range = this.$toggleFoldWidget(row, options); + if (!range) { + var el = (e.target || e.srcElement); + if (el && /ace_fold-widget/.test(el.className)) + el.className += " ace_invalid"; + } + }; + + this.$toggleFoldWidget = function(row, options) { + if (!this.getFoldWidget) + return; + var type = this.getFoldWidget(row); + var line = this.getLine(row); + + var dir = type === "end" ? -1 : 1; + var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir); + + if (fold) { + if (options.children || options.all) + this.removeFold(fold); + else + this.expandFold(fold); + return fold; + } + + var range = this.getFoldWidgetRange(row, true); + // sometimes singleline folds can be missed by the code above + if (range && !range.isMultiLine()) { + fold = this.getFoldAt(range.start.row, range.start.column, 1); + if (fold && range.isEqual(fold.range)) { + this.removeFold(fold); + return fold; + } + } + + if (options.siblings) { + var data = this.getParentFoldRangeData(row); + if (data.range) { + var startRow = data.range.start.row + 1; + var endRow = data.range.end.row; + } + this.foldAll(startRow, endRow, options.all ? 10000 : 0); + } else if (options.children) { + endRow = range ? range.end.row : this.getLength(); + this.foldAll(row + 1, endRow, options.all ? 10000 : 0); + } else if (range) { + if (options.all) + range.collapseChildren = 10000; + this.addFold("...", range); + } + + return range; + }; + + + + this.toggleFoldWidget = function(toggleParent) { + var row = this.selection.getCursor().row; + row = this.getRowFoldStart(row); + var range = this.$toggleFoldWidget(row, {}); + + if (range) + return; + // handle toggleParent + var data = this.getParentFoldRangeData(row, true); + range = data.range || data.firstRange; + + if (range) { + row = range.start.row; + var fold = this.getFoldAt(row, this.getLine(row).length, 1); + + if (fold) { + this.removeFold(fold); + } else { + this.addFold("...", range); + } + } + }; + + 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 == 'remove') { + this.foldWidgets.splice(firstRow, len + 1, null); + } else { + var args = Array(len + 1); + args.unshift(firstRow, 1); + 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; + +}); diff --git a/public/lib/ace/edit_session_test.js b/public/lib/ace/edit_session_test.js new file mode 100644 index 0000000..0717c3c --- /dev/null +++ b/public/lib/ace/edit_session_test.js @@ -0,0 +1,1087 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("./test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +var lang = require("./lib/lang"); +var EditSession = require("./edit_session").EditSession; +var Editor = require("./editor").Editor; +var UndoManager = require("./undomanager").UndoManager; +var MockRenderer = require("./test/mockrenderer").MockRenderer; +var Range = require("./range").Range; +var assert = require("./test/assertions"); +var JavaScriptMode = require("./mode/javascript").Mode; + +function createFoldTestSession() { + var lines = [ + "function foo(items) {", + " for (var i=0; i>", [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() { + var session = new EditSession(["12"]); + session.setTabSize(4); + assert.equal(session.getScreenWidth(), 2); + + session.doc.insertMergedLines({row: 0, column: Infinity}, ['', '']); + session.doc.insertFullLines(1, ["123"]); + assert.equal(session.getScreenWidth(), 3); + + session.doc.insertMergedLines({row: 0, column: Infinity}, ['', '']); + session.doc.insertFullLines(1, ["\t\t"]); + + assert.equal(session.getScreenWidth(), 8); + + session.setTabSize(2); + assert.equal(session.getScreenWidth(), 4); + }, + + "test getDisplayString": function() { + var session = new EditSession(["12"]); + session.setTabSize(4); + + assert.equal(session.$getDisplayTokens("\t").length, 4); + assert.equal(session.$getDisplayTokens("abc").length, 3); + assert.equal(session.$getDisplayTokens("abc\t").length, 4); + }, + + "test issue 83": function() { + var session = new EditSession(""); + var editor = new Editor(new MockRenderer(), session); + var document = session.getDocument(); + + session.setUseWrapMode(true); + + document.insertFullLines(0, ["a", "b"]); + document.insertFullLines(2, ["c", "d"]); + document.removeFullLines(1, 2); + }, + + "test wrapMode init has to create wrapData array": function() { + var session = new EditSession("foo bar\nfoo bar"); + var editor = new Editor(new MockRenderer(), session); + var document = session.getDocument(); + + session.setUseWrapMode(true); + session.setWrapLimitRange(3, 3); + session.adjustWrapLimit(80); + + // Test if wrapData is there and was computed. + assert.equal(session.$wrapData.length, 2); + assert.equal(session.$wrapData[0].length, 1); + assert.equal(session.$wrapData[1].length, 1); + }, + + "test first line blank with wrap": function() { + var session = new EditSession("\nfoo"); + session.setUseWrapMode(true); + assert.equal(session.doc.getValue(), ["", "foo"].join("\n")); + }, + + "test first line blank with wrap 2" : function() { + var session = new EditSession(""); + session.setUseWrapMode(true); + session.setValue("\nfoo"); + + assert.equal(session.doc.getValue(), ["", "foo"].join("\n")); + }, + + "test fold getFoldDisplayLine": function() { + var session = createFoldTestSession(); + function assertDisplayLine(foldLine, str) { + var line = session.getLine(foldLine.end.row); + var displayLine = + session.getFoldDisplayLine(foldLine, foldLine.end.row, line.length); + assert.equal(displayLine, str); + } + + assertDisplayLine(session.$foldData[0], "function foo(args...) {"); + assertDisplayLine(session.$foldData[1], " for (vfoo...ert(items[bar...\"juhu\");"); + }, + + "test foldLine idxToPosition": function() { + var session = createFoldTestSession(); + + function assertIdx2Pos(foldLineIdx, idx, row, column) { + var foldLine = session.$foldData[foldLineIdx]; + assert.position(foldLine.idxToPosition(idx), row, column); + } + +// "function foo(items) {", +// " for (var i=0; iThe cursor in this paragraph text will be offset by 1 row.

", + "

Everything after this will be offset as well due to the folds in the row before too.

" + ].join("\n")); + session.addFold('...', new Range(0, 8, 0, 42)); + session.addFold('...', new Range(1, 8, 1, 42)); + session.addFold('...', new Range(3, 7, 3, 51)); + session.setOption("wrap", 40); + session.remove(new Range(0,0, 2, 5)); + // needed because adjustWrapLimit is called async from renderer + session.adjustWrapLimit(80); + + assert.equal(session.$wrapData + "", [[], [], [40, 76]] + ""); + }, + + "test add fold": function() { + var session = createFoldTestSession(); + var fold; + + function tryAddFold(placeholder, range, shouldFail) { + var fail = false; + try { + fold = session.addFold(placeholder, range); + } catch (e) { + fail = true; + } + if (fail != shouldFail) { + throw new Error("Expected to get an exception"); + } + } + + tryAddFold("foo", new Range(0, 13, 0, 17), false); + tryAddFold("foo", new Range(0, 14, 0, 18), true); + tryAddFold("foo", new Range(0, 13, 0, 18), false); + assert.equal(session.$foldData[0].folds.length, 1); + + tryAddFold("f", new Range(0, 13, 0, 18), false); + tryAddFold("foo", new Range(0, 18, 0, 21), false); + assert.equal(session.$foldData[0].folds.length, 2); + session.removeFold(fold); + + tryAddFold("foo", new Range(0, 18, 0, 22), false); + tryAddFold("foo", new Range(0, 18, 0, 19), true); + tryAddFold("foo", new Range(0, 22, 1, 10), false); + }, + + "test add subfolds": function() { + var session = createFoldTestSession(); + var fold, oldFold; + var foldData = session.$foldData; + + oldFold = foldData[0].folds[0]; + + fold = session.addFold("fold0", new Range(0, 10, 0, 21)); + assert.equal(foldData[0].folds.length, 1); + assert.equal(fold.subFolds.length, 1); + assert.equal(fold.subFolds[0], oldFold); + + session.expandFold(fold); + assert.equal(foldData[0].folds.length, 1); + assert.equal(foldData[0].folds[0], oldFold); + assert.equal(fold.subFolds.length, 0); + + fold = session.addFold("fold0", new Range(0, 13, 2, 10)); + assert.equal(foldData.length, 1); + assert.equal(fold.subFolds.length, 2); + assert.equal(fold.subFolds[0], oldFold); + + session.expandFold(fold); + assert.equal(foldData.length, 2); + assert.equal(foldData[0].folds.length, 1); + assert.equal(foldData[0].folds[0], oldFold); + assert.equal(fold.subFolds.length, 0); + + session.unfold(null, true); + fold = session.addFold("fold0", new Range(0, 0, 0, 21)); + session.addFold("fold0", new Range(0, 1, 0, 5)); + session.addFold("fold0", new Range(0, 6, 0, 8)); + assert.equal(fold.subFolds.length, 2); + }, + + "test row cache": function() { + var session = createFoldTestSession(); + + session.screenToDocumentPosition(2,3); + assertArray(session.$docRowCache, [1,3]); + assertArray(session.$screenRowCache, [1,2]); + + session.screenToDocumentPosition(5,3); + assertArray(session.$docRowCache, [1,3,4]); + assertArray(session.$screenRowCache, [1,2,3]); + + session.screenToDocumentPosition(0,3); + assertArray(session.$docRowCache, [1,3,4]); + assertArray(session.$screenRowCache, [1,2,3]); + + var pos = session.screenToDocumentPosition(0,0); + assert.equal(pos.row, 0); + assertArray(session.$docRowCache, [1,3,4]); + assertArray(session.$screenRowCache, [1,2,3]); + + session.screenToDocumentPosition(1,0); + assertArray(session.$docRowCache, [1,3,4]); + assertArray(session.$screenRowCache, [1,2,3]); + + session.$resetRowCache(); + assertArray(session.$docRowCache, []); + assertArray(session.$screenRowCache, []); + + session.screenToDocumentPosition(1,3); + assertArray(session.$docRowCache, [1]); + assertArray(session.$screenRowCache, [1]); + + session.screenToDocumentPosition(5,3); + assertArray(session.$docRowCache, [1,3,4]); + assertArray(session.$screenRowCache, [1,2,3]); + + session = new EditSession(new Array(30).join("\n")); + session.documentToScreenPosition(2,0); + session.documentToScreenPosition(2,0); + assertArray(session.$docRowCache, [1,2]); + assertArray(session.$screenRowCache, [1,2]); + }, + + "test annotations": function() { + var session = new EditSession([]), + annotation = {row: 0, type: 'info', text: "This is a test."}; + + session.clearAnnotations(); + assertArray(session.getAnnotations(), []); + session.setAnnotations([annotation]); + assertArray(session.getAnnotations(), [annotation]); + }, + + "test: mode loading" : function(next) { + if (!require.undef) { + console.log("Skipping test: This test only runs in the browser"); + next(); + return; + } + var session = new EditSession([]); + session.setMode("ace/mode/javascript"); + assert.equal(session.$modeid, "ace/mode/javascript"); + session.on("changeMode", function() { + assert.equal(session.$modeid, "ace/mode/javascript"); + }); + session.setMode("ace/mode/sh", function(mode) { + assert.ok(!mode); + }); + setTimeout(function() { + session.setMode("ace/mode/javascript", function(mode) { + session.setMode("ace/mode/javascript"); + assert.equal(session.$modeid, "ace/mode/javascript"); + next(); + }); + }, 0); + } +}; +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/editor.js b/public/lib/ace/editor.js new file mode 100644 index 0000000..a015bcb --- /dev/null +++ b/public/lib/ace/editor.js @@ -0,0 +1,2705 @@ +/* ***** 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"; + +require("./lib/fixoldbrowsers"); + +var oop = require("./lib/oop"); +var dom = require("./lib/dom"); +var lang = require("./lib/lang"); +var useragent = require("./lib/useragent"); +var TextInput = require("./keyboard/textinput").TextInput; +var MouseHandler = require("./mouse/mouse_handler").MouseHandler; +var FoldHandler = require("./mouse/fold_handler").FoldHandler; +var KeyBinding = require("./keyboard/keybinding").KeyBinding; +var EditSession = require("./edit_session").EditSession; +var Search = require("./search").Search; +var Range = require("./range").Range; +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var CommandManager = require("./commands/command_manager").CommandManager; +var defaultCommands = require("./commands/default_commands").commands; +var config = require("./config"); +var TokenIterator = require("./token_iterator").TokenIterator; + +/** + * The main entry point into the Ace functionality. + * + * The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen. + * + * Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them. + * @class Editor + **/ + +/** + * Creates a new `Editor` object. + * + * @param {VirtualRenderer} renderer Associated `VirtualRenderer` that draws everything + * @param {EditSession} session The `EditSession` to refer to + * + * + * @constructor + **/ +var Editor = function(renderer, session) { + var container = renderer.getContainerElement(); + this.container = container; + this.renderer = renderer; + this.id = "editor" + (++Editor.$uid); + + this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands); + if (typeof document == "object") { + this.textInput = new TextInput(renderer.getTextAreaContainer(), this); + this.renderer.textarea = this.textInput.getElement(); + // TODO detect touch event support + this.$mouseHandler = new MouseHandler(this); + new FoldHandler(this); + } + + this.keyBinding = new KeyBinding(this); + + this.$blockScrolling = 0; + this.$search = new Search().set({ + wrap: true + }); + + this.$historyTracker = this.$historyTracker.bind(this); + this.commands.on("exec", this.$historyTracker); + + this.$initOperationListeners(); + + this._$emitInputEvent = lang.delayedCall(function() { + this._signal("input", {}); + if (this.session && this.session.bgTokenizer) + this.session.bgTokenizer.scheduleStart(); + }.bind(this)); + + this.on("change", function(_, _self) { + _self._$emitInputEvent.schedule(31); + }); + + this.setSession(session || new EditSession("")); + config.resetOptions(this); + config._signal("editor", this); +}; + +Editor.$uid = 0; + +(function(){ + + oop.implement(this, EventEmitter); + + this.$initOperationListeners = function() { + function last(a) {return a[a.length - 1];} + + this.selections = []; + 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)); + + this.on("change", function() { + this.curOp || this.startOperation(); + this.curOp.docChanged = true; + }.bind(this), true); + + this.on("changeSelection", function() { + this.curOp || this.startOperation(); + this.curOp.selectionChanged = true; + }.bind(this), true); + }; + + this.curOp = null; + this.prevOp = {}; + this.startOperation = function(commadEvent) { + if (this.curOp) { + if (!commadEvent || this.curOp.command) + return; + this.prevOp = this.curOp; + } + if (!commadEvent) { + this.previousCommand = null; + commadEvent = {}; + } + + this.$opResetTimer.schedule(); + this.curOp = { + command: commadEvent.command || {}, + args: commadEvent.args, + scrollTop: this.renderer.scrollTop + }; + if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined) + this.$blockScrolling++; + }; + + 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.name && this.$blockScrolling > 0) + this.$blockScrolling--; + 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; + case "animate": + case "cursor": + this.renderer.scrollCursorIntoView(); + break; + case "selectionPart": + var range = this.selection.getRange(); + var config = this.renderer.layerConfig; + if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) { + this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead); + } + break; + default: + break; + } + if (scrollIntoView == "animate") + this.renderer.animateScrolling(this.curOp.scrollTop); + } + + this.prevOp = this.curOp; + this.curOp = null; + } + }; + + // 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 = this.$mergeableCommands; + // previous command was the same + var shouldMerge = prev.command && (e.command.name == prev.command.name); + if (e.command.name == "insertstring") { + var text = e.args; + if (this.mergeNextCommand === undefined) + this.mergeNextCommand = true; + + shouldMerge = shouldMerge + && this.mergeNextCommand // previous command allows to coalesce with + && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type + + this.mergeNextCommand = true; + } else { + shouldMerge = shouldMerge + && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable + } + + if ( + this.$mergeUndoDeltas != "always" + && Date.now() - this.sequenceStartTime > 2000 + ) { + shouldMerge = false; // the sequence is too long + } + + if (shouldMerge) + this.session.mergeUndoDeltas = true; + else if (mergeableCommands.indexOf(e.command.name) !== -1) + this.sequenceStartTime = Date.now(); + }; + + /** + * Sets a new key handler, such as "vim" or "windows". + * @param {String} keyboardHandler The new key handler + * + **/ + 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(); + } + }; + + /** + * Returns the keyboard handler, such as "vim" or "windows". + * + * @returns {String} + * + **/ + this.getKeyboardHandler = function() { + return this.keyBinding.getKeyboardHandler(); + }; + + + /** + * Emitted whenever the [[EditSession]] changes. + * @event changeSession + * @param {Object} e An object with two properties, `oldSession` and `session`, that represent the old and new [[EditSession]]s. + * + **/ + /** + * Sets a new editsession to use. This method also emits the `'changeSession'` event. + * @param {EditSession} session The new session to use + * + **/ + 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) { + this.session.off("change", this.$onDocumentChange); + this.session.off("changeMode", this.$onChangeMode); + this.session.off("tokenizerUpdate", this.$onTokenizerUpdate); + this.session.off("changeTabSize", this.$onChangeTabSize); + this.session.off("changeWrapLimit", this.$onChangeWrapLimit); + this.session.off("changeWrapMode", this.$onChangeWrapMode); + this.session.off("changeFold", this.$onChangeFold); + this.session.off("changeFrontMarker", this.$onChangeFrontMarker); + this.session.off("changeBackMarker", this.$onChangeBackMarker); + this.session.off("changeBreakpoint", this.$onChangeBreakpoint); + this.session.off("changeAnnotation", this.$onChangeAnnotation); + this.session.off("changeOverwrite", this.$onCursorChange); + this.session.off("changeScrollTop", this.$onScrollTopChange); + this.session.off("changeScrollLeft", this.$onScrollLeftChange); + + var selection = this.session.getSelection(); + selection.off("changeCursor", this.$onCursorChange); + selection.off("changeSelection", this.$onSelectionChange); + } + + this.session = session; + if (session) { + this.$onDocumentChange = this.onDocumentChange.bind(this); + session.on("change", this.$onDocumentChange); + this.renderer.setSession(session); + + this.$onChangeMode = this.onChangeMode.bind(this); + session.on("changeMode", this.$onChangeMode); + + this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this); + session.on("tokenizerUpdate", this.$onTokenizerUpdate); + + this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer); + session.on("changeTabSize", this.$onChangeTabSize); + + this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this); + session.on("changeWrapLimit", this.$onChangeWrapLimit); + + this.$onChangeWrapMode = this.onChangeWrapMode.bind(this); + session.on("changeWrapMode", this.$onChangeWrapMode); + + this.$onChangeFold = this.onChangeFold.bind(this); + session.on("changeFold", this.$onChangeFold); + + this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this); + this.session.on("changeFrontMarker", this.$onChangeFrontMarker); + + this.$onChangeBackMarker = this.onChangeBackMarker.bind(this); + this.session.on("changeBackMarker", this.$onChangeBackMarker); + + this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this); + this.session.on("changeBreakpoint", this.$onChangeBreakpoint); + + this.$onChangeAnnotation = this.onChangeAnnotation.bind(this); + this.session.on("changeAnnotation", this.$onChangeAnnotation); + + this.$onCursorChange = this.onCursorChange.bind(this); + this.session.on("changeOverwrite", this.$onCursorChange); + + this.$onScrollTopChange = this.onScrollTopChange.bind(this); + this.session.on("changeScrollTop", this.$onScrollTopChange); + + this.$onScrollLeftChange = this.onScrollLeftChange.bind(this); + this.session.on("changeScrollLeft", this.$onScrollLeftChange); + + this.selection = session.getSelection(); + this.selection.on("changeCursor", this.$onCursorChange); + + this.$onSelectionChange = this.onSelectionChange.bind(this); + this.selection.on("changeSelection", this.$onSelectionChange); + + this.onChangeMode(); + + this.$blockScrolling += 1; + this.onCursorChange(); + this.$blockScrolling -= 1; + + this.onScrollTopChange(); + this.onScrollLeftChange(); + this.onSelectionChange(); + this.onChangeFrontMarker(); + this.onChangeBackMarker(); + this.onChangeBreakpoint(); + this.onChangeAnnotation(); + this.session.getUseWrapMode() && this.renderer.adjustWrapLimit(); + this.renderer.updateFull(); + } else { + this.selection = null; + this.renderer.setSession(session); + } + + this._signal("changeSession", { + session: session, + oldSession: oldSession + }); + + this.curOp = null; + + oldSession && oldSession._signal("changeEditor", {oldEditor: this}); + session && session._signal("changeEditor", {editor: this}); + + if (session && session.bgTokenizer) + session.bgTokenizer.scheduleStart(); + }; + + /** + * Returns the current session being used. + * @returns {EditSession} + **/ + this.getSession = function() { + return this.session; + }; + + /** + * Sets the current document to `val`. + * @param {String} val The new value to set for the document + * @param {Number} cursorPos Where to set the new value. `undefined` or 0 is selectAll, -1 is at the document start, and 1 is at the end + * + * @returns {String} The current document value + * @related Document.setValue + **/ + this.setValue = function(val, cursorPos) { + this.session.doc.setValue(val); + + if (!cursorPos) + this.selectAll(); + else if (cursorPos == 1) + this.navigateFileEnd(); + else if (cursorPos == -1) + this.navigateFileStart(); + + return val; + }; + + /** + * Returns the current session's content. + * + * @returns {String} + * @related EditSession.getValue + **/ + this.getValue = function() { + return this.session.getValue(); + }; + + /** + * + * Returns the currently highlighted selection. + * @returns {Selection} The selection object + **/ + this.getSelection = function() { + return this.selection; + }; + + /** + * {:VirtualRenderer.onResize} + * @param {Boolean} force If `true`, recomputes the size, even if the height and width haven't changed + * + * + * @related VirtualRenderer.onResize + **/ + this.resize = function(force) { + this.renderer.onResize(force); + }; + + /** + * {:VirtualRenderer.setTheme} + * @param {String} theme The path to a theme + * @param {Function} cb optional callback called when theme is loaded + **/ + this.setTheme = function(theme, cb) { + this.renderer.setTheme(theme, cb); + }; + + /** + * {:VirtualRenderer.getTheme} + * + * @returns {String} The set theme + * @related VirtualRenderer.getTheme + **/ + this.getTheme = function() { + return this.renderer.getTheme(); + }; + + /** + * {:VirtualRenderer.setStyle} + * @param {String} style A class name + * + * + * @related VirtualRenderer.setStyle + **/ + this.setStyle = function(style) { + this.renderer.setStyle(style); + }; + + /** + * {:VirtualRenderer.unsetStyle} + * @related VirtualRenderer.unsetStyle + **/ + this.unsetStyle = function(style) { + this.renderer.unsetStyle(style); + }; + + /** + * Gets the current font size of the editor text. + */ + this.getFontSize = function () { + return this.getOption("fontSize") || + dom.computedStyle(this.container, "fontSize"); + }; + + /** + * Set a new font size (in pixels) for the editor text. + * @param {String} size A font size ( _e.g._ "12px") + * + * + **/ + this.setFontSize = function(size) { + this.setOption("fontSize", size); + }; + + this.$highlightBrackets = function() { + if (this.session.$bracketHighlight) { + this.session.removeMarker(this.session.$bracketHighlight); + this.session.$bracketHighlight = null; + } + + if (this.$highlightPending) { + return; + } + + // perform highlight async to not block the browser during navigation + var self = this; + this.$highlightPending = true; + setTimeout(function() { + self.$highlightPending = false; + 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 (session.$mode.getMatching) { + var range = session.$mode.getMatching(self.session); + } + if (range) + session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text"); + }, 50); + }; + + // todo: move to mode.getMatching + this.$highlightTags = function() { + if (this.$highlightTagPending) + return; + + // perform highlight async to not block the browser during navigation + var self = this; + this.$highlightTagPending = true; + 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 || !/\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(); + + if (prevToken.value == '<'){ + //find closing tag + do { + prevToken = token; + token = iterator.stepForward(); + + if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) { + if (prevToken.value === '<'){ + depth++; + } else if (prevToken.value === '= 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 === '<') { + depth++; + } else if (prevToken.value === ' 1)) + highlight = false; + } + + if (session.$highlightLineMarker && !highlight) { + session.removeMarker(session.$highlightLineMarker.id); + session.$highlightLineMarker = null; + } else if (!session.$highlightLineMarker && highlight) { + var range = new Range(highlight.row, highlight.column, highlight.row, Infinity); + range.id = session.addMarker(range, "ace_active-line", "screenLine"); + session.$highlightLineMarker = range; + } else if (highlight) { + session.$highlightLineMarker.start.row = highlight.row; + session.$highlightLineMarker.end.row = highlight.row; + session.$highlightLineMarker.start.column = highlight.column; + session._signal("changeBackMarker"); + } + }; + + this.onSelectionChange = function(e) { + var session = this.session; + + if (session.$selectionMarker) { + session.removeMarker(session.$selectionMarker); + } + session.$selectionMarker = null; + + if (!this.selection.isEmpty()) { + var range = this.selection.getRange(); + var style = this.getSelectionStyle(); + session.$selectionMarker = session.addMarker(range, "ace_selection", style); + } else { + this.$updateHighlightActiveLine(); + } + + var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp(); + this.session.highlight(re); + + this._signal("changeSelection"); + }; + + this.$getSelectionHighLightRegexp = function() { + var session = this.session; + + var selection = this.getSelectionRange(); + if (selection.isEmpty() || selection.isMultiLine()) + return; + + var startOuter = selection.start.column - 1; + var endOuter = selection.end.column + 1; + var line = session.getLine(selection.start.row); + var lineCols = line.length; + var needle = line.substring(Math.max(startOuter, 0), + Math.min(endOuter, lineCols)); + + // Make sure the outer characters are not part of the word. + if ((startOuter >= 0 && /^[\w\d]/.test(needle)) || + (endOuter <= lineCols && /[\w\d]$/.test(needle))) + return; + + needle = line.substring(selection.start.column, selection.end.column); + if (!/^[\w\d]+$/.test(needle)) + return; + + var re = this.$search.$assembleRegExp({ + wholeWord: true, + caseSensitive: true, + needle: needle + }); + + return re; + }; + + + this.onChangeFrontMarker = function() { + this.renderer.updateFrontMarkers(); + }; + + this.onChangeBackMarker = function() { + this.renderer.updateBackMarkers(); + }; + + + this.onChangeBreakpoint = function() { + this.renderer.updateBreakpoints(); + }; + + this.onChangeAnnotation = function() { + this.renderer.setAnnotations(this.session.getAnnotations()); + }; + + + this.onChangeMode = function(e) { + this.renderer.updateText(); + this._emit("changeMode", e); + }; + + + this.onChangeWrapLimit = function() { + this.renderer.updateFull(); + }; + + this.onChangeWrapMode = function() { + this.renderer.onResize(true); + }; + + + this.onChangeFold = function() { + // Update the active line marker as due to folding changes the current + // line range on the screen might have changed. + this.$updateHighlightActiveLine(); + // TODO: This might be too much updating. Okay for now. + this.renderer.updateFull(); + }; + + + /** + * Returns the string of text currently highlighted. + * @returns {String} + **/ + this.getSelectedText = function() { + return this.session.getTextRange(this.getSelectionRange()); + }; + + /** + * Emitted when text is copied. + * @event copy + * @param {String} text The copied text + * + **/ + /** + * Returns the string of text currently highlighted. + * @returns {String} + * @deprecated Use getSelectedText instead. + **/ + this.getCopyText = function() { + var text = this.getSelectedText(); + this._signal("copy", text); + return text; + }; + + /** + * Called whenever a text "copy" happens. + **/ + this.onCopy = function() { + this.commands.exec("copy", this); + }; + + /** + * Called whenever a text "cut" happens. + **/ + this.onCut = function() { + this.commands.exec("cut", this); + }; + + /** + * Emitted when text is pasted. + * @event paste + * @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. + * + * + **/ + /** + * Called whenever a text "paste" happens. + * @param {String} text The pasted 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); + 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) { + return this.commands.exec(command, this, args); + }; + + /** + * Inserts `text` into wherever the cursor is pointing. + * @param {String} text The new text to add + * + **/ + this.insert = function(text, pasted) { + var session = this.session; + var mode = session.getMode(); + var cursor = this.getCursorPosition(); + + if (this.getBehavioursEnabled() && !pasted) { + // Get a transform if the current mode wants one. + var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text); + if (transform) { + if (text !== transform.text) { + this.session.mergeUndoDeltas = false; + this.$mergeNextCommand = false; + } + text = transform.text; + + } + } + + if (text == "\t") + text = this.session.getTabString(); + + // remove selected text + if (!this.selection.isEmpty()) { + var range = this.getSelectionRange(); + cursor = this.session.remove(range); + this.clearSelection(); + } + else if (this.session.getOverwrite() && text.indexOf("\n") == -1) { + var range = new Range.fromPoints(cursor, cursor); + range.end.column += text.length; + this.session.remove(range); + } + + if (text == "\n" || text == "\r\n") { + var line = session.getLine(cursor.row); + if (cursor.column > line.search(/\S|$/)) { + var d = line.substr(cursor.column).search(/\S|$/); + session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d); + } + } + this.clearSelection(); + + var start = cursor.column; + var lineState = session.getState(cursor.row); + var line = session.getLine(cursor.row); + var shouldOutdent = mode.checkOutdent(lineState, line, text); + var end = session.insert(cursor, text); + + if (transform && transform.selection) { + if (transform.selection.length == 2) { // Transform relative to the current column + this.selection.setSelectionRange( + new Range(cursor.row, start + transform.selection[0], + cursor.row, start + transform.selection[1])); + } else { // Transform relative to the current row. + this.selection.setSelectionRange( + new Range(cursor.row + transform.selection[0], + transform.selection[1], + cursor.row + transform.selection[2], + transform.selection[3])); + } + } + + if (session.getDocument().isNewLine(text)) { + var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString()); + + session.insert({row: cursor.row+1, column: 0}, lineIndent); + } + if (shouldOutdent) + mode.autoOutdent(lineState, session, cursor.row); + }; + + this.onTextInput = function(text) { + this.keyBinding.onTextInput(text); + }; + + this.onCommandKey = function(e, hashId, keyCode) { + this.keyBinding.onCommandKey(e, hashId, keyCode); + }; + + /** + * Pass in `true` to enable overwrites in your session, or `false` to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emits the `changeOverwrite` event. + * @param {Boolean} overwrite Defines whether or not to set overwrites + * + * + * @related EditSession.setOverwrite + **/ + this.setOverwrite = function(overwrite) { + this.session.setOverwrite(overwrite); + }; + + /** + * Returns `true` if overwrites are enabled; `false` otherwise. + * @returns {Boolean} + * @related EditSession.getOverwrite + **/ + this.getOverwrite = function() { + return this.session.getOverwrite(); + }; + + /** + * Sets the value of overwrite to the opposite of whatever it currently is. + * @related EditSession.toggleOverwrite + **/ + this.toggleOverwrite = function() { + this.session.toggleOverwrite(); + }; + + /** + * Sets how fast the mouse scrolling should do. + * @param {Number} speed A value indicating the new speed (in milliseconds) + **/ + this.setScrollSpeed = function(speed) { + this.setOption("scrollSpeed", speed); + }; + + /** + * Returns the value indicating how fast the mouse scroll speed is (in milliseconds). + * @returns {Number} + **/ + this.getScrollSpeed = function() { + return this.getOption("scrollSpeed"); + }; + + /** + * Sets the delay (in milliseconds) of the mouse drag. + * @param {Number} dragDelay A value indicating the new delay + **/ + this.setDragDelay = function(dragDelay) { + this.setOption("dragDelay", dragDelay); + }; + + /** + * Returns the current mouse drag delay. + * @returns {Number} + **/ + this.getDragDelay = function() { + return this.getOption("dragDelay"); + }; + + /** + * Emitted when the selection style changes, via [[Editor.setSelectionStyle]]. + * @event changeSelectionStyle + * @param {Object} data Contains one property, `data`, which indicates the new selection style + **/ + /** + * Draw selection markers spanning whole line, or only over selected text. Default value is "line" + * @param {String} style The new selection style "line"|"text" + * + **/ + this.setSelectionStyle = function(val) { + this.setOption("selectionStyle", val); + }; + + /** + * Returns the current selection style. + * @returns {String} + **/ + this.getSelectionStyle = function() { + return this.getOption("selectionStyle"); + }; + + /** + * Determines whether or not the current line should be highlighted. + * @param {Boolean} shouldHighlight Set to `true` to highlight the current line + **/ + this.setHighlightActiveLine = function(shouldHighlight) { + this.setOption("highlightActiveLine", shouldHighlight); + }; + /** + * Returns `true` if current lines are always highlighted. + * @return {Boolean} + **/ + this.getHighlightActiveLine = function() { + return this.getOption("highlightActiveLine"); + }; + this.setHighlightGutterLine = function(shouldHighlight) { + this.setOption("highlightGutterLine", shouldHighlight); + }; + + this.getHighlightGutterLine = function() { + return this.getOption("highlightGutterLine"); + }; + + /** + * Determines if the currently selected word should be highlighted. + * @param {Boolean} shouldHighlight Set to `true` to highlight the currently selected word + * + **/ + this.setHighlightSelectedWord = function(shouldHighlight) { + this.setOption("highlightSelectedWord", shouldHighlight); + }; + + /** + * Returns `true` if currently highlighted words are to be highlighted. + * @returns {Boolean} + **/ + this.getHighlightSelectedWord = function() { + return this.$highlightSelectedWord; + }; + + this.setAnimatedScroll = function(shouldAnimate){ + this.renderer.setAnimatedScroll(shouldAnimate); + }; + + this.getAnimatedScroll = function(){ + return this.renderer.getAnimatedScroll(); + }; + + /** + * If `showInvisibles` is set to `true`, invisible characters—like spaces or new lines—are show in the editor. + * @param {Boolean} showInvisibles Specifies whether or not to show invisible characters + * + **/ + this.setShowInvisibles = function(showInvisibles) { + this.renderer.setShowInvisibles(showInvisibles); + }; + + /** + * Returns `true` if invisible characters are being shown. + * @returns {Boolean} + **/ + this.getShowInvisibles = function() { + return this.renderer.getShowInvisibles(); + }; + + this.setDisplayIndentGuides = function(display) { + this.renderer.setDisplayIndentGuides(display); + }; + + this.getDisplayIndentGuides = function() { + return this.renderer.getDisplayIndentGuides(); + }; + + /** + * If `showPrintMargin` is set to `true`, the print margin is shown in the editor. + * @param {Boolean} showPrintMargin Specifies whether or not to show the print margin + * + **/ + this.setShowPrintMargin = function(showPrintMargin) { + this.renderer.setShowPrintMargin(showPrintMargin); + }; + + /** + * Returns `true` if the print margin is being shown. + * @returns {Boolean} + **/ + this.getShowPrintMargin = function() { + return this.renderer.getShowPrintMargin(); + }; + + /** + * Sets the column defining where the print margin should be. + * @param {Number} showPrintMargin Specifies the new print margin + * + **/ + this.setPrintMarginColumn = function(showPrintMargin) { + this.renderer.setPrintMarginColumn(showPrintMargin); + }; + + /** + * Returns the column number of where the print margin is. + * @returns {Number} + **/ + this.getPrintMarginColumn = function() { + return this.renderer.getPrintMarginColumn(); + }; + + /** + * If `readOnly` is true, then the editor is set to read-only mode, and none of the content can change. + * @param {Boolean} readOnly Specifies whether the editor can be modified or not + * + **/ + this.setReadOnly = function(readOnly) { + this.setOption("readOnly", readOnly); + }; + + /** + * Returns `true` if the editor is set to read-only mode. + * @returns {Boolean} + **/ + this.getReadOnly = function() { + return this.getOption("readOnly"); + }; + + /** + * Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef} + * @param {Boolean} enabled Enables or disables behaviors + * + **/ + this.setBehavioursEnabled = function (enabled) { + this.setOption("behavioursEnabled", enabled); + }; + + /** + * Returns `true` if the behaviors are currently enabled. {:BehaviorsDef} + * + * @returns {Boolean} + **/ + this.getBehavioursEnabled = function () { + return this.getOption("behavioursEnabled"); + }; + + /** + * 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. + * @param {Boolean} enabled Enables or disables wrapping behaviors + * + **/ + this.setWrapBehavioursEnabled = function (enabled) { + this.setOption("wrapBehavioursEnabled", enabled); + }; + + /** + * Returns `true` if the wrapping behaviors are currently enabled. + **/ + this.getWrapBehavioursEnabled = function () { + return this.getOption("wrapBehavioursEnabled"); + }; + + /** + * Indicates whether the fold widgets should be shown or not. + * @param {Boolean} show Specifies whether the fold widgets are shown + **/ + this.setShowFoldWidgets = function(show) { + this.setOption("showFoldWidgets", show); + + }; + /** + * Returns `true` if the fold widgets are shown. + * @return {Boolean} + **/ + this.getShowFoldWidgets = function() { + return this.getOption("showFoldWidgets"); + }; + + this.setFadeFoldWidgets = function(fade) { + this.setOption("fadeFoldWidgets", fade); + }; + + this.getFadeFoldWidgets = function() { + return this.getOption("fadeFoldWidgets"); + }; + + /** + * Removes the current selection or one character. + * @param {String} dir The direction of the deletion to occur, either "left" or "right" + * + **/ + this.remove = function(dir) { + if (this.selection.isEmpty()){ + if (dir == "left") + this.selection.selectLeft(); + else + this.selection.selectRight(); + } + + var range = this.getSelectionRange(); + if (this.getBehavioursEnabled()) { + var session = this.session; + var state = session.getState(range.start.row); + var new_range = session.getMode().transformAction(state, 'deletion', this, session, range); + + if (range.end.column === 0) { + var text = session.getTextRange(range); + if (text[text.length - 1] == "\n") { + var line = session.getLine(range.end.row); + if (/^\s+$/.test(line)) { + range.end.column = line.length; + } + } + } + if (new_range) + range = new_range; + } + + this.session.remove(range); + this.clearSelection(); + }; + + /** + * Removes the word directly to the right of the current selection. + **/ + this.removeWordRight = function() { + if (this.selection.isEmpty()) + this.selection.selectWordRight(); + + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + }; + + /** + * Removes the word directly to the left of the current selection. + **/ + this.removeWordLeft = function() { + if (this.selection.isEmpty()) + this.selection.selectWordLeft(); + + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + }; + + /** + * Removes all the words to the left of the current selection, until the start of the line. + **/ + this.removeToLineStart = function() { + if (this.selection.isEmpty()) + this.selection.selectLineStart(); + + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + }; + + /** + * Removes all the words to the right of the current selection, until the end of the line. + **/ + this.removeToLineEnd = function() { + if (this.selection.isEmpty()) + this.selection.selectLineEnd(); + + var range = this.getSelectionRange(); + if (range.start.column == range.end.column && range.start.row == range.end.row) { + range.end.column = 0; + range.end.row++; + } + + this.session.remove(range); + this.clearSelection(); + }; + + /** + * Splits the line at the current selection (by inserting an `'\n'`). + **/ + this.splitLine = function() { + if (!this.selection.isEmpty()) { + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + } + + var cursor = this.getCursorPosition(); + this.insert("\n"); + this.moveCursorToPosition(cursor); + }; + + /** + * Transposes current line. + **/ + this.transposeLetters = function() { + if (!this.selection.isEmpty()) { + return; + } + + var cursor = this.getCursorPosition(); + var column = cursor.column; + if (column === 0) + return; + + var line = this.session.getLine(cursor.row); + var swap, range; + if (column < line.length) { + swap = line.charAt(column) + line.charAt(column-1); + range = new Range(cursor.row, column-1, cursor.row, column+1); + } + else { + swap = line.charAt(column-1) + line.charAt(column-2); + range = new Range(cursor.row, column-2, cursor.row, column); + } + this.session.replace(range, swap); + this.session.selection.moveToPosition(range.end); + }; + + /** + * Converts the current selection entirely into lowercase. + **/ + this.toLowerCase = function() { + var originalRange = this.getSelectionRange(); + if (this.selection.isEmpty()) { + this.selection.selectWord(); + } + + var range = this.getSelectionRange(); + var text = this.session.getTextRange(range); + this.session.replace(range, text.toLowerCase()); + this.selection.setSelectionRange(originalRange); + }; + + /** + * Converts the current selection entirely into uppercase. + **/ + this.toUpperCase = function() { + var originalRange = this.getSelectionRange(); + if (this.selection.isEmpty()) { + this.selection.selectWord(); + } + + var range = this.getSelectionRange(); + var text = this.session.getTextRange(range); + this.session.replace(range, text.toUpperCase()); + this.selection.setSelectionRange(originalRange); + }; + + /** + * Inserts an indentation into the current cursor position or indents the selected lines. + * + * @related EditSession.indentRows + **/ + this.indent = function() { + var session = this.session; + var range = this.getSelectionRange(); + + if (range.start.row < range.end.row) { + var rows = this.$getSelectedRows(); + session.indentRows(rows.first, rows.last, "\t"); + return; + } else if (range.start.column < range.end.column) { + var text = session.getTextRange(range); + if (!/^\s+$/.test(text)) { + var rows = this.$getSelectedRows(); + session.indentRows(rows.first, rows.last, "\t"); + return; + } + } + + var line = session.getLine(range.start.row); + var position = range.start; + var size = session.getTabSize(); + var column = session.documentToScreenColumn(position.row, position.column); + + if (this.session.getUseSoftTabs()) { + var count = (size - column % size); + var indentString = lang.stringRepeat(" ", count); + } else { + var count = column % size; + while (line[range.start.column - 1] == " " && count) { + range.start.column--; + count--; + } + this.selection.setSelectionRange(range); + indentString = "\t"; + } + return this.insert(indentString); + }; + + /** + * Indents the current line. + * @related EditSession.indentRows + **/ + this.blockIndent = function() { + var rows = this.$getSelectedRows(); + this.session.indentRows(rows.first, rows.last, "\t"); + }; + + /** + * Outdents the current line. + * @related EditSession.outdentRows + **/ + this.blockOutdent = function() { + var selection = this.session.getSelection(); + this.session.outdentRows(selection.getRange()); + }; + + // TODO: move out of core when we have good mechanism for managing extensions + this.sortLines = function() { + var rows = this.$getSelectedRows(); + var session = this.session; + + var lines = []; + for (var i = rows.first; i <= rows.last; i++) + lines.push(session.getLine(i)); + + lines.sort(function(a, b) { + if (a.toLowerCase() < b.toLowerCase()) return -1; + if (a.toLowerCase() > b.toLowerCase()) return 1; + return 0; + }); + + var deleteRange = new Range(0, 0, 0, 0); + for (var i = rows.first; i <= rows.last; i++) { + var line = session.getLine(i); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = line.length; + session.replace(deleteRange, lines[i-rows.first]); + } + }; + + /** + * Given the currently selected range, this function either comments all the lines, or uncomments all of them. + **/ + this.toggleCommentLines = function() { + var state = this.session.getState(this.getCursorPosition().row); + var rows = this.$getSelectedRows(); + this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last); + }; + + this.toggleBlockComment = function() { + var cursor = this.getCursorPosition(); + var state = this.session.getState(cursor.row); + var range = this.getSelectionRange(); + this.session.getMode().toggleBlockComment(state, this.session, range, cursor); + }; + + /** + * Works like [[EditSession.getTokenAt]], except it returns a number. + * @returns {Number} + **/ + this.getNumberAt = function(row, column) { + var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g; + _numberRx.lastIndex = 0; + + var s = this.session.getLine(row); + while (_numberRx.lastIndex < column) { + var m = _numberRx.exec(s); + if(m.index <= column && m.index+m[0].length >= column){ + var number = { + value: m[0], + start: m.index, + end: m.index+m[0].length + }; + return number; + } + } + return null; + }; + + /** + * If the character before the cursor is a number, this functions changes its value by `amount`. + * @param {Number} amount The value to change the numeral by (can be negative to decrease value) + * + **/ + this.modifyNumber = function(amount) { + var row = this.selection.getCursor().row; + var column = this.selection.getCursor().column; + + // get the char before the cursor + var charRange = new Range(row, column-1, row, column); + + var c = this.session.getTextRange(charRange); + // if the char is a digit + if (!isNaN(parseFloat(c)) && isFinite(c)) { + // get the whole number the digit is part of + var nr = this.getNumberAt(row, column); + // if number found + if (nr) { + var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end; + var decimals = nr.start + nr.value.length - fp; + + var t = parseFloat(nr.value); + t *= Math.pow(10, decimals); + + + if(fp !== nr.end && column < fp){ + amount *= Math.pow(10, nr.end - column - 1); + } else { + amount *= Math.pow(10, nr.end - column); + } + + t += amount; + t /= Math.pow(10, decimals); + var nnr = t.toFixed(decimals); + + //update number + var replaceRange = new Range(row, nr.start, row, nr.end); + this.session.replace(replaceRange, nnr); + + //reposition the cursor + this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length)); + + } + } + }; + + /** + * Removes all the lines in the current selection + * @related EditSession.remove + **/ + this.removeLines = function() { + var rows = this.$getSelectedRows(); + this.session.removeFullLines(rows.first, rows.last); + this.clearSelection(); + }; + + this.duplicateSelection = function() { + var sel = this.selection; + var doc = this.session; + var range = sel.getRange(); + var reverse = sel.isBackwards(); + if (range.isEmpty()) { + var row = range.start.row; + doc.duplicateLines(row, row); + } else { + var point = reverse ? range.start : range.end; + var endPoint = doc.insert(point, doc.getTextRange(range), false); + range.start = point; + range.end = endPoint; + + sel.setSelectionRange(range, reverse); + } + }; + + /** + * Shifts all the selected lines down one row. + * + * @returns {Number} On success, it returns -1. + * @related EditSession.moveLinesUp + **/ + this.moveLinesDown = function() { + this.$moveLines(1, false); + }; + + /** + * Shifts all the selected lines up one row. + * @returns {Number} On success, it returns -1. + * @related EditSession.moveLinesDown + **/ + this.moveLinesUp = function() { + this.$moveLines(-1, false); + }; + + /** + * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this: + * ```json + * { row: newRowLocation, column: newColumnLocation } + * ``` + * @param {Range} fromRange The range of text you want moved within the document + * @param {Object} toPosition The location (row and column) where you want to move the text to + * + * @returns {Range} The new range where the text was moved to. + * @related EditSession.moveText + **/ + this.moveText = function(range, toPosition, copy) { + return this.session.moveText(range, toPosition, copy); + }; + + /** + * Copies all the selected lines up one row. + * @returns {Number} On success, returns 0. + * + **/ + this.copyLinesUp = function() { + this.$moveLines(-1, true); + }; + + /** + * Copies all the selected lines down one row. + * @returns {Number} On success, returns the number of new rows added; in other words, `lastRow - firstRow + 1`. + * @related EditSession.duplicateLines + * + **/ + this.copyLinesDown = function() { + this.$moveLines(1, true); + }; + + /** + * for internal use + * @ignore + * + **/ + this.$moveLines = function(dir, copy) { + var rows, moved; + var selection = this.selection; + if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) { + var range = selection.toOrientedRange(); + 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); + this.inVirtualSelectionMode = true; + + var diff = 0; + var totalDiff = 0; + var l = ranges.length; + for (var i = 0; i < l; i++) { + var rangeIndex = i; + 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--; + 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; + } + }; + + /** + * Returns an object indicating the currently selected rows. The object looks like this: + * + * ```json + * { first: range.start.row, last: range.end.row } + * ``` + * + * @returns {Object} + **/ + this.$getSelectedRows = function(range) { + range = (range || this.getSelectionRange()).collapseRows(); + + return { + first: this.session.getRowFoldStart(range.start.row), + last: this.session.getRowFoldEnd(range.end.row) + }; + }; + + this.onCompositionStart = function(text) { + this.renderer.showComposition(this.getCursorPosition()); + }; + + this.onCompositionUpdate = function(text) { + this.renderer.setCompositionText(text); + }; + + this.onCompositionEnd = function() { + this.renderer.hideComposition(); + }; + + /** + * {:VirtualRenderer.getFirstVisibleRow} + * + * @returns {Number} + * @related VirtualRenderer.getFirstVisibleRow + **/ + this.getFirstVisibleRow = function() { + return this.renderer.getFirstVisibleRow(); + }; + + /** + * {:VirtualRenderer.getLastVisibleRow} + * + * @returns {Number} + * @related VirtualRenderer.getLastVisibleRow + **/ + this.getLastVisibleRow = function() { + return this.renderer.getLastVisibleRow(); + }; + + /** + * Indicates if the row is currently visible on the screen. + * @param {Number} row The row to check + * + * @returns {Boolean} + **/ + this.isRowVisible = function(row) { + return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow()); + }; + + /** + * Indicates if the entire row is currently visible on the screen. + * @param {Number} row The row to check + * + * + * @returns {Boolean} + **/ + this.isRowFullyVisible = function(row) { + return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow()); + }; + + /** + * Returns the number of currently visible rows. + * @returns {Number} + **/ + this.$getVisibleRowCount = function() { + return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1; + }; + + this.$moveByPage = function(dir, select) { + var renderer = this.renderer; + var config = this.renderer.layerConfig; + var rows = dir * Math.floor(config.height / config.lineHeight); + + this.$blockScrolling++; + if (select === true) { + this.selection.$moveSelection(function(){ + this.moveCursorBy(rows, 0); + }); + } else if (select === false) { + this.selection.moveCursorBy(rows, 0); + this.selection.clearSelection(); + } + this.$blockScrolling--; + + var scrollTop = renderer.scrollTop; + + renderer.scrollBy(0, rows * config.lineHeight); + if (select != null) + renderer.scrollCursorIntoView(null, 0.5); + + renderer.animateScrolling(scrollTop); + }; + + /** + * Selects the text from the current position of the document until where a "page down" finishes. + **/ + this.selectPageDown = function() { + this.$moveByPage(1, true); + }; + + /** + * Selects the text from the current position of the document until where a "page up" finishes. + **/ + this.selectPageUp = function() { + this.$moveByPage(-1, true); + }; + + /** + * Shifts the document to wherever "page down" is, as well as moving the cursor position. + **/ + this.gotoPageDown = function() { + this.$moveByPage(1, false); + }; + + /** + * Shifts the document to wherever "page up" is, as well as moving the cursor position. + **/ + this.gotoPageUp = function() { + this.$moveByPage(-1, false); + }; + + /** + * Scrolls the document to wherever "page down" is, without changing the cursor position. + **/ + this.scrollPageDown = function() { + this.$moveByPage(1); + }; + + /** + * Scrolls the document to wherever "page up" is, without changing the cursor position. + **/ + this.scrollPageUp = function() { + this.$moveByPage(-1); + }; + + /** + * Moves the editor to the specified row. + * @related VirtualRenderer.scrollToRow + **/ + this.scrollToRow = function(row) { + this.renderer.scrollToRow(row); + }; + + /** + * Scrolls to a line. If `center` is `true`, it puts the line in middle of screen (or attempts to). + * @param {Number} line The line to scroll to + * @param {Boolean} center If `true` + * @param {Boolean} animate If `true` animates scrolling + * @param {Function} callback Function to be called when the animation has finished + * + * + * @related VirtualRenderer.scrollToLine + **/ + this.scrollToLine = function(line, center, animate, callback) { + this.renderer.scrollToLine(line, center, animate, callback); + }; + + /** + * Attempts to center the current selection on the screen. + **/ + this.centerSelection = function() { + var range = this.getSelectionRange(); + var pos = { + row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2), + column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2) + }; + this.renderer.alignCursor(pos, 0.5); + }; + + /** + * Gets the current position of the cursor. + * @returns {Object} An object that looks something like this: + * + * ```json + * { row: currRow, column: currCol } + * ``` + * + * @related Selection.getCursor + **/ + this.getCursorPosition = function() { + return this.selection.getCursor(); + }; + + /** + * Returns the screen position of the cursor. + * @returns {Number} + * @related EditSession.documentToScreenPosition + **/ + this.getCursorPositionScreen = function() { + return this.session.documentToScreenPosition(this.getCursorPosition()); + }; + + /** + * {:Selection.getRange} + * @returns {Range} + * @related Selection.getRange + **/ + this.getSelectionRange = function() { + return this.selection.getRange(); + }; + + + /** + * Selects all the text in editor. + * @related Selection.selectAll + **/ + this.selectAll = function() { + this.$blockScrolling += 1; + this.selection.selectAll(); + this.$blockScrolling -= 1; + }; + + /** + * {:Selection.clearSelection} + * @related Selection.clearSelection + **/ + this.clearSelection = function() { + this.selection.clearSelection(); + }; + + /** + * Moves the cursor to the specified row and column. Note that this does not de-select the current selection. + * @param {Number} row The new row number + * @param {Number} column The new column number + * + * + * @related Selection.moveCursorTo + **/ + this.moveCursorTo = function(row, column) { + this.selection.moveCursorTo(row, column); + }; + + /** + * Moves the cursor to the position indicated by `pos.row` and `pos.column`. + * @param {Object} pos An object with two properties, row and column + * + * + * @related Selection.moveCursorToPosition + **/ + this.moveCursorToPosition = function(pos) { + this.selection.moveCursorToPosition(pos); + }; + + /** + * Moves the cursor's row and column to the next matching bracket or HTML tag. + * + **/ + 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 || iterator.stepForward(); + + if (!token) return; + + //get next closing tag or bracket + var matchType; + var found = false; + var depth = {}; + var i = cursor.column - token.start; + var bracketType; + var brackets = { + ")": "(", + "(": "(", + "]": "[", + "[": "[", + "{": "{", + "}": "{" + }; + + do { + if (token.value.match(/[{}()\[\]]/g)) { + for (; i < token.value.length && !found; i++) { + if (!brackets[token.value[i]]) { + continue; + } + + bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen"); + + if (isNaN(depth[bracketType])) { + depth[bracketType] = 0; + } + + switch (token.value[i]) { + case '(': + case '[': + case '{': + depth[bracketType]++; + break; + case ')': + case ']': + case '}': + depth[bracketType]--; + + if (depth[bracketType] === -1) { + matchType = 'bracket'; + found = true; + } + break; + } + } + } + else if (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 === '= 0; --i) { + if(this.$tryReplace(ranges[i], replacement)) { + replaced++; + } + } + + this.selection.setSelectionRange(selection); + this.$blockScrolling -= 1; + + return replaced; + }; + + this.$tryReplace = function(range, replacement) { + var input = this.session.getTextRange(range); + replacement = this.$search.replace(input, replacement); + if (replacement !== null) { + range.end = this.session.replace(range, replacement); + return range; + } else { + return null; + } + }; + + /** + * {:Search.getOptions} For more information on `options`, see [[Search `Search`]]. + * @related Search.getOptions + * @returns {Object} + **/ + this.getLastSearchOptions = function() { + return this.$search.getOptions(); + }; + + /** + * Attempts to find `needle` within the document. For more information on `options`, see [[Search `Search`]]. + * @param {String} needle The text to search for (optional) + * @param {Object} options An object defining various search properties + * @param {Boolean} animate If `true` animate scrolling + * + * + * @related Search.find + **/ + this.find = function(needle, options, animate) { + if (!options) + options = {}; + + if (typeof needle == "string" || needle instanceof RegExp) + options.needle = needle; + else if (typeof needle == "object") + oop.mixin(options, needle); + + var range = this.selection.getRange(); + if (options.needle == null) { + needle = this.session.getTextRange(range) + || this.$search.$options.needle; + if (!needle) { + range = this.session.getWordRange(range.start.row, range.start.column); + needle = this.session.getTextRange(range); + } + this.$search.set({needle: needle}); + } + + this.$search.set(options); + if (!options.start) + this.$search.set({start: range}); + + var newRange = this.$search.find(this.session); + if (options.preventScroll) + return newRange; + if (newRange) { + this.revealRange(newRange, animate); + return newRange; + } + // clear selection if nothing is found + if (options.backwards) + range.start = range.end; + else + range.end = range.start; + this.selection.setRange(range); + }; + + /** + * Performs another search for `needle` in the document. For more information on `options`, see [[Search `Search`]]. + * @param {Object} options search options + * @param {Boolean} animate If `true` animate scrolling + * + * + * @related Editor.find + **/ + this.findNext = function(options, animate) { + this.find({skipCurrent: true, backwards: false}, options, animate); + }; + + /** + * Performs a search for `needle` backwards. For more information on `options`, see [[Search `Search`]]. + * @param {Object} options search options + * @param {Boolean} animate If `true` animate scrolling + * + * + * @related Editor.find + **/ + this.findPrevious = function(options, animate) { + this.find(options, {skipCurrent: true, backwards: true}, animate); + }; + + this.revealRange = function(range, animate) { + this.$blockScrolling += 1; + this.session.unfold(range); + this.selection.setSelectionRange(range); + this.$blockScrolling -= 1; + + var scrollTop = this.renderer.scrollTop; + this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5); + if (animate !== false) + this.renderer.animateScrolling(scrollTop); + }; + + /** + * {:UndoManager.undo} + * @related UndoManager.undo + **/ + this.undo = function() { + this.$blockScrolling++; + this.session.getUndoManager().undo(); + this.$blockScrolling--; + this.renderer.scrollCursorIntoView(null, 0.5); + }; + + /** + * {:UndoManager.redo} + * @related UndoManager.redo + **/ + this.redo = function() { + this.$blockScrolling++; + this.session.getUndoManager().redo(); + this.$blockScrolling--; + this.renderer.scrollCursorIntoView(null, 0.5); + }; + + /** + * + * Cleans up the entire editor. + **/ + this.destroy = function() { + this.renderer.destroy(); + this._signal("destroy", this); + if (this.session) { + this.session.destroy(); + } + }; + + /** + * Enables automatic scrolling of the cursor into view when editor itself is inside scrollable element + * @param {Boolean} enable default true + **/ + this.setAutoScrollEditorIntoView = function(enable) { + if (!enable) + return; + var rect; + var self = this; + var shouldScroll = false; + if (!this.$scrollAnchor) + this.$scrollAnchor = document.createElement("div"); + var scrollAnchor = this.$scrollAnchor; + scrollAnchor.style.cssText = "position:absolute"; + this.container.insertBefore(scrollAnchor, this.container.firstChild); + var onChangeSelection = this.on("changeSelection", function() { + shouldScroll = true; + }); + // needed to not trigger sync reflow + var onBeforeRender = this.renderer.on("beforeRender", function() { + if (shouldScroll) + rect = self.renderer.container.getBoundingClientRect(); + }); + var onAfterRender = this.renderer.on("afterRender", function() { + if (shouldScroll && rect && (self.isFocused() + || self.searchBox && self.searchBox.isFocused()) + ) { + var renderer = self.renderer; + var pos = renderer.$cursorLayer.$pixelPos; + var config = renderer.layerConfig; + var top = pos.top - config.offset; + if (pos.top >= 0 && top + rect.top < 0) { + shouldScroll = true; + } else if (pos.top < config.height && + pos.top + rect.top + config.lineHeight > window.innerHeight) { + shouldScroll = false; + } else { + shouldScroll = null; + } + if (shouldScroll != null) { + scrollAnchor.style.top = top + "px"; + scrollAnchor.style.left = pos.left + "px"; + scrollAnchor.style.height = config.lineHeight + "px"; + scrollAnchor.scrollIntoView(shouldScroll); + } + shouldScroll = rect = null; + } + }); + this.setAutoScrollEditorIntoView = function(enable) { + if (enable) + return; + delete this.setAutoScrollEditorIntoView; + this.off("changeSelection", onChangeSelection); + this.renderer.off("afterRender", onAfterRender); + this.renderer.off("beforeRender", onBeforeRender); + }; + }; + + + this.$resetCursorStyle = function() { + var style = this.$cursorStyle || "ace"; + var cursorLayer = this.renderer.$cursorLayer; + if (!cursorLayer) + return; + cursorLayer.setSmoothBlinking(/smooth/.test(style)); + cursorLayer.isBlinking = !this.$readOnly && style != "wide"; + dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style)); + }; + +}).call(Editor.prototype); + + + +config.defineOptions(Editor.prototype, "editor", { + selectionStyle: { + set: function(style) { + this.onSelectionChange(); + this._signal("changeSelectionStyle", {data: style}); + }, + initialValue: "line" + }, + highlightActiveLine: { + set: function() {this.$updateHighlightActiveLine();}, + initialValue: true + }, + highlightSelectedWord: { + set: function(shouldHighlight) {this.$onSelectionChange();}, + initialValue: true + }, + readOnly: { + set: function(readOnly) { + // disabled to not break vim mode! + // this.textInput.setReadOnly(readOnly); + this.$resetCursorStyle(); + }, + initialValue: false + }, + cursorStyle: { + set: function(val) { this.$resetCursorStyle(); }, + values: ["ace", "slim", "smooth", "wide"], + initialValue: "ace" + }, + mergeUndoDeltas: { + values: [false, true, "always"], + initialValue: true + }, + behavioursEnabled: {initialValue: true}, + wrapBehavioursEnabled: {initialValue: true}, + autoScrollEditorIntoView: { + set: function(val) {this.setAutoScrollEditorIntoView(val);} + }, + keyboardHandler: { + set: function(val) { this.setKeyboardHandler(val); }, + get: function() { return this.keybindingId; }, + handlesSet: true + }, + + hScrollBarAlwaysVisible: "renderer", + vScrollBarAlwaysVisible: "renderer", + highlightGutterLine: "renderer", + animatedScroll: "renderer", + showInvisibles: "renderer", + showPrintMargin: "renderer", + printMarginColumn: "renderer", + printMargin: "renderer", + fadeFoldWidgets: "renderer", + showFoldWidgets: "renderer", + showLineNumbers: "renderer", + showGutter: "renderer", + displayIndentGuides: "renderer", + fontSize: "renderer", + fontFamily: "renderer", + maxLines: "renderer", + minLines: "renderer", + scrollPastEnd: "renderer", + fixedWidthGutter: "renderer", + theme: "renderer", + + scrollSpeed: "$mouseHandler", + dragDelay: "$mouseHandler", + dragEnabled: "$mouseHandler", + focusTimout: "$mouseHandler", + tooltipFollowsMouse: "$mouseHandler", + + firstLineNumber: "session", + overwrite: "session", + newLineMode: "session", + useWorker: "session", + useSoftTabs: "session", + tabSize: "session", + wrap: "session", + indentedSoftWrap: "session", + foldStyle: "session", + mode: "session" +}); + +exports.Editor = Editor; +}); diff --git a/public/lib/ace/editor_change_document_test.js b/public/lib/ace/editor_change_document_test.js new file mode 100644 index 0000000..fe4e856 --- /dev/null +++ b/public/lib/ace/editor_change_document_test.js @@ -0,0 +1,188 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("./test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +var EditSession = require("./edit_session").EditSession; +var Editor = require("./editor").Editor; +var Text = require("./mode/text").Mode; +var JavaScriptMode = require("./mode/javascript").Mode; +var CssMode = require("./mode/css").Mode; +var HtmlMode = require("./mode/html").Mode; +var MockRenderer = require("./test/mockrenderer").MockRenderer; +var assert = require("./test/assertions"); + +module.exports = { + + setUp : function(next) { + this.session1 = new EditSession(["abc", "def"]); + this.session2 = new EditSession(["ghi", "jkl"]); + + + this.editor = new Editor(new MockRenderer()); + next(); + }, + + "test: change document" : function() { + this.editor.setSession(this.session1); + assert.equal(this.editor.getSession(), this.session1); + + this.editor.setSession(this.session2); + assert.equal(this.editor.getSession(), this.session2); + }, + + "test: only changes to the new document should have effect" : function() { + var called = false; + this.editor.onDocumentChange = function() { + called = true; + }; + + this.editor.setSession(this.session1); + this.editor.setSession(this.session2); + + this.session1.duplicateLines(0, 0); + assert.notOk(called); + + this.session2.duplicateLines(0, 0); + assert.ok(called); + }, + + "test: should use cursor of new document" : function() { + this.session1.getSelection().moveCursorTo(0, 1); + this.session2.getSelection().moveCursorTo(1, 0); + + this.editor.setSession(this.session1); + assert.position(this.editor.getCursorPosition(), 0, 1); + + this.editor.setSession(this.session2); + assert.position(this.editor.getCursorPosition(), 1, 0); + }, + + "test: only changing the cursor of the new doc should not have an effect" : function() { + this.editor.onCursorChange = function() { + called = true; + }; + + this.editor.setSession(this.session1); + this.editor.setSession(this.session2); + assert.position(this.editor.getCursorPosition(), 0, 0); + + var called = false; + this.session1.getSelection().moveCursorTo(0, 1); + assert.position(this.editor.getCursorPosition(), 0, 0); + assert.notOk(called); + + this.session2.getSelection().moveCursorTo(1, 1); + assert.position(this.editor.getCursorPosition(), 1, 1); + assert.ok(called); + }, + + "test: should use selection of new document" : function() { + this.session1.getSelection().selectTo(0, 1); + this.session2.getSelection().selectTo(1, 0); + + this.editor.setSession(this.session1); + assert.position(this.editor.getSelection().getSelectionLead(), 0, 1); + + this.editor.setSession(this.session2); + assert.position(this.editor.getSelection().getSelectionLead(), 1, 0); + }, + + "test: only changing the selection of the new doc should not have an effect" : function() { + this.editor.onSelectionChange = function() { + called = true; + }; + + this.editor.setSession(this.session1); + this.editor.setSession(this.session2); + assert.position(this.editor.getSelection().getSelectionLead(), 0, 0); + + var called = false; + this.session1.getSelection().selectTo(0, 1); + assert.position(this.editor.getSelection().getSelectionLead(), 0, 0); + assert.notOk(called); + + this.session2.getSelection().selectTo(1, 1); + assert.position(this.editor.getSelection().getSelectionLead(), 1, 1); + assert.ok(called); + }, + + "test: should use mode of new document" : function() { + this.editor.onChangeMode = function() { + called = true; + }; + this.editor.setSession(this.session1); + this.editor.setSession(this.session2); + + var called = false; + this.session1.setMode(new Text()); + assert.notOk(called); + + this.session2.setMode(new JavaScriptMode()); + assert.ok(called); + }, + + "test: should use stop worker of old document" : function(next) { + var self = this; + + // 1. Open an editor and set the session to CssMode + self.editor.setSession(self.session1); + self.session1.setMode(new CssMode()); + + // 2. Add a line or two of valid CSS. + self.session1.setValue("DIV { color: red; }"); + + // 3. Clear the session value. + self.session1.setValue(""); + + // 4. Set the session to HtmlMode + self.session1.setMode(new HtmlMode()); + + // 5. Try to type valid HTML + self.session1.insert({row: 0, column: 0}, ""); + + setTimeout(function() { + assert.equal(Object.keys(self.session1.getAnnotations()).length, 0); + next(); + }, 600); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/editor_highlight_selected_word_test.js b/public/lib/ace/editor_highlight_selected_word_test.js new file mode 100644 index 0000000..a226a69 --- /dev/null +++ b/public/lib/ace/editor_highlight_selected_word_test.js @@ -0,0 +1,223 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("./test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +var EditSession = require("./edit_session").EditSession; +var Editor = require("./editor").Editor; +var MockRenderer = require("./test/mockrenderer").MockRenderer; +var assert = require("./test/assertions"); + +var lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + + "Mauris at arcu mi, eu lobortis mauris. Quisque ut libero eget " + + "diam congue vehicula. Quisque ut odio ut mi aliquam tincidunt. " + + "Duis lacinia aliquam lorem eget eleifend. Morbi eget felis mi. " + + "Duis quam ligula, consequat vitae convallis volutpat, blandit " + + "nec neque. Nulla facilisi. Etiam suscipit lorem ac justo " + + "sollicitudin tristique. Phasellus ut posuere nunc. Aliquam " + + "scelerisque mollis felis non gravida. Vestibulum lacus sem, " + + "posuere non bibendum id, luctus non dolor. Aenean id metus " + + "lorem, vel dapibus est. Donec gravida feugiat augue nec " + + "accumsan.Lorem ipsum dolor sit amet, consectetur adipiscing " + + "elit. Nulla vulputate, velit vitae tincidunt congue, nunc " + + "augue accumsan velit, eu consequat turpis lectus ac orci. " + + "Pellentesque ornare dolor feugiat dui auctor eu varius nulla " + + "fermentum. Sed aliquam odio at velit lacinia vel fermentum " + + "felis sodales. In dignissim magna eget nunc lobortis non " + + "fringilla nibh ullamcorper. Donec facilisis malesuada elit " + + "at egestas. Etiam bibendum, diam vitae tempor aliquet, dui " + + "libero vehicula odio, eget bibendum mauris velit eu lorem.\n" + + "consectetur"; + +function callHighlighterUpdate(session, firstRow, lastRow) { + var rangeCount = 0; + var mockMarkerLayer = { drawSingleLineMarker: function() {rangeCount++;} }; + session.$searchHighlight.update([], mockMarkerLayer, session, { + firstRow: firstRow, + lastRow: lastRow + }); + return rangeCount; +} + +module.exports = { + setUp: function(next) { + this.session = new EditSession(lipsum); + this.editor = new Editor(new MockRenderer(), this.session); + this.selection = this.session.getSelection(); + this.search = this.editor.$search; + next(); + }, + + "test: highlight selected words by default": function() { + assert.equal(this.editor.getHighlightSelectedWord(), true); + }, + + "test: highlight a word": function() { + this.editor.moveCursorTo(0, 9); + this.selection.selectWord(); + + var highlighter = this.editor.session.$searchHighlight; + assert.ok(highlighter != null); + + var range = this.selection.getRange(); + assert.equal(this.session.getTextRange(range), "ipsum"); + assert.equal(highlighter.cache.length, 0); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 2); + }, + + "test: highlight a word and clear highlight": function() { + this.editor.moveCursorTo(0, 8); + this.selection.selectWord(); + + var range = this.selection.getRange(); + assert.equal(this.session.getTextRange(range), "ipsum"); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 2); + + this.session.highlight(""); + assert.equal(this.session.$searchHighlight.cache.length, 0); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 0); + }, + + "test: highlight another word": function() { + this.selection.moveCursorTo(0, 14); + this.selection.selectWord(); + + var range = this.selection.getRange(); + assert.equal(this.session.getTextRange(range), "dolor"); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 4); + }, + + "test: no selection, no highlight": function() { + this.selection.clearSelection(); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 0); + }, + + "test: select a word, no highlight": function() { + this.selection.moveCursorTo(0, 14); + this.selection.selectWord(); + + this.editor.setHighlightSelectedWord(false); + + var range = this.selection.getRange(); + assert.equal(this.session.getTextRange(range), "dolor"); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 0); + }, + + "test: select a word with no matches": function() { + this.editor.setHighlightSelectedWord(true); + + var currentOptions = this.search.getOptions(); + var newOptions = { + wrap: true, + wholeWord: true, + caseSensitive: true, + needle: "Mauris" + }; + this.search.set(newOptions); + + var match = this.search.find(this.session); + assert.notEqual(match, null, "found a match for 'Mauris'"); + + this.search.set(currentOptions); + + this.selection.setSelectionRange(match); + + assert.equal(this.session.getTextRange(match), "Mauris"); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 1); + }, + + "test: partial word selection 1": function() { + this.selection.moveCursorTo(0, 14); + this.selection.selectWord(); + this.selection.selectLeft(); + + var range = this.selection.getRange(); + assert.equal(this.session.getTextRange(range), "dolo"); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 0); + }, + + "test: partial word selection 2": function() { + this.selection.moveCursorTo(0, 13); + this.selection.selectWord(); + this.selection.selectRight(); + + var range = this.selection.getRange(); + assert.equal(this.session.getTextRange(range), "dolor "); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 0); + }, + + "test: partial word selection 3": function() { + this.selection.moveCursorTo(0, 14); + this.selection.selectWord(); + this.selection.selectLeft(); + this.selection.shiftSelection(1); + + var range = this.selection.getRange(); + assert.equal(this.session.getTextRange(range), "olor"); + assert.equal(callHighlighterUpdate(this.session, 0, 0), 0); + }, + + "test: select last word": function() { + this.selection.moveCursorTo(0, 1); + + var currentOptions = this.search.getOptions(); + var newOptions = { + wrap: true, + wholeWord: true, + caseSensitive: true, + backwards: true, + needle: "consectetur" + }; + this.search.set(newOptions); + + var match = this.search.find(this.session); + assert.notEqual(match, null, "found a match for 'consectetur'"); + assert.position(match.start, 1, 0); + + this.search.set(currentOptions); + + this.selection.setSelectionRange(match); + + assert.equal(this.session.getTextRange(match), "consectetur"); + assert.equal(callHighlighterUpdate(this.session, 0, 1), 3); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/editor_navigation_test.js b/public/lib/ace/editor_navigation_test.js new file mode 100644 index 0000000..5c9e2aa --- /dev/null +++ b/public/lib/ace/editor_navigation_test.js @@ -0,0 +1,187 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("./test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +var EditSession = require("./edit_session").EditSession; +var Editor = require("./editor").Editor; +var MockRenderer = require("./test/mockrenderer").MockRenderer; +var assert = require("./test/assertions"); + +module.exports = { + createEditSession : function(rows, cols) { + var line = new Array(cols + 1).join("a"); + var text = new Array(rows).join(line + "\n") + line; + return new EditSession(text); + }, + + "test: navigate to end of file should scroll the last line into view" : function() { + var doc = this.createEditSession(200, 10); + var editor = new Editor(new MockRenderer(), doc); + + editor.navigateFileEnd(); + var cursor = editor.getCursorPosition(); + + assert.ok(editor.getFirstVisibleRow() <= cursor.row); + assert.ok(editor.getLastVisibleRow() >= cursor.row); + }, + + "test: navigate to start of file should scroll the first row into view" : function() { + var doc = this.createEditSession(200, 10); + var editor = new Editor(new MockRenderer(), doc); + + editor.moveCursorTo(editor.getLastVisibleRow() + 20); + editor.navigateFileStart(); + + assert.equal(editor.getFirstVisibleRow(), 0); + }, + + "test: goto hidden line should scroll the line into the middle of the viewport" : function() { + var editor = new Editor(new MockRenderer(), this.createEditSession(200, 5)); + + editor.navigateTo(0, 0); + editor.gotoLine(101); + assert.position(editor.getCursorPosition(), 100, 0); + assert.equal(editor.getFirstVisibleRow(), 89); + + editor.navigateTo(100, 0); + editor.gotoLine(11); + assert.position(editor.getCursorPosition(), 10, 0); + assert.equal(editor.getFirstVisibleRow(), 0); + + editor.navigateTo(100, 0); + editor.gotoLine(6); + assert.position(editor.getCursorPosition(), 5, 0); + assert.equal(0, editor.getFirstVisibleRow(), 0); + + editor.navigateTo(100, 0); + editor.gotoLine(1); + assert.position(editor.getCursorPosition(), 0, 0); + assert.equal(editor.getFirstVisibleRow(), 0); + + editor.navigateTo(0, 0); + editor.gotoLine(191); + assert.position(editor.getCursorPosition(), 190, 0); + assert.equal(editor.getFirstVisibleRow(), 179); + + editor.navigateTo(0, 0); + editor.gotoLine(196); + assert.position(editor.getCursorPosition(), 195, 0); + assert.equal(editor.getFirstVisibleRow(), 180); + }, + + "test: goto visible line should only move the cursor and not scroll": function() { + var editor = new Editor(new MockRenderer(), this.createEditSession(200, 5)); + + editor.navigateTo(0, 0); + editor.gotoLine(12); + assert.position(editor.getCursorPosition(), 11, 0); + assert.equal(editor.getFirstVisibleRow(), 0); + + editor.navigateTo(30, 0); + editor.gotoLine(33); + assert.position(editor.getCursorPosition(), 32, 0); + assert.equal(editor.getFirstVisibleRow(), 30); + }, + + "test: navigate from the end of a long line down to a short line and back should maintain the curser column": function() { + var editor = new Editor(new MockRenderer(), new EditSession(["123456", "1"])); + + editor.navigateTo(0, 6); + assert.position(editor.getCursorPosition(), 0, 6); + + editor.navigateDown(); + assert.position(editor.getCursorPosition(), 1, 1); + + editor.navigateUp(); + assert.position(editor.getCursorPosition(), 0, 6); + }, + + "test: reset desired column on navigate left or right": function() { + var editor = new Editor(new MockRenderer(), new EditSession(["123456", "12"])); + + editor.navigateTo(0, 6); + assert.position(editor.getCursorPosition(), 0, 6); + + editor.navigateDown(); + assert.position(editor.getCursorPosition(), 1, 2); + + editor.navigateLeft(); + assert.position(editor.getCursorPosition(), 1, 1); + + editor.navigateUp(); + assert.position(editor.getCursorPosition(), 0, 1); + }, + + "test: navigate within soft tabs based on setting": function() { + var editor = new Editor(new MockRenderer(), new EditSession([" "])); + + editor.getSession().setUseSoftTabs(true); + editor.getSession().setTabSize(4); + + editor.navigateTo(0, 0); + editor.navigateRight(); + assert.position(editor.getCursorPosition(), 0, 4); + + editor.navigateLeft(); + assert.position(editor.getCursorPosition(), 0, 0); + + editor.getSession().setNavigateWithinSoftTabs(true); + + editor.navigateRight(); + assert.position(editor.getCursorPosition(), 0, 1); + + editor.navigateTo(0, 4); + editor.navigateLeft(); + assert.position(editor.getCursorPosition(), 0, 3); + }, + + "test: typing text should update the desired column": function() { + var editor = new Editor(new MockRenderer(), new EditSession(["1234", "1234567890"])); + + editor.navigateTo(0, 3); + editor.insert("juhu"); + + editor.navigateDown(); + assert.position(editor.getCursorPosition(), 1, 7); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/editor_text_edit_test.js b/public/lib/ace/editor_text_edit_test.js new file mode 100644 index 0000000..bd87507 --- /dev/null +++ b/public/lib/ace/editor_text_edit_test.js @@ -0,0 +1,563 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("./test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +var EditSession = require("./edit_session").EditSession; +var Editor = require("./editor").Editor; +var JavaScriptMode = require("./mode/javascript").Mode; +var UndoManager = require("./undomanager").UndoManager; +var MockRenderer = require("./test/mockrenderer").MockRenderer; +var assert = require("./test/assertions"); +var whitespace = require("./ext/whitespace"); + +module.exports = { + "test: delete line from the middle" : function() { + var session = new EditSession(["a", "b", "c", "d"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(1, 1); + editor.removeLines(); + + assert.equal(session.toString(), "a\nc\nd"); + assert.position(editor.getCursorPosition(), 1, 0); + + editor.removeLines(); + + assert.equal(session.toString(), "a\nd"); + assert.position(editor.getCursorPosition(), 1, 0); + + editor.removeLines(); + + assert.equal(session.toString(), "a"); + assert.position(editor.getCursorPosition(), 0, 1); + + editor.removeLines(); + + assert.equal(session.toString(), ""); + assert.position(editor.getCursorPosition(), 0, 0); + }, + + "test: delete multiple selected lines" : function() { + var session = new EditSession(["a", "b", "c", "d"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(1, 1); + editor.getSelection().selectDown(); + + editor.removeLines(); + assert.equal(session.toString(), "a\nd"); + assert.position(editor.getCursorPosition(), 1, 0); + }, + + "test: delete first line" : function() { + var session = new EditSession(["a", "b", "c"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.removeLines(); + + assert.equal(session.toString(), "b\nc"); + assert.position(editor.getCursorPosition(), 0, 0); + }, + + "test: delete last should also delete the new line of the previous line" : function() { + var session = new EditSession(["a", "b", "c", ""].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(3, 0); + + editor.removeLines(); + assert.equal(session.toString(), "a\nb\nc"); + assert.position(editor.getCursorPosition(), 2, 1); + + editor.removeLines(); + assert.equal(session.toString(), "a\nb"); + assert.position(editor.getCursorPosition(), 1, 1); + }, + + "test: indent block" : function() { + var session = new EditSession(["a12345", "b12345", "c12345"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(1, 3); + editor.getSelection().selectDown(); + + editor.indent(); + + assert.equal(["a12345", " b12345", " c12345"].join("\n"), session.toString()); + + assert.position(editor.getCursorPosition(), 2, 7); + + var range = editor.getSelectionRange(); + assert.position(range.start, 1, 7); + assert.position(range.end, 2, 7); + + session.setValue(" x"); + session.setOption("useSoftTabs", false); + editor.selection.moveTo(0, 3); + editor.indent(); + assert.equal("\tx", session.toString()); + }, + + "test: indent selected lines" : function() { + var session = new EditSession(["a12345", "b12345", "c12345"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(1, 0); + editor.getSelection().selectDown(); + + editor.indent(); + assert.equal(["a12345", " b12345", "c12345"].join("\n"), session.toString()); + }, + + "test: no auto indent if cursor is before the {" : function() { + var session = new EditSession("{", new JavaScriptMode()); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(0, 0); + editor.onTextInput("\n"); + assert.equal(["", "{"].join("\n"), session.toString()); + }, + + "test: outdent block" : function() { + var session = new EditSession([" a12345", " b12345", " c12345"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(0, 5); + editor.getSelection().selectDown(); + editor.getSelection().selectDown(); + + editor.blockOutdent(); + assert.equal(session.toString(), [" a12345", "b12345", " c12345"].join("\n")); + + assert.position(editor.getCursorPosition(), 2, 1); + + var range = editor.getSelectionRange(); + assert.position(range.start, 0, 1); + assert.position(range.end, 2, 1); + + editor.blockOutdent(); + assert.equal(session.toString(), ["a12345", "b12345", "c12345"].join("\n")); + + var range = editor.getSelectionRange(); + assert.position(range.start, 0, 0); + assert.position(range.end, 2, 0); + }, + + "test: outent without a selection should update cursor" : function() { + var session = new EditSession(" 12"); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(0, 3); + editor.blockOutdent(" "); + + assert.equal(session.toString(), " 12"); + assert.position(editor.getCursorPosition(), 0, 0); + }, + + "test: comment lines should perserve selection" : function() { + var session = new EditSession([" abc", "cde"].join("\n"), new JavaScriptMode()); + var editor = new Editor(new MockRenderer(), session); + whitespace.detectIndentation(session); + + editor.moveCursorTo(0, 2); + editor.getSelection().selectDown(); + editor.toggleCommentLines(); + + assert.equal(["// abc", "// cde"].join("\n"), session.toString()); + + var selection = editor.getSelectionRange(); + assert.position(selection.start, 0, 5); + assert.position(selection.end, 1, 5); + }, + + "test: uncomment lines should perserve selection" : function() { + var session = new EditSession(["// abc", "//cde"].join("\n"), new JavaScriptMode()); + var editor = new Editor(new MockRenderer(), session); + session.setTabSize(2); + + editor.moveCursorTo(0, 1); + editor.getSelection().selectDown(); + editor.getSelection().selectRight(); + editor.getSelection().selectRight(); + + editor.toggleCommentLines(); + + assert.equal([" abc", "cde"].join("\n"), session.toString()); + assert.range(editor.getSelectionRange(), 0, 0, 1, 1); + }, + + "test: toggle comment lines twice should return the original text" : function() { + var session = new EditSession([" abc", "cde", "fg"], new JavaScriptMode()); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(0, 0); + editor.getSelection().selectDown(); + editor.getSelection().selectDown(); + + editor.toggleCommentLines(); + editor.toggleCommentLines(); + + assert.equal([" abc", "cde", "fg"].join("\n"), session.toString()); + }, + + + "test: comment lines - if the selection end is at the line start it should stay there": function() { + //select down + var session = new EditSession(["abc", "cde"].join("\n"), new JavaScriptMode()); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(0, 0); + editor.getSelection().selectDown(); + + editor.toggleCommentLines(); + assert.range(editor.getSelectionRange(), 0, 3, 1, 0); + + // select up + var session = new EditSession(["abc", "cde"].join("\n"), new JavaScriptMode()); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(1, 0); + editor.getSelection().selectUp(); + + editor.toggleCommentLines(); + assert.range(editor.getSelectionRange(), 0, 3, 1, 0); + }, + + "test: move lines down should keep selection on moved lines" : function() { + var session = new EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(0, 1); + editor.getSelection().selectDown(); + + editor.moveLinesDown(); + assert.equal(["33", "11", "22", "44"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 2, 1); + assert.position(editor.getSelection().getSelectionAnchor(), 1, 1); + assert.position(editor.getSelection().getSelectionLead(), 2, 1); + + editor.moveLinesDown(); + assert.equal(["33", "44", "11", "22"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 3, 1); + assert.position(editor.getSelection().getSelectionAnchor(), 2, 1); + assert.position(editor.getSelection().getSelectionLead(), 3, 1); + + // moving again should have no effect + editor.moveLinesDown(); + assert.equal(["33", "44", "11", "22"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 3, 1); + assert.position(editor.getSelection().getSelectionAnchor(), 2, 1); + assert.position(editor.getSelection().getSelectionLead(), 3, 1); + }, + + "test: move lines up should keep selection on moved lines" : function() { + var session = new EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(2, 1); + editor.getSelection().selectDown(); + + editor.moveLinesUp(); + assert.equal(session.toString(), ["11", "33", "44", "22"].join("\n")); + assert.position(editor.getCursorPosition(), 2, 1); + assert.position(editor.getSelection().getSelectionAnchor(), 1, 1); + assert.position(editor.getSelection().getSelectionLead(), 2, 1); + + editor.moveLinesUp(); + assert.equal(session.toString(), ["33", "44", "11", "22"].join("\n")); + assert.position(editor.getCursorPosition(), 1, 1); + assert.position(editor.getSelection().getSelectionAnchor(), 0, 1); + assert.position(editor.getSelection().getSelectionLead(), 1, 1); + }, + + "test: move line without active selection should not move cursor relative to the moved line" : function() { + var session = new EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(1, 1); + editor.clearSelection(); + + editor.moveLinesDown(); + assert.equal(["11", "33", "22", "44"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 2, 1); + + editor.clearSelection(); + + editor.moveLinesUp(); + assert.equal(["11", "22", "33", "44"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 1, 1); + }, + + "test: copy lines down should keep selection" : function() { + var session = new EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(1, 1); + editor.getSelection().selectDown(); + + editor.copyLinesDown(); + assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString()); + + assert.position(editor.getCursorPosition(), 4, 1); + assert.position(editor.getSelection().getSelectionAnchor(), 3, 1); + assert.position(editor.getSelection().getSelectionLead(), 4, 1); + }, + + "test: copy lines up should keep selection" : function() { + var session = new EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new Editor(new MockRenderer(), session); + + editor.moveCursorTo(1, 1); + editor.getSelection().selectDown(); + + editor.copyLinesUp(); + assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString()); + + assert.position(editor.getCursorPosition(), 2, 1); + assert.position(editor.getSelection().getSelectionAnchor(), 1, 1); + assert.position(editor.getSelection().getSelectionLead(), 2, 1); + }, + + "test: input a tab with soft tab should convert it to spaces" : function() { + var session = new EditSession(""); + var editor = new Editor(new MockRenderer(), session); + + session.setTabSize(2); + session.setUseSoftTabs(true); + + editor.onTextInput("\t"); + assert.equal(session.toString(), " "); + + session.setTabSize(5); + editor.onTextInput("\t"); + assert.equal(session.toString(), " "); + }, + + "test: input tab without soft tabs should keep the tab character" : function() { + var session = new EditSession(""); + var editor = new Editor(new MockRenderer(), session); + + session.setUseSoftTabs(false); + + editor.onTextInput("\t"); + assert.equal(session.toString(), "\t"); + }, + + "test: undo/redo for delete line" : function() { + var session = new EditSession(["111", "222", "333"]); + var undoManager = new UndoManager(); + session.setUndoManager(undoManager); + + var initialText = session.toString(); + var editor = new Editor(new MockRenderer(), session); + + editor.removeLines(); + var step1 = session.toString(); + assert.equal(step1, "222\n333"); + session.$syncInformUndoManager(); + + editor.removeLines(); + var step2 = session.toString(); + assert.equal(step2, "333"); + session.$syncInformUndoManager(); + + editor.removeLines(); + var step3 = session.toString(); + assert.equal(step3, ""); + session.$syncInformUndoManager(); + + undoManager.undo(); + session.$syncInformUndoManager(); + assert.equal(session.toString(), step2); + + undoManager.undo(); + session.$syncInformUndoManager(); + assert.equal(session.toString(), step1); + + undoManager.undo(); + session.$syncInformUndoManager(); + assert.equal(session.toString(), initialText); + + undoManager.undo(); + session.$syncInformUndoManager(); + assert.equal(session.toString(), initialText); + }, + + "test: remove left should remove character left of the cursor" : function() { + var session = new EditSession(["123", "456"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 1); + editor.remove("left"); + assert.equal(session.toString(), "123\n56"); + }, + + "test: remove left should remove line break if cursor is at line start" : function() { + var session = new EditSession(["123", "456"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 0); + editor.remove("left"); + assert.equal(session.toString(), "123456"); + }, + + "test: remove left should remove tabsize spaces if cursor is on a tab stop and preceeded by spaces" : function() { + var session = new EditSession(["123", " 456"]); + session.setUseSoftTabs(true); + session.setTabSize(4); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 8); + editor.remove("left"); + assert.equal(session.toString(), "123\n 456"); + }, + + "test: transpose at line start should be a noop": function() { + var session = new EditSession(["123", "4567", "89"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 0); + editor.transposeLetters(); + + assert.equal(session.getValue(), ["123", "4567", "89"].join("\n")); + }, + + "test: transpose in line should swap the charaters before and after the cursor": function() { + var session = new EditSession(["123", "4567", "89"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 2); + editor.transposeLetters(); + + assert.equal(session.getValue(), ["123", "4657", "89"].join("\n")); + }, + + "test: transpose at line end should swap the last two characters": function() { + var session = new EditSession(["123", "4567", "89"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 4); + editor.transposeLetters(); + + assert.equal(session.getValue(), ["123", "4576", "89"].join("\n")); + }, + + "test: transpose with non empty selection should be a noop": function() { + var session = new EditSession(["123", "4567", "89"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 1); + editor.getSelection().selectRight(); + editor.transposeLetters(); + + assert.equal(session.getValue(), ["123", "4567", "89"].join("\n")); + }, + + "test: transpose should move the cursor behind the last swapped character": function() { + var session = new EditSession(["123", "4567", "89"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 2); + editor.transposeLetters(); + assert.position(editor.getCursorPosition(), 1, 3); + }, + + "test: remove to line end": function() { + var session = new EditSession(["123", "4567", "89"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 2); + editor.removeToLineEnd(); + assert.equal(session.getValue(), ["123", "45", "89"].join("\n")); + }, + + "test: remove to line end at line end should remove the new line": function() { + var session = new EditSession(["123", "4567", "89"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 4); + editor.removeToLineEnd(); + assert.position(editor.getCursorPosition(), 1, 4); + assert.equal(session.getValue(), ["123", "456789"].join("\n")); + }, + + "test: transform selection to uppercase": function() { + var session = new EditSession(["ajax", "dot", "org"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 0); + editor.getSelection().selectLineEnd(); + editor.toUpperCase(); + assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n")); + }, + + "test: transform word to uppercase": function() { + var session = new EditSession(["ajax", "dot", "org"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 0); + editor.toUpperCase(); + assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n")); + assert.position(editor.getCursorPosition(), 1, 0); + }, + + "test: transform selection to lowercase": function() { + var session = new EditSession(["AJAX", "DOT", "ORG"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 0); + editor.getSelection().selectLineEnd(); + editor.toLowerCase(); + assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n")); + }, + + "test: transform word to lowercase": function() { + var session = new EditSession(["AJAX", "DOT", "ORG"]); + + var editor = new Editor(new MockRenderer(), session); + editor.moveCursorTo(1, 0); + editor.toLowerCase(); + assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n")); + assert.position(editor.getCursorPosition(), 1, 0); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/ext/beautify.js b/public/lib/ace/ext/beautify.js new file mode 100644 index 0000000..89d9405 --- /dev/null +++ b/public/lib/ace/ext/beautify.js @@ -0,0 +1,57 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +// [WIP] + +define(function(require, exports, module) { +"use strict"; +var TokenIterator = require("ace/token_iterator").TokenIterator; + +var phpTransform = require("./beautify/php_rules").transform; + +exports.beautify = function(session) { + var iterator = new TokenIterator(session, 0, 0); + var token = iterator.getCurrentToken(); + + var context = session.$modeId.split("/").pop(); + + var code = phpTransform(iterator, context); + session.doc.setValue(code); +}; + +exports.commands = [{ + name: "beautify", + exec: function(editor) { + exports.beautify(editor.session); + }, + bindKey: "Ctrl-Shift-B" +}]; + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/beautify/php_rules.js b/public/lib/ace/ext/beautify/php_rules.js new file mode 100644 index 0000000..9a5bed3 --- /dev/null +++ b/public/lib/ace/ext/beautify/php_rules.js @@ -0,0 +1,366 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 TokenIterator = require("ace/token_iterator").TokenIterator; +exports.newLines = [{ + type: 'support.php_tag', + value: '' +}, { + type: 'paren.lparen', + value: '{', + indent: true +}, { + type: 'paren.rparen', + breakBefore: true, + value: '}', + indent: false +}, { + type: 'paren.rparen', + breakBefore: true, + value: '})', + indent: false, + dontBreak: true +}, { + type: 'comment' +}, { + type: 'text', + value: ';' +}, { + type: 'text', + value: ':', + context: 'php' +}, { + type: 'keyword', + value: 'case', + indent: true, + dontBreak: true +}, { + type: 'keyword', + value: 'default', + indent: true, + dontBreak: true +}, { + type: 'keyword', + value: 'break', + indent: false, + dontBreak: true +}, { + type: 'punctuation.doctype.end', + value: '>' +}, { + type: 'meta.tag.punctuation.end', + value: '>' +}, { + type: 'meta.tag.punctuation.begin', + value: '<', + blockTag: true, + indent: true, + dontBreak: true +}, { + type: 'meta.tag.punctuation.begin', + value: '' ){ + context = 'php'; + } + else if( token.type == 'support.php_tag' && token.value == '?>' ){ + context = 'html'; + } + //css + else if( token.type == 'meta.tag.name.style' && context != 'css' ){ + context = 'css'; + } + else if( token.type == 'meta.tag.name.style' && context == 'css' ){ + context = 'html'; + } + //js + else if( token.type == 'meta.tag.name.script' && context != 'js' ){ + context = 'js'; + } + else if( token.type == 'meta.tag.name.script' && context == 'js' ){ + context = 'html'; + } + + nextToken = iterator.stepForward(); + + //tag name + if (nextToken && nextToken.type.indexOf('meta.tag.name') == 0) { + nextTag = nextToken.value; + } + + //don't linebreak + if ( lastToken.type == 'support.php_tag' && lastToken.value == '' ) { + dontBreak = false; + } + + //next token + lastTag = tag; + + lastToken = token; + + token = nextToken; + + if (token===null) { + break; + } + } + + return code; +}; + + + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/elastic_tabstops_lite.js b/public/lib/ace/ext/elastic_tabstops_lite.js new file mode 100644 index 0000000..0f89423 --- /dev/null +++ b/public/lib/ace/ext/elastic_tabstops_lite.js @@ -0,0 +1,318 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ElasticTabstopsLite = function(editor) { + this.$editor = editor; + var self = this; + var changedRows = []; + var recordChanges = false; + this.onAfterExec = function() { + recordChanges = false; + self.processRows(changedRows); + changedRows = []; + }; + this.onExec = function() { + recordChanges = true; + }; + this.onChange = function(delta) { + if (recordChanges) { + if (changedRows.indexOf(delta.start.row) == -1) + changedRows.push(delta.start.row); + if (delta.end.row != delta.start.row) + changedRows.push(delta.end.row); + } + }; +}; + +(function() { + this.processRows = function(rows) { + this.$inChange = true; + var checkedRows = []; + + for (var r = 0, rowCount = rows.length; r < rowCount; r++) { + var row = rows[r]; + + if (checkedRows.indexOf(row) > -1) + continue; + + var cellWidthObj = this.$findCellWidthsForBlock(row); + var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths); + var rowIndex = cellWidthObj.firstRow; + + for (var w = 0, l = cellWidths.length; w < l; w++) { + var widths = cellWidths[w]; + checkedRows.push(rowIndex); + this.$adjustRow(rowIndex, widths); + rowIndex++; + } + } + this.$inChange = false; + }; + + this.$findCellWidthsForBlock = function(row) { + var cellWidths = [], widths; + + // starting row and backward + var rowIter = row; + while (rowIter >= 0) { + widths = this.$cellWidthsForRow(rowIter); + if (widths.length == 0) + break; + + cellWidths.unshift(widths); + rowIter--; + } + var firstRow = rowIter + 1; + + // forward (not including starting row) + rowIter = row; + var numRows = this.$editor.session.getLength(); + + while (rowIter < numRows - 1) { + rowIter++; + + widths = this.$cellWidthsForRow(rowIter); + if (widths.length == 0) + break; + + cellWidths.push(widths); + } + + return { cellWidths: cellWidths, firstRow: firstRow }; + }; + + this.$cellWidthsForRow = function(row) { + var selectionColumns = this.$selectionColumnsForRow(row); + // todo: support multicursor + + var tabs = [-1].concat(this.$tabsForRow(row)); + var widths = tabs.map(function(el) { return 0; } ).slice(1); + var line = this.$editor.session.getLine(row); + + for (var i = 0, len = tabs.length - 1; i < len; i++) { + var leftEdge = tabs[i]+1; + var rightEdge = tabs[i+1]; + + var rightmostSelection = this.$rightmostSelectionInCell(selectionColumns, rightEdge); + var cell = line.substring(leftEdge, rightEdge); + widths[i] = Math.max(cell.replace(/\s+$/g,'').length, rightmostSelection - leftEdge); + } + + return widths; + }; + + this.$selectionColumnsForRow = function(row) { + var selections = [], cursor = this.$editor.getCursorPosition(); + if (this.$editor.session.getSelection().isEmpty()) { + // todo: support multicursor + if (row == cursor.row) + selections.push(cursor.column); + } + + return selections; + }; + + this.$setBlockCellWidthsToMax = function(cellWidths) { + var startingNewBlock = true, blockStartRow, blockEndRow, maxWidth; + var columnInfo = this.$izip_longest(cellWidths); + + for (var c = 0, l = columnInfo.length; c < l; c++) { + var column = columnInfo[c]; + if (!column.push) { + console.error(column); + continue; + } + // add an extra None to the end so that the end of the column automatically + // finishes a block + column.push(NaN); + + for (var r = 0, s = column.length; r < s; r++) { + var width = column[r]; + if (startingNewBlock) { + blockStartRow = r; + maxWidth = 0; + startingNewBlock = false; + } + if (isNaN(width)) { + // block ended + blockEndRow = r; + + for (var j = blockStartRow; j < blockEndRow; j++) { + cellWidths[j][c] = maxWidth; + } + startingNewBlock = true; + } + + maxWidth = Math.max(maxWidth, width); + } + } + + return cellWidths; + }; + + this.$rightmostSelectionInCell = function(selectionColumns, cellRightEdge) { + var rightmost = 0; + + if (selectionColumns.length) { + var lengths = []; + for (var s = 0, length = selectionColumns.length; s < length; s++) { + if (selectionColumns[s] <= cellRightEdge) + lengths.push(s); + else + lengths.push(0); + } + rightmost = Math.max.apply(Math, lengths); + } + + return rightmost; + }; + + this.$tabsForRow = function(row) { + var rowTabs = [], line = this.$editor.session.getLine(row), + re = /\t/g, match; + + while ((match = re.exec(line)) != null) { + rowTabs.push(match.index); + } + + return rowTabs; + }; + + this.$adjustRow = function(row, widths) { + var rowTabs = this.$tabsForRow(row); + + if (rowTabs.length == 0) + return; + + var bias = 0, location = -1; + + // this always only contains two elements, so we're safe in the loop below + var expandedSet = this.$izip(widths, rowTabs); + + for (var i = 0, l = expandedSet.length; i < l; i++) { + var w = expandedSet[i][0], it = expandedSet[i][1]; + location += 1 + w; + it += bias; + var difference = location - it; + + if (difference == 0) + continue; + + var partialLine = this.$editor.session.getLine(row).substr(0, it ); + var strippedPartialLine = partialLine.replace(/\s*$/g, ""); + var ispaces = partialLine.length - strippedPartialLine.length; + + if (difference > 0) { + // put the spaces after the tab and then delete the tab, so any insertion + // points behave as expected + this.$editor.session.getDocument().insertInLine({row: row, column: it + 1}, Array(difference + 1).join(" ") + "\t"); + this.$editor.session.getDocument().removeInLine(row, it, it + 1); + + bias += difference; + } + + if (difference < 0 && ispaces >= -difference) { + this.$editor.session.getDocument().removeInLine(row, it + difference, it); + bias += difference; + } + } + }; + + // the is a (naive) Python port--but works for these purposes + this.$izip_longest = function(iterables) { + if (!iterables[0]) + return []; + var longest = iterables[0].length; + var iterablesLength = iterables.length; + + for (var i = 1; i < iterablesLength; i++) { + var iLength = iterables[i].length; + if (iLength > longest) + longest = iLength; + } + + var expandedSet = []; + + for (var l = 0; l < longest; l++) { + var set = []; + for (var i = 0; i < iterablesLength; i++) { + if (iterables[i][l] === "") + set.push(NaN); + else + set.push(iterables[i][l]); + } + + expandedSet.push(set); + } + + + return expandedSet; + }; + + // an even more (naive) Python port + this.$izip = function(widths, tabs) { + // grab the shorter size + var size = widths.length >= tabs.length ? tabs.length : widths.length; + + var expandedSet = []; + for (var i = 0; i < size; i++) { + var set = [ widths[i], tabs[i] ]; + expandedSet.push(set); + } + return expandedSet; + }; + +}).call(ElasticTabstopsLite.prototype); + +exports.ElasticTabstopsLite = ElasticTabstopsLite; + +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + useElasticTabstops: { + set: function(val) { + if (val) { + if (!this.elasticTabstops) + this.elasticTabstops = new ElasticTabstopsLite(this); + this.commands.on("afterExec", this.elasticTabstops.onAfterExec); + this.commands.on("exec", this.elasticTabstops.onExec); + this.on("change", this.elasticTabstops.onChange); + } else if (this.elasticTabstops) { + this.commands.removeListener("afterExec", this.elasticTabstops.onAfterExec); + this.commands.removeListener("exec", this.elasticTabstops.onExec); + this.removeListener("change", this.elasticTabstops.onChange); + } + } + } +}); + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/emmet.js b/public/lib/ace/ext/emmet.js new file mode 100644 index 0000000..00f89c6 --- /dev/null +++ b/public/lib/ace/ext/emmet.js @@ -0,0 +1,463 @@ +/* ***** 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("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, emmetPath; + +/** + * Implementation of {@link IEmmetEditor} interface for Ace + */ +function AceEmmetEditor() {} + +AceEmmetEditor.prototype = { + setupContext: function(editor) { + this.ace = editor; + this.indentation = editor.session.getTabString(); + if (!emmet) + emmet = window.emmet; + var resources = emmet.resources || emmet.require("resources"); + resources.setVariable("indentation", this.indentation); + this.$syntax = null; + this.$syntax = this.getSyntax(); + }, + /** + * Returns character indexes of selected text: object with start + * and end properties. If there's no selection, should return + * object with start and end properties referring + * to current caret position + * @return {Object} + * @example + * var selection = editor.getSelectionRange(); + * alert(selection.start + ', ' + selection.end); + */ + getSelectionRange: function() { + // TODO should start be caret position instead? + var range = this.ace.getSelectionRange(); + var doc = this.ace.session.doc; + return { + start: doc.positionToIndex(range.start), + end: doc.positionToIndex(range.end) + }; + }, + + /** + * Creates selection from start to end character + * indexes. If end is ommited, this method should place caret + * and start index + * @param {Number} start + * @param {Number} [end] + * @example + * editor.createSelection(10, 40); + * + * //move caret to 15th character + * editor.createSelection(15); + */ + createSelection: function(start, end) { + var doc = this.ace.session.doc; + this.ace.selection.setRange({ + start: doc.indexToPosition(start), + end: doc.indexToPosition(end) + }); + }, + + /** + * Returns current line's start and end indexes as object with start + * and end properties + * @return {Object} + * @example + * var range = editor.getCurrentLineRange(); + * alert(range.start + ', ' + range.end); + */ + getCurrentLineRange: function() { + 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 + }; + }, + + /** + * Returns current caret position + * @return {Number|null} + */ + getCaretPos: function(){ + var pos = this.ace.getCursorPosition(); + return this.ace.session.doc.positionToIndex(pos); + }, + + /** + * Set new caret position + * @param {Number} index Caret position + */ + setCaretPos: function(index){ + var pos = this.ace.session.doc.indexToPosition(index); + this.ace.selection.moveToPosition(pos); + }, + + /** + * Returns content of current line + * @return {String} + */ + getCurrentLine: function() { + var row = this.ace.getCursorPosition().row; + return this.ace.session.getLine(row); + }, + + /** + * Replace editor's content or it's part (from start to + * end index). If value contains + * caret_placeholder, the editor will put caret into + * this position. If you skip start and end + * arguments, the whole target's content will be replaced with + * value. + * + * If you pass start argument only, + * the value will be placed at start string + * index of current content. + * + * If you pass start and end arguments, + * the corresponding substring of current target's content will be + * replaced with value. + * @param {String} value Content you want to paste + * @param {Number} [start] Start index of editor's content + * @param {Number} [end] End index of editor's content + * @param {Boolean} [noIndent] Do not auto indent value + */ + replaceContent: function(value, start, end, noIndent) { + if (end == null) + end = start == null ? this.getContent().length : start; + if (start == null) + start = 0; + + var editor = this.ace; + 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); + }, + + /** + * Returns editor's content + * @return {String} + */ + getContent: function(){ + return this.ace.getValue(); + }, + + /** + * Returns current editor's syntax mode + * @return {String} + */ + getSyntax: function() { + if (this.$syntax) + return this.$syntax; + var syntax = this.ace.session.$modeId.split("/").pop(); + if (syntax == "html" || syntax == "php") { + var cursor = this.ace.getCursorPosition(); + var state = this.ace.session.getState(cursor.row); + if (typeof state != "string") + state = state[0]; + if (state) { + state = state.split("-"); + if (state.length > 1) + syntax = state[0]; + else if (syntax == "php") + syntax = "html"; + } + } + return syntax; + }, + + /** + * Returns current output profile name (@see emmet#setupProfile) + * @return {String} + */ + getProfileName: function() { + var resources = emmet.resources || emmet.require("resources"); + switch (this.getSyntax()) { + case "css": return "css"; + case "xml": + case "xsl": + return "xml"; + case "html": + var profile = resources.getVariable("profile"); + // no forced profile, guess from content html or xhtml? + if (!profile) + profile = this.ace.session.getLines(0,2).join("").search(/]+XHTML/i) != -1 ? "xhtml": "html"; + return profile; + default: + var mode = this.ace.session.$mode; + return mode.emmetConfig && mode.emmetConfig.profile || "xhtml"; + } + }, + + /** + * Ask user to enter something + * @param {String} title Dialog title + * @return {String} Entered data + * @since 0.65 + */ + prompt: function(title) { + return prompt(title); + }, + + /** + * Returns current selection + * @return {String} + * @since 0.65 + */ + getSelection: function() { + return this.ace.session.getTextRange(); + }, + + /** + * Returns current editor's file path + * @return {String} + * @since 0.65 + */ + getFilePath: function() { + return ""; + }, + + // update tabstops: make sure all caret placeholders are unique + // by default, abbreviation parser generates all unlinked (un-mirrored) + // tabstops as ${0}, so we have upgrade all caret tabstops with unique + // positions but make sure that all other tabstops are not linked accidentally + // based on https://github.com/sergeche/emmet-sublime/blob/master/editor.js#L119-L171 + $updateTabstops: function(value) { + var base = 1000; + var zeroBase = 0; + var lastZero = null; + var ts = emmet.tabStops || emmet.require('tabStops'); + var resources = emmet.resources || emmet.require("resources"); + var settings = resources.getVocabulary("user"); + var tabstopOptions = { + tabstop: function(data) { + var group = parseInt(data.group, 10); + var isZero = group === 0; + if (isZero) + group = ++zeroBase; + else + group += base; + + var placeholder = data.placeholder; + if (placeholder) { + // recursively update nested tabstops + placeholder = ts.processText(placeholder, tabstopOptions); + } + + var result = '${' + group + (placeholder ? ':' + placeholder : '') + '}'; + + if (isZero) { + lastZero = [data.start, result]; + } + + return result; + }, + escape: function(ch) { + if (ch == '$') return '\\$'; + if (ch == '\\') return '\\\\'; + return ch; + } + }; + + value = ts.processText(value, tabstopOptions); + + if (settings.variables['insert_final_tabstop'] && !/\$\{0\}$/.test(value)) { + value += '${0}'; + } else if (lastZero) { + var common = emmet.utils ? emmet.utils.common : emmet.require('utils'); + value = common.replaceSubstring(value, '${0}', lastZero[0], lastZero[1]); + } + + return value; + } +}; + + +var keymap = { + expand_abbreviation: {"mac": "ctrl+alt+e", "win": "alt+e"}, + match_pair_outward: {"mac": "ctrl+d", "win": "ctrl+,"}, + match_pair_inward: {"mac": "ctrl+j", "win": "ctrl+shift+0"}, + matching_pair: {"mac": "ctrl+alt+j", "win": "alt+j"}, + next_edit_point: "alt+right", + prev_edit_point: "alt+left", + toggle_comment: {"mac": "command+/", "win": "ctrl+/"}, + split_join_tag: {"mac": "shift+command+'", "win": "shift+ctrl+`"}, + remove_tag: {"mac": "command+'", "win": "shift+ctrl+;"}, + evaluate_math_expression: {"mac": "shift+command+y", "win": "shift+ctrl+y"}, + increment_number_by_1: "ctrl+up", + decrement_number_by_1: "ctrl+down", + increment_number_by_01: "alt+up", + decrement_number_by_01: "alt+down", + increment_number_by_10: {"mac": "alt+command+up", "win": "shift+alt+up"}, + decrement_number_by_10: {"mac": "alt+command+down", "win": "shift+alt+down"}, + select_next_item: {"mac": "shift+command+.", "win": "shift+ctrl+."}, + select_previous_item: {"mac": "shift+command+,", "win": "shift+ctrl+,"}, + reflect_css_value: {"mac": "shift+command+r", "win": "shift+ctrl+r"}, + + encode_decode_data_url: {"mac": "shift+ctrl+d", "win": "ctrl+'"}, + // update_image_size: {"mac": "shift+ctrl+i", "win": "ctrl+u"}, + // expand_as_you_type: "ctrl+alt+enter", + // wrap_as_you_type: {"mac": "shift+ctrl+g", "win": "shift+ctrl+g"}, + expand_abbreviation_with_tab: "Tab", + wrap_with_abbreviation: {"mac": "shift+ctrl+a", "win": "shift+ctrl+a"} +}; + +var editorProxy = new AceEmmetEditor(); +exports.commands = new HashHandler(); +exports.runEmmetCommand = function runEmmetCommand(editor) { + try { + editorProxy.setupContext(editor); + var actions = emmet.actions || emmet.require("actions"); + + if (this.action == "expand_abbreviation_with_tab") { + if (!editor.selection.isEmpty()) + return false; + var pos = editor.selection.lead; + var token = editor.session.getTokenAt(pos.row, pos.column); + if (token && /\btag\b/.test(token.type)) + 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 result = actions.run(this.action, editorProxy); + } catch(e) { + if (!emmet) { + load(runEmmetCommand.bind(this, editor)); + return true; + } + editor._signal("changeStatus", typeof e == "string" ? e : e.message); + console.log(e); + result = false; + } + return result; +}; + +for (var command in keymap) { + exports.commands.addCommand({ + name: "emmet:" + command, + action: command, + bindKey: keymap[command], + exec: exports.runEmmetCommand, + multiSelectAction: "forEach" + }); +} + +exports.updateCommands = function(editor, enabled) { + if (enabled) { + editor.keyBinding.addKeyboardHandler(exports.commands); + } else { + editor.keyBinding.removeKeyboardHandler(exports.commands); + } +}; + +exports.isSupportedMode = function(mode) { + if (!mode) return false; + if (mode.emmetConfig) return true; + var id = mode.$id || mode; + return /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(id); +}; + +exports.isAvailable = function(editor, command) { + if (/(evaluate_math_expression|expand_abbreviation)$/.test(command)) + return true; + var mode = editor.session.$mode; + var isSupported = exports.isSupportedMode(mode); + if (isSupported && mode.$modes) { + // TODO refactor mode delegates to make this simpler + try { + editorProxy.setupContext(editor); + if (/js|php/.test(editorProxy.getSyntax())) + isSupported = false; + } catch(e) {} + } + return isSupported; +}; + +var onChangeMode = function(e, target) { + var editor = target; + if (!editor) + return; + var enabled = exports.isSupportedMode(editor.session.$mode); + if (e.enableEmmet === false) + enabled = false; + if (enabled) + load(); + exports.updateCommands(editor, enabled); +}; + +var load = function(cb) { + if (typeof emmetPath == "string") { + require("ace/config").loadModule(emmetPath, function() { + emmetPath = null; + cb && cb(); + }); + } +}; + +exports.AceEmmetEditor = AceEmmetEditor; +require("ace/config").defineOptions(Editor.prototype, "editor", { + enableEmmet: { + set: function(val) { + this[val ? "on" : "removeListener"]("changeMode", onChangeMode); + onChangeMode({enableEmmet: !!val}, this); + }, + value: true + } +}); + +exports.setCore = function(e) { + if (typeof e == "string") + emmetPath = e; + else + emmet = e; +}; +}); + diff --git a/public/lib/ace/ext/error_marker.js b/public/lib/ace/ext/error_marker.js new file mode 100644 index 0000000..03baa11 --- /dev/null +++ b/public/lib/ace/ext/error_marker.js @@ -0,0 +1,217 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 LineWidgets = require("../line_widgets").LineWidgets; +var dom = require("../lib/dom"); +var Range = require("../range").Range; + +function binarySearch(array, needle, comparator) { + var first = 0; + var last = array.length - 1; + + while (first <= last) { + var mid = (first + last) >> 1; + var c = comparator(needle, array[mid]); + if (c > 0) + first = mid + 1; + else if (c < 0) + last = mid - 1; + else + return mid; + } + + // Return the nearest lesser index, "-1" means "0, "-2" means "1", etc. + return -(first + 1); +} + +function findAnnotations(session, row, dir) { + var annotations = session.getAnnotations().sort(Range.comparePoints); + if (!annotations.length) + return; + + var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints); + if (i < 0) + i = -i - 1; + + if (i >= annotations.length) + i = dir > 0 ? 0 : annotations.length - 1; + else if (i === 0 && dir < 0) + i = annotations.length - 1; + + var annotation = annotations[i]; + if (!annotation || !dir) + return; + + if (annotation.row === row) { + do { + annotation = annotations[i += dir]; + } while (annotation && annotation.row === row); + if (!annotation) + return annotations.slice(); + } + + + var matched = []; + row = annotation.row; + do { + matched[dir < 0 ? "unshift" : "push"](annotation); + annotation = annotations[i += dir]; + } while (annotation && annotation.row == row); + return matched.length && matched; +} + +exports.showErrorMarker = function(editor, dir) { + var session = editor.session; + if (!session.widgetManager) { + session.widgetManager = new LineWidgets(session); + session.widgetManager.attach(editor); + } + + var pos = editor.getCursorPosition(); + var row = pos.row; + var oldWidget = session.widgetManager.getWidgetsAtRow(row).filter(function(w) { + return w.type == "errorMarker"; + })[0]; + if (oldWidget) { + oldWidget.destroy(); + } else { + row -= dir; + } + var annotations = findAnnotations(session, row, dir); + var gutterAnno; + if (annotations) { + var annotation = annotations[0]; + pos.column = (annotation.pos && typeof annotation.column != "number" + ? annotation.pos.sc + : annotation.column) || 0; + pos.row = annotation.row; + gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row]; + } else if (oldWidget) { + return; + } else { + gutterAnno = { + text: ["Looks good!"], + className: "ace_ok" + }; + } + editor.session.unfold(pos.row); + editor.selection.moveToPosition(pos); + + var w = { + row: pos.row, + fixedWidth: true, + coverGutter: true, + el: dom.createElement("div"), + type: "errorMarker" + }; + var el = w.el.appendChild(dom.createElement("div")); + var arrow = w.el.appendChild(dom.createElement("div")); + arrow.className = "error_widget_arrow " + gutterAnno.className; + + var left = editor.renderer.$cursorLayer + .getPixelPosition(pos).left; + arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px"; + + w.el.className = "error_widget_wrapper"; + el.className = "error_widget " + gutterAnno.className; + el.innerHTML = gutterAnno.text.join("
"); + + el.appendChild(dom.createElement("div")); + + var kb = function(_, hashId, keyString) { + if (hashId === 0 && (keyString === "esc" || keyString === "return")) { + w.destroy(); + return {command: "null"}; + } + }; + + w.destroy = function() { + if (editor.$mouseHandler.isMousePressed) + return; + editor.keyBinding.removeKeyboardHandler(kb); + session.widgetManager.removeLineWidget(w); + editor.off("changeSelection", w.destroy); + editor.off("changeSession", w.destroy); + editor.off("mouseup", w.destroy); + editor.off("change", w.destroy); + }; + + editor.keyBinding.addKeyboardHandler(kb); + editor.on("changeSelection", w.destroy); + editor.on("changeSession", w.destroy); + editor.on("mouseup", w.destroy); + editor.on("change", w.destroy); + + editor.session.widgetManager.addLineWidget(w); + + w.el.onmousedown = editor.focus.bind(editor); + + editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight}); +}; + + +dom.importCssString("\ + .error_widget_wrapper {\ + background: inherit;\ + color: inherit;\ + border:none\ + }\ + .error_widget {\ + border-top: solid 2px;\ + border-bottom: solid 2px;\ + margin: 5px 0;\ + padding: 10px 40px;\ + white-space: pre-wrap;\ + }\ + .error_widget.ace_error, .error_widget_arrow.ace_error{\ + border-color: #ff5a5a\ + }\ + .error_widget.ace_warning, .error_widget_arrow.ace_warning{\ + border-color: #F1D817\ + }\ + .error_widget.ace_info, .error_widget_arrow.ace_info{\ + border-color: #5a5a5a\ + }\ + .error_widget.ace_ok, .error_widget_arrow.ace_ok{\ + border-color: #5aaa5a\ + }\ + .error_widget_arrow {\ + position: absolute;\ + border: solid 5px;\ + border-top-color: transparent!important;\ + border-right-color: transparent!important;\ + border-left-color: transparent!important;\ + top: -5px;\ + }\ +", ""); + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/keybinding_menu.js b/public/lib/ace/ext/keybinding_menu.js new file mode 100644 index 0000000..38e578d --- /dev/null +++ b/public/lib/ace/ext/keybinding_menu.js @@ -0,0 +1,86 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl + * All rights reserved. + * + * Contributed to Ajax.org under the BSD license. + * + * 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 ***** */ + +/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +/*global define, require */ + +/** + * Show Keyboard Shortcuts + * @fileOverview Show Keyboard Shortcuts
+ * Generates a menu which displays the keyboard shortcuts. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + +define(function(require, exports, module) { + "use strict"; + var Editor = require("ace/editor").Editor; + /** + * Generates a menu which displays the keyboard shortcuts. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {ace.Editor} editor An instance of the ace editor. + */ + function showKeyboardShortcuts (editor) { + // make sure the menu isn't open already. + if(!document.getElementById('kbshortcutmenu')) { + var overlayPage = require('./menu_tools/overlay_page').overlayPage; + var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts; + var kb = getEditorKeybordShortcuts(editor); + var el = document.createElement('div'); + var commands = kb.reduce(function(previous, current) { + return previous + '
' + + current.command + ' : ' + + '' + current.key + '
'; + }, ''); + + el.id = 'kbshortcutmenu'; + el.innerHTML = '

Keyboard Shortcuts

' + commands + ''; + overlayPage(editor, el, '0', '0', '0', null); + } + } + module.exports.init = function(editor) { + Editor.prototype.showKeyboardShortcuts = function() { + showKeyboardShortcuts(this); + }; + editor.commands.addCommands([{ + name: "showKeyboardShortcuts", + bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"}, + exec: function(editor, line) { + editor.showKeyboardShortcuts(); + } + }]); + }; + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/language_tools.js b/public/lib/ace/ext/language_tools.js new file mode 100644 index 0000000..3de3d0c --- /dev/null +++ b/public/lib/ace/ext/language_tools.js @@ -0,0 +1,209 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 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); + } +}; + +var snippetCompleter = { + getCompletions: function(editor, session, pos, prefix, callback) { + var snippetMap = snippetManager.snippetMap; + var completions = []; + snippetManager.getActiveScopes(editor).forEach(function(scope) { + var snippets = snippetMap[scope] || []; + for (var i = snippets.length; i--;) { + var s = snippets[i]; + var caption = s.name || s.tabTrigger; + if (!caption) + continue; + completions.push({ + caption: caption, + snippet: s.content, + 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 = [ + "", lang.escapeHTML(item.caption), "", "
", + lang.escapeHTML(item.snippet) + ].join(""); + } + } +}; + +var completers = [snippetCompleter, textCompleter, keyWordCompleter]; +// Modifies list of default completers +exports.setCompleters = function(val) { + completers.length = 0; + if (val) completers.push.apply(completers, val); +}; +exports.addCompleter = function(completer) { + completers.push(completer); +}; + +// Exports existing completer so that user can construct his own set of completers. +exports.textCompleter = textCompleter; +exports.keyWordCompleter = keyWordCompleter; +exports.snippetCompleter = snippetCompleter; + +var expandSnippet = { + name: "expandSnippet", + exec: function(editor) { + return snippetManager.expandWithTab(editor); + }, + bindKey: "Tab" +}; + +var onChangeMode = function(e, editor) { + loadSnippetsForMode(editor.session.$mode); +}; + +var loadSnippetsForMode = function(mode) { + var id = mode.$id; + if (!snippetManager.files) + snippetManager.files = {}; + loadSnippetFile(id); + if (mode.modes) + mode.modes.forEach(loadSnippetsForMode); +}; + +var loadSnippetFile = function(id) { + if (!id || snippetManager.files[id]) + return; + var snippetFilePath = id.replace("mode", "snippets"); + snippetManager.files[id] = {}; + config.loadModule(snippetFilePath, function(m) { + if (m) { + snippetManager.files[id] = m; + if (!m.snippets && m.snippetText) + m.snippets = snippetManager.parseSnippetFile(m.snippetText); + snippetManager.register(m.snippets || [], m.scope); + if (m.includeScopes) { + snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes; + m.includeScopes.forEach(function(x) { + loadSnippetFile("ace/mode/" + x); + }); + } + } + }); +}; + +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") { + if (hasCompleter && !util.getCompletionPrefix(editor)) + editor.completer.detach(); + } + else if (e.command.name === "insertstring") { + var prefix = util.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.autoInsert = false; + editor.completer.showPopup(editor); + } + } +}; + +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + enableBasicAutocompletion: { + set: function(val) { + if (val) { + if (!this.completers) + this.completers = Array.isArray(val)? val: completers; + this.commands.addCommand(Autocomplete.startCommand); + } else { + this.commands.removeCommand(Autocomplete.startCommand); + } + }, + value: false + }, + /** + * Enable live autocomplete. If the value is an array, it is assumed to be an array of completers + * and will use them instead of the default completers. + */ + enableLiveAutocompletion: { + set: function(val) { + if (val) { + if (!this.completers) + this.completers = Array.isArray(val)? val: completers; + // On each change automatically trigger the autocomplete + this.commands.on('afterExec', doLiveAutocomplete); + } else { + this.commands.removeListener('afterExec', doLiveAutocomplete); + } + }, + value: false + }, + enableSnippets: { + set: function(val) { + if (val) { + this.commands.addCommand(expandSnippet); + this.on("changeMode", onChangeMode); + onChangeMode(null, this); + } else { + this.commands.removeCommand(expandSnippet); + this.off("changeMode", onChangeMode); + } + }, + value: false + } +}); +}); diff --git a/public/lib/ace/ext/linking.js b/public/lib/ace/ext/linking.js new file mode 100644 index 0000000..836f9f6 --- /dev/null +++ b/public/lib/ace/ext/linking.js @@ -0,0 +1,87 @@ +/* ***** 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) { + +var Editor = require("ace/editor").Editor; + +require("../config").defineOptions(Editor.prototype, "editor", { + enableLinking: { + set: function(val) { + if (val) { + this.on("click", onClick); + this.on("mousemove", onMouseMove); + } else { + this.off("click", onClick); + this.off("mousemove", onMouseMove); + } + }, + value: false + } +}); + +exports.previousLinkingHover = false; + +function onMouseMove(e) { + var editor = e.editor; + var ctrl = e.getAccelKey(); + + if (ctrl) { + var editor = e.editor; + var docPos = e.getDocumentPosition(); + var session = editor.session; + var token = session.getTokenAt(docPos.row, docPos.column); + + if (exports.previousLinkingHover && exports.previousLinkingHover != token) { + editor._emit("linkHoverOut"); + } + editor._emit("linkHover", {position: docPos, token: token}); + exports.previousLinkingHover = token; + } else if (exports.previousLinkingHover) { + editor._emit("linkHoverOut"); + exports.previousLinkingHover = false; + } +} + +function onClick(e) { + var ctrl = e.getAccelKey(); + var button = e.getButton(); + + if (button == 0 && ctrl) { + var editor = e.editor; + var docPos = e.getDocumentPosition(); + var session = editor.session; + var token = session.getTokenAt(docPos.row, docPos.column); + + editor._emit("linkClick", {position: docPos, token: token}); + } +} + +}); diff --git a/public/lib/ace/ext/menu_tools/add_editor_menu_options.js b/public/lib/ace/ext/menu_tools/add_editor_menu_options.js new file mode 100644 index 0000000..eb90e31 --- /dev/null +++ b/public/lib/ace/ext/menu_tools/add_editor_menu_options.js @@ -0,0 +1,109 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl + * All rights reserved. + * + * Contributed to Ajax.org under the BSD license. + * + * 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 ***** */ + +/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +/*global define, require */ + +/** + * Add Editor Menu Options + * @fileOverview Add Editor Menu Options
+ * The menu options property needs to be added to the editor + * so that the settings menu can know about options for + * selection elements and track which option is selected. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + +define(function(require, exports, module) { +'use strict'; + +/** + * The menu options property needs to be added to the editor + * so that the settings menu can know about options for + * selection elements and track which option is selected. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {ace.Editor} editor An instance of the ace editor. + */ +module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) { + var modelist = require('../modelist'); + var themelist = require('../themelist'); + editor.menuOptions = { + setNewLineMode: [{ + textContent: "unix", + value: "unix" + }, { + textContent: "windows", + value: "windows" + }, { + textContent: "auto", + value: "auto" + }], + setTheme: [], + setMode: [], + setKeyboardHandler: [{ + textContent: "ace", + value: "" + }, { + textContent: "vim", + value: "ace/keyboard/vim" + }, { + 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 + }; + }); + + editor.menuOptions.setMode = modelist.modes.map(function(mode) { + return { + textContent: mode.name, + value: mode.mode + }; + }); +}; + + +}); diff --git a/public/lib/ace/ext/menu_tools/element_generator.js b/public/lib/ace/ext/menu_tools/element_generator.js new file mode 100644 index 0000000..ec6ba93 --- /dev/null +++ b/public/lib/ace/ext/menu_tools/element_generator.js @@ -0,0 +1,148 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl + * All rights reserved. + * + * Contributed to Ajax.org under the BSD license. + * + * 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 ***** */ + +/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +/*global define, require */ + +/** + * Element Generator + * @fileOverview Element Generator
+ * Contains methods for generating elements. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + +define(function(require, exports, module) { +'use strict'; +/** + * Creates a DOM option element + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {object} obj An object containing properties to add to the dom + * element. If one of those properties is named `selected` then it will be + * added as an attribute on the element instead. + */ +module.exports.createOption = function createOption (obj) { + var attribute; + var el = document.createElement('option'); + for(attribute in obj) { + if(obj.hasOwnProperty(attribute)) { + if(attribute === 'selected') { + el.setAttribute(attribute, obj[attribute]); + } else { + el[attribute] = obj[attribute]; + } + } + } + return el; +}; +/** + * Creates a DOM checkbox element. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {string} id The id of the element. + * @param {boolean} checked Whether or not the element is checked. + * @param {string} clss The class of the element. + * @returns {DOMElement} Returns a checkbox element reference. + */ +module.exports.createCheckbox = function createCheckbox (id, checked, clss) { + var el = document.createElement('input'); + el.setAttribute('type', 'checkbox'); + el.setAttribute('id', id); + el.setAttribute('name', id); + el.setAttribute('value', checked); + el.setAttribute('class', clss); + if(checked) { + el.setAttribute('checked', 'checked'); + } + return el; +}; +/** + * Creates a DOM text input element. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {string} id The id of the element. + * @param {string} value The default value of the input element. + * @param {string} clss The class of the element. + * @returns {DOMElement} Returns an input element reference. + */ +module.exports.createInput = function createInput (id, value, clss) { + var el = document.createElement('input'); + el.setAttribute('type', 'text'); + el.setAttribute('id', id); + el.setAttribute('name', id); + el.setAttribute('value', value); + el.setAttribute('class', clss); + return el; +}; +/** + * Creates a DOM label element. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {string} text The label text. + * @param {string} labelFor The id of the element being labeled. + * @returns {DOMElement} Returns a label element reference. + */ +module.exports.createLabel = function createLabel (text, labelFor) { + var el = document.createElement('label'); + el.setAttribute('for', labelFor); + el.textContent = text; + return el; +}; +/** + * Creates a DOM selection element. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {string} id The id of the element. + * @param {string} values An array of objects suitable for `createOption` + * @param {string} clss The class of the element. + * @returns {DOMElement} Returns a selection element reference. + * @see ace/ext/element_generator.createOption + */ +module.exports.createSelection = function createSelection (id, values, clss) { + var el = document.createElement('select'); + el.setAttribute('id', id); + el.setAttribute('name', id); + el.setAttribute('class', clss); + values.forEach(function(item) { + el.appendChild(module.exports.createOption(item)); + }); + return el; +}; + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/menu_tools/generate_settings_menu.js b/public/lib/ace/ext/menu_tools/generate_settings_menu.js new file mode 100644 index 0000000..a15c26d --- /dev/null +++ b/public/lib/ace/ext/menu_tools/generate_settings_menu.js @@ -0,0 +1,264 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl + * All rights reserved. + * + * Contributed to Ajax.org under the BSD license. + * + * 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 ***** */ + +/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +/*global define*/ + +/** + * Generates the settings menu + * @fileOverview Generates the settings menu. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + +define(function(require, exports, module) { +'use strict'; +var egen = require('./element_generator'); +var addEditorMenuOptions = require('./add_editor_menu_options').addEditorMenuOptions; +var getSetFunctions = require('./get_set_functions').getSetFunctions; + +/** + * Generates an interactive menu with settings useful to end users. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {ace.Editor} editor An instance of the ace editor. + */ +module.exports.generateSettingsMenu = function generateSettingsMenu (editor) { + /** + * container for dom elements that will go in the menu. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + var elements = []; + /** + * Sorts the menu entries (elements var) so they'll appear in alphabetical order + * the sort is performed based on the value of the contains property + * of each element. Since this is an `array.sort` the array is sorted + * in place. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + function cleanupElementsList() { + elements.sort(function(a, b) { + var x = a.getAttribute('contains'); + var y = b.getAttribute('contains'); + return x.localeCompare(y); + }); + } + /** + * Wraps all dom elements contained in the elements var with a single + * div. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + function wrapElements() { + var topmenu = document.createElement('div'); + topmenu.setAttribute('id', 'ace_settingsmenu'); + elements.forEach(function(element) { + topmenu.appendChild(element); + }); + + var el = topmenu.appendChild(document.createElement('div')); + var version = require("../../ace").version; + el.style.padding = "1em"; + el.textContent = "Ace version " + version; + + return topmenu; + } + /** + * Creates a new menu entry. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {object} obj This is a reference to the object containing the + * set function. It is used to set up event listeners for when the + * menu options change. + * @param {string} clss Maps to the class of the dom element. This is + * the name of the object containing the set function e.g. `editor`, + * `session`, `renderer`. + * @param {string} item This is the set function name. It maps to the + * id of the dom element (check, select, input) and to the "contains" + * attribute of the div holding both the element and its label. + * @param {mixed} val This is the value of the setting. It is mapped to + * the dom element's value, checked, or selected option accordingly. + */ + function createNewEntry(obj, clss, item, val) { + var el; + var div = document.createElement('div'); + div.setAttribute('contains', item); + div.setAttribute('class', 'ace_optionsMenuEntry'); + div.setAttribute('style', 'clear: both;'); + + div.appendChild(egen.createLabel( + item.replace(/^set/, '').replace(/([A-Z])/g, ' $1').trim(), + item + )); + + if (Array.isArray(val)) { + el = egen.createSelection(item, val, clss); + el.addEventListener('change', function(e) { + try{ + editor.menuOptions[e.target.id].forEach(function(x) { + if(x.textContent !== e.target.textContent) { + delete x.selected; + } + }); + obj[e.target.id](e.target.value); + } catch (err) { + throw new Error(err); + } + }); + } else if(typeof val === 'boolean') { + el = egen.createCheckbox(item, val, clss); + el.addEventListener('change', function(e) { + try{ + // renderer['setHighlightGutterLine'](true); + obj[e.target.id](!!e.target.checked); + } catch (err) { + throw new Error(err); + } + }); + } else { + // this aids in giving the ability to specify settings through + // post and get requests. + // /ace_editor.html?setMode=ace/mode/html&setOverwrite=true + el = egen.createInput(item, val, clss); + el.addEventListener('change', function(e) { + try{ + if(e.target.value === 'true') { + obj[e.target.id](true); + } else if(e.target.value === 'false') { + obj[e.target.id](false); + } else { + obj[e.target.id](e.target.value); + } + } catch (err) { + throw new Error(err); + } + }); + } + el.style.cssText = 'float:right;'; + div.appendChild(el); + return div; + } + /** + * Generates selection fields for the menu and populates their options + * using information from `editor.menuOptions` + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {string} item The set function name. + * @param {object} esr A reference to the object having the set function. + * @param {string} clss The name of the object containing the set function. + * @param {string} fn The matching get function's function name. + * @returns {DOMElement} Returns a dom element containing a selection + * element populated with options. The option whose value matches that + * returned from `esr[fn]()` will be selected. + */ + function makeDropdown(item, esr, clss, fn) { + var val = editor.menuOptions[item]; + var currentVal = esr[fn](); + if (typeof currentVal == 'object') + currentVal = currentVal.$id; + val.forEach(function(valuex) { + if (valuex.value === currentVal) + valuex.selected = 'selected'; + }); + return createNewEntry(esr, clss, item, val); + } + /** + * Processes the set functions returned from `getSetFunctions`. First it + * checks for menu options defined in `editor.menuOptions`. If no + * options are specified then it checks whether there is a get function + * (replace set with get) for the setting. When either of those + * conditions are met it will attempt to create a new entry for the + * settings menu and push it into the elements array defined above. + * It can only do so for get functions which return + * strings, numbers, and booleans. A special case is written in for + * `getMode` where it looks at the returned objects `$id` property and + * forwards that through instead. Other special cases could be written + * in but that would get a bit ridiculous. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {object} setObj An item from the array returned by + * `getSetFunctions`. + */ + function handleSet(setObj) { + var item = setObj.functionName; + var esr = setObj.parentObj; + var clss = setObj.parentName; + var val; + var fn = item.replace(/^set/, 'get'); + if(editor.menuOptions[item] !== undefined) { + // has options for select element + elements.push(makeDropdown(item, esr, clss, fn)); + } else if(typeof esr[fn] === 'function') { + // has get function + try { + val = esr[fn](); + if(typeof val === 'object') { + // setMode takes a string, getMode returns an object + // the $id property of that object is the string + // which may be given to setMode... + val = val.$id; + } + // the rest of the get functions return strings, + // booleans, or numbers. + elements.push( + createNewEntry(esr, clss, item, val) + ); + } catch (e) { + // if there are errors it is because the element + // does not belong in the settings menu + } + } + } + addEditorMenuOptions(editor); + // gather the set functions + getSetFunctions(editor).forEach(function(setObj) { + // populate the elements array with good stuff. + handleSet(setObj); + }); + // sort the menu entries in the elements list so people can find + // the settings in alphabetical order. + cleanupElementsList(); + // dump the entries from the elements list and wrap them up in a div + return wrapElements(); +}; + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js b/public/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js new file mode 100644 index 0000000..c3f7a62 --- /dev/null +++ b/public/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js @@ -0,0 +1,91 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl + * All rights reserved. + * + * Contributed to Ajax.org under the BSD license. + * + * 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 ***** */ + +/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +/*global define, require */ + +/** + * Get Editor Keyboard Shortcuts + * @fileOverview Get Editor Keyboard Shortcuts
+ * Gets a map of keyboard shortcuts to command names for the current platform. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + +define(function(require, exports, module) { +"use strict"; +var keys = require("../../lib/keys"); + +/** + * Gets a map of keyboard shortcuts to command names for the current platform. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {ace.Editor} editor An editor instance. + * @returns {Array} Returns an array of objects representing the keyboard + * shortcuts for the given editor. + * @example + * var getKbShortcuts = require('./get_keyboard_shortcuts'); + * console.log(getKbShortcuts(editor)); + * // [ + * // {'command' : aCommand, 'key' : 'Control-d'}, + * // {'command' : aCommand, 'key' : 'Control-d'} + * // ] + */ +module.exports.getEditorKeybordShortcuts = function(editor) { + var KEY_MODS = keys.KEY_MODS; + var keybindings = []; + var commandMap = {}; + editor.keyBinding.$handlers.forEach(function(handler) { + var ckb = handler.commandKeyBinding; + for (var i in ckb) { + 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 += "|" + key; + } else { + commandMap[command] = {key: key, command: command}; + keybindings.push(commandMap[command]); + } + }); + } + }); + return keybindings; +}; + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/menu_tools/get_set_functions.js b/public/lib/ace/ext/menu_tools/get_set_functions.js new file mode 100644 index 0000000..4cd6550 --- /dev/null +++ b/public/lib/ace/ext/menu_tools/get_set_functions.js @@ -0,0 +1,141 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl + * All rights reserved. + * + * Contributed to Ajax.org under the BSD license. + * + * 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 ***** */ + +/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true */ +/*global define*/ + +/** + * Get Set Functions + * @fileOverview Get Set Functions
+ * Gets various functions for setting settings. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + +define(function(require, exports, module) { +'use strict'; +/** + * Generates a list of set functions for the settings menu. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {object} editor The editor instance + * @return {array} Returns an array of objects. Each object contains the + * following properties: functionName, parentObj, and parentName. The + * function name will be the name of a method beginning with the string + * `set` which was found. The parent object will be a reference to the + * object having the method matching the function name. The parent name + * will be a string representing the identifier of the parent object e.g. + * `editor`, `session`, or `renderer`. + */ +module.exports.getSetFunctions = function getSetFunctions (editor) { + /** + * Output array. Will hold the objects described above. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + var out = []; + /** + * This object provides a map between the objects which will be + * traversed and the parent name which will appear in the output. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + var my = { + 'editor' : editor, + 'session' : editor.session, + 'renderer' : editor.renderer + }; + /** + * This array will hold the set function names which have already been + * found so that they are not added to the output multiple times. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + var opts = []; + /** + * This is a list of set functions which will not appear in the settings + * menu. I don't know what to do with setKeyboardHandler. When I tried + * to use it, it didn't appear to be working. Someone who knows better + * could remove it from this list and add it's options to + * add_editor_menu_options.js + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + var skip = [ + 'setOption', + 'setUndoManager', + 'setDocument', + 'setValue', + 'setBreakpoints', + 'setScrollTop', + 'setScrollLeft', + 'setSelectionStyle', + 'setWrapLimitRange' + ]; + + + /** + * This will search the objects mapped to the `my` variable above. When + * it finds a set function in the object that is not listed in the + * `skip` list or the `opts` list it will push a new object to the + * output array. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + ['renderer', 'session', 'editor'].forEach(function(esra) { + var esr = my[esra]; + var clss = esra; + for(var fn in esr) { + if(skip.indexOf(fn) === -1) { + if(/^set/.test(fn) && opts.indexOf(fn) === -1) { + // found set function + opts.push(fn); + out.push({ + 'functionName' : fn, + 'parentObj' : esr, + 'parentName' : clss + }); + } + } + } + }); + return out; +}; + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/menu_tools/overlay_page.js b/public/lib/ace/ext/menu_tools/overlay_page.js new file mode 100644 index 0000000..bf985e2 --- /dev/null +++ b/public/lib/ace/ext/menu_tools/overlay_page.js @@ -0,0 +1,116 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl + * All rights reserved. + * + * Contributed to Ajax.org under the BSD license. + * + * 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 ***** */ + +/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +/*global define, require */ + +/** + * Overlay Page + * @fileOverview Overlay Page
+ * Generates an overlay for displaying menus. The overlay is an absolutely + * positioned div. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + +define(function(require, exports, module) { +'use strict'; +var dom = require("../../lib/dom"); +var cssText = require("../../requirejs/text!./settings_menu.css"); +dom.importCssString(cssText); + +/** + * Generates an overlay for displaying menus. The overlay is an absolutely + * positioned div. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {DOMElement} contentElement Any element which may be presented inside + * a div. + * @param {string|number} top absolute position value. + * @param {string|number} right absolute position value. + * @param {string|number} bottom absolute position value. + * @param {string|number} left absolute position value. + */ +module.exports.overlayPage = function overlayPage(editor, contentElement, top, right, bottom, left) { + top = top ? 'top: ' + top + ';' : ''; + bottom = bottom ? 'bottom: ' + bottom + ';' : ''; + right = right ? 'right: ' + right + ';' : ''; + left = left ? 'left: ' + left + ';' : ''; + + var closer = document.createElement('div'); + var contentContainer = document.createElement('div'); + + function documentEscListener(e) { + if (e.keyCode === 27) { + closer.click(); + } + } + + closer.style.cssText = 'margin: 0; padding: 0; ' + + 'position: fixed; top:0; bottom:0; left:0; right:0;' + + 'z-index: 9990; ' + + 'background-color: rgba(0, 0, 0, 0.3);'; + closer.addEventListener('click', function() { + document.removeEventListener('keydown', documentEscListener); + closer.parentNode.removeChild(closer); + editor.focus(); + closer = null; + }); + // click closer if esc key is pressed + document.addEventListener('keydown', documentEscListener); + + contentContainer.style.cssText = top + right + bottom + left; + contentContainer.addEventListener('click', function(e) { + e.stopPropagation(); + }); + + var wrapper = dom.createElement("div"); + wrapper.style.position = "relative"; + + var closeButton = dom.createElement("div"); + closeButton.className = "ace_closeButton"; + closeButton.addEventListener('click', function() { + closer.click(); + }); + + wrapper.appendChild(closeButton); + contentContainer.appendChild(wrapper); + + contentContainer.appendChild(contentElement); + closer.appendChild(contentContainer); + document.body.appendChild(closer); + editor.blur(); +}; + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/menu_tools/settings_menu.css b/public/lib/ace/ext/menu_tools/settings_menu.css new file mode 100644 index 0000000..f8b761c --- /dev/null +++ b/public/lib/ace/ext/menu_tools/settings_menu.css @@ -0,0 +1,48 @@ +#ace_settingsmenu, #kbshortcutmenu { + background-color: #F7F7F7; + color: black; + box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55); + padding: 1em 0.5em 2em 1em; + overflow: auto; + position: absolute; + margin: 0; + bottom: 0; + right: 0; + top: 0; + z-index: 9991; + cursor: default; +} + +.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu { + box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25); + background-color: rgba(255, 255, 255, 0.6); + color: black; +} + +.ace_optionsMenuEntry:hover { + background-color: rgba(100, 100, 100, 0.1); + -webkit-transition: all 0.5s; + transition: all 0.3s +} + +.ace_closeButton { + background: rgba(245, 146, 146, 0.5); + border: 1px solid #F48A8A; + border-radius: 50%; + padding: 7px; + position: absolute; + right: -8px; + top: -8px; + z-index: 1000; +} +.ace_closeButton{ + background: rgba(245, 146, 146, 0.9); +} +.ace_optionsMenuKey { + color: darkslateblue; + font-weight: bold; +} +.ace_optionsMenuCommand { + color: darkcyan; + font-weight: normal; +} \ No newline at end of file diff --git a/public/lib/ace/ext/modelist.js b/public/lib/ace/ext/modelist.js new file mode 100644 index 0000000..a7dc98d --- /dev/null +++ b/public/lib/ace/ext/modelist.js @@ -0,0 +1,220 @@ +define(function(require, exports, module) { +"use strict"; + +var modes = []; +/** + * Suggests a mode based on the file extension present in the given path + * @param {string} path The path to the file + * @returns {object} Returns an object containing information about the + * suggested mode. + */ +function getModeForPath(path) { + var mode = modesByName.text; + var fileName = path.split(/[\/\\]/).pop(); + for (var i = 0; i < modes.length; i++) { + if (modes[i].supportsFile(fileName)) { + mode = modes[i]; + break; + } + } + return mode; +} + +var Mode = function(name, caption, extensions) { + this.name = name; + this.caption = caption; + this.mode = "ace/mode/" + name; + this.extensions = extensions; + var re; + if (/\^/.test(extensions)) { + re = extensions.replace(/\|(\^)?/g, function(a, b){ + return "$|" + (b ? "^" : "^.*\\."); + }) + "$"; + } else { + re = "^.*\\.(" + extensions + ")$"; + } + + this.extRe = new RegExp(re, "gi"); +}; + +Mode.prototype.supportsFile = function(filename) { + return filename.match(this.extRe); +}; + +// todo firstlinematch +var supportedModes = { + ABAP: ["abap"], + ABC: ["abc"], + ActionScript:["as"], + ADA: ["ada|adb"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + AsciiDoc: ["asciidoc|adoc"], + Assembly_x86:["asm|a"], + AutoHotKey: ["ahk"], + BatchFile: ["bat|cmd"], + Bro: ["bro"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], + C9Search: ["c9search_results"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], + ColdFusion: ["cfm"], + CSharp: ["cs"], + Csound_Document: ["csd"], + Csound_Orchestra: ["orc"], + Csound_Score: ["sco"], + CSS: ["css"], + Curly: ["curly"], + D: ["d|di"], + Dart: ["dart"], + Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], + Dot: ["dot"], + Drools: ["drl"], + Eiffel: ["e|ge"], + EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], + Forth: ["frt|fs|ldr|fth|4th"], + Fortran: ["f|f90"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], + Glsl: ["glsl|frag|vert"], + Gobstones: ["gbs"], + golang: ["go"], + GraphQLSchema: ["gql"], + Groovy: ["groovy"], + HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], + Haskell: ["hs"], + Haskell_Cabal: ["cabal"], + haXe: ["hx"], + Hjson: ["hjson"], + HTML: ["html|htm|xhtml|vue|we|wpy"], + HTML_Elixir: ["eex|html.eex"], + HTML_Ruby: ["erb|rhtml|html.erb"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Jack: ["jack"], + Jade: ["jade|pug"], + Java: ["java"], + JavaScript: ["js|jsm|jsx"], + JSON: ["json"], + JSONiq: ["jq"], + JSP: ["jsp"], + JSSM: ["jssm|jssm_state"], + JSX: ["jsx"], + Julia: ["jl"], + Kotlin: ["kt|kts"], + LaTeX: ["tex|latex|ltx|bib"], + LESS: ["less"], + Liquid: ["liquid"], + Lisp: ["lisp"], + LiveScript: ["ls"], + LogiQL: ["logic|lql"], + LSL: ["lsl"], + Lua: ["lua"], + LuaPage: ["lp"], + Lucene: ["lucene"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], + Markdown: ["md|markdown"], + Mask: ["mask"], + MATLAB: ["matlab"], + Maze: ["mz"], + MEL: ["mel"], + MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nix: ["nix"], + NSIS: ["nsi|nsh"], + ObjectiveC: ["m|mm"], + OCaml: ["ml|mli"], + Pascal: ["pas|p"], + Perl: ["pl|pm"], + pgSQL: ["pgsql"], + PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], + Pig: ["pig"], + Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], + Prolog: ["plg|prolog"], + Properties: ["properties"], + Protobuf: ["proto"], + Python: ["py"], + R: ["r"], + Razor: ["cshtml|asp"], + RDoc: ["Rd"], + Red: ["red|reds"], + RHTML: ["Rhtml"], + RST: ["rst"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], + Rust: ["rs"], + SASS: ["sass"], + SCAD: ["scad"], + Scala: ["scala"], + Scheme: ["scm|sm|rkt|oak|scheme"], + SCSS: ["scss"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Smarty: ["smarty|tpl"], + snippets: ["snippets"], + Soy_Template:["soy"], + Space: ["space"], + SQL: ["sql"], + SQLServer: ["sqlserver"], + Stylus: ["styl|stylus"], + SVG: ["svg"], + Swift: ["swift"], + Tcl: ["tcl"], + Tex: ["tex"], + Text: ["txt"], + Textile: ["textile"], + Toml: ["toml"], + TSX: ["tsx"], + Twig: ["twig|swig"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], + Velocity: ["vm"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + Wollok: ["wlk|wpgm|wtest"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], + XQuery: ["xq"], + 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 and C++", + Csound_Document: "Csound Document", + Csound_Orchestra: "Csound", + Csound_Score: "Csound Score", + coffee: "CoffeeScript", + HTML_Ruby: "HTML (Ruby)", + HTML_Elixir: "HTML (Elixir)", + FTL: "FreeMarker" +}; +var modesByName = {}; +for (var name in supportedModes) { + var data = supportedModes[name]; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); + var filename = name.toLowerCase(); + var mode = new Mode(filename, displayName, data[0]); + modesByName[filename] = mode; + modes.push(mode); +} + +module.exports = { + getModeForPath: getModeForPath, + modes: modes, + modesByName: modesByName +}; + +}); diff --git a/public/lib/ace/ext/searchbox.css b/public/lib/ace/ext/searchbox.css new file mode 100644 index 0000000..0bdf8cf --- /dev/null +++ b/public/lib/ace/ext/searchbox.css @@ -0,0 +1,162 @@ + + +/* ------------------------------------------------------------------------------------------ + * Editor Search Form + * --------------------------------------------------------------------------------------- */ +.ace_search { + background-color: #ddd; + color: #666; + border: 1px solid #cbcbcb; + border-top: 0 none; + overflow: hidden; + margin: 0; + padding: 4px 6px 0 4px; + position: absolute; + top: 0; + z-index: 99; + white-space: normal; +} +.ace_search.left { + border-left: 0 none; + border-radius: 0px 0px 5px 0px; + left: 0; +} +.ace_search.right { + border-radius: 0px 0px 0px 5px; + border-right: 0 none; + right: 0; +} + +.ace_search_form, .ace_replace_form { + margin: 0 20px 4px 0; + overflow: hidden; + line-height: 1.9; +} +.ace_replace_form { + margin-right: 0; +} +.ace_search_form.ace_nomatch { + outline: 1px solid red; +} + +.ace_search_field { + border-radius: 3px 0 0 3px; + background-color: white; + color: black; + border: 1px solid #cbcbcb; + border-right: 0 none; + box-sizing: border-box!important; + outline: 0; + padding: 0; + font-size: inherit; + margin: 0; + line-height: inherit; + padding: 0 6px; + min-width: 17em; + vertical-align: top; +} +.ace_searchbtn { + border: 1px solid #cbcbcb; + line-height: inherit; + display: inline-block; + padding: 0 6px; + background: #fff; + border-right: 0 none; + border-left: 1px solid #dcdcdc; + cursor: pointer; + margin: 0; + position: relative; + box-sizing: content-box!important; + color: #666; +} +.ace_searchbtn:last-child { + border-radius: 0 3px 3px 0; + border-right: 1px solid #cbcbcb; +} +.ace_searchbtn:disabled { + background: none; + cursor: default; +} +.ace_searchbtn:hover { + background-color: #eef1f6; +} +.ace_searchbtn.prev, .ace_searchbtn.next { + padding: 0px 0.7em +} +.ace_searchbtn.prev:after, .ace_searchbtn.next:after { + content: ""; + border: solid 2px #888; + width: 0.5em; + height: 0.5em; + border-width: 2px 0 0 2px; + display:inline-block; + transform: rotate(-45deg); +} +.ace_searchbtn.next:after { + border-width: 0 2px 2px 0 ; +} +.ace_searchbtn_close { + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0; + border-radius: 50%; + border: 0 none; + color: #656565; + cursor: pointer; + font: 16px/16px Arial; + padding: 0; + height: 14px; + width: 14px; + top: 9px; + right: 7px; + position: absolute; +} +.ace_searchbtn_close:hover { + background-color: #656565; + background-position: 50% 100%; + color: white; +} + +.ace_button { + margin-left: 2px; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -o-user-select: none; + -ms-user-select: none; + user-select: none; + overflow: hidden; + opacity: 0.7; + border: 1px solid rgba(100,100,100,0.23); + padding: 1px; + box-sizing: border-box!important; + color: black; +} + +.ace_button:hover { + background-color: #eee; + opacity:1; +} +.ace_button:active { + background-color: #ddd; +} + +.ace_button.checked { + border-color: #3399ff; + opacity:1; +} + +.ace_search_options{ + margin-bottom: 3px; + text-align: right; + -webkit-user-select: none; + -moz-user-select: none; + -o-user-select: none; + -ms-user-select: none; + user-select: none; + clear: both; +} + +.ace_search_counter { + float: left; + font-family: arial; + padding: 0 8px; +} \ No newline at end of file diff --git a/public/lib/ace/ext/searchbox.js b/public/lib/ace/ext/searchbox.js new file mode 100644 index 0000000..854bc23 --- /dev/null +++ b/public/lib/ace/ext/searchbox.js @@ -0,0 +1,399 @@ +/* ***** 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 dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var event = require("../lib/event"); +var searchboxCss = require("../requirejs/text!./searchbox.css"); +var HashHandler = require("../keyboard/hash_handler").HashHandler; +var keyUtil = require("../lib/keys"); + +var MAX_COUNT = 999; + +dom.importCssString(searchboxCss, "ace_searchbox"); + +var html = ''.replace(/> +/g, ">"); + +var SearchBox = function(editor, range, showReplaceForm) { + var div = dom.createElement("div"); + div.innerHTML = html; + this.element = div.firstChild; + + this.setSession = this.setSession.bind(this); + + this.$init(); + this.setEditor(editor); +}; + +(function() { + this.setEditor = function(editor) { + editor.searchBox = this; + editor.renderer.scroller.appendChild(this.element); + this.editor = editor; + }; + + this.setSession = function(e) { + this.searchRange = null; + this.$syncOptions(true); + }; + + this.$initElements = function(sb) { + this.searchBox = sb.querySelector(".ace_search_form"); + this.replaceBox = sb.querySelector(".ace_replace_form"); + this.searchOption = sb.querySelector("[action=searchInSelection]"); + this.replaceOption = sb.querySelector("[action=toggleReplace]"); + this.regExpOption = sb.querySelector("[action=toggleRegexpMode]"); + this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]"); + this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]"); + this.searchInput = this.searchBox.querySelector(".ace_search_field"); + this.replaceInput = this.replaceBox.querySelector(".ace_search_field"); + this.searchCounter = sb.querySelector(".ace_search_counter"); + }; + + this.$init = function() { + var sb = this.element; + + this.$initElements(sb); + + var _this = this; + event.addListener(sb, "mousedown", function(e) { + setTimeout(function(){ + _this.activeInput.focus(); + }, 0); + event.stopPropagation(e); + }); + event.addListener(sb, "click", function(e) { + var t = e.target || e.srcElement; + var action = t.getAttribute("action"); + if (action && _this[action]) + _this[action](); + else if (_this.$searchBarKb.commands[action]) + _this.$searchBarKb.commands[action].exec(_this); + event.stopPropagation(e); + }); + + event.addCommandKeyListener(sb, function(e, hashId, keyCode) { + var keyString = keyUtil.keyCodeToString(keyCode); + var command = _this.$searchBarKb.findKeyCommand(hashId, keyString); + if (command && command.exec) { + command.exec(_this); + event.stopEvent(e); + } + }); + + this.$onChange = lang.delayedCall(function() { + _this.find(false, false); + }); + + event.addListener(this.searchInput, "input", function() { + _this.$onChange.schedule(20); + }); + event.addListener(this.searchInput, "focus", function() { + _this.activeInput = _this.searchInput; + _this.searchInput.value && _this.highlight(); + }); + event.addListener(this.replaceInput, "focus", function() { + _this.activeInput = _this.replaceInput; + _this.searchInput.value && _this.highlight(); + }); + }; + + //keybinding outside of the searchbox + this.$closeSearchBarKb = new HashHandler([{ + bindKey: "Esc", + name: "closeSearchBar", + exec: function(editor) { + editor.searchBox.hide(); + } + }]); + + //keybinding outside of the searchbox + this.$searchBarKb = new HashHandler(); + this.$searchBarKb.bindKeys({ + "Ctrl-f|Command-f": function(sb) { + var isReplace = sb.isReplace = !sb.isReplace; + sb.replaceBox.style.display = isReplace ? "" : "none"; + sb.replaceOption.checked = false; + sb.$syncOptions(); + sb.searchInput.focus(); + }, + "Ctrl-H|Command-Option-F": function(sb) { + sb.replaceOption.checked = true; + sb.$syncOptions(); + sb.replaceInput.focus(); + }, + "Ctrl-G|Command-G": function(sb) { + sb.findNext(); + }, + "Ctrl-Shift-G|Command-Shift-G": function(sb) { + sb.findPrev(); + }, + "esc": function(sb) { + setTimeout(function() { sb.hide();}); + }, + "Return": function(sb) { + if (sb.activeInput == sb.replaceInput) + sb.replace(); + sb.findNext(); + }, + "Shift-Return": function(sb) { + if (sb.activeInput == sb.replaceInput) + 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(); + } + }); + + this.$searchBarKb.addCommands([{ + name: "toggleRegexpMode", + bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"}, + exec: function(sb) { + sb.regExpOption.checked = !sb.regExpOption.checked; + sb.$syncOptions(); + } + }, { + name: "toggleCaseSensitive", + bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"}, + exec: function(sb) { + sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked; + sb.$syncOptions(); + } + }, { + name: "toggleWholeWords", + bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"}, + exec: function(sb) { + sb.wholeWordOption.checked = !sb.wholeWordOption.checked; + sb.$syncOptions(); + } + }, { + name: "toggleReplace", + exec: function(sb) { + sb.replaceOption.checked = !sb.replaceOption.checked; + sb.$syncOptions(); + } + }, { + name: "searchInSelection", + exec: function(sb) { + sb.searchOption.checked = !sb.searchRange; + sb.setSearchRange(sb.searchOption.checked && sb.editor.getSelectionRange()); + sb.$syncOptions(); + } + }]); + + this.setSearchRange = function(range) { + this.searchRange = range; + if (range) { + this.searchRangeMarker = this.editor.session.addMarker(range, "ace_active-line"); + } else if (this.searchRangeMarker) { + this.editor.session.removeMarker(this.searchRangeMarker); + this.searchRangeMarker = null; + } + }; + + this.$syncOptions = function(preventScroll) { + dom.setCssClass(this.replaceOption, "checked", this.searchRange); + dom.setCssClass(this.searchOption, "checked", this.searchOption.checked); + this.replaceOption.textContent = this.replaceOption.checked ? "-" : "+"; + dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked); + dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked); + dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked); + this.replaceBox.style.display = this.replaceOption.checked ? "" : "none"; + this.find(false, false, preventScroll); + }; + + this.highlight = function(re) { + this.editor.session.highlight(re || this.editor.$search.$options.re); + this.editor.renderer.updateBackMarkers(); + }; + this.find = function(skipCurrent, backwards, preventScroll) { + var range = this.editor.find(this.searchInput.value, { + skipCurrent: skipCurrent, + backwards: backwards, + wrap: true, + regExp: this.regExpOption.checked, + caseSensitive: this.caseSensitiveOption.checked, + wholeWord: this.wholeWordOption.checked, + preventScroll: preventScroll, + range: this.searchRange + }); + var noMatch = !range && this.searchInput.value; + dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); + this.editor._emit("findSearchBox", { match: !noMatch }); + this.highlight(); + this.updateCounter(); + }; + this.updateCounter = function() { + var editor = this.editor; + var regex = editor.$search.$options.re; + var all = 0; + var before = 0; + if (regex) { + var value = this.searchRange + ? editor.session.getTextRange(this.searchRange) + : editor.getValue(); + + var offset = editor.session.doc.positionToIndex(editor.selection.anchor); + if (this.searchRange) + offset -= editor.session.doc.positionToIndex(this.searchRange.start); + + var last = regex.lastIndex = 0; + var m; + while ((m = regex.exec(value))) { + all++; + last = m.index; + if (last <= offset) + before++; + if (all > MAX_COUNT) + break; + if (!m[0]) { + regex.lastIndex = last += 1; + if (last >= value.length) + break; + } + } + } + this.searchCounter.textContent = before + " of " + (all > MAX_COUNT ? MAX_COUNT + "+" : all); + }; + this.findNext = function() { + this.find(true, false); + }; + 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); + }; + this.replaceAndFindNext = function() { + if (!this.editor.getReadOnly()) { + this.editor.replace(this.replaceInput.value); + this.findNext(); + } + }; + this.replaceAll = function() { + if (!this.editor.getReadOnly()) + this.editor.replaceAll(this.replaceInput.value); + }; + + this.hide = function() { + this.active = false; + this.setSearchRange(null); + this.editor.off("changeSession", this.setSession); + + this.element.style.display = "none"; + this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb); + this.editor.focus(); + }; + this.show = function(value, isReplace) { + this.active = true; + this.editor.on("changeSession", this.setSession); + this.element.style.display = ""; + this.replaceOption.checked = isReplace; + + if (value) + this.searchInput.value = value; + + this.searchInput.focus(); + this.searchInput.select(); + + this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb); + + this.$syncOptions(true); + }; + + this.isFocused = function() { + var el = document.activeElement; + return el == this.searchInput || el == this.replaceInput; + }; +}).call(SearchBox.prototype); + +exports.SearchBox = SearchBox; + +exports.Search = function(editor, isReplace) { + var sb = editor.searchBox || new SearchBox(editor); + sb.show(editor.session.getTextRange(), isReplace); +}; + +}); + + +/* ------------------------------------------------------------------------------------------ + * TODO + * --------------------------------------------------------------------------------------- */ +/* +- move search form to the left if it masks current word +- include all options that search has. ex: regex +- searchbox.searchbox is not that pretty. We should have just searchbox +- disable prev button if it makes sense +*/ diff --git a/public/lib/ace/ext/settings_menu.js b/public/lib/ace/ext/settings_menu.js new file mode 100644 index 0000000..44f6d6a --- /dev/null +++ b/public/lib/ace/ext/settings_menu.js @@ -0,0 +1,76 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl + * All rights reserved. + * + * Contributed to Ajax.org under the BSD license. + * + * 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 ***** */ + +/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ +/*global define, require */ + +/** + * Show Settings Menu + * @fileOverview Show Settings Menu
+ * Displays an interactive settings menu mostly generated on the fly based on + * the current state of the editor. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + +define(function(require, exports, module) { +"use strict"; +var generateSettingsMenu = require('./menu_tools/generate_settings_menu').generateSettingsMenu; +var overlayPage = require('./menu_tools/overlay_page').overlayPage; +/** + * This displays the settings menu if it is not already being shown. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + * @param {ace.Editor} editor An instance of the ace editor. + */ +function showSettingsMenu(editor) { + // make sure the menu isn't open already. + var sm = document.getElementById('ace_settingsmenu'); + if (!sm) + overlayPage(editor, generateSettingsMenu(editor), '0', '0', '0'); +} + +/** + * Initializes the settings menu extension. It adds the showSettingsMenu + * method to the given editor object and adds the showSettingsMenu command + * to the editor with appropriate keyboard shortcuts. + * @param {ace.Editor} editor An instance of the Editor. + */ +module.exports.init = function(editor) { + var Editor = require("ace/editor").Editor; + Editor.prototype.showSettingsMenu = function() { + showSettingsMenu(this); + }; +}; +}); \ No newline at end of file diff --git a/public/lib/ace/ext/spellcheck.js b/public/lib/ace/ext/spellcheck.js new file mode 100644 index 0000000..713b905 --- /dev/null +++ b/public/lib/ace/ext/spellcheck.js @@ -0,0 +1,69 @@ +define(function(require, exports, module) { +"use strict"; +var event = require("../lib/event"); + +exports.contextMenuHandler = function(e){ + var host = e.target; + var text = host.textInput.getElement(); + if (!host.selection.isEmpty()) + return; + var c = host.getCursorPosition(); + var r = host.session.getWordRange(c.row, c.column); + var w = host.session.getTextRange(r); + + host.session.tokenRe.lastIndex = 0; + if (!host.session.tokenRe.test(w)) + return; + var PLACEHOLDER = "\x01\x01"; + var value = w + " " + PLACEHOLDER; + text.value = value; + text.setSelectionRange(w.length, w.length + 1); + text.setSelectionRange(0, 0); + text.setSelectionRange(0, w.length); + + var afterKeydown = false; + event.addListener(text, "keydown", function onKeydown() { + event.removeListener(text, "keydown", onKeydown); + afterKeydown = true; + }); + + host.textInput.setInputHandler(function(newVal) { + console.log(newVal , value, text.selectionStart, text.selectionEnd); + if (newVal == value) + return ''; + if (newVal.lastIndexOf(value, 0) === 0) + return newVal.slice(value.length); + if (newVal.substr(text.selectionEnd) == value) + return newVal.slice(0, -value.length); + if (newVal.slice(-2) == PLACEHOLDER) { + var val = newVal.slice(0, -2); + if (val.slice(-1) == " ") { + if (afterKeydown) + return val.substring(0, text.selectionEnd); + val = val.slice(0, -1); + host.session.replace(r, val); + return ""; + } + } + + return newVal; + }); +}; +// todo support highlighting with typo.js +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + spellcheck: { + set: function(val) { + var text = this.textInput.getElement(); + text.spellcheck = !!val; + if (!val) + this.removeListener("nativecontextmenu", exports.contextMenuHandler); + else + this.on("nativecontextmenu", exports.contextMenuHandler); + }, + value: true + } +}); + +}); + diff --git a/public/lib/ace/ext/split.js b/public/lib/ace/ext/split.js new file mode 100644 index 0000000..8316562 --- /dev/null +++ b/public/lib/ace/ext/split.js @@ -0,0 +1,40 @@ +/* ***** 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"; + +/** + * this is experimental, and subject to change, use at your own risk! + */ +module.exports = require("../split"); + +}); + diff --git a/public/lib/ace/ext/static.css b/public/lib/ace/ext/static.css new file mode 100644 index 0000000..51986c3 --- /dev/null +++ b/public/lib/ace/ext/static.css @@ -0,0 +1,38 @@ +.ace_static_highlight { + 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: 2em; + text-align: right; + padding: 0 3px 0 0; + margin-right: 3px; +} + +.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; + top: 0; + bottom: 0; + left: 0; + position: absolute; +} + + +.ace_static_highlight .ace_gutter-cell:before { + content: counter(ace_line, decimal); + counter-increment: ace_line; +} +.ace_static_highlight { + counter-reset: ace_line; +} diff --git a/public/lib/ace/ext/static_highlight.js b/public/lib/ace/ext/static_highlight.js new file mode 100644 index 0000000..fc1928f --- /dev/null +++ b/public/lib/ace/ext/static_highlight.js @@ -0,0 +1,191 @@ +/* ***** 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 EditSession = require("../edit_session").EditSession; +var TextLayer = require("../layer/text").Text; +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+)/); + var mode = opts.mode || m && ("ace/mode/" + m[1]); + if (!mode) + return false; + var theme = opts.theme || "ace/theme/textmate"; + + var data = ""; + var nodes = []; + + if (el.firstElementChild) { + var textLen = 0; + for (var i = 0; i < el.childNodes.length; i++) { + var ch = el.childNodes[i]; + if (ch.nodeType == 3) { + textLen += ch.data.length; + data += ch.data; + } else { + nodes.push(textLen, ch); + } + } + } else { + data = dom.getInnerText(el); + if (opts.trim) + data = data.trim(); + } + + highlight.render(data, mode, theme, opts.firstLineNumber, !opts.showGutter, function (highlighted) { + dom.importCssString(highlighted.css, "ace_highlight"); + el.innerHTML = highlighted.html; + var container = el.firstChild.firstChild; + for (var i = 0; i < nodes.length; i += 2) { + var pos = highlighted.session.doc.indexToPosition(nodes[i]); + var node = nodes[i + 1]; + var lineEl = container.children[pos.row]; + lineEl && lineEl.appendChild(node); + } + callback && callback(); + }); +}; + +/** + * Transforms a given input code snippet into HTML using the given mode + * + * @param {string} input Code snippet + * @param {string|mode} mode String specifying the mode to load such as + * `ace/mode/javascript` or, a mode loaded from `/ace/mode` + * (use 'ServerSideHiglighter.getMode'). + * @param {string|theme} theme String specifying the theme to load such as + * `ace/theme/twilight` or, a theme loaded from `/ace/theme`. + * @param {number} lineStart A number indicating the first line number. Defaults + * to 1. + * @param {boolean} disableGutter Specifies whether or not to disable the gutter. + * `true` disables the gutter, `false` enables the gutter. Defaults to `false`. + * @param {function} callback When specifying the mode or theme as a string, + * this method has no return value and you must specify a callback function. The + * callback will receive the rendered object containing the properties `html` + * 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; + + // if either the theme or the mode were specified as objects + // then we need to lazily load them. + if (typeof theme == "string") { + waiting++; + config.loadModule(['theme', theme], function(m) { + theme = m; + --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] || modeOptions) + modeCache[mode] = new m.Mode(modeOptions); + mode = modeCache[mode]; + --waiting || done(); + }); + } + + // loads or passes the specified mode module then calls renderer + function done() { + var result = highlight.renderSync(input, mode, theme, lineStart, disableGutter); + return callback ? callback(result) : result; + } + 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); + + var session = new EditSession(""); + session.setUseWorker(false); + session.setMode(mode); + + var textLayer = new SimpleTextLayer(); + textLayer.setSession(session); + + session.setValue(input); + + var stringBuilder = []; + var length = session.getLength(); + + for(var ix = 0; ix < length; ix++) { + stringBuilder.push("
"); + if (!disableGutter) + stringBuilder.push("" + /*(ix + lineStart) + */ ""); + textLayer.$renderLine(stringBuilder, ix, true, false); + stringBuilder.push("\n
"); + } + + // let's prepare the whole html + var html = "
" + + "
" + + stringBuilder.join("") + + "
" + + "
"; + + textLayer.destroy(); + + return { + css: baseStyles + theme.cssText, + html: html, + session: session + }; +}; + +module.exports = highlight; +module.exports.highlight = highlight; +}); diff --git a/public/lib/ace/ext/static_highlight_test.js b/public/lib/ace/ext/static_highlight_test.js new file mode 100644 index 0000000..6c1d0a1 --- /dev/null +++ b/public/lib/ace/ext/static_highlight_test.js @@ -0,0 +1,101 @@ +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { +"use strict"; + +var assert = require("assert"); +var highlighter = require("./static_highlight"); +var JavaScriptMode = require("../mode/javascript").Mode; +var TextMode = require("../mode/text").Mode; + +// Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite +module.exports = { + timeout: 10000, + + "test loading in node": function(next) { + assert.equal(typeof window, "undefined"); + require("../ace"); + next(); + }, + + "test simple snippet": function(next) { + var theme = require("../theme/tomorrow"); + var snippet = [ + "/** this is a function", + "*", + "*/", + "function hello (a, b, c) {", + " console.log(a * b + c + 'sup$');", + "}" + ].join("\n"); + var mode = new JavaScriptMode(); + + var result = highlighter.render(snippet, mode, theme); + assert.equal(result.html, "
" + + "
/** this is a function\n
" + + "
*\n
" + + "
*/\n
" + + "
function hello (a, b, c) {\n
" + + "
console.log(a * b + c + 'sup$');\n
" + + "
}\n
" + + "
"); + assert.ok(!!result.css); + next(); + }, + + "test css from theme is used": function(next) { + var theme = require("../theme/tomorrow"); + var snippet = [ + "/** this is a function", + "*", + "*/", + "function hello (a, b, c) {", + " console.log(a * b + c + 'sup?');", + "}" + ].join("\n"); + var mode = new JavaScriptMode(); + + var result = highlighter.render(snippet, mode, theme); + + assert.ok(result.css.indexOf(theme.cssText) !== -1); + + next(); + }, + + "test theme classname should be in output html": function(next) { + var theme = require("../theme/tomorrow"); + var snippet = [ + "/** this is a function", + "*", + "*/", + "function hello (a, b, c) {", + " console.log(a * b + c + 'sup?');", + "}" + ].join("\n"); + var mode = new JavaScriptMode(); + + var result = highlighter.render(snippet, mode, theme); + assert.equal(!!result.html.match(/
/), true); + + next(); + }, + + "test js string replace specials": function(next) { + var theme = require("../theme/tomorrow"); + var snippet = "$'$1$2$$$&"; + var mode = new TextMode(); + + var result = highlighter.render(snippet, mode, theme); + assert.ok(result.html.indexOf(snippet) != -1); + + next(); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/ext/statusbar.js b/public/lib/ace/ext/statusbar.js new file mode 100644 index 0000000..20e1a09 --- /dev/null +++ b/public/lib/ace/ext/statusbar.js @@ -0,0 +1,50 @@ +define(function(require, exports, module) { +"use strict"; +/** simple statusbar **/ +var dom = require("ace/lib/dom"); +var lang = require("ace/lib/lang"); + +var StatusBar = function(editor, parentNode) { + this.element = dom.createElement("div"); + this.element.className = "ace_status-indicator"; + this.element.style.cssText = "display: inline-block;"; + parentNode.appendChild(this.element); + + var statusUpdate = lang.delayedCall(function(){ + this.updateStatus(editor); + }.bind(this)).schedule.bind(null, 100); + + editor.on("changeStatus", statusUpdate); + editor.on("changeSelection", statusUpdate); + editor.on("keyboardActivity", statusUpdate); +}; + +(function(){ + this.updateStatus = function(editor) { + var status = []; + function add(str, separator) { + str && status.push(str, separator || "|"); + } + + add(editor.keyBinding.getStatusText(editor)); + if (editor.commands.recording) + add("REC"); + + var sel = editor.selection; + var c = sel.lead; + + if (!sel.isEmpty()) { + var r = editor.getSelectionRange(); + add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")", " "); + } + add(c.row + ":" + c.column, " "); + if (sel.rangeCount) + add("[" + sel.rangeCount + "]", " "); + status.pop(); + this.element.textContent = status.join(""); + }; +}).call(StatusBar.prototype); + +exports.StatusBar = StatusBar; + +}); \ No newline at end of file diff --git a/public/lib/ace/ext/textarea.js b/public/lib/ace/ext/textarea.js new file mode 100644 index 0000000..4ca4578 --- /dev/null +++ b/public/lib/ace/ext/textarea.js @@ -0,0 +1,521 @@ +/* ***** 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 event = require("../lib/event"); +var UA = require("../lib/useragent"); +var net = require("../lib/net"); +var ace = require("../ace"); + +require("../theme/textmate"); + +module.exports = exports = ace; + +/* + * Returns the CSS property of element. + * 1) If the CSS property is on the style object of the element, use it, OR + * 2) Compute the CSS property + * + * If the property can't get computed, is 'auto' or 'intrinsic', the former + * calculated property is used (this can happen in cases where the textarea + * is hidden and has no dimension styles). + */ +var getCSSProperty = function(element, container, property) { + var ret = element.style[property]; + + if (!ret) { + if (window.getComputedStyle) { + ret = window.getComputedStyle(element, '').getPropertyValue(property); + } else { + ret = element.currentStyle[property]; + } + } + + if (!ret || ret == 'auto' || ret == 'intrinsic') { + ret = container.style[property]; + } + return ret; +}; + +function applyStyles(elm, styles) { + for (var style in styles) { + elm.style[style] = styles[style]; + } +} + +function setupContainer(element, getValue) { + if (element.type != 'textarea') { + throw new Error("Textarea required!"); + } + + var parentNode = element.parentNode; + + // This will hold the editor. + var container = document.createElement('div'); + + // To put Ace in the place of the textarea, we have to copy a few of the + // textarea's style attributes to the div container. + // + // The problem is that the properties have to get computed (they might be + // defined by a CSS file on the page - you can't access such rules that + // apply to an element via elm.style). Computed properties are converted to + // pixels although the dimension might be given as percentage. When the + // window resizes, the dimensions defined by percentages changes, so the + // properties have to get recomputed to get the new/true pixels. + var resizeEvent = function() { + var style = 'position:relative;'; + [ + 'margin-top', 'margin-left', 'margin-right', 'margin-bottom' + ].forEach(function(item) { + style += item + ':' + + getCSSProperty(element, container, item) + ';'; + }); + + // Calculating the width/height of the textarea is somewhat tricky. To + // do it right, you have to include the paddings to the sides as well + // (eg. width = width + padding-left, -right). This works well, as + // long as the width of the element is not set or given in pixels. In + // this case and after the textarea is hidden, getCSSProperty(element, + // container, 'width') will still return pixel value. If the element + // has realtiv dimensions (e.g. width='95') + // getCSSProperty(...) will return pixel values only as long as the + // textarea is visible. After it is hidden getCSSProperty will return + // the relative dimensions as they are set on the element (in the case + // of width, 95). + // Making the sum of pixel vaules (e.g. padding) and realtive values + // (e.g. ) is not possible. As such the padding styles are + // ignored. + + // The complete width is the width of the textarea + the padding + // to the left and right. + var width = getCSSProperty(element, container, 'width') || (element.clientWidth + "px"); + var height = getCSSProperty(element, container, 'height') || (element.clientHeight + "px"); + style += 'height:' + height + ';width:' + width + ';'; + + // Set the display property to 'inline-block'. + style += 'display:inline-block;'; + container.setAttribute('style', style); + }; + event.addListener(window, 'resize', resizeEvent); + + // Call the resizeEvent once, so that the size of the container is + // calculated. + resizeEvent(); + + // Insert the div container after the element. + parentNode.insertBefore(container, element.nextSibling); + + // Override the forms onsubmit function. Set the innerHTML and value + // of the textarea before submitting. + while (parentNode !== document) { + if (parentNode.tagName.toUpperCase() === 'FORM') { + var oldSumit = parentNode.onsubmit; + // Override the onsubmit function of the form. + parentNode.onsubmit = function(evt) { + element.value = getValue(); + // If there is a onsubmit function already, then call + // it with the current context and pass the event. + if (oldSumit) { + oldSumit.call(this, evt); + } + }; + break; + } + parentNode = parentNode.parentNode; + } + return container; +} + +exports.transformTextarea = function(element, options) { + var session; + var container = setupContainer(element, function() { + return session.getValue(); + }); + + // Hide the element. + element.style.display = 'none'; + container.style.background = 'white'; + + // + var editorDiv = document.createElement("div"); + applyStyles(editorDiv, { + top: "0px", + left: "0px", + right: "0px", + bottom: "0px", + border: "1px solid gray", + position: "absolute" + }); + container.appendChild(editorDiv); + + var settingOpener = document.createElement("div"); + applyStyles(settingOpener, { + position: "absolute", + right: "0px", + bottom: "0px", + background: "red", + cursor: "nw-resize", + borderStyle: "solid", + borderWidth: "9px 8px 10px 9px", + width: "2px", + borderColor: "lightblue gray gray lightblue", + zIndex: 101 + }); + + var settingDiv = document.createElement("div"); + var settingDivStyles = { + top: "0px", + left: "20%", + right: "0px", + bottom: "0px", + position: "absolute", + padding: "5px", + zIndex: 100, + color: "white", + display: "none", + overflow: "auto", + fontSize: "14px", + boxShadow: "-5px 2px 3px gray" + }; + if (!UA.isOldIE) { + settingDivStyles.backgroundColor = "rgba(0, 0, 0, 0.6)"; + } else { + settingDivStyles.backgroundColor = "#333"; + } + + applyStyles(settingDiv, settingDivStyles); + container.appendChild(settingDiv); + + options = options || exports.defaultOptions; + // Power up ace on the textarea: + var editor = ace.edit(editorDiv); + session = editor.getSession(); + + session.setValue(element.value || element.innerHTML); + editor.focus(); + + // Add the settingPanel opener to the editor's div. + container.appendChild(settingOpener); + + // Create the API. + setupApi(editor, editorDiv, settingDiv, ace, options); + + // Create the setting's panel. + setupSettingPanel(settingDiv, settingOpener, editor); + + var state = ""; + event.addListener(settingOpener, "mousemove", function(e) { + var rect = this.getBoundingClientRect(); + var x = e.clientX - rect.left, y = e.clientY - rect.top; + if (x + y < (rect.width + rect.height)/2) { + this.style.cursor = "pointer"; + state = "toggle"; + } else { + state = "resize"; + this.style.cursor = "nw-resize"; + } + }); + + event.addListener(settingOpener, "mousedown", function(e) { + if (state == "toggle") { + editor.setDisplaySettings(); + return; + } + container.style.zIndex = 100000; + var rect = container.getBoundingClientRect(); + var startX = rect.width + rect.left - e.clientX; + var startY = rect.height + rect.top - e.clientY; + event.capture(settingOpener, function(e) { + container.style.width = e.clientX - rect.left + startX + "px"; + container.style.height = e.clientY - rect.top + startY + "px"; + editor.resize(); + }, function() {}); + }); + + return editor; +}; + +function load(url, module, callback) { + net.loadScript(url, function() { + require([module], callback); + }); +} + +function setupApi(editor, editorDiv, settingDiv, ace, options) { + var session = editor.getSession(); + var renderer = editor.renderer; + + function toBool(value) { + return value === "true" || value == true; + } + + editor.setDisplaySettings = function(display) { + if (display == null) + display = settingDiv.style.display == "none"; + if (display) { + settingDiv.style.display = "block"; + settingDiv.hideButton.focus(); + editor.on("focus", function onFocus() { + editor.removeListener("focus", onFocus); + settingDiv.style.display = "none"; + }); + } else { + editor.focus(); + } + }; + + editor.$setOption = editor.setOption; + editor.$getOption = editor.getOption; + editor.setOption = function(key, value) { + switch (key) { + case "mode": + editor.$setOption("mode", "ace/mode/" + value); + break; + case "theme": + editor.$setOption("theme", "ace/theme/" + value); + break; + case "keybindings": + switch (value) { + case "vim": + editor.setKeyboardHandler("ace/keyboard/vim"); + break; + case "emacs": + editor.setKeyboardHandler("ace/keyboard/emacs"); + break; + default: + editor.setKeyboardHandler(null); + } + break; + + case "softWrap": + case "fontSize": + editor.$setOption(key, value); + break; + + default: + editor.$setOption(key, toBool(value)); + } + }; + + editor.getOption = function(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.setOptions(options); + return editor; +} + +function setupSettingPanel(settingDiv, settingOpener, editor) { + var BOOL = null; + + var desc = { + mode: "Mode:", + wrap: "Soft Wrap:", + theme: "Theme:", + fontSize: "Font Size:", + showGutter: "Display Gutter:", + keybindings: "Keyboard", + showPrintMargin: "Show Print Margin:", + useSoftTabs: "Use Soft Tabs:", + showInvisibles: "Show Invisibles" + }; + + var optionValues = { + mode: { + text: "Plain", + javascript: "JavaScript", + xml: "XML", + html: "HTML", + css: "CSS", + scss: "SCSS", + python: "Python", + php: "PHP", + java: "Java", + ruby: "Ruby", + c_cpp: "C/C++", + coffee: "CoffeeScript", + json: "json", + perl: "Perl", + clojure: "Clojure", + ocaml: "OCaml", + csharp: "C#", + haxe: "haXe", + svg: "SVG", + textile: "Textile", + groovy: "Groovy", + liquid: "Liquid", + Scala: "Scala" + }, + theme: { + clouds: "Clouds", + clouds_midnight: "Clouds Midnight", + cobalt: "Cobalt", + crimson_editor: "Crimson Editor", + dawn: "Dawn", + gob: "Green on Black", + eclipse: "Eclipse", + idle_fingers: "Idle Fingers", + kr_theme: "Kr Theme", + merbivore: "Merbivore", + merbivore_soft: "Merbivore Soft", + mono_industrial: "Mono Industrial", + monokai: "Monokai", + pastel_on_dark: "Pastel On Dark", + solarized_dark: "Solarized Dark", + solarized_light: "Solarized Light", + textmate: "Textmate", + twilight: "Twilight", + vibrant_ink: "Vibrant Ink" + }, + showGutter: BOOL, + fontSize: { + "10px": "10px", + "11px": "11px", + "12px": "12px", + "14px": "14px", + "16px": "16px" + }, + wrap: { + off: "Off", + 40: "40", + 80: "80", + free: "Free" + }, + keybindings: { + ace: "ace", + vim: "vim", + emacs: "emacs" + }, + showPrintMargin: BOOL, + useSoftTabs: BOOL, + showInvisibles: BOOL + }; + + var table = []; + table.push(""); + + function renderOption(builder, option, obj, cValue) { + if (!obj) { + builder.push( + "" + ); + return; + } + builder.push(""); + } + + for (var option in exports.defaultOptions) { + table.push(""); + table.push(""); + } + table.push("
SettingValue
", desc[option], ""); + renderOption(table, option, optionValues[option], editor.getOption(option)); + table.push("
"); + settingDiv.innerHTML = table.join(""); + + var onChange = function(e) { + var select = e.currentTarget; + editor.setOption(select.title, select.value); + }; + var onClick = function(e) { + var cb = e.currentTarget; + editor.setOption(cb.title, cb.checked); + }; + var selects = settingDiv.getElementsByTagName("select"); + for (var i = 0; i < selects.length; i++) + selects[i].onchange = onChange; + var cbs = settingDiv.getElementsByTagName("input"); + for (var i = 0; i < cbs.length; i++) + cbs[i].onclick = onClick; + + + var button = document.createElement("input"); + button.type = "button"; + button.value = "Hide"; + event.addListener(button, "click", function() { + editor.setDisplaySettings(false); + }); + settingDiv.appendChild(button); + settingDiv.hideButton = button; +} + +// Default startup options. +exports.defaultOptions = { + mode: "javascript", + theme: "textmate", + wrap: "off", + fontSize: "12px", + showGutter: "false", + keybindings: "ace", + showPrintMargin: "false", + useSoftTabs: "true", + showInvisibles: "false" +}; + +}); diff --git a/public/lib/ace/ext/themelist.js b/public/lib/ace/ext/themelist.js new file mode 100644 index 0000000..10deca1 --- /dev/null +++ b/public/lib/ace/ext/themelist.js @@ -0,0 +1,104 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl + * All rights reserved. + * + * Contributed to Ajax.org under the BSD license. + * + * 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 ***** */ + + +/** + * Generates a list of themes available when ace was built. + * @fileOverview Generates a list of themes available when ace was built. + * @author + * Matthew Christopher Kastor-Inare III
+ * ☭ Hial Atropa!! ☭ + */ + +define(function(require, exports, module) { +"use strict"; +require("ace/lib/fixoldbrowsers"); + +var themeData = [ + ["Chrome" ], + ["Clouds" ], + ["Crimson Editor" ], + ["Dawn" ], + ["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"], + ["Cobalt" ,"cobalt" , "dark"], + ["Gruvbox" ,"gruvbox" , "dark"], + ["Green on Black" ,"gob" , "dark"], + ["idle Fingers" ,"idle_fingers" , "dark"], + ["krTheme" ,"kr_theme" , "dark"], + ["Merbivore" ,"merbivore" , "dark"], + ["Merbivore Soft" ,"merbivore_soft" , "dark"], + ["Mono Industrial" ,"mono_industrial" , "dark"], + ["Monokai" ,"monokai" , "dark"], + ["Pastel on dark" ,"pastel_on_dark" , "dark"], + ["Solarized Dark" ,"solarized_dark" , "dark"], + ["Terminal" ,"terminal" , "dark"], + ["Tomorrow Night" ,"tomorrow_night" , "dark"], + ["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"], + ["Tomorrow Night Bright","tomorrow_night_bright" , "dark"], + ["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"], + ["Twilight" ,"twilight" , "dark"], + ["Vibrant Ink" ,"vibrant_ink" , "dark"] +]; + + +exports.themesByName = {}; + +/** + * An array containing information about available themes. + */ +exports.themes = themeData.map(function(data) { + var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); + var theme = { + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name + }; + exports.themesByName[name] = theme; + return theme; +}); + +}); + diff --git a/public/lib/ace/ext/whitespace.js b/public/lib/ace/ext/whitespace.js new file mode 100644 index 0000000..f605303 --- /dev/null +++ b/public/lib/ace/ext/whitespace.js @@ -0,0 +1,243 @@ +/* ***** 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 lang = require("../lib/lang"); + +// based on http://www.freehackers.org/Indent_Finder +exports.$detectIndentation = function(lines, fallback) { + var stats = []; + var changes = []; + var tabIndents = 0; + var prevSpaces = 0; + var max = Math.min(lines.length, 1000); + for (var i = 0; i < max; i++) { + var line = lines[i]; + // ignore empty and comment lines + if (!/^\s*[^*+\-\s]/.test(line)) + continue; + + if (line[0] == "\t") { + tabIndents++; + prevSpaces = -Number.MAX_VALUE; + } else { + var spaces = line.match(/^ */)[0].length; + if (spaces && line[spaces] != "\t") { + var diff = spaces - prevSpaces; + if (diff > 0 && !(prevSpaces%diff) && !(spaces%diff)) + changes[diff] = (changes[diff] || 0) + 1; + + stats[spaces] = (stats[spaces] || 0) + 1; + } + prevSpaces = spaces; + } + // ignore lines ending with backslash + while (i < max && line[line.length - 1] == "\\") + line = lines[i++]; + } + + function getScore(indent) { + var score = 0; + for (var i = indent; i < stats.length; i += indent) + score += stats[i] || 0; + return score; + } + + var changesTotal = changes.reduce(function(a,b){return a+b;}, 0); + + var first = {score: 0, length: 0}; + var spaceIndents = 0; + for (var i = 1; i < 12; i++) { + var score = getScore(i); + if (i == 1) { + spaceIndents = score; + score = stats[1] ? 0.9 : 0.8; + if (!stats.length) + score = 0; + } else + score /= spaceIndents; + + if (changes[i]) + score += changes[i] / changesTotal; + + if (score > first.score) + first = {score: score, length: i}; + } + + if (first.score && first.score > 1.4) + var tabLength = first.length; + + if (tabIndents > spaceIndents + 1) { + if (tabLength == 1 || spaceIndents < tabIndents / 4 || first.score < 1.8) + tabLength = undefined; + return {ch: "\t", length: tabLength}; + } + if (spaceIndents > tabIndents + 1) + return {ch: " ", length: tabLength}; +}; + +exports.detectIndentation = function(session) { + var lines = session.getLines(0, 1000); + var indent = exports.$detectIndentation(lines) || {}; + + if (indent.ch) + session.setUseSoftTabs(indent.ch == " "); + + if (indent.length) + session.setTabSize(indent.length); + return indent; +}; + +/** + * EditSession session + * options.trimEmpty trim empty lines too + * options.keepCursorPosition do not trim whitespace before the cursor + */ +exports.trimTrailingSpace = function(session, options) { + var doc = session.getDocument(); + var lines = doc.getAllLines(); + + var min = options && options.trimEmpty ? -1 : 0; + var cursors = [], ci = -1; + if (options && options.keepCursorPosition) { + if (session.selection.rangeCount) { + session.selection.rangeList.ranges.forEach(function(x, i, ranges) { + var next = ranges[i + 1]; + if (next && next.cursor.row == x.cursor.row) + return; + cursors.push(x.cursor); + }); + } else { + cursors.push(session.selection.getCursor()); + } + ci = 0; + } + var cursorRow = cursors[ci] && cursors[ci].row; + + for (var i = 0, l=lines.length; i < l; i++) { + var line = lines[i]; + var index = line.search(/\s+$/); + + if (i == cursorRow) { + if (index < cursors[ci].column && index > min) + index = cursors[ci].column; + ci++; + cursorRow = cursors[ci] ? cursors[ci].row : -1; + } + + if (index > min) + doc.removeInLine(i, index, line.length); + } +}; + +exports.convertIndentation = function(session, ch, len) { + var oldCh = session.getTabString()[0]; + var oldLen = session.getTabSize(); + if (!len) len = oldLen; + if (!ch) ch = oldCh; + + var tab = ch == "\t" ? ch: lang.stringRepeat(ch, len); + + var doc = session.doc; + var lines = doc.getAllLines(); + + var cache = {}; + var spaceCache = {}; + for (var i = 0, l=lines.length; i < l; i++) { + var line = lines[i]; + var match = line.match(/^\s*/)[0]; + if (match) { + var w = session.$getStringScreenWidth(match)[0]; + var tabCount = Math.floor(w/oldLen); + var reminder = w%oldLen; + var toInsert = cache[tabCount] || (cache[tabCount] = lang.stringRepeat(tab, tabCount)); + toInsert += spaceCache[reminder] || (spaceCache[reminder] = lang.stringRepeat(" ", reminder)); + + if (toInsert != match) { + doc.removeInLine(i, 0, match.length); + doc.insertInLine({row: i, column: 0}, toInsert); + } + } + } + session.setTabSize(len); + session.setUseSoftTabs(ch == " "); +}; + +exports.$parseStringArg = function(text) { + var indent = {}; + if (/t/.test(text)) + indent.ch = "\t"; + else if (/s/.test(text)) + indent.ch = " "; + var m = text.match(/\d+/); + if (m) + indent.length = parseInt(m[0], 10); + return indent; +}; + +exports.$parseArg = function(arg) { + if (!arg) + return {}; + if (typeof arg == "string") + return exports.$parseStringArg(arg); + if (typeof arg.text == "string") + return exports.$parseStringArg(arg.text); + return arg; +}; + +exports.commands = [{ + name: "detectIndentation", + exec: function(editor) { + exports.detectIndentation(editor.session); + // todo show message? + } +}, { + name: "trimTrailingSpace", + exec: function(editor) { + exports.trimTrailingSpace(editor.session); + } +}, { + name: "convertIndentation", + exec: function(editor, arg) { + var indent = exports.$parseArg(arg); + exports.convertIndentation(editor.session, indent.ch, indent.length); + } +}, { + name: "setIndentation", + exec: function(editor, arg) { + var indent = exports.$parseArg(arg); + indent.length && editor.session.setTabSize(indent.length); + indent.ch && editor.session.setUseSoftTabs(indent.ch == " "); + } +}]; + +}); diff --git a/public/lib/ace/ext/whitespace_test.js b/public/lib/ace/ext/whitespace_test.js new file mode 100644 index 0000000..18d4f3c --- /dev/null +++ b/public/lib/ace/ext/whitespace_test.js @@ -0,0 +1,206 @@ +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { +"use strict"; + +require("../multi_select"); +var assert = require("assert"); +var EditSession = require("../edit_session").EditSession; +var UndoManager = require("../undomanager").UndoManager; +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, undefined); + s.doc.removeInLine(0, 0, 2); + + s.insert({row: 0, column: 0}, "x\n y\n z\n"); + 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(); + }, + + "test trimTrailingSpace": function(next) { + var session = new EditSession([ + "a", + "\t b \t", + " ", + "\t", + "\t\tx\t\t", + " ", + " " + ]); + session.setUndoManager(new UndoManager()); + + function testOne(value, options) { + console.log(JSON.stringify(session.getValue())); + + whitespace.trimTrailingSpace(session, options); + assert.equal(value, session.getValue()); + session.markUndoGroup(); + session.getUndoManager().undo(); + } + + testOne("a\n\t b\n \n\t\n\t\tx\n \n "); + + testOne("a\n\t b\n\n\n\t\tx\n\n", { + trimEmpty: true + }); + + session.selection.fromJSON([{ + start: {row:2,column:3}, + end: {row:4,column:4} + }]); + testOne("a\n\t b\n\n\n\t\tx\t\n\n", { + keepCursorPosition: true, + trimEmpty: true + }); + + session.selection.fromJSON([{ + start: {row:2,column:3}, + end: {row:4,column:4}, + isBackwards: true + }]); + testOne("a\n\t b\n \n\n\t\tx\n\n", { + keepCursorPosition: true, + trimEmpty: true + }); + + session.selection.$initRangeList(); + session.selection.fromJSON([{ + start: {row:2, column:3}, + end: {row:2,column:3} + }, { + start: {row:1, column:1}, + end: {row:1, column:1} + }, { + start: {row:2,column:2}, + end: {row:2,column:2} + }, { + start: {row:0,column:5}, + end: {row:0,column:5}, + isBackwards:false + }, { + start: {row:6,column:1}, + end: {row:6,column:1}, + isBackwards:false + }]); + testOne("a\n\t b\n \n\n\t\tx\n\n ", { + trimEmpty: true, + keepCursorPosition: true + }); + + session.setValue("some text"); + session.selection.fromJSON([{ + start: {row:0,column:4}, + end: {row:0,column:4} + }]); + testOne("some text", { + keepCursorPosition: true, + trimEmpty: true + }); + + next(); + } + +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/incremental_search.js b/public/lib/ace/incremental_search.js new file mode 100644 index 0000000..298dd59 --- /dev/null +++ b/public/lib/ace/incremental_search.js @@ -0,0 +1,317 @@ +/* ***** 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 oop = require("./lib/oop"); +var Range = require("./range").Range; +var Search = require("./search").Search; +var SearchHighlight = require("./search_highlight").SearchHighlight; +var iSearchCommandModule = require("./commands/incremental_search_commands"); +var ISearchKbd = iSearchCommandModule.IncrementalSearchKeyboardHandler; + +/** + * @class IncrementalSearch + * + * Implements immediate searching while the user is typing. When incremental + * search is activated, keystrokes into the editor will be used for composing + * a search term. Immediately after every keystroke the search is updated: + * - so-far-matching characters are highlighted + * - the cursor is moved to the next match + * + **/ + + +/** + * + * + * Creates a new `IncrementalSearch` object. + * + * @constructor + **/ +function IncrementalSearch() { + this.$options = {wrap: false, skipCurrent: false}; + this.$keyboardHandler = new ISearchKbd(this); +} + +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) { + this.$editor = ed; + this.$startPos = this.$currentPos = ed.getCursorPosition(); + this.$options.needle = ''; + this.$options.backwards = backwards; + ed.keyBinding.addKeyboardHandler(this.$keyboardHandler); + // we need to completely intercept paste, just registering an event handler does not work + this.$originalEditorOnPaste = ed.onPaste; ed.onPaste = this.onPaste.bind(this); + this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this)); + this.selectionFix(ed); + this.statusMessage(true); + }; + + this.deactivate = function(reset) { + this.cancelSearch(reset); + var ed = this.$editor; + ed.keyBinding.removeKeyboardHandler(this.$keyboardHandler); + if (this.$mousedownHandler) { + ed.removeEventListener('mousedown', this.$mousedownHandler); + delete this.$mousedownHandler; + } + ed.onPaste = this.$originalEditorOnPaste; + this.message(''); + }; + + this.selectionFix = function(editor) { + // Fix selection bug: When clicked inside the editor + // editor.selection.$isEmpty is false even if the mouse click did not + // open a selection. This is interpreted by the move commands to + // extend the selection. To only extend the selection when there is + // one, we clear it here + if (editor.selection.isEmpty() && !editor.session.$emacsMark) { + editor.clearSelection(); + } + }; + + this.highlight = function(regexp) { + var sess = this.$editor.session, + hl = sess.$isearchHighlight = sess.$isearchHighlight || sess.addDynamicMarker( + 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; + this.$prevNeedle = this.$options.needle; + this.$options.needle = ''; + if (reset) { + e.moveCursorToPosition(this.$startPos); + this.$currentPos = this.$startPos; + } else { + e.pushEmacsMark && e.pushEmacsMark(this.$startPos, false); + } + this.highlight(null); + return Range.fromPoints(this.$currentPos, this.$currentPos); + }; + + this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) { + if (!this.$editor) return null; + var options = this.$options; + + // get search term + if (needleUpdateFunc) { + options.needle = needleUpdateFunc.call(this, options.needle || '') || ''; + } + if (options.needle.length === 0) { + this.statusMessage(true); + return this.cancelSearch(true); + } + + // try to find the next occurrence and enable highlighting marker + options.start = this.$currentPos; + var session = this.$editor.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.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.statusMessage(found); + + return found; + }; + + this.addString = function(s) { + return this.highlightAndFindWithNeedle(false, function(needle) { + 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) { + 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 occurrence of whatever we have searched for + // earlier. + // options = {[backwards: BOOL], [useCurrentOrPrevSearch: BOOL]} + options = options || {}; + this.$options.backwards = !!options.backwards; + this.$currentPos = this.$editor.getCursorPosition(); + return this.highlightAndFindWithNeedle(true, function(needle) { + 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 = ''; + msg += options.backwards ? 'reverse-' : ''; + msg += 'isearch: ' + options.needle; + msg += found ? '' : ' (not found)'; + this.message(msg); + }; + + this.message = function(msg) { + if (this.$editor.showCommandLine) { + this.$editor.showCommandLine(msg); + this.$editor.focus(); + } else { + console.log(msg); + } + }; + +}).call(IncrementalSearch.prototype); + + +exports.IncrementalSearch = IncrementalSearch; + + +/** + * + * Config settings for enabling/disabling [[IncrementalSearch `IncrementalSearch`]]. + * + **/ + +var dom = require('./lib/dom'); +dom.importCssString && dom.importCssString("\ +.ace_marker-layer .ace_isearch-result {\ + position: absolute;\ + z-index: 6;\ + -moz-box-sizing: border-box;\ + -webkit-box-sizing: border-box;\ + box-sizing: border-box;\ +}\ +div.ace_isearch-result {\ + border-radius: 4px;\ + background-color: rgba(255, 200, 0, 0.5);\ + box-shadow: 0 0 4px rgb(255, 200, 0);\ +}\ +.ace_dark div.ace_isearch-result {\ + background-color: rgb(100, 110, 160);\ + box-shadow: 0 0 4px rgb(80, 90, 140);\ +}", "incremental-search-highlighting"); + +// support for default keyboard handler +var commands = require("./commands/command_manager"); +(function() { + this.setupIncrementalSearch = function(editor, val) { + if (this.usesIncrementalSearch == val) return; + this.usesIncrementalSearch = val; + var iSearchCommands = iSearchCommandModule.iSearchStartCommands; + var method = val ? 'addCommands' : 'removeCommands'; + this[method](iSearchCommands); + }; +}).call(commands.CommandManager.prototype); + +// incremental search config option +var Editor = require("./editor").Editor; +require("./config").defineOptions(Editor.prototype, "editor", { + useIncrementalSearch: { + set: function(val) { + this.keyBinding.$handlers.forEach(function(handler) { + if (handler.setupIncrementalSearch) { + handler.setupIncrementalSearch(this, val); + } + }); + this._emit('incrementalSearchSettingChanged', {isEnabled: val}); + } + } +}); + +}); diff --git a/public/lib/ace/incremental_search_test.js b/public/lib/ace/incremental_search_test.js new file mode 100644 index 0000000..0fa60fd --- /dev/null +++ b/public/lib/ace/incremental_search_test.js @@ -0,0 +1,213 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +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(); + assert.equal(ranges + "", str + ""); +} + +// force "rerender" +function callHighlighterUpdate() { + var session = editor.session, + ranges = [], + mockMarkerLayer = { + drawSingleLineMarker: function(_, markerRanges) { + ranges = ranges.concat(markerRanges); + } + }; + session.$isearchHighlight.update([], mockMarkerLayer, session, { + firstRow: 0, lastRow: session.getRowLength()}); + return ranges; +} + +module.exports = { + + name: "ACE incremental_search.js", + + setUp: function() { + var session = new EditSession(["abc123", "xyz124"]); + editor = new Editor(new MockRenderer(), session); + new MultiSelect(editor); + iSearch = new IncrementalSearch(); + }, + + "test: keyboard handler setup" : function() { + iSearch.activate(editor); + assert.equal(editor.getKeyboardHandler(), iSearch.$keyboardHandler); + iSearch.deactivate(); + assert.notEqual(editor.getKeyboardHandler(), iSearch.$keyboardHandler); + }, + + "test: isearch highlight setup" : function() { + var sess = editor.session; + iSearch.activate(editor); + iSearch.highlight('foo'); + var highl = sess.$isearchHighlight.id; + assert.ok(sess.$isearchHighlight, 'session has no isearch highlighter'); + assert.equal(sess.getMarkers()[highl.id], highl.id, 'isearch highlight not in markers'); + iSearch.deactivate(); + iSearch.activate(editor); + iSearch.highlight('bar'); + var highl2 = sess.$isearchHighlight.id; + assert.equal(highl2, highl, 'multiple isearch highlights'); + }, + + "test: find simple text incrementally" : function() { + iSearch.activate(editor); + var range = iSearch.addString('1'), // "1" + highlightRanges = callHighlighterUpdate(); + testRanges("Range: [0/3] -> [0/4]", [range]); + testRanges("Range: [0/3] -> [0/4],Range: [1/3] -> [1/4]", highlightRanges); + + range = iSearch.addString('2'); // "12" + highlightRanges = callHighlighterUpdate(); + testRanges("Range: [0/3] -> [0/5]", [range]); + testRanges("Range: [0/3] -> [0/5],Range: [1/3] -> [1/5]", highlightRanges); + + range = iSearch.addString('3'); // "123" + highlightRanges = callHighlighterUpdate(); + testRanges("Range: [0/3] -> [0/6]", [range]); + testRanges("Range: [0/3] -> [0/6]", highlightRanges); + + range = iSearch.removeChar(); // "12" + highlightRanges = callHighlighterUpdate(); + testRanges("Range: [0/3] -> [0/5]", [range]); + testRanges("Range: [0/3] -> [0/5],Range: [1/3] -> [1/5]", highlightRanges); + }, + + "test: forward / backward" : function() { + iSearch.activate(editor); + iSearch.addString('1'); iSearch.addString('2'); + var range = iSearch.next(); + testRanges("Range: [1/3] -> [1/5]", [range]); + + range = iSearch.next(); // nothing to find + testRanges("", [range]); + + range = iSearch.next({backwards: true}); // backwards + testRanges("Range: [1/5] -> [1/3]", [range]); + }, + + "test: cancelSearch" : function() { + iSearch.activate(editor); + iSearch.addString('1'); iSearch.addString('2'); + var range = iSearch.cancelSearch(true); + testRanges("Range: [0/0] -> [0/0]", [range]); + + iSearch.addString('1'); range = iSearch.addString('2'); + testRanges("Range: [0/3] -> [0/5]", [range]); + }, + + "test: failing search keeps pos" : function() { + iSearch.activate(editor); + iSearch.addString('1'); iSearch.addString('2'); + var range = iSearch.addString('x'); + testRanges("", [range]); + assert.position(editor.getCursorPosition(), 0, 5); + }, + + "test: backwards search" : function() { + editor.moveCursorTo(1,0); + iSearch.activate(editor, true); + iSearch.addString('1'); var range = iSearch.addString('2'); + testRanges("Range: [0/5] -> [0/3]", [range]); + assert.position(editor.getCursorPosition(), 0, 3); + }, + + "test: forwards then backwards, same result, reoriented range" : function() { + iSearch.activate(editor); + iSearch.addString('1'); var range = iSearch.addString('2'); + testRanges("Range: [0/3] -> [0/5]", [range]); + assert.position(editor.getCursorPosition(), 0, 5); + + range = iSearch.next({backwards: true}); + testRanges("Range: [0/5] -> [0/3]", [range]); + assert.position(editor.getCursorPosition(), 0, 3); + }, + + "test: reuse prev search via option" : function() { + iSearch.activate(editor); + iSearch.addString('1'); iSearch.addString('2'); + assert.position(editor.getCursorPosition(), 0, 5); + iSearch.deactivate(); + + iSearch.activate(editor); + iSearch.next({backwards: false, useCurrentOrPrevSearch: true}); + assert.position(editor.getCursorPosition(), 1, 5); + }, + + "test: don't extend selection range if selection is empty" : function() { + iSearch.activate(editor); + iSearch.addString('1'); iSearch.addString('2'); + testRanges("Range: [0/5] -> [0/5]", [editor.getSelectionRange()]); + }, + + "test: extend selection range if selection exists" : function() { + iSearch.activate(editor); + editor.selection.selectTo(0, 1); + iSearch.addString('1'); iSearch.addString('2'); + testRanges("Range: [0/0] -> [0/5]", [editor.getSelectionRange()]); + }, + + "test: extend selection in emacs mark mode" : function() { + var emacs = require('./keyboard/emacs'); + editor.keyBinding.addKeyboardHandler(emacs.handler); + emacs.handler.commands.setMark.exec(editor); + iSearch.activate(editor); + iSearch.addString('1'); iSearch.addString('2'); + testRanges("Range: [0/0] -> [0/5]", [editor.getSelectionRange()]); + } + +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/keyboard/emacs.js b/public/lib/ace/keyboard/emacs.js new file mode 100644 index 0000000..098632e --- /dev/null +++ b/public/lib/ace/keyboard/emacs.js @@ -0,0 +1,666 @@ +/* ***** 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 dom = require("../lib/dom"); +require("../incremental_search"); +var iSearchCommandModule = require("../commands/incremental_search_commands"); + + +var screenToTextBlockCoordinates = function(x, y) { + var canvasPos = this.scroller.getBoundingClientRect(); + var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding; + + var col = Math.floor(offsetX / this.characterWidth); + + var row = Math.floor( + (y + this.scrollTop - canvasPos.top) / this.lineHeight + ); + + return this.session.screenToDocumentPosition(row, col, offsetX); +}; + +var HashHandler = require("./hash_handler").HashHandler; +exports.handler = new HashHandler(); + +exports.handler.isEmacs = true; +exports.handler.$id = "ace/keyboard/emacs"; + +var initialized = false; +var $formerLongWords; +var $formerLineStart; + +exports.handler.attach = function(editor) { + if (!initialized) { + initialized = true; + dom.importCssString('\ + .emacs-mode .ace_cursor{\ + 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;\ + background-color: rgba(0,250,0,0.9);\ + opacity: 0.5;\ + }\ + .emacs-mode .ace_hidden-cursors .ace_cursor{\ + opacity: 1;\ + background-color: transparent;\ + }\ + .emacs-mode .ace_overwrite-cursors .ace_cursor {\ + opacity: 1;\ + background-color: transparent;\ + border-width: 0 0 2px 2px !important;\ + }\ + .emacs-mode .ace_text-layer {\ + z-index: 4\ + }\ + .emacs-mode .ace_cursor-layer {\ + z-index: 2\ + }', 'emacsMode' + ); + } + // in emacs, gotowordleft/right should not count a space as a word.. + $formerLongWords = editor.session.$selectLongWords; + editor.session.$selectLongWords = true; + // CTRL-A should go to actual beginning of line + $formerLineStart = editor.session.$useEmacsStyleLineStart; + editor.session.$useEmacsStyleLineStart = true; + + editor.session.$emacsMark = null; // the active mark + editor.session.$emacsMarkRing = editor.session.$emacsMarkRing || []; + + editor.emacsMark = function() { + return this.session.$emacsMark; + }; + + editor.setEmacsMark = function(p) { + // to deactivate pass in a falsy value + this.session.$emacsMark = p; + }; + + editor.pushEmacsMark = function(p, activate) { + var prevMark = this.session.$emacsMark; + if (prevMark) + this.session.$emacsMarkRing.push(prevMark); + if (!p || activate) this.setEmacsMark(p); + else this.session.$emacsMarkRing.push(p); + }; + + editor.popEmacsMark = function() { + var mark = this.emacsMark(); + if (mark) { this.setEmacsMark(null); return mark; } + return this.session.$emacsMarkRing.pop(); + }; + + editor.getLastEmacsMark = function(p) { + 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; + editor.setStyle("emacs-mode"); + editor.commands.addCommands(commands); + exports.handler.platform = editor.commands.platform; + editor.$emacsModeHandler = this; + editor.addEventListener('copy', this.onCopy); + editor.addEventListener('paste', this.onPaste); +}; + +exports.handler.detach = function(editor) { + delete editor.renderer.screenToTextCoordinates; + editor.session.$selectLongWords = $formerLongWords; + editor.session.$useEmacsStyleLineStart = $formerLineStart; + editor.removeEventListener("click", $resetMarkMode); + editor.removeEventListener("changeSession", $kbSessionChange); + editor.unsetStyle("emacs-mode"); + editor.commands.removeCommands(commands); + editor.removeEventListener('copy', this.onCopy); + editor.removeEventListener('paste', this.onPaste); + editor.$emacsModeHandler = null; +}; + +var $kbSessionChange = function(e) { + if (e.oldSession) { + e.oldSession.$selectLongWords = $formerLongWords; + e.oldSession.$useEmacsStyleLineStart = $formerLineStart; + } + + $formerLongWords = e.session.$selectLongWords; + e.session.$selectLongWords = true; + $formerLineStart = e.session.$useEmacsStyleLineStart; + e.session.$useEmacsStyleLineStart = true; + + if (!e.session.hasOwnProperty('$emacsMark')) + e.session.$emacsMark = null; + if (!e.session.hasOwnProperty('$emacsMarkRing')) + e.session.$emacsMarkRing = []; +}; + +var $resetMarkMode = function(e) { + e.editor.session.$emacsMark = null; +}; + +var keys = require("../lib/keys").KEY_MODS; +var eMods = {C: "ctrl", S: "shift", M: "alt", CMD: "command"}; +var combinations = ["C-S-M-CMD", + "S-M-CMD", "C-M-CMD", "C-S-CMD", "C-S-M", + "M-CMD", "S-CMD", "S-M", "C-CMD", "C-M", "C-S", + "CMD", "M", "S", "C"]; +combinations.forEach(function(c) { + var hashId = 0; + c.split("-").forEach(function(c) { + hashId = hashId | keys[eMods[c]]; + }); + eMods[hashId] = c.toLowerCase() + "-"; +}); + +exports.handler.onCopy = function(e, editor) { + if (editor.$handlesEmacsOnCopy) return; + editor.$handlesEmacsOnCopy = true; + exports.handler.commands.killRingSave.exec(editor); + editor.$handlesEmacsOnCopy = false; +}; + +exports.handler.onPaste = function(e, editor) { + editor.pushEmacsMark(editor.getCursorPosition()); +}; + +exports.handler.bindKey = function(key, command) { + if (typeof key == "object") + key = key[this.platform]; + if (!key) + return; + + var ckb = this.commandKeyBinding; + key.split("|").forEach(function(keyPart) { + keyPart = keyPart.toLowerCase(); + ckb[keyPart] = command; + // register all partial key combos as null commands + // to be able to activate key combos with arbitrary length + // Example: if keyPart is "C-c C-l t" then "C-c C-l t" will + // get command assigned and "C-c" and "C-c C-l" will get + // a null command assigned in this.commandKeyBinding. For + // the lookup logic see handleKeyboard() + var keyParts = keyPart.split(" ").slice(0,-1); + keyParts.reduce(function(keyMapKeys, keyPart, i) { + var prefix = keyMapKeys[i-1] ? keyMapKeys[i-1] + ' ' : ''; + return keyMapKeys.concat([prefix + keyPart]); + }, []).forEach(function(keyPart) { + if (!ckb[keyPart]) ckb[keyPart] = "null"; + }); + }, 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(); + if (data.count) { + var str = new Array(data.count + 1).join(key); + data.count = null; + return {command: "insertstring", args: str}; + } + } + + var modifier = eMods[hashId]; + + // CTRL + number / universalArgument for setting data.count + if (modifier == "c-" || data.count) { + var count = parseInt(key[key.length - 1]); + if (typeof count === 'number' && !isNaN(count)) { + data.count = Math.max(data.count, 0) || 0; + data.count = 10 * data.count + count; + return {command: "null"}; + } + } + + // this.commandKeyBinding maps key specs like "c-p" (for CTRL + P) to + // command objects, for lookup key needs to include the modifier + if (modifier) key = modifier + key; + + // Key combos like CTRL+X H build up the data.keyChain + if (data.keyChain) key = data.keyChain += " " + key; + + // Key combo prefixes get stored as "null" (String!) in this + // this.commandKeyBinding. When encountered no command is invoked but we + // buld up data.keyChain + var command = this.commandKeyBinding[key]; + data.keyChain = command == "null" ? key : ""; + + // there really is no command + if (!command) return undefined; + + // we pass b/c of key combo or universalArgument + if (command === "null") return {command: "null"}; + + if (command === "universalArgument") { + // 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"}; + } + + // lookup command + // TODO extract special handling of markmode + // TODO special case command.command is really unnecessary, remove + var args; + if (typeof command !== "string") { + args = command.args; + if (command.command) command = command.command; + if (command === "goorselect") { + command = editor.emacsMark() ? args[1] : args[0]; + args = null; + } + } + + if (typeof command === "string") { + if (command === "insertstring" || + command === "splitline" || + command === "togglecomment") { + editor.pushEmacsMark(); + } + command = this.commands[command] || editor.commands.commands[command]; + if (!command) return undefined; + } + + 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; + if (!command || !command.handlesCount) { + return { + args: args, + command: { + exec: function(editor, args) { + for (var i = 0; i < count; i++) + command.exec(editor, args); + }, + multiSelectAction: command.multiSelectAction + } + }; + } else { + if (!args) args = {}; + if (typeof args === 'object') args.count = count; + } + } + + return {command: command, args: args}; +}; + +exports.emacsKeys = { + // movement + "Up|C-p" : {command: "goorselect", args: ["golineup","selectup"]}, + "Down|C-n" : {command: "goorselect", args: ["golinedown","selectdown"]}, + "Left|C-b" : {command: "goorselect", args: ["gotoleft","selectleft"]}, + "Right|C-f" : {command: "goorselect", args: ["gotoright","selectright"]}, + "C-Left|M-b" : {command: "goorselect", args: ["gotowordleft","selectwordleft"]}, + "C-Right|M-f" : {command: "goorselect", args: ["gotowordright","selectwordright"]}, + "Home|C-a" : {command: "goorselect", args: ["gotolinestart","selecttolinestart"]}, + "End|C-e" : {command: "goorselect", args: ["gotolineend","selecttolineend"]}, + "C-Home|S-M-,": {command: "goorselect", args: ["gotostart","selecttostart"]}, + "C-End|S-M-." : {command: "goorselect", args: ["gotoend","selecttoend"]}, + + // selection + "S-Up|S-C-p" : "selectup", + "S-Down|S-C-n" : "selectdown", + "S-Left|S-C-b" : "selectleft", + "S-Right|S-C-f" : "selectright", + "S-C-Left|S-M-b" : "selectwordleft", + "S-C-Right|S-M-f" : "selectwordright", + "S-Home|S-C-a" : "selecttolinestart", + "S-End|S-C-e" : "selecttolineend", + "S-C-Home" : "selecttostart", + "S-C-End" : "selecttoend", + + "C-l" : "recenterTopBottom", + "M-s" : "centerselection", + "M-g": "gotoline", + "C-x C-p": "selectall", + + // todo fix these + "C-Down": {command: "goorselect", args: ["gotopagedown","selectpagedown"]}, + "C-Up": {command: "goorselect", args: ["gotopageup","selectpageup"]}, + "PageDown|C-v": {command: "goorselect", args: ["gotopagedown","selectpagedown"]}, + "PageUp|M-v": {command: "goorselect", args: ["gotopageup","selectpageup"]}, + "S-C-Down": "selectpagedown", + "S-C-Up": "selectpageup", + + "C-s": "iSearch", + "C-r": "iSearchBackwards", + + "M-C-s": "findnext", + "M-C-r": "findprevious", + "S-M-5": "replace", + + // basic editing + "Backspace": "backspace", + "Delete|C-d": "del", + "Return|C-m": {command: "insertstring", args: "\n"}, // "newline" + "C-o": "splitline", + + "M-d|C-Delete": {command: "killWord", args: "right"}, + "C-Backspace|M-Backspace|M-Delete": {command: "killWord", args: "left"}, + "C-k": "killLine", + + "C-y|S-Delete": "yank", + "M-y": "yankRotate", + "C-g": "keyboardQuit", + + "C-w|C-S-W": "killRegion", + "M-w": "killRingSave", + "C-Space": "setMark", + "C-x C-x": "exchangePointAndMark", + + "C-t": "transposeletters", + "M-u": "touppercase", // Doesn't work + "M-l": "tolowercase", + "M-/": "autocomplete", // Doesn't work + "C-u": "universalArgument", + + "M-;": "togglecomment", + + "C-/|C-x u|S-C--|C-z": "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 "} + // todo + // "C-x C-t" "M-t" "M-c" "F11" "C-M- "M-q" +}; + + +exports.handler.bindKeys(exports.emacsKeys); + +exports.handler.addCommands({ + recenterTopBottom: function(editor) { + var renderer = editor.renderer; + var pos = renderer.$cursorLayer.getPixelPosition(); + var h = renderer.$size.scrollerHeight - renderer.lineHeight; + var scrollTop = renderer.scrollTop; + if (Math.abs(pos.top - scrollTop) < 2) { + scrollTop = pos.top - h; + } else if (Math.abs(pos.top - scrollTop - h * 0.5) < 2) { + scrollTop = pos.top; + } else { + scrollTop = pos.top - h * 0.5; + } + editor.session.setScrollTop(scrollTop); + }, + selectRectangularRegion: function(editor) { + editor.multiSelect.toggleBlockSelection(); + }, + setMark: { + exec: function(editor, args) { + // Sets mark-mode and clears current selection. + // When mark is set, keyboard cursor movement commands become + // 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. + // in multi select mode, ea selection is handled individually + + if (args && args.count) { + if (editor.inMultiSelectMode) editor.forEachSelection(moveToMark); + else moveToMark(); + moveToMark(); + return; + } + + var mark = editor.emacsMark(), + 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 || !hasNoSelection)) { + if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)}); + else editor.clearSelection(); + if (mark) editor.pushEmacsMark(null); + return; + } + + if (!mark) { + rangePositions.forEach(function(pos) { editor.pushEmacsMark(pos); }); + editor.setEmacsMark(rangePositions[rangePositions.length-1]); + return; + } + + // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + + function moveToMark() { + var mark = editor.popEmacsMark(); + mark && editor.moveCursorToPosition(mark); + } + + }, + readOnly: true, + handlesCount: true + }, + exchangePointAndMark: { + exec: function exchangePointAndMark$exec(editor, args) { + var sel = editor.selection; + 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.emacsMarkForSelection(pos)); + } else { // create selection to last mark + sel.selectToPosition(editor.emacsMarkForSelection()); + } + }, + readOnly: true, + handlesCount: true, + multiSelectAction: "forEach" + }, + killWord: { + exec: function(editor, dir) { + editor.clearSelection(); + if (dir == "left") + editor.selection.selectWordLeft(); + else + editor.selection.selectWordRight(); + + var range = editor.getSelectionRange(); + var text = editor.session.getTextRange(range); + exports.killRing.add(text); + + editor.session.remove(range); + editor.clearSelection(); + }, + multiSelectAction: "forEach" + }, + killLine: function(editor) { + editor.pushEmacsMark(null); + // don't delete the selection if it's before the cursor + editor.clearSelection(); + var range = editor.getSelectionRange(); + var line = editor.session.getLine(range.start.row); + range.end.column = line.length; + line = line.substr(range.start.column); + + var foldLine = editor.session.getFoldLine(range.start.row); + if (foldLine && range.end.row != foldLine.end.row) { + range.end.row = foldLine.end.row; + line = "x"; + } + // remove EOL if only whitespace remains after the cursor + if (/^\s*$/.test(line)) { + range.end.row++; + line = editor.session.getLine(range.end.row); + range.end.column = /^\s*$/.test(line) ? line.length : 0; + } + var text = editor.session.getTextRange(range); + if (editor.prevOp.command == this) + exports.killRing.append(text); + else + exports.killRing.add(text); + + editor.session.remove(range); + editor.clearSelection(); + }, + yank: function(editor) { + editor.onPaste(exports.killRing.get() || ''); + editor.keyBinding.$data.lastCommand = "yank"; + }, + yankRotate: function(editor) { + 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"; + }, + killRegion: { + exec: function(editor) { + exports.killRing.add(editor.getCopyText()); + editor.commands.byName.cut.exec(editor); + editor.setEmacsMark(null); + }, + 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() { + 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 + }, + keyboardQuit: function(editor) { + editor.selection.clearSelection(); + editor.setEmacsMark(null); + editor.keyBinding.$data.count = null; + }, + focusCommandLine: function(editor, arg) { + if (editor.showCommandLine) + editor.showCommandLine(arg); + } +}); + +exports.handler.addCommands(iSearchCommandModule.iSearchStartCommands); + +var commands = exports.handler.commands; +commands.yank.isYank = true; +commands.yankRotate.isYank = true; + +exports.killRing = { + $data: [], + add: function(str) { + str && this.$data.push(str); + if (this.$data.length > 30) + this.$data.shift(); + }, + append: function(str) { + var idx = this.$data.length - 1; + var text = this.$data[idx] || ""; + if (str) text += str; + if (text) this.$data[idx] = text; + }, + get: function(n) { + n = n || 1; + return this.$data.slice(this.$data.length-n, this.$data.length).reverse().join('\n'); + }, + pop: function() { + if (this.$data.length > 1) + this.$data.pop(); + return this.get(); + }, + rotate: function() { + this.$data.unshift(this.$data.pop()); + return this.get(); + } +}; + +}); diff --git a/public/lib/ace/keyboard/emacs_test.js b/public/lib/ace/keyboard/emacs_test.js new file mode 100644 index 0000000..2a30acc --- /dev/null +++ b/public/lib/ace/keyboard/emacs_test.js @@ -0,0 +1,173 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("../test/mockdom"); +} + +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, 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 = { + + "test: detach removes emacs commands from command manager": function() { + initEditor(''); + assert.ok(!!editor.commands.byName["keyboardQuit"], 'setup error: emacs commands not installed'); + editor.keyBinding.removeKeyboardHandler(editor.getKeyboardHandler()); + assert.ok(!editor.commands.byName["keyboardQuit"], 'emacs commands not removed'); + }, + + "test: keyboardQuit clears selection": function() { + initEditor('foo'); + 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)); + }, + + "test: killLine": function() { + initEditor("foo \n Hello world\n \n 123"); + sel.setRange(new Range(0, 0, 0, 2)); + editor.endOperation(); + editor.execCommand("killLine"); + assert.equal(editor.getValue(),"fo\n Hello world\n \n 123"); + editor.execCommand("killLine"); + assert.equal(editor.getValue(),"fo Hello world\n \n 123"); + editor.execCommand("killLine"); + assert.equal(editor.getValue(),"fo\n \n 123"); + editor.execCommand("killLine"); + assert.equal(editor.getValue(),"fo\n 123"); + editor.execCommand("killLine"); + assert.equal(editor.getValue(),"fo 123"); + editor.execCommand("killLine"); + assert.equal(editor.getValue(),"fo"); + editor.execCommand("killLine"); + editor.execCommand("yank"); + assert.equal(editor.getValue(),"foo \n Hello world\n \n 123"); + } + +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/keyboard/hash_handler.js b/public/lib/ace/keyboard/hash_handler.js new file mode 100644 index 0000000..1074fc2 --- /dev/null +++ b/public/lib/ace/keyboard/hash_handler.js @@ -0,0 +1,256 @@ +/* ***** 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 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 = {}; + 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]) + this.removeCommand(command); + + this.commands[command.name] = command; + + if (command.bindKey) + this._buildKeyHash(command); + }; + + this.removeCommand = function(command, keepCommand) { + var name = command && (typeof command === 'string' ? command : command.name); + command = 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 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, position) { + if (typeof key == "object" && key) { + if (position == undefined) + position = key.position; + key = key[this.platform]; + } + if (!key) + return; + if (typeof command == "function") + return this.addCommand({exec: command, bindKey: key, name: command.name || key}); + + key.split("|").forEach(function(keyPart) { + 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 + || (command.isDefault ? -100 : 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") { + 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) { + var command = commands[name]; + if (!command) + return; + + if (typeof command === "string") + return this.bindKey(command, name); + + if (typeof command === "function") + command = { exec: command }; + + if (typeof command !== "object") + return; + + if (!command.name) + command.name = name; + + this.addCommand(command); + }, this); + }; + + this.removeCommands = function(commands) { + Object.keys(commands).forEach(function(name) { + this.removeCommand(commands[name]); + }, this); + }; + + this.bindKeys = function(keyList) { + Object.keys(keyList).forEach(function(key) { + this.bindKey(key, keyList[key]); + }, this); + }; + + this._buildKeyHash = function(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) { + var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x;}); + var key = parts.pop(); + + var keyCode = keyUtil[key]; + if (keyUtil.FUNCTION_KEYS[keyCode]) + key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase(); + else if (!parts.length) + return {key: key, hashId: -1}; + else if (parts.length == 1 && parts[0] == "shift") + return {key: key.toUpperCase(), hashId: -1}; + + var hashId = 0; + for (var i = parts.length; i--;) { + var modifier = keyUtil.KEY_MODS[parts[i]]; + if (modifier == null) { + if (typeof console != "undefined") + console.error("invalid modifier " + parts[i] + " in " + keys); + return false; + } + hashId |= modifier; + } + return {key: key, hashId: hashId}; + }; + + this.findKeyCommand = function findKeyCommand(hashId, keyString) { + var key = KEY_MODS[hashId] + keyString; + return this.commandKeyBinding[key]; + }; + + this.handleKeyboard = function(data, hashId, keyString, keyCode) { + if (keyCode < 0) return; + 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); + +exports.HashHandler = HashHandler; +exports.MultiHashHandler = MultiHashHandler; +}); diff --git a/public/lib/ace/keyboard/keybinding.js b/public/lib/ace/keyboard/keybinding.js new file mode 100644 index 0000000..4879a3b --- /dev/null +++ b/public/lib/ace/keyboard/keybinding.js @@ -0,0 +1,152 @@ +/* ***** 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 keyUtil = require("../lib/keys"); +var event = require("../lib/event"); + +var KeyBinding = function(editor) { + this.$editor = editor; + this.$data = {editor: editor}; + this.$handlers = []; + this.setDefaultHandler(editor.commands); +}; + +(function() { + this.setDefaultHandler = function(kb) { + this.removeKeyboardHandler(this.$defaultHandler); + this.$defaultHandler = kb; + this.addKeyboardHandler(kb, 0); + }; + + this.setKeyboardHandler = function(kb) { + var h = this.$handlers; + if (h[h.length - 1] == kb) + return; + + while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler) + this.removeKeyboardHandler(h[h.length - 1]); + + this.addKeyboardHandler(kb, 1); + }; + + this.addKeyboardHandler = function(kb, pos) { + if (!kb) + return; + if (typeof kb == "function" && !kb.handleKeyboard) + kb.handleKeyboard = kb; + var i = this.$handlers.indexOf(kb); + if (i != -1) + this.$handlers.splice(i, 1); + + if (pos == undefined) + this.$handlers.push(kb); + else + this.$handlers.splice(pos, 0, kb); + + if (i == -1 && kb.attach) + kb.attach(this.$editor); + }; + + this.removeKeyboardHandler = function(kb) { + var i = this.$handlers.indexOf(kb); + if (i == -1) + return false; + this.$handlers.splice(i, 1); + kb.detach && kb.detach(this.$editor); + return true; + }; + + 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) { + var toExecute; + var success = false; + var commands = this.$editor.commands; + + for (var i = this.$handlers.length; i--;) { + toExecute = this.$handlers[i].handleKeyboard( + this.$data, hashId, keyString, keyCode, e + ); + if (!toExecute || !toExecute.command) + continue; + + // allow keyboardHandler to consume keys + if (toExecute.command == "null") { + success = true; + } else { + success = commands.exec(toExecute.command, this.$editor, toExecute.args, e); + } + // do not stop input events to not break repeating + if (success && e && hashId != -1 && + toExecute.passEvent != true && toExecute.command.passEvent != true + ) { + event.stopEvent(e); + } + if (success) + break; + } + + if (!success && hashId == -1) { + toExecute = {command: "insertstring"}; + success = commands.exec("insertstring", this.$editor, keyString); + } + + if (success && this.$editor._signal) + this.$editor._signal("keyboardActivity", toExecute); + + return success; + }; + + this.onCommandKey = function(e, hashId, keyCode) { + var keyString = keyUtil.keyCodeToString(keyCode); + this.$callKeyboardHandlers(hashId, keyString, keyCode, e); + }; + + this.onTextInput = function(text) { + this.$callKeyboardHandlers(-1, text); + }; + +}).call(KeyBinding.prototype); + +exports.KeyBinding = KeyBinding; +}); diff --git a/public/lib/ace/keyboard/keybinding_test.js b/public/lib/ace/keyboard/keybinding_test.js new file mode 100644 index 0000000..eee6d59 --- /dev/null +++ b/public/lib/ace/keyboard/keybinding_test.js @@ -0,0 +1,69 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { +"use strict"; + +var EditSession = require("./../edit_session").EditSession, + Editor = require("./../editor").Editor, + MockRenderer = require("./../test/mockrenderer").MockRenderer, + assert = require("./../test/assertions"), + HashHandler = require('./hash_handler').HashHandler, + keys = require('../lib/keys'), + editor; + +function initEditor(docString) { + var doc = new EditSession(docString.split("\n")); + editor = new Editor(new MockRenderer(), doc); +} + +module.exports = { + + "test: adding a new keyboard handler does not remove the default handler": function() { + initEditor('abc'); + var handler = new HashHandler({'del': 'f1'}); + editor.keyBinding.setKeyboardHandler(handler); + editor.onCommandKey({}, 0, keys['f1']); + assert.equal('bc', editor.getValue(), "binding of new handler"); + editor.onCommandKey({}, 0, keys['delete']); + assert.equal('c', editor.getValue(), "bindings of the old handler should still work"); + } + +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/keyboard/state_handler.js b/public/lib/ace/keyboard/state_handler.js new file mode 100644 index 0000000..6859e74 --- /dev/null +++ b/public/lib/ace/keyboard/state_handler.js @@ -0,0 +1,249 @@ +/* ***** 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"; + +// If you're developing a new keymapping and want to get an idea what's going +// on, then enable debugging. +var DEBUG = false; + +function StateHandler(keymapping) { + this.keymapping = this.$buildKeymappingRegex(keymapping); +} + +StateHandler.prototype = { + /* + * Build the RegExp from the keymapping as RegExp can't stored directly + * in the metadata JSON and as the RegExp used to match the keys/buffer + * need to be adapted. + */ + $buildKeymappingRegex: function(keymapping) { + for (var state in keymapping) { + this.$buildBindingsRegex(keymapping[state]); + } + return keymapping; + }, + + $buildBindingsRegex: function(bindings) { + // Escape a given Regex string. + bindings.forEach(function(binding) { + if (binding.key) { + binding.key = new RegExp('^' + binding.key + '$'); + } else if (Array.isArray(binding.regex)) { + if (!('key' in binding)) + binding.key = new RegExp('^' + binding.regex[1] + '$'); + binding.regex = new RegExp(binding.regex.join('') + '$'); + } else if (binding.regex) { + binding.regex = new RegExp(binding.regex + '$'); + } + }); + }, + + $composeBuffer: function(data, hashId, key, e) { + // Initialize the data object. + if (data.state == null || data.buffer == null) { + data.state = "start"; + data.buffer = ""; + } + + var keyArray = []; + if (hashId & 1) keyArray.push("ctrl"); + if (hashId & 8) keyArray.push("command"); + if (hashId & 2) keyArray.push("option"); + if (hashId & 4) keyArray.push("shift"); + if (key) keyArray.push(key); + + var symbolicName = keyArray.join("-"); + var bufferToUse = data.buffer + symbolicName; + + // Don't add the symbolic name to the key buffer if the alt_ key is + // part of the symbolic name. If it starts with alt_, this means + // that the user hit an alt keycombo and there will be a single, + // new character detected after this event, which then will be + // added to the buffer (e.g. alt_j will result in ∆). + // + // We test for 2 and not for & 2 as we only want to exclude the case where + // the option key is pressed alone. + if (hashId != 2) { + data.buffer = bufferToUse; + } + + var bufferObj = { + bufferToUse: bufferToUse, + symbolicName: symbolicName + }; + + if (e) { + bufferObj.keyIdentifier = e.keyIdentifier; + } + + return bufferObj; + }, + + $find: function(data, buffer, symbolicName, hashId, key, keyIdentifier) { + // Holds the command to execute and the args if a command matched. + var result = {}; + + // Loop over all the bindings of the keymap until a match is found. + this.keymapping[data.state].some(function(binding) { + var match; + + // Check if the key matches. + if (binding.key && !binding.key.test(symbolicName)) { + return false; + } + + // Check if the regex matches. + if (binding.regex && !(match = binding.regex.exec(buffer))) { + return false; + } + + // Check if the match function matches. + if (binding.match && !binding.match(buffer, hashId, key, symbolicName, keyIdentifier)) { + return false; + } + + // Check for disallowed matches. + if (binding.disallowMatches) { + for (var i = 0; i < binding.disallowMatches.length; i++) { + if (!!match[binding.disallowMatches[i]]) { + return false; + } + } + } + + // If there is a command to execute, then figure out the + // command and the arguments. + if (binding.exec) { + result.command = binding.exec; + + // Build the arguments. + if (binding.params) { + var value; + result.args = {}; + binding.params.forEach(function(param) { + if (param.match != null && match != null) { + value = match[param.match] || param.defaultValue; + } else { + value = param.defaultValue; + } + + if (param.type === 'number') { + value = parseInt(value); + } + + result.args[param.name] = value; + }); + } + data.buffer = ""; + } + + // Handle the 'then' property. + if (binding.then) { + data.state = binding.then; + data.buffer = ""; + } + + // If no command is set, then execute the "null" fake command. + if (result.command == null) { + result.command = "null"; + } + + if (DEBUG) { + console.log("KeyboardStateMapper#find", binding); + } + return true; + }); + + if (result.command) { + return result; + } else { + data.buffer = ""; + return false; + } + }, + + /* + * This function is called by keyBinding. + */ + handleKeyboard: function(data, hashId, key, keyCode, e) { + if (hashId == -1) + hashId = 0; + // If we pressed any command key but no other key, then ignore the input. + // Otherwise "shift-" is added to the buffer, and later on "shift-g" + // which results in "shift-shift-g" which doesn't make sense. + if (hashId != 0 && (key == "" || key == String.fromCharCode(0))) { + return null; + } + + // Compute the current value of the keyboard input buffer. + var r = this.$composeBuffer(data, hashId, key, e); + var buffer = r.bufferToUse; + var symbolicName = r.symbolicName; + var keyId = r.keyIdentifier; + + r = this.$find(data, buffer, symbolicName, hashId, key, keyId); + if (DEBUG) { + console.log("KeyboardStateMapper#match", buffer, symbolicName, r); + } + + return r; + } +}; + +/* + * This is a useful matching function and therefore is defined here so that + * users of KeyboardStateMapper can use it. + * + * @return {Boolean} If no command key (Command|Option|Shift|Ctrl) is pressed, it + * returns true. If the only the Shift key is pressed + a character + * true is returned as well. Otherwise, false is returned. + * Summing up, the function returns true whenever the user typed + * a normal character on the keyboard and no shortcut. + */ +exports.matchCharacterOnly = function(buffer, hashId, key, symbolicName) { + // If no command keys are pressed, then catch the input. + if (hashId == 0) { + return true; + } + // If only the shift key is pressed and a character key, then + // catch that input as well. + else if ((hashId == 4) && key.length == 1) { + return true; + } + // Otherwise, we let the input got through. + else { + return false; + } +}; + +exports.StateHandler = StateHandler; +}); diff --git a/public/lib/ace/keyboard/textarea.js b/public/lib/ace/keyboard/textarea.js new file mode 100644 index 0000000..d0e2088 --- /dev/null +++ b/public/lib/ace/keyboard/textarea.js @@ -0,0 +1,88 @@ +/* ***** 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|Ctrl-K", mac: "Cmd-T|Cmd-Shift-T"}, + // TODO can't used shared passKeysToBrowser command since passEvent from it is ignored + command: { + name: "passKeysToBrowser", + exec: function() {}, + passEvent: true, + readOnly: true + } +}, { + bindKey: {win: "Ctrl-G", mac: "Cmd-G"}, + command: "passKeysToBrowser" +}, { + bindKey: {win: "Ctrl-G", mac: "Cmd-G"}, + command: "passKeysToBrowser" +}, { + command: "golineup", + bindKey: {win: null, mac: "Ctrl-P"} +}, { + command: "golinedown", + bindKey: {win: null, mac: "Ctrl-N"} +}, { + command: "gotoleft", + bindKey: {win: null, mac: "Ctrl-B"} +}, { + command: "gotoright", + bindKey: {win: null, mac: "Ctrl-F"} +}, { + command: "gotolineend", + bindKey: {win: null, mac: "Ctrl-E"} +}, { + command: "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"; + +}); diff --git a/public/lib/ace/keyboard/textinput.js b/public/lib/ace/keyboard/textinput.js new file mode 100644 index 0000000..3a55afc --- /dev/null +++ b/public/lib/ace/keyboard/textinput.js @@ -0,0 +1,480 @@ +/* ***** 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 event = require("../lib/event"); +var useragent = require("../lib/useragent"); +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var BROKEN_SETDATA = useragent.isChrome < 18; +var USE_IE_MIME_TYPE = useragent.isIE; + +var TextInputIOS = require("./textinput_ios").TextInput; +var TextInput = function(parentNode, host) { + if (useragent.isIOS) + return TextInputIOS.call(this, parentNode, host); + + var text = dom.createElement("textarea"); + text.className = "ace_text-input"; + + text.setAttribute("wrap", "off"); + text.setAttribute("autocorrect", "off"); + text.setAttribute("autocapitalize", "off"); + text.setAttribute("spellcheck", false); + + text.style.opacity = "0"; + parentNode.insertBefore(text, parentNode.firstChild); + + var PLACEHOLDER = "\u2028\u2028"; + + var copied = false; + var pasted = false; + var inComposition = false; + var tempStyle = ''; + var isSelectionEmpty = true; + + // FOCUS + // ie9 throws error if document.activeElement is accessed too soon + try { var isFocused = document.activeElement === text; } catch(e) {} + + event.addListener(text, "blur", function(e) { + host.onBlur(e); + isFocused = false; + }); + event.addListener(text, "focus", function(e) { + isFocused = true; + host.onFocus(e); + resetSelection(); + }); + this.focus = function() { + if (tempStyle) return text.focus(); + var top = text.style.top; + text.style.position = "fixed"; + text.style.top = "0px"; + text.focus(); + setTimeout(function() { + text.style.position = ""; + if (text.style.top == "0px") + text.style.top = top; + }, 0); + }; + this.blur = function() { + text.blur(); + }; + this.isFocused = function() { + return isFocused; + }; + + // modifying selection of blured textarea can focus it (chrome mac/linux) + var syncSelection = lang.delayedCall(function() { + isFocused && resetSelection(isSelectionEmpty); + }); + var syncValue = lang.delayedCall(function() { + if (!inComposition) { + text.value = PLACEHOLDER; + isFocused && resetSelection(); + } + }); + + 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) { + var selectionStart = 0; + var selectionEnd = isEmpty ? 0 : text.value.length - 1; + } else { + var selectionStart = isEmpty ? 2 : 1; + var selectionEnd = 2; + } + // on firefox this throws if textarea is hidden + try { + text.setSelectionRange(selectionStart, selectionEnd); + } catch(e){} + + inComposition = false; + } + + function resetValue() { + if (inComposition) + return; + text.value = PLACEHOLDER; + //http://code.google.com/p/chromium/issues/detail?id=76516 + if (useragent.isWebKit) + syncValue.schedule(); + } + + useragent.isWebKit || host.addEventListener('changeSelection', function() { + if (host.selection.isEmpty() != isSelectionEmpty) { + isSelectionEmpty = !isSelectionEmpty; + syncSelection.schedule(); + } + }); + + resetValue(); + if (isFocused) + host.onFocus(); + + + var isAllSelected = function(text) { + return text.selectionStart === 0 && text.selectionEnd === text.value.length; + }; + + var onSelect = function(e) { + if (copied) { + copied = false; + } else if (isAllSelected(text)) { + host.selectAll(); + resetSelection(); + } else if (inputHandler) { + resetSelection(host.selection.isEmpty()); + } + }; + + var inputHandler = null; + this.setInputHandler = function(cb) {inputHandler = cb;}; + this.getInputHandler = function() {return inputHandler;}; + var afterContextMenu = false; + + var sendText = function(data) { + if (inputHandler) { + data = inputHandler(data); + inputHandler = null; + } + if (pasted) { + resetSelection(); + if (data) + host.onPaste(data); + pasted = false; + } else if (data == PLACEHOLDER.charAt(0)) { + if (afterContextMenu) + host.execCommand("del", {source: "ace"}); + else // some versions of android do not fire keydown when pressing backspace + host.execCommand("backspace", {source: "ace"}); + } else { + if (data.substring(0, 2) == PLACEHOLDER) + data = data.substr(2); + else if (data.charAt(0) == PLACEHOLDER.charAt(0)) + data = data.substr(1); + else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0)) + data = data.slice(0, -1); + // can happen if undo in textarea isn't stopped + if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0)) + data = data.slice(0, -1); + + if (data) + host.onTextInput(data); + } + if (afterContextMenu) + afterContextMenu = false; + }; + var onInput = function(e) { + // console.log("onInput", inComposition) + if (inComposition) + return; + var data = text.value; + sendText(data); + resetValue(); + }; + + var handleClipboardData = function(e, data, forceIEMime) { + var clipboardData = e.clipboardData || window.clipboardData; + if (!clipboardData || BROKEN_SETDATA) + return; + // using "Text" doesn't work on old webkit but ie needs it + var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain"; + try { + if (data) { + // Safari 5 has clipboardData object, but does not handle setData() + return clipboardData.setData(mime, data) !== false; + } else { + return clipboardData.getData(mime); + } + } catch(e) { + if (!forceIEMime) + return handleClipboardData(e, data, true); + } + }; + + var doCopy = function(e, isCut) { + var data = host.getCopyText(); + if (!data) + return event.preventDefault(e); + + if (handleClipboardData(e, data)) { + isCut ? host.onCut() : host.onCopy(); + event.preventDefault(e); + } else { + copied = true; + text.value = data; + text.select(); + setTimeout(function(){ + copied = false; + resetValue(); + resetSelection(); + isCut ? host.onCut() : host.onCopy(); + }); + } + }; + + 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, e); + if (useragent.isIE) + setTimeout(resetSelection); + event.preventDefault(e); + } + else { + text.value = ""; + pasted = true; + } + }; + + event.addCommandKeyListener(text, host.onCommandKey.bind(host)); + + event.addListener(text, "select", onSelect); + + event.addListener(text, "input", onInput); + + event.addListener(text, "cut", onCut); + event.addListener(text, "copy", onCopy); + event.addListener(text, "paste", onPaste); + + + // Opera has no clipboard events + if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)) { + event.addListener(parentNode, "keydown", function(e) { + if ((useragent.isMac && !e.metaKey) || !e.ctrlKey) + return; + + switch (e.keyCode) { + case 67: + onCopy(e); + break; + case 86: + onPaste(e); + break; + case 88: + onCut(e); + break; + } + }); + } + + + // COMPOSITION + var onCompositionStart = function(e) { + if (inComposition || !host.onCompositionStart || host.$readOnly) + return; + // console.log("onCompositionStart", inComposition) + inComposition = {}; + inComposition.canUndo = host.session.$undoManager; + host.onCompositionStart(); + setTimeout(onCompositionUpdate, 0); + host.on("mousedown", onCompositionEnd); + if (inComposition.canUndo && !host.selection.isEmpty()) { + host.insert(""); + host.session.markUndoGroup(); + host.selection.clearSelection(); + } + host.session.markUndoGroup(); + }; + + var onCompositionUpdate = function() { + // console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value)) + if (!inComposition || !host.onCompositionUpdate || host.$readOnly) + return; + var val = text.value.replace(/\u2028/g, ""); + if (inComposition.lastValue === val) return; + + host.onCompositionUpdate(val); + if (inComposition.lastValue) + host.undo(); + if (inComposition.canUndo) + inComposition.lastValue = val; + if (inComposition.lastValue) { + var r = host.selection.getRange(); + host.insert(inComposition.lastValue); + host.session.markUndoGroup(); + inComposition.range = host.selection.getRange(); + host.selection.setRange(r); + host.selection.clearSelection(); + } + }; + + var onCompositionEnd = function(e) { + if (!host.onCompositionEnd || host.$readOnly) return; + // console.log("onCompositionEnd", inComposition &&inComposition.lastValue) + var c = inComposition; + inComposition = false; + var timer = setTimeout(function() { + timer = null; + var str = text.value.replace(/\u2028/g, ""); + // console.log(str, c.lastValue) + if (inComposition) + return; + else if (str == c.lastValue) + resetValue(); + else if (!c.lastValue && str) { + resetValue(); + sendText(str); + } + }); + inputHandler = function compositionInputHandler(str) { + // console.log("onCompositionEnd", str, c.lastValue) + if (timer) + clearTimeout(timer); + str = str.replace(/\u2028/g, ""); + if (str == c.lastValue) + return ""; + if (c.lastValue && timer) + host.undo(); + return str; + }; + host.onCompositionEnd(); + host.removeListener("mousedown", onCompositionEnd); + if (e.type == "compositionend" && c.range) { + host.selection.setRange(c.range); + } + // Workaround for #3027, #3045, #3097, #3100, #3249 + var needsOnInput = + (!!useragent.isChrome && useragent.isChrome >= 53) || + (!!useragent.isWebKit && useragent.isWebKit >= 603); + + if (needsOnInput) { + onInput(); + } + }; + + + + var syncComposition = lang.delayedCall(onCompositionUpdate, 50); + + event.addListener(text, "compositionstart", onCompositionStart); + if (useragent.isGecko) { + event.addListener(text, "text", function(){syncComposition.schedule();}); + } else { + event.addListener(text, "keyup", function(){syncComposition.schedule();}); + event.addListener(text, "keydown", function(){syncComposition.schedule();}); + } + event.addListener(text, "compositionend", onCompositionEnd); + + this.getElement = function() { + return text; + }; + + this.setReadOnly = function(readOnly) { + text.readOnly = readOnly; + }; + + this.onContextMenu = function(e) { + afterContextMenu = true; + resetSelection(host.selection.isEmpty()); + host._emit("nativecontextmenu", {target: host, domEvent: e}); + this.moveToMouse(e, true); + }; + + this.moveToMouse = function(e, bringToFront) { + 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 -2; + var move = function(e) { + text.style.left = e.clientX - left - 2 + "px"; + text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px"; + }; + move(e); + + if (e.type != "mousedown") + return; + + if (host.renderer.$keepTextAreaAtCursor) + host.renderer.$keepTextAreaAtCursor = null; + + clearTimeout(closeTimeout); + // on windows context menu is opened after mouseup + if (useragent.isWin) + event.capture(host.container, move, onContextMenuClose); + }; + + this.onContextMenuClose = onContextMenuClose; + var closeTimeout; + function onContextMenuClose() { + clearTimeout(closeTimeout); + closeTimeout = setTimeout(function () { + if (tempStyle) { + text.style.cssText = tempStyle; + tempStyle = ''; + } + if (host.renderer.$keepTextAreaAtCursor == null) { + host.renderer.$keepTextAreaAtCursor = true; + host.renderer.$moveTextAreaToCursor(); + } + }, 0); + } + + var onContextMenu = function(e) { + host.textInput.onContextMenu(e); + onContextMenuClose(); + }; + event.addListener(text, "mouseup", onContextMenu); + event.addListener(text, "mousedown", function(e) { + e.preventDefault(); + onContextMenuClose(); + }); + event.addListener(host.renderer.scroller, "contextmenu", onContextMenu); + event.addListener(text, "contextmenu", onContextMenu); +}; + +exports.TextInput = TextInput; +}); diff --git a/public/lib/ace/keyboard/textinput_ios.js b/public/lib/ace/keyboard/textinput_ios.js new file mode 100644 index 0000000..01671cb --- /dev/null +++ b/public/lib/ace/keyboard/textinput_ios.js @@ -0,0 +1,530 @@ +/* ***** 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 event = require("../lib/event"); +var useragent = require("../lib/useragent"); +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var KEYS = require("../lib/keys"); +var MODS = KEYS.KEY_MODS; +var BROKEN_SETDATA = useragent.isChrome < 18; +var USE_IE_MIME_TYPE = useragent.isIE; + +var TextInput = function(parentNode, host) { + var self = this; + var text = dom.createElement("textarea"); + text.className = useragent.isIOS ? "ace_text-input ace_text-input-ios" : "ace_text-input"; + + if (useragent.isTouchPad) + text.setAttribute("x-palm-disable-auto-cap", true); + + text.setAttribute("wrap", "off"); + text.setAttribute("autocorrect", "off"); + text.setAttribute("autocapitalize", "off"); + text.setAttribute("spellcheck", false); + + text.style.opacity = "0"; + parentNode.insertBefore(text, parentNode.firstChild); + + var PLACEHOLDER = "\n aaaa a\n"; + + var copied = false; + var cut = false; + var pasted = false; + var inComposition = false; + var tempStyle = ''; + var isSelectionEmpty = true; + + // FOCUS + // ie9 throws error if document.activeElement is accessed too soon + try { var isFocused = document.activeElement === text; } catch(e) {} + + event.addListener(text, "blur", function(e) { + host.onBlur(e); + isFocused = false; + }); + event.addListener(text, "focus", function(e) { + isFocused = true; + host.onFocus(e); + resetSelection(); + }); + this.focus = function() { + if (tempStyle) return text.focus(); + text.style.position = "fixed"; + text.focus(); + }; + this.blur = function() { + text.blur(); + }; + this.isFocused = function() { + return isFocused; + }; + + // modifying selection of blured textarea can focus it (chrome mac/linux) + var syncSelection = lang.delayedCall(function() { + isFocused && resetSelection(isSelectionEmpty); + }); + var syncValue = lang.delayedCall(function() { + if (!inComposition) { + text.value = PLACEHOLDER; + isFocused && resetSelection(); + } + }); + + 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; + } else { + var selectionStart = 4; + var selectionEnd = 5; + } + // on firefox this throws if textarea is hidden + try { + text.setSelectionRange(selectionStart, selectionEnd); + } catch(e) {} + + inComposition = false; + } + + function resetValue() { + if (inComposition) + return; + text.value = PLACEHOLDER; + //http://code.google.com/p/chromium/issues/detail?id=76516 + if (useragent.isWebKit) + syncValue.schedule(); + } + + useragent.isWebKit || host.addEventListener('changeSelection', function() { + if (host.selection.isEmpty() != isSelectionEmpty) { + isSelectionEmpty = !isSelectionEmpty; + syncSelection.schedule(); + } + }); + + resetValue(); + if (isFocused) + host.onFocus(); + + + var isAllSelected = function(text) { + return text.selectionStart === 0 && text.selectionEnd === text.value.length; + }; + + var onSelect = function(e) { + if (isAllSelected(text)) { + host.selectAll(); + resetSelection(); + } else if (inputHandler) { + resetSelection(host.selection.isEmpty()); + } + }; + + var inputHandler = null; + this.setInputHandler = function(cb) {inputHandler = cb;}; + this.getInputHandler = function() {return inputHandler;}; + var afterContextMenu = false; + + var sendText = function(data) { + if (text.selectionStart === 4 && text.selectionEnd === 5) { + return; + } + if (inputHandler) { + data = inputHandler(data); + inputHandler = null; + } + if (pasted) { + resetSelection(); + if (data) + host.onPaste(data); + pasted = false; + } else if (data == PLACEHOLDER.substr(0) && text.selectionStart === 4) { + if (afterContextMenu) + host.execCommand("del", {source: "ace"}); + else // some versions of android do not fire keydown when pressing backspace + host.execCommand("backspace", {source: "ace"}); + } else if (!copied) { + if (data.substring(0, 9) == PLACEHOLDER && data.length > PLACEHOLDER.length) + data = data.substr(9); + else if (data.substr(0, 4) == PLACEHOLDER.substr(0, 4)) + data = data.substr(4, data.length - PLACEHOLDER.length + 1); + else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0)) + data = data.slice(0, -1); + // can happen if undo in textarea isn't stopped + if (data == PLACEHOLDER.charAt(0)) { + // Do nothing + } else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0)) + data = data.slice(0, -1); + + if (data) + host.onTextInput(data); + } + if (copied) { + copied = false; + } + if (afterContextMenu) + afterContextMenu = false; + }; + var onInput = function(e) { + // console.log("onInput", inComposition) + if (inComposition) + return; + var data = text.value; + sendText(data); + resetValue(); + }; + + var handleClipboardData = function(e, data, forceIEMime) { + var clipboardData = e.clipboardData || window.clipboardData; + if (!clipboardData || BROKEN_SETDATA) + return; + // using "Text" doesn't work on old webkit but ie needs it + var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain"; + try { + if (data) { + // Safari 5 has clipboardData object, but does not handle setData() + return clipboardData.setData(mime, data) !== false; + } else { + return clipboardData.getData(mime); + } + } catch(e) { + if (!forceIEMime) + return handleClipboardData(e, data, true); + } + }; + + var doCopy = function(e, isCut) { + var data = host.getCopyText(); + if (!data) + return event.preventDefault(e); + + if (handleClipboardData(e, data)) { + if (useragent.isIOS) { + cut = isCut; + text.value = "\n aa" + data + "a a\n"; + text.setSelectionRange(4, 4 + data.length); + copied = { + value: data + }; + } + isCut ? host.onCut() : host.onCopy(); + if (!useragent.isIOS) event.preventDefault(e); + } else { + copied = true; + text.value = data; + text.select(); + setTimeout(function(){ + copied = false; + resetValue(); + resetSelection(); + isCut ? host.onCut() : host.onCopy(); + }); + } + }; + + 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, e); + if (useragent.isIE) + setTimeout(resetSelection); + event.preventDefault(e); + } + else { + text.value = ""; + pasted = true; + } + }; + + event.addCommandKeyListener(text, host.onCommandKey.bind(host)); + + event.addListener(text, "select", onSelect); + + event.addListener(text, "input", onInput); + + event.addListener(text, "cut", onCut); + event.addListener(text, "copy", onCopy); + event.addListener(text, "paste", onPaste); + + + // COMPOSITION + var onCompositionStart = function(e) { + if (inComposition || !host.onCompositionStart || host.$readOnly) + return; + // console.log("onCompositionStart", inComposition) + inComposition = {}; + inComposition.canUndo = host.session.$undoManager; + host.onCompositionStart(); + setTimeout(onCompositionUpdate, 0); + host.on("mousedown", onCompositionEnd); + if (inComposition.canUndo && !host.selection.isEmpty()) { + host.insert(""); + host.session.markUndoGroup(); + host.selection.clearSelection(); + } + host.session.markUndoGroup(); + }; + + var onCompositionUpdate = function() { + // console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value)) + if (!inComposition || !host.onCompositionUpdate || host.$readOnly) + return; + var val = text.value.replace(/\x01/g, ""); + if (inComposition.lastValue === val) return; + + host.onCompositionUpdate(val); + if (inComposition.lastValue) + host.undo(); + if (inComposition.canUndo) + inComposition.lastValue = val; + if (inComposition.lastValue) { + var r = host.selection.getRange(); + host.insert(inComposition.lastValue); + host.session.markUndoGroup(); + inComposition.range = host.selection.getRange(); + host.selection.setRange(r); + host.selection.clearSelection(); + } + }; + + var onCompositionEnd = function(e) { + if (!host.onCompositionEnd || host.$readOnly) return; + // console.log("onCompositionEnd", inComposition &&inComposition.lastValue) + var c = inComposition; + inComposition = false; + var timer = setTimeout(function() { + timer = null; + var str = text.value.replace(/\x01/g, ""); + // console.log(str, c.lastValue) + if (inComposition) + return; + else if (str == c.lastValue) + resetValue(); + else if (!c.lastValue && str) { + resetValue(); + sendText(str); + } + }); + inputHandler = function compositionInputHandler(str) { + // console.log("onCompositionEnd", str, c.lastValue) + if (timer) + clearTimeout(timer); + str = str.replace(/\x01/g, ""); + if (str == c.lastValue) + return ""; + if (c.lastValue && timer) + host.undo(); + return str; + }; + host.onCompositionEnd(); + host.removeListener("mousedown", onCompositionEnd); + if (e.type == "compositionend" && c.range) { + host.selection.setRange(c.range); + } + // Workaround for #3027, #3045, #3097, #3100, #3249 + var needsOnInput = + (!!useragent.isChrome && useragent.isChrome >= 53) || + (!!useragent.isWebKit && useragent.isWebKit >= 603); + + if (needsOnInput) { + onInput(); + } + }; + + + + var syncComposition = lang.delayedCall(onCompositionUpdate, 50); + + event.addListener(text, "compositionstart", onCompositionStart); + if (useragent.isGecko) { + event.addListener(text, "text", function(){syncComposition.schedule();}); + } else { + event.addListener(text, "keyup", function(){syncComposition.schedule();}); + event.addListener(text, "keydown", function(){syncComposition.schedule();}); + } + event.addListener(text, "compositionend", onCompositionEnd); + + this.getElement = function() { + return text; + }; + + this.setReadOnly = function(readOnly) { + text.readOnly = readOnly; + }; + + this.onContextMenu = function(e) { + afterContextMenu = true; + resetSelection(host.selection.isEmpty()); + host._emit("nativecontextmenu", {target: host, domEvent: e}); + this.moveToMouse(e, true); + }; + + this.moveToMouse = function(e, bringToFront) { + 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 -2; + var move = function(e) { + text.style.left = e.clientX - left - 2 + "px"; + text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px"; + }; + move(e); + + if (e.type != "mousedown") + return; + + if (host.renderer.$keepTextAreaAtCursor) + host.renderer.$keepTextAreaAtCursor = null; + + clearTimeout(closeTimeout); + // on windows context menu is opened after mouseup + if (useragent.isWin) + event.capture(host.container, move, onContextMenuClose); + }; + + this.onContextMenuClose = onContextMenuClose; + var closeTimeout; + function onContextMenuClose() { + clearTimeout(closeTimeout); + closeTimeout = setTimeout(function () { + if (tempStyle) { + text.style.cssText = tempStyle; + tempStyle = ''; + } + if (host.renderer.$keepTextAreaAtCursor == null) { + host.renderer.$keepTextAreaAtCursor = true; + host.renderer.$moveTextAreaToCursor(); + } + }, 0); + } + + var onContextMenu = function(e) { + host.textInput.onContextMenu(e); + onContextMenuClose(); + }; + event.addListener(text, "mouseup", onContextMenu); + event.addListener(text, "mousedown", function(e) { + e.preventDefault(); + onContextMenuClose(); + }); + event.addListener(host.renderer.scroller, "contextmenu", onContextMenu); + event.addListener(text, "contextmenu", onContextMenu); + + if (useragent.isIOS) { + var typingResetTimeout = null; + var typing = false; + + parentNode.addEventListener("keydown", function (e) { + if (typingResetTimeout) clearTimeout(typingResetTimeout); + typing = true; + }); + + parentNode.addEventListener("keyup", function (e) { + typingResetTimeout = setTimeout(function () { + typing = false; + }, 100); + }); + + // IOS doesn't fire events for arrow keys, but this unique hack changes everything! + var detectArrowKeys = function(e) { + if (document.activeElement !== text) return; + if (typing) return; + + if (cut) { + return setTimeout(function () { + cut = false; + }, 100); + } + var selectionStart = text.selectionStart; + var selectionEnd = text.selectionEnd; + text.setSelectionRange(4, 5); + if (selectionStart == selectionEnd) { + switch (selectionStart) { + case 0: host.onCommandKey(null, 0, KEYS.up); break; + case 1: host.onCommandKey(null, 0, KEYS.home); break; + case 2: host.onCommandKey(null, MODS.option, KEYS.left); break; + case 4: host.onCommandKey(null, 0, KEYS.left); break; + case 5: host.onCommandKey(null, 0, KEYS.right); break; + case 7: host.onCommandKey(null, MODS.option, KEYS.right); break; + case 8: host.onCommandKey(null, 0, KEYS.end); break; + case 9: host.onCommandKey(null, 0, KEYS.down); break; + } + } else { + switch (selectionEnd) { + case 6: host.onCommandKey(null, MODS.shift, KEYS.right); break; + case 7: host.onCommandKey(null, MODS.shift | MODS.option, KEYS.right); break; + case 8: host.onCommandKey(null, MODS.shift, KEYS.end); break; + case 9: host.onCommandKey(null, MODS.shift, KEYS.down); break; + } + switch (selectionStart) { + case 0: host.onCommandKey(null, MODS.shift, KEYS.up); break; + case 1: host.onCommandKey(null, MODS.shift, KEYS.home); break; + case 2: host.onCommandKey(null, MODS.shift | MODS.option, KEYS.left); break; + case 3: host.onCommandKey(null, MODS.shift, KEYS.left); break; + } + } + }; + // On iOS, "selectionchange" can only be attached to the document object... + document.addEventListener("selectionchange", detectArrowKeys); + host.on("destroy", function() { + document.removeEventListener("selectionchange", detectArrowKeys); + }); + } +}; + +exports.TextInput = TextInput; +}); diff --git a/public/lib/ace/keyboard/vim.js b/public/lib/ace/keyboard/vim.js new file mode 100644 index 0000000..426d8cc --- /dev/null +++ b/public/lib/ace/keyboard/vim.js @@ -0,0 +1,6249 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +/** + * Supported keybindings: + * Too many to list. Refer to defaultKeyMap below. + * + * Supported Ex commands: + * Refer to defaultExCommandMap below. + * + * Registers: unnamed, -, a-z, A-Z, 0-9 + * (Does not respect the special case for number registers when delete + * operator is made with these commands: %, (, ), , /, ?, n, N, {, } ) + * TODO: Implement the remaining registers. + * + * Marks: a-z, A-Z, and 0-9 + * TODO: Implement the remaining special marks. They have more complex + * behavior. + * + * Events: + * 'vim-mode-change' - raised on the editor anytime the current mode changes, + * Event object: {mode: "visual", subMode: "linewise"} + * + * Code structure: + * 1. Default keymap + * 2. Variable declarations and short basic helpers + * 3. Instance (External API) implementation + * 4. Internal state tracking objects (input state, counter) implementation + * and instanstiation + * 5. Key handler (the main command dispatcher) implementation + * 6. Motion, operator, and action implementations + * 7. Helper functions for the key handler, motions, operators, and actions + * 8. Set up Vim to work as a keymap for CodeMirror. + * 9. Ex command implementations. + */ + +define(function(require, exports, module) { + 'use strict'; + + function log() { + var d = ""; + function format(p) { + if (typeof p != "object") + return p + ""; + if ("line" in p) { + return p.line + ":" + p.ch; + } + if ("anchor" in p) { + return format(p.anchor) + "->" + format(p.head); + } + if (Array.isArray(p)) + return "[" + p.map(function(x) { + return format(x); + }) + "]"; + return JSON.stringify(p); + } + for (var i = 0; i < arguments.length; i++) { + var p = arguments[i]; + var f = format(p); + d += f + " "; + } + console.log(d); + } + var Range = require("../range").Range; + var EventEmitter = require("../lib/event_emitter").EventEmitter; + var dom = require("../lib/dom"); + var oop = require("../lib/oop"); + var KEYS = require("../lib/keys"); + var event = require("../lib/event"); + var Search = require("../search").Search; + var useragent = require("../lib/useragent"); + var SearchHighlight = require("../search_highlight").SearchHighlight; + var multiSelectCommands = require("../commands/multi_select_commands"); + var TextModeTokenRe = require("../mode/text").Mode.prototype.tokenRe; + require("../multi_select"); + + var CodeMirror = function(ace) { + this.ace = ace; + this.state = {}; + this.marks = {}; + this.$uid = 0; + this.onChange = this.onChange.bind(this); + this.onSelectionChange = this.onSelectionChange.bind(this); + this.onBeforeEndOperation = this.onBeforeEndOperation.bind(this); + this.ace.on('change', this.onChange); + this.ace.on('changeSelection', this.onSelectionChange); + this.ace.on('beforeEndOperation', this.onBeforeEndOperation); + }; + CodeMirror.Pos = function(line, ch) { + if (!(this instanceof Pos)) return new Pos(line, ch); + this.line = line; this.ch = ch; + }; + CodeMirror.defineOption = function(name, val, setter) {}; + CodeMirror.commands = { + redo: function(cm) { cm.ace.redo(); }, + undo: function(cm) { cm.ace.undo(); }, + newlineAndIndent: function(cm) { cm.ace.insert("\n"); } + }; + CodeMirror.keyMap = {}; + CodeMirror.addClass = CodeMirror.rmClass = + CodeMirror.e_stop = function() {}; + CodeMirror.keyName = function(e) { + if (e.key) return e.key; + var key = (KEYS[e.keyCode] || ""); + if (key.length == 1) key = key.toUpperCase(); + key = event.getModifierString(e).replace(/(^|-)\w/g, function(m) { + return m.toUpperCase(); + }) + key; + return key; + }; + CodeMirror.keyMap['default'] = function(key) { + return function(cm) { + var cmd = cm.ace.commands.commandKeyBinding[key.toLowerCase()]; + return cmd && cm.ace.execCommand(cmd) !== false; + }; + }; + CodeMirror.lookupKey = function lookupKey(key, map, handle) { + if (typeof map == "string") + map = CodeMirror.keyMap[map]; + var found = typeof map == "function" ? map(key) : map[key]; + if (found === false) return "nothing"; + if (found === "...") return "multi"; + if (found != null && handle(found)) return "handled"; + + if (map.fallthrough) { + if (!Array.isArray(map.fallthrough)) + return lookupKey(key, map.fallthrough, handle); + for (var i = 0; i < map.fallthrough.length; i++) { + var result = lookupKey(key, map.fallthrough[i], handle); + if (result) return result; + } + } + }; + + CodeMirror.signal = function(o, name, e) { return o._signal(name, e) }; + CodeMirror.on = event.addListener; + CodeMirror.off = event.removeListener; + CodeMirror.isWordChar = function(ch) { + if (ch < "\x7f") return /^\w$/.test(ch); + TextModeTokenRe.lastIndex = 0; + return TextModeTokenRe.test(ch); + }; + +(function() { + oop.implement(CodeMirror.prototype, EventEmitter); + + this.destroy = function() { + this.ace.off('change', this.onChange); + this.ace.off('changeSelection', this.onSelectionChange); + this.ace.off('beforeEndOperation', this.onBeforeEndOperation); + this.removeOverlay(); + }; + this.virtualSelectionMode = function() { + return this.ace.inVirtualSelectionMode && this.ace.selection.index; + }; + this.onChange = function(delta) { + var change = { text: delta.action[0] == 'i' ? delta.lines : [] }; + var curOp = this.curOp = this.curOp || {}; + if (!curOp.changeHandlers) + curOp.changeHandlers = this._eventRegistry["change"] && this._eventRegistry["change"].slice(); + if (this.virtualSelectionMode()) return; + if (!curOp.lastChange) { + curOp.lastChange = curOp.change = change; + } else { + curOp.lastChange.next = curOp.lastChange = change; + } + this.$updateMarkers(delta); + }; + this.onSelectionChange = function() { + var curOp = this.curOp = this.curOp || {}; + if (!curOp.cursorActivityHandlers) + curOp.cursorActivityHandlers = this._eventRegistry["cursorActivity"] && this._eventRegistry["cursorActivity"].slice(); + this.curOp.cursorActivity = true; + if (this.ace.inMultiSelectMode) { + this.ace.keyBinding.removeKeyboardHandler(multiSelectCommands.keyboardHandler); + } + }; + this.operation = function(fn, force) { + if (!force && this.curOp || force && this.curOp && this.curOp.force) { + return fn(); + } + if (force || !this.ace.curOp) { + if (this.curOp) + this.onBeforeEndOperation(); + } + if (!this.ace.curOp) { + var prevOp = this.ace.prevOp; + this.ace.startOperation({ + command: { name: "vim", scrollIntoView: "cursor" } + }); + } + var curOp = this.curOp = this.curOp || {}; + this.curOp.force = force; + var result = fn(); + if (this.ace.curOp && this.ace.curOp.command.name == "vim") { + this.ace.endOperation(); + if (!curOp.cursorActivity && !curOp.lastChange && prevOp) + this.ace.prevOp = prevOp; + } + if (force || !this.ace.curOp) { + if (this.curOp) + this.onBeforeEndOperation(); + } + return result; + }; + this.onBeforeEndOperation = function() { + var op = this.curOp; + if (op) { + if (op.change) { this.signal("change", op.change, op); } + if (op && op.cursorActivity) { this.signal("cursorActivity", null, op); } + this.curOp = null; + } + }; + + this.signal = function(eventName, e, handlers) { + var listeners = handlers ? handlers[eventName + "Handlers"] + : (this._eventRegistry || {})[eventName]; + if (!listeners) + return; + listeners = listeners.slice(); + for (var i=0; i 0) { + point.row += rowShift; + point.column += point.row == end.row ? colShift : 0; + continue; + } + if (!isInsert && cmp2 <= 0) { + point.row = start.row; + point.column = start.column; + if (cmp2 === 0) + point.bias = 1; + } + } + }; + var Marker = function(cm, id, row, column) { + this.cm = cm; + this.id = id; + this.row = row; + this.column = column; + cm.marks[this.id] = this; + }; + Marker.prototype.clear = function() { delete this.cm.marks[this.id] }; + Marker.prototype.find = function() { return toCmPos(this) }; + this.setBookmark = function(cursor, options) { + var bm = new Marker(this, this.$uid++, cursor.line, cursor.ch); + if (!options || !options.insertLeft) + bm.$insertRight = true; + this.marks[bm.id] = bm; + return bm; + }; + this.moveH = function(increment, unit) { + if (unit == 'char') { + var sel = this.ace.selection; + sel.clearSelection(); + sel.moveCursorBy(0, increment); + } + }; + this.findPosV = function(start, amount, unit, goalColumn) { + if (unit == 'page') { + var renderer = this.ace.renderer; + var config = renderer.layerConfig; + amount = amount * Math.floor(config.height / config.lineHeight); + unit = 'line'; + } + if (unit == 'line') { + var screenPos = this.ace.session.documentToScreenPosition(start.line, start.ch); + if (goalColumn != null) + screenPos.column = goalColumn; + screenPos.row += amount; + // not what codemirror does but vim mode needs only this + screenPos.row = Math.min(Math.max(0, screenPos.row), this.ace.session.getScreenLength() - 1); + var pos = this.ace.session.screenToDocumentPosition(screenPos.row, screenPos.column); + return toCmPos(pos); + } else { + debugger; + } + }; + this.charCoords = function(pos, mode) { + if (mode == 'div' || !mode) { + var sc = this.ace.session.documentToScreenPosition(pos.line, pos.ch); + return {left: sc.column, top: sc.row}; + }if (mode == 'local') { + var renderer = this.ace.renderer; + var sc = this.ace.session.documentToScreenPosition(pos.line, pos.ch); + var lh = renderer.layerConfig.lineHeight; + var cw = renderer.layerConfig.characterWidth; + var top = lh * sc.row; + return {left: sc.column * cw, top: top, bottom: top + lh}; + } + }; + this.coordsChar = function(pos, mode) { + var renderer = this.ace.renderer; + if (mode == 'local') { + var row = Math.max(0, Math.floor(pos.top / renderer.lineHeight)); + var col = Math.max(0, Math.floor(pos.left / renderer.characterWidth)); + var ch = renderer.session.screenToDocumentPosition(row, col); + return toCmPos(ch); + } else if (mode == 'div') { + throw "not implemented"; + } + }; + this.getSearchCursor = function(query, pos, caseFold) { + var caseSensitive = false; + var isRegexp = false; + if (query instanceof RegExp && !query.global) { + caseSensitive = !query.ignoreCase; + query = query.source; + isRegexp = true; + } + var search = new Search(); + if (pos.ch == undefined) pos.ch = Number.MAX_VALUE; + var acePos = {row: pos.line, column: pos.ch}; + var cm = this; + var last = null; + return { + findNext: function() { return this.find(false) }, + findPrevious: function() {return this.find(true) }, + find: function(back) { + search.setOptions({ + needle: query, + caseSensitive: caseSensitive, + wrap: false, + backwards: back, + regExp: isRegexp, + start: last || acePos + }); + var range = search.find(cm.ace.session); + if (range && range.isEmpty()) { + if (cm.getLine(range.start.row).length == range.start.column) { + search.$options.start = range; + range = search.find(cm.ace.session); + } + } + last = range; + return last; + }, + from: function() { return last && toCmPos(last.start) }, + to: function() { return last && toCmPos(last.end) }, + replace: function(text) { + if (last) { + last.end = cm.ace.session.doc.replace(last, text); + } + } + }; + }; + this.scrollTo = function(x, y) { + var renderer = this.ace.renderer; + var config = renderer.layerConfig; + var maxHeight = config.maxHeight; + maxHeight -= (renderer.$size.scrollerHeight - renderer.lineHeight) * renderer.$scrollPastEnd; + if (y != null) this.ace.session.setScrollTop(Math.max(0, Math.min(y, maxHeight))); + if (x != null) this.ace.session.setScrollLeft(Math.max(0, Math.min(x, config.width))); + }; + this.scrollInfo = function() { return 0; }; + this.scrollIntoView = function(pos, margin) { + if (pos) { + var renderer = this.ace.renderer; + var viewMargin = { "top": 0, "bottom": margin }; + renderer.scrollCursorIntoView(toAcePos(pos), + (renderer.lineHeight * 2) / renderer.$size.scrollerHeight, viewMargin); + } + }; + this.getLine = function(row) { return this.ace.session.getLine(row) }; + this.getRange = function(s, e) { + return this.ace.session.getTextRange(new Range(s.line, s.ch, e.line, e.ch)); + }; + this.replaceRange = function(text, s, e) { + if (!e) e = s; + return this.ace.session.replace(new Range(s.line, s.ch, e.line, e.ch), text); + }; + this.replaceSelections = function(p) { + var sel = this.ace.selection; + if (this.ace.inVirtualSelectionMode) { + this.ace.session.replace(sel.getRange(), p[0] || ""); + return; + } + sel.inVirtualSelectionMode = true; + var ranges = sel.rangeList.ranges; + if (!ranges.length) ranges = [this.ace.multiSelect.getRange()]; + for (var i = ranges.length; i--;) + this.ace.session.replace(ranges[i], p[i] || ""); + sel.inVirtualSelectionMode = false; + }; + this.getSelection = function() { + return this.ace.getSelectedText(); + }; + this.getSelections = function() { + return this.listSelections().map(function(x) { + return this.getRange(x.anchor, x.head); + }, this); + }; + this.getInputField = function() { + return this.ace.textInput.getElement(); + }; + this.getWrapperElement = function() { + return this.ace.containter; + }; + var optMap = { + indentWithTabs: "useSoftTabs", + indentUnit: "tabSize", + tabSize: "tabSize", + firstLineNumber: "firstLineNumber", + readOnly: "readOnly" + }; + this.setOption = function(name, val) { + this.state[name] = val; + switch (name) { + case 'indentWithTabs': + name = optMap[name]; + val = !val; + break; + default: + name = optMap[name]; + } + if (name) + this.ace.setOption(name, val); + }; + this.getOption = function(name, val) { + var aceOpt = optMap[name]; + if (aceOpt) + val = this.ace.getOption(aceOpt); + switch (name) { + case 'indentWithTabs': + name = optMap[name]; + return !val; + } + return aceOpt ? val : this.state[name]; + }; + this.toggleOverwrite = function(on) { + this.state.overwrite = on; + return this.ace.setOverwrite(on); + }; + this.addOverlay = function(o) { + if (!this.$searchHighlight || !this.$searchHighlight.session) { + var highlight = new SearchHighlight(null, "ace_highlight-marker", "text"); + var marker = this.ace.session.addDynamicMarker(highlight); + highlight.id = marker.id; + highlight.session = this.ace.session; + highlight.destroy = function(o) { + highlight.session.off("change", highlight.updateOnChange); + highlight.session.off("changeEditor", highlight.destroy); + highlight.session.removeMarker(highlight.id); + highlight.session = null; + }; + highlight.updateOnChange = function(delta) { + var row = delta.start.row; + if (row == delta.end.row) highlight.cache[row] = undefined; + else highlight.cache.splice(row, highlight.cache.length); + }; + highlight.session.on("changeEditor", highlight.destroy); + highlight.session.on("change", highlight.updateOnChange); + } + var re = new RegExp(o.query.source, "gmi"); + this.$searchHighlight = o.highlight = highlight; + this.$searchHighlight.setRegexp(re); + this.ace.renderer.updateBackMarkers(); + }; + this.removeOverlay = function(o) { + if (this.$searchHighlight && this.$searchHighlight.session) { + this.$searchHighlight.destroy(); + } + }; + this.getScrollInfo = function() { + var renderer = this.ace.renderer; + var config = renderer.layerConfig; + return { + left: renderer.scrollLeft, + top: renderer.scrollTop, + height: config.maxHeight, + width: config.width, + clientHeight: config.height, + clientWidth: config.width + }; + }; + this.getValue = function() { + return this.ace.getValue(); + }; + this.setValue = function(v) { + return this.ace.setValue(v); + }; + this.getTokenTypeAt = function(pos) { + var token = this.ace.session.getTokenAt(pos.line, pos.ch); + return token && /comment|string/.test(token.type) ? "string" : ""; + }; + this.findMatchingBracket = function(pos) { + var m = this.ace.session.findMatchingBracket(toAcePos(pos)); + return {to: m && toCmPos(m)}; + }; + this.indentLine = function(line, method) { + if (method === true) + this.ace.session.indentRows(line, line, "\t"); + else if (method === false) + this.ace.session.outdentRows(new Range(line, 0, line, 0)); + }; + this.indexFromPos = function(pos) { + return this.ace.session.doc.positionToIndex(toAcePos(pos)); + }; + this.posFromIndex = function(index) { + return toCmPos(this.ace.session.doc.indexToPosition(index)); + }; + this.focus = function(index) { + return this.ace.focus(); + }; + this.blur = function(index) { + return this.ace.blur(); + }; + this.defaultTextHeight = function(index) { + return this.ace.renderer.layerConfig.lineHeight; + }; + this.scanForBracket = function(pos, dir, _, options) { + var re = options.bracketRegex.source; + if (dir == 1) { + var m = this.ace.session.$findClosingBracket(re.slice(1, 2), toAcePos(pos), /paren|text/); + } else { + var m = this.ace.session.$findOpeningBracket(re.slice(-2, -1), {row: pos.line, column: pos.ch + 1}, /paren|text/); + } + return m && {pos: toCmPos(m)}; + }; + this.refresh = function() { + return this.ace.resize(true); + }; + this.getMode = function() { + return { name : this.getOption("mode") }; + } +}).call(CodeMirror.prototype); + function toAcePos(cmPos) { + return {row: cmPos.line, column: cmPos.ch}; + } + function toCmPos(acePos) { + return new Pos(acePos.row, acePos.column); + } + + var StringStream = CodeMirror.StringStream = function(string, tabSize) { + this.pos = this.start = 0; + this.string = string; + this.tabSize = tabSize || 8; + this.lastColumnPos = this.lastColumnValue = 0; + this.lineStart = 0; + }; + + StringStream.prototype = { + eol: function() {return this.pos >= this.string.length;}, + sol: function() {return this.pos == this.lineStart;}, + peek: function() {return this.string.charAt(this.pos) || undefined;}, + next: function() { + if (this.pos < this.string.length) + return this.string.charAt(this.pos++); + }, + eat: function(match) { + var ch = this.string.charAt(this.pos); + if (typeof match == "string") var ok = ch == match; + else var ok = ch && (match.test ? match.test(ch) : match(ch)); + if (ok) {++this.pos; return ch;} + }, + eatWhile: function(match) { + var start = this.pos; + while (this.eat(match)){} + return this.pos > start; + }, + eatSpace: function() { + var start = this.pos; + while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos; + return this.pos > start; + }, + skipToEnd: function() {this.pos = this.string.length;}, + skipTo: function(ch) { + var found = this.string.indexOf(ch, this.pos); + if (found > -1) {this.pos = found; return true;} + }, + backUp: function(n) {this.pos -= n;}, + column: function() { + throw "not implemented"; + }, + indentation: function() { + throw "not implemented"; + }, + match: function(pattern, consume, caseInsensitive) { + if (typeof pattern == "string") { + var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;}; + var substr = this.string.substr(this.pos, pattern.length); + if (cased(substr) == cased(pattern)) { + if (consume !== false) this.pos += pattern.length; + return true; + } + } else { + var match = this.string.slice(this.pos).match(pattern); + if (match && match.index > 0) return null; + if (match && consume !== false) this.pos += match[0].length; + return match; + } + }, + current: function(){return this.string.slice(this.start, this.pos);}, + hideFirstChars: function(n, inner) { + this.lineStart += n; + try { return inner(); } + finally { this.lineStart -= n; } + } + }; + +// todo replace with showCommandLine +CodeMirror.defineExtension = function(name, fn) { + CodeMirror.prototype[name] = fn; +}; +dom.importCssString(".normal-mode .ace_cursor{\ + border: 1px solid red;\ + background-color: red;\ + opacity: 0.5;\ +}\ +.normal-mode .ace_hidden-cursors .ace_cursor{\ + background-color: transparent;\ +}\ +.ace_dialog {\ + position: absolute;\ + left: 0; right: 0;\ + background: white;\ + z-index: 15;\ + padding: .1em .8em;\ + overflow: hidden;\ + color: #333;\ +}\ +.ace_dialog-top {\ + border-bottom: 1px solid #eee;\ + top: 0;\ +}\ +.ace_dialog-bottom {\ + border-top: 1px solid #eee;\ + bottom: 0;\ +}\ +.ace_dialog input {\ + border: none;\ + outline: none;\ + background: transparent;\ + width: 20em;\ + color: inherit;\ + font-family: monospace;\ +}", "vimMode"); +(function() { + function dialogDiv(cm, template, bottom) { + var wrap = cm.ace.container; + var dialog; + dialog = wrap.appendChild(document.createElement("div")); + if (bottom) + dialog.className = "ace_dialog ace_dialog-bottom"; + else + dialog.className = "ace_dialog ace_dialog-top"; + + if (typeof template == "string") { + dialog.innerHTML = template; + } else { // Assuming it's a detached DOM element. + dialog.appendChild(template); + } + return dialog; + } + + function closeNotification(cm, newVal) { + if (cm.state.currentNotificationClose) + cm.state.currentNotificationClose(); + cm.state.currentNotificationClose = newVal; + } + + CodeMirror.defineExtension("openDialog", function(template, callback, options) { + if (this.virtualSelectionMode()) return; + if (!options) options = {}; + + closeNotification(this, null); + + var dialog = dialogDiv(this, template, options.bottom); + var closed = false, me = this; + function close(newVal) { + if (typeof newVal == 'string') { + inp.value = newVal; + } else { + if (closed) return; + closed = true; + dialog.parentNode.removeChild(dialog); + me.focus(); + + if (options.onClose) options.onClose(dialog); + } + } + + var inp = dialog.getElementsByTagName("input")[0], button; + if (inp) { + if (options.value) { + inp.value = options.value; + if (options.select !== false) inp.select(); + } + + if (options.onInput) + CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);}); + if (options.onKeyUp) + CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);}); + + CodeMirror.on(inp, "keydown", function(e) { + if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; } + if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) { + inp.blur(); + CodeMirror.e_stop(e); + close(); + } + if (e.keyCode == 13) callback(inp.value); + }); + + if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close); + + inp.focus(); + } else if (button = dialog.getElementsByTagName("button")[0]) { + CodeMirror.on(button, "click", function() { + close(); + me.focus(); + }); + + if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close); + + button.focus(); + } + return close; + }); + + CodeMirror.defineExtension("openNotification", function(template, options) { + if (this.virtualSelectionMode()) return; + closeNotification(this, close); + var dialog = dialogDiv(this, template, options && options.bottom); + var closed = false, doneTimer; + var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000; + + function close() { + if (closed) return; + closed = true; + clearTimeout(doneTimer); + dialog.parentNode.removeChild(dialog); + } + + CodeMirror.on(dialog, 'click', function(e) { + CodeMirror.e_preventDefault(e); + close(); + }); + + if (duration) + doneTimer = setTimeout(close, duration); + + return close; + }); +})(); + + + var defaultKeymap = [ + // Key to key mapping. This goes first to make it possible to override + // existing mappings. + { keys: '', type: 'keyToKey', toKeys: 'h' }, + { keys: '', type: 'keyToKey', toKeys: 'l' }, + { keys: '', type: 'keyToKey', toKeys: 'k' }, + { keys: '', type: 'keyToKey', toKeys: 'j' }, + { keys: '', type: 'keyToKey', toKeys: 'l' }, + { keys: '', type: 'keyToKey', toKeys: 'h', context: 'normal'}, + { keys: '', type: 'keyToKey', toKeys: 'W' }, + { keys: '', type: 'keyToKey', toKeys: 'B', context: 'normal' }, + { keys: '', type: 'keyToKey', toKeys: 'w' }, + { keys: '', type: 'keyToKey', toKeys: 'b', context: 'normal' }, + { keys: '', type: 'keyToKey', toKeys: 'j' }, + { keys: '', type: 'keyToKey', toKeys: 'k' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '', context: 'insert' }, + { keys: '', type: 'keyToKey', toKeys: '', context: 'insert' }, + { keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' }, + { keys: 's', type: 'keyToKey', toKeys: 'c', context: 'visual'}, + { keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' }, + { keys: 'S', type: 'keyToKey', toKeys: 'VdO', context: 'visual' }, + { keys: '', type: 'keyToKey', toKeys: '0' }, + { keys: '', type: 'keyToKey', toKeys: '$' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: 'j^', context: 'normal' }, + // Motions + { keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'L', type: 'motion', motion: 'moveToBottomLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'h', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: false }}, + { keys: 'l', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: true }}, + { keys: 'j', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, linewise: true }}, + { keys: 'k', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, linewise: true }}, + { keys: 'gj', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: true }}, + { keys: 'gk', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: false }}, + { keys: 'w', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false }}, + { keys: 'W', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false, bigWord: true }}, + { keys: 'e', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, inclusive: true }}, + { keys: 'E', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, bigWord: true, inclusive: true }}, + { keys: 'b', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }}, + { keys: 'B', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false, bigWord: true }}, + { keys: 'ge', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, inclusive: true }}, + { keys: 'gE', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, bigWord: true, inclusive: true }}, + { keys: '{', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: false, toJumplist: true }}, + { keys: '}', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: true, toJumplist: true }}, + { keys: '', type: 'motion', motion: 'moveByPage', motionArgs: { forward: true }}, + { keys: '', type: 'motion', motion: 'moveByPage', motionArgs: { forward: false }}, + { keys: '', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: true, explicitRepeat: true }}, + { keys: '', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: false, explicitRepeat: true }}, + { keys: 'gg', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: false, explicitRepeat: true, linewise: true, toJumplist: true }}, + { keys: 'G', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: true, explicitRepeat: true, linewise: true, toJumplist: true }}, + { keys: '0', type: 'motion', motion: 'moveToStartOfLine' }, + { keys: '^', type: 'motion', motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: '+', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true }}, + { keys: '-', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, toFirstChar:true }}, + { keys: '_', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true, repeatOffset:-1 }}, + { keys: '$', type: 'motion', motion: 'moveToEol', motionArgs: { inclusive: true }}, + { keys: '%', type: 'motion', motion: 'moveToMatchedSymbol', motionArgs: { inclusive: true, toJumplist: true }}, + { keys: 'f', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: true , inclusive: true }}, + { keys: 'F', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: false }}, + { keys: 't', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: true, inclusive: true }}, + { keys: 'T', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: false }}, + { keys: ';', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: true }}, + { keys: ',', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: false }}, + { keys: '\'', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true, linewise: true}}, + { keys: '`', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true}}, + { keys: ']`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } }, + { keys: '[`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false } }, + { keys: ']\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true, linewise: true } }, + { keys: '[\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false, linewise: true } }, + // the next two aren't motions but must come before more general motion declarations + { keys: ']p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true, matchIndent: true}}, + { keys: '[p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true, matchIndent: true}}, + { keys: ']', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: true, toJumplist: true}}, + { keys: '[', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: false, toJumplist: true}}, + { keys: '|', type: 'motion', motion: 'moveToColumn'}, + { keys: 'o', type: 'motion', motion: 'moveToOtherHighlightedEnd', context:'visual'}, + { keys: 'O', type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: {sameLine: true}, context:'visual'}, + // Operators + { keys: 'd', type: 'operator', operator: 'delete' }, + { keys: 'y', type: 'operator', operator: 'yank' }, + { keys: 'c', type: 'operator', operator: 'change' }, + { keys: '>', type: 'operator', operator: 'indent', operatorArgs: { indentRight: true }}, + { keys: '<', type: 'operator', operator: 'indent', operatorArgs: { indentRight: false }}, + { keys: 'g~', type: 'operator', operator: 'changeCase' }, + { keys: 'gu', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: true}, isEdit: true }, + { keys: 'gU', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: false}, isEdit: true }, + { keys: 'n', type: 'motion', motion: 'findNext', motionArgs: { forward: true, toJumplist: true }}, + { keys: 'N', type: 'motion', motion: 'findNext', motionArgs: { forward: false, toJumplist: true }}, + // Operator-Motion dual commands + { keys: 'x', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorMotionArgs: { visualLine: false }}, + { keys: 'X', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: false }, operatorMotionArgs: { visualLine: true }}, + { keys: 'D', type: 'operatorMotion', operator: 'delete', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'}, + { keys: 'D', type: 'operator', operator: 'delete', operatorArgs: { linewise: true }, context: 'visual'}, + { keys: 'Y', type: 'operatorMotion', operator: 'yank', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'}, + { keys: 'Y', type: 'operator', operator: 'yank', operatorArgs: { linewise: true }, context: 'visual'}, + { keys: 'C', type: 'operatorMotion', operator: 'change', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'}, + { keys: 'C', type: 'operator', operator: 'change', operatorArgs: { linewise: true }, context: 'visual'}, + { keys: '~', type: 'operatorMotion', operator: 'changeCase', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorArgs: { shouldMoveCursor: true }, context: 'normal'}, + { keys: '~', type: 'operator', operator: 'changeCase', context: 'visual'}, + { keys: '', type: 'operatorMotion', operator: 'delete', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }, context: 'insert' }, + // Actions + { keys: '', type: 'action', action: 'jumpListWalk', actionArgs: { forward: true }}, + { keys: '', type: 'action', action: 'jumpListWalk', actionArgs: { forward: false }}, + { keys: '', type: 'action', action: 'scroll', actionArgs: { forward: true, linewise: true }}, + { keys: '', type: 'action', action: 'scroll', actionArgs: { forward: false, linewise: true }}, + { keys: 'a', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'charAfter' }, context: 'normal' }, + { keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'eol' }, context: 'normal' }, + { keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'endOfSelectedArea' }, context: 'visual' }, + { keys: 'i', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'inplace' }, context: 'normal' }, + { keys: 'I', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'firstNonBlank'}, context: 'normal' }, + { keys: 'I', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'startOfSelectedArea' }, context: 'visual' }, + { keys: 'o', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: true }, context: 'normal' }, + { keys: 'O', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: false }, context: 'normal' }, + { keys: 'v', type: 'action', action: 'toggleVisualMode' }, + { keys: 'V', type: 'action', action: 'toggleVisualMode', actionArgs: { linewise: true }}, + { keys: '', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }}, + { keys: '', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }}, + { keys: 'gv', type: 'action', action: 'reselectLastSelection' }, + { keys: 'J', type: 'action', action: 'joinLines', isEdit: true }, + { keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true }}, + { keys: 'P', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true }}, + { keys: 'r', type: 'action', action: 'replace', isEdit: true }, + { keys: '@', type: 'action', action: 'replayMacro' }, + { keys: 'q', type: 'action', action: 'enterMacroRecordMode' }, + // Handle Replace-mode as a special case of insert mode. + { keys: 'R', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { replace: true }}, + { keys: 'u', type: 'action', action: 'undo', context: 'normal' }, + { keys: 'u', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: true}, context: 'visual', isEdit: true }, + { keys: 'U', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: false}, context: 'visual', isEdit: true }, + { keys: '', type: 'action', action: 'redo' }, + { keys: 'm', type: 'action', action: 'setMark' }, + { keys: '"', type: 'action', action: 'setRegister' }, + { keys: 'zz', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }}, + { keys: 'z.', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: 'zt', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }}, + { keys: 'z', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: 'z-', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }}, + { keys: 'zb', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: '.', type: 'action', action: 'repeatLastEdit' }, + { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}}, + { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}}, + // Text object motions + { keys: 'a', type: 'motion', motion: 'textObjectManipulation' }, + { keys: 'i', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }}, + // Search + { keys: '/', type: 'search', searchArgs: { forward: true, querySrc: 'prompt', toJumplist: true }}, + { keys: '?', type: 'search', searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true }}, + { keys: '*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, + { keys: '#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, + { keys: 'g*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }}, + { keys: 'g#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }}, + // Ex command + { keys: ':', type: 'ex' } + ]; + + /** + * Ex commands + * Care must be taken when adding to the default Ex command map. For any + * pair of commands that have a shared prefix, at least one of their + * shortNames must not match the prefix of the other command. + */ + var defaultExCommandMap = [ + { name: 'colorscheme', shortName: 'colo' }, + { name: 'map' }, + { name: 'imap', shortName: 'im' }, + { name: 'nmap', shortName: 'nm' }, + { name: 'vmap', shortName: 'vm' }, + { name: 'unmap' }, + { name: 'write', shortName: 'w' }, + { name: 'undo', shortName: 'u' }, + { name: 'redo', shortName: 'red' }, + { name: 'set', shortName: 'se' }, + { name: 'set', shortName: 'se' }, + { name: 'setlocal', shortName: 'setl' }, + { name: 'setglobal', shortName: 'setg' }, + { name: 'sort', shortName: 'sor' }, + { name: 'substitute', shortName: 's', possiblyAsync: true }, + { name: 'nohlsearch', shortName: 'noh' }, + { name: 'delmarks', shortName: 'delm' }, + { name: 'registers', shortName: 'reg', excludeFromCommandHistory: true }, + { name: 'global', shortName: 'g' } + ]; + + var Pos = CodeMirror.Pos; + + var Vim = function() { return vimApi; } //{ + function enterVimMode(cm) { + cm.setOption('disableInput', true); + cm.setOption('showCursorWhenSelecting', false); + CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); + cm.on('cursorActivity', onCursorActivity); + maybeInitVimState(cm); + CodeMirror.on(cm.getInputField(), 'paste', getOnPasteFn(cm)); + } + + function leaveVimMode(cm) { + cm.setOption('disableInput', false); + cm.off('cursorActivity', onCursorActivity); + CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm)); + cm.state.vim = null; + } + + function detachVimMap(cm, next) { + if (this == CodeMirror.keyMap.vim) + CodeMirror.rmClass(cm.getWrapperElement(), "cm-fat-cursor"); + + if (!next || next.attach != attachVimMap) + leaveVimMode(cm); + } + function attachVimMap(cm, prev) { + if (this == CodeMirror.keyMap.vim) + CodeMirror.addClass(cm.getWrapperElement(), "cm-fat-cursor"); + + if (!prev || prev.attach != attachVimMap) + enterVimMode(cm); + } + + // Deprecated, simply setting the keymap works again. + CodeMirror.defineOption('vimMode', false, function(cm, val, prev) { + if (val && cm.getOption("keyMap") != "vim") + cm.setOption("keyMap", "vim"); + else if (!val && prev != CodeMirror.Init && /^vim/.test(cm.getOption("keyMap"))) + cm.setOption("keyMap", "default"); + }); + + function cmKey(key, cm) { + if (!cm) { return undefined; } + var vimKey = cmKeyToVimKey(key); + if (!vimKey) { + return false; + } + var cmd = CodeMirror.Vim.findKey(cm, vimKey); + if (typeof cmd == 'function') { + CodeMirror.signal(cm, 'vim-keypress', vimKey); + } + return cmd; + } + + var modifiers = {'Shift': 'S', 'Ctrl': 'C', 'Alt': 'A', 'Cmd': 'D', 'Mod': 'A'}; + var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del'}; + function cmKeyToVimKey(key) { + if (key.charAt(0) == '\'') { + // Keypress character binding of format "'a'" + return key.charAt(1); + } + var pieces = key.split(/-(?!$)/); + var lastPiece = pieces[pieces.length - 1]; + if (pieces.length == 1 && pieces[0].length == 1) { + // No-modifier bindings use literal character bindings above. Skip. + return false; + } else if (pieces.length == 2 && pieces[0] == 'Shift' && lastPiece.length == 1) { + // Ignore Shift+char bindings as they should be handled by literal character. + return false; + } + var hasCharacter = false; + for (var i = 0; i < pieces.length; i++) { + var piece = pieces[i]; + if (piece in modifiers) { pieces[i] = modifiers[piece]; } + else { hasCharacter = true; } + if (piece in specialKeys) { pieces[i] = specialKeys[piece]; } + } + if (!hasCharacter) { + // Vim does not support modifier only keys. + return false; + } + // TODO: Current bindings expect the character to be lower case, but + // it looks like vim key notation uses upper case. + if (isUpperCase(lastPiece)) { + pieces[pieces.length - 1] = lastPiece.toLowerCase(); + } + return '<' + pieces.join('-') + '>'; + } + + function getOnPasteFn(cm) { + var vim = cm.state.vim; + if (!vim.onPasteFn) { + vim.onPasteFn = function() { + if (!vim.insertMode) { + cm.setCursor(offsetCursor(cm.getCursor(), 0, 1)); + actions.enterInsertMode(cm, {}, vim); + } + }; + } + return vim.onPasteFn; + } + + var numberRegex = /[\d]/; + var wordCharTest = [CodeMirror.isWordChar, function(ch) { + return ch && !CodeMirror.isWordChar(ch) && !/\s/.test(ch); + }], bigWordCharTest = [function(ch) { + return /\S/.test(ch); + }]; + function makeKeyRange(start, size) { + var keys = []; + for (var i = start; i < start + size; i++) { + keys.push(String.fromCharCode(i)); + } + return keys; + } + var upperCaseAlphabet = makeKeyRange(65, 26); + var lowerCaseAlphabet = makeKeyRange(97, 26); + var numbers = makeKeyRange(48, 10); + var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']); + var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '/']); + + function isLine(cm, line) { + return line >= cm.firstLine() && line <= cm.lastLine(); + } + function isLowerCase(k) { + return (/^[a-z]$/).test(k); + } + function isMatchableSymbol(k) { + return '()[]{}'.indexOf(k) != -1; + } + function isNumber(k) { + return numberRegex.test(k); + } + function isUpperCase(k) { + return (/^[A-Z]$/).test(k); + } + function isWhiteSpaceString(k) { + return (/^\s*$/).test(k); + } + function inArray(val, arr) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] == val) { + return true; + } + } + return false; + } + + var options = {}; + function defineOption(name, defaultValue, type, aliases, callback) { + if (defaultValue === undefined && !callback) { + throw Error('defaultValue is required unless callback is provided'); + } + if (!type) { type = 'string'; } + options[name] = { + type: type, + defaultValue: defaultValue, + callback: callback + }; + if (aliases) { + for (var i = 0; i < aliases.length; i++) { + options[aliases[i]] = options[name]; + } + } + if (defaultValue) { + setOption(name, defaultValue); + } + } + + function setOption(name, value, cm, cfg) { + var option = options[name]; + cfg = cfg || {}; + var scope = cfg.scope; + if (!option) { + throw Error('Unknown option: ' + name); + } + if (option.type == 'boolean') { + if (value && value !== true) { + throw Error('Invalid argument: ' + name + '=' + value); + } else if (value !== false) { + // Boolean options are set to true if value is not defined. + value = true; + } + } + if (option.callback) { + if (scope !== 'local') { + option.callback(value, undefined); + } + if (scope !== 'global' && cm) { + option.callback(value, cm); + } + } else { + if (scope !== 'local') { + option.value = option.type == 'boolean' ? !!value : value; + } + if (scope !== 'global' && cm) { + cm.state.vim.options[name] = {value: value}; + } + } + } + + function getOption(name, cm, cfg) { + var option = options[name]; + cfg = cfg || {}; + var scope = cfg.scope; + if (!option) { + throw Error('Unknown option: ' + name); + } + if (option.callback) { + var local = cm && option.callback(undefined, cm); + if (scope !== 'global' && local !== undefined) { + return local; + } + if (scope !== 'local') { + return option.callback(); + } + return; + } else { + var local = (scope !== 'global') && (cm && cm.state.vim.options[name]); + return (local || (scope !== 'local') && option || {}).value; + } + } + + defineOption('filetype', undefined, 'string', ['ft'], function(name, cm) { + // Option is local. Do nothing for global. + if (cm === undefined) { + return; + } + // The 'filetype' option proxies to the CodeMirror 'mode' option. + if (name === undefined) { + var mode = cm.getOption('mode'); + return mode == 'null' ? '' : mode; + } else { + var mode = name == '' ? 'null' : name; + cm.setOption('mode', mode); + } + }); + + var createCircularJumpList = function() { + var size = 100; + var pointer = -1; + var head = 0; + var tail = 0; + var buffer = new Array(size); + function add(cm, oldCur, newCur) { + var current = pointer % size; + var curMark = buffer[current]; + function useNextSlot(cursor) { + var next = ++pointer % size; + var trashMark = buffer[next]; + if (trashMark) { + trashMark.clear(); + } + buffer[next] = cm.setBookmark(cursor); + } + if (curMark) { + var markPos = curMark.find(); + // avoid recording redundant cursor position + if (markPos && !cursorEqual(markPos, oldCur)) { + useNextSlot(oldCur); + } + } else { + useNextSlot(oldCur); + } + useNextSlot(newCur); + head = pointer; + tail = pointer - size + 1; + if (tail < 0) { + tail = 0; + } + } + function move(cm, offset) { + pointer += offset; + if (pointer > head) { + pointer = head; + } else if (pointer < tail) { + pointer = tail; + } + var mark = buffer[(size + pointer) % size]; + // skip marks that are temporarily removed from text buffer + if (mark && !mark.find()) { + var inc = offset > 0 ? 1 : -1; + var newCur; + var oldCur = cm.getCursor(); + do { + pointer += inc; + mark = buffer[(size + pointer) % size]; + // skip marks that are the same as current position + if (mark && + (newCur = mark.find()) && + !cursorEqual(oldCur, newCur)) { + break; + } + } while (pointer < head && pointer > tail); + } + return mark; + } + return { + cachedCursor: undefined, //used for # and * jumps + add: add, + move: move + }; + }; + + // Returns an object to track the changes associated insert mode. It + // clones the object that is passed in, or creates an empty object one if + // none is provided. + var createInsertModeChanges = function(c) { + if (c) { + // Copy construction + return { + changes: c.changes, + expectCursorActivityForChange: c.expectCursorActivityForChange + }; + } + return { + // Change list + changes: [], + // Set to true on change, false on cursorActivity. + expectCursorActivityForChange: false + }; + }; + + function MacroModeState() { + this.latestRegister = undefined; + this.isPlaying = false; + this.isRecording = false; + this.replaySearchQueries = []; + this.onRecordingDone = undefined; + this.lastInsertModeChanges = createInsertModeChanges(); + } + MacroModeState.prototype = { + exitMacroRecordMode: function() { + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.onRecordingDone) { + macroModeState.onRecordingDone(); // close dialog + } + macroModeState.onRecordingDone = undefined; + macroModeState.isRecording = false; + }, + enterMacroRecordMode: function(cm, registerName) { + var register = + vimGlobalState.registerController.getRegister(registerName); + if (register) { + register.clear(); + this.latestRegister = registerName; + if (cm.openDialog) { + this.onRecordingDone = cm.openDialog( + '(recording)['+registerName+']', null, {bottom:true}); + } + this.isRecording = true; + } + } + }; + + function maybeInitVimState(cm) { + if (!cm.state.vim) { + // Store instance state in the CodeMirror object. + cm.state.vim = { + inputState: new InputState(), + // Vim's input state that triggered the last edit, used to repeat + // motions and operators with '.'. + lastEditInputState: undefined, + // Vim's action command before the last edit, used to repeat actions + // with '.' and insert mode repeat. + lastEditActionCommand: undefined, + // When using jk for navigation, if you move from a longer line to a + // shorter line, the cursor may clip to the end of the shorter line. + // If j is pressed again and cursor goes to the next line, the + // cursor should go back to its horizontal position on the longer + // line if it can. This is to keep track of the horizontal position. + lastHPos: -1, + // Doing the same with screen-position for gj/gk + lastHSPos: -1, + // The last motion command run. Cleared if a non-motion command gets + // executed in between. + lastMotion: null, + marks: {}, + // Mark for rendering fake cursor for visual mode. + fakeCursor: null, + insertMode: false, + // Repeat count for changes made in insert mode, triggered by key + // sequences like 3,i. Only exists when insertMode is true. + insertModeRepeat: undefined, + visualMode: false, + // If we are in visual line mode. No effect if visualMode is false. + visualLine: false, + visualBlock: false, + lastSelection: null, + lastPastedText: null, + sel: {}, + // Buffer-local/window-local values of vim options. + options: {} + }; + } + return cm.state.vim; + } + var vimGlobalState; + function resetVimGlobalState() { + vimGlobalState = { + // The current search query. + searchQuery: null, + // Whether we are searching backwards. + searchIsReversed: false, + // Replace part of the last substituted pattern + lastSubstituteReplacePart: undefined, + jumpList: createCircularJumpList(), + macroModeState: new MacroModeState, + // Recording latest f, t, F or T motion command. + lastChararacterSearch: {increment:0, forward:true, selectedCharacter:''}, + registerController: new RegisterController({}), + // search history buffer + searchHistoryController: new HistoryController(), + // ex Command history buffer + exCommandHistoryController : new HistoryController() + }; + for (var optionName in options) { + var option = options[optionName]; + option.value = option.defaultValue; + } + } + + var lastInsertModeKeyTimer; + var vimApi= { + buildKeyMap: function() { + // TODO: Convert keymap into dictionary format for fast lookup. + }, + // Testing hook, though it might be useful to expose the register + // controller anyways. + getRegisterController: function() { + return vimGlobalState.registerController; + }, + // Testing hook. + resetVimGlobalState_: resetVimGlobalState, + + // Testing hook. + getVimGlobalState_: function() { + return vimGlobalState; + }, + + // Testing hook. + maybeInitVimState_: maybeInitVimState, + + suppressErrorLogging: false, + + InsertModeKey: InsertModeKey, + map: function(lhs, rhs, ctx) { + // Add user defined key bindings. + exCommandDispatcher.map(lhs, rhs, ctx); + }, + unmap: function(lhs, ctx) { + exCommandDispatcher.unmap(lhs, ctx); + }, + // TODO: Expose setOption and getOption as instance methods. Need to decide how to namespace + // them, or somehow make them work with the existing CodeMirror setOption/getOption API. + setOption: setOption, + getOption: getOption, + defineOption: defineOption, + defineEx: function(name, prefix, func){ + if (!prefix) { + prefix = name; + } else if (name.indexOf(prefix) !== 0) { + throw new Error('(Vim.defineEx) "'+prefix+'" is not a prefix of "'+name+'", command not registered'); + } + exCommands[name]=func; + exCommandDispatcher.commandMap_[prefix]={name:name, shortName:prefix, type:'api'}; + }, + handleKey: function (cm, key, origin) { + var command = this.findKey(cm, key, origin); + if (typeof command === 'function') { + return command(); + } + }, + /** + * This is the outermost function called by CodeMirror, after keys have + * been mapped to their Vim equivalents. + * + * Finds a command based on the key (and cached keys if there is a + * multi-key sequence). Returns `undefined` if no key is matched, a noop + * function if a partial match is found (multi-key), and a function to + * execute the bound command if a a key is matched. The function always + * returns true. + */ + findKey: function(cm, key, origin) { + var vim = maybeInitVimState(cm); + function handleMacroRecording() { + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isRecording) { + if (key == 'q') { + macroModeState.exitMacroRecordMode(); + clearInputState(cm); + return true; + } + if (origin != 'mapping') { + logKey(macroModeState, key); + } + } + } + function handleEsc() { + if (key == '') { + // Clear input state and get back to normal mode. + clearInputState(cm); + if (vim.visualMode) { + exitVisualMode(cm); + } else if (vim.insertMode) { + exitInsertMode(cm); + } + return true; + } + } + function doKeyToKey(keys) { + // TODO: prevent infinite recursion. + var match; + while (keys) { + // Pull off one command key, which is either a single character + // or a special sequence wrapped in '<' and '>', e.g. ''. + match = (/<\w+-.+?>|<\w+>|./).exec(keys); + key = match[0]; + keys = keys.substring(match.index + key.length); + CodeMirror.Vim.handleKey(cm, key, 'mapping'); + } + } + + function handleKeyInsertMode() { + if (handleEsc()) { return true; } + var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key; + var keysAreChars = key.length == 1; + var match = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); + // Need to check all key substrings in insert mode. + while (keys.length > 1 && match.type != 'full') { + var keys = vim.inputState.keyBuffer = keys.slice(1); + var thisMatch = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); + if (thisMatch.type != 'none') { match = thisMatch; } + } + if (match.type == 'none') { clearInputState(cm); return false; } + else if (match.type == 'partial') { + if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } + lastInsertModeKeyTimer = window.setTimeout( + function() { if (vim.insertMode && vim.inputState.keyBuffer) { clearInputState(cm); } }, + getOption('insertModeEscKeysTimeout')); + return !keysAreChars; + } + + if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } + if (keysAreChars) { + var selections = cm.listSelections(); + for (var i = 0; i < selections.length; i++) { + var here = selections[i].head; + cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input'); + } + vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop(); + } + clearInputState(cm); + return match.command; + } + + function handleKeyNonInsertMode() { + if (handleMacroRecording() || handleEsc()) { return true; } + + var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key; + if (/^[1-9]\d*$/.test(keys)) { return true; } + + var keysMatcher = /^(\d*)(.*)$/.exec(keys); + if (!keysMatcher) { clearInputState(cm); return false; } + var context = vim.visualMode ? 'visual' : + 'normal'; + var match = commandDispatcher.matchCommand(keysMatcher[2] || keysMatcher[1], defaultKeymap, vim.inputState, context); + if (match.type == 'none') { clearInputState(cm); return false; } + else if (match.type == 'partial') { return true; } + + vim.inputState.keyBuffer = ''; + var keysMatcher = /^(\d*)(.*)$/.exec(keys); + if (keysMatcher[1] && keysMatcher[1] != '0') { + vim.inputState.pushRepeatDigit(keysMatcher[1]); + } + return match.command; + } + + var command; + if (vim.insertMode) { command = handleKeyInsertMode(); } + else { command = handleKeyNonInsertMode(); } + if (command === false) { + return undefined; + } else if (command === true) { + // TODO: Look into using CodeMirror's multi-key handling. + // Return no-op since we are caching the key. Counts as handled, but + // don't want act on it just yet. + return function() { return true; }; + } else { + return function() { + if ((command.operator || command.isEdit) && cm.getOption('readOnly')) + return; // ace_patch + return cm.operation(function() { + cm.curOp.isVimOp = true; + try { + if (command.type == 'keyToKey') { + doKeyToKey(command.toKeys); + } else { + commandDispatcher.processCommand(cm, vim, command); + } + } catch (e) { + // clear VIM state in case it's in a bad state. + cm.state.vim = undefined; + maybeInitVimState(cm); + if (!CodeMirror.Vim.suppressErrorLogging) { + console['log'](e); + } + throw e; + } + return true; + }); + }; + } + }, + handleEx: function(cm, input) { + exCommandDispatcher.processCommand(cm, input); + }, + + defineMotion: defineMotion, + defineAction: defineAction, + defineOperator: defineOperator, + mapCommand: mapCommand, + _mapCommand: _mapCommand, + + defineRegister: defineRegister, + + exitVisualMode: exitVisualMode, + exitInsertMode: exitInsertMode + }; + + // Represents the current input state. + function InputState() { + this.prefixRepeat = []; + this.motionRepeat = []; + + this.operator = null; + this.operatorArgs = null; + this.motion = null; + this.motionArgs = null; + this.keyBuffer = []; // For matching multi-key commands. + this.registerName = null; // Defaults to the unnamed register. + } + InputState.prototype.pushRepeatDigit = function(n) { + if (!this.operator) { + this.prefixRepeat = this.prefixRepeat.concat(n); + } else { + this.motionRepeat = this.motionRepeat.concat(n); + } + }; + InputState.prototype.getRepeat = function() { + var repeat = 0; + if (this.prefixRepeat.length > 0 || this.motionRepeat.length > 0) { + repeat = 1; + if (this.prefixRepeat.length > 0) { + repeat *= parseInt(this.prefixRepeat.join(''), 10); + } + if (this.motionRepeat.length > 0) { + repeat *= parseInt(this.motionRepeat.join(''), 10); + } + } + return repeat; + }; + + function clearInputState(cm, reason) { + cm.state.vim.inputState = new InputState(); + CodeMirror.signal(cm, 'vim-command-done', reason); + } + + /* + * Register stores information about copy and paste registers. Besides + * text, a register must store whether it is linewise (i.e., when it is + * pasted, should it insert itself into a new line, or should the text be + * inserted at the cursor position.) + */ + function Register(text, linewise, blockwise) { + this.clear(); + this.keyBuffer = [text || '']; + this.insertModeChanges = []; + this.searchQueries = []; + this.linewise = !!linewise; + this.blockwise = !!blockwise; + } + Register.prototype = { + setText: function(text, linewise, blockwise) { + this.keyBuffer = [text || '']; + this.linewise = !!linewise; + this.blockwise = !!blockwise; + }, + pushText: function(text, linewise) { + // if this register has ever been set to linewise, use linewise. + if (linewise) { + if (!this.linewise) { + this.keyBuffer.push('\n'); + } + this.linewise = true; + } + this.keyBuffer.push(text); + }, + pushInsertModeChanges: function(changes) { + this.insertModeChanges.push(createInsertModeChanges(changes)); + }, + pushSearchQuery: function(query) { + this.searchQueries.push(query); + }, + clear: function() { + this.keyBuffer = []; + this.insertModeChanges = []; + this.searchQueries = []; + this.linewise = false; + }, + toString: function() { + return this.keyBuffer.join(''); + } + }; + + /** + * Defines an external register. + * + * The name should be a single character that will be used to reference the register. + * The register should support setText, pushText, clear, and toString(). See Register + * for a reference implementation. + */ + function defineRegister(name, register) { + var registers = vimGlobalState.registerController.registers[name]; + if (!name || name.length != 1) { + throw Error('Register name must be 1 character'); + } + // ace_patch + registers[name] = register; + validRegisters.push(name); + } + + /* + * vim registers allow you to keep many independent copy and paste buffers. + * See http://usevim.com/2012/04/13/registers/ for an introduction. + * + * RegisterController keeps the state of all the registers. An initial + * state may be passed in. The unnamed register '"' will always be + * overridden. + */ + function RegisterController(registers) { + this.registers = registers; + this.unnamedRegister = registers['"'] = new Register(); + registers['.'] = new Register(); + registers[':'] = new Register(); + registers['/'] = new Register(); + } + RegisterController.prototype = { + pushText: function(registerName, operator, text, linewise, blockwise) { + if (linewise && text.charAt(0) == '\n') { + text = text.slice(1) + '\n'; + } + if (linewise && text.charAt(text.length - 1) !== '\n'){ + text += '\n'; + } + // Lowercase and uppercase registers refer to the same register. + // Uppercase just means append. + var register = this.isValidRegister(registerName) ? + this.getRegister(registerName) : null; + // if no register/an invalid register was specified, things go to the + // default registers + if (!register) { + switch (operator) { + case 'yank': + // The 0 register contains the text from the most recent yank. + this.registers['0'] = new Register(text, linewise, blockwise); + break; + case 'delete': + case 'change': + if (text.indexOf('\n') == -1) { + // Delete less than 1 line. Update the small delete register. + this.registers['-'] = new Register(text, linewise); + } else { + // Shift down the contents of the numbered registers and put the + // deleted text into register 1. + this.shiftNumericRegisters_(); + this.registers['1'] = new Register(text, linewise); + } + break; + } + // Make sure the unnamed register is set to what just happened + this.unnamedRegister.setText(text, linewise, blockwise); + return; + } + + // If we've gotten to this point, we've actually specified a register + var append = isUpperCase(registerName); + if (append) { + register.pushText(text, linewise); + } else { + register.setText(text, linewise, blockwise); + } + // The unnamed register always has the same value as the last used + // register. + this.unnamedRegister.setText(register.toString(), linewise); + }, + // Gets the register named @name. If one of @name doesn't already exist, + // create it. If @name is invalid, return the unnamedRegister. + getRegister: function(name) { + if (!this.isValidRegister(name)) { + return this.unnamedRegister; + } + name = name.toLowerCase(); + if (!this.registers[name]) { + this.registers[name] = new Register(); + } + return this.registers[name]; + }, + isValidRegister: function(name) { + return name && inArray(name, validRegisters); + }, + shiftNumericRegisters_: function() { + for (var i = 9; i >= 2; i--) { + this.registers[i] = this.getRegister('' + (i - 1)); + } + } + }; + function HistoryController() { + this.historyBuffer = []; + this.iterator; + this.initialPrefix = null; + } + HistoryController.prototype = { + // the input argument here acts a user entered prefix for a small time + // until we start autocompletion in which case it is the autocompleted. + nextMatch: function (input, up) { + var historyBuffer = this.historyBuffer; + var dir = up ? -1 : 1; + if (this.initialPrefix === null) this.initialPrefix = input; + for (var i = this.iterator + dir; up ? i >= 0 : i < historyBuffer.length; i+= dir) { + var element = historyBuffer[i]; + for (var j = 0; j <= element.length; j++) { + if (this.initialPrefix == element.substring(0, j)) { + this.iterator = i; + return element; + } + } + } + // should return the user input in case we reach the end of buffer. + if (i >= historyBuffer.length) { + this.iterator = historyBuffer.length; + return this.initialPrefix; + } + // return the last autocompleted query or exCommand as it is. + if (i < 0 ) return input; + }, + pushInput: function(input) { + var index = this.historyBuffer.indexOf(input); + if (index > -1) this.historyBuffer.splice(index, 1); + if (input.length) this.historyBuffer.push(input); + }, + reset: function() { + this.initialPrefix = null; + this.iterator = this.historyBuffer.length; + } + }; + var commandDispatcher = { + matchCommand: function(keys, keyMap, inputState, context) { + var matches = commandMatches(keys, keyMap, context, inputState); + if (!matches.full && !matches.partial) { + return {type: 'none'}; + } else if (!matches.full && matches.partial) { + return {type: 'partial'}; + } + + var bestMatch; + for (var i = 0; i < matches.full.length; i++) { + var match = matches.full[i]; + if (!bestMatch) { + bestMatch = match; + } + } + if (bestMatch.keys.slice(-11) == '') { + var character = lastChar(keys); + if (//.test(character)) return {type: 'none'}; + inputState.selectedCharacter = character; + } + return {type: 'full', command: bestMatch}; + }, + processCommand: function(cm, vim, command) { + vim.inputState.repeatOverride = command.repeatOverride; + switch (command.type) { + case 'motion': + this.processMotion(cm, vim, command); + break; + case 'operator': + this.processOperator(cm, vim, command); + break; + case 'operatorMotion': + this.processOperatorMotion(cm, vim, command); + break; + case 'action': + this.processAction(cm, vim, command); + break; + case 'search': + this.processSearch(cm, vim, command); + break; + case 'ex': + case 'keyToEx': + this.processEx(cm, vim, command); + break; + default: + break; + } + }, + processMotion: function(cm, vim, command) { + vim.inputState.motion = command.motion; + vim.inputState.motionArgs = copyArgs(command.motionArgs); + this.evalInput(cm, vim); + }, + processOperator: function(cm, vim, command) { + var inputState = vim.inputState; + if (inputState.operator) { + if (inputState.operator == command.operator) { + // Typing an operator twice like 'dd' makes the operator operate + // linewise + inputState.motion = 'expandToLine'; + inputState.motionArgs = { linewise: true }; + this.evalInput(cm, vim); + return; + } else { + // 2 different operators in a row doesn't make sense. + clearInputState(cm); + } + } + inputState.operator = command.operator; + inputState.operatorArgs = copyArgs(command.operatorArgs); + if (vim.visualMode) { + // Operating on a selection in visual mode. We don't need a motion. + this.evalInput(cm, vim); + } + }, + processOperatorMotion: function(cm, vim, command) { + var visualMode = vim.visualMode; + var operatorMotionArgs = copyArgs(command.operatorMotionArgs); + if (operatorMotionArgs) { + // Operator motions may have special behavior in visual mode. + if (visualMode && operatorMotionArgs.visualLine) { + vim.visualLine = true; + } + } + this.processOperator(cm, vim, command); + if (!visualMode) { + this.processMotion(cm, vim, command); + } + }, + processAction: function(cm, vim, command) { + var inputState = vim.inputState; + var repeat = inputState.getRepeat(); + var repeatIsExplicit = !!repeat; + var actionArgs = copyArgs(command.actionArgs) || {}; + if (inputState.selectedCharacter) { + actionArgs.selectedCharacter = inputState.selectedCharacter; + } + // Actions may or may not have motions and operators. Do these first. + if (command.operator) { + this.processOperator(cm, vim, command); + } + if (command.motion) { + this.processMotion(cm, vim, command); + } + if (command.motion || command.operator) { + this.evalInput(cm, vim); + } + actionArgs.repeat = repeat || 1; + actionArgs.repeatIsExplicit = repeatIsExplicit; + actionArgs.registerName = inputState.registerName; + clearInputState(cm); + vim.lastMotion = null; + if (command.isEdit) { + this.recordLastEdit(vim, inputState, command); + } + actions[command.action](cm, actionArgs, vim); + }, + processSearch: function(cm, vim, command) { + if (!cm.getSearchCursor) { + // Search depends on SearchCursor. + return; + } + var forward = command.searchArgs.forward; + var wholeWordOnly = command.searchArgs.wholeWordOnly; + getSearchState(cm).setReversed(!forward); + var promptPrefix = (forward) ? '/' : '?'; + var originalQuery = getSearchState(cm).getQuery(); + var originalScrollPos = cm.getScrollInfo(); + function handleQuery(query, ignoreCase, smartCase) { + vimGlobalState.searchHistoryController.pushInput(query); + vimGlobalState.searchHistoryController.reset(); + try { + updateSearchQuery(cm, query, ignoreCase, smartCase); + } catch (e) { + showConfirm(cm, 'Invalid regex: ' + query); + clearInputState(cm); + return; + } + commandDispatcher.processMotion(cm, vim, { + type: 'motion', + motion: 'findNext', + motionArgs: { forward: true, toJumplist: command.searchArgs.toJumplist } + }); + } + function onPromptClose(query) { + cm.scrollTo(originalScrollPos.left, originalScrollPos.top); + handleQuery(query, true /** ignoreCase */, true /** smartCase */); + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isRecording) { + logSearchQuery(macroModeState, query); + } + } + function onPromptKeyUp(e, query, close) { + var keyName = CodeMirror.keyName(e), up; + if (keyName == 'Up' || keyName == 'Down') { + up = keyName == 'Up' ? true : false; + query = vimGlobalState.searchHistoryController.nextMatch(query, up) || ''; + close(query); + } else { + if ( keyName != 'Left' && keyName != 'Right' && keyName != 'Ctrl' && keyName != 'Alt' && keyName != 'Shift') + vimGlobalState.searchHistoryController.reset(); + } + var parsedQuery; + try { + parsedQuery = updateSearchQuery(cm, query, + true /** ignoreCase */, true /** smartCase */); + } catch (e) { + // Swallow bad regexes for incremental search. + } + if (parsedQuery) { + cm.scrollIntoView(findNext(cm, !forward, parsedQuery), 30); + } else { + clearSearchHighlight(cm); + cm.scrollTo(originalScrollPos.left, originalScrollPos.top); + } + } + function onPromptKeyDown(e, query, close) { + var keyName = CodeMirror.keyName(e); + if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[' || + (keyName == 'Backspace' && query == '')) { + vimGlobalState.searchHistoryController.pushInput(query); + vimGlobalState.searchHistoryController.reset(); + updateSearchQuery(cm, originalQuery); + clearSearchHighlight(cm); + cm.scrollTo(originalScrollPos.left, originalScrollPos.top); + CodeMirror.e_stop(e); + clearInputState(cm); + close(); + cm.focus(); + } else if (keyName == 'Ctrl-U') { + // Ctrl-U clears input. + CodeMirror.e_stop(e); + close(''); + } + } + switch (command.searchArgs.querySrc) { + case 'prompt': + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isPlaying) { + var query = macroModeState.replaySearchQueries.shift(); + handleQuery(query, true /** ignoreCase */, false /** smartCase */); + } else { + showPrompt(cm, { + onClose: onPromptClose, + prefix: promptPrefix, + desc: searchPromptDesc, + onKeyUp: onPromptKeyUp, + onKeyDown: onPromptKeyDown + }); + } + break; + case 'wordUnderCursor': + var word = expandWordUnderCursor(cm, false /** inclusive */, + true /** forward */, false /** bigWord */, + true /** noSymbol */); + var isKeyword = true; + if (!word) { + word = expandWordUnderCursor(cm, false /** inclusive */, + true /** forward */, false /** bigWord */, + false /** noSymbol */); + isKeyword = false; + } + if (!word) { + return; + } + var query = cm.getLine(word.start.line).substring(word.start.ch, + word.end.ch); + if (isKeyword && wholeWordOnly) { + query = '\\b' + query + '\\b'; + } else { + query = escapeRegex(query); + } + + // cachedCursor is used to save the old position of the cursor + // when * or # causes vim to seek for the nearest word and shift + // the cursor before entering the motion. + vimGlobalState.jumpList.cachedCursor = cm.getCursor(); + cm.setCursor(word.start); + + handleQuery(query, true /** ignoreCase */, false /** smartCase */); + break; + } + }, + processEx: function(cm, vim, command) { + function onPromptClose(input) { + // Give the prompt some time to close so that if processCommand shows + // an error, the elements don't overlap. + vimGlobalState.exCommandHistoryController.pushInput(input); + vimGlobalState.exCommandHistoryController.reset(); + exCommandDispatcher.processCommand(cm, input); + } + function onPromptKeyDown(e, input, close) { + var keyName = CodeMirror.keyName(e), up; + if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[' || + (keyName == 'Backspace' && input == '')) { + vimGlobalState.exCommandHistoryController.pushInput(input); + vimGlobalState.exCommandHistoryController.reset(); + CodeMirror.e_stop(e); + clearInputState(cm); + close(); + cm.focus(); + } + if (keyName == 'Up' || keyName == 'Down') { + up = keyName == 'Up' ? true : false; + input = vimGlobalState.exCommandHistoryController.nextMatch(input, up) || ''; + close(input); + } else if (keyName == 'Ctrl-U') { + // Ctrl-U clears input. + CodeMirror.e_stop(e); + close(''); + } else { + if ( keyName != 'Left' && keyName != 'Right' && keyName != 'Ctrl' && keyName != 'Alt' && keyName != 'Shift') + vimGlobalState.exCommandHistoryController.reset(); + } + } + if (command.type == 'keyToEx') { + // Handle user defined Ex to Ex mappings + exCommandDispatcher.processCommand(cm, command.exArgs.input); + } else { + if (vim.visualMode) { + showPrompt(cm, { onClose: onPromptClose, prefix: ':', value: '\'<,\'>', + onKeyDown: onPromptKeyDown}); + } else { + showPrompt(cm, { onClose: onPromptClose, prefix: ':', + onKeyDown: onPromptKeyDown}); + } + } + }, + evalInput: function(cm, vim) { + // If the motion comand is set, execute both the operator and motion. + // Otherwise return. + var inputState = vim.inputState; + var motion = inputState.motion; + var motionArgs = inputState.motionArgs || {}; + var operator = inputState.operator; + var operatorArgs = inputState.operatorArgs || {}; + var registerName = inputState.registerName; + var sel = vim.sel; + // TODO: Make sure cm and vim selections are identical outside visual mode. + var origHead = copyCursor(vim.visualMode ? clipCursorToContent(cm, sel.head): cm.getCursor('head')); + var origAnchor = copyCursor(vim.visualMode ? clipCursorToContent(cm, sel.anchor) : cm.getCursor('anchor')); + var oldHead = copyCursor(origHead); + var oldAnchor = copyCursor(origAnchor); + var newHead, newAnchor; + var repeat; + if (operator) { + this.recordLastEdit(vim, inputState); + } + if (inputState.repeatOverride !== undefined) { + // If repeatOverride is specified, that takes precedence over the + // input state's repeat. Used by Ex mode and can be user defined. + repeat = inputState.repeatOverride; + } else { + repeat = inputState.getRepeat(); + } + if (repeat > 0 && motionArgs.explicitRepeat) { + motionArgs.repeatIsExplicit = true; + } else if (motionArgs.noRepeat || + (!motionArgs.explicitRepeat && repeat === 0)) { + repeat = 1; + motionArgs.repeatIsExplicit = false; + } + if (inputState.selectedCharacter) { + // If there is a character input, stick it in all of the arg arrays. + motionArgs.selectedCharacter = operatorArgs.selectedCharacter = + inputState.selectedCharacter; + } + motionArgs.repeat = repeat; + clearInputState(cm); + if (motion) { + var motionResult = motions[motion](cm, origHead, motionArgs, vim); + vim.lastMotion = motions[motion]; + if (!motionResult) { + return; + } + if (motionArgs.toJumplist) { + if (!operator && cm.ace.curOp != null) + cm.ace.curOp.command.scrollIntoView = "center-animate"; // ace_patch + var jumpList = vimGlobalState.jumpList; + // if the current motion is # or *, use cachedCursor + var cachedCursor = jumpList.cachedCursor; + if (cachedCursor) { + recordJumpPosition(cm, cachedCursor, motionResult); + delete jumpList.cachedCursor; + } else { + recordJumpPosition(cm, origHead, motionResult); + } + } + if (motionResult instanceof Array) { + newAnchor = motionResult[0]; + newHead = motionResult[1]; + } else { + newHead = motionResult; + } + // TODO: Handle null returns from motion commands better. + if (!newHead) { + newHead = copyCursor(origHead); + } + if (vim.visualMode) { + if (!(vim.visualBlock && newHead.ch === Infinity)) { + newHead = clipCursorToContent(cm, newHead, vim.visualBlock); + } + if (newAnchor) { + newAnchor = clipCursorToContent(cm, newAnchor, true); + } + newAnchor = newAnchor || oldAnchor; + sel.anchor = newAnchor; + sel.head = newHead; + updateCmSelection(cm); + updateMark(cm, vim, '<', + cursorIsBefore(newAnchor, newHead) ? newAnchor + : newHead); + updateMark(cm, vim, '>', + cursorIsBefore(newAnchor, newHead) ? newHead + : newAnchor); + } else if (!operator) { + newHead = clipCursorToContent(cm, newHead); + cm.setCursor(newHead.line, newHead.ch); + } + } + if (operator) { + if (operatorArgs.lastSel) { + // Replaying a visual mode operation + newAnchor = oldAnchor; + var lastSel = operatorArgs.lastSel; + var lineOffset = Math.abs(lastSel.head.line - lastSel.anchor.line); + var chOffset = Math.abs(lastSel.head.ch - lastSel.anchor.ch); + if (lastSel.visualLine) { + // Linewise Visual mode: The same number of lines. + newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch); + } else if (lastSel.visualBlock) { + // Blockwise Visual mode: The same number of lines and columns. + newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch + chOffset); + } else if (lastSel.head.line == lastSel.anchor.line) { + // Normal Visual mode within one line: The same number of characters. + newHead = Pos(oldAnchor.line, oldAnchor.ch + chOffset); + } else { + // Normal Visual mode with several lines: The same number of lines, in the + // last line the same number of characters as in the last line the last time. + newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch); + } + vim.visualMode = true; + vim.visualLine = lastSel.visualLine; + vim.visualBlock = lastSel.visualBlock; + sel = vim.sel = { + anchor: newAnchor, + head: newHead + }; + updateCmSelection(cm); + } else if (vim.visualMode) { + operatorArgs.lastSel = { + anchor: copyCursor(sel.anchor), + head: copyCursor(sel.head), + visualBlock: vim.visualBlock, + visualLine: vim.visualLine + }; + } + var curStart, curEnd, linewise, mode; + var cmSel; + if (vim.visualMode) { + // Init visual op + curStart = cursorMin(sel.head, sel.anchor); + curEnd = cursorMax(sel.head, sel.anchor); + linewise = vim.visualLine || operatorArgs.linewise; + mode = vim.visualBlock ? 'block' : + linewise ? 'line' : + 'char'; + cmSel = makeCmSelection(cm, { + anchor: curStart, + head: curEnd + }, mode); + if (linewise) { + var ranges = cmSel.ranges; + if (mode == 'block') { + // Linewise operators in visual block mode extend to end of line + for (var i = 0; i < ranges.length; i++) { + ranges[i].head.ch = lineLength(cm, ranges[i].head.line); + } + } else if (mode == 'line') { + ranges[0].head = Pos(ranges[0].head.line + 1, 0); + } + } + } else { + // Init motion op + curStart = copyCursor(newAnchor || oldAnchor); + curEnd = copyCursor(newHead || oldHead); + if (cursorIsBefore(curEnd, curStart)) { + var tmp = curStart; + curStart = curEnd; + curEnd = tmp; + } + linewise = motionArgs.linewise || operatorArgs.linewise; + if (linewise) { + // Expand selection to entire line. + expandSelectionToLine(cm, curStart, curEnd); + } else if (motionArgs.forward) { + // Clip to trailing newlines only if the motion goes forward. + clipToLine(cm, curStart, curEnd); + } + mode = 'char'; + var exclusive = !motionArgs.inclusive || linewise; + cmSel = makeCmSelection(cm, { + anchor: curStart, + head: curEnd + }, mode, exclusive); + } + cm.setSelections(cmSel.ranges, cmSel.primary); + vim.lastMotion = null; + operatorArgs.repeat = repeat; // For indent in visual mode. + operatorArgs.registerName = registerName; + // Keep track of linewise as it affects how paste and change behave. + operatorArgs.linewise = linewise; + var operatorMoveTo = operators[operator]( + cm, operatorArgs, cmSel.ranges, oldAnchor, newHead); + if (vim.visualMode) { + exitVisualMode(cm, operatorMoveTo != null); + } + if (operatorMoveTo) { + cm.setCursor(operatorMoveTo); + } + } + }, + recordLastEdit: function(vim, inputState, actionCommand) { + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isPlaying) { return; } + vim.lastEditInputState = inputState; + vim.lastEditActionCommand = actionCommand; + macroModeState.lastInsertModeChanges.changes = []; + macroModeState.lastInsertModeChanges.expectCursorActivityForChange = false; + } + }; + + /** + * typedef {Object{line:number,ch:number}} Cursor An object containing the + * position of the cursor. + */ + // All of the functions below return Cursor objects. + var motions = { + moveToTopLine: function(cm, _head, motionArgs) { + var line = getUserVisibleLines(cm).top + motionArgs.repeat -1; + return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); + }, + moveToMiddleLine: function(cm) { + var range = getUserVisibleLines(cm); + var line = Math.floor((range.top + range.bottom) * 0.5); + return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); + }, + moveToBottomLine: function(cm, _head, motionArgs) { + var line = getUserVisibleLines(cm).bottom - motionArgs.repeat +1; + return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); + }, + expandToLine: function(_cm, head, motionArgs) { + // Expands forward to end of line, and then to next line if repeat is + // >1. Does not handle backward motion! + var cur = head; + return Pos(cur.line + motionArgs.repeat - 1, Infinity); + }, + findNext: function(cm, _head, motionArgs) { + var state = getSearchState(cm); + var query = state.getQuery(); + if (!query) { + return; + } + var prev = !motionArgs.forward; + // If search is initiated with ? instead of /, negate direction. + prev = (state.isReversed()) ? !prev : prev; + highlightSearchMatches(cm, query); + return findNext(cm, prev/** prev */, query, motionArgs.repeat); + }, + goToMark: function(cm, _head, motionArgs, vim) { + var mark = vim.marks[motionArgs.selectedCharacter]; + if (mark) { + var pos = mark.find(); + return motionArgs.linewise ? { line: pos.line, ch: findFirstNonWhiteSpaceCharacter(cm.getLine(pos.line)) } : pos; + } + return null; + }, + moveToOtherHighlightedEnd: function(cm, _head, motionArgs, vim) { + if (vim.visualBlock && motionArgs.sameLine) { + var sel = vim.sel; + return [ + clipCursorToContent(cm, Pos(sel.anchor.line, sel.head.ch)), + clipCursorToContent(cm, Pos(sel.head.line, sel.anchor.ch)) + ]; + } else { + return ([vim.sel.head, vim.sel.anchor]); + } + }, + jumpToMark: function(cm, head, motionArgs, vim) { + var best = head; + for (var i = 0; i < motionArgs.repeat; i++) { + var cursor = best; + for (var key in vim.marks) { + if (!isLowerCase(key)) { + continue; + } + var mark = vim.marks[key].find(); + var isWrongDirection = (motionArgs.forward) ? + cursorIsBefore(mark, cursor) : cursorIsBefore(cursor, mark); + + if (isWrongDirection) { + continue; + } + if (motionArgs.linewise && (mark.line == cursor.line)) { + continue; + } + + var equal = cursorEqual(cursor, best); + var between = (motionArgs.forward) ? + cursorIsBetween(cursor, mark, best) : + cursorIsBetween(best, mark, cursor); + + if (equal || between) { + best = mark; + } + } + } + + if (motionArgs.linewise) { + // Vim places the cursor on the first non-whitespace character of + // the line if there is one, else it places the cursor at the end + // of the line, regardless of whether a mark was found. + best = Pos(best.line, findFirstNonWhiteSpaceCharacter(cm.getLine(best.line))); + } + return best; + }, + moveByCharacters: function(_cm, head, motionArgs) { + var cur = head; + var repeat = motionArgs.repeat; + var ch = motionArgs.forward ? cur.ch + repeat : cur.ch - repeat; + return Pos(cur.line, ch); + }, + moveByLines: function(cm, head, motionArgs, vim) { + var cur = head; + var endCh = cur.ch; + // Depending what our last motion was, we may want to do different + // things. If our last motion was moving vertically, we want to + // preserve the HPos from our last horizontal move. If our last motion + // was going to the end of a line, moving vertically we should go to + // the end of the line, etc. + switch (vim.lastMotion) { + case this.moveByLines: + case this.moveByDisplayLines: + case this.moveByScroll: + case this.moveToColumn: + case this.moveToEol: + endCh = vim.lastHPos; + break; + default: + vim.lastHPos = endCh; + } + var repeat = motionArgs.repeat+(motionArgs.repeatOffset||0); + var line = motionArgs.forward ? cur.line + repeat : cur.line - repeat; + var first = cm.firstLine(); + var last = cm.lastLine(); + // Vim cancels linewise motions that start on an edge and move beyond + // that edge. It does not cancel motions that do not start on an edge. + if ((line < first && cur.line == first) || + (line > last && cur.line == last)) { + return; + } + // ace_patch{ + var fold = cm.ace.session.getFoldLine(line); + if (fold) { + if (motionArgs.forward) { + if (line > fold.start.row) + line = fold.end.row + 1; + } else { + line = fold.start.row; + } + } + // ace_patch} + if (motionArgs.toFirstChar){ + endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line)); + vim.lastHPos = endCh; + } + vim.lastHSPos = cm.charCoords(Pos(line, endCh),'div').left; + return Pos(line, endCh); + }, + moveByDisplayLines: function(cm, head, motionArgs, vim) { + var cur = head; + switch (vim.lastMotion) { + case this.moveByDisplayLines: + case this.moveByScroll: + case this.moveByLines: + case this.moveToColumn: + case this.moveToEol: + break; + default: + vim.lastHSPos = cm.charCoords(cur,'div').left; + } + var repeat = motionArgs.repeat; + var res=cm.findPosV(cur,(motionArgs.forward ? repeat : -repeat),'line',vim.lastHSPos); + if (res.hitSide) { + if (motionArgs.forward) { + var lastCharCoords = cm.charCoords(res, 'div'); + var goalCoords = { top: lastCharCoords.top + 8, left: vim.lastHSPos }; + var res = cm.coordsChar(goalCoords, 'div'); + } else { + var resCoords = cm.charCoords(Pos(cm.firstLine(), 0), 'div'); + resCoords.left = vim.lastHSPos; + res = cm.coordsChar(resCoords, 'div'); + } + } + vim.lastHPos = res.ch; + return res; + }, + moveByPage: function(cm, head, motionArgs) { + // CodeMirror only exposes functions that move the cursor page down, so + // doing this bad hack to move the cursor and move it back. evalInput + // will move the cursor to where it should be in the end. + var curStart = head; + var repeat = motionArgs.repeat; + return cm.findPosV(curStart, (motionArgs.forward ? repeat : -repeat), 'page'); + }, + moveByParagraph: function(cm, head, motionArgs) { + var dir = motionArgs.forward ? 1 : -1; + return findParagraph(cm, head, motionArgs.repeat, dir); + }, + moveByScroll: function(cm, head, motionArgs, vim) { + var scrollbox = cm.getScrollInfo(); + var curEnd = null; + var repeat = motionArgs.repeat; + if (!repeat) { + repeat = scrollbox.clientHeight / (2 * cm.defaultTextHeight()); + } + var orig = cm.charCoords(head, 'local'); + motionArgs.repeat = repeat; + var curEnd = motions.moveByDisplayLines(cm, head, motionArgs, vim); + if (!curEnd) { + return null; + } + var dest = cm.charCoords(curEnd, 'local'); + cm.scrollTo(null, scrollbox.top + dest.top - orig.top); + return curEnd; + }, + moveByWords: function(cm, head, motionArgs) { + return moveToWord(cm, head, motionArgs.repeat, !!motionArgs.forward, + !!motionArgs.wordEnd, !!motionArgs.bigWord); + }, + moveTillCharacter: function(cm, _head, motionArgs) { + var repeat = motionArgs.repeat; + var curEnd = moveToCharacter(cm, repeat, motionArgs.forward, + motionArgs.selectedCharacter); + var increment = motionArgs.forward ? -1 : 1; + recordLastCharacterSearch(increment, motionArgs); + if (!curEnd) return null; + curEnd.ch += increment; + return curEnd; + }, + moveToCharacter: function(cm, head, motionArgs) { + var repeat = motionArgs.repeat; + recordLastCharacterSearch(0, motionArgs); + return moveToCharacter(cm, repeat, motionArgs.forward, + motionArgs.selectedCharacter) || head; + }, + moveToSymbol: function(cm, head, motionArgs) { + var repeat = motionArgs.repeat; + return findSymbol(cm, repeat, motionArgs.forward, + motionArgs.selectedCharacter) || head; + }, + moveToColumn: function(cm, head, motionArgs, vim) { + var repeat = motionArgs.repeat; + // repeat is equivalent to which column we want to move to! + vim.lastHPos = repeat - 1; + vim.lastHSPos = cm.charCoords(head,'div').left; + return moveToColumn(cm, repeat); + }, + moveToEol: function(cm, head, motionArgs, vim) { + var cur = head; + vim.lastHPos = Infinity; + var retval= Pos(cur.line + motionArgs.repeat - 1, Infinity); + var end=cm.clipPos(retval); + end.ch--; + vim.lastHSPos = cm.charCoords(end,'div').left; + return retval; + }, + moveToFirstNonWhiteSpaceCharacter: function(cm, head) { + // Go to the start of the line where the text begins, or the end for + // whitespace-only lines + var cursor = head; + return Pos(cursor.line, + findFirstNonWhiteSpaceCharacter(cm.getLine(cursor.line))); + }, + moveToMatchedSymbol: function(cm, head) { + var cursor = head; + var line = cursor.line; + var ch = cursor.ch; + var lineText = cm.getLine(line); + var symbol; + do { + symbol = lineText.charAt(ch++); + if (symbol && isMatchableSymbol(symbol)) { + var style = cm.getTokenTypeAt(Pos(line, ch)); + if (style !== "string" && style !== "comment") { + break; + } + } + } while (symbol); + if (symbol) { + var matched = cm.findMatchingBracket(Pos(line, ch)); + return matched.to; + } else { + return cursor; + } + }, + moveToStartOfLine: function(_cm, head) { + return Pos(head.line, 0); + }, + moveToLineOrEdgeOfDocument: function(cm, _head, motionArgs) { + var lineNum = motionArgs.forward ? cm.lastLine() : cm.firstLine(); + if (motionArgs.repeatIsExplicit) { + lineNum = motionArgs.repeat - cm.getOption('firstLineNumber'); + } + return Pos(lineNum, + findFirstNonWhiteSpaceCharacter(cm.getLine(lineNum))); + }, + textObjectManipulation: function(cm, head, motionArgs, vim) { + // TODO: lots of possible exceptions that can be thrown here. Try da( + // outside of a () block. + + // TODO: adding <> >< to this map doesn't work, presumably because + // they're operators + var mirroredPairs = {'(': ')', ')': '(', + '{': '}', '}': '{', + '[': ']', ']': '['}; + var selfPaired = {'\'': true, '"': true}; + + var character = motionArgs.selectedCharacter; + // 'b' refers to '()' block. + // 'B' refers to '{}' block. + if (character == 'b') { + character = '('; + } else if (character == 'B') { + character = '{'; + } + + // Inclusive is the difference between a and i + // TODO: Instead of using the additional text object map to perform text + // object operations, merge the map into the defaultKeyMap and use + // motionArgs to define behavior. Define separate entries for 'aw', + // 'iw', 'a[', 'i[', etc. + var inclusive = !motionArgs.textObjectInner; + + var tmp; + if (mirroredPairs[character]) { + tmp = selectCompanionObject(cm, head, character, inclusive); + } else if (selfPaired[character]) { + tmp = findBeginningAndEnd(cm, head, character, inclusive); + } else if (character === 'W') { + tmp = expandWordUnderCursor(cm, inclusive, true /** forward */, + true /** bigWord */); + } else if (character === 'w') { + tmp = expandWordUnderCursor(cm, inclusive, true /** forward */, + false /** bigWord */); + } else if (character === 'p') { + tmp = findParagraph(cm, head, motionArgs.repeat, 0, inclusive); + motionArgs.linewise = true; + if (vim.visualMode) { + if (!vim.visualLine) { vim.visualLine = true; } + } else { + var operatorArgs = vim.inputState.operatorArgs; + if (operatorArgs) { operatorArgs.linewise = true; } + tmp.end.line--; + } + } else { + // No text object defined for this, don't move. + return null; + } + + if (!cm.state.vim.visualMode) { + return [tmp.start, tmp.end]; + } else { + return expandSelection(cm, tmp.start, tmp.end); + } + }, + + repeatLastCharacterSearch: function(cm, head, motionArgs) { + var lastSearch = vimGlobalState.lastChararacterSearch; + var repeat = motionArgs.repeat; + var forward = motionArgs.forward === lastSearch.forward; + var increment = (lastSearch.increment ? 1 : 0) * (forward ? -1 : 1); + cm.moveH(-increment, 'char'); + motionArgs.inclusive = forward ? true : false; + var curEnd = moveToCharacter(cm, repeat, forward, lastSearch.selectedCharacter); + if (!curEnd) { + cm.moveH(increment, 'char'); + return head; + } + curEnd.ch += increment; + return curEnd; + } + }; + + function defineMotion(name, fn) { + motions[name] = fn; + } + + function fillArray(val, times) { + var arr = []; + for (var i = 0; i < times; i++) { + arr.push(val); + } + return arr; + } + /** + * An operator acts on a text selection. It receives the list of selections + * as input. The corresponding CodeMirror selection is guaranteed to + * match the input selection. + */ + var operators = { + change: function(cm, args, ranges) { + var finalHead, text; + var vim = cm.state.vim; + vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock = vim.visualBlock; + if (!vim.visualMode) { + var anchor = ranges[0].anchor, + head = ranges[0].head; + text = cm.getRange(anchor, head); + var lastState = vim.lastEditInputState || {}; + if (lastState.motion == "moveByWords" && !isWhiteSpaceString(text)) { + // Exclude trailing whitespace if the range is not all whitespace. + var match = (/\s+$/).exec(text); + if (match && lastState.motionArgs && lastState.motionArgs.forward) { + head = offsetCursor(head, 0, - match[0].length); + text = text.slice(0, - match[0].length); + } + } + var prevLineEnd = new Pos(anchor.line - 1, Number.MAX_VALUE); + var wasLastLine = cm.firstLine() == cm.lastLine(); + if (head.line > cm.lastLine() && args.linewise && !wasLastLine) { + cm.replaceRange('', prevLineEnd, head); + } else { + cm.replaceRange('', anchor, head); + } + if (args.linewise) { + // Push the next line back down, if there is a next line. + if (!wasLastLine) { + cm.setCursor(prevLineEnd); + CodeMirror.commands.newlineAndIndent(cm); + } + // make sure cursor ends up at the end of the line. + anchor.ch = Number.MAX_VALUE; + } + finalHead = anchor; + } else { + text = cm.getSelection(); + var replacement = fillArray('', ranges.length); + cm.replaceSelections(replacement); + finalHead = cursorMin(ranges[0].head, ranges[0].anchor); + } + vimGlobalState.registerController.pushText( + args.registerName, 'change', text, + args.linewise, ranges.length > 1); + actions.enterInsertMode(cm, {head: finalHead}, cm.state.vim); + }, + // delete is a javascript keyword. + 'delete': function(cm, args, ranges) { + var finalHead, text; + var vim = cm.state.vim; + if (!vim.visualBlock) { + var anchor = ranges[0].anchor, + head = ranges[0].head; + if (args.linewise && + head.line != cm.firstLine() && + anchor.line == cm.lastLine() && + anchor.line == head.line - 1) { + // Special case for dd on last line (and first line). + if (anchor.line == cm.firstLine()) { + anchor.ch = 0; + } else { + anchor = Pos(anchor.line - 1, lineLength(cm, anchor.line - 1)); + } + } + text = cm.getRange(anchor, head); + cm.replaceRange('', anchor, head); + finalHead = anchor; + if (args.linewise) { + finalHead = motions.moveToFirstNonWhiteSpaceCharacter(cm, anchor); + } + } else { + text = cm.getSelection(); + var replacement = fillArray('', ranges.length); + cm.replaceSelections(replacement); + finalHead = ranges[0].anchor; + } + vimGlobalState.registerController.pushText( + args.registerName, 'delete', text, + args.linewise, vim.visualBlock); + return clipCursorToContent(cm, finalHead); + }, + indent: function(cm, args, ranges) { + var vim = cm.state.vim; + var startLine = ranges[0].anchor.line; + var endLine = vim.visualBlock ? + ranges[ranges.length - 1].anchor.line : + ranges[0].head.line; + // In visual mode, n> shifts the selection right n times, instead of + // shifting n lines right once. + var repeat = (vim.visualMode) ? args.repeat : 1; + if (args.linewise) { + // The only way to delete a newline is to delete until the start of + // the next line, so in linewise mode evalInput will include the next + // line. We don't want this in indent, so we go back a line. + endLine--; + } + for (var i = startLine; i <= endLine; i++) { + for (var j = 0; j < repeat; j++) { + cm.indentLine(i, args.indentRight); + } + } + return motions.moveToFirstNonWhiteSpaceCharacter(cm, ranges[0].anchor); + }, + changeCase: function(cm, args, ranges, oldAnchor, newHead) { + var selections = cm.getSelections(); + var swapped = []; + var toLower = args.toLower; + for (var j = 0; j < selections.length; j++) { + var toSwap = selections[j]; + var text = ''; + if (toLower === true) { + text = toSwap.toLowerCase(); + } else if (toLower === false) { + text = toSwap.toUpperCase(); + } else { + for (var i = 0; i < toSwap.length; i++) { + var character = toSwap.charAt(i); + text += isUpperCase(character) ? character.toLowerCase() : + character.toUpperCase(); + } + } + swapped.push(text); + } + cm.replaceSelections(swapped); + if (args.shouldMoveCursor){ + return newHead; + } else if (!cm.state.vim.visualMode && args.linewise && ranges[0].anchor.line + 1 == ranges[0].head.line) { + return motions.moveToFirstNonWhiteSpaceCharacter(cm, oldAnchor); + } else if (args.linewise){ + return oldAnchor; + } else { + return cursorMin(ranges[0].anchor, ranges[0].head); + } + }, + yank: function(cm, args, ranges, oldAnchor) { + var vim = cm.state.vim; + var text = cm.getSelection(); + var endPos = vim.visualMode + ? cursorMin(vim.sel.anchor, vim.sel.head, ranges[0].head, ranges[0].anchor) + : oldAnchor; + vimGlobalState.registerController.pushText( + args.registerName, 'yank', + text, args.linewise, vim.visualBlock); + return endPos; + } + }; + + function defineOperator(name, fn) { + operators[name] = fn; + } + + var actions = { + jumpListWalk: function(cm, actionArgs, vim) { + if (vim.visualMode) { + return; + } + var repeat = actionArgs.repeat; + var forward = actionArgs.forward; + var jumpList = vimGlobalState.jumpList; + + var mark = jumpList.move(cm, forward ? repeat : -repeat); + var markPos = mark ? mark.find() : undefined; + markPos = markPos ? markPos : cm.getCursor(); + cm.setCursor(markPos); + cm.ace.curOp.command.scrollIntoView = "center-animate"; // ace_patch + }, + scroll: function(cm, actionArgs, vim) { + if (vim.visualMode) { + return; + } + var repeat = actionArgs.repeat || 1; + var lineHeight = cm.defaultTextHeight(); + var top = cm.getScrollInfo().top; + var delta = lineHeight * repeat; + var newPos = actionArgs.forward ? top + delta : top - delta; + var cursor = copyCursor(cm.getCursor()); + var cursorCoords = cm.charCoords(cursor, 'local'); + if (actionArgs.forward) { + if (newPos > cursorCoords.top) { + cursor.line += (newPos - cursorCoords.top) / lineHeight; + cursor.line = Math.ceil(cursor.line); + cm.setCursor(cursor); + cursorCoords = cm.charCoords(cursor, 'local'); + cm.scrollTo(null, cursorCoords.top); + } else { + // Cursor stays within bounds. Just reposition the scroll window. + cm.scrollTo(null, newPos); + } + } else { + var newBottom = newPos + cm.getScrollInfo().clientHeight; + if (newBottom < cursorCoords.bottom) { + cursor.line -= (cursorCoords.bottom - newBottom) / lineHeight; + cursor.line = Math.floor(cursor.line); + cm.setCursor(cursor); + cursorCoords = cm.charCoords(cursor, 'local'); + cm.scrollTo( + null, cursorCoords.bottom - cm.getScrollInfo().clientHeight); + } else { + // Cursor stays within bounds. Just reposition the scroll window. + cm.scrollTo(null, newPos); + } + } + }, + scrollToCursor: function(cm, actionArgs) { + var lineNum = cm.getCursor().line; + var charCoords = cm.charCoords(Pos(lineNum, 0), 'local'); + var height = cm.getScrollInfo().clientHeight; + var y = charCoords.top; + var lineHeight = charCoords.bottom - y; + switch (actionArgs.position) { + case 'center': y = y - (height / 2) + lineHeight; + break; + case 'bottom': y = y - height + lineHeight*1.4; + break; + case 'top': y = y + lineHeight*0.4; + break; + } + cm.scrollTo(null, y); + }, + replayMacro: function(cm, actionArgs, vim) { + var registerName = actionArgs.selectedCharacter; + var repeat = actionArgs.repeat; + var macroModeState = vimGlobalState.macroModeState; + if (registerName == '@') { + registerName = macroModeState.latestRegister; + } + while(repeat--){ + executeMacroRegister(cm, vim, macroModeState, registerName); + } + }, + enterMacroRecordMode: function(cm, actionArgs) { + var macroModeState = vimGlobalState.macroModeState; + var registerName = actionArgs.selectedCharacter; + macroModeState.enterMacroRecordMode(cm, registerName); + }, + enterInsertMode: function(cm, actionArgs, vim) { + if (cm.getOption('readOnly')) { return; } + vim.insertMode = true; + vim.insertModeRepeat = actionArgs && actionArgs.repeat || 1; + var insertAt = (actionArgs) ? actionArgs.insertAt : null; + var sel = vim.sel; + var head = actionArgs.head || cm.getCursor('head'); + var height = cm.listSelections().length; + if (insertAt == 'eol') { + head = Pos(head.line, lineLength(cm, head.line)); + } else if (insertAt == 'charAfter') { + head = offsetCursor(head, 0, 1); + } else if (insertAt == 'firstNonBlank') { + head = motions.moveToFirstNonWhiteSpaceCharacter(cm, head); + } else if (insertAt == 'startOfSelectedArea') { + if (!vim.visualBlock) { + if (sel.head.line < sel.anchor.line) { + head = sel.head; + } else { + head = Pos(sel.anchor.line, 0); + } + } else { + head = Pos( + Math.min(sel.head.line, sel.anchor.line), + Math.min(sel.head.ch, sel.anchor.ch)); + height = Math.abs(sel.head.line - sel.anchor.line) + 1; + } + } else if (insertAt == 'endOfSelectedArea') { + if (!vim.visualBlock) { + if (sel.head.line >= sel.anchor.line) { + head = offsetCursor(sel.head, 0, 1); + } else { + head = Pos(sel.anchor.line, 0); + } + } else { + head = Pos( + Math.min(sel.head.line, sel.anchor.line), + Math.max(sel.head.ch + 1, sel.anchor.ch)); + height = Math.abs(sel.head.line - sel.anchor.line) + 1; + } + } else if (insertAt == 'inplace') { + if (vim.visualMode){ + return; + } + } + cm.setOption('keyMap', 'vim-insert'); + cm.setOption('disableInput', false); + if (actionArgs && actionArgs.replace) { + // Handle Replace-mode as a special case of insert mode. + cm.toggleOverwrite(true); + cm.setOption('keyMap', 'vim-replace'); + CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"}); + } else { + cm.setOption('keyMap', 'vim-insert'); + CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"}); + } + if (!vimGlobalState.macroModeState.isPlaying) { + // Only record if not replaying. + cm.on('change', onChange); + CodeMirror.on(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown); + } + if (vim.visualMode) { + exitVisualMode(cm); + } + selectForInsert(cm, head, height); + }, + toggleVisualMode: function(cm, actionArgs, vim) { + var repeat = actionArgs.repeat; + var anchor = cm.getCursor(); + var head; + // TODO: The repeat should actually select number of characters/lines + // equal to the repeat times the size of the previous visual + // operation. + if (!vim.visualMode) { + // Entering visual mode + vim.visualMode = true; + vim.visualLine = !!actionArgs.linewise; + vim.visualBlock = !!actionArgs.blockwise; + head = clipCursorToContent( + cm, Pos(anchor.line, anchor.ch + repeat - 1), + true /** includeLineBreak */); + vim.sel = { + anchor: anchor, + head: head + }; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: vim.visualLine ? "linewise" : vim.visualBlock ? "blockwise" : ""}); + updateCmSelection(cm); + updateMark(cm, vim, '<', cursorMin(anchor, head)); + updateMark(cm, vim, '>', cursorMax(anchor, head)); + } else if (vim.visualLine ^ actionArgs.linewise || + vim.visualBlock ^ actionArgs.blockwise) { + // Toggling between modes + vim.visualLine = !!actionArgs.linewise; + vim.visualBlock = !!actionArgs.blockwise; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: vim.visualLine ? "linewise" : vim.visualBlock ? "blockwise" : ""}); + updateCmSelection(cm); + } else { + exitVisualMode(cm); + } + }, + reselectLastSelection: function(cm, _actionArgs, vim) { + var lastSelection = vim.lastSelection; + if (vim.visualMode) { + updateLastSelection(cm, vim); + } + if (lastSelection) { + var anchor = lastSelection.anchorMark.find(); + var head = lastSelection.headMark.find(); + if (!anchor || !head) { + // If the marks have been destroyed due to edits, do nothing. + return; + } + vim.sel = { + anchor: anchor, + head: head + }; + vim.visualMode = true; + vim.visualLine = lastSelection.visualLine; + vim.visualBlock = lastSelection.visualBlock; + updateCmSelection(cm); + updateMark(cm, vim, '<', cursorMin(anchor, head)); + updateMark(cm, vim, '>', cursorMax(anchor, head)); + CodeMirror.signal(cm, 'vim-mode-change', { + mode: 'visual', + subMode: vim.visualLine ? 'linewise' : + vim.visualBlock ? 'blockwise' : ''}); + } + }, + joinLines: function(cm, actionArgs, vim) { + var curStart, curEnd; + if (vim.visualMode) { + curStart = cm.getCursor('anchor'); + curEnd = cm.getCursor('head'); + if (cursorIsBefore(curEnd, curStart)) { + var tmp = curEnd; + curEnd = curStart; + curStart = tmp; + } + curEnd.ch = lineLength(cm, curEnd.line) - 1; + } else { + // Repeat is the number of lines to join. Minimum 2 lines. + var repeat = Math.max(actionArgs.repeat, 2); + curStart = cm.getCursor(); + curEnd = clipCursorToContent(cm, Pos(curStart.line + repeat - 1, + Infinity)); + } + var finalCh = 0; + for (var i = curStart.line; i < curEnd.line; i++) { + finalCh = lineLength(cm, curStart.line); + var tmp = Pos(curStart.line + 1, + lineLength(cm, curStart.line + 1)); + var text = cm.getRange(curStart, tmp); + text = text.replace(/\n\s*/g, ' '); + cm.replaceRange(text, curStart, tmp); + } + var curFinalPos = Pos(curStart.line, finalCh); + if (vim.visualMode) { + exitVisualMode(cm, false); + } + cm.setCursor(curFinalPos); + }, + newLineAndEnterInsertMode: function(cm, actionArgs, vim) { + vim.insertMode = true; + var insertAt = copyCursor(cm.getCursor()); + if (insertAt.line === cm.firstLine() && !actionArgs.after) { + // Special case for inserting newline before start of document. + cm.replaceRange('\n', Pos(cm.firstLine(), 0)); + cm.setCursor(cm.firstLine(), 0); + } else { + insertAt.line = (actionArgs.after) ? insertAt.line : + insertAt.line - 1; + insertAt.ch = lineLength(cm, insertAt.line); + cm.setCursor(insertAt); + var newlineFn = CodeMirror.commands.newlineAndIndentContinueComment || + CodeMirror.commands.newlineAndIndent; + newlineFn(cm); + } + this.enterInsertMode(cm, { repeat: actionArgs.repeat }, vim); + }, + paste: function(cm, actionArgs, vim) { + var cur = copyCursor(cm.getCursor()); + var register = vimGlobalState.registerController.getRegister( + actionArgs.registerName); + var text = register.toString(); + if (!text) { + return; + } + if (actionArgs.matchIndent) { + var tabSize = cm.getOption("tabSize"); + // length that considers tabs and tabSize + var whitespaceLength = function(str) { + var tabs = (str.split("\t").length - 1); + var spaces = (str.split(" ").length - 1); + return tabs * tabSize + spaces * 1; + }; + var currentLine = cm.getLine(cm.getCursor().line); + var indent = whitespaceLength(currentLine.match(/^\s*/)[0]); + // chomp last newline b/c don't want it to match /^\s*/gm + var chompedText = text.replace(/\n$/, ''); + var wasChomped = text !== chompedText; + var firstIndent = whitespaceLength(text.match(/^\s*/)[0]); + var text = chompedText.replace(/^\s*/gm, function(wspace) { + var newIndent = indent + (whitespaceLength(wspace) - firstIndent); + if (newIndent < 0) { + return ""; + } + else if (cm.getOption("indentWithTabs")) { + var quotient = Math.floor(newIndent / tabSize); + return Array(quotient + 1).join('\t'); + } + else { + return Array(newIndent + 1).join(' '); + } + }); + text += wasChomped ? "\n" : ""; + } + if (actionArgs.repeat > 1) { + var text = Array(actionArgs.repeat + 1).join(text); + } + var linewise = register.linewise; + var blockwise = register.blockwise; + if (linewise && !blockwise) { + if(vim.visualMode) { + text = vim.visualLine ? text.slice(0, -1) : '\n' + text.slice(0, text.length - 1) + '\n'; + } else if (actionArgs.after) { + // Move the newline at the end to the start instead, and paste just + // before the newline character of the line we are on right now. + text = '\n' + text.slice(0, text.length - 1); + cur.ch = lineLength(cm, cur.line); + } else { + cur.ch = 0; + } + } else { + if (blockwise) { + text = text.split('\n'); + for (var i = 0; i < text.length; i++) { + text[i] = (text[i] == '') ? ' ' : text[i]; + } + } + cur.ch += actionArgs.after ? 1 : 0; + } + var curPosFinal; + var idx; + if (vim.visualMode) { + // save the pasted text for reselection if the need arises + vim.lastPastedText = text; + var lastSelectionCurEnd; + var selectedArea = getSelectedAreaRange(cm, vim); + var selectionStart = selectedArea[0]; + var selectionEnd = selectedArea[1]; + var selectedText = cm.getSelection(); + var selections = cm.listSelections(); + var emptyStrings = new Array(selections.length).join('1').split('1'); + // save the curEnd marker before it get cleared due to cm.replaceRange. + if (vim.lastSelection) { + lastSelectionCurEnd = vim.lastSelection.headMark.find(); + } + // push the previously selected text to unnamed register + vimGlobalState.registerController.unnamedRegister.setText(selectedText); + if (blockwise) { + // first delete the selected text + cm.replaceSelections(emptyStrings); + // Set new selections as per the block length of the yanked text + selectionEnd = Pos(selectionStart.line + text.length-1, selectionStart.ch); + cm.setCursor(selectionStart); + selectBlock(cm, selectionEnd); + cm.replaceSelections(text); + curPosFinal = selectionStart; + } else if (vim.visualBlock) { + cm.replaceSelections(emptyStrings); + cm.setCursor(selectionStart); + cm.replaceRange(text, selectionStart, selectionStart); + curPosFinal = selectionStart; + } else { + cm.replaceRange(text, selectionStart, selectionEnd); + curPosFinal = cm.posFromIndex(cm.indexFromPos(selectionStart) + text.length - 1); + } + // restore the the curEnd marker + if(lastSelectionCurEnd) { + vim.lastSelection.headMark = cm.setBookmark(lastSelectionCurEnd); + } + if (linewise) { + curPosFinal.ch=0; + } + } else { + if (blockwise) { + cm.setCursor(cur); + for (var i = 0; i < text.length; i++) { + var line = cur.line+i; + if (line > cm.lastLine()) { + cm.replaceRange('\n', Pos(line, 0)); + } + var lastCh = lineLength(cm, line); + if (lastCh < cur.ch) { + extendLineToColumn(cm, line, cur.ch); + } + } + cm.setCursor(cur); + selectBlock(cm, Pos(cur.line + text.length-1, cur.ch)); + cm.replaceSelections(text); + curPosFinal = cur; + } else { + cm.replaceRange(text, cur); + // Now fine tune the cursor to where we want it. + if (linewise && actionArgs.after) { + curPosFinal = Pos( + cur.line + 1, + findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line + 1))); + } else if (linewise && !actionArgs.after) { + curPosFinal = Pos( + cur.line, + findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line))); + } else if (!linewise && actionArgs.after) { + idx = cm.indexFromPos(cur); + curPosFinal = cm.posFromIndex(idx + text.length - 1); + } else { + idx = cm.indexFromPos(cur); + curPosFinal = cm.posFromIndex(idx + text.length); + } + } + } + if (vim.visualMode) { + exitVisualMode(cm, false); + } + cm.setCursor(curPosFinal); + }, + undo: function(cm, actionArgs) { + cm.operation(function() { + repeatFn(cm, CodeMirror.commands.undo, actionArgs.repeat)(); + cm.setCursor(cm.getCursor('anchor')); + }); + }, + redo: function(cm, actionArgs) { + repeatFn(cm, CodeMirror.commands.redo, actionArgs.repeat)(); + }, + setRegister: function(_cm, actionArgs, vim) { + vim.inputState.registerName = actionArgs.selectedCharacter; + }, + setMark: function(cm, actionArgs, vim) { + var markName = actionArgs.selectedCharacter; + updateMark(cm, vim, markName, cm.getCursor()); + }, + replace: function(cm, actionArgs, vim) { + var replaceWith = actionArgs.selectedCharacter; + var curStart = cm.getCursor(); + var replaceTo; + var curEnd; + var selections = cm.listSelections(); + if (vim.visualMode) { + curStart = cm.getCursor('start'); + curEnd = cm.getCursor('end'); + } else { + var line = cm.getLine(curStart.line); + replaceTo = curStart.ch + actionArgs.repeat; + if (replaceTo > line.length) { + replaceTo=line.length; + } + curEnd = Pos(curStart.line, replaceTo); + } + if (replaceWith=='\n') { + if (!vim.visualMode) cm.replaceRange('', curStart, curEnd); + // special case, where vim help says to replace by just one line-break + (CodeMirror.commands.newlineAndIndentContinueComment || CodeMirror.commands.newlineAndIndent)(cm); + } else { + var replaceWithStr = cm.getRange(curStart, curEnd); + //replace all characters in range by selected, but keep linebreaks + replaceWithStr = replaceWithStr.replace(/[^\n]/g, replaceWith); + if (vim.visualBlock) { + // Tabs are split in visua block before replacing + var spaces = new Array(cm.getOption("tabSize")+1).join(' '); + replaceWithStr = cm.getSelection(); + replaceWithStr = replaceWithStr.replace(/\t/g, spaces).replace(/[^\n]/g, replaceWith).split('\n'); + cm.replaceSelections(replaceWithStr); + } else { + cm.replaceRange(replaceWithStr, curStart, curEnd); + } + if (vim.visualMode) { + curStart = cursorIsBefore(selections[0].anchor, selections[0].head) ? + selections[0].anchor : selections[0].head; + cm.setCursor(curStart); + exitVisualMode(cm, false); + } else { + cm.setCursor(offsetCursor(curEnd, 0, -1)); + } + } + }, + incrementNumberToken: function(cm, actionArgs) { + var cur = cm.getCursor(); + var lineStr = cm.getLine(cur.line); + var re = /-?\d+/g; + var match; + var start; + var end; + var numberStr; + var token; + while ((match = re.exec(lineStr)) !== null) { + token = match[0]; + start = match.index; + end = start + token.length; + if (cur.ch < end)break; + } + if (!actionArgs.backtrack && (end <= cur.ch))return; + if (token) { + var increment = actionArgs.increase ? 1 : -1; + var number = parseInt(token) + (increment * actionArgs.repeat); + var from = Pos(cur.line, start); + var to = Pos(cur.line, end); + numberStr = number.toString(); + cm.replaceRange(numberStr, from, to); + } else { + return; + } + cm.setCursor(Pos(cur.line, start + numberStr.length - 1)); + }, + repeatLastEdit: function(cm, actionArgs, vim) { + var lastEditInputState = vim.lastEditInputState; + if (!lastEditInputState) { return; } + var repeat = actionArgs.repeat; + if (repeat && actionArgs.repeatIsExplicit) { + vim.lastEditInputState.repeatOverride = repeat; + } else { + repeat = vim.lastEditInputState.repeatOverride || repeat; + } + repeatLastEdit(cm, vim, repeat, false /** repeatForInsert */); + }, + exitInsertMode: exitInsertMode + }; + + function defineAction(name, fn) { + actions[name] = fn; + } + + /* + * Below are miscellaneous utility functions used by vim.js + */ + + /** + * Clips cursor to ensure that line is within the buffer's range + * If includeLineBreak is true, then allow cur.ch == lineLength. + */ + function clipCursorToContent(cm, cur, includeLineBreak) { + var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() ); + var maxCh = lineLength(cm, line) - 1; + maxCh = (includeLineBreak) ? maxCh + 1 : maxCh; + var ch = Math.min(Math.max(0, cur.ch), maxCh); + return Pos(line, ch); + } + function copyArgs(args) { + var ret = {}; + for (var prop in args) { + if (args.hasOwnProperty(prop)) { + ret[prop] = args[prop]; + } + } + return ret; + } + function offsetCursor(cur, offsetLine, offsetCh) { + if (typeof offsetLine === 'object') { + offsetCh = offsetLine.ch; + offsetLine = offsetLine.line; + } + return Pos(cur.line + offsetLine, cur.ch + offsetCh); + } + function getOffset(anchor, head) { + return { + line: head.line - anchor.line, + ch: head.line - anchor.line + }; + } + function commandMatches(keys, keyMap, context, inputState) { + // Partial matches are not applied. They inform the key handler + // that the current key sequence is a subsequence of a valid key + // sequence, so that the key buffer is not cleared. + var match, partial = [], full = []; + for (var i = 0; i < keyMap.length; i++) { + var command = keyMap[i]; + if (context == 'insert' && command.context != 'insert' || + command.context && command.context != context || + inputState.operator && command.type == 'action' || + !(match = commandMatch(keys, command.keys))) { continue; } + if (match == 'partial') { partial.push(command); } + if (match == 'full') { full.push(command); } + } + return { + partial: partial.length && partial, + full: full.length && full + }; + } + function commandMatch(pressed, mapped) { + if (mapped.slice(-11) == '') { + // Last character matches anything. + var prefixLen = mapped.length - 11; + var pressedPrefix = pressed.slice(0, prefixLen); + var mappedPrefix = mapped.slice(0, prefixLen); + return pressedPrefix == mappedPrefix && pressed.length > prefixLen ? 'full' : + mappedPrefix.indexOf(pressedPrefix) == 0 ? 'partial' : false; + } else { + return pressed == mapped ? 'full' : + mapped.indexOf(pressed) == 0 ? 'partial' : false; + } + } + function lastChar(keys) { + var match = /^.*(<[\w\-]+>)$/.exec(keys); + var selectedCharacter = match ? match[1] : keys.slice(-1); + if (selectedCharacter.length > 1){ + switch(selectedCharacter){ + case '': + selectedCharacter='\n'; + break; + case '': + selectedCharacter=' '; + break; + default: + break; + } + } + return selectedCharacter; + } + function repeatFn(cm, fn, repeat) { + return function() { + for (var i = 0; i < repeat; i++) { + fn(cm); + } + }; + } + function copyCursor(cur) { + return Pos(cur.line, cur.ch); + } + function cursorEqual(cur1, cur2) { + return cur1.ch == cur2.ch && cur1.line == cur2.line; + } + function cursorIsBefore(cur1, cur2) { + if (cur1.line < cur2.line) { + return true; + } + if (cur1.line == cur2.line && cur1.ch < cur2.ch) { + return true; + } + return false; + } + function cursorMin(cur1, cur2) { + if (arguments.length > 2) { + cur2 = cursorMin.apply(undefined, Array.prototype.slice.call(arguments, 1)); + } + return cursorIsBefore(cur1, cur2) ? cur1 : cur2; + } + function cursorMax(cur1, cur2) { + if (arguments.length > 2) { + cur2 = cursorMax.apply(undefined, Array.prototype.slice.call(arguments, 1)); + } + return cursorIsBefore(cur1, cur2) ? cur2 : cur1; + } + function cursorIsBetween(cur1, cur2, cur3) { + // returns true if cur2 is between cur1 and cur3. + var cur1before2 = cursorIsBefore(cur1, cur2); + var cur2before3 = cursorIsBefore(cur2, cur3); + return cur1before2 && cur2before3; + } + function lineLength(cm, lineNum) { + return cm.getLine(lineNum).length; + } + function trim(s) { + if (s.trim) { + return s.trim(); + } + return s.replace(/^\s+|\s+$/g, ''); + } + function escapeRegex(s) { + return s.replace(/([.?*+$\[\]\/\\(){}|\-])/g, '\\$1'); + } + function extendLineToColumn(cm, lineNum, column) { + var endCh = lineLength(cm, lineNum); + var spaces = new Array(column-endCh+1).join(' '); + cm.setCursor(Pos(lineNum, endCh)); + cm.replaceRange(spaces, cm.getCursor()); + } + // This functions selects a rectangular block + // of text with selectionEnd as any of its corner + // Height of block: + // Difference in selectionEnd.line and first/last selection.line + // Width of the block: + // Distance between selectionEnd.ch and any(first considered here) selection.ch + function selectBlock(cm, selectionEnd) { + var selections = [], ranges = cm.listSelections(); + var head = copyCursor(cm.clipPos(selectionEnd)); + var isClipped = !cursorEqual(selectionEnd, head); + var curHead = cm.getCursor('head'); + var primIndex = getIndex(ranges, curHead); + var wasClipped = cursorEqual(ranges[primIndex].head, ranges[primIndex].anchor); + var max = ranges.length - 1; + var index = max - primIndex > primIndex ? max : 0; + var base = ranges[index].anchor; + + var firstLine = Math.min(base.line, head.line); + var lastLine = Math.max(base.line, head.line); + var baseCh = base.ch, headCh = head.ch; + + var dir = ranges[index].head.ch - baseCh; + var newDir = headCh - baseCh; + if (dir > 0 && newDir <= 0) { + baseCh++; + if (!isClipped) { headCh--; } + } else if (dir < 0 && newDir >= 0) { + baseCh--; + if (!wasClipped) { headCh++; } + } else if (dir < 0 && newDir == -1) { + baseCh--; + headCh++; + } + for (var line = firstLine; line <= lastLine; line++) { + var range = {anchor: new Pos(line, baseCh), head: new Pos(line, headCh)}; + selections.push(range); + } + primIndex = head.line == lastLine ? selections.length - 1 : 0; + cm.setSelections(selections); + selectionEnd.ch = headCh; + base.ch = baseCh; + return base; + } + function selectForInsert(cm, head, height) { + var sel = []; + for (var i = 0; i < height; i++) { + var lineHead = offsetCursor(head, i, 0); + sel.push({anchor: lineHead, head: lineHead}); + } + cm.setSelections(sel, 0); + } + // getIndex returns the index of the cursor in the selections. + function getIndex(ranges, cursor, end) { + for (var i = 0; i < ranges.length; i++) { + var atAnchor = end != 'head' && cursorEqual(ranges[i].anchor, cursor); + var atHead = end != 'anchor' && cursorEqual(ranges[i].head, cursor); + if (atAnchor || atHead) { + return i; + } + } + return -1; + } + function getSelectedAreaRange(cm, vim) { + var lastSelection = vim.lastSelection; + var getCurrentSelectedAreaRange = function() { + var selections = cm.listSelections(); + var start = selections[0]; + var end = selections[selections.length-1]; + var selectionStart = cursorIsBefore(start.anchor, start.head) ? start.anchor : start.head; + var selectionEnd = cursorIsBefore(end.anchor, end.head) ? end.head : end.anchor; + return [selectionStart, selectionEnd]; + }; + var getLastSelectedAreaRange = function() { + var selectionStart = cm.getCursor(); + var selectionEnd = cm.getCursor(); + var block = lastSelection.visualBlock; + if (block) { + var width = block.width; + var height = block.height; + selectionEnd = Pos(selectionStart.line + height, selectionStart.ch + width); + var selections = []; + // selectBlock creates a 'proper' rectangular block. + // We do not want that in all cases, so we manually set selections. + for (var i = selectionStart.line; i < selectionEnd.line; i++) { + var anchor = Pos(i, selectionStart.ch); + var head = Pos(i, selectionEnd.ch); + var range = {anchor: anchor, head: head}; + selections.push(range); + } + cm.setSelections(selections); + } else { + var start = lastSelection.anchorMark.find(); + var end = lastSelection.headMark.find(); + var line = end.line - start.line; + var ch = end.ch - start.ch; + selectionEnd = {line: selectionEnd.line + line, ch: line ? selectionEnd.ch : ch + selectionEnd.ch}; + if (lastSelection.visualLine) { + selectionStart = Pos(selectionStart.line, 0); + selectionEnd = Pos(selectionEnd.line, lineLength(cm, selectionEnd.line)); + } + cm.setSelection(selectionStart, selectionEnd); + } + return [selectionStart, selectionEnd]; + }; + if (!vim.visualMode) { + // In case of replaying the action. + return getLastSelectedAreaRange(); + } else { + return getCurrentSelectedAreaRange(); + } + } + // Updates the previous selection with the current selection's values. This + // should only be called in visual mode. + function updateLastSelection(cm, vim) { + var anchor = vim.sel.anchor; + var head = vim.sel.head; + // To accommodate the effect of lastPastedText in the last selection + if (vim.lastPastedText) { + head = cm.posFromIndex(cm.indexFromPos(anchor) + vim.lastPastedText.length); + vim.lastPastedText = null; + } + vim.lastSelection = {'anchorMark': cm.setBookmark(anchor), + 'headMark': cm.setBookmark(head), + 'anchor': copyCursor(anchor), + 'head': copyCursor(head), + 'visualMode': vim.visualMode, + 'visualLine': vim.visualLine, + 'visualBlock': vim.visualBlock}; + } + function expandSelection(cm, start, end) { + var sel = cm.state.vim.sel; + var head = sel.head; + var anchor = sel.anchor; + var tmp; + if (cursorIsBefore(end, start)) { + tmp = end; + end = start; + start = tmp; + } + if (cursorIsBefore(head, anchor)) { + head = cursorMin(start, head); + anchor = cursorMax(anchor, end); + } else { + anchor = cursorMin(start, anchor); + head = cursorMax(head, end); + head = offsetCursor(head, 0, -1); + if (head.ch == -1 && head.line != cm.firstLine()) { + head = Pos(head.line - 1, lineLength(cm, head.line - 1)); + } + } + return [anchor, head]; + } + /** + * Updates the CodeMirror selection to match the provided vim selection. + * If no arguments are given, it uses the current vim selection state. + */ + function updateCmSelection(cm, sel, mode) { + var vim = cm.state.vim; + sel = sel || vim.sel; + var mode = mode || + vim.visualLine ? 'line' : vim.visualBlock ? 'block' : 'char'; + var cmSel = makeCmSelection(cm, sel, mode); + cm.setSelections(cmSel.ranges, cmSel.primary); + updateFakeCursor(cm); + } + function makeCmSelection(cm, sel, mode, exclusive) { + var head = copyCursor(sel.head); + var anchor = copyCursor(sel.anchor); + if (mode == 'char') { + var headOffset = !exclusive && !cursorIsBefore(sel.head, sel.anchor) ? 1 : 0; + var anchorOffset = cursorIsBefore(sel.head, sel.anchor) ? 1 : 0; + head = offsetCursor(sel.head, 0, headOffset); + anchor = offsetCursor(sel.anchor, 0, anchorOffset); + return { + ranges: [{anchor: anchor, head: head}], + primary: 0 + }; + } else if (mode == 'line') { + if (!cursorIsBefore(sel.head, sel.anchor)) { + anchor.ch = 0; + + var lastLine = cm.lastLine(); + if (head.line > lastLine) { + head.line = lastLine; + } + head.ch = lineLength(cm, head.line); + } else { + head.ch = 0; + anchor.ch = lineLength(cm, anchor.line); + } + return { + ranges: [{anchor: anchor, head: head}], + primary: 0 + }; + } else if (mode == 'block') { + var top = Math.min(anchor.line, head.line), + left = Math.min(anchor.ch, head.ch), + bottom = Math.max(anchor.line, head.line), + right = Math.max(anchor.ch, head.ch) + 1; + var height = bottom - top + 1; + var primary = head.line == top ? 0 : height - 1; + var ranges = []; + for (var i = 0; i < height; i++) { + ranges.push({ + anchor: Pos(top + i, left), + head: Pos(top + i, right) + }); + } + return { + ranges: ranges, + primary: primary + }; + } + } + function getHead(cm) { + var cur = cm.getCursor('head'); + if (cm.getSelection().length == 1) { + // Small corner case when only 1 character is selected. The "real" + // head is the left of head and anchor. + cur = cursorMin(cur, cm.getCursor('anchor')); + } + return cur; + } + + /** + * If moveHead is set to false, the CodeMirror selection will not be + * touched. The caller assumes the responsibility of putting the cursor + * in the right place. + */ + function exitVisualMode(cm, moveHead) { + var vim = cm.state.vim; + if (moveHead !== false) { + cm.setCursor(clipCursorToContent(cm, vim.sel.head)); + } + updateLastSelection(cm, vim); + vim.visualMode = false; + vim.visualLine = false; + vim.visualBlock = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); + if (vim.fakeCursor) { + vim.fakeCursor.clear(); + } + } + + // Remove any trailing newlines from the selection. For + // example, with the caret at the start of the last word on the line, + // 'dw' should word, but not the newline, while 'w' should advance the + // caret to the first character of the next line. + function clipToLine(cm, curStart, curEnd) { + var selection = cm.getRange(curStart, curEnd); + // Only clip if the selection ends with trailing newline + whitespace + if (/\n\s*$/.test(selection)) { + var lines = selection.split('\n'); + // We know this is all whitepsace. + lines.pop(); + + // Cases: + // 1. Last word is an empty line - do not clip the trailing '\n' + // 2. Last word is not an empty line - clip the trailing '\n' + var line; + // Find the line containing the last word, and clip all whitespace up + // to it. + for (var line = lines.pop(); lines.length > 0 && line && isWhiteSpaceString(line); line = lines.pop()) { + curEnd.line--; + curEnd.ch = 0; + } + // If the last word is not an empty line, clip an additional newline + if (line) { + curEnd.line--; + curEnd.ch = lineLength(cm, curEnd.line); + } else { + curEnd.ch = 0; + } + } + } + + // Expand the selection to line ends. + function expandSelectionToLine(_cm, curStart, curEnd) { + curStart.ch = 0; + curEnd.ch = 0; + curEnd.line++; + } + + function findFirstNonWhiteSpaceCharacter(text) { + if (!text) { + return 0; + } + var firstNonWS = text.search(/\S/); + return firstNonWS == -1 ? text.length : firstNonWS; + } + + function expandWordUnderCursor(cm, inclusive, _forward, bigWord, noSymbol) { + var cur = getHead(cm); + var line = cm.getLine(cur.line); + var idx = cur.ch; + + // Seek to first word or non-whitespace character, depending on if + // noSymbol is true. + var test = noSymbol ? wordCharTest[0] : bigWordCharTest [0]; + while (!test(line.charAt(idx))) { + idx++; + if (idx >= line.length) { return null; } + } + + if (bigWord) { + test = bigWordCharTest[0]; + } else { + test = wordCharTest[0]; + if (!test(line.charAt(idx))) { + test = wordCharTest[1]; + } + } + + var end = idx, start = idx; + while (test(line.charAt(end)) && end < line.length) { end++; } + while (test(line.charAt(start)) && start >= 0) { start--; } + start++; + + if (inclusive) { + // If present, include all whitespace after word. + // Otherwise, include all whitespace before word, except indentation. + var wordEnd = end; + while (/\s/.test(line.charAt(end)) && end < line.length) { end++; } + if (wordEnd == end) { + var wordStart = start; + while (/\s/.test(line.charAt(start - 1)) && start > 0) { start--; } + if (!start) { start = wordStart; } + } + } + return { start: Pos(cur.line, start), end: Pos(cur.line, end) }; + } + + function recordJumpPosition(cm, oldCur, newCur) { + if (!cursorEqual(oldCur, newCur)) { + vimGlobalState.jumpList.add(cm, oldCur, newCur); + } + } + + function recordLastCharacterSearch(increment, args) { + vimGlobalState.lastChararacterSearch.increment = increment; + vimGlobalState.lastChararacterSearch.forward = args.forward; + vimGlobalState.lastChararacterSearch.selectedCharacter = args.selectedCharacter; + } + + var symbolToMode = { + '(': 'bracket', ')': 'bracket', '{': 'bracket', '}': 'bracket', + '[': 'section', ']': 'section', + '*': 'comment', '/': 'comment', + 'm': 'method', 'M': 'method', + '#': 'preprocess' + }; + var findSymbolModes = { + bracket: { + isComplete: function(state) { + if (state.nextCh === state.symb) { + state.depth++; + if (state.depth >= 1)return true; + } else if (state.nextCh === state.reverseSymb) { + state.depth--; + } + return false; + } + }, + section: { + init: function(state) { + state.curMoveThrough = true; + state.symb = (state.forward ? ']' : '[') === state.symb ? '{' : '}'; + }, + isComplete: function(state) { + return state.index === 0 && state.nextCh === state.symb; + } + }, + comment: { + isComplete: function(state) { + var found = state.lastCh === '*' && state.nextCh === '/'; + state.lastCh = state.nextCh; + return found; + } + }, + // TODO: The original Vim implementation only operates on level 1 and 2. + // The current implementation doesn't check for code block level and + // therefore it operates on any levels. + method: { + init: function(state) { + state.symb = (state.symb === 'm' ? '{' : '}'); + state.reverseSymb = state.symb === '{' ? '}' : '{'; + }, + isComplete: function(state) { + if (state.nextCh === state.symb)return true; + return false; + } + }, + preprocess: { + init: function(state) { + state.index = 0; + }, + isComplete: function(state) { + if (state.nextCh === '#') { + var token = state.lineText.match(/#(\w+)/)[1]; + if (token === 'endif') { + if (state.forward && state.depth === 0) { + return true; + } + state.depth++; + } else if (token === 'if') { + if (!state.forward && state.depth === 0) { + return true; + } + state.depth--; + } + if (token === 'else' && state.depth === 0)return true; + } + return false; + } + } + }; + function findSymbol(cm, repeat, forward, symb) { + var cur = copyCursor(cm.getCursor()); + var increment = forward ? 1 : -1; + var endLine = forward ? cm.lineCount() : -1; + var curCh = cur.ch; + var line = cur.line; + var lineText = cm.getLine(line); + var state = { + lineText: lineText, + nextCh: lineText.charAt(curCh), + lastCh: null, + index: curCh, + symb: symb, + reverseSymb: (forward ? { ')': '(', '}': '{' } : { '(': ')', '{': '}' })[symb], + forward: forward, + depth: 0, + curMoveThrough: false + }; + var mode = symbolToMode[symb]; + if (!mode)return cur; + var init = findSymbolModes[mode].init; + var isComplete = findSymbolModes[mode].isComplete; + if (init) { init(state); } + while (line !== endLine && repeat) { + state.index += increment; + state.nextCh = state.lineText.charAt(state.index); + if (!state.nextCh) { + line += increment; + state.lineText = cm.getLine(line) || ''; + if (increment > 0) { + state.index = 0; + } else { + var lineLen = state.lineText.length; + state.index = (lineLen > 0) ? (lineLen-1) : 0; + } + state.nextCh = state.lineText.charAt(state.index); + } + if (isComplete(state)) { + cur.line = line; + cur.ch = state.index; + repeat--; + } + } + if (state.nextCh || state.curMoveThrough) { + return Pos(line, state.index); + } + return cur; + } + + /** + * Returns the boundaries of the next word. If the cursor in the middle of + * the word, then returns the boundaries of the current word, starting at + * the cursor. If the cursor is at the start/end of a word, and we are going + * forward/backward, respectively, find the boundaries of the next word. + * + * @param {CodeMirror} cm CodeMirror object. + * @param {Cursor} cur The cursor position. + * @param {boolean} forward True to search forward. False to search + * backward. + * @param {boolean} bigWord True if punctuation count as part of the word. + * False if only [a-zA-Z0-9] characters count as part of the word. + * @param {boolean} emptyLineIsWord True if empty lines should be treated + * as words. + * @return {Object{from:number, to:number, line: number}} The boundaries of + * the word, or null if there are no more words. + */ + function findWord(cm, cur, forward, bigWord, emptyLineIsWord) { + var lineNum = cur.line; + var pos = cur.ch; + var line = cm.getLine(lineNum); + var dir = forward ? 1 : -1; + var charTests = bigWord ? bigWordCharTest: wordCharTest; + + if (emptyLineIsWord && line == '') { + lineNum += dir; + line = cm.getLine(lineNum); + if (!isLine(cm, lineNum)) { + return null; + } + pos = (forward) ? 0 : line.length; + } + + while (true) { + if (emptyLineIsWord && line == '') { + return { from: 0, to: 0, line: lineNum }; + } + var stop = (dir > 0) ? line.length : -1; + var wordStart = stop, wordEnd = stop; + // Find bounds of next word. + while (pos != stop) { + var foundWord = false; + for (var i = 0; i < charTests.length && !foundWord; ++i) { + if (charTests[i](line.charAt(pos))) { + wordStart = pos; + // Advance to end of word. + while (pos != stop && charTests[i](line.charAt(pos))) { + pos += dir; + } + wordEnd = pos; + foundWord = wordStart != wordEnd; + if (wordStart == cur.ch && lineNum == cur.line && + wordEnd == wordStart + dir) { + // We started at the end of a word. Find the next one. + continue; + } else { + return { + from: Math.min(wordStart, wordEnd + 1), + to: Math.max(wordStart, wordEnd), + line: lineNum }; + } + } + } + if (!foundWord) { + pos += dir; + } + } + // Advance to next/prev line. + lineNum += dir; + if (!isLine(cm, lineNum)) { + return null; + } + line = cm.getLine(lineNum); + pos = (dir > 0) ? 0 : line.length; + } + // Should never get here. + throw new Error('The impossible happened.'); + } + + /** + * @param {CodeMirror} cm CodeMirror object. + * @param {Pos} cur The position to start from. + * @param {int} repeat Number of words to move past. + * @param {boolean} forward True to search forward. False to search + * backward. + * @param {boolean} wordEnd True to move to end of word. False to move to + * beginning of word. + * @param {boolean} bigWord True if punctuation count as part of the word. + * False if only alphabet characters count as part of the word. + * @return {Cursor} The position the cursor should move to. + */ + function moveToWord(cm, cur, repeat, forward, wordEnd, bigWord) { + var curStart = copyCursor(cur); + var words = []; + if (forward && !wordEnd || !forward && wordEnd) { + repeat++; + } + // For 'e', empty lines are not considered words, go figure. + var emptyLineIsWord = !(forward && wordEnd); + for (var i = 0; i < repeat; i++) { + var word = findWord(cm, cur, forward, bigWord, emptyLineIsWord); + if (!word) { + var eodCh = lineLength(cm, cm.lastLine()); + words.push(forward + ? {line: cm.lastLine(), from: eodCh, to: eodCh} + : {line: 0, from: 0, to: 0}); + break; + } + words.push(word); + cur = Pos(word.line, forward ? (word.to - 1) : word.from); + } + var shortCircuit = words.length != repeat; + var firstWord = words[0]; + var lastWord = words.pop(); + if (forward && !wordEnd) { + // w + if (!shortCircuit && (firstWord.from != curStart.ch || firstWord.line != curStart.line)) { + // We did not start in the middle of a word. Discard the extra word at the end. + lastWord = words.pop(); + } + return Pos(lastWord.line, lastWord.from); + } else if (forward && wordEnd) { + return Pos(lastWord.line, lastWord.to - 1); + } else if (!forward && wordEnd) { + // ge + if (!shortCircuit && (firstWord.to != curStart.ch || firstWord.line != curStart.line)) { + // We did not start in the middle of a word. Discard the extra word at the end. + lastWord = words.pop(); + } + return Pos(lastWord.line, lastWord.to); + } else { + // b + return Pos(lastWord.line, lastWord.from); + } + } + + function moveToCharacter(cm, repeat, forward, character) { + var cur = cm.getCursor(); + var start = cur.ch; + var idx; + for (var i = 0; i < repeat; i ++) { + var line = cm.getLine(cur.line); + idx = charIdxInLine(start, line, character, forward, true); + if (idx == -1) { + return null; + } + start = idx; + } + return Pos(cm.getCursor().line, idx); + } + + function moveToColumn(cm, repeat) { + // repeat is always >= 1, so repeat - 1 always corresponds + // to the column we want to go to. + var line = cm.getCursor().line; + return clipCursorToContent(cm, Pos(line, repeat - 1)); + } + + function updateMark(cm, vim, markName, pos) { + if (!inArray(markName, validMarks)) { + return; + } + if (vim.marks[markName]) { + vim.marks[markName].clear(); + } + vim.marks[markName] = cm.setBookmark(pos); + } + + function charIdxInLine(start, line, character, forward, includeChar) { + // Search for char in line. + // motion_options: {forward, includeChar} + // If includeChar = true, include it too. + // If forward = true, search forward, else search backwards. + // If char is not found on this line, do nothing + var idx; + if (forward) { + idx = line.indexOf(character, start + 1); + if (idx != -1 && !includeChar) { + idx -= 1; + } + } else { + idx = line.lastIndexOf(character, start - 1); + if (idx != -1 && !includeChar) { + idx += 1; + } + } + return idx; + } + + function findParagraph(cm, head, repeat, dir, inclusive) { + var line = head.line; + var min = cm.firstLine(); + var max = cm.lastLine(); + var start, end, i = line; + function isEmpty(i) { return !/\S/.test(cm.getLine(i)); } // ace_patch + function isBoundary(i, dir, any) { + if (any) { return isEmpty(i) != isEmpty(i + dir); } + return !isEmpty(i) && isEmpty(i + dir); + } + function skipFold(i) { + dir = dir > 0 ? 1 : -1; + var foldLine = cm.ace.session.getFoldLine(i); + if (foldLine) { + if (i + dir > foldLine.start.row && i + dir < foldLine.end.row) + dir = (dir > 0 ? foldLine.end.row : foldLine.start.row) - i; + } + } + if (dir) { + while (min <= i && i <= max && repeat > 0) { + skipFold(i); + if (isBoundary(i, dir)) { repeat--; } + i += dir; + } + return new Pos(i, 0); + } + + var vim = cm.state.vim; + if (vim.visualLine && isBoundary(line, 1, true)) { + var anchor = vim.sel.anchor; + if (isBoundary(anchor.line, -1, true)) { + if (!inclusive || anchor.line != line) { + line += 1; + } + } + } + var startState = isEmpty(line); + for (i = line; i <= max && repeat; i++) { + if (isBoundary(i, 1, true)) { + if (!inclusive || isEmpty(i) != startState) { + repeat--; + } + } + } + end = new Pos(i, 0); + // select boundary before paragraph for the last one + if (i > max && !startState) { startState = true; } + else { inclusive = false; } + for (i = line; i > min; i--) { + if (!inclusive || isEmpty(i) == startState || i == line) { + if (isBoundary(i, -1, true)) { break; } + } + } + start = new Pos(i, 0); + return { start: start, end: end }; + } + + // TODO: perhaps this finagling of start and end positions belonds + // in codmirror/replaceRange? + function selectCompanionObject(cm, head, symb, inclusive) { + var cur = head, start, end; + + var bracketRegexp = ({ + '(': /[()]/, ')': /[()]/, + '[': /[[\]]/, ']': /[[\]]/, + '{': /[{}]/, '}': /[{}]/})[symb]; + var openSym = ({ + '(': '(', ')': '(', + '[': '[', ']': '[', + '{': '{', '}': '{'})[symb]; + var curChar = cm.getLine(cur.line).charAt(cur.ch); + // Due to the behavior of scanForBracket, we need to add an offset if the + // cursor is on a matching open bracket. + var offset = curChar === openSym ? 1 : 0; + + start = cm.scanForBracket(Pos(cur.line, cur.ch + offset), -1, null, {'bracketRegex': bracketRegexp}); + end = cm.scanForBracket(Pos(cur.line, cur.ch + offset), 1, null, {'bracketRegex': bracketRegexp}); + + if (!start || !end) { + return { start: cur, end: cur }; + } + + start = start.pos; + end = end.pos; + + if ((start.line == end.line && start.ch > end.ch) + || (start.line > end.line)) { + var tmp = start; + start = end; + end = tmp; + } + + if (inclusive) { + end.ch += 1; + } else { + start.ch += 1; + } + + return { start: start, end: end }; + } + + // Takes in a symbol and a cursor and tries to simulate text objects that + // have identical opening and closing symbols + // TODO support across multiple lines + function findBeginningAndEnd(cm, head, symb, inclusive) { + var cur = copyCursor(head); + var line = cm.getLine(cur.line); + var chars = line.split(''); + var start, end, i, len; + var firstIndex = chars.indexOf(symb); + + // the decision tree is to always look backwards for the beginning first, + // but if the cursor is in front of the first instance of the symb, + // then move the cursor forward + if (cur.ch < firstIndex) { + cur.ch = firstIndex; + // Why is this line even here??? + // cm.setCursor(cur.line, firstIndex+1); + } + // otherwise if the cursor is currently on the closing symbol + else if (firstIndex < cur.ch && chars[cur.ch] == symb) { + end = cur.ch; // assign end to the current cursor + --cur.ch; // make sure to look backwards + } + + // if we're currently on the symbol, we've got a start + if (chars[cur.ch] == symb && !end) { + start = cur.ch + 1; // assign start to ahead of the cursor + } else { + // go backwards to find the start + for (i = cur.ch; i > -1 && !start; i--) { + if (chars[i] == symb) { + start = i + 1; + } + } + } + + // look forwards for the end symbol + if (start && !end) { + for (i = start, len = chars.length; i < len && !end; i++) { + if (chars[i] == symb) { + end = i; + } + } + } + + // nothing found + if (!start || !end) { + return { start: cur, end: cur }; + } + + // include the symbols + if (inclusive) { + --start; ++end; + } + + return { + start: Pos(cur.line, start), + end: Pos(cur.line, end) + }; + } + + // Search functions + defineOption('pcre', true, 'boolean'); + function SearchState() {} + SearchState.prototype = { + getQuery: function() { + return vimGlobalState.query; + }, + setQuery: function(query) { + vimGlobalState.query = query; + }, + getOverlay: function() { + return this.searchOverlay; + }, + setOverlay: function(overlay) { + this.searchOverlay = overlay; + }, + isReversed: function() { + return vimGlobalState.isReversed; + }, + setReversed: function(reversed) { + vimGlobalState.isReversed = reversed; + }, + getScrollbarAnnotate: function() { + return this.annotate; + }, + setScrollbarAnnotate: function(annotate) { + this.annotate = annotate; + } + }; + function getSearchState(cm) { + var vim = cm.state.vim; + return vim.searchState_ || (vim.searchState_ = new SearchState()); + } + function dialog(cm, template, shortText, onClose, options) { + if (cm.openDialog) { + cm.openDialog(template, onClose, { bottom: true, value: options.value, + onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp, + selectValueOnOpen: false}); + } + else { + onClose(prompt(shortText, '')); + } + } + function splitBySlash(argString) { + var slashes = findUnescapedSlashes(argString) || []; + if (!slashes.length) return []; + var tokens = []; + // in case of strings like foo/bar + if (slashes[0] !== 0) return; + for (var i = 0; i < slashes.length; i++) { + if (typeof slashes[i] == 'number') + tokens.push(argString.substring(slashes[i] + 1, slashes[i+1])); + } + return tokens; + } + + function findUnescapedSlashes(str) { + var escapeNextChar = false; + var slashes = []; + for (var i = 0; i < str.length; i++) { + var c = str.charAt(i); + if (!escapeNextChar && c == '/') { + slashes.push(i); + } + escapeNextChar = !escapeNextChar && (c == '\\'); + } + return slashes; + } + + // Translates a search string from ex (vim) syntax into javascript form. + function translateRegex(str) { + // When these match, add a '\' if unescaped or remove one if escaped. + var specials = '|(){'; + // Remove, but never add, a '\' for these. + var unescape = '}'; + var escapeNextChar = false; + var out = []; + for (var i = -1; i < str.length; i++) { + var c = str.charAt(i) || ''; + var n = str.charAt(i+1) || ''; + var specialComesNext = (n && specials.indexOf(n) != -1); + if (escapeNextChar) { + if (c !== '\\' || !specialComesNext) { + out.push(c); + } + escapeNextChar = false; + } else { + if (c === '\\') { + escapeNextChar = true; + // Treat the unescape list as special for removing, but not adding '\'. + if (n && unescape.indexOf(n) != -1) { + specialComesNext = true; + } + // Not passing this test means removing a '\'. + if (!specialComesNext || n === '\\') { + out.push(c); + } + } else { + out.push(c); + if (specialComesNext && n !== '\\') { + out.push('\\'); + } + } + } + } + return out.join(''); + } + + // Translates the replace part of a search and replace from ex (vim) syntax into + // javascript form. Similar to translateRegex, but additionally fixes back references + // (translates '\[0..9]' to '$[0..9]') and follows different rules for escaping '$'. + var charUnescapes = {'\\n': '\n', '\\r': '\r', '\\t': '\t'}; + function translateRegexReplace(str) { + var escapeNextChar = false; + var out = []; + for (var i = -1; i < str.length; i++) { + var c = str.charAt(i) || ''; + var n = str.charAt(i+1) || ''; + if (charUnescapes[c + n]) { + out.push(charUnescapes[c+n]); + i++; + } else if (escapeNextChar) { + // At any point in the loop, escapeNextChar is true if the previous + // character was a '\' and was not escaped. + out.push(c); + escapeNextChar = false; + } else { + if (c === '\\') { + escapeNextChar = true; + if ((isNumber(n) || n === '$')) { + out.push('$'); + } else if (n !== '/' && n !== '\\') { + out.push('\\'); + } + } else { + if (c === '$') { + out.push('$'); + } + out.push(c); + if (n === '/') { + out.push('\\'); + } + } + } + } + return out.join(''); + } + + // Unescape \ and / in the replace part, for PCRE mode. + var unescapes = {'\\/': '/', '\\\\': '\\', '\\n': '\n', '\\r': '\r', '\\t': '\t'}; + function unescapeRegexReplace(str) { + var stream = new CodeMirror.StringStream(str); + var output = []; + while (!stream.eol()) { + // Search for \. + while (stream.peek() && stream.peek() != '\\') { + output.push(stream.next()); + } + var matched = false; + for (var matcher in unescapes) { + if (stream.match(matcher, true)) { + matched = true; + output.push(unescapes[matcher]); + break; + } + } + if (!matched) { + // Don't change anything + output.push(stream.next()); + } + } + return output.join(''); + } + + /** + * Extract the regular expression from the query and return a Regexp object. + * Returns null if the query is blank. + * If ignoreCase is passed in, the Regexp object will have the 'i' flag set. + * If smartCase is passed in, and the query contains upper case letters, + * then ignoreCase is overridden, and the 'i' flag will not be set. + * If the query contains the /i in the flag part of the regular expression, + * then both ignoreCase and smartCase are ignored, and 'i' will be passed + * through to the Regex object. + */ + function parseQuery(query, ignoreCase, smartCase) { + // First update the last search register + var lastSearchRegister = vimGlobalState.registerController.getRegister('/'); + lastSearchRegister.setText(query); + // Check if the query is already a regex. + if (query instanceof RegExp) { return query; } + // First try to extract regex + flags from the input. If no flags found, + // extract just the regex. IE does not accept flags directly defined in + // the regex string in the form /regex/flags + var slashes = findUnescapedSlashes(query); + var regexPart; + var forceIgnoreCase; + if (!slashes.length) { + // Query looks like 'regexp' + regexPart = query; + } else { + // Query looks like 'regexp/...' + regexPart = query.substring(0, slashes[0]); + var flagsPart = query.substring(slashes[0]); + forceIgnoreCase = (flagsPart.indexOf('i') != -1); + } + if (!regexPart) { + return null; + } + if (!getOption('pcre')) { + regexPart = translateRegex(regexPart); + } + if (smartCase) { + ignoreCase = (/^[^A-Z]*$/).test(regexPart); + } + var regexp = new RegExp(regexPart, + (ignoreCase || forceIgnoreCase) ? 'i' : undefined); + return regexp; + } + function showConfirm(cm, text) { + if (cm.openNotification) { + cm.openNotification('' + text + '', + {bottom: true, duration: 5000}); + } else { + alert(text); + } + } + function makePrompt(prefix, desc) { + var raw = ''; + if (prefix) { + raw += '' + prefix + ''; + } + raw += ' ' + + ''; + if (desc) { + raw += ''; + raw += desc; + raw += ''; + } + return raw; + } + var searchPromptDesc = '(Javascript regexp)'; + function showPrompt(cm, options) { + var shortText = (options.prefix || '') + ' ' + (options.desc || ''); + var prompt = makePrompt(options.prefix, options.desc); + dialog(cm, prompt, shortText, options.onClose, options); + } + function regexEqual(r1, r2) { + if (r1 instanceof RegExp && r2 instanceof RegExp) { + var props = ['global', 'multiline', 'ignoreCase', 'source']; + for (var i = 0; i < props.length; i++) { + var prop = props[i]; + if (r1[prop] !== r2[prop]) { + return false; + } + } + return true; + } + return false; + } + // Returns true if the query is valid. + function updateSearchQuery(cm, rawQuery, ignoreCase, smartCase) { + if (!rawQuery) { + return; + } + var state = getSearchState(cm); + var query = parseQuery(rawQuery, !!ignoreCase, !!smartCase); + if (!query) { + return; + } + highlightSearchMatches(cm, query); + if (regexEqual(query, state.getQuery())) { + return query; + } + state.setQuery(query); + return query; + } + function searchOverlay(query) { + if (query.source.charAt(0) == '^') { + var matchSol = true; + } + return { + token: function(stream) { + if (matchSol && !stream.sol()) { + stream.skipToEnd(); + return; + } + var match = stream.match(query, false); + if (match) { + if (match[0].length == 0) { + // Matched empty string, skip to next. + stream.next(); + return 'searching'; + } + if (!stream.sol()) { + // Backtrack 1 to match \b + stream.backUp(1); + if (!query.exec(stream.next() + match[0])) { + stream.next(); + return null; + } + } + stream.match(query); + return 'searching'; + } + while (!stream.eol()) { + stream.next(); + if (stream.match(query, false)) break; + } + }, + query: query + }; + } + function highlightSearchMatches(cm, query) { + var searchState = getSearchState(cm); + var overlay = searchState.getOverlay(); + if (!overlay || query != overlay.query) { + if (overlay) { + cm.removeOverlay(overlay); + } + overlay = searchOverlay(query); + cm.addOverlay(overlay); + if (cm.showMatchesOnScrollbar) { + if (searchState.getScrollbarAnnotate()) { + searchState.getScrollbarAnnotate().clear(); + } + searchState.setScrollbarAnnotate(cm.showMatchesOnScrollbar(query)); + } + searchState.setOverlay(overlay); + } + } + function findNext(cm, prev, query, repeat) { + if (repeat === undefined) { repeat = 1; } + return cm.operation(function() { + var pos = cm.getCursor(); + var cursor = cm.getSearchCursor(query, pos); + for (var i = 0; i < repeat; i++) { + var found = cursor.find(prev); + if (i == 0 && found && cursorEqual(cursor.from(), pos)) { found = cursor.find(prev); } + if (!found) { + // SearchCursor may have returned null because it hit EOF, wrap + // around and try again. + cursor = cm.getSearchCursor(query, + (prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) ); + if (!cursor.find(prev)) { + return; + } + } + } + return cursor.from(); + }); + } + function clearSearchHighlight(cm) { + var state = getSearchState(cm); + cm.removeOverlay(getSearchState(cm).getOverlay()); + state.setOverlay(null); + if (state.getScrollbarAnnotate()) { + state.getScrollbarAnnotate().clear(); + state.setScrollbarAnnotate(null); + } + } + /** + * Check if pos is in the specified range, INCLUSIVE. + * Range can be specified with 1 or 2 arguments. + * If the first range argument is an array, treat it as an array of line + * numbers. Match pos against any of the lines. + * If the first range argument is a number, + * if there is only 1 range argument, check if pos has the same line + * number + * if there are 2 range arguments, then check if pos is in between the two + * range arguments. + */ + function isInRange(pos, start, end) { + if (typeof pos != 'number') { + // Assume it is a cursor position. Get the line number. + pos = pos.line; + } + if (start instanceof Array) { + return inArray(pos, start); + } else { + if (end) { + return (pos >= start && pos <= end); + } else { + return pos == start; + } + } + } + function getUserVisibleLines(cm) { + // ace_patch{ + var renderer = cm.ace.renderer; + return { + top: renderer.getFirstFullyVisibleRow(), + bottom: renderer.getLastFullyVisibleRow() + } + // ace_patch} + } + + var ExCommandDispatcher = function() { + this.buildCommandMap_(); + }; + ExCommandDispatcher.prototype = { + processCommand: function(cm, input, opt_params) { + var that = this; + cm.operation(function () { + cm.curOp.isVimOp = true; + that._processCommand(cm, input, opt_params); + }); + }, + _processCommand: function(cm, input, opt_params) { + var vim = cm.state.vim; + var commandHistoryRegister = vimGlobalState.registerController.getRegister(':'); + var previousCommand = commandHistoryRegister.toString(); + if (vim.visualMode) { + exitVisualMode(cm); + } + var inputStream = new CodeMirror.StringStream(input); + // update ": with the latest command whether valid or invalid + commandHistoryRegister.setText(input); + var params = opt_params || {}; + params.input = input; + try { + this.parseInput_(cm, inputStream, params); + } catch(e) { + showConfirm(cm, e); + throw e; + } + var command; + var commandName; + if (!params.commandName) { + // If only a line range is defined, move to the line. + if (params.line !== undefined) { + commandName = 'move'; + } + } else { + command = this.matchCommand_(params.commandName); + if (command) { + commandName = command.name; + if (command.excludeFromCommandHistory) { + commandHistoryRegister.setText(previousCommand); + } + this.parseCommandArgs_(inputStream, params, command); + if (command.type == 'exToKey') { + // Handle Ex to Key mapping. + for (var i = 0; i < command.toKeys.length; i++) { + CodeMirror.Vim.handleKey(cm, command.toKeys[i], 'mapping'); + } + return; + } else if (command.type == 'exToEx') { + // Handle Ex to Ex mapping. + this.processCommand(cm, command.toInput); + return; + } + } + } + if (!commandName) { + showConfirm(cm, 'Not an editor command ":' + input + '"'); + return; + } + try { + exCommands[commandName](cm, params); + // Possibly asynchronous commands (e.g. substitute, which might have a + // user confirmation), are responsible for calling the callback when + // done. All others have it taken care of for them here. + if ((!command || !command.possiblyAsync) && params.callback) { + params.callback(); + } + } catch(e) { + showConfirm(cm, e); + throw e; + } + }, + parseInput_: function(cm, inputStream, result) { + inputStream.eatWhile(':'); + // Parse range. + if (inputStream.eat('%')) { + result.line = cm.firstLine(); + result.lineEnd = cm.lastLine(); + } else { + result.line = this.parseLineSpec_(cm, inputStream); + if (result.line !== undefined && inputStream.eat(',')) { + result.lineEnd = this.parseLineSpec_(cm, inputStream); + } + } + + // Parse command name. + var commandMatch = inputStream.match(/^(\w+)/); + if (commandMatch) { + result.commandName = commandMatch[1]; + } else { + result.commandName = inputStream.match(/.*/)[0]; + } + + return result; + }, + parseLineSpec_: function(cm, inputStream) { + var numberMatch = inputStream.match(/^(\d+)/); + if (numberMatch) { + return parseInt(numberMatch[1], 10) - 1; + } + switch (inputStream.next()) { + case '.': + return cm.getCursor().line; + case '$': + return cm.lastLine(); + case '\'': + var mark = cm.state.vim.marks[inputStream.next()]; + if (mark && mark.find()) { + return mark.find().line; + } + throw new Error('Mark not set'); + default: + inputStream.backUp(1); + return undefined; + } + }, + parseCommandArgs_: function(inputStream, params, command) { + if (inputStream.eol()) { + return; + } + params.argString = inputStream.match(/.*/)[0]; + // Parse command-line arguments + var delim = command.argDelimiter || /\s+/; + var args = trim(params.argString).split(delim); + if (args.length && args[0]) { + params.args = args; + } + }, + matchCommand_: function(commandName) { + // Return the command in the command map that matches the shortest + // prefix of the passed in command name. The match is guaranteed to be + // unambiguous if the defaultExCommandMap's shortNames are set up + // correctly. (see @code{defaultExCommandMap}). + for (var i = commandName.length; i > 0; i--) { + var prefix = commandName.substring(0, i); + if (this.commandMap_[prefix]) { + var command = this.commandMap_[prefix]; + if (command.name.indexOf(commandName) === 0) { + return command; + } + } + } + return null; + }, + buildCommandMap_: function() { + this.commandMap_ = {}; + for (var i = 0; i < defaultExCommandMap.length; i++) { + var command = defaultExCommandMap[i]; + var key = command.shortName || command.name; + this.commandMap_[key] = command; + } + }, + map: function(lhs, rhs, ctx) { + if (lhs != ':' && lhs.charAt(0) == ':') { + if (ctx) { throw Error('Mode not supported for ex mappings'); } + var commandName = lhs.substring(1); + if (rhs != ':' && rhs.charAt(0) == ':') { + // Ex to Ex mapping + this.commandMap_[commandName] = { + name: commandName, + type: 'exToEx', + toInput: rhs.substring(1), + user: true + }; + } else { + // Ex to key mapping + this.commandMap_[commandName] = { + name: commandName, + type: 'exToKey', + toKeys: rhs, + user: true + }; + } + } else { + if (rhs != ':' && rhs.charAt(0) == ':') { + // Key to Ex mapping. + var mapping = { + keys: lhs, + type: 'keyToEx', + exArgs: { input: rhs.substring(1) }, + user: true}; + if (ctx) { mapping.context = ctx; } + defaultKeymap.unshift(mapping); + } else { + // Key to key mapping + var mapping = { + keys: lhs, + type: 'keyToKey', + toKeys: rhs, + user: true + }; + if (ctx) { mapping.context = ctx; } + defaultKeymap.unshift(mapping); + } + } + }, + unmap: function(lhs, ctx) { + if (lhs != ':' && lhs.charAt(0) == ':') { + // Ex to Ex or Ex to key mapping + if (ctx) { throw Error('Mode not supported for ex mappings'); } + var commandName = lhs.substring(1); + if (this.commandMap_[commandName] && this.commandMap_[commandName].user) { + delete this.commandMap_[commandName]; + return; + } + } else { + // Key to Ex or key to key mapping + var keys = lhs; + for (var i = 0; i < defaultKeymap.length; i++) { + if (keys == defaultKeymap[i].keys + && defaultKeymap[i].context === ctx + && defaultKeymap[i].user) { + defaultKeymap.splice(i, 1); + return; + } + } + } + // throw Error('No such mapping.'); + } + }; + + var exCommands = { + colorscheme: function(cm, params) { + if (!params.args || params.args.length < 1) { + showConfirm(cm, cm.getOption('theme')); + return; + } + cm.setOption('theme', params.args[0]); + }, + map: function(cm, params, ctx) { + var mapArgs = params.args; + if (!mapArgs || mapArgs.length < 2) { + if (cm) { + showConfirm(cm, 'Invalid mapping: ' + params.input); + } + return; + } + exCommandDispatcher.map(mapArgs[0], mapArgs[1], ctx); + }, + imap: function(cm, params) { this.map(cm, params, 'insert'); }, + nmap: function(cm, params) { this.map(cm, params, 'normal'); }, + vmap: function(cm, params) { this.map(cm, params, 'visual'); }, + unmap: function(cm, params, ctx) { + var mapArgs = params.args; + if (!mapArgs || mapArgs.length < 1) { + if (cm) { + showConfirm(cm, 'No such mapping: ' + params.input); + } + return; + } + exCommandDispatcher.unmap(mapArgs[0], ctx); + }, + move: function(cm, params) { + commandDispatcher.processCommand(cm, cm.state.vim, { + type: 'motion', + motion: 'moveToLineOrEdgeOfDocument', + motionArgs: { forward: false, explicitRepeat: true, + linewise: true }, + repeatOverride: params.line+1}); + }, + set: function(cm, params) { + var setArgs = params.args; + // Options passed through to the setOption/getOption calls. May be passed in by the + // local/global versions of the set command + var setCfg = params.setCfg || {}; + if (!setArgs || setArgs.length < 1) { + if (cm) { + showConfirm(cm, 'Invalid mapping: ' + params.input); + } + return; + } + var expr = setArgs[0].split('='); + var optionName = expr[0]; + var value = expr[1]; + var forceGet = false; + + if (optionName.charAt(optionName.length - 1) == '?') { + // If post-fixed with ?, then the set is actually a get. + if (value) { throw Error('Trailing characters: ' + params.argString); } + optionName = optionName.substring(0, optionName.length - 1); + forceGet = true; + } + if (value === undefined && optionName.substring(0, 2) == 'no') { + // To set boolean options to false, the option name is prefixed with + // 'no'. + optionName = optionName.substring(2); + value = false; + } + + var optionIsBoolean = options[optionName] && options[optionName].type == 'boolean'; + if (optionIsBoolean && value == undefined) { + // Calling set with a boolean option sets it to true. + value = true; + } + // If no value is provided, then we assume this is a get. + if (!optionIsBoolean && value === undefined || forceGet) { + var oldValue = getOption(optionName, cm, setCfg); + if (oldValue === true || oldValue === false) { + showConfirm(cm, ' ' + (oldValue ? '' : 'no') + optionName); + } else { + showConfirm(cm, ' ' + optionName + '=' + oldValue); + } + } else { + setOption(optionName, value, cm, setCfg); + } + }, + setlocal: function (cm, params) { + // setCfg is passed through to setOption + params.setCfg = {scope: 'local'}; + this.set(cm, params); + }, + setglobal: function (cm, params) { + // setCfg is passed through to setOption + params.setCfg = {scope: 'global'}; + this.set(cm, params); + }, + registers: function(cm, params) { + var regArgs = params.args; + var registers = vimGlobalState.registerController.registers; + var regInfo = '----------Registers----------

'; + if (!regArgs) { + for (var registerName in registers) { + var text = registers[registerName].toString(); + if (text.length) { + regInfo += '"' + registerName + ' ' + text + '
'; + } + } + } else { + var registerName; + regArgs = regArgs.join(''); + for (var i = 0; i < regArgs.length; i++) { + registerName = regArgs.charAt(i); + if (!vimGlobalState.registerController.isValidRegister(registerName)) { + continue; + } + var register = registers[registerName] || new Register(); + regInfo += '"' + registerName + ' ' + register.toString() + '
'; + } + } + showConfirm(cm, regInfo); + }, + sort: function(cm, params) { + var reverse, ignoreCase, unique, number; + function parseArgs() { + if (params.argString) { + var args = new CodeMirror.StringStream(params.argString); + if (args.eat('!')) { reverse = true; } + if (args.eol()) { return; } + if (!args.eatSpace()) { return 'Invalid arguments'; } + var opts = args.match(/[a-z]+/); + if (opts) { + opts = opts[0]; + ignoreCase = opts.indexOf('i') != -1; + unique = opts.indexOf('u') != -1; + var decimal = opts.indexOf('d') != -1 && 1; + var hex = opts.indexOf('x') != -1 && 1; + var octal = opts.indexOf('o') != -1 && 1; + if (decimal + hex + octal > 1) { return 'Invalid arguments'; } + number = decimal && 'decimal' || hex && 'hex' || octal && 'octal'; + } + if (args.match(/\/.*\//)) { return 'patterns not supported'; } + } + } + var err = parseArgs(); + if (err) { + showConfirm(cm, err + ': ' + params.argString); + return; + } + var lineStart = params.line || cm.firstLine(); + var lineEnd = params.lineEnd || params.line || cm.lastLine(); + if (lineStart == lineEnd) { return; } + var curStart = Pos(lineStart, 0); + var curEnd = Pos(lineEnd, lineLength(cm, lineEnd)); + var text = cm.getRange(curStart, curEnd).split('\n'); + var numberRegex = (number == 'decimal') ? /(-?)([\d]+)/ : + (number == 'hex') ? /(-?)(?:0x)?([0-9a-f]+)/i : + (number == 'octal') ? /([0-7]+)/ : null; + var radix = (number == 'decimal') ? 10 : (number == 'hex') ? 16 : (number == 'octal') ? 8 : null; + var numPart = [], textPart = []; + if (number) { + for (var i = 0; i < text.length; i++) { + if (numberRegex.exec(text[i])) { + numPart.push(text[i]); + } else { + textPart.push(text[i]); + } + } + } else { + textPart = text; + } + function compareFn(a, b) { + if (reverse) { var tmp; tmp = a; a = b; b = tmp; } + if (ignoreCase) { a = a.toLowerCase(); b = b.toLowerCase(); } + var anum = number && numberRegex.exec(a); + var bnum = number && numberRegex.exec(b); + if (!anum) { return a < b ? -1 : 1; } + anum = parseInt((anum[1] + anum[2]).toLowerCase(), radix); + bnum = parseInt((bnum[1] + bnum[2]).toLowerCase(), radix); + return anum - bnum; + } + numPart.sort(compareFn); + textPart.sort(compareFn); + text = (!reverse) ? textPart.concat(numPart) : numPart.concat(textPart); + if (unique) { // Remove duplicate lines + var textOld = text; + var lastLine; + text = []; + for (var i = 0; i < textOld.length; i++) { + if (textOld[i] != lastLine) { + text.push(textOld[i]); + } + lastLine = textOld[i]; + } + } + cm.replaceRange(text.join('\n'), curStart, curEnd); + }, + global: function(cm, params) { + // a global command is of the form + // :[range]g/pattern/[cmd] + // argString holds the string /pattern/[cmd] + var argString = params.argString; + if (!argString) { + showConfirm(cm, 'Regular Expression missing from global'); + return; + } + // range is specified here + var lineStart = (params.line !== undefined) ? params.line : cm.firstLine(); + var lineEnd = params.lineEnd || params.line || cm.lastLine(); + // get the tokens from argString + var tokens = splitBySlash(argString); + var regexPart = argString, cmd; + if (tokens.length) { + regexPart = tokens[0]; + cmd = tokens.slice(1, tokens.length).join('/'); + } + if (regexPart) { + // If regex part is empty, then use the previous query. Otherwise + // use the regex part as the new query. + try { + updateSearchQuery(cm, regexPart, true /** ignoreCase */, + true /** smartCase */); + } catch (e) { + showConfirm(cm, 'Invalid regex: ' + regexPart); + return; + } + } + // now that we have the regexPart, search for regex matches in the + // specified range of lines + var query = getSearchState(cm).getQuery(); + var matchedLines = [], content = ''; + for (var i = lineStart; i <= lineEnd; i++) { + var matched = query.test(cm.getLine(i)); + if (matched) { + matchedLines.push(i+1); + content+= cm.getLine(i) + '
'; + } + } + // if there is no [cmd], just display the list of matched lines + if (!cmd) { + showConfirm(cm, content); + return; + } + var index = 0; + var nextCommand = function() { + if (index < matchedLines.length) { + var command = matchedLines[index] + cmd; + exCommandDispatcher.processCommand(cm, command, { + callback: nextCommand + }); + } + index++; + }; + nextCommand(); + }, + substitute: function(cm, params) { + if (!cm.getSearchCursor) { + throw new Error('Search feature not available. Requires searchcursor.js or ' + + 'any other getSearchCursor implementation.'); + } + var argString = params.argString; + var tokens = argString ? splitBySlash(argString) : []; + var regexPart, replacePart = '', trailing, flagsPart, count; + var confirm = false; // Whether to confirm each replace. + var global = false; // True to replace all instances on a line, false to replace only 1. + if (tokens.length) { + regexPart = tokens[0]; + replacePart = tokens[1]; + if (replacePart !== undefined) { + if (getOption('pcre')) { + replacePart = unescapeRegexReplace(replacePart); + } else { + replacePart = translateRegexReplace(replacePart); + } + vimGlobalState.lastSubstituteReplacePart = replacePart; + } + trailing = tokens[2] ? tokens[2].split(' ') : []; + } else { + // either the argString is empty or its of the form ' hello/world' + // actually splitBySlash returns a list of tokens + // only if the string starts with a '/' + if (argString && argString.length) { + showConfirm(cm, 'Substitutions should be of the form ' + + ':s/pattern/replace/'); + return; + } + } + // After the 3rd slash, we can have flags followed by a space followed + // by count. + if (trailing) { + flagsPart = trailing[0]; + count = parseInt(trailing[1]); + if (flagsPart) { + if (flagsPart.indexOf('c') != -1) { + confirm = true; + flagsPart.replace('c', ''); + } + if (flagsPart.indexOf('g') != -1) { + global = true; + flagsPart.replace('g', ''); + } + regexPart = regexPart + '/' + flagsPart; + } + } + if (regexPart) { + // If regex part is empty, then use the previous query. Otherwise use + // the regex part as the new query. + try { + updateSearchQuery(cm, regexPart, true /** ignoreCase */, + true /** smartCase */); + } catch (e) { + showConfirm(cm, 'Invalid regex: ' + regexPart); + return; + } + } + replacePart = replacePart || vimGlobalState.lastSubstituteReplacePart; + if (replacePart === undefined) { + showConfirm(cm, 'No previous substitute regular expression'); + return; + } + var state = getSearchState(cm); + var query = state.getQuery(); + var lineStart = (params.line !== undefined) ? params.line : cm.getCursor().line; + var lineEnd = params.lineEnd || lineStart; + if (lineStart == cm.firstLine() && lineEnd == cm.lastLine()) { + lineEnd = Infinity; + } + if (count) { + lineStart = lineEnd; + lineEnd = lineStart + count - 1; + } + var startPos = clipCursorToContent(cm, Pos(lineStart, 0)); + var cursor = cm.getSearchCursor(query, startPos); + doReplace(cm, confirm, global, lineStart, lineEnd, cursor, query, replacePart, params.callback); + }, + redo: CodeMirror.commands.redo, + undo: CodeMirror.commands.undo, + write: function(cm) { + if (CodeMirror.commands.save) { + // If a save command is defined, call it. + CodeMirror.commands.save(cm); + } else { + // Saves to text area if no save command is defined. + cm.save(); + } + }, + nohlsearch: function(cm) { + clearSearchHighlight(cm); + }, + delmarks: function(cm, params) { + if (!params.argString || !trim(params.argString)) { + showConfirm(cm, 'Argument required'); + return; + } + + var state = cm.state.vim; + var stream = new CodeMirror.StringStream(trim(params.argString)); + while (!stream.eol()) { + stream.eatSpace(); + + // Record the streams position at the beginning of the loop for use + // in error messages. + var count = stream.pos; + + if (!stream.match(/[a-zA-Z]/, false)) { + showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count)); + return; + } + + var sym = stream.next(); + // Check if this symbol is part of a range + if (stream.match('-', true)) { + // This symbol is part of a range. + + // The range must terminate at an alphabetic character. + if (!stream.match(/[a-zA-Z]/, false)) { + showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count)); + return; + } + + var startMark = sym; + var finishMark = stream.next(); + // The range must terminate at an alphabetic character which + // shares the same case as the start of the range. + if (isLowerCase(startMark) && isLowerCase(finishMark) || + isUpperCase(startMark) && isUpperCase(finishMark)) { + var start = startMark.charCodeAt(0); + var finish = finishMark.charCodeAt(0); + if (start >= finish) { + showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count)); + return; + } + + // Because marks are always ASCII values, and we have + // determined that they are the same case, we can use + // their char codes to iterate through the defined range. + for (var j = 0; j <= finish - start; j++) { + var mark = String.fromCharCode(start + j); + delete state.marks[mark]; + } + } else { + showConfirm(cm, 'Invalid argument: ' + startMark + '-'); + return; + } + } else { + // This symbol is a valid mark, and is not part of a range. + delete state.marks[sym]; + } + } + } + }; + + var exCommandDispatcher = new ExCommandDispatcher(); + + /** + * @param {CodeMirror} cm CodeMirror instance we are in. + * @param {boolean} confirm Whether to confirm each replace. + * @param {Cursor} lineStart Line to start replacing from. + * @param {Cursor} lineEnd Line to stop replacing at. + * @param {RegExp} query Query for performing matches with. + * @param {string} replaceWith Text to replace matches with. May contain $1, + * $2, etc for replacing captured groups using Javascript replace. + * @param {function()} callback A callback for when the replace is done. + */ + function doReplace(cm, confirm, global, lineStart, lineEnd, searchCursor, query, + replaceWith, callback) { + // Set up all the functions. + cm.state.vim.exMode = true; + var done = false; + var lastPos = searchCursor.from(); + function replaceAll() { + cm.operation(function() { + while (!done) { + replace(); + next(); + } + stop(); + }); + } + function replace() { + var text = cm.getRange(searchCursor.from(), searchCursor.to()); + var newText = text.replace(query, replaceWith); + searchCursor.replace(newText); + } + function next() { + // The below only loops to skip over multiple occurrences on the same + // line when 'global' is not true. + while(searchCursor.findNext() && + isInRange(searchCursor.from(), lineStart, lineEnd)) { + if (!global && lastPos && searchCursor.from().line == lastPos.line) { + continue; + } + cm.scrollIntoView(searchCursor.from(), 30); + cm.setSelection(searchCursor.from(), searchCursor.to()); + lastPos = searchCursor.from(); + done = false; + return; + } + done = true; + } + function stop(close) { + if (close) { close(); } + cm.focus(); + if (lastPos) { + cm.setCursor(lastPos); + var vim = cm.state.vim; + vim.exMode = false; + vim.lastHPos = vim.lastHSPos = lastPos.ch; + } + if (callback) { callback(); } + } + function onPromptKeyDown(e, _value, close) { + // Swallow all keys. + CodeMirror.e_stop(e); + var keyName = CodeMirror.keyName(e); + switch (keyName) { + case 'Y': + replace(); next(); break; + case 'N': + next(); break; + case 'A': + // replaceAll contains a call to close of its own. We don't want it + // to fire too early or multiple times. + var savedCallback = callback; + callback = undefined; + cm.operation(replaceAll); + callback = savedCallback; + break; + case 'L': + replace(); + // fall through and exit. + case 'Q': + case 'Esc': + case 'Ctrl-C': + case 'Ctrl-[': + stop(close); + break; + } + if (done) { stop(close); } + return true; + } + + // Actually do replace. + next(); + if (done) { + showConfirm(cm, 'No matches for ' + query.source); + return; + } + if (!confirm) { + replaceAll(); + if (callback) { callback(); } + return; + } + showPrompt(cm, { + prefix: 'replace with ' + replaceWith + ' (y/n/a/q/l)', + onKeyDown: onPromptKeyDown + }); + } + + CodeMirror.keyMap.vim = { + attach: attachVimMap, + detach: detachVimMap, + call: cmKey + }; + + function exitInsertMode(cm) { + var vim = cm.state.vim; + var macroModeState = vimGlobalState.macroModeState; + var insertModeChangeRegister = vimGlobalState.registerController.getRegister('.'); + var isPlaying = macroModeState.isPlaying; + var lastChange = macroModeState.lastInsertModeChanges; + // In case of visual block, the insertModeChanges are not saved as a + // single word, so we convert them to a single word + // so as to update the ". register as expected in real vim. + var text = []; + if (!isPlaying) { + var selLength = lastChange.inVisualBlock ? vim.lastSelection.visualBlock.height : 1; + var changes = lastChange.changes; + var text = []; + var i = 0; + // In case of multiple selections in blockwise visual, + // the inserted text, for example: 'foo', is stored as + // 'f', 'f', InsertModeKey 'o', 'o', 'o', 'o'. (if you have a block with 2 lines). + // We push the contents of the changes array as per the following: + // 1. In case of InsertModeKey, just increment by 1. + // 2. In case of a character, jump by selLength (2 in the example). + while (i < changes.length) { + // This loop will convert 'ffoooo' to 'foo'. + text.push(changes[i]); + if (changes[i] instanceof InsertModeKey) { + i++; + } else { + i+= selLength; + } + } + lastChange.changes = text; + cm.off('change', onChange); + CodeMirror.off(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown); + } + if (!isPlaying && vim.insertModeRepeat > 1) { + // Perform insert mode repeat for commands like 3,a and 3,o. + repeatLastEdit(cm, vim, vim.insertModeRepeat - 1, + true /** repeatForInsert */); + vim.lastEditInputState.repeatOverride = vim.insertModeRepeat; + } + delete vim.insertModeRepeat; + vim.insertMode = false; + cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1); + cm.setOption('keyMap', 'vim'); + cm.setOption('disableInput', true); + + lastChange.overwrite = cm.state.overwrite; + cm.toggleOverwrite(false); // exit replace mode if we were in it. + // update the ". register before exiting insert mode + insertModeChangeRegister.setText(lastChange.changes.join('')); + CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); + if (macroModeState.isRecording) { + logInsertModeChange(macroModeState); + } + } + + function _mapCommand(command) { + defaultKeymap.unshift(command); + } + + function mapCommand(keys, type, name, args, extra) { + var command = {keys: keys, type: type}; + command[type] = name; + command[type + "Args"] = args; + for (var key in extra) + command[key] = extra[key]; + _mapCommand(command); + } + + // The timeout in milliseconds for the two-character ESC keymap should be + // adjusted according to your typing speed to prevent false positives. + defineOption('insertModeEscKeysTimeout', 200, 'number'); + + CodeMirror.keyMap['vim-insert'] = { + // TODO: override navigation keys so that Esc will cancel automatic + // indentation from o, O, i_ + 'Ctrl-N': 'autocomplete', + 'Ctrl-P': 'autocomplete', + 'Enter': function(cm) { + var fn = CodeMirror.commands.newlineAndIndentContinueComment || + CodeMirror.commands.newlineAndIndent; + fn(cm); + }, + fallthrough: ['default'], + attach: attachVimMap, + detach: detachVimMap, + call: cmKey + }; + + CodeMirror.keyMap['vim-replace'] = { + 'Backspace': 'goCharLeft', + fallthrough: ['vim-insert'], + attach: attachVimMap, + detach: detachVimMap, + call: cmKey + }; + + function executeMacroRegister(cm, vim, macroModeState, registerName) { + var register = vimGlobalState.registerController.getRegister(registerName); + if (registerName == ':') { + // Read-only register containing last Ex command. + if (register.keyBuffer[0]) { + exCommandDispatcher.processCommand(cm, register.keyBuffer[0]); + } + macroModeState.isPlaying = false; + return; + } + var keyBuffer = register.keyBuffer; + var imc = 0; + macroModeState.isPlaying = true; + macroModeState.replaySearchQueries = register.searchQueries.slice(0); + for (var i = 0; i < keyBuffer.length; i++) { + var text = keyBuffer[i]; + var match, key; + while (text) { + // Pull off one command key, which is either a single character + // or a special sequence wrapped in '<' and '>', e.g. ''. + match = (/<\w+-.+?>|<\w+>|./).exec(text); + key = match[0]; + text = text.substring(match.index + key.length); + CodeMirror.Vim.handleKey(cm, key, 'macro'); + if (vim.insertMode) { + var changes = register.insertModeChanges[imc++].changes; + vimGlobalState.macroModeState.lastInsertModeChanges.changes = + changes; + repeatInsertModeChanges(cm, changes, 1); + exitInsertMode(cm); + } + } + } + macroModeState.isPlaying = false; + } + + function logKey(macroModeState, key) { + if (macroModeState.isPlaying) { return; } + var registerName = macroModeState.latestRegister; + var register = vimGlobalState.registerController.getRegister(registerName); + if (register) { + register.pushText(key); + } + } + + function logInsertModeChange(macroModeState) { + if (macroModeState.isPlaying) { return; } + var registerName = macroModeState.latestRegister; + var register = vimGlobalState.registerController.getRegister(registerName); + if (register && register.pushInsertModeChanges) { + register.pushInsertModeChanges(macroModeState.lastInsertModeChanges); + } + } + + function logSearchQuery(macroModeState, query) { + if (macroModeState.isPlaying) { return; } + var registerName = macroModeState.latestRegister; + var register = vimGlobalState.registerController.getRegister(registerName); + if (register && register.pushSearchQuery) { + register.pushSearchQuery(query); + } + } + + /** + * Listens for changes made in insert mode. + * Should only be active in insert mode. + */ + function onChange(_cm, changeObj) { + var macroModeState = vimGlobalState.macroModeState; + var lastChange = macroModeState.lastInsertModeChanges; + if (!macroModeState.isPlaying) { + while(changeObj) { + lastChange.expectCursorActivityForChange = true; + if (changeObj.origin == '+input' || changeObj.origin == 'paste' + || changeObj.origin === undefined /* only in testing */) { + var text = changeObj.text.join('\n'); + if (lastChange.maybeReset) { + lastChange.changes = []; + lastChange.maybeReset = false; + } + lastChange.changes.push(text); + } + // Change objects may be chained with next. + changeObj = changeObj.next; + } + } + } + + /** + * Listens for any kind of cursor activity on CodeMirror. + */ + function onCursorActivity(cm) { + var vim = cm.state.vim; + if (vim.insertMode) { + // Tracking cursor activity in insert mode (for macro support). + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isPlaying) { return; } + var lastChange = macroModeState.lastInsertModeChanges; + if (lastChange.expectCursorActivityForChange) { + lastChange.expectCursorActivityForChange = false; + } else { + // Cursor moved outside the context of an edit. Reset the change. + lastChange.maybeReset = true; + } + } else if (!cm.curOp.isVimOp) { + handleExternalSelection(cm, vim); + } + if (vim.visualMode) { + updateFakeCursor(cm); + } + } + function updateFakeCursor(cm) { + var vim = cm.state.vim; + var from = clipCursorToContent(cm, copyCursor(vim.sel.head)); + var to = offsetCursor(from, 0, 1); + if (vim.fakeCursor) { + vim.fakeCursor.clear(); + } + vim.fakeCursor = cm.markText(from, to, {className: 'cm-animate-fat-cursor'}); + } + function handleExternalSelection(cm, vim) { + var anchor = cm.getCursor('anchor'); + var head = cm.getCursor('head'); + // Enter or exit visual mode to match mouse selection. + if (vim.visualMode && !cm.somethingSelected()) { + exitVisualMode(cm, false); + } else if (!vim.visualMode && !vim.insertMode && cm.somethingSelected()) { + vim.visualMode = true; + vim.visualLine = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"}); + } + if (vim.visualMode) { + // Bind CodeMirror selection model to vim selection model. + // Mouse selections are considered visual characterwise. + var headOffset = !cursorIsBefore(head, anchor) ? -1 : 0; + var anchorOffset = cursorIsBefore(head, anchor) ? -1 : 0; + head = offsetCursor(head, 0, headOffset); + anchor = offsetCursor(anchor, 0, anchorOffset); + vim.sel = { + anchor: anchor, + head: head + }; + updateMark(cm, vim, '<', cursorMin(head, anchor)); + updateMark(cm, vim, '>', cursorMax(head, anchor)); + } else if (!vim.insertMode) { + // Reset lastHPos if selection was modified by something outside of vim mode e.g. by mouse. + vim.lastHPos = cm.getCursor().ch; + } + } + + /** Wrapper for special keys pressed in insert mode */ + function InsertModeKey(keyName) { + this.keyName = keyName; + } + + /** + * Handles raw key down events from the text area. + * - Should only be active in insert mode. + * - For recording deletes in insert mode. + */ + function onKeyEventTargetKeyDown(e) { + var macroModeState = vimGlobalState.macroModeState; + var lastChange = macroModeState.lastInsertModeChanges; + var keyName = CodeMirror.keyName(e); + if (!keyName) { return; } + function onKeyFound() { + if (lastChange.maybeReset) { + lastChange.changes = []; + lastChange.maybeReset = false; + } + lastChange.changes.push(new InsertModeKey(keyName)); + return true; + } + if (keyName.indexOf('Delete') != -1 || keyName.indexOf('Backspace') != -1) { + CodeMirror.lookupKey(keyName, 'vim-insert', onKeyFound); + } + } + + /** + * Repeats the last edit, which includes exactly 1 command and at most 1 + * insert. Operator and motion commands are read from lastEditInputState, + * while action commands are read from lastEditActionCommand. + * + * If repeatForInsert is true, then the function was called by + * exitInsertMode to repeat the insert mode changes the user just made. The + * corresponding enterInsertMode call was made with a count. + */ + function repeatLastEdit(cm, vim, repeat, repeatForInsert) { + var macroModeState = vimGlobalState.macroModeState; + macroModeState.isPlaying = true; + var isAction = !!vim.lastEditActionCommand; + var cachedInputState = vim.inputState; + function repeatCommand() { + if (isAction) { + commandDispatcher.processAction(cm, vim, vim.lastEditActionCommand); + } else { + commandDispatcher.evalInput(cm, vim); + } + } + function repeatInsert(repeat) { + if (macroModeState.lastInsertModeChanges.changes.length > 0) { + // For some reason, repeat cw in desktop VIM does not repeat + // insert mode changes. Will conform to that behavior. + repeat = !vim.lastEditActionCommand ? 1 : repeat; + var changeObject = macroModeState.lastInsertModeChanges; + repeatInsertModeChanges(cm, changeObject.changes, repeat, changeObject.overwrite); + } + } + vim.inputState = vim.lastEditInputState; + if (isAction && vim.lastEditActionCommand.interlaceInsertRepeat) { + // o and O repeat have to be interlaced with insert repeats so that the + // insertions appear on separate lines instead of the last line. + for (var i = 0; i < repeat; i++) { + repeatCommand(); + repeatInsert(1); + } + } else { + if (!repeatForInsert) { + // Hack to get the cursor to end up at the right place. If I is + // repeated in insert mode repeat, cursor will be 1 insert + // change set left of where it should be. + repeatCommand(); + } + repeatInsert(repeat); + } + vim.inputState = cachedInputState; + if (vim.insertMode && !repeatForInsert) { + // Don't exit insert mode twice. If repeatForInsert is set, then we + // were called by an exitInsertMode call lower on the stack. + exitInsertMode(cm); + } + macroModeState.isPlaying = false; + } + + function repeatInsertModeChanges(cm, changes, repeat, overwrite) { + function keyHandler(binding) { + if (typeof binding == 'string') { + CodeMirror.commands[binding](cm); + } else { + binding(cm); + } + return true; + } + var head = cm.getCursor('head'); + var inVisualBlock = vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock; + if (inVisualBlock) { + // Set up block selection again for repeating the changes. + var vim = cm.state.vim; + var lastSel = vim.lastSelection; + var offset = getOffset(lastSel.anchor, lastSel.head); + selectForInsert(cm, head, offset.line + 1); + repeat = cm.listSelections().length; + cm.setCursor(head); + } + for (var i = 0; i < repeat; i++) { + if (inVisualBlock) { + cm.setCursor(offsetCursor(head, i, 0)); + } + for (var j = 0; j < changes.length; j++) { + var change = changes[j]; + if (change instanceof InsertModeKey) { + CodeMirror.lookupKey(change.keyName, 'vim-insert', keyHandler); + } else { + var cur = cm.getCursor(); + var end = cur; + if (overwrite && !/\n/.test(change)) { + end = offsetCursor(cur, 0, change.length); + } + cm.replaceRange(change, cur, end); + } + } + } + if (inVisualBlock) { + cm.setCursor(offsetCursor(head, 0, 1)); + } + } + + resetVimGlobalState(); + //}; + // Initialize Vim and make it available as an API. + CodeMirror.Vim = Vim(); + + Vim = CodeMirror.Vim; + + var specialKey = {'return':'CR',backspace:'BS','delete':'Del',esc:'Esc', + left:'Left',right:'Right',up:'Up',down:'Down',space: 'Space', + home:'Home',end:'End',pageup:'PageUp',pagedown:'PageDown', enter: 'CR' + }; + function lookupKey(hashId, key, e) { + if (key.length > 1 && key[0] == "n") { + key = key.replace("numpad", ""); + } + key = specialKey[key] || key; + var name = ''; + if (e.ctrlKey) { name += 'C-'; } + if (e.altKey) { name += 'A-'; } + if (e.shiftKey) { name += 'S-'; } + + name += key; + if (name.length > 1) { name = '<' + name + '>'; } + return name; + } + var handleKey = Vim.handleKey.bind(Vim); + Vim.handleKey = function(cm, key, origin) { + return cm.operation(function() { + return handleKey(cm, key, origin); + }, true); + } + function cloneVimState(state) { + var n = new state.constructor(); + Object.keys(state).forEach(function(key) { + var o = state[key]; + if (Array.isArray(o)) + o = o.slice(); + else if (o && typeof o == "object" && o.constructor != Object) + o = cloneVimState(o); + n[key] = o; + }); + if (state.sel) { + n.sel = { + head: state.sel.head && copyCursor(state.sel.head), + anchor: state.sel.anchor && copyCursor(state.sel.anchor) + }; + } + return n; + } + function multiSelectHandleKey(cm, key, origin) { + var isHandled = false; + var vim = Vim.maybeInitVimState_(cm); + var visualBlock = vim.visualBlock || vim.wasInVisualBlock; + if (vim.wasInVisualBlock && !cm.ace.inMultiSelectMode) { + vim.wasInVisualBlock = false; + } else if (cm.ace.inMultiSelectMode && vim.visualBlock) { + vim.wasInVisualBlock = true; + } + + if (key == '' && !vim.insertMode && !vim.visualMode && cm.ace.inMultiSelectMode) { + cm.ace.exitMultiSelectMode(); + } else if (visualBlock || !cm.ace.inMultiSelectMode || cm.ace.inVirtualSelectionMode) { + isHandled = Vim.handleKey(cm, key, origin); + } else { + var old = cloneVimState(vim); + cm.operation(function() { + cm.ace.forEachSelection(function() { + var sel = cm.ace.selection; + cm.state.vim.lastHPos = sel.$desiredColumn == null ? sel.lead.column : sel.$desiredColumn; + var head = cm.getCursor("head"); + var anchor = cm.getCursor("anchor"); + var headOffset = !cursorIsBefore(head, anchor) ? -1 : 0; + var anchorOffset = cursorIsBefore(head, anchor) ? -1 : 0; + head = offsetCursor(head, 0, headOffset); + anchor = offsetCursor(anchor, 0, anchorOffset); + cm.state.vim.sel.head = head; + cm.state.vim.sel.anchor = anchor; + + isHandled = handleKey(cm, key, origin); + sel.$desiredColumn = cm.state.vim.lastHPos == -1 ? null : cm.state.vim.lastHPos; + if (cm.virtualSelectionMode()) { + cm.state.vim = cloneVimState(old); + } + }); + if (cm.curOp.cursorActivity && !isHandled) + cm.curOp.cursorActivity = false; + }, true); + } + return isHandled; + } + exports.CodeMirror = CodeMirror; + var getVim = Vim.maybeInitVimState_; + exports.handler = { + $id: "ace/keyboard/vim", + drawCursor: function(style, pixelPos, config, sel, session) { + var vim = this.state.vim || {}; + var w = config.characterWidth; + var h = config.lineHeight; + var top = pixelPos.top; + var left = pixelPos.left; + if (!vim.insertMode) { + var isbackwards = !sel.cursor + ? session.selection.isBackwards() || session.selection.isEmpty() + : Range.comparePoints(sel.cursor, sel.start) <= 0; + if (!isbackwards && left > w) + left -= w; + } + if (!vim.insertMode && vim.status) { + h = h / 2; + top += h; + } + style.left = left + "px"; + style.top = top + "px"; + style.width = w + "px"; + style.height = h + "px"; + }, + handleKeyboard: function(data, hashId, key, keyCode, e) { + var editor = data.editor; + var cm = editor.state.cm; + var vim = getVim(cm); + if (keyCode == -1) return; + + if (key == "c" && hashId == 1) { // key == "ctrl-c" + if (!useragent.isMac && editor.getCopyText()) { + editor.once("copy", function() { + editor.selection.clearSelection(); + }); + return {command: "null", passEvent: true}; + } + } else if (!vim.insertMode) { + if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) { + hashId = -1; + key = data.inputChar; + } + } + + if (hashId == -1 || hashId & 1 || hashId === 0 && key.length > 1) { + var insertMode = vim.insertMode; + var name = lookupKey(hashId, key, e || {}); + if (vim.status == null) + vim.status = ""; + var isHandled = multiSelectHandleKey(cm, name, 'user'); + vim = getVim(cm); // may be changed by multiSelectHandleKey + if (isHandled && vim.status != null) + vim.status += name; + else if (vim.status == null) + vim.status = ""; + cm._signal("changeStatus"); + if (!isHandled && (hashId != -1 || insertMode)) + return; + return {command: "null", passEvent: !isHandled}; + } + }, + attach: function(editor) { + if (!editor.state) editor.state = {}; + var cm = new CodeMirror(editor); + editor.state.cm = cm; + editor.$vimModeHandler = this; + CodeMirror.keyMap.vim.attach(cm); + getVim(cm).status = null; + cm.on('vim-command-done', function() { + if (cm.virtualSelectionMode()) return; + getVim(cm).status = null; + cm.ace._signal("changeStatus"); + cm.ace.session.markUndoGroup(); + }); + cm.on("changeStatus", function() { + cm.ace.renderer.updateCursor(); + cm.ace._signal("changeStatus"); + }); + cm.on("vim-mode-change", function() { + if (cm.virtualSelectionMode()) return; + cm.ace.renderer.setStyle("normal-mode", !getVim(cm).insertMode); + cm._signal("changeStatus"); + }); + cm.ace.renderer.setStyle("normal-mode", !getVim(cm).insertMode); + editor.renderer.$cursorLayer.drawCursor = this.drawCursor.bind(cm); + // renderVirtualNumbers.attach(editor); + this.updateMacCompositionHandlers(editor, true); + }, + detach: function(editor) { + var cm = editor.state.cm; + CodeMirror.keyMap.vim.detach(cm); + cm.destroy(); + editor.state.cm = null; + editor.$vimModeHandler = null; + editor.renderer.$cursorLayer.drawCursor = null; + editor.renderer.setStyle("normal-mode", false); + // renderVirtualNumbers.detach(editor); + this.updateMacCompositionHandlers(editor, false); + }, + getStatusText: function(editor) { + var cm = editor.state.cm; + var vim = getVim(cm); + if (vim.insertMode) + return "INSERT"; + var status = ""; + if (vim.visualMode) { + status += "VISUAL"; + if (vim.visualLine) + status += " LINE"; + if (vim.visualBlock) + status += " BLOCK"; + } + if (vim.status) + status += (status ? " " : "") + vim.status; + return status; + }, + // workaround for j not repeating with `defaults write -g ApplePressAndHoldEnabled -bool true` + handleMacRepeat: function(data, hashId, key) { + if (hashId == -1) { + // record key + data.inputChar = key; + data.lastEvent = "input"; + } else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) { + // check for repeated keypress + if (data.lastEvent == "input") { + data.lastEvent = "input1"; + } else if (data.lastEvent == "input1") { + // simulate textinput + return true; + } + } else { + // reset + data.$lastHash = hashId; + data.$lastKey = key; + data.lastEvent = "keypress"; + } + }, + // on mac, with some keyboard layouts (e.g swedish) ^ starts composition, we don't need it in normal mode + updateMacCompositionHandlers: function(editor, enable) { + var onCompositionUpdateOverride = function(text) { + var cm = editor.state.cm; + var vim = getVim(cm); + if (!vim.insertMode) { + var el = this.textInput.getElement(); + el.blur(); + el.focus(); + el.value = text; + } else { + this.onCompositionUpdateOrig(text); + } + }; + var onCompositionStartOverride = function(text) { + var cm = editor.state.cm; + var vim = getVim(cm); + if (!vim.insertMode) { + this.onCompositionStartOrig(text); + } + }; + if (enable) { + if (!editor.onCompositionUpdateOrig) { + editor.onCompositionUpdateOrig = editor.onCompositionUpdate; + editor.onCompositionUpdate = onCompositionUpdateOverride; + editor.onCompositionStartOrig = editor.onCompositionStart; + editor.onCompositionStart = onCompositionStartOverride; + } + } else { + if (editor.onCompositionUpdateOrig) { + editor.onCompositionUpdate = editor.onCompositionUpdateOrig; + editor.onCompositionUpdateOrig = null; + editor.onCompositionStart = editor.onCompositionStartOrig; + editor.onCompositionStartOrig = null; + } + } + } + }; + var renderVirtualNumbers = { + getText: function(session, row) { + return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9? "\xb7" : "" ))) + ""; + }, + getWidth: function(session, lastLineNumber, config) { + return session.getLength().toString().length * config.characterWidth; + }, + update: function(e, editor) { + editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER); + }, + attach: function(editor) { + editor.renderer.$gutterLayer.$renderer = this; + editor.on("changeSelection", this.update); + }, + detach: function(editor) { + editor.renderer.$gutterLayer.$renderer = null; + editor.off("changeSelection", this.update); + } + }; + Vim.defineOption({ + name: "wrap", + set: function(value, cm) { + if (cm) {cm.ace.setOption("wrap", value)} + }, + type: "boolean" + }, false); + Vim.defineEx('write', 'w', function() { + console.log(':write is not implemented') + }); + defaultKeymap.push( + { keys: 'zc', type: 'action', action: 'fold', actionArgs: { open: false } }, + { keys: 'zC', type: 'action', action: 'fold', actionArgs: { open: false, all: true } }, + { keys: 'zo', type: 'action', action: 'fold', actionArgs: { open: true } }, + { keys: 'zO', type: 'action', action: 'fold', actionArgs: { open: true, all: true } }, + { keys: 'za', type: 'action', action: 'fold', actionArgs: { toggle: true } }, + { keys: 'zA', type: 'action', action: 'fold', actionArgs: { toggle: true, all: true } }, + { keys: 'zf', type: 'action', action: 'fold', actionArgs: { open: true, all: true } }, + { keys: 'zd', type: 'action', action: 'fold', actionArgs: { open: true, all: true } }, + + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorAbove" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorBelow" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorAboveSkipCurrent" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorBelowSkipCurrent" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectMoreBefore" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectMoreAfter" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectNextBefore" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectNextAfter" } } + ); + actions.aceCommand = function(cm, actionArgs, vim) { + cm.vimCmd = actionArgs; + if (cm.ace.inVirtualSelectionMode) + cm.ace.on("beforeEndOperation", delayedExecAceCommand); + else + delayedExecAceCommand(null, cm.ace); + }; + function delayedExecAceCommand(op, ace) { + ace.off("beforeEndOperation", delayedExecAceCommand); + var cmd = ace.state.cm.vimCmd; + if (cmd) { + ace.execCommand(cmd.exec ? cmd : cmd.name, cmd.args); + } + ace.curOp = ace.prevOp; + } + actions.fold = function(cm, actionArgs, vim) { + cm.ace.execCommand(['toggleFoldWidget', 'toggleFoldWidget', 'foldOther', 'unfoldall' + ][(actionArgs.all ? 2 : 0) + (actionArgs.open ? 1 : 0)]); + }; + + exports.handler.defaultKeymap = defaultKeymap; + exports.handler.actions = actions; + exports.Vim = Vim; + + Vim.map("Y", "yy", "normal"); +}); diff --git a/public/lib/ace/keyboard/vim_test.js b/public/lib/ace/keyboard/vim_test.js new file mode 100644 index 0000000..0791d65 --- /dev/null +++ b/public/lib/ace/keyboard/vim_test.js @@ -0,0 +1,4122 @@ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { + +var EditSession = require("./../edit_session").EditSession; +var Editor = require("./../editor").Editor; +var UndoManager = require("./../undomanager").UndoManager; +var MockRenderer = require("./../test/mockrenderer").MockRenderer; +var JavaScriptMode = require("./../mode/javascript").Mode; +var VirtualRenderer = require("./../virtual_renderer").VirtualRenderer; +var assert = require("./../test/assertions"); +var keys = require("./../lib/keys"); +var vim = require("./vim"); + +var el = document.createElement("div"); +el.style.position = "fixed"; +el.style.left = "20px"; +el.style.top = "30px"; +el.style.width = "500px"; +el.style.height = "300px"; +document.body.appendChild(el); + +if (window.name == "nodejs") + return console.log("Skipping test: This test only runs in the browser"); + +var renderer = new VirtualRenderer(el); +editor = new Editor(renderer);//(new MockRenderer()); +editor.session.setUndoManager(new UndoManager()); +editor.session.setUseWorker(false); +editor.session.setMode(new JavaScriptMode()); +function CodeMirror(place, opts) { + if (opts.value != null) + editor.session.setValue(opts.value); + editor.setOption("indentedSoftWrap", false); + editor.setOption("wrap", opts.lineWrapping); + editor.setOption("useSoftTabs", !opts.indentWithTabs); + editor.setKeyboardHandler(null); + editor.setKeyboardHandler(vim.handler); + var cm = editor.state.cm; + cm.setOption("tabSize", opts.tabSize || 4); + cm.setOption("indentUnit", opts.indentUnit || 2); + + cm.setSize = function(w, h) { + var changed = false; + if (w && editor.w != w) { + changed = true; + el.style.width = (editor.w = w) + "px"; + } + if (h && editor.h != h) { + changed = true; + el.style.height = (editor.h = h) + "px"; + } + if (changed) + editor.resize(true); + }; + cm.setSize(500, 300); + return cm; +} +CodeMirror.defineMode = function() {} +for (var key in vim.CodeMirror) + CodeMirror[key] = vim.CodeMirror[key]; +var editor; +var i = 0; +function test(name, fn) { + // if (name != 'vim_search_history') return + // for (i = 0; i < 1000; i++) + // exports["test " + name + i] = fn; // vim_ex_global_confirm + if (i++ < 0 || /- /.test(name)) + exports["test " + name] = function() {}; + else + exports["test " + name] = fn; +} +function expectFail(fn) { + try { + fn(); + } catch(expected) {}; + throw new Error("Expected to throw an error"); +} + +vim.CodeMirror.Vim.unmap("Y"); +vim.CodeMirror.Vim.defineEx('write', 'w', function(cm) { + CodeMirror.commands.save(cm); +}); + + + +// cm.setBookmark({ch: 5, line: 0}) +// cm.setBookmark({ch: 4, line: 0}) +// cm.replaceRange("x-", {ch: 4, line: 0}, {ch: 5, line: 0}); [editor.$vimModeHandler.cm.marks[0].find(),editor.$vimModeHandler.cm.marks[1].find()] + +var lineText, verbose, phantom; +var Pos = CodeMirror.Pos; +var place = document.createElement("div"); +var eqPos = assert.deepEqual; +var eq = assert.equal; +var is = assert.ok; + +CodeMirror.Vim.suppressErrorLogging = true; + +var code = '' + +' wOrd1 (#%\n' + +' word3] \n' + +'aopop pop 0 1 2 3 4\n' + +' (a) [b] {c} \n' + +'int getchar(void) {\n' + +' static char buf[BUFSIZ];\n' + +' static char *bufp = buf;\n' + +' if (n == 0) { /* buffer is empty */\n' + +' n = read(0, buf, sizeof buf);\n' + +' bufp = buf;\n' + +' }\n' + +'\n' + +' return (--n >= 0) ? (unsigned char) *bufp++ : EOF;\n' + +' \n' + +'}\n'; + +var lines = (function() { + lineText = code.split('\n'); + var ret = []; + for (var i = 0; i < lineText.length; i++) { + ret[i] = { + line: i, + length: lineText[i].length, + lineText: lineText[i], + textStart: /^\s*/.exec(lineText[i])[0].length + }; + } + return ret; +})(); +var endOfDocument = makeCursor(lines.length - 1, + lines[lines.length - 1].length); +var wordLine = lines[0]; +var bigWordLine = lines[1]; +var charLine = lines[2]; +var bracesLine = lines[3]; +var seekBraceLine = lines[4]; + +var word1 = { + start: { line: wordLine.line, ch: 1 }, + end: { line: wordLine.line, ch: 5 } +}; +var word2 = { + start: { line: wordLine.line, ch: word1.end.ch + 2 }, + end: { line: wordLine.line, ch: word1.end.ch + 4 } +}; +var word3 = { + start: { line: bigWordLine.line, ch: 1 }, + end: { line: bigWordLine.line, ch: 5 } +}; +var bigWord1 = word1; +var bigWord2 = word2; +var bigWord3 = { + start: { line: bigWordLine.line, ch: 1 }, + end: { line: bigWordLine.line, ch: 7 } +}; +var bigWord4 = { + start: { line: bigWordLine.line, ch: bigWord1.end.ch + 3 }, + end: { line: bigWordLine.line, ch: bigWord1.end.ch + 7 } +}; + +var oChars = [ { line: charLine.line, ch: 1 }, + { line: charLine.line, ch: 3 }, + { line: charLine.line, ch: 7 } ]; +var pChars = [ { line: charLine.line, ch: 2 }, + { line: charLine.line, ch: 4 }, + { line: charLine.line, ch: 6 }, + { line: charLine.line, ch: 8 } ]; +var numChars = [ { line: charLine.line, ch: 10 }, + { line: charLine.line, ch: 12 }, + { line: charLine.line, ch: 14 }, + { line: charLine.line, ch: 16 }, + { line: charLine.line, ch: 18 }]; +var parens1 = { + start: { line: bracesLine.line, ch: 1 }, + end: { line: bracesLine.line, ch: 3 } +}; +var squares1 = { + start: { line: bracesLine.line, ch: 5 }, + end: { line: bracesLine.line, ch: 7 } +}; +var curlys1 = { + start: { line: bracesLine.line, ch: 9 }, + end: { line: bracesLine.line, ch: 11 } +}; +var seekOutside = { + start: { line: seekBraceLine.line, ch: 1 }, + end: { line: seekBraceLine.line, ch: 16 } +}; +var seekInside = { + start: { line: seekBraceLine.line, ch: 14 }, + end: { line: seekBraceLine.line, ch: 11 } +}; + +function copyCursor(cur) { + return { ch: cur.ch, line: cur.line }; +} + +function forEach(arr, func) { + for (var i = 0; i < arr.length; i++) { + func(arr[i], i, arr); + } +} + +function testVim(name, run, opts, expectedFail) { + var vimOpts = { + lineNumbers: true, + vimMode: true, + showCursorWhenSelecting: true, + value: code + }; + for (var prop in opts) { + if (opts.hasOwnProperty(prop)) { + vimOpts[prop] = opts[prop]; + } + } + return test('vim_' + name, function() { + var place = document.getElementById("testground"); + var cm = CodeMirror(place, vimOpts); + var vim = CodeMirror.Vim.maybeInitVimState_(cm); + + function doKeysFn(cm) { + return function(args) { + if (args instanceof Array) { + arguments = args; + } + for (var i = 0; i < arguments.length; i++) { + var result = CodeMirror.Vim.handleKey(cm, arguments[i]); + if (!result && cm.state.vim.insertMode) { + cm.replaceSelections(fillArray(arguments[i], cm.listSelections().length)); + } + } + } + } + function doInsertModeKeysFn(cm) { + return function(args) { + if (args instanceof Array) { arguments = args; } + function executeHandler(handler) { + if (typeof handler == 'string') { + CodeMirror.commands[handler](cm); + } else { + handler(cm); + } + return true; + } + for (var i = 0; i < arguments.length; i++) { + var key = arguments[i]; + // Find key in keymap and handle. + var handled = CodeMirror.lookupKey(key, 'vim-insert', executeHandler); + // Record for insert mode. + if (handled == "handled" && cm.state.vim.insertMode && arguments[i] != 'Esc') { + var lastChange = CodeMirror.Vim.getVimGlobalState_().macroModeState.lastInsertModeChanges; + if (lastChange && (key.indexOf('Delete') != -1 || key.indexOf('Backspace') != -1)) { + lastChange.changes.push(new CodeMirror.Vim.InsertModeKey(key)); + } + } + } + } + } + function doExFn(cm) { + return function(command) { + cm.openDialog = helpers.fakeOpenDialog(command); + helpers.doKeys(':'); + } + } + function assertCursorAtFn(cm) { + return function(line, ch) { + var pos; + if (ch == null && typeof line.line == 'number') { + pos = line; + } else { + pos = makeCursor(line, ch); + } + eqPos(pos, cm.getCursor()); + } + } + function fakeOpenDialog(result) { + return function(text, callback) { + return callback(result); + } + } + function fakeOpenNotification(matcher) { + return function(text) { + matcher(text); + } + } + var helpers = { + doKeys: doKeysFn(cm), + // Warning: Only emulates keymap events, not character insertions. Use + // replaceRange to simulate character insertions. + // Keys are in CodeMirror format, NOT vim format. + doInsertModeKeys: doInsertModeKeysFn(cm), + doEx: doExFn(cm), + assertCursorAt: assertCursorAtFn(cm), + fakeOpenDialog: fakeOpenDialog, + fakeOpenNotification: fakeOpenNotification, + getRegisterController: function() { + return CodeMirror.Vim.getRegisterController(); + } + } + CodeMirror.Vim.resetVimGlobalState_(); + var successful = false; + var savedOpenNotification = cm.openNotification; + var savedOpenDialog = cm.openDialog; + try { + run(cm, vim, helpers); + successful = true; + } finally { + cm.openNotification = savedOpenNotification; + cm.openDialog = savedOpenDialog; + // ace_patch + } + }); +} +testVim('qq@q', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'q', 'l', 'l', 'q'); + helpers.assertCursorAt(0,2); + helpers.doKeys('@', 'q'); + helpers.assertCursorAt(0,4); +}, { value: ' '}); +testVim('@@', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'q', 'l', 'l', 'q'); + helpers.assertCursorAt(0,2); + helpers.doKeys('@', 'q'); + helpers.assertCursorAt(0,4); + helpers.doKeys('@', '@'); + helpers.assertCursorAt(0,6); +}, { value: ' '}); +var jumplistScene = ''+ + 'word\n'+ + '(word)\n'+ + '{word\n'+ + 'word.\n'+ + '\n'+ + 'word search\n'+ + '}word\n'+ + 'word\n'+ + 'word\n'; +function testJumplist(name, keys, endPos, startPos, dialog) { + endPos = makeCursor(endPos[0], endPos[1]); + startPos = makeCursor(startPos[0], startPos[1]); + testVim(name, function(cm, vim, helpers) { + CodeMirror.Vim.resetVimGlobalState_(); + if(dialog)cm.openDialog = helpers.fakeOpenDialog('word'); + cm.setCursor(startPos); + helpers.doKeys.apply(null, keys); + helpers.assertCursorAt(endPos); + }, {value: jumplistScene}); +} +testJumplist('jumplist_H', ['H', ''], [5,2], [5,2]); +testJumplist('jumplist_M', ['M', ''], [2,2], [2,2]); +testJumplist('jumplist_L', ['L', ''], [2,2], [2,2]); +testJumplist('jumplist_[[', ['[', '[', ''], [5,2], [5,2]); +testJumplist('jumplist_]]', [']', ']', ''], [2,2], [2,2]); +testJumplist('jumplist_G', ['G', ''], [5,2], [5,2]); +testJumplist('jumplist_gg', ['g', 'g', ''], [5,2], [5,2]); +testJumplist('jumplist_%', ['%', ''], [1,5], [1,5]); +testJumplist('jumplist_{', ['{', ''], [1,5], [1,5]); +testJumplist('jumplist_}', ['}', ''], [1,5], [1,5]); +testJumplist('jumplist_\'', ['m', 'a', 'h', '\'', 'a', 'h', ''], [1,0], [1,5]); +testJumplist('jumplist_`', ['m', 'a', 'h', '`', 'a', 'h', ''], [1,5], [1,5]); +testJumplist('jumplist_*_cachedCursor', ['*', ''], [1,3], [1,3]); +testJumplist('jumplist_#_cachedCursor', ['#', ''], [1,3], [1,3]); +testJumplist('jumplist_n', ['#', 'n', ''], [1,1], [2,3]); +testJumplist('jumplist_N', ['#', 'N', ''], [1,1], [2,3]); +testJumplist('jumplist_repeat_', ['*', '*', '*', '3', ''], [2,3], [2,3]); +testJumplist('jumplist_repeat_', ['*', '*', '*', '3', '', '2', ''], [5,0], [2,3]); +testJumplist('jumplist_repeated_motion', ['3', '*', ''], [2,3], [2,3]); +testJumplist('jumplist_/', ['/', ''], [2,3], [2,3], 'dialog'); +testJumplist('jumplist_?', ['?', ''], [2,3], [2,3], 'dialog'); +testJumplist('jumplist_skip_delted_mark', + ['*', 'n', 'n', 'k', 'd', 'k', '', '', ''], + [0,2], [0,2]); +testJumplist('jumplist_skip_delted_mark', + ['*', 'n', 'n', 'k', 'd', 'k', '', '', ''], + [1,0], [0,2]); + +/** + * @param name Name of the test + * @param keys An array of keys or a string with a single key to simulate. + * @param endPos The expected end position of the cursor. + * @param startPos The position the cursor should start at, defaults to 0, 0. + */ +function testMotion(name, keys, endPos, startPos) { + testVim(name, function(cm, vim, helpers) { + if (!startPos) { + startPos = { line: 0, ch: 0 }; + } + cm.setCursor(startPos); + helpers.doKeys(keys); + helpers.assertCursorAt(endPos); + }); +} + +function makeCursor(line, ch) { + return { line: line, ch: ch }; +} + +function offsetCursor(cur, offsetLine, offsetCh) { + return { line: cur.line + offsetLine, ch: cur.ch + offsetCh }; +} + +// Motion tests +testMotion('|', '|', makeCursor(0, 0), makeCursor(0,4)); +testMotion('|_repeat', ['3', '|'], makeCursor(0, 2), makeCursor(0,4)); +testMotion('h', 'h', makeCursor(0, 0), word1.start); +testMotion('h_repeat', ['3', 'h'], offsetCursor(word1.end, 0, -3), word1.end); +testMotion('l', 'l', makeCursor(0, 1)); +testMotion('l_repeat', ['2', 'l'], makeCursor(0, 2)); +testMotion('j', 'j', offsetCursor(word1.end, 1, 0), word1.end); +testMotion('j_repeat', ['2', 'j'], offsetCursor(word1.end, 2, 0), word1.end); +testMotion('j_repeat_clip', ['1000', 'j'], endOfDocument); +testMotion('k', 'k', offsetCursor(word3.end, -1, 0), word3.end); +testMotion('k_repeat', ['2', 'k'], makeCursor(0, 4), makeCursor(2, 4)); +testMotion('k_repeat_clip', ['1000', 'k'], makeCursor(0, 4), makeCursor(2, 4)); +testMotion('w', 'w', word1.start); +testMotion('w_multiple_newlines_no_space', 'w', makeCursor(12, 2), makeCursor(11, 2)); +testMotion('w_multiple_newlines_with_space', 'w', makeCursor(14, 0), makeCursor(12, 51)); +testMotion('w_repeat', ['2', 'w'], word2.start); +testMotion('w_wrap', ['w'], word3.start, word2.start); +testMotion('w_endOfDocument', 'w', endOfDocument, endOfDocument); +testMotion('w_start_to_end', ['1000', 'w'], endOfDocument, makeCursor(0, 0)); +testMotion('W', 'W', bigWord1.start); +testMotion('W_repeat', ['2', 'W'], bigWord3.start, bigWord1.start); +testMotion('e', 'e', word1.end); +testMotion('e_repeat', ['2', 'e'], word2.end); +testMotion('e_wrap', 'e', word3.end, word2.end); +testMotion('e_endOfDocument', 'e', endOfDocument, endOfDocument); +testMotion('e_start_to_end', ['1000', 'e'], endOfDocument, makeCursor(0, 0)); +testMotion('b', 'b', word3.start, word3.end); +testMotion('b_repeat', ['2', 'b'], word2.start, word3.end); +testMotion('b_wrap', 'b', word2.start, word3.start); +testMotion('b_startOfDocument', 'b', makeCursor(0, 0), makeCursor(0, 0)); +testMotion('b_end_to_start', ['1000', 'b'], makeCursor(0, 0), endOfDocument); +testMotion('ge', ['g', 'e'], word2.end, word3.end); +testMotion('ge_repeat', ['2', 'g', 'e'], word1.end, word3.start); +testMotion('ge_wrap', ['g', 'e'], word2.end, word3.start); +testMotion('ge_startOfDocument', ['g', 'e'], makeCursor(0, 0), + makeCursor(0, 0)); +testMotion('ge_end_to_start', ['1000', 'g', 'e'], makeCursor(0, 0), endOfDocument); +testMotion('gg', ['g', 'g'], makeCursor(lines[0].line, lines[0].textStart), + makeCursor(3, 1)); +testMotion('gg_repeat', ['3', 'g', 'g'], + makeCursor(lines[2].line, lines[2].textStart)); +testMotion('G', 'G', + makeCursor(lines[lines.length - 1].line, lines[lines.length - 1].textStart), + makeCursor(3, 1)); +testMotion('G_repeat', ['3', 'G'], makeCursor(lines[2].line, + lines[2].textStart)); +// TODO: Make the test code long enough to test Ctrl-F and Ctrl-B. +testMotion('0', '0', makeCursor(0, 0), makeCursor(0, 8)); +testMotion('^', '^', makeCursor(0, lines[0].textStart), makeCursor(0, 8)); +testMotion('+', '+', makeCursor(1, lines[1].textStart), makeCursor(0, 8)); +testMotion('-', '-', makeCursor(0, lines[0].textStart), makeCursor(1, 4)); +testMotion('_', ['6','_'], makeCursor(5, lines[5].textStart), makeCursor(0, 8)); +testMotion('$', '$', makeCursor(0, lines[0].length - 1), makeCursor(0, 1)); +testMotion('$_repeat', ['2', '$'], makeCursor(1, lines[1].length - 1), + makeCursor(0, 3)); +testMotion('f', ['f', 'p'], pChars[0], makeCursor(charLine.line, 0)); +testMotion('f_repeat', ['2', 'f', 'p'], pChars[2], pChars[0]); +testMotion('f_num', ['f', '2'], numChars[2], makeCursor(charLine.line, 0)); +testMotion('t', ['t','p'], offsetCursor(pChars[0], 0, -1), + makeCursor(charLine.line, 0)); +testMotion('t_repeat', ['2', 't', 'p'], offsetCursor(pChars[2], 0, -1), + pChars[0]); +testMotion('F', ['F', 'p'], pChars[0], pChars[1]); +testMotion('F_repeat', ['2', 'F', 'p'], pChars[0], pChars[2]); +testMotion('T', ['T', 'p'], offsetCursor(pChars[0], 0, 1), pChars[1]); +testMotion('T_repeat', ['2', 'T', 'p'], offsetCursor(pChars[0], 0, 1), pChars[2]); +testMotion('%_parens', ['%'], parens1.end, parens1.start); +testMotion('%_squares', ['%'], squares1.end, squares1.start); +testMotion('%_braces', ['%'], curlys1.end, curlys1.start); +testMotion('%_seek_outside', ['%'], seekOutside.end, seekOutside.start); +testMotion('%_seek_inside', ['%'], seekInside.end, seekInside.start); +testVim('%_seek_skip', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,9); +}, {value:'01234"("()'}); +testVim('%_skip_string', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,4); + cm.setCursor(0,2); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,0); +}, {value:'(")")'}); +testVim('%_skip_comment', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,6); + cm.setCursor(0,3); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,0); +}, {value:'(/*)*/)'}); +// Make sure that moving down after going to the end of a line always leaves you +// at the end of a line, but preserves the offset in other cases +testVim('Changing lines after Eol operation', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys(['$']); + helpers.doKeys(['j']); + // After moving to Eol and then down, we should be at Eol of line 2 + helpers.assertCursorAt({ line: 1, ch: lines[1].length - 1 }); + helpers.doKeys(['j']); + // After moving down, we should be at Eol of line 3 + helpers.assertCursorAt({ line: 2, ch: lines[2].length - 1 }); + helpers.doKeys(['h']); + helpers.doKeys(['j']); + // After moving back one space and then down, since line 4 is shorter than line 2, we should + // be at Eol of line 2 - 1 + helpers.assertCursorAt({ line: 3, ch: lines[3].length - 1 }); + helpers.doKeys(['j']); + helpers.doKeys(['j']); + // After moving down again, since line 3 has enough characters, we should be back to the + // same place we were at on line 1 + helpers.assertCursorAt({ line: 5, ch: lines[2].length - 2 }); +}); +//making sure gj and gk recover from clipping +testVim('gj_gk_clipping', function(cm,vim,helpers){ + cm.setCursor(0, 1); + helpers.doKeys('g','j','g','j'); + helpers.assertCursorAt(2, 1); + helpers.doKeys('g','k','g','k'); + helpers.assertCursorAt(0, 1); +},{value: 'line 1\n\nline 2'}); +//testing a mix of j/k and gj/gk +testVim('j_k_and_gj_gk', function(cm,vim,helpers){ + cm.setSize(120); + cm.setCursor(0, 0); + //go to the last character on the first line + helpers.doKeys('$'); + //move up/down on the column within the wrapped line + //side-effect: cursor is not locked to eol anymore + helpers.doKeys('g','k'); + var cur=cm.getCursor(); + eq(cur.line,0); + is((cur.ch<176),'gk didn\'t move cursor back (1)'); + helpers.doKeys('g','j'); + helpers.assertCursorAt(0, 176); + //should move to character 177 on line 2 (j/k preserve character index within line) + helpers.doKeys('j'); + //due to different line wrapping, the cursor can be on a different screen-x now + //gj and gk preserve screen-x on movement, much like moveV + helpers.doKeys('3','g','k'); + cur=cm.getCursor(); + eq(cur.line,1); + is((cur.ch<176),'gk didn\'t move cursor back (2)'); + helpers.doKeys('g','j','2','g','j'); + //should return to the same character-index + helpers.doKeys('k'); + helpers.assertCursorAt(0, 176); +},{ lineWrapping:true, value: 'This line is intentially long to test movement of gj and gk over wrapped lines. I will start on the end of this line, then make a step up and back to set the origin for j and k.\nThis line is supposed to be even longer than the previous. I will jump here and make another wiggle with gj and gk, before I jump back to the line above. Both wiggles should not change my cursor\'s target character but both j/k and gj/gk change each other\'s reference position.'}); +testVim('gj_gk', function(cm, vim, helpers) { + if (phantom) return; + cm.setSize(120); + // Test top of document edge case. + cm.setCursor(0, 4); + helpers.doKeys('g', 'j'); + helpers.doKeys('10', 'g', 'k'); + helpers.assertCursorAt(0, 4); + + // Test moving down preserves column position. + helpers.doKeys('g', 'j'); + var pos1 = cm.getCursor(); + var expectedPos2 = { line: 0, ch: (pos1.ch - 4) * 2 + 4}; + helpers.doKeys('g', 'j'); + helpers.assertCursorAt(expectedPos2); + + // Move to the last character + cm.setCursor(0, 0); + // Move left to reset HSPos + helpers.doKeys('h'); + // Test bottom of document edge case. + helpers.doKeys('100', 'g', 'j'); + var endingPos = cm.getCursor(); + is(endingPos != 0, 'gj should not be on wrapped line 0'); + var topLeftCharCoords = cm.charCoords(makeCursor(0, 0)); + var endingCharCoords = cm.charCoords(endingPos); + is(topLeftCharCoords.left == endingCharCoords.left, 'gj should end up on column 0'); +},{ lineNumbers: false, lineWrapping:true, value: 'Thislineisintentiallylongtotestmovementofgjandgkoverwrappedlines.' }); +testVim('}', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('}'); + helpers.assertCursorAt(1, 0); + cm.setCursor(0, 0); + helpers.doKeys('2', '}'); + helpers.assertCursorAt(4, 0); + cm.setCursor(0, 0); + helpers.doKeys('6', '}'); + helpers.assertCursorAt(5, 0); +}, { value: 'a\n\nb\nc\n\nd' }); +testVim('{', function(cm, vim, helpers) { + cm.setCursor(5, 0); + helpers.doKeys('{'); + helpers.assertCursorAt(4, 0); + cm.setCursor(5, 0); + helpers.doKeys('2', '{'); + helpers.assertCursorAt(1, 0); + cm.setCursor(5, 0); + helpers.doKeys('6', '{'); + helpers.assertCursorAt(0, 0); +}, { value: 'a\n\nb\nc\n\nd' }); +testVim('paragraph_motions', function(cm, vim, helpers) { + cm.setCursor(10, 0); + helpers.doKeys('{'); + helpers.assertCursorAt(4, 0); + helpers.doKeys('{'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('2', '}'); + helpers.assertCursorAt(7, 0); + helpers.doKeys('2', '}'); + helpers.assertCursorAt(16, 0); + + cm.setCursor(9, 0); + helpers.doKeys('}'); + helpers.assertCursorAt(14, 0); + + cm.setCursor(6, 0); + helpers.doKeys('}'); + helpers.assertCursorAt(7, 0); + + // ip inside empty space + cm.setCursor(10, 0); + helpers.doKeys('v', 'i', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(12, 0), cm.getCursor('head')); + helpers.doKeys('i', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(13, 1), cm.getCursor('head')); + helpers.doKeys('2', 'i', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(16, 1), cm.getCursor('head')); + + // should switch to visualLine mode + cm.setCursor(14, 0); + helpers.doKeys('', 'v', 'i', 'p'); + helpers.assertCursorAt(14, 0); + + cm.setCursor(14, 0); + helpers.doKeys('', 'V', 'i', 'p'); + eqPos(Pos(16, 1), cm.getCursor('head')); + + // ap inside empty space + cm.setCursor(10, 0); + helpers.doKeys('', 'v', 'a', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(13, 1), cm.getCursor('head')); + helpers.doKeys('a', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(16, 1), cm.getCursor('head')); + + cm.setCursor(13, 0); + helpers.doKeys('v', 'a', 'p'); + eqPos(Pos(13, 0), cm.getCursor('anchor')); + eqPos(Pos(14, 0), cm.getCursor('head')); + + cm.setCursor(16, 0); + helpers.doKeys('v', 'a', 'p'); + eqPos(Pos(14, 0), cm.getCursor('anchor')); + eqPos(Pos(16, 1), cm.getCursor('head')); + + cm.setCursor(0, 0); + helpers.doKeys('v', 'a', 'p'); + eqPos(Pos(0, 0), cm.getCursor('anchor')); + eqPos(Pos(4, 0), cm.getCursor('head')); + + cm.setCursor(0, 0); + helpers.doKeys('d', 'i', 'p'); + var register = helpers.getRegisterController().getRegister(); + eq('a\na\n', register.toString()); + is(register.linewise); + helpers.doKeys('3', 'j', 'p'); + helpers.doKeys('y', 'i', 'p'); + is(register.linewise); + eq('b\na\na\nc\n', register.toString()); +}, { value: 'a\na\n\n\n\nb\nc\n\n\n\n\n\n\nd\n\ne\nf' }); + +// Operator tests +testVim('dl', function(cm, vim, helpers) { + var curStart = makeCursor(0, 0); + cm.setCursor(curStart); + helpers.doKeys('d', 'l'); + eq('word1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' ', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 ' }); +testVim('dl_eol', function(cm, vim, helpers) { + cm.setCursor(0, 6); + helpers.doKeys('d', 'l'); + eq(' word1', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' ', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 5); +}, { value: ' word1 ' }); +testVim('dl_repeat', function(cm, vim, helpers) { + var curStart = makeCursor(0, 0); + cm.setCursor(curStart); + helpers.doKeys('2', 'd', 'l'); + eq('ord1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' w', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 ' }); +testVim('dh', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'h'); + eq(' wrd1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('o', register.toString()); + is(!register.linewise); + eqPos(offsetCursor(curStart, 0 , -1), cm.getCursor()); +}, { value: ' word1 ' }); +testVim('dj', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'j'); + eq(' word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' word1\nword2\n', register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\nword2\n word3' }); +testVim('dj_end_of_document', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'j'); + eq(' word1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1 ' }); +testVim('dk', function(cm, vim, helpers) { + var curStart = makeCursor(1, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'k'); + eq(' word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' word1\nword2\n', register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\nword2\n word3' }); +testVim('dk_start_of_document', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'k'); + eq(' word1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1 ' }); +testVim('dw_space', function(cm, vim, helpers) { + var curStart = makeCursor(0, 0); + cm.setCursor(curStart); + helpers.doKeys('d', 'w'); + eq('word1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' ', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 ' }); +testVim('dw_word', function(cm, vim, helpers) { + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('d', 'w'); + eq(' word2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1 ', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 word2' }); +testVim('dw_unicode_word', function(cm, vim, helpers) { + helpers.doKeys('d', 'w'); + eq(cm.getValue().length, 10); + helpers.doKeys('d', 'w'); + eq(cm.getValue().length, 6); + helpers.doKeys('d', 'w'); + eq(cm.getValue().length, 5); + helpers.doKeys('d', 'e'); + eq(cm.getValue().length, 2); +}, { value: ' \u0562\u0561\u0580\u0587\xbbe\xb5g ' }); +testVim('dw_only_word', function(cm, vim, helpers) { + // Test that if there is only 1 word left, dw deletes till the end of the + // line. + cm.setCursor(0, 1); + helpers.doKeys('d', 'w'); + eq(' ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1 ', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 0); +}, { value: ' word1 ' }); +testVim('dw_eol', function(cm, vim, helpers) { + // Assert that dw does not delete the newline if last word to delete is at end + // of line. + cm.setCursor(0, 1); + helpers.doKeys('d', 'w'); + eq(' \nword2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 0); +}, { value: ' word1\nword2' }); +testVim('dw_eol_with_multiple_newlines', function(cm, vim, helpers) { + // Assert that dw does not delete the newline if last word to delete is at end + // of line and it is followed by multiple newlines. + cm.setCursor(0, 1); + helpers.doKeys('d', 'w'); + eq(' \n\nword2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 0); +}, { value: ' word1\n\nword2' }); +testVim('dw_empty_line_followed_by_whitespace', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq(' \nword', cm.getValue()); +}, { value: '\n \nword' }); +testVim('dw_empty_line_followed_by_word', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('word', cm.getValue()); +}, { value: '\nword' }); +testVim('dw_empty_line_followed_by_empty_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('\n', cm.getValue()); +}, { value: '\n\n' }); +testVim('dw_whitespace_followed_by_whitespace', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('\n \n', cm.getValue()); +}, { value: ' \n \n' }); +testVim('dw_whitespace_followed_by_empty_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('\n\n', cm.getValue()); +}, { value: ' \n\n' }); +testVim('dw_word_whitespace_word', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('\n \nword2', cm.getValue()); +}, { value: 'word1\n \nword2'}) +testVim('dw_end_of_document', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('d', 'w'); + eq('\nab', cm.getValue()); +}, { value: '\nabc' }); +testVim('dw_repeat', function(cm, vim, helpers) { + // Assert that dw does delete newline if it should go to the next line, and + // that repeat works properly. + cm.setCursor(0, 1); + helpers.doKeys('d', '2', 'w'); + eq(' ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1\nword2', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 0); +}, { value: ' word1\nword2' }); +testVim('de_word_start_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'e'); + eq('\n\n', cm.getValue()); +}, { value: 'word\n\n' }); +testVim('de_word_end_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(0, 3); + helpers.doKeys('d', 'e'); + eq('wor', cm.getValue()); +}, { value: 'word\n\n\n' }); +testVim('de_whitespace_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'e'); + eq('', cm.getValue()); +}, { value: ' \n\n\n' }); +testVim('de_end_of_document', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('d', 'e'); + eq('\nab', cm.getValue()); +}, { value: '\nabc' }); +testVim('db_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('d', 'b'); + eq('\n\n', cm.getValue()); +}, { value: '\n\n\n' }); +testVim('db_word_start_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('d', 'b'); + eq('\nword', cm.getValue()); +}, { value: '\n\nword' }); +testVim('db_word_end_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 3); + helpers.doKeys('d', 'b'); + eq('\n\nd', cm.getValue()); +}, { value: '\n\nword' }); +testVim('db_whitespace_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('d', 'b'); + eq('', cm.getValue()); +}, { value: '\n \n' }); +testVim('db_start_of_document', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'b'); + eq('abc\n', cm.getValue()); +}, { value: 'abc\n' }); +testVim('dge_empty_lines', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doKeys('d', 'g', 'e'); + // Note: In real VIM the result should be '', but it's not quite consistent, + // since 2 newlines are deleted. But in the similar case of word\n\n, only + // 1 newline is deleted. We'll diverge from VIM's behavior since it's much + // easier this way. + eq('\n', cm.getValue()); +}, { value: '\n\n' }); +testVim('dge_word_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doKeys('d', 'g', 'e'); + eq('wor\n', cm.getValue()); +}, { value: 'word\n\n'}); +testVim('dge_whitespace_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('d', 'g', 'e'); + eq('', cm.getValue()); +}, { value: '\n \n' }); +testVim('dge_start_of_document', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'g', 'e'); + eq('bc\n', cm.getValue()); +}, { value: 'abc\n' }); +testVim('d_inclusive', function(cm, vim, helpers) { + // Assert that when inclusive is set, the character the cursor is on gets + // deleted too. + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('d', 'e'); + eq(' ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 ' }); +testVim('d_reverse', function(cm, vim, helpers) { + // Test that deleting in reverse works. + cm.setCursor(1, 0); + helpers.doKeys('d', 'b'); + eq(' word2 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1\n', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\nword2 ' }); +testVim('dd', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 1, ch: 0 }); + var expectedLineCount = cm.lineCount() - 1; + helpers.doKeys('d', 'd'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, lines[1].textStart); +}); +testVim('dd_prefix_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 2, ch: 0 }); + var expectedLineCount = cm.lineCount() - 2; + helpers.doKeys('2', 'd', 'd'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, lines[2].textStart); +}); +testVim('dd_motion_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 2, ch: 0 }); + var expectedLineCount = cm.lineCount() - 2; + helpers.doKeys('d', '2', 'd'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, lines[2].textStart); +}); +testVim('dd_multiply_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 6, ch: 0 }); + var expectedLineCount = cm.lineCount() - 6; + helpers.doKeys('2', 'd', '3', 'd'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, lines[6].textStart); +}); +testVim('dd_lastline', function(cm, vim, helpers) { + cm.setCursor(cm.lineCount(), 0); + var expectedLineCount = cm.lineCount() - 1; + helpers.doKeys('d', 'd'); + eq(expectedLineCount, cm.lineCount()); + helpers.assertCursorAt(cm.lineCount() - 1, 0); +}); +testVim('dd_only_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + var expectedRegister = cm.getValue() + "\n"; + helpers.doKeys('d','d'); + eq(1, cm.lineCount()); + eq('', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedRegister, register.toString()); +}, { value: "thisistheonlyline" }); +// Yank commands should behave the exact same as d commands, expect that nothing +// gets deleted. +testVim('yw_repeat', function(cm, vim, helpers) { + // Assert that yw does yank newline if it should go to the next line, and + // that repeat works properly. + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('y', '2', 'w'); + eq(' word1\nword2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1\nword2', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1\nword2' }); +testVim('yy_multiply_repeat', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 6, ch: 0 }); + var expectedLineCount = cm.lineCount(); + helpers.doKeys('2', 'y', '3', 'y'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + eqPos(curStart, cm.getCursor()); +}); +// Change commands behave like d commands except that it also enters insert +// mode. In addition, when the change is linewise, an additional newline is +// inserted so that insert mode starts on that line. +testVim('cw', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('c', '2', 'w'); + eq(' word3', cm.getValue()); + helpers.assertCursorAt(0, 0); +}, { value: 'word1 word2 word3'}); +testVim('cw_repeat', function(cm, vim, helpers) { + // Assert that cw does delete newline if it should go to the next line, and + // that repeat works properly. + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('c', '2', 'w'); + eq(' ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1\nword2', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: ' word1\nword2' }); +testVim('cc_multiply_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 6, ch: 0 }); + var expectedLineCount = cm.lineCount() - 5; + helpers.doKeys('2', 'c', '3', 'c'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('ct', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('c', 't', 'w'); + eq(' word1 word3', cm.getValue()); + helpers.doKeys('', 'c', '|'); + eq(' word3', cm.getValue()); + helpers.assertCursorAt(0, 0); + helpers.doKeys('', '2', 'u', 'w', 'h'); + helpers.doKeys('c', '2', 'g', 'e'); + eq(' wordword3', cm.getValue()); +}, { value: ' word1 word2 word3'}); +testVim('cc_should_not_append_to_document', function(cm, vim, helpers) { + var expectedLineCount = cm.lineCount(); + cm.setCursor(cm.lastLine(), 0); + helpers.doKeys('c', 'c'); + eq(expectedLineCount, cm.lineCount()); +}); +function fillArray(val, times) { + var arr = []; + for (var i = 0; i < times; i++) { + arr.push(val); + } + return arr; +} +testVim('c_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'l', 'l', 'c'); + var replacement = fillArray('hello', 3); + cm.replaceSelections(replacement); + eq('1hello\n5hello\nahellofg', cm.getValue()); + helpers.doKeys(''); + cm.setCursor(2, 3); + helpers.doKeys('', '2', 'k', 'h', 'C'); + replacement = fillArray('world', 3); + cm.replaceSelections(replacement); + eq('1hworld\n5hworld\nahworld', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); +testVim('c_visual_block_replay', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'c'); + var replacement = fillArray('fo', 3); + cm.replaceSelections(replacement); + eq('1fo4\n5fo8\nafodefg', cm.getValue()); + helpers.doKeys(''); + cm.setCursor(0, 0); + helpers.doKeys('.'); + eq('foo4\nfoo8\nfoodefg', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); + +testVim('d_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'l', 'l', 'd'); + eq('1\n5\nafg', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); +testVim('D_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'D'); + eq('1\n5\na', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); + +testVim('s_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'l', 'l', 's'); + var replacement = fillArray('hello{', 3); + cm.replaceSelections(replacement); + eq('1hello{\n5hello{\nahello{fg\n', cm.getValue()); + helpers.doKeys(''); + cm.setCursor(2, 3); + helpers.doKeys('', '1', 'k', 'h', 'S'); + replacement = fillArray('world', 1); + cm.replaceSelections(replacement); + eq('1hello{\n world\n', cm.getValue()); +}, {value: '1234\n5678\nabcdefg\n'}); + +// Swapcase commands edit in place and do not modify registers. +testVim('g~w_repeat', function(cm, vim, helpers) { + // Assert that dw does delete newline if it should go to the next line, and + // that repeat works properly. + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('g', '~', '2', 'w'); + eq(' WORD1\nWORD2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1\nword2' }); +testVim('g~g~', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + var expectedLineCount = cm.lineCount(); + var expectedValue = cm.getValue().toUpperCase(); + helpers.doKeys('2', 'g', '~', '3', 'g', '~'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1\nword2\nword3\nword4\nword5\nword6' }); +testVim('gu_and_gU', function(cm, vim, helpers) { + var curStart = makeCursor(0, 7); + var value = cm.getValue(); + cm.setCursor(curStart); + helpers.doKeys('2', 'g', 'U', 'w'); + eq(cm.getValue(), 'wa wb xX WC wd'); + eqPos(curStart, cm.getCursor()); + helpers.doKeys('2', 'g', 'u', 'w'); + eq(cm.getValue(), value); + + helpers.doKeys('2', 'g', 'U', 'B'); + eq(cm.getValue(), 'wa WB Xx wc wd'); + eqPos(makeCursor(0, 3), cm.getCursor()); + + cm.setCursor(makeCursor(0, 4)); + helpers.doKeys('g', 'u', 'i', 'w'); + eq(cm.getValue(), 'wa wb Xx wc wd'); + eqPos(makeCursor(0, 3), cm.getCursor()); + + // TODO: support gUgU guu + // eqPos(makeCursor(0, 0), cm.getCursor()); + + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); +}, { value: 'wa wb xx wc wd' }); +testVim('visual_block_~', function(cm, vim, helpers) { + cm.setCursor(1, 1); + helpers.doKeys('', 'l', 'l', 'j', '~'); + helpers.assertCursorAt(1, 1); + eq('hello\nwoRLd\naBCDe', cm.getValue()); + cm.setCursor(2, 0); + helpers.doKeys('v', 'l', 'l', '~'); + helpers.assertCursorAt(2, 0); + eq('hello\nwoRLd\nAbcDe', cm.getValue()); +},{value: 'hello\nwOrld\nabcde' }); +testVim('._swapCase_visualBlock', function(cm, vim, helpers) { + helpers.doKeys('', 'j', 'j', 'l', '~'); + cm.setCursor(0, 3); + helpers.doKeys('.'); + eq('HelLO\nWorLd\nAbcdE', cm.getValue()); +},{value: 'hEllo\nwOrlD\naBcDe' }); +testVim('._delete_visualBlock', function(cm, vim, helpers) { + helpers.doKeys('', 'j', 'x'); + eq('ive\ne\nsome\nsugar', cm.getValue()); + helpers.doKeys('.'); + eq('ve\n\nsome\nsugar', cm.getValue()); + helpers.doKeys('j', 'j', '.'); + eq('ve\n\nome\nugar', cm.getValue()); + helpers.doKeys('u', '', '.'); + eq('ve\n\nme\ngar', cm.getValue()); +},{value: 'give\nme\nsome\nsugar' }); +testVim('>{motion}', function(cm, vim, helpers) { + cm.setCursor(1, 3); + var expectedLineCount = cm.lineCount(); + var expectedValue = ' word1\n word2\nword3 '; + helpers.doKeys('>', 'k'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1\nword2\nword3 ', indentUnit: 2 }); +testVim('>>', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedLineCount = cm.lineCount(); + var expectedValue = ' word1\n word2\nword3 '; + helpers.doKeys('2', '>', '>'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1\nword2\nword3 ', indentUnit: 2 }); +testVim('<{motion}', function(cm, vim, helpers) { + cm.setCursor(1, 3); + var expectedLineCount = cm.lineCount(); + var expectedValue = ' word1\nword2\nword3 '; + helpers.doKeys('<', 'k'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\n word2\nword3 ', indentUnit: 2 }); +testVim('<<', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedLineCount = cm.lineCount(); + var expectedValue = ' word1\nword2\nword3 '; + helpers.doKeys('2', '<', '<'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\n word2\nword3 ', indentUnit: 2 }); + +// Edit tests +function testEdit(name, before, pos, edit, after) { + return testVim(name, function(cm, vim, helpers) { + var ch = before.search(pos) + var line = before.substring(0, ch).split('\n').length - 1; + if (line) { + ch = before.substring(0, ch).split('\n').pop().length; + } + cm.setCursor(line, ch); + helpers.doKeys.apply(this, edit.split('')); + eq(after, cm.getValue()); + }, {value: before}); +} + +// These Delete tests effectively cover word-wise Change, Visual & Yank. +// Tabs are used as differentiated whitespace to catch edge cases. +// Normal word: +testEdit('diw_mid_spc', 'foo \tbAr\t baz', /A/, 'diw', 'foo \t\t baz'); +testEdit('daw_mid_spc', 'foo \tbAr\t baz', /A/, 'daw', 'foo \tbaz'); +testEdit('diw_mid_punct', 'foo \tbAr.\t baz', /A/, 'diw', 'foo \t.\t baz'); +testEdit('daw_mid_punct', 'foo \tbAr.\t baz', /A/, 'daw', 'foo.\t baz'); +testEdit('diw_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'diw', 'foo \t,.\t baz'); +testEdit('daw_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'daw', 'foo \t,.\t baz'); +testEdit('diw_start_spc', 'bAr \tbaz', /A/, 'diw', ' \tbaz'); +testEdit('daw_start_spc', 'bAr \tbaz', /A/, 'daw', 'baz'); +testEdit('diw_start_punct', 'bAr. \tbaz', /A/, 'diw', '. \tbaz'); +testEdit('daw_start_punct', 'bAr. \tbaz', /A/, 'daw', '. \tbaz'); +testEdit('diw_end_spc', 'foo \tbAr', /A/, 'diw', 'foo \t'); +testEdit('daw_end_spc', 'foo \tbAr', /A/, 'daw', 'foo'); +testEdit('diw_end_punct', 'foo \tbAr.', /A/, 'diw', 'foo \t.'); +testEdit('daw_end_punct', 'foo \tbAr.', /A/, 'daw', 'foo.'); +// Big word: +testEdit('diW_mid_spc', 'foo \tbAr\t baz', /A/, 'diW', 'foo \t\t baz'); +testEdit('daW_mid_spc', 'foo \tbAr\t baz', /A/, 'daW', 'foo \tbaz'); +testEdit('diW_mid_punct', 'foo \tbAr.\t baz', /A/, 'diW', 'foo \t\t baz'); +testEdit('daW_mid_punct', 'foo \tbAr.\t baz', /A/, 'daW', 'foo \tbaz'); +testEdit('diW_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'diW', 'foo \t\t baz'); +testEdit('daW_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'daW', 'foo \tbaz'); +testEdit('diW_start_spc', 'bAr\t baz', /A/, 'diW', '\t baz'); +testEdit('daW_start_spc', 'bAr\t baz', /A/, 'daW', 'baz'); +testEdit('diW_start_punct', 'bAr.\t baz', /A/, 'diW', '\t baz'); +testEdit('daW_start_punct', 'bAr.\t baz', /A/, 'daW', 'baz'); +testEdit('diW_end_spc', 'foo \tbAr', /A/, 'diW', 'foo \t'); +testEdit('daW_end_spc', 'foo \tbAr', /A/, 'daW', 'foo'); +testEdit('diW_end_punct', 'foo \tbAr.', /A/, 'diW', 'foo \t'); +testEdit('daW_end_punct', 'foo \tbAr.', /A/, 'daW', 'foo'); +// Deleting text objects +// Open and close on same line +testEdit('di(_open_spc', 'foo (bAr) baz', /\(/, 'di(', 'foo () baz'); +testEdit('di)_open_spc', 'foo (bAr) baz', /\(/, 'di)', 'foo () baz'); +testEdit('dib_open_spc', 'foo (bAr) baz', /\(/, 'dib', 'foo () baz'); +testEdit('da(_open_spc', 'foo (bAr) baz', /\(/, 'da(', 'foo baz'); +testEdit('da)_open_spc', 'foo (bAr) baz', /\(/, 'da)', 'foo baz'); + +testEdit('di(_middle_spc', 'foo (bAr) baz', /A/, 'di(', 'foo () baz'); +testEdit('di)_middle_spc', 'foo (bAr) baz', /A/, 'di)', 'foo () baz'); +testEdit('da(_middle_spc', 'foo (bAr) baz', /A/, 'da(', 'foo baz'); +testEdit('da)_middle_spc', 'foo (bAr) baz', /A/, 'da)', 'foo baz'); + +testEdit('di(_close_spc', 'foo (bAr) baz', /\)/, 'di(', 'foo () baz'); +testEdit('di)_close_spc', 'foo (bAr) baz', /\)/, 'di)', 'foo () baz'); +testEdit('da(_close_spc', 'foo (bAr) baz', /\)/, 'da(', 'foo baz'); +testEdit('da)_close_spc', 'foo (bAr) baz', /\)/, 'da)', 'foo baz'); + +// delete around and inner b. +testEdit('dab_on_(_should_delete_around_()block', 'o( in(abc) )', /\(a/, 'dab', 'o( in )'); + +// delete around and inner B. +testEdit('daB_on_{_should_delete_around_{}block', 'o{ in{abc} }', /{a/, 'daB', 'o{ in }'); +testEdit('diB_on_{_should_delete_inner_{}block', 'o{ in{abc} }', /{a/, 'diB', 'o{ in{} }'); + +testEdit('da{_on_{_should_delete_inner_block', 'o{ in{abc} }', /{a/, 'da{', 'o{ in }'); +testEdit('di[_on_(_should_not_delete', 'foo (bAr) baz', /\(/, 'di[', 'foo (bAr) baz'); +testEdit('di[_on_)_should_not_delete', 'foo (bAr) baz', /\)/, 'di[', 'foo (bAr) baz'); +testEdit('da[_on_(_should_not_delete', 'foo (bAr) baz', /\(/, 'da[', 'foo (bAr) baz'); +testEdit('da[_on_)_should_not_delete', 'foo (bAr) baz', /\)/, 'da[', 'foo (bAr) baz'); +testMotion('di(_outside_should_stay', ['d', 'i', '('], { line: 0, ch: 0}, { line: 0, ch: 0}); + +// Open and close on different lines, equally indented +testEdit('di{_middle_spc', 'a{\n\tbar\n}b', /r/, 'di{', 'a{}b'); +testEdit('di}_middle_spc', 'a{\n\tbar\n}b', /r/, 'di}', 'a{}b'); +testEdit('da{_middle_spc', 'a{\n\tbar\n}b', /r/, 'da{', 'ab'); +testEdit('da}_middle_spc', 'a{\n\tbar\n}b', /r/, 'da}', 'ab'); +testEdit('daB_middle_spc', 'a{\n\tbar\n}b', /r/, 'daB', 'ab'); + +// open and close on diff lines, open indented less than close +testEdit('di{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'di{', 'a{}b'); +testEdit('di}_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'di}', 'a{}b'); +testEdit('da{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'da{', 'ab'); +testEdit('da}_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'da}', 'ab'); + +// open and close on diff lines, open indented more than close +testEdit('di[_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'di[', 'a\t[]b'); +testEdit('di]_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'di]', 'a\t[]b'); +testEdit('da[_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'da[', 'a\tb'); +testEdit('da]_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'da]', 'a\tb'); + +function testSelection(name, before, pos, keys, sel) { + return testVim(name, function(cm, vim, helpers) { + var ch = before.search(pos) + var line = before.substring(0, ch).split('\n').length - 1; + if (line) { + ch = before.substring(0, ch).split('\n').pop().length; + } + cm.setCursor(line, ch); + helpers.doKeys.apply(this, keys.split('')); + eq(sel, cm.getSelection()); + }, {value: before}); +} +testSelection('viw_middle_spc', 'foo \tbAr\t baz', /A/, 'viw', 'bAr'); +testSelection('vaw_middle_spc', 'foo \tbAr\t baz', /A/, 'vaw', 'bAr\t '); +testSelection('viw_middle_punct', 'foo \tbAr,\t baz', /A/, 'viw', 'bAr'); +testSelection('vaW_middle_punct', 'foo \tbAr,\t baz', /A/, 'vaW', 'bAr,\t '); +testSelection('viw_start_spc', 'foo \tbAr\t baz', /b/, 'viw', 'bAr'); +testSelection('viw_end_spc', 'foo \tbAr\t baz', /r/, 'viw', 'bAr'); +testSelection('viw_eol', 'foo \tbAr', /r/, 'viw', 'bAr'); +testSelection('vi{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'vi{', '\n\tbar\n\t'); +testSelection('va{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'va{', '{\n\tbar\n\t}'); + +testVim('mouse_select', function(cm, vim, helpers) { + cm.setSelection(Pos(0, 2), Pos(0, 4), {origin: '*mouse'}); + is(cm.state.vim.visualMode); + is(!cm.state.vim.visualLine); + is(!cm.state.vim.visualBlock); + helpers.doKeys(''); + is(!cm.somethingSelected()); + helpers.doKeys('g', 'v'); + eq('cd', cm.getSelection()); +}, {value: 'abcdef'}); + +// Operator-motion tests +testVim('D', function(cm, vim, helpers) { + cm.setCursor(0, 3); + helpers.doKeys('D'); + eq(' wo\nword2\n word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('rd1', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 2); +}, { value: ' word1\nword2\n word3' }); +testVim('C', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('C'); + eq(' wo\nword2\n word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('rd1', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: ' word1\nword2\n word3' }); +testVim('Y', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('Y'); + eq(' word1\nword2\n word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('rd1', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1\nword2\n word3' }); +testVim('~', function(cm, vim, helpers) { + helpers.doKeys('3', '~'); + eq('ABCdefg', cm.getValue()); + helpers.assertCursorAt(0, 3); +}, { value: 'abcdefg' }); + +// Action tests +testVim('ctrl-a', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys(''); + eq('-9', cm.getValue()); + helpers.assertCursorAt(0, 1); + helpers.doKeys('2',''); + eq('-7', cm.getValue()); +}, {value: '-10'}); +testVim('ctrl-x', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys(''); + eq('-1', cm.getValue()); + helpers.assertCursorAt(0, 1); + helpers.doKeys('2',''); + eq('-3', cm.getValue()); +}, {value: '0'}); +testVim('/ search forward', function(cm, vim, helpers) { + forEach(['', ''], function(key) { + cm.setCursor(0, 0); + helpers.doKeys(key); + helpers.assertCursorAt(0, 5); + helpers.doKeys('l'); + helpers.doKeys(key); + helpers.assertCursorAt(0, 10); + cm.setCursor(0, 11); + helpers.doKeys(key); + helpers.assertCursorAt(0, 11); + }); +}, {value: '__jmp1 jmp2 jmp'}); +testVim('a', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('a'); + helpers.assertCursorAt(0, 2); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('a_eol', function(cm, vim, helpers) { + cm.setCursor(0, lines[0].length - 1); + helpers.doKeys('a'); + helpers.assertCursorAt(0, lines[0].length); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('A_endOfSelectedArea', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('v', 'j', 'l'); + helpers.doKeys('A'); + helpers.assertCursorAt(1, 2); + eq('vim-insert', cm.getOption('keyMap')); +}, {value: 'foo\nbar'}); +testVim('i', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('i'); + helpers.assertCursorAt(0, 1); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('i_repeat', function(cm, vim, helpers) { + helpers.doKeys('3', 'i'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + eq('testtesttest', cm.getValue()); + helpers.assertCursorAt(0, 11); +}, { value: '' }); +testVim('i_repeat_delete', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('2', 'i'); + cm.replaceRange('z', cm.getCursor()); + helpers.doInsertModeKeys('Backspace', 'Backspace'); + helpers.doKeys(''); + eq('abe', cm.getValue()); + helpers.assertCursorAt(0, 1); +}, { value: 'abcde' }); +testVim('A', function(cm, vim, helpers) { + helpers.doKeys('A'); + helpers.assertCursorAt(0, lines[0].length); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('A_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'l', 'A'); + var replacement = new Array(cm.listSelections().length+1).join('hello ').split(' '); + replacement.pop(); + cm.replaceSelections(replacement); + eq('testhello\nmehello\npleahellose', cm.getValue()); + helpers.doKeys(''); + cm.setCursor(0, 0); + helpers.doKeys('.'); + // TODO this doesn't work yet + // eq('teshellothello\nme hello hello\nplehelloahellose', cm.getValue()); +}, {value: 'test\nme\nplease'}); +testVim('I', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('I'); + helpers.assertCursorAt(0, lines[0].textStart); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('I_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('3', 'I'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + eq('testtesttestblah', cm.getValue()); + helpers.assertCursorAt(0, 11); +}, { value: 'blah' }); +testVim('I_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '2', 'j', 'l', 'l', 'I'); + var replacement = new Array(cm.listSelections().length+1).join('hello ').split(' '); + replacement.pop(); + cm.replaceSelections(replacement); + eq('hellotest\nhellome\nhelloplease', cm.getValue()); +}, {value: 'test\nme\nplease'}); +testVim('o', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('o'); + eq('word1\n\nword2', cm.getValue()); + helpers.assertCursorAt(1, 0); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: 'word1\nword2' }); +testVim('o_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('3', 'o'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + eq('\ntest\ntest\ntest', cm.getValue()); + helpers.assertCursorAt(3, 3); +}, { value: '' }); +testVim('O', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('O'); + eq('\nword1\nword2', cm.getValue()); + helpers.assertCursorAt(0, 0); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: 'word1\nword2' }); +testVim('J', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('J'); + var expectedValue = 'word1 word2\nword3\n word4'; + eq(expectedValue, cm.getValue()); + helpers.assertCursorAt(0, expectedValue.indexOf('word2') - 1); +}, { value: 'word1 \n word2\nword3\n word4' }); +testVim('J_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('3', 'J'); + var expectedValue = 'word1 word2 word3\n word4'; + eq(expectedValue, cm.getValue()); + helpers.assertCursorAt(0, expectedValue.indexOf('word3') - 1); +}, { value: 'word1 \n word2\nword3\n word4' }); +testVim('p', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', 'abc\ndef', false); + helpers.doKeys('p'); + eq('__abc\ndef_', cm.getValue()); + helpers.assertCursorAt(1, 2); +}, { value: '___' }); +testVim('p_register', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().getRegister('a').setText('abc\ndef', false); + helpers.doKeys('"', 'a', 'p'); + eq('__abc\ndef_', cm.getValue()); + helpers.assertCursorAt(1, 2); +}, { value: '___' }); +testVim('p_wrong_register', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().getRegister('a').setText('abc\ndef', false); + helpers.doKeys('p'); + eq('___', cm.getValue()); + helpers.assertCursorAt(0, 1); +}, { value: '___' }); +testVim('p_line', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', ' a\nd\n', true); + helpers.doKeys('2', 'p'); + eq('___\n a\nd\n a\nd', cm.getValue()); + helpers.assertCursorAt(1, 2); +}, { value: '___' }); +testVim('p_lastline', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', ' a\nd', true); + helpers.doKeys('2', 'p'); + eq('___\n a\nd\n a\nd', cm.getValue()); + helpers.assertCursorAt(1, 2); +}, { value: '___' }); +testVim(']p_first_indent_is_smaller', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true); + helpers.doKeys(']', 'p'); + eq(' ___\n abc\n def', cm.getValue()); +}, { value: ' ___' }); +testVim(']p_first_indent_is_larger', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true); + helpers.doKeys(']', 'p'); + eq(' ___\n abc\ndef', cm.getValue()); +}, { value: ' ___' }); +testVim(']p_with_tab_indents', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', '\t\tabc\n\t\t\tdef\n', true); + helpers.doKeys(']', 'p'); + eq('\t___\n\tabc\n\t\tdef', cm.getValue()); +}, { value: '\t___', indentWithTabs: true}); +testVim(']p_with_spaces_translated_to_tabs', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true); + helpers.doKeys(']', 'p'); + eq('\t___\n\tabc\n\t\tdef', cm.getValue()); +}, { value: '\t___', indentWithTabs: true, tabSize: 2 }); +testVim('[p', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true); + helpers.doKeys('[', 'p'); + eq(' abc\n def\n ___', cm.getValue()); +}, { value: ' ___' }); +testVim('P', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', 'abc\ndef', false); + helpers.doKeys('P'); + eq('_abc\ndef__', cm.getValue()); + helpers.assertCursorAt(1, 3); +}, { value: '___' }); +testVim('P_line', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', ' a\nd\n', true); + helpers.doKeys('2', 'P'); + eq(' a\nd\n a\nd\n___', cm.getValue()); + helpers.assertCursorAt(0, 2); +}, { value: '___' }); +testVim('r', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('3', 'r', 'u'); + eq('wuuuet\nanother', cm.getValue(),'3r failed'); + helpers.assertCursorAt(0, 3); + cm.setCursor(0, 4); + helpers.doKeys('v', 'j', 'h', 'r', ''); + eq('wuuu \n her', cm.getValue(),'Replacing selection by space-characters failed'); +}, { value: 'wordet\nanother' }); +testVim('r_visual_block', function(cm, vim, helpers) { + cm.setCursor(2, 3); + helpers.doKeys('', 'k', 'k', 'h', 'h', 'r', 'l'); + eq('1lll\n5lll\nalllefg', cm.getValue()); + helpers.doKeys('', 'l', 'j', 'r', ''); + eq('1 l\n5 l\nalllefg', cm.getValue()); + cm.setCursor(2, 0); + helpers.doKeys('o'); + helpers.doKeys(''); + cm.replaceRange('\t\t', cm.getCursor()); + helpers.doKeys('', 'h', 'h', 'r', 'r'); + eq('1 l\n5 l\nalllefg\nrrrrrrrr', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); +testVim('R', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('R'); + helpers.assertCursorAt(0, 1); + eq('vim-replace', cm.getOption('keyMap')); + is(cm.state.overwrite, 'Setting overwrite state failed'); +}); +testVim('mark', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(0, 0); + helpers.doKeys('`', 't'); + helpers.assertCursorAt(2, 2); + cm.setCursor(2, 0); + cm.replaceRange(' h', cm.getCursor()); + cm.setCursor(0, 0); + helpers.doKeys('\'', 't'); + helpers.assertCursorAt(2, 3); +}); +testVim('jumpToMark_next', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(0, 0); + helpers.doKeys(']', '`'); + helpers.assertCursorAt(2, 2); + cm.setCursor(0, 0); + helpers.doKeys(']', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_next_repeat', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(0, 0); + helpers.doKeys('2', ']', '`'); + helpers.assertCursorAt(3, 2); + cm.setCursor(0, 0); + helpers.doKeys('2', ']', '\''); + helpers.assertCursorAt(3, 1); +}); +testVim('jumpToMark_next_sameline', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 4); + helpers.doKeys('m', 'b'); + cm.setCursor(2, 2); + helpers.doKeys(']', '`'); + helpers.assertCursorAt(2, 4); +}); +testVim('jumpToMark_next_onlyprev', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('m', 'a'); + cm.setCursor(4, 0); + helpers.doKeys(']', '`'); + helpers.assertCursorAt(4, 0); +}); +testVim('jumpToMark_next_nomark', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys(']', '`'); + helpers.assertCursorAt(2, 2); + helpers.doKeys(']', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_next_linewise_over', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(3, 4); + helpers.doKeys('m', 'b'); + cm.setCursor(2, 1); + helpers.doKeys(']', '\''); + helpers.assertCursorAt(3, 1); +}); +testVim('jumpToMark_next_action', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(0, 0); + helpers.doKeys('d', ']', '`'); + helpers.assertCursorAt(0, 0); + var actual = cm.getLine(0); + var expected = 'pop pop 0 1 2 3 4'; + eq(actual, expected, "Deleting while jumping to the next mark failed."); +}); +testVim('jumpToMark_next_line_action', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(0, 0); + helpers.doKeys('d', ']', '\''); + helpers.assertCursorAt(0, 1); + var actual = cm.getLine(0); + var expected = ' (a) [b] {c} ' + eq(actual, expected, "Deleting while jumping to the next mark line failed."); +}); +testVim('jumpToMark_prev', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(4, 0); + helpers.doKeys('[', '`'); + helpers.assertCursorAt(2, 2); + cm.setCursor(4, 0); + helpers.doKeys('[', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_prev_repeat', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(5, 0); + helpers.doKeys('2', '[', '`'); + helpers.assertCursorAt(3, 2); + cm.setCursor(5, 0); + helpers.doKeys('2', '[', '\''); + helpers.assertCursorAt(3, 1); +}); +testVim('jumpToMark_prev_sameline', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 4); + helpers.doKeys('m', 'b'); + cm.setCursor(2, 2); + helpers.doKeys('[', '`'); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_prev_onlynext', function(cm, vim, helpers) { + cm.setCursor(4, 4); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 0); + helpers.doKeys('[', '`'); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_prev_nomark', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('[', '`'); + helpers.assertCursorAt(2, 2); + helpers.doKeys('[', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_prev_linewise_over', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(3, 4); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 6); + helpers.doKeys('[', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('delmark_single', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 't'); + helpers.doEx('delmarks t'); + cm.setCursor(0, 0); + helpers.doKeys('`', 't'); + helpers.assertCursorAt(0, 0); +}); +testVim('delmark_range', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'd'); + cm.setCursor(5, 2); + helpers.doKeys('m', 'e'); + helpers.doEx('delmarks b-d'); + cm.setCursor(0, 0); + helpers.doKeys('`', 'a'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'b'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'c'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'd'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'e'); + helpers.assertCursorAt(5, 2); +}); +testVim('delmark_multi', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'd'); + cm.setCursor(5, 2); + helpers.doKeys('m', 'e'); + helpers.doEx('delmarks bcd'); + cm.setCursor(0, 0); + helpers.doKeys('`', 'a'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'b'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'c'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'd'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'e'); + helpers.assertCursorAt(5, 2); +}); +testVim('delmark_multi_space', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'd'); + cm.setCursor(5, 2); + helpers.doKeys('m', 'e'); + helpers.doEx('delmarks b c d'); + cm.setCursor(0, 0); + helpers.doKeys('`', 'a'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'b'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'c'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'd'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'e'); + helpers.assertCursorAt(5, 2); +}); +testVim('delmark_all', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'd'); + cm.setCursor(5, 2); + helpers.doKeys('m', 'e'); + helpers.doEx('delmarks a b-de'); + cm.setCursor(0, 0); + helpers.doKeys('`', 'a'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('`', 'b'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('`', 'c'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('`', 'd'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('`', 'e'); + helpers.assertCursorAt(0, 0); +}); +testVim('visual', function(cm, vim, helpers) { + helpers.doKeys('l', 'v', 'l', 'l'); + helpers.assertCursorAt(0, 4); + eqPos(makeCursor(0, 1), cm.getCursor('anchor')); + helpers.doKeys('d'); + eq('15', cm.getValue()); +}, { value: '12345' }); +testVim('visual_yank', function(cm, vim, helpers) { + helpers.doKeys('v', '3', 'l', 'y'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('p'); + eq('aa te test for yank', cm.getValue()); +}, { value: 'a test for yank' }) +testVim('visual_w', function(cm, vim, helpers) { + helpers.doKeys('v', 'w'); + eq(cm.getSelection(), 'motion t'); +}, { value: 'motion test'}); +testVim('visual_initial_selection', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('v'); + cm.getSelection('n'); +}, { value: 'init'}); +testVim('visual_crossover_left', function(cm, vim, helpers) { + cm.setCursor(0, 2); + helpers.doKeys('v', 'l', 'h', 'h'); + cm.getSelection('ro'); +}, { value: 'cross'}); +testVim('visual_crossover_left', function(cm, vim, helpers) { + cm.setCursor(0, 2); + helpers.doKeys('v', 'h', 'l', 'l'); + cm.getSelection('os'); +}, { value: 'cross'}); +testVim('visual_crossover_up', function(cm, vim, helpers) { + cm.setCursor(3, 2); + helpers.doKeys('v', 'j', 'k', 'k'); + eqPos(Pos(2, 2), cm.getCursor('head')); + eqPos(Pos(3, 3), cm.getCursor('anchor')); + helpers.doKeys('k'); + eqPos(Pos(1, 2), cm.getCursor('head')); + eqPos(Pos(3, 3), cm.getCursor('anchor')); +}, { value: 'cross\ncross\ncross\ncross\ncross\n'}); +testVim('visual_crossover_down', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('v', 'k', 'j', 'j'); + eqPos(Pos(2, 3), cm.getCursor('head')); + eqPos(Pos(1, 2), cm.getCursor('anchor')); + helpers.doKeys('j'); + eqPos(Pos(3, 3), cm.getCursor('head')); + eqPos(Pos(1, 2), cm.getCursor('anchor')); +}, { value: 'cross\ncross\ncross\ncross\ncross\n'}); +testVim('visual_exit', function(cm, vim, helpers) { + helpers.doKeys('', 'l', 'j', 'j', ''); + eqPos(cm.getCursor('anchor'), cm.getCursor('head')); + eq(vim.visualMode, false); +}, { value: 'hello\nworld\nfoo' }); +testVim('visual_line', function(cm, vim, helpers) { + helpers.doKeys('l', 'V', 'l', 'j', 'j', 'd'); + eq(' 4\n 5', cm.getValue()); +}, { value: ' 1\n 2\n 3\n 4\n 5' }); +testVim('visual_block_move_to_eol', function(cm, vim, helpers) { + // moveToEol should move all block cursors to end of line + cm.setCursor(0, 0); + helpers.doKeys('', 'G', '$'); + var selections = cm.getSelections().join(); + eq('123,45,6', selections); + // Checks that with cursor at Infinity, finding words backwards still works. + helpers.doKeys('2', 'k', 'b'); + selections = cm.getSelections().join(); + eq('1', selections); +}, {value: '123\n45\n6'}); +testVim('visual_block_different_line_lengths', function(cm, vim, helpers) { + // test the block selection with lines of different length + // i.e. extending the selection + // till the end of the longest line. + helpers.doKeys('', 'l', 'j', 'j', '6', 'l', 'd'); + helpers.doKeys('d', 'd', 'd', 'd'); + eq('', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); +testVim('visual_block_truncate_on_short_line', function(cm, vim, helpers) { + // check for left side selection in case + // of moving up to a shorter line. + cm.replaceRange('', cm.getCursor()); + cm.setCursor(3, 4); + helpers.doKeys('', 'l', 'k', 'k', 'd'); + eq('hello world\n{\ntis\nsa!', cm.getValue()); +}, {value: 'hello world\n{\nthis is\nsparta!'}); +testVim('visual_block_corners', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('', '2', 'l', 'k'); + // circle around the anchor + // and check the selections + var selections = cm.getSelections(); + eq('345891', selections.join('')); + helpers.doKeys('4', 'h'); + selections = cm.getSelections(); + eq('123678', selections.join('')); + helpers.doKeys('j', 'j'); + selections = cm.getSelections(); + eq('678abc', selections.join('')); + helpers.doKeys('4', 'l'); + selections = cm.getSelections(); + eq('891cde', selections.join('')); +}, {value: '12345\n67891\nabcde'}); +testVim('visual_block_mode_switch', function(cm, vim, helpers) { + // switch between visual modes + cm.setCursor(1, 1); + // blockwise to characterwise visual + helpers.doKeys('', 'j', 'l', 'v'); + var selections = cm.getSelections(); + eq('7891\nabc', selections.join('')); + // characterwise to blockwise + helpers.doKeys(''); + selections = cm.getSelections(); + eq('78bc', selections.join('')); + // blockwise to linewise visual + helpers.doKeys('V'); + selections = cm.getSelections(); + eq('67891\nabcde', selections.join('')); +}, {value: '12345\n67891\nabcde'}); +testVim('visual_block_crossing_short_line', function(cm, vim, helpers) { + // visual block with long and short lines + cm.setCursor(0, 3); + helpers.doKeys('', 'j', 'j', 'j'); + var selections = cm.getSelections().join(); + eq('4,,d,b', selections); + helpers.doKeys('3', 'k'); + selections = cm.getSelections().join(); + eq('4', selections); + helpers.doKeys('5', 'j', 'k'); + selections = cm.getSelections().join(""); + eq(10, selections.length); +}, {value: '123456\n78\nabcdefg\nfoobar\n}\n'}); +testVim('visual_block_curPos_on_exit', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '3' , 'l', ''); + eqPos(makeCursor(0, 3), cm.getCursor()); + helpers.doKeys('h', '', '2' , 'j' ,'3' , 'l'); + eq(cm.getSelections().join(), "3456,,cdef"); + helpers.doKeys('4' , 'h'); + eq(cm.getSelections().join(), "23,8,bc"); + helpers.doKeys('2' , 'l'); + eq(cm.getSelections().join(), "34,,cd"); +}, {value: '123456\n78\nabcdefg\nfoobar'}); + +testVim('visual_marks', function(cm, vim, helpers) { + helpers.doKeys('l', 'v', 'l', 'l', 'j', 'j', 'v'); + // Test visual mode marks + cm.setCursor(2, 1); + helpers.doKeys('\'', '<'); + helpers.assertCursorAt(0, 1); + helpers.doKeys('\'', '>'); + helpers.assertCursorAt(2, 0); +}); +testVim('visual_join', function(cm, vim, helpers) { + helpers.doKeys('l', 'V', 'l', 'j', 'j', 'J'); + eq(' 1 2 3\n 4\n 5', cm.getValue()); + is(!vim.visualMode); +}, { value: ' 1\n 2\n 3\n 4\n 5' }); +testVim('visual_join_2', function(cm, vim, helpers) { + helpers.doKeys('G', 'V', 'g', 'g', 'J'); + eq('1 2 3 4 5 6 ', cm.getValue()); + is(!vim.visualMode); +}, { value: '1\n2\n3\n4\n5\n6\n'}); +testVim('visual_blank', function(cm, vim, helpers) { + helpers.doKeys('v', 'k'); + eq(vim.visualMode, true); +}, { value: '\n' }); +testVim('reselect_visual', function(cm, vim, helpers) { + helpers.doKeys('l', 'v', 'l', 'l', 'l', 'y', 'g', 'v'); + helpers.assertCursorAt(0, 5); + eqPos(makeCursor(0, 1), cm.getCursor('anchor')); + helpers.doKeys('v'); + cm.setCursor(1, 0); + helpers.doKeys('v', 'l', 'l', 'p'); + eq('123456\n2345\nbar', cm.getValue()); + cm.setCursor(0, 0); + helpers.doKeys('g', 'v'); + // here the fake cursor is at (1, 3) + helpers.assertCursorAt(1, 4); + eqPos(makeCursor(1, 0), cm.getCursor('anchor')); + helpers.doKeys('v'); + cm.setCursor(2, 0); + helpers.doKeys('v', 'l', 'l', 'g', 'v'); + helpers.assertCursorAt(1, 4); + eqPos(makeCursor(1, 0), cm.getCursor('anchor')); + helpers.doKeys('g', 'v'); + helpers.assertCursorAt(2, 3); + eqPos(makeCursor(2, 0), cm.getCursor('anchor')); + eq('123456\n2345\nbar', cm.getValue()); +}, { value: '123456\nfoo\nbar' }); +testVim('reselect_visual_line', function(cm, vim, helpers) { + helpers.doKeys('l', 'V', 'j', 'j', 'V', 'g', 'v', 'd'); + eq('foo\nand\nbar', cm.getValue()); + cm.setCursor(1, 0); + helpers.doKeys('V', 'y', 'j'); + helpers.doKeys('V', 'p' , 'g', 'v', 'd'); + eq('foo\nand', cm.getValue()); +}, { value: 'hello\nthis\nis\nfoo\nand\nbar' }); +testVim('reselect_visual_block', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('', 'k', 'h', ''); + cm.setCursor(2, 1); + helpers.doKeys('v', 'l', 'g', 'v'); + eqPos(Pos(1, 2), vim.sel.anchor); + eqPos(Pos(0, 1), vim.sel.head); + // Ensure selection is done with visual block mode rather than one + // continuous range. + eq(cm.getSelections().join(''), '23oo') + helpers.doKeys('g', 'v'); + eqPos(Pos(2, 1), vim.sel.anchor); + eqPos(Pos(2, 2), vim.sel.head); + helpers.doKeys(''); + // Ensure selection of deleted range + cm.setCursor(1, 1); + helpers.doKeys('v', '', 'j', 'd', 'g', 'v'); + eq(cm.getSelections().join(''), 'or'); +}, { value: '123456\nfoo\nbar' }); +testVim('s_normal', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('s'); + helpers.doKeys(''); + eq('ac', cm.getValue()); +}, { value: 'abc'}); +testVim('s_visual', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('v', 's'); + helpers.doKeys(''); + helpers.assertCursorAt(0, 0); + eq('ac', cm.getValue()); +}, { value: 'abc'}); +testVim('o_visual', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys('v','l','l','l','o'); + helpers.assertCursorAt(0,0); + helpers.doKeys('v','v','j','j','j','o'); + helpers.assertCursorAt(0,0); + helpers.doKeys('O'); + helpers.doKeys('l','l') + helpers.assertCursorAt(3, 3); + helpers.doKeys('d'); + eq('p',cm.getValue()); +}, { value: 'abcd\nefgh\nijkl\nmnop'}); +testVim('o_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('','3','j','l','l', 'o'); + eqPos(Pos(3, 3), vim.sel.anchor); + eqPos(Pos(0, 1), vim.sel.head); + helpers.doKeys('O'); + eqPos(Pos(3, 1), vim.sel.anchor); + eqPos(Pos(0, 3), vim.sel.head); + helpers.doKeys('o'); + eqPos(Pos(0, 3), vim.sel.anchor); + eqPos(Pos(3, 1), vim.sel.head); +}, { value: 'abcd\nefgh\nijkl\nmnop'}); +testVim('changeCase_visual', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('v', 'l', 'l'); + helpers.doKeys('U'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('v', 'l', 'l'); + helpers.doKeys('u'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('l', 'l', 'l', '.'); + helpers.assertCursorAt(0, 3); + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', 'v', 'j', 'U', 'q'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('j', '@', 'a'); + helpers.assertCursorAt(1, 0); + cm.setCursor(3, 0); + helpers.doKeys('V', 'U', 'j', '.'); + eq('ABCDEF\nGHIJKL\nMnopq\nSHORT LINE\nLONG LINE OF TEXT', cm.getValue()); +}, { value: 'abcdef\nghijkl\nmnopq\nshort line\nlong line of text'}); +testVim('changeCase_visual_block', function(cm, vim, helpers) { + cm.setCursor(2, 1); + helpers.doKeys('', 'k', 'k', 'h', 'U'); + eq('ABcdef\nGHijkl\nMNopq\nfoo', cm.getValue()); + cm.setCursor(0, 2); + helpers.doKeys('.'); + eq('ABCDef\nGHIJkl\nMNOPq\nfoo', cm.getValue()); + // check when last line is shorter. + cm.setCursor(2, 2); + helpers.doKeys('.'); + eq('ABCDef\nGHIJkl\nMNOPq\nfoO', cm.getValue()); +}, { value: 'abcdef\nghijkl\nmnopq\nfoo'}); +testVim('visual_paste', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('v', 'l', 'l', 'y'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('3', 'l', 'j', 'v', 'l', 'p'); + helpers.assertCursorAt(1, 5); + eq('this is a\nunithitest for visual paste', cm.getValue()); + cm.setCursor(0, 0); + // in case of pasting whole line + helpers.doKeys('y', 'y'); + cm.setCursor(1, 6); + helpers.doKeys('v', 'l', 'l', 'l', 'p'); + helpers.assertCursorAt(2, 0); + eq('this is a\nunithi\nthis is a\n for visual paste', cm.getValue()); +}, { value: 'this is a\nunit test for visual paste'}); + +// This checks the contents of the register used to paste the text +testVim('v_paste_from_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'w'); + cm.setCursor(1, 0); + helpers.doKeys('v', 'p'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+register/.test(text)); + }); +}, { value: 'register contents\nare not erased'}); +testVim('S_normal', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('j', 'S'); + helpers.doKeys(''); + helpers.assertCursorAt(1, 1); + eq('aa{\n \ncc', cm.getValue()); + helpers.doKeys('j', 'S'); + eq('aa{\n \n ', cm.getValue()); + helpers.assertCursorAt(2, 2); + helpers.doKeys(''); + helpers.doKeys('d', 'd', 'd', 'd'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('S'); + is(vim.insertMode); + eq('', cm.getValue()); +}, { value: 'aa{\nbb\ncc'}); +testVim('blockwise_paste', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '3', 'j', 'l', 'y'); + cm.setCursor(0, 2); + // paste one char after the current cursor position + helpers.doKeys('p'); + eq('helhelo\nworwold\nfoofo\nbarba', cm.getValue()); + cm.setCursor(0, 0); + helpers.doKeys('v', '4', 'l', 'y'); + cm.setCursor(0, 0); + helpers.doKeys('', '3', 'j', 'p'); + eq('helheelhelo\norwold\noofo\narba', cm.getValue()); +}, { value: 'hello\nworld\nfoo\nbar'}); +testVim('blockwise_paste_long/short_line', function(cm, vim, helpers) { + // extend short lines in case of different line lengths. + cm.setCursor(0, 0); + helpers.doKeys('', 'j', 'j', 'y'); + cm.setCursor(0, 3); + helpers.doKeys('p'); + eq('hellho\nfoo f\nbar b', cm.getValue()); +}, { value: 'hello\nfoo\nbar'}); +testVim('blockwise_paste_cut_paste', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '2', 'j', 'x'); + cm.setCursor(0, 0); + helpers.doKeys('P'); + eq('cut\nand\npaste\nme', cm.getValue()); +}, { value: 'cut\nand\npaste\nme'}); +testVim('blockwise_paste_from_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '2', 'j', '"', 'a', 'y'); + cm.setCursor(0, 3); + helpers.doKeys('"', 'a', 'p'); + eq('foobfar\nhellho\nworlwd', cm.getValue()); +}, { value: 'foobar\nhello\nworld'}); +testVim('blockwise_paste_last_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '2', 'j', 'l', 'y'); + cm.setCursor(3, 0); + helpers.doKeys('p'); + eq('cut\nand\npaste\nmcue\n an\n pa', cm.getValue()); +}, { value: 'cut\nand\npaste\nme'}); + +testVim('S_visual', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('v', 'j', 'S'); + helpers.doKeys(''); + helpers.assertCursorAt(0, 0); + eq('\ncc', cm.getValue()); +}, { value: 'aa\nbb\ncc'}); + +testVim('d_/', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('2', 'd', '/'); + helpers.assertCursorAt(0, 0); + eq('match \n next', cm.getValue()); + cm.openDialog = helpers.fakeOpenDialog('2'); + helpers.doKeys('d', ':'); + // TODO eq(' next', cm.getValue()); +}, { value: 'text match match \n next' }); +testVim('/ and n/N', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 11); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 6); + helpers.doKeys('N'); + helpers.assertCursorAt(0, 11); + + cm.setCursor(0, 0); + helpers.doKeys('2', '/'); + helpers.assertCursorAt(1, 6); +}, { value: 'match nope match \n nope Match' }); +testVim('/_case', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('Match'); + helpers.doKeys('/'); + helpers.assertCursorAt(1, 6); +}, { value: 'match nope match \n nope Match' }); +testVim('/_2_pcre', function(cm, vim, helpers) { + CodeMirror.Vim.setOption('pcre', true); + cm.openDialog = helpers.fakeOpenDialog('(word){2}'); + helpers.doKeys('/'); + helpers.assertCursorAt(1, 9); + helpers.doKeys('n'); + helpers.assertCursorAt(2, 1); +}, { value: 'word\n another wordword\n wordwordword\n' }); +testVim('/_2_nopcre', function(cm, vim, helpers) { + CodeMirror.Vim.setOption('pcre', false); + cm.openDialog = helpers.fakeOpenDialog('\\(word\\)\\{2}'); + helpers.doKeys('/'); + helpers.assertCursorAt(1, 9); + helpers.doKeys('n'); + helpers.assertCursorAt(2, 1); +}, { value: 'word\n another wordword\n wordwordword\n' }); +testVim('/_nongreedy', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('aa'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa \n a aa'}); +testVim('?_nongreedy', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('aa'); + helpers.doKeys('?'); + helpers.assertCursorAt(1, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa \n a aa'}); +testVim('/_greedy', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('a+'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 1); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa \n a aa'}); +testVim('?_greedy', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('a+'); + helpers.doKeys('?'); + helpers.assertCursorAt(1, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 1); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa \n a aa'}); +testVim('/_greedy_0_or_more', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('a*'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 5); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 0); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 1); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa\n aa'}); +testVim('?_greedy_0_or_more', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('a*'); + helpers.doKeys('?'); + helpers.assertCursorAt(1, 1); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 0); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 5); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa\n aa'}); +testVim('? and n/N', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('?'); + helpers.assertCursorAt(1, 6); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 11); + helpers.doKeys('N'); + helpers.assertCursorAt(1, 6); + + cm.setCursor(0, 0); + helpers.doKeys('2', '?'); + helpers.assertCursorAt(0, 11); +}, { value: 'match nope match \n nope Match' }); +testVim('*', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('*'); + helpers.assertCursorAt(0, 22); + + cm.setCursor(0, 9); + helpers.doKeys('2', '*'); + helpers.assertCursorAt(1, 8); +}, { value: 'nomatch match nomatch match \nnomatch Match' }); +testVim('*_no_word', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('*'); + helpers.assertCursorAt(0, 0); +}, { value: ' \n match \n' }); +testVim('*_symbol', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('*'); + helpers.assertCursorAt(1, 0); +}, { value: ' /}\n/} match \n' }); +testVim('#', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('#'); + helpers.assertCursorAt(1, 8); + + cm.setCursor(0, 9); + helpers.doKeys('2', '#'); + helpers.assertCursorAt(0, 22); +}, { value: 'nomatch match nomatch match \nnomatch Match' }); +testVim('*_seek', function(cm, vim, helpers) { + // Should skip over space and symbols. + cm.setCursor(0, 3); + helpers.doKeys('*'); + helpers.assertCursorAt(0, 22); +}, { value: ' := match nomatch match \nnomatch Match' }); +testVim('#', function(cm, vim, helpers) { + // Should skip over space and symbols. + cm.setCursor(0, 3); + helpers.doKeys('#'); + helpers.assertCursorAt(1, 8); +}, { value: ' := match nomatch match \nnomatch Match' }); +testVim('g*', function(cm, vim, helpers) { + cm.setCursor(0, 8); + helpers.doKeys('g', '*'); + helpers.assertCursorAt(0, 18); + cm.setCursor(0, 8); + helpers.doKeys('3', 'g', '*'); + helpers.assertCursorAt(1, 8); +}, { value: 'matches match alsoMatch\nmatchme matching' }); +testVim('g#', function(cm, vim, helpers) { + cm.setCursor(0, 8); + helpers.doKeys('g', '#'); + helpers.assertCursorAt(0, 0); + cm.setCursor(0, 8); + helpers.doKeys('3', 'g', '#'); + helpers.assertCursorAt(1, 0); +}, { value: 'matches match alsoMatch\nmatchme matching' }); +testVim('macro_insert', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', '0', 'i'); + cm.replaceRange('foo', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q', '@', 'a'); + eq('foofoo', cm.getValue()); +}, { value: ''}); +testVim('macro_insert_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', '$', 'a'); + cm.replaceRange('larry.', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('a'); + cm.replaceRange('curly.', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('a'); + cm.replaceRange('moe.', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('@', 'a'); + // At this point, the most recent edit should be the 2nd insert change + // inside the macro, i.e. "curly.". + helpers.doKeys('.'); + eq('larry.curly.moe.larry.curly.curly.', cm.getValue()); +}, { value: ''}); +testVim('macro_space', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', ''); + helpers.assertCursorAt(0, 2); + helpers.doKeys('q', 'a', '', '', 'q'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('@', 'a'); + helpers.assertCursorAt(0, 6); + helpers.doKeys('@', 'a'); + helpers.assertCursorAt(0, 8); +}, { value: 'one line of text.'}); +testVim('macro_t_search', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', 't', 'e', 'q'); + helpers.assertCursorAt(0, 1); + helpers.doKeys('l', '@', 'a'); + helpers.assertCursorAt(0, 6); + helpers.doKeys('l', ';'); + helpers.assertCursorAt(0, 12); +}, { value: 'one line of text.'}); +testVim('macro_f_search', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'b', 'f', 'e', 'q'); + helpers.assertCursorAt(0, 2); + helpers.doKeys('@', 'b'); + helpers.assertCursorAt(0, 7); + helpers.doKeys(';'); + helpers.assertCursorAt(0, 13); +}, { value: 'one line of text.'}); +testVim('macro_slash_search', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'c'); + cm.openDialog = helpers.fakeOpenDialog('e'); + helpers.doKeys('/', 'q'); + helpers.assertCursorAt(0, 2); + helpers.doKeys('@', 'c'); + helpers.assertCursorAt(0, 7); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 13); +}, { value: 'one line of text.'}); +testVim('macro_multislash_search', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'd'); + cm.openDialog = helpers.fakeOpenDialog('e'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('t'); + helpers.doKeys('/', 'q'); + helpers.assertCursorAt(0, 12); + helpers.doKeys('@', 'd'); + helpers.assertCursorAt(0, 15); +}, { value: 'one line of text to rule them all.'}); +testVim('macro_last_ex_command_register', function (cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doEx('s/a/b'); + helpers.doKeys('2', '@', ':'); + eq('bbbaa', cm.getValue()); + helpers.assertCursorAt(0, 2); +}, { value: 'aaaaa'}); +testVim('macro_parens', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'z', 'i'); + cm.replaceRange('(', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('e', 'a'); + cm.replaceRange(')', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('w', '@', 'z'); + helpers.doKeys('w', '@', 'z'); + eq('(see) (spot) (run)', cm.getValue()); +}, { value: 'see spot run'}); +testVim('macro_overwrite', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'z', '0', 'i'); + cm.replaceRange('I ', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('e'); + // Now replace the macro with something else. + helpers.doKeys('q', 'z', 'a'); + cm.replaceRange('.', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('e', '@', 'z'); + helpers.doKeys('e', '@', 'z'); + eq('I see. spot. run.', cm.getValue()); +}, { value: 'see spot run'}); +testVim('macro_search_f', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', 'f', ' '); + helpers.assertCursorAt(0,3); + helpers.doKeys('q', '0'); + helpers.assertCursorAt(0,0); + helpers.doKeys('@', 'a'); + helpers.assertCursorAt(0,3); +}, { value: 'The quick brown fox jumped over the lazy dog.'}); +testVim('macro_search_2f', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', '2', 'f', ' '); + helpers.assertCursorAt(0,9); + helpers.doKeys('q', '0'); + helpers.assertCursorAt(0,0); + helpers.doKeys('@', 'a'); + helpers.assertCursorAt(0,9); +}, { value: 'The quick brown fox jumped over the lazy dog.'}); +testVim('yank_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'y'); + helpers.doKeys('j', '"', 'b', 'y', 'y'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foo/.test(text)); + is(/b\s+bar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', 'l', 'j', '"', 'a', 'y'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+oo\nar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_append_line_to_line_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'y'); + helpers.doKeys('j', '"', 'A', 'y', 'y'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foo\nbar/.test(text)); + is(/"\s+foo\nbar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_append_word_to_word_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'w'); + helpers.doKeys('j', '"', 'A', 'y', 'w'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foobar/.test(text)); + is(/"\s+foobar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_append_line_to_word_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'w'); + helpers.doKeys('j', '"', 'A', 'y', 'y'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foo\nbar/.test(text)); + is(/"\s+foo\nbar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_append_word_to_line_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'y'); + helpers.doKeys('j', '"', 'A', 'y', 'w'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foo\nbar/.test(text)); + is(/"\s+foo\nbar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('macro_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', 'i'); + cm.replaceRange('gangnam', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('q', 'b', 'o'); + cm.replaceRange('style', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+i/.test(text)); + is(/b\s+o/.test(text)); + }); + helpers.doKeys(':'); +}, { value: ''}); +testVim('._register', function(cm,vim,helpers) { + cm.setCursor(0,0); + helpers.doKeys('i'); + cm.replaceRange('foo',cm.getCursor()); + helpers.doKeys(''); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/\.\s+foo/.test(text)); + }); + helpers.doKeys(':'); +}, {value: ''}); +testVim(':_register', function(cm,vim,helpers) { + helpers.doEx('bar'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/:\s+bar/.test(text)); + }); + helpers.doKeys(':'); +}, {value: ''}); +testVim('search_register_escape', function(cm, vim, helpers) { + // Check that the register is restored if the user escapes rather than confirms. + cm.openDialog = helpers.fakeOpenDialog('waldo'); + helpers.doKeys('/'); + var onKeyDown; + var onKeyUp; + var KEYCODES = { + f: 70, + o: 79, + Esc: 27 + }; + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + onKeyUp = options.onKeyUp; + }; + var close = function() {}; + helpers.doKeys('/'); + // Fake some keyboard events coming in. + onKeyDown({keyCode: KEYCODES.f}, '', close); + onKeyUp({keyCode: KEYCODES.f}, '', close); + onKeyDown({keyCode: KEYCODES.o}, 'f', close); + onKeyUp({keyCode: KEYCODES.o}, 'f', close); + onKeyDown({keyCode: KEYCODES.o}, 'fo', close); + onKeyUp({keyCode: KEYCODES.o}, 'fo', close); + onKeyDown({keyCode: KEYCODES.Esc}, 'foo', close); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/waldo/.test(text)); + is(!/foo/.test(text)); + }); + helpers.doKeys(':'); +}, {value: ''}); +testVim('search_register', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('foo'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/\/\s+foo/.test(text)); + }); + helpers.doKeys(':'); +}, {value: ''}); +testVim('search_history', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('this'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('checks'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('search'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('history'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('checks'); + helpers.doKeys('/'); + var onKeyDown; + var onKeyUp; + var query = ''; + var keyCodes = { + Up: 38, + Down: 40 + }; + cm.openDialog = function(template, callback, options) { + onKeyUp = options.onKeyUp; + onKeyDown = options.onKeyDown; + }; + var close = function(newVal) { + if (typeof newVal == 'string') query = newVal; + } + helpers.doKeys('/'); + onKeyDown({keyCode: keyCodes.Up}, query, close); + onKeyUp({keyCode: keyCodes.Up}, query, close); + eq(query, 'checks'); + onKeyDown({keyCode: keyCodes.Up}, query, close); + onKeyUp({keyCode: keyCodes.Up}, query, close); + eq(query, 'history'); + onKeyDown({keyCode: keyCodes.Up}, query, close); + onKeyUp({keyCode: keyCodes.Up}, query, close); + eq(query, 'search'); + onKeyDown({keyCode: keyCodes.Up}, query, close); + onKeyUp({keyCode: keyCodes.Up}, query, close); + eq(query, 'this'); + onKeyDown({keyCode: keyCodes.Down}, query, close); + onKeyUp({keyCode: keyCodes.Down}, query, close); + eq(query, 'search'); +}, {value: ''}); +testVim('exCommand_history', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('registers'); + helpers.doKeys(':'); + cm.openDialog = helpers.fakeOpenDialog('sort'); + helpers.doKeys(':'); + cm.openDialog = helpers.fakeOpenDialog('map'); + helpers.doKeys(':'); + cm.openDialog = helpers.fakeOpenDialog('invalid'); + helpers.doKeys(':'); + var onKeyDown; + var onKeyUp; + var input = ''; + var keyCodes = { + Up: 38, + Down: 40, + s: 115 + }; + cm.openDialog = function(template, callback, options) { + onKeyUp = options.onKeyUp; + onKeyDown = options.onKeyDown; + }; + var close = function(newVal) { + if (typeof newVal == 'string') input = newVal; + } + helpers.doKeys(':'); + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'invalid'); + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'map'); + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'sort'); + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'registers'); + onKeyDown({keyCode: keyCodes.s}, '', close); + input = 's'; + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'sort'); +}, {value: ''}); +testVim('search_clear', function(cm, vim, helpers) { + var onKeyDown; + var input = ''; + var keyCodes = { + Ctrl: 17, + u: 85 + }; + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + }; + var close = function(newVal) { + if (typeof newVal == 'string') input = newVal; + } + helpers.doKeys('/'); + input = 'foo'; + onKeyDown({keyCode: keyCodes.Ctrl}, input, close); + onKeyDown({keyCode: keyCodes.u, ctrlKey: true}, input, close); + eq(input, ''); +}); +testVim('exCommand_clear', function(cm, vim, helpers) { + var onKeyDown; + var input = ''; + var keyCodes = { + Ctrl: 17, + u: 85 + }; + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + }; + var close = function(newVal) { + if (typeof newVal == 'string') input = newVal; + } + helpers.doKeys(':'); + input = 'foo'; + onKeyDown({keyCode: keyCodes.Ctrl}, input, close); + onKeyDown({keyCode: keyCodes.u, ctrlKey: true}, input, close); + eq(input, ''); +}); +testVim('.', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('2', 'd', 'w'); + helpers.doKeys('.'); + eq('5 6', cm.getValue()); +}, { value: '1 2 3 4 5 6'}); +testVim('._repeat', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('2', 'd', 'w'); + helpers.doKeys('3', '.'); + eq('6', cm.getValue()); +}, { value: '1 2 3 4 5 6'}); +testVim('._insert', function(cm, vim, helpers) { + helpers.doKeys('i'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('.'); + eq('testestt', cm.getValue()); + helpers.assertCursorAt(0, 6); + helpers.doKeys('O'); + cm.replaceRange('xyz', cm.getCursor()); + helpers.doInsertModeKeys('Backspace'); + helpers.doInsertModeKeys('Down'); + helpers.doKeys(''); + helpers.doKeys('.'); + eq('xy\nxy\ntestestt', cm.getValue()); + helpers.assertCursorAt(1, 1); +}, { value: ''}); +testVim('._insert_repeat', function(cm, vim, helpers) { + helpers.doKeys('i'); + cm.replaceRange('test', cm.getCursor()); + cm.setCursor(0, 4); + helpers.doKeys(''); + helpers.doKeys('2', '.'); + eq('testesttestt', cm.getValue()); + helpers.assertCursorAt(0, 10); +}, { value: ''}); +testVim('._repeat_insert', function(cm, vim, helpers) { + helpers.doKeys('3', 'i'); + cm.replaceRange('te', cm.getCursor()); + cm.setCursor(0, 2); + helpers.doKeys(''); + helpers.doKeys('.'); + eq('tetettetetee', cm.getValue()); + helpers.assertCursorAt(0, 10); +}, { value: ''}); +testVim('._insert_o', function(cm, vim, helpers) { + helpers.doKeys('o'); + cm.replaceRange('z', cm.getCursor()); + cm.setCursor(1, 1); + helpers.doKeys(''); + helpers.doKeys('.'); + eq('\nz\nz', cm.getValue()); + helpers.assertCursorAt(2, 0); +}, { value: ''}); +testVim('._insert_o_repeat', function(cm, vim, helpers) { + helpers.doKeys('o'); + cm.replaceRange('z', cm.getCursor()); + helpers.doKeys(''); + cm.setCursor(1, 0); + helpers.doKeys('2', '.'); + eq('\nz\nz\nz', cm.getValue()); + helpers.assertCursorAt(3, 0); +}, { value: ''}); +testVim('._insert_o_indent', function(cm, vim, helpers) { + helpers.doKeys('o'); + cm.replaceRange('z', cm.getCursor()); + helpers.doKeys(''); + cm.setCursor(1, 2); + helpers.doKeys('.'); + eq('{\n z\n z', cm.getValue()); + helpers.assertCursorAt(2, 2); +}, { value: '{'}); +testVim('._insert_cw', function(cm, vim, helpers) { + helpers.doKeys('c', 'w'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + cm.setCursor(0, 3); + helpers.doKeys('2', 'l'); + helpers.doKeys('.'); + eq('test test word3', cm.getValue()); + helpers.assertCursorAt(0, 8); +}, { value: 'word1 word2 word3' }); +testVim('._insert_cw_repeat', function(cm, vim, helpers) { + // For some reason, repeat cw in desktop VIM will does not repeat insert mode + // changes. Will conform to that behavior. + helpers.doKeys('c', 'w'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + cm.setCursor(0, 4); + helpers.doKeys('l'); + helpers.doKeys('2', '.'); + eq('test test', cm.getValue()); + helpers.assertCursorAt(0, 8); +}, { value: 'word1 word2 word3' }); +testVim('._delete', function(cm, vim, helpers) { + cm.setCursor(0, 5); + helpers.doKeys('i'); + helpers.doInsertModeKeys('Backspace'); + helpers.doKeys(''); + helpers.doKeys('.'); + eq('zace', cm.getValue()); + helpers.assertCursorAt(0, 1); +}, { value: 'zabcde'}); +testVim('._delete_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 6); + helpers.doKeys('i'); + helpers.doInsertModeKeys('Backspace'); + helpers.doKeys(''); + helpers.doKeys('2', '.'); + eq('zzce', cm.getValue()); + helpers.assertCursorAt(0, 1); +}, { value: 'zzabcde'}); +testVim('._visual_>', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('V', 'j', '>'); + cm.setCursor(2, 0) + helpers.doKeys('.'); + eq(' 1\n 2\n 3\n 4', cm.getValue()); + helpers.assertCursorAt(2, 2); +}, { value: '1\n2\n3\n4'}); +testVim('f;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('f', 'x'); + helpers.doKeys(';'); + helpers.doKeys('2', ';'); + eq(9, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('F;', function(cm, vim, helpers) { + cm.setCursor(0, 8); + helpers.doKeys('F', 'x'); + helpers.doKeys(';'); + helpers.doKeys('2', ';'); + eq(2, cm.getCursor().ch); +}, { value: '01x3xx6x8x'}); +testVim('t;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('t', 'x'); + helpers.doKeys(';'); + helpers.doKeys('2', ';'); + eq(8, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('T;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('T', 'x'); + helpers.doKeys(';'); + helpers.doKeys('2', ';'); + eq(2, cm.getCursor().ch); +}, { value: '0xx3xx678x'}); +testVim('f,', function(cm, vim, helpers) { + cm.setCursor(0, 6); + helpers.doKeys('f', 'x'); + helpers.doKeys(','); + helpers.doKeys('2', ','); + eq(2, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('F,', function(cm, vim, helpers) { + cm.setCursor(0, 3); + helpers.doKeys('F', 'x'); + helpers.doKeys(','); + helpers.doKeys('2', ','); + eq(9, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('t,', function(cm, vim, helpers) { + cm.setCursor(0, 6); + helpers.doKeys('t', 'x'); + helpers.doKeys(','); + helpers.doKeys('2', ','); + eq(3, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('T,', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('T', 'x'); + helpers.doKeys(','); + helpers.doKeys('2', ','); + eq(8, cm.getCursor().ch); +}, { value: '01x3xx67xx'}); +testVim('fd,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('f', '4'); + cm.setCursor(0, 0); + helpers.doKeys('d', ';'); + eq('56789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('d', ','); + eq('01239', cm.getValue()); +}, { value: '0123456789'}); +testVim('Fd,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('F', '4'); + cm.setCursor(0, 9); + helpers.doKeys('d', ';'); + eq('01239', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('d', ','); + eq('56789', cm.getValue()); +}, { value: '0123456789'}); +testVim('td,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('t', '4'); + cm.setCursor(0, 0); + helpers.doKeys('d', ';'); + eq('456789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('d', ','); + eq('012349', cm.getValue()); +}, { value: '0123456789'}); +testVim('Td,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('T', '4'); + cm.setCursor(0, 9); + helpers.doKeys('d', ';'); + eq('012349', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('d', ','); + eq('456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('fc,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('f', '4'); + cm.setCursor(0, 0); + helpers.doKeys('c', ';', ''); + eq('56789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('c', ','); + eq('01239', cm.getValue()); +}, { value: '0123456789'}); +testVim('Fc,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('F', '4'); + cm.setCursor(0, 9); + helpers.doKeys('c', ';', ''); + eq('01239', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('c', ','); + eq('56789', cm.getValue()); +}, { value: '0123456789'}); +testVim('tc,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('t', '4'); + cm.setCursor(0, 0); + helpers.doKeys('c', ';', ''); + eq('456789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('c', ','); + eq('012349', cm.getValue()); +}, { value: '0123456789'}); +testVim('Tc,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('T', '4'); + cm.setCursor(0, 9); + helpers.doKeys('c', ';', ''); + eq('012349', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('c', ','); + eq('456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('fy,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('f', '4'); + cm.setCursor(0, 0); + helpers.doKeys('y', ';', 'P'); + eq('012340123456789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('y', ',', 'P'); + eq('012345678456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('Fy,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('F', '4'); + cm.setCursor(0, 9); + helpers.doKeys('y', ';', 'p'); + eq('012345678945678', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('y', ',', 'P'); + eq('012340123456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('ty,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('t', '4'); + cm.setCursor(0, 0); + helpers.doKeys('y', ';', 'P'); + eq('01230123456789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('y', ',', 'p'); + eq('01234567895678', cm.getValue()); +}, { value: '0123456789'}); +testVim('Ty,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('T', '4'); + cm.setCursor(0, 9); + helpers.doKeys('y', ';', 'p'); + eq('01234567895678', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('y', ',', 'P'); + eq('01230123456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('HML', function(cm, vim, helpers) { + var lines = 35; + var textHeight = cm.defaultTextHeight(); + cm.setSize(600, lines*textHeight); + cm.setCursor(120, 0); + cm.refresh(); //ace_patch + helpers.doKeys('H'); + helpers.assertCursorAt(86, 2); + helpers.doKeys('L'); + helpers.assertCursorAt(120, 4); + helpers.doKeys('M'); + helpers.assertCursorAt(103,4); +}, { value: (function(){ + var lines = new Array(100); + var upper = ' xx\n'; + var lower = ' xx\n'; + upper = lines.join(upper); + lower = lines.join(lower); + return upper + lower; +})()}); + +var zVals = []; +forEach(['zb','zz','zt','z-','z.','z'], function(e, idx){ + var lineNum = 250; + var lines = 35; + testVim(e, function(cm, vim, helpers) { + var k1 = e[0]; + var k2 = e.substring(1); + var textHeight = cm.defaultTextHeight(); + cm.setSize(600, lines*textHeight); + cm.setCursor(lineNum, 0); + helpers.doKeys(k1, k2); + zVals[idx] = cm.getScrollInfo().top; + }, { value: (function(){ + return new Array(500).join('\n'); + })()}); +}); +testVim('zb_to_bottom', function(cm, vim, helpers){ + var lineNum = 250; + cm.setSize(600, 35*cm.defaultTextHeight()); + cm.setCursor(lineNum, 0); + helpers.doKeys('z', 'b'); + var scrollInfo = cm.getScrollInfo(); + eq(scrollInfo.top + scrollInfo.clientHeight, cm.charCoords(Pos(lineNum, 0), 'local').bottom); +}, { value: (function(){ + return new Array(500).join('\n'); +})()}); +testVim('zt_to_top', function(cm, vim, helpers){ + var lineNum = 250; + cm.setSize(600, 35*cm.defaultTextHeight()); + cm.setCursor(lineNum, 0); + helpers.doKeys('z', 't'); + eq(cm.getScrollInfo().top, cm.charCoords(Pos(lineNum, 0), 'local').top); +}, { value: (function(){ + return new Array(500).join('\n'); +})()}); +testVim('zb', function(cm, vim, helpers){ + eq(zVals[2], zVals[5]); +}); + +var moveTillCharacterSandbox = + 'The quick brown fox \n'; +testVim('moveTillCharacter', function(cm, vim, helpers){ + cm.setCursor(0, 0); + // Search for the 'q'. + cm.openDialog = helpers.fakeOpenDialog('q'); + helpers.doKeys('/'); + eq(4, cm.getCursor().ch); + // Jump to just before the first o in the list. + helpers.doKeys('t'); + helpers.doKeys('o'); + eq('The quick brown fox \n', cm.getValue()); + // Delete that one character. + helpers.doKeys('d'); + helpers.doKeys('t'); + helpers.doKeys('o'); + eq('The quick bown fox \n', cm.getValue()); + // Delete everything until the next 'o'. + helpers.doKeys('.'); + eq('The quick box \n', cm.getValue()); + // An unmatched character should have no effect. + helpers.doKeys('d'); + helpers.doKeys('t'); + helpers.doKeys('q'); + eq('The quick box \n', cm.getValue()); + // Matches should only be possible on single lines. + helpers.doKeys('d'); + helpers.doKeys('t'); + helpers.doKeys('z'); + eq('The quick box \n', cm.getValue()); + // After all that, the search for 'q' should still be active, so the 'N' command + // can run it again in reverse. Use that to delete everything back to the 'q'. + helpers.doKeys('d'); + helpers.doKeys('N'); + eq('The ox \n', cm.getValue()); + eq(4, cm.getCursor().ch); +}, { value: moveTillCharacterSandbox}); +testVim('searchForPipe', function(cm, vim, helpers){ + CodeMirror.Vim.setOption('pcre', false); + cm.setCursor(0, 0); + // Search for the '|'. + cm.openDialog = helpers.fakeOpenDialog('|'); + helpers.doKeys('/'); + eq(4, cm.getCursor().ch); +}, { value: 'this|that'}); + + +var scrollMotionSandbox = + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'; +testVim('scrollMotion', function(cm, vim, helpers){ + var prevCursor, prevScrollInfo; + cm.setCursor(0, 0); + // ctrl-y at the top of the file should have no effect. + helpers.doKeys(''); + eq(0, cm.getCursor().line); + prevScrollInfo = cm.getScrollInfo(); + helpers.doKeys(''); + eq(1, cm.getCursor().line); + is(prevScrollInfo.top < cm.getScrollInfo().top); + // Jump to the end of the sandbox. + cm.setCursor(1000, 0); + cm.refresh(); //ace_patch + prevCursor = cm.getCursor(); + // ctrl-e at the bottom of the file should have no effect. + helpers.doKeys(''); + eq(prevCursor.line, cm.getCursor().line); + cm.refresh(); //ace_patch + prevScrollInfo = cm.getScrollInfo(); + helpers.doKeys(''); + eq(prevCursor.line - 1, cm.getCursor().line, "Y"); + is(prevScrollInfo.top > cm.getScrollInfo().top); +}, { value: scrollMotionSandbox}); + +var squareBracketMotionSandbox = ''+ + '({\n'+//0 + ' ({\n'+//11 + ' /*comment {\n'+//2 + ' */(\n'+//3 + '#else \n'+//4 + ' /* )\n'+//5 + '#if }\n'+//6 + ' )}*/\n'+//7 + ')}\n'+//8 + '{}\n'+//9 + '#else {{\n'+//10 + '{}\n'+//11 + '}\n'+//12 + '{\n'+//13 + '#endif\n'+//14 + '}\n'+//15 + '}\n'+//16 + '#else';//17 +testVim('[[, ]]', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys(']', ']'); + helpers.assertCursorAt(9,0); + helpers.doKeys('2', ']', ']'); + helpers.assertCursorAt(13,0); + helpers.doKeys(']', ']'); + helpers.assertCursorAt(17,0); + helpers.doKeys('[', '['); + helpers.assertCursorAt(13,0); + helpers.doKeys('2', '[', '['); + helpers.assertCursorAt(9,0); + helpers.doKeys('[', '['); + helpers.assertCursorAt(0,0); +}, { value: squareBracketMotionSandbox}); +testVim('[], ][', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys(']', '['); + helpers.assertCursorAt(12,0); + helpers.doKeys('2', ']', '['); + helpers.assertCursorAt(16,0); + helpers.doKeys(']', '['); + helpers.assertCursorAt(17,0); + helpers.doKeys('[', ']'); + helpers.assertCursorAt(16,0); + helpers.doKeys('2', '[', ']'); + helpers.assertCursorAt(12,0); + helpers.doKeys('[', ']'); + helpers.assertCursorAt(0,0); +}, { value: squareBracketMotionSandbox}); +testVim('[{, ]}', function(cm, vim, helpers) { + cm.setCursor(4, 10); + helpers.doKeys('[', '{'); + helpers.assertCursorAt(2,12); + helpers.doKeys('2', '[', '{'); + helpers.assertCursorAt(0,1); + cm.setCursor(4, 10); + helpers.doKeys(']', '}'); + helpers.assertCursorAt(6,11); + helpers.doKeys('2', ']', '}'); + helpers.assertCursorAt(8,1); + cm.setCursor(0,1); + helpers.doKeys(']', '}'); + helpers.assertCursorAt(8,1); + helpers.doKeys('[', '{'); + helpers.assertCursorAt(0,1); +}, { value: squareBracketMotionSandbox}); +testVim('[(, ])', function(cm, vim, helpers) { + cm.setCursor(4, 10); + helpers.doKeys('[', '('); + helpers.assertCursorAt(3,14); + helpers.doKeys('2', '[', '('); + helpers.assertCursorAt(0,0); + cm.setCursor(4, 10); + helpers.doKeys(']', ')'); + helpers.assertCursorAt(5,11); + helpers.doKeys('2', ']', ')'); + helpers.assertCursorAt(8,0); + helpers.doKeys('[', '('); + helpers.assertCursorAt(0,0); + helpers.doKeys(']', ')'); + helpers.assertCursorAt(8,0); +}, { value: squareBracketMotionSandbox}); +testVim('[*, ]*, [/, ]/', function(cm, vim, helpers) { + forEach(['*', '/'], function(key){ + cm.setCursor(7, 0); + helpers.doKeys('2', '[', key); + helpers.assertCursorAt(2,2); + helpers.doKeys('2', ']', key); + helpers.assertCursorAt(7,5); + }); +}, { value: squareBracketMotionSandbox}); +testVim('[#, ]#', function(cm, vim, helpers) { + cm.setCursor(10, 3); + helpers.doKeys('2', '[', '#'); + helpers.assertCursorAt(4,0); + helpers.doKeys('5', ']', '#'); + helpers.assertCursorAt(17,0); + cm.setCursor(10, 3); + helpers.doKeys(']', '#'); + helpers.assertCursorAt(14,0); +}, { value: squareBracketMotionSandbox}); +testVim('[m, ]m, [M, ]M', function(cm, vim, helpers) { + cm.setCursor(11, 0); + helpers.doKeys('[', 'm'); + helpers.assertCursorAt(10,7); + helpers.doKeys('4', '[', 'm'); + helpers.assertCursorAt(1,3); + helpers.doKeys('5', ']', 'm'); + helpers.assertCursorAt(11,0); + helpers.doKeys('[', 'M'); + helpers.assertCursorAt(9,1); + helpers.doKeys('3', ']', 'M'); + helpers.assertCursorAt(15,0); + helpers.doKeys('5', '[', 'M'); + helpers.assertCursorAt(7,3); +}, { value: squareBracketMotionSandbox}); + +// Ex mode tests +testVim('ex_go_to_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doEx('4'); + helpers.assertCursorAt(3, 0); +}, { value: 'a\nb\nc\nd\ne\n'}); +testVim('ex_write', function(cm, vim, helpers) { + var tmp = CodeMirror.commands.save; + var written; + var actualCm; + CodeMirror.commands.save = function(cm) { + written = true; + actualCm = cm; + }; + // Test that w, wr, wri ... write all trigger :write. + var command = 'write'; + for (var i = 1; i < command.length; i++) { + written = false; + actualCm = null; + helpers.doEx(command.substring(0, i)); + eq(written, true); + eq(actualCm, cm); + } + CodeMirror.commands.save = tmp; +}); +testVim('ex_sort', function(cm, vim, helpers) { + helpers.doEx('sort'); + eq('Z\na\nb\nc\nd', cm.getValue()); +}, { value: 'b\nZ\nd\nc\na'}); +testVim('ex_sort_reverse', function(cm, vim, helpers) { + helpers.doEx('sort!'); + eq('d\nc\nb\na', cm.getValue()); +}, { value: 'b\nd\nc\na'}); +testVim('ex_sort_range', function(cm, vim, helpers) { + helpers.doEx('2,3sort'); + eq('b\nc\nd\na', cm.getValue()); +}, { value: 'b\nd\nc\na'}); +testVim('ex_sort_oneline', function(cm, vim, helpers) { + helpers.doEx('2sort'); + // Expect no change. + eq('b\nd\nc\na', cm.getValue()); +}, { value: 'b\nd\nc\na'}); +testVim('ex_sort_ignoreCase', function(cm, vim, helpers) { + helpers.doEx('sort i'); + eq('a\nb\nc\nd\nZ', cm.getValue()); +}, { value: 'b\nZ\nd\nc\na'}); +testVim('ex_sort_unique', function(cm, vim, helpers) { + helpers.doEx('sort u'); + eq('Z\na\nb\nc\nd', cm.getValue()); +}, { value: 'b\nZ\na\na\nd\na\nc\na'}); +testVim('ex_sort_decimal', function(cm, vim, helpers) { + helpers.doEx('sort d'); + eq('d3\n s5\n6\n.9', cm.getValue()); +}, { value: '6\nd3\n s5\n.9'}); +testVim('ex_sort_decimal_negative', function(cm, vim, helpers) { + helpers.doEx('sort d'); + eq('z-9\nd3\n s5\n6\n.9', cm.getValue()); +}, { value: '6\nd3\n s5\n.9\nz-9'}); +testVim('ex_sort_decimal_reverse', function(cm, vim, helpers) { + helpers.doEx('sort! d'); + eq('.9\n6\n s5\nd3', cm.getValue()); +}, { value: '6\nd3\n s5\n.9'}); +testVim('ex_sort_hex', function(cm, vim, helpers) { + helpers.doEx('sort x'); + eq(' s5\n6\n.9\n&0xB\nd3', cm.getValue()); +}, { value: '6\nd3\n s5\n&0xB\n.9'}); +testVim('ex_sort_octal', function(cm, vim, helpers) { + helpers.doEx('sort o'); + eq('.8\n.9\nd3\n s5\n6', cm.getValue()); +}, { value: '6\nd3\n s5\n.9\n.8'}); +testVim('ex_sort_decimal_mixed', function(cm, vim, helpers) { + helpers.doEx('sort d'); + eq('y\nz\nc1\nb2\na3', cm.getValue()); +}, { value: 'a3\nz\nc1\ny\nb2'}); +testVim('ex_sort_decimal_mixed_reverse', function(cm, vim, helpers) { + helpers.doEx('sort! d'); + eq('a3\nb2\nc1\nz\ny', cm.getValue()); +}, { value: 'a3\nz\nc1\ny\nb2'}); +testVim('ex_sort_patterns_not_supported', function(cm, vim, helpers) { + var notified = false; + cm.openNotification = helpers.fakeOpenNotification(function(text) { + notified = /patterns not supported/.test(text); + }); + helpers.doEx('sort /abc/'); + is(notified, 'No notification.'); +}); +// test for :global command +testVim('ex_global', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doEx('g/one/s//two'); + eq('two two\n two two\n two two', cm.getValue()); + helpers.doEx('1,2g/two/s//one'); + eq('one one\n one one\n two two', cm.getValue()); +}, {value: 'one one\n one one\n one one'}); +testVim('ex_global_confirm', function(cm, vim, helpers) { + cm.setCursor(0, 0); + var onKeyDown; + var openDialogSave = cm.openDialog; + var KEYCODES = { + a: 65, + n: 78, + q: 81, + y: 89 + }; + // Intercept the ex command, 'global' + cm.openDialog = function(template, callback, options) { + // Intercept the prompt for the embedded ex command, 'substitute' + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + }; + callback('g/one/s//two/gc'); + }; + helpers.doKeys(':'); + var close = function() {}; + onKeyDown({keyCode: KEYCODES.n}, '', close); + onKeyDown({keyCode: KEYCODES.y}, '', close); + onKeyDown({keyCode: KEYCODES.a}, '', close); + onKeyDown({keyCode: KEYCODES.q}, '', close); + onKeyDown({keyCode: KEYCODES.y}, '', close); + eq('one two\n two two\n one one\n two one\n one one', cm.getValue()); +}, {value: 'one one\n one one\n one one\n one one\n one one'}); +// Basic substitute tests. +testVim('ex_substitute_same_line', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doEx('s/one/two/g'); + eq('one one\n two two', cm.getValue()); +}, { value: 'one one\n one one'}); +testVim('ex_substitute_full_file', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doEx('%s/one/two/g'); + eq('two two\n two two', cm.getValue()); +}, { value: 'one one\n one one'}); +testVim('ex_substitute_input_range', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doEx('1,3s/\\d/0/g'); + eq('0\n0\n0\n4', cm.getValue()); +}, { value: '1\n2\n3\n4' }); +testVim('ex_substitute_visual_range', function(cm, vim, helpers) { + cm.setCursor(1, 0); + // Set last visual mode selection marks '< and '> at lines 2 and 4 + helpers.doKeys('V', '2', 'j', 'v'); + helpers.doEx('\'<,\'>s/\\d/0/g'); + eq('1\n0\n0\n0\n5', cm.getValue()); +}, { value: '1\n2\n3\n4\n5' }); +testVim('ex_substitute_empty_query', function(cm, vim, helpers) { + // If the query is empty, use last query. + cm.setCursor(1, 0); + cm.openDialog = helpers.fakeOpenDialog('1'); + helpers.doKeys('/'); + helpers.doEx('s//b/g'); + eq('abb ab2 ab3', cm.getValue()); +}, { value: 'a11 a12 a13' }); +testVim('ex_substitute_javascript', function(cm, vim, helpers) { + CodeMirror.Vim.setOption('pcre', false); + cm.setCursor(1, 0); + // Throw all the things that javascript likes to treat as special values + // into the replace part. All should be literal (this is VIM). + helpers.doEx('s/\\(\\d+\\)/$$ $\' $` $& \\1/g') + eq('a $$ $\' $` $& 0 b', cm.getValue()); +}, { value: 'a 0 b' }); +testVim('ex_substitute_empty_arguments', function(cm,vim,helpers) { + cm.setCursor(0, 0); + helpers.doEx('s/a/b/g'); + cm.setCursor(1, 0); + helpers.doEx('s'); + eq('b b\nb a', cm.getValue()); +}, {value: 'a a\na a'}); + +// More complex substitute tests that test both pcre and nopcre options. +function testSubstitute(name, options) { + testVim(name + '_pcre', function(cm, vim, helpers) { + cm.setCursor(1, 0); + CodeMirror.Vim.setOption('pcre', true); + helpers.doEx(options.expr); + eq(options.expectedValue, cm.getValue()); + }, options); + // If no noPcreExpr is defined, assume that it's the same as the expr. + var noPcreExpr = options.noPcreExpr ? options.noPcreExpr : options.expr; + testVim(name + '_nopcre', function(cm, vim, helpers) { + cm.setCursor(1, 0); + CodeMirror.Vim.setOption('pcre', false); + helpers.doEx(noPcreExpr); + eq(options.expectedValue, cm.getValue()); + }, options); +} +testSubstitute('ex_substitute_capture', { + value: 'a11 a12 a13', + expectedValue: 'a1111 a1212 a1313', + // $n is a backreference + expr: 's/(\\d+)/$1$1/g', + // \n is a backreference. + noPcreExpr: 's/\\(\\d+\\)/\\1\\1/g'}); +testSubstitute('ex_substitute_capture2', { + value: 'a 0 b', + expectedValue: 'a $00 b', + expr: 's/(\\d+)/$$$1$1/g', + noPcreExpr: 's/\\(\\d+\\)/$\\1\\1/g'}); +testSubstitute('ex_substitute_nocapture', { + value: 'a11 a12 a13', + expectedValue: 'a$1$1 a$1$1 a$1$1', + expr: 's/(\\d+)/$$1$$1/g', + noPcreExpr: 's/\\(\\d+\\)/$1$1/g'}); +testSubstitute('ex_substitute_nocapture2', { + value: 'a 0 b', + expectedValue: 'a $10 b', + expr: 's/(\\d+)/$$1$1/g', + noPcreExpr: 's/\\(\\d+\\)/\\$1\\1/g'}); +testSubstitute('ex_substitute_nocapture', { + value: 'a b c', + expectedValue: 'a $ c', + expr: 's/b/$$/', + noPcreExpr: 's/b/$/'}); +testSubstitute('ex_substitute_slash_regex', { + value: 'one/two \n three/four', + expectedValue: 'one|two \n three|four', + expr: '%s/\\//|'}); +testSubstitute('ex_substitute_pipe_regex', { + value: 'one|two \n three|four', + expectedValue: 'one,two \n three,four', + expr: '%s/\\|/,/', + noPcreExpr: '%s/|/,/'}); +testSubstitute('ex_substitute_or_regex', { + value: 'one|two \n three|four', + expectedValue: 'ana|twa \n thraa|faar', + expr: '%s/o|e|u/a/g', + noPcreExpr: '%s/o\\|e\\|u/a/g'}); +testSubstitute('ex_substitute_or_word_regex', { + value: 'one|two \n three|four', + expectedValue: 'five|five \n three|four', + expr: '%s/(one|two)/five/g', + noPcreExpr: '%s/\\(one\\|two\\)/five/g'}); +testSubstitute('ex_substitute_backslashslash_regex', { + value: 'one\\two \n three\\four', + expectedValue: 'one,two \n three,four', + expr: '%s/\\\\/,'}); +testSubstitute('ex_substitute_slash_replacement', { + value: 'one,two \n three,four', + expectedValue: 'one/two \n three/four', + expr: '%s/,/\\/'}); +testSubstitute('ex_substitute_backslash_replacement', { + value: 'one,two \n three,four', + expectedValue: 'one\\two \n three\\four', + expr: '%s/,/\\\\/g'}); +testSubstitute('ex_substitute_multibackslash_replacement', { + value: 'one,two \n three,four', + expectedValue: 'one\\\\\\\\two \n three\\\\\\\\four', // 2*8 backslashes. + expr: '%s/,/\\\\\\\\\\\\\\\\/g'}); // 16 backslashes. +testSubstitute('ex_substitute_newline_replacement', { + value: 'one,two \n three,four', + expectedValue: 'one\ntwo \n three\nfour', + expr: '%s/,/\\n/g'}); +testSubstitute('ex_substitute_braces_word', { + value: 'ababab abb ab{2}', + expectedValue: 'ab abb ab{2}', + expr: '%s/(ab){2}//g', + noPcreExpr: '%s/\\(ab\\)\\{2\\}//g'}); +testSubstitute('ex_substitute_braces_range', { + value: 'a aa aaa aaaa', + expectedValue: 'a a', + expr: '%s/a{2,3}//g', + noPcreExpr: '%s/a\\{2,3\\}//g'}); +testSubstitute('ex_substitute_braces_literal', { + value: 'ababab abb ab{2}', + expectedValue: 'ababab abb ', + expr: '%s/ab\\{2\\}//g', + noPcreExpr: '%s/ab{2}//g'}); +testSubstitute('ex_substitute_braces_char', { + value: 'ababab abb ab{2}', + expectedValue: 'ababab ab{2}', + expr: '%s/ab{2}//g', + noPcreExpr: '%s/ab\\{2\\}//g'}); +testSubstitute('ex_substitute_braces_no_escape', { + value: 'ababab abb ab{2}', + expectedValue: 'ababab ab{2}', + expr: '%s/ab{2}//g', + noPcreExpr: '%s/ab\\{2}//g'}); +testSubstitute('ex_substitute_count', { + value: '1\n2\n3\n4', + expectedValue: '1\n0\n0\n4', + expr: 's/\\d/0/i 2'}); +testSubstitute('ex_substitute_count_with_range', { + value: '1\n2\n3\n4', + expectedValue: '1\n2\n0\n0', + expr: '1,3s/\\d/0/ 3'}); +testSubstitute('ex_substitute_not_global', { + value: 'aaa\nbaa\ncaa', + expectedValue: 'xaa\nbxa\ncxa', + expr: '%s/a/x/'}); +function testSubstituteConfirm(name, command, initialValue, expectedValue, keys, finalPos) { + testVim(name, function(cm, vim, helpers) { + var savedOpenDialog = cm.openDialog; + var savedKeyName = CodeMirror.keyName; + var onKeyDown; + var recordedCallback; + var closed = true; // Start out closed, set false on second openDialog. + function close() { + closed = true; + } + // First openDialog should save callback. + cm.openDialog = function(template, callback, options) { + recordedCallback = callback; + } + // Do first openDialog. + helpers.doKeys(':'); + // Second openDialog should save keyDown handler. + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + closed = false; + }; + // Return the command to Vim and trigger second openDialog. + recordedCallback(command); + // The event should really use keyCode, but here just mock it out and use + // key and replace keyName to just return key. + CodeMirror.keyName = function (e) { return e.key; } + keys = keys.toUpperCase(); + for (var i = 0; i < keys.length; i++) { + is(!closed); + onKeyDown({ key: keys.charAt(i) }, '', close); + } + try { + eq(expectedValue, cm.getValue()); + helpers.assertCursorAt(finalPos); + is(closed); + } catch(e) { + throw e + } finally { + // Restore overriden functions. + CodeMirror.keyName = savedKeyName; + cm.openDialog = savedOpenDialog; + } + }, { value: initialValue }); +} +testSubstituteConfirm('ex_substitute_confirm_emptydoc', + '%s/x/b/c', '', '', '', makeCursor(0, 0)); +testSubstituteConfirm('ex_substitute_confirm_nomatch', + '%s/x/b/c', 'ba a\nbab', 'ba a\nbab', '', makeCursor(0, 0)); +testSubstituteConfirm('ex_substitute_confirm_accept', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'yyy', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_random_keys', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'ysdkywerty', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_some', + '%s/a/b/cg', 'ba a\nbab', 'bb a\nbbb', 'yny', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_all', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'a', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_accept_then_all', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'ya', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_quit', + '%s/a/b/cg', 'ba a\nbab', 'bb a\nbab', 'yq', makeCursor(0, 3)); +testSubstituteConfirm('ex_substitute_confirm_last', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbab', 'yl', makeCursor(0, 3)); +testSubstituteConfirm('ex_substitute_confirm_oneline', + '1s/a/b/cg', 'ba a\nbab', 'bb b\nbab', 'yl', makeCursor(0, 3)); +testSubstituteConfirm('ex_substitute_confirm_range_accept', + '1,2s/a/b/cg', 'aa\na \na\na', 'bb\nb \na\na', 'yyy', makeCursor(1, 0)); +testSubstituteConfirm('ex_substitute_confirm_range_some', + '1,3s/a/b/cg', 'aa\na \na\na', 'ba\nb \nb\na', 'ynyy', makeCursor(2, 0)); +testSubstituteConfirm('ex_substitute_confirm_range_all', + '1,3s/a/b/cg', 'aa\na \na\na', 'bb\nb \nb\na', 'a', makeCursor(2, 0)); +testSubstituteConfirm('ex_substitute_confirm_range_last', + '1,3s/a/b/cg', 'aa\na \na\na', 'bb\nb \na\na', 'yyl', makeCursor(1, 0)); +//:noh should clear highlighting of search-results but allow to resume search through n +testVim('ex_noh_clearSearchHighlight', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('?'); + helpers.doEx('noh'); + eq(vim.searchState_.getOverlay(),null,'match-highlighting wasn\'t cleared'); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 11,'can\'t resume search after clearing highlighting'); +}, { value: 'match nope match \n nope Match' }); +testVim('set_boolean', function(cm, vim, helpers) { + CodeMirror.Vim.defineOption('testoption', true, 'boolean'); + // Test default value is set. + is(CodeMirror.Vim.getOption('testoption')); + expectFail(function() { + // Test fail to set to non-boolean + CodeMirror.Vim.setOption('testoption', '5'); + }); + // Test setOption + CodeMirror.Vim.setOption('testoption', false); + is(!CodeMirror.Vim.getOption('testoption')); +}); +testVim('ex_set_boolean', function(cm, vim, helpers) { + CodeMirror.Vim.defineOption('testoption', true, 'boolean'); + // Test default value is set. + is(CodeMirror.Vim.getOption('testoption')); + expectFail(function() { + // Test fail to set to non-boolean + helpers.doEx('set testoption=22'); + }); + // Test setOption + helpers.doEx('set notestoption'); + is(!CodeMirror.Vim.getOption('testoption')); +}); +testVim('set_string', function(cm, vim, helpers) { + CodeMirror.Vim.defineOption('testoption', 'a', 'string'); + // Test default value is set. + eq('a', CodeMirror.Vim.getOption('testoption')); + expectFail(function() { + // Test fail to set non-string. + CodeMirror.Vim.setOption('testoption', true); + }); + expectFail(function() { + // Test fail to set 'notestoption' + CodeMirror.Vim.setOption('notestoption', 'b'); + }); + // Test setOption + CodeMirror.Vim.setOption('testoption', 'c'); + eq('c', CodeMirror.Vim.getOption('testoption')); +}); +testVim('ex_set_string', function(cm, vim, helpers) { + CodeMirror.Vim.defineOption('testopt', 'a', 'string'); + // Test default value is set. + eq('a', CodeMirror.Vim.getOption('testopt')); + expectFail(function() { + // Test fail to set 'notestopt' + helpers.doEx('set notestopt=b'); + }); + // Test setOption + helpers.doEx('set testopt=c') + eq('c', CodeMirror.Vim.getOption('testopt')); + helpers.doEx('set testopt=c') + eq('c', CodeMirror.Vim.getOption('testopt', cm)); //local || global + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); // local + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); // global + eq('c', CodeMirror.Vim.getOption('testopt')); // global + // Test setOption global + helpers.doEx('setg testopt=d') + eq('c', CodeMirror.Vim.getOption('testopt', cm)); + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); + eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); + eq('d', CodeMirror.Vim.getOption('testopt')); + // Test setOption local + helpers.doEx('setl testopt=e') + eq('e', CodeMirror.Vim.getOption('testopt', cm)); + eq('e', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); + eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); + eq('d', CodeMirror.Vim.getOption('testopt')); +}); +testVim('ex_set_callback', function(cm, vim, helpers) { + var global; + + function cb(val, cm, cfg) { + if (val === undefined) { + // Getter + if (cm) { + return cm._local; + } else { + return global; + } + } else { + // Setter + if (cm) { + cm._local = val; + } else { + global = val; + } + } + } + + CodeMirror.Vim.defineOption('testopt', 'a', 'string', cb); + // Test default value is set. + eq('a', CodeMirror.Vim.getOption('testopt')); + expectFail(function() { + // Test fail to set 'notestopt' + helpers.doEx('set notestopt=b'); + }); + // Test setOption (Identical to the string tests, but via callback instead) + helpers.doEx('set testopt=c') + eq('c', CodeMirror.Vim.getOption('testopt', cm)); //local || global + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); // local + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); // global + eq('c', CodeMirror.Vim.getOption('testopt')); // global + // Test setOption global + helpers.doEx('setg testopt=d') + eq('c', CodeMirror.Vim.getOption('testopt', cm)); + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); + eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); + eq('d', CodeMirror.Vim.getOption('testopt')); + // Test setOption local + helpers.doEx('setl testopt=e') + eq('e', CodeMirror.Vim.getOption('testopt', cm)); + eq('e', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); + eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); + eq('d', CodeMirror.Vim.getOption('testopt')); +}) +testVim('ex_set_filetype', function(cm, vim, helpers) { + CodeMirror.defineMode('test_mode', function() { + return {token: function(stream) { + stream.match(/^\s+|^\S+/); + }}; + }); + CodeMirror.defineMode('test_mode_2', function() { + return {token: function(stream) { + stream.match(/^\s+|^\S+/); + }}; + }); + // Test mode is set. + helpers.doEx('set filetype=test_mode'); + eq('test_mode', cm.getMode().name); + // Test 'ft' alias also sets mode. + helpers.doEx('set ft=test_mode_2'); + eq('test_mode_2', cm.getMode().name); +}); +testVim('ex_set_filetype_null', function(cm, vim, helpers) { + CodeMirror.defineMode('test_mode', function() { + return {token: function(stream) { + stream.match(/^\s+|^\S+/); + }}; + }); + cm.setOption('mode', 'test_mode'); + // Test mode is set to null. + helpers.doEx('set filetype='); + eq('null', cm.getMode().name); +}); +// TODO: Reset key maps after each test. +testVim('ex_map_key2key', function(cm, vim, helpers) { + helpers.doEx('map a x'); + helpers.doKeys('a'); + helpers.assertCursorAt(0, 0); + eq('bc', cm.getValue()); +}, { value: 'abc' }); +testVim('ex_unmap_key2key', function(cm, vim, helpers) { + helpers.doEx('unmap a'); + helpers.doKeys('a'); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: 'abc' }); +testVim('ex_unmap_key2key_does_not_remove_default', function(cm, vim, helpers) { + expectFail(function() { + helpers.doEx('unmap a'); + }); + helpers.doKeys('a'); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: 'abc' }); +testVim('ex_map_key2key_to_colon', function(cm, vim, helpers) { + helpers.doEx('map ; :'); + var dialogOpened = false; + cm.openDialog = function() { + dialogOpened = true; + } + helpers.doKeys(';'); + eq(dialogOpened, true); +}); +testVim('ex_map_ex2key:', function(cm, vim, helpers) { + helpers.doEx('map :del x'); + helpers.doEx('del'); + helpers.assertCursorAt(0, 0); + eq('bc', cm.getValue()); +}, { value: 'abc' }); +testVim('ex_map_ex2ex', function(cm, vim, helpers) { + helpers.doEx('map :del :w'); + var tmp = CodeMirror.commands.save; + var written = false; + var actualCm; + CodeMirror.commands.save = function(cm) { + written = true; + actualCm = cm; + }; + helpers.doEx('del'); + CodeMirror.commands.save = tmp; + eq(written, true); + eq(actualCm, cm); +}); +testVim('ex_map_key2ex', function(cm, vim, helpers) { + helpers.doEx('map a :w'); + var tmp = CodeMirror.commands.save; + var written = false; + var actualCm; + CodeMirror.commands.save = function(cm) { + written = true; + actualCm = cm; + }; + helpers.doKeys('a'); + CodeMirror.commands.save = tmp; + eq(written, true); + eq(actualCm, cm); +}); +testVim('ex_map_key2key_visual_api', function(cm, vim, helpers) { + CodeMirror.Vim.map('b', ':w', 'visual'); + var tmp = CodeMirror.commands.save; + var written = false; + var actualCm; + CodeMirror.commands.save = function(cm) { + written = true; + actualCm = cm; + }; + // Mapping should not work in normal mode. + helpers.doKeys('b'); + eq(written, false); + // Mapping should work in visual mode. + helpers.doKeys('v', 'b'); + eq(written, true); + eq(actualCm, cm); + + CodeMirror.commands.save = tmp; +}); +testVim('ex_imap', function(cm, vim, helpers) { + CodeMirror.Vim.map('jk', '', 'insert'); + helpers.doKeys('i'); + is(vim.insertMode); + helpers.doKeys('j', 'k'); + is(!vim.insertMode); + cm.setCursor(0, 1); + CodeMirror.Vim.map('jj', '', 'insert'); + helpers.doKeys('', '2', 'j', 'l', 'c'); + var replacement = fillArray('fo', 3); + cm.replaceSelections(replacement); + eq('1fo4\n5fo8\nafodefg', cm.getValue()); + helpers.doKeys('j', 'j'); + cm.setCursor(0, 0); + helpers.doKeys('.'); + eq('foo4\nfoo8\nfoodefg', cm.getValue()); +}, { value: '1234\n5678\nabcdefg' }); +testVim('ex_unmap_api', function(cm, vim, helpers) { + CodeMirror.Vim.map('', 'gg', 'normal'); + is(CodeMirror.Vim.handleKey(cm, "", "normal"), "Alt-X key is mapped"); + CodeMirror.Vim.unmap("", "normal"); + is(!CodeMirror.Vim.handleKey(cm, "", "normal"), "Alt-X key is unmapped"); +}); + +// Testing registration of functions as ex-commands and mapping to -keys +testVim('ex_api_test', function(cm, vim, helpers) { + var res=false; + var val='from'; + CodeMirror.Vim.defineEx('extest','ext',function(cm,params){ + if(params.args)val=params.args[0]; + else res=true; + }); + helpers.doEx(':ext to'); + eq(val,'to','Defining ex-command failed'); + CodeMirror.Vim.map('',':ext'); + helpers.doKeys('',''); + is(res,'Mapping to key failed'); +}); +// For now, this test needs to be last because it messes up : for future tests. +testVim('ex_map_key2key_from_colon', function(cm, vim, helpers) { + helpers.doEx('map : x'); + helpers.doKeys(':'); + helpers.assertCursorAt(0, 0); + eq('bc', cm.getValue()); +}, { value: 'abc' }); + +// Test event handlers +testVim('beforeSelectionChange', function(cm, vim, helpers) { + cm.setCursor(0, 100); + eqPos(cm.getCursor('head'), cm.getCursor('anchor')); +}, { value: 'abc' }); + + +}); + + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/layer/cursor.js b/public/lib/ace/layer/cursor.js new file mode 100644 index 0000000..14edaeb --- /dev/null +++ b/public/lib/ace/layer/cursor.js @@ -0,0 +1,243 @@ +/* ***** 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 dom = require("../lib/dom"); +var isIE8; + +var Cursor = function(parentEl) { + this.element = dom.createElement("div"); + this.element.className = "ace_layer ace_cursor-layer"; + parentEl.appendChild(this.element); + + if (isIE8 === undefined) + isIE8 = !("opacity" in this.element.style); + + this.isVisible = false; + this.isBlinking = true; + this.blinkInterval = 1000; + this.smoothBlinking = false; + + this.cursors = []; + this.cursor = this.addCursor(); + dom.addCssClass(this.element, "ace_hidden-cursors"); + this.$updateCursors = (isIE8 + ? this.$updateVisibility + : this.$updateOpacity).bind(this); +}; + +(function() { + + this.$updateVisibility = function(val) { + var cursors = this.cursors; + for (var i = cursors.length; i--; ) + cursors[i].style.visibility = val ? "" : "hidden"; + }; + this.$updateOpacity = function(val) { + var cursors = this.cursors; + for (var i = cursors.length; i--; ) + cursors[i].style.opacity = val ? "" : "0"; + }; + + + this.$padding = 0; + this.setPadding = function(padding) { + this.$padding = padding; + }; + + this.setSession = function(session) { + this.session = session; + }; + + this.setBlinking = function(blinking) { + if (blinking != this.isBlinking){ + this.isBlinking = blinking; + this.restartTimer(); + } + }; + + this.setBlinkInterval = function(blinkInterval) { + if (blinkInterval != this.blinkInterval){ + this.blinkInterval = blinkInterval; + this.restartTimer(); + } + }; + + this.setSmoothBlinking = function(smoothBlinking) { + if (smoothBlinking != this.smoothBlinking && !isIE8) { + this.smoothBlinking = smoothBlinking; + dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking); + this.$updateCursors(true); + this.$updateCursors = (this.$updateOpacity).bind(this); + this.restartTimer(); + } + }; + + this.addCursor = function() { + var el = dom.createElement("div"); + el.className = "ace_cursor"; + this.element.appendChild(el); + this.cursors.push(el); + return el; + }; + + this.removeCursor = function() { + if (this.cursors.length > 1) { + var el = this.cursors.pop(); + el.parentNode.removeChild(el); + return el; + } + }; + + this.hideCursor = function() { + this.isVisible = false; + dom.addCssClass(this.element, "ace_hidden-cursors"); + this.restartTimer(); + }; + + this.showCursor = function() { + this.isVisible = true; + dom.removeCssClass(this.element, "ace_hidden-cursors"); + this.restartTimer(); + }; + + this.restartTimer = function() { + var update = this.$updateCursors; + clearInterval(this.intervalId); + clearTimeout(this.timeoutId); + if (this.smoothBlinking) { + dom.removeCssClass(this.element, "ace_smooth-blinking"); + } + + update(true); + + if (!this.isBlinking || !this.blinkInterval || !this.isVisible) + return; + + if (this.smoothBlinking) { + setTimeout(function(){ + dom.addCssClass(this.element, "ace_smooth-blinking"); + }.bind(this)); + } + + var blink = function(){ + this.timeoutId = setTimeout(function() { + update(false); + }, 0.6 * this.blinkInterval); + }.bind(this); + + this.intervalId = setInterval(function() { + update(true); + blink(); + }, this.blinkInterval); + + blink(); + }; + + this.getPixelPosition = function(position, onScreen) { + if (!this.config || !this.session) + return {left : 0, top : 0}; + + if (!position) + position = this.session.selection.getCursor(); + var pos = this.session.documentToScreenPosition(position); + var cursorLeft = this.$padding + (this.session.$bidiHandler.isBidiRow(pos.row, position.row) + ? this.session.$bidiHandler.getPosLeft(pos.column) + : pos.column * this.config.characterWidth); + + var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) * + this.config.lineHeight; + + return {left : cursorLeft, top : cursorTop}; + }; + + this.update = function(config) { + this.config = config; + + var selections = this.session.$selectionMarkers; + var i = 0, cursorIndex = 0; + + if (selections === undefined || selections.length === 0){ + selections = [{cursor: null}]; + } + + for (var i = 0, n = selections.length; i < n; i++) { + var pixelPos = this.getPixelPosition(selections[i].cursor, true); + if ((pixelPos.top > config.height + config.offset || + pixelPos.top < 0) && i > 1) { + continue; + } + + var style = (this.cursors[cursorIndex++] || this.addCursor()).style; + + if (!this.drawCursor) { + style.left = pixelPos.left + "px"; + style.top = pixelPos.top + "px"; + style.width = config.characterWidth + "px"; + style.height = config.lineHeight + "px"; + } else { + this.drawCursor(style, pixelPos, config, selections[i], this.session); + } + } + while (this.cursors.length > cursorIndex) + this.removeCursor(); + + var overwrite = this.session.getOverwrite(); + this.$setOverwrite(overwrite); + + // cache for textarea and gutter highlight + this.$pixelPos = pixelPos; + this.restartTimer(); + }; + + this.drawCursor = null; + + this.$setOverwrite = function(overwrite) { + if (overwrite != this.overwrite) { + this.overwrite = overwrite; + if (overwrite) + dom.addCssClass(this.element, "ace_overwrite-cursors"); + else + dom.removeCssClass(this.element, "ace_overwrite-cursors"); + } + }; + + this.destroy = function() { + clearInterval(this.intervalId); + clearTimeout(this.timeoutId); + }; + +}).call(Cursor.prototype); + +exports.Cursor = Cursor; + +}); diff --git a/public/lib/ace/layer/font_metrics.js b/public/lib/ace/layer/font_metrics.js new file mode 100644 index 0000000..e410169 --- /dev/null +++ b/public/lib/ace/layer/font_metrics.js @@ -0,0 +1,176 @@ +/* ***** 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) { + +var oop = require("../lib/oop"); +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var useragent = require("../lib/useragent"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; + +var CHAR_COUNT = 0; + +var FontMetrics = exports.FontMetrics = function(parentEl) { + this.el = dom.createElement("div"); + this.$setMeasureNodeStyles(this.el.style, true); + + this.$main = dom.createElement("div"); + this.$setMeasureNodeStyles(this.$main.style); + + this.$measureNode = dom.createElement("div"); + this.$setMeasureNodeStyles(this.$measureNode.style); + + + this.el.appendChild(this.$main); + this.el.appendChild(this.$measureNode); + parentEl.appendChild(this.el); + + if (!CHAR_COUNT) + this.$testFractionalRect(); + this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT); + + this.$characterSize = {width: 0, height: 0}; + this.checkForSizeChanges(); +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.$characterSize = {width: 0, height: 0}; + + this.$testFractionalRect = function() { + var el = dom.createElement("div"); + this.$setMeasureNodeStyles(el.style); + el.style.width = "0.2px"; + document.documentElement.appendChild(el); + var w = el.getBoundingClientRect().width; + if (w > 0 && w < 1) + CHAR_COUNT = 50; + else + CHAR_COUNT = 100; + el.parentNode.removeChild(el); + }; + + this.$setMeasureNodeStyles = function(style, isRoot) { + style.width = style.height = "auto"; + style.left = style.top = "0px"; + style.visibility = "hidden"; + style.position = "absolute"; + style.whiteSpace = "pre"; + + if (useragent.isIE < 8) { + style["font-family"] = "inherit"; + } else { + style.font = "inherit"; + } + style.overflow = isRoot ? "hidden" : "visible"; + }; + + this.checkForSizeChanges = function() { + var size = this.$measureSizes(); + if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) { + this.$measureNode.style.fontWeight = "bold"; + var boldSize = this.$measureSizes(); + this.$measureNode.style.fontWeight = ""; + this.$characterSize = size; + this.charSizes = Object.create(null); + this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height; + this._emit("changeCharacterSize", {data: size}); + } + }; + + this.$pollSizeChanges = function() { + if (this.$pollSizeChangesTimer) + return this.$pollSizeChangesTimer; + var self = this; + return this.$pollSizeChangesTimer = setInterval(function() { + self.checkForSizeChanges(); + }, 500); + }; + + this.setPolling = function(val) { + if (val) { + this.$pollSizeChanges(); + } else if (this.$pollSizeChangesTimer) { + clearInterval(this.$pollSizeChangesTimer); + this.$pollSizeChangesTimer = 0; + } + }; + + this.$measureSizes = function() { + if (CHAR_COUNT === 50) { + var rect = null; + try { + rect = this.$measureNode.getBoundingClientRect(); + } catch(e) { + rect = {width: 0, height:0 }; + } + var size = { + height: rect.height, + width: rect.width / CHAR_COUNT + }; + } else { + var size = { + height: this.$measureNode.clientHeight, + width: this.$measureNode.clientWidth / CHAR_COUNT + }; + } + // Size and width can be null if the editor is not visible or + // detached from the document + if (size.width === 0 || size.height === 0) + return null; + return size; + }; + + this.$measureCharWidth = function(ch) { + this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT); + var rect = this.$main.getBoundingClientRect(); + return rect.width / CHAR_COUNT; + }; + + this.getCharacterWidth = function(ch) { + var w = this.charSizes[ch]; + if (w === undefined) { + w = this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width; + } + return w; + }; + + this.destroy = function() { + clearInterval(this.$pollSizeChangesTimer); + if (this.el && this.el.parentNode) + this.el.parentNode.removeChild(this.el); + }; + +}).call(FontMetrics.prototype); + +}); diff --git a/public/lib/ace/layer/gutter.js b/public/lib/ace/layer/gutter.js new file mode 100644 index 0000000..18fe335 --- /dev/null +++ b/public/lib/ace/layer/gutter.js @@ -0,0 +1,285 @@ +/* ***** 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 dom = require("../lib/dom"); +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; + +var Gutter = function(parentEl) { + this.element = dom.createElement("div"); + this.element.className = "ace_layer ace_gutter-layer"; + parentEl.appendChild(this.element); + this.setShowFoldWidgets(this.$showFoldWidgets); + + this.gutterWidth = 0; + + this.$annotations = []; + this.$updateAnnotations = this.$updateAnnotations.bind(this); + + this.$cells = []; +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.setSession = function(session) { + if (this.session) + this.session.removeEventListener("change", this.$updateAnnotations); + this.session = session; + if (session) + session.on("change", this.$updateAnnotations); + }; + + this.addGutterDecoration = function(row, className){ + if (window.console) + console.warn && console.warn("deprecated use session.addGutterDecoration"); + this.session.addGutterDecoration(row, className); + }; + + this.removeGutterDecoration = function(row, className){ + if (window.console) + console.warn && console.warn("deprecated use session.removeGutterDecoration"); + this.session.removeGutterDecoration(row, className); + }; + + this.setAnnotations = function(annotations) { + // iterate over sparse array + this.$annotations = []; + for (var i = 0; i < annotations.length; i++) { + var annotation = annotations[i]; + var row = annotation.row; + var rowInfo = this.$annotations[row]; + if (!rowInfo) + rowInfo = this.$annotations[row] = {text: []}; + + var annoText = annotation.text; + annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || ""; + + if (rowInfo.text.indexOf(annoText) === -1) + rowInfo.text.push(annoText); + + var type = annotation.type; + if (type == "error") + rowInfo.className = " ace_error"; + else if (type == "warning" && rowInfo.className != " ace_error") + rowInfo.className = " ace_warning"; + else if (type == "info" && (!rowInfo.className)) + rowInfo.className = " ace_info"; + } + }; + + this.$updateAnnotations = function (delta) { + if (!this.$annotations.length) + return; + var firstRow = delta.start.row; + var len = delta.end.row - firstRow; + if (len === 0) { + // do nothing + } else if (delta.action == 'remove') { + this.$annotations.splice(firstRow, len + 1, null); + } else { + var args = new Array(len + 1); + args.unshift(firstRow, 1); + this.$annotations.splice.apply(this.$annotations, args); + } + }; + + this.update = function(config) { + var session = this.session; + var firstRow = config.firstRow; + var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar + session.getLength() - 1); + var fold = session.getNextFoldLine(firstRow); + var foldStart = fold ? fold.start.row : Infinity; + var foldWidgets = this.$showFoldWidgets && session.foldWidgets; + var breakpoints = session.$breakpoints; + var decorations = session.$decorations; + var firstLineNumber = session.$firstLineNumber; + var lastLineNumber = 0; + + var gutterRenderer = session.gutterRenderer || this.$renderer; + + var cell = null; + var index = -1; + var row = firstRow; + while (true) { + if (row > foldStart) { + row = fold.end.row + 1; + fold = session.getNextFoldLine(row, fold); + foldStart = fold ? fold.start.row : Infinity; + } + if (row > lastRow) { + while (this.$cells.length > index + 1) { + cell = this.$cells.pop(); + this.element.removeChild(cell.element); + } + break; + } + + cell = this.$cells[++index]; + if (!cell) { + cell = {element: null, textNode: null, foldWidget: null}; + cell.element = dom.createElement("div"); + cell.textNode = document.createTextNode(''); + cell.element.appendChild(cell.textNode); + this.element.appendChild(cell.element); + this.$cells[index] = cell; + } + + var className = "ace_gutter-cell "; + if (breakpoints[row]) + className += breakpoints[row]; + if (decorations[row]) + className += decorations[row]; + if (this.$annotations[row]) + className += this.$annotations[row].className; + if (cell.element.className != className) + cell.element.className = className; + + var height = session.getRowLength(row) * config.lineHeight + "px"; + if (height != cell.element.style.height) + cell.element.style.height = height; + + if (foldWidgets) { + var c = foldWidgets[row]; + // check if cached value is invalidated and we need to recompute + if (c == null) + c = foldWidgets[row] = session.getFoldWidget(row); + } + + if (c) { + if (!cell.foldWidget) { + cell.foldWidget = dom.createElement("span"); + cell.element.appendChild(cell.foldWidget); + } + var className = "ace_fold-widget ace_" + c; + if (c == "start" && row == foldStart && row < fold.end.row) + className += " ace_closed"; + else + className += " ace_open"; + if (cell.foldWidget.className != className) + cell.foldWidget.className = className; + + var height = config.lineHeight + "px"; + if (cell.foldWidget.style.height != height) + cell.foldWidget.style.height = height; + } else { + if (cell.foldWidget) { + cell.element.removeChild(cell.foldWidget); + cell.foldWidget = null; + } + } + + var text = lastLineNumber = gutterRenderer + ? gutterRenderer.getText(session, row) + : row + firstLineNumber; + if (text !== cell.textNode.data) + cell.textNode.data = text; + + row++; + } + + this.element.style.height = config.minHeight + "px"; + + if (this.$fixedWidth || session.$useWrapMode) + lastLineNumber = session.getLength() + firstLineNumber; + + var gutterWidth = gutterRenderer + ? gutterRenderer.getWidth(session, lastLineNumber, config) + : lastLineNumber.toString().length * config.characterWidth; + + var padding = this.$padding || this.$computePadding(); + gutterWidth += padding.left + padding.right; + if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) { + this.gutterWidth = gutterWidth; + this.element.style.width = Math.ceil(this.gutterWidth) + "px"; + this._emit("changeGutterWidth", gutterWidth); + } + }; + + this.$fixedWidth = false; + + this.$showLineNumbers = true; + this.$renderer = ""; + this.setShowLineNumbers = function(show) { + this.$renderer = !show && { + getWidth: function() {return "";}, + getText: function() {return "";} + }; + }; + + this.getShowLineNumbers = function() { + return this.$showLineNumbers; + }; + + this.$showFoldWidgets = true; + this.setShowFoldWidgets = function(show) { + if (show) + dom.addCssClass(this.element, "ace_folding-enabled"); + else + dom.removeCssClass(this.element, "ace_folding-enabled"); + + this.$showFoldWidgets = show; + this.$padding = null; + }; + + this.getShowFoldWidgets = function() { + return this.$showFoldWidgets; + }; + + this.$computePadding = function() { + if (!this.element.firstChild) + return {left: 0, right: 0}; + var style = dom.computedStyle(this.element.firstChild); + this.$padding = {}; + this.$padding.left = parseInt(style.paddingLeft) + 1 || 0; + this.$padding.right = parseInt(style.paddingRight) || 0; + return this.$padding; + }; + + this.getRegion = function(point) { + var padding = this.$padding || this.$computePadding(); + var rect = this.element.getBoundingClientRect(); + if (point.x < padding.left + rect.left) + return "markers"; + if (this.$showFoldWidgets && point.x > rect.right - padding.right) + return "foldWidgets"; + }; + +}).call(Gutter.prototype); + +exports.Gutter = Gutter; + +}); diff --git a/public/lib/ace/layer/marker.js b/public/lib/ace/layer/marker.js new file mode 100644 index 0000000..6abed35 --- /dev/null +++ b/public/lib/ace/layer/marker.js @@ -0,0 +1,262 @@ +/* ***** 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 Range = require("../range").Range; +var dom = require("../lib/dom"); + +var Marker = function(parentEl) { + this.element = dom.createElement("div"); + this.element.className = "ace_layer ace_marker-layer"; + parentEl.appendChild(this.element); +}; + +(function() { + + this.$padding = 0; + + this.setPadding = function(padding) { + this.$padding = padding; + }; + this.setSession = function(session) { + this.session = session; + }; + + this.setMarkers = function(markers) { + this.markers = markers; + }; + + this.update = function(config) { + if (!config) return; + + this.config = config; + + + var html = []; + for (var key in this.markers) { + var marker = this.markers[key]; + + if (!marker.range) { + marker.update(html, this, this.session, config); + continue; + } + + var range = marker.range.clipRows(config.firstRow, config.lastRow); + if (range.isEmpty()) continue; + + range = range.toScreenRange(this.session); + if (marker.renderer) { + var top = this.$getTop(range.start.row, config); + var left = this.$padding + (this.session.$bidiHandler.isBidiRow(range.start.row) + ? this.session.$bidiHandler.getPosLeft(range.start.column) + : range.start.column * config.characterWidth); + marker.renderer(html, range, left, top, config); + } else if (marker.type == "fullLine") { + this.drawFullLineMarker(html, range, marker.clazz, config); + } else if (marker.type == "screenLine") { + this.drawScreenLineMarker(html, range, marker.clazz, config); + } else if (range.isMultiLine()) { + if (marker.type == "text") + this.drawTextMarker(html, range, marker.clazz, config); + else + this.drawMultiLineMarker(html, range, marker.clazz, config); + } else { + if (this.session.$bidiHandler.isBidiRow(range.start.row)) { + this.drawBidiSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); + } else { + this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); + } + } + } + this.element.innerHTML = html.join(""); + }; + + this.$getTop = function(row, layerConfig) { + return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight; + }; + + function getBorderClass(tl, tr, br, bl) { + return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0); + } + // Draws a marker, which spans a range of text on multiple lines + this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) { + var session = this.session; + var start = range.start.row; + var end = range.end.row; + var row = start; + var prev = 0; + var curr = 0; + var next = session.getScreenLastRowColumn(row); + var clazzModified = null; + var lineRange = new Range(row, range.start.column, row, curr); + for (; row <= end; row++) { + lineRange.start.row = lineRange.end.row = row; + lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row); + lineRange.end.column = next; + prev = curr; + curr = next; + next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column; + clazzModified = clazz + (row == start ? " ace_start" : "") + " ace_br" + + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end); + + if (this.session.$bidiHandler.isBidiRow(row)) { + this.drawBidiSingleLineMarker(stringBuilder, lineRange, clazzModified, + layerConfig, row == end ? 0 : 1, extraStyle); + } else { + this.drawSingleLineMarker(stringBuilder, lineRange, clazzModified, + layerConfig, row == end ? 0 : 1, extraStyle); + } + } + }; + + // Draws a multi line marker, where lines span the full width + this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { + // from selection start to the end of the line + var padding = this.$padding; + var height, top, left; + extraStyle = extraStyle || ""; + if (this.session.$bidiHandler.isBidiRow(range.start.row)) { + var range1 = range.clone(); + range1.end.row = range1.start.row; + range1.end.column = this.session.getLine(range1.start.row).length; + this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle); + } else { + height = config.lineHeight; + top = this.$getTop(range.start.row, config); + left = padding + range.start.column * config.characterWidth; + stringBuilder.push( + "
" + ); + } + // from start of the last line to the selection end + if (this.session.$bidiHandler.isBidiRow(range.end.row)) { + var range1 = range.clone(); + range1.start.row = range1.end.row; + range1.start.column = 0; + this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle); + } else { + var width = range.end.column * config.characterWidth; + height = config.lineHeight; + top = this.$getTop(range.end.row, config); + stringBuilder.push( + "
" + ); + } + // all the complete lines + height = (range.end.row - range.start.row - 1) * config.lineHeight; + if (height <= 0) + return; + top = this.$getTop(range.start.row + 1, config); + + var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8); + + stringBuilder.push( + "
" + ); + }; + + // Draws a marker which covers part or whole width of a single screen line + this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { + var height = config.lineHeight; + var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth; + + var top = this.$getTop(range.start.row, config); + var left = this.$padding + range.start.column * config.characterWidth; + + stringBuilder.push( + "
" + ); + }; + + // Draws Bidi marker which covers part or whole width of a single screen line + this.drawBidiSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { + var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding; + var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column); + + selections.forEach(function(selection) { + stringBuilder.push( + "
" + ); + }); + }; + + this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { + var top = this.$getTop(range.start.row, config); + var height = config.lineHeight; + if (range.start.row != range.end.row) + height += this.$getTop(range.end.row, config) - top; + + stringBuilder.push( + "
" + ); + }; + + this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { + var top = this.$getTop(range.start.row, config); + var height = config.lineHeight; + + stringBuilder.push( + "
" + ); + }; + +}).call(Marker.prototype); + +exports.Marker = Marker; + +}); diff --git a/public/lib/ace/layer/text.js b/public/lib/ace/layer/text.js new file mode 100644 index 0000000..0abfd72 --- /dev/null +++ b/public/lib/ace/layer/text.js @@ -0,0 +1,579 @@ +/* ***** 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 oop = require("../lib/oop"); +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var useragent = require("../lib/useragent"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; + +var Text = function(parentEl) { + this.element = dom.createElement("div"); + this.element.className = "ace_layer ace_text-layer"; + parentEl.appendChild(this.element); + this.$updateEolChar = this.$updateEolChar.bind(this); +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.EOF_CHAR = "\xB6"; + this.EOL_CHAR_LF = "\xAC"; + this.EOL_CHAR_CRLF = "\xa4"; + this.EOL_CHAR = this.EOL_CHAR_LF; + this.TAB_CHAR = "\u2014"; //"\u21E5"; + this.SPACE_CHAR = "\xB7"; + this.$padding = 0; + + this.$updateEolChar = function() { + var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n" + ? this.EOL_CHAR_LF + : this.EOL_CHAR_CRLF; + if (this.EOL_CHAR != EOL_CHAR) { + this.EOL_CHAR = EOL_CHAR; + return true; + } + }; + + this.setPadding = function(padding) { + this.$padding = padding; + this.element.style.padding = "0 " + padding + "px"; + }; + + this.getLineHeight = function() { + return this.$fontMetrics.$characterSize.height || 0; + }; + + this.getCharacterWidth = function() { + return this.$fontMetrics.$characterSize.width || 0; + }; + + this.$setFontMetrics = function(measure) { + this.$fontMetrics = measure; + this.$fontMetrics.on("changeCharacterSize", function(e) { + this._signal("changeCharacterSize", e); + }.bind(this)); + this.$pollSizeChanges(); + }; + + this.checkForSizeChanges = function() { + this.$fontMetrics.checkForSizeChanges(); + }; + this.$pollSizeChanges = function() { + return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges(); + }; + this.setSession = function(session) { + this.session = session; + if (session) + this.$computeTabString(); + }; + + this.showInvisibles = false; + this.setShowInvisibles = function(showInvisibles) { + if (this.showInvisibles == showInvisibles) + return false; + + this.showInvisibles = showInvisibles; + this.$computeTabString(); + return true; + }; + + this.displayIndentGuides = true; + this.setDisplayIndentGuides = function(display) { + if (this.displayIndentGuides == display) + return false; + + this.displayIndentGuides = display; + this.$computeTabString(); + return true; + }; + + this.$tabStrings = []; + this.onChangeTabSize = + this.$computeTabString = function() { + var tabSize = this.session.getTabSize(); + this.tabSize = tabSize; + var tabStr = this.$tabStrings = [0]; + for (var i = 1; i < tabSize + 1; i++) { + if (this.showInvisibles) { + tabStr.push("" + + lang.stringRepeat(this.TAB_CHAR, i) + + ""); + } else { + tabStr.push(lang.stringRepeat(" ", i)); + } + } + if (this.displayIndentGuides) { + this.$indentGuideRe = /\s\S| \t|\t |\s$/; + var className = "ace_indent-guide"; + var spaceClass = ""; + var tabClass = ""; + if (this.showInvisibles) { + className += " ace_invisible"; + spaceClass = " ace_invisible_space"; + tabClass = " ace_invisible_tab"; + var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); + var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); + } else{ + var spaceContent = lang.stringRepeat(" ", this.tabSize); + var tabContent = spaceContent; + } + + this.$tabStrings[" "] = "" + spaceContent + ""; + this.$tabStrings["\t"] = "" + tabContent + ""; + } + }; + + this.updateLines = function(config, firstRow, lastRow) { + // Due to wrap line changes there can be new lines if e.g. + // the line to updated wrapped in the meantime. + if (this.config.lastRow != config.lastRow || + this.config.firstRow != config.firstRow) { + this.scrollLines(config); + } + this.config = config; + + var first = Math.max(firstRow, config.firstRow); + var last = Math.min(lastRow, config.lastRow); + + var lineElements = this.element.childNodes; + var lineElementsIdx = 0; + + for (var row = config.firstRow; row < first; row++) { + var foldLine = this.session.getFoldLine(row); + if (foldLine) { + if (foldLine.containsRow(first)) { + first = foldLine.start.row; + break; + } else { + row = foldLine.end.row; + } + } + lineElementsIdx ++; + } + + var row = first; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row :Infinity; + } + if (row > last) + break; + + var lineElement = lineElements[lineElementsIdx++]; + if (lineElement) { + var html = []; + this.$renderLine( + html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false + ); + lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; + lineElement.innerHTML = html.join(""); + } + row++; + } + }; + + this.scrollLines = function(config) { + var oldConfig = this.config; + this.config = config; + + if (!oldConfig || oldConfig.lastRow < config.firstRow) + return this.update(config); + + if (config.lastRow < oldConfig.firstRow) + return this.update(config); + + var el = this.element; + if (oldConfig.firstRow < config.firstRow) + for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) + el.removeChild(el.firstChild); + + if (oldConfig.lastRow > config.lastRow) + for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--) + el.removeChild(el.lastChild); + + if (config.firstRow < oldConfig.firstRow) { + var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1); + if (el.firstChild) + el.insertBefore(fragment, el.firstChild); + else + el.appendChild(fragment); + } + + if (config.lastRow > oldConfig.lastRow) { + var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow); + el.appendChild(fragment); + } + }; + + this.$renderLinesFragment = function(config, firstRow, lastRow) { + var fragment = this.element.ownerDocument.createDocumentFragment(); + var row = firstRow; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row : Infinity; + } + if (row > lastRow) + break; + + var container = dom.createElement("div"); + + var html = []; + // Get the tokens per line as there might be some lines in between + // beeing folded. + this.$renderLine(html, row, false, row == foldStart ? foldLine : false); + + // don't use setInnerHtml since we are working with an empty DIV + container.innerHTML = html.join(""); + if (this.$useLineGroups()) { + container.className = 'ace_line_group'; + fragment.appendChild(container); + container.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; + + } else { + while(container.firstChild) + fragment.appendChild(container.firstChild); + } + + row++; + } + return fragment; + }; + + this.update = function(config) { + this.config = config; + + var html = []; + var firstRow = config.firstRow, lastRow = config.lastRow; + + var row = firstRow; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row :Infinity; + } + if (row > lastRow) + break; + + if (this.$useLineGroups()) + html.push("
"); + + this.$renderLine(html, row, false, row == foldStart ? foldLine : false); + + if (this.$useLineGroups()) + html.push("
"); // end the line group + + row++; + } + this.element.innerHTML = html.join(""); + }; + + this.$textToken = { + "text": true, + "rparen": true, + "lparen": true + }; + + this.$renderToken = function(stringBuilder, screenColumn, token, value) { + var self = this; + var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g; + var replaceFunc = function(c, a, b, tabIdx, idx4) { + if (a) { + return self.showInvisibles + ? "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" + : c; + } else if (c == "&") { + return "&"; + } else if (c == "<") { + return "<"; + } else if (c == ">") { + // normally escaping this is not needed, but xml documents throw error when setting innerHTML to ]]> + return ">"; + } else if (c == "\t") { + var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx); + screenColumn += tabSize - 1; + return self.$tabStrings[tabSize]; + } else if (c == "\u3000") { + // U+3000 is both invisible AND full-width, so must be handled uniquely + var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + var space = self.showInvisibles ? self.SPACE_CHAR : ""; + screenColumn += 1; + return "" + space + ""; + } else if (b) { + return "" + self.SPACE_CHAR + ""; + } else { + screenColumn += 1; + return "" + c + ""; + } + }; + + var output = value.replace(replaceReg, replaceFunc); + + if (!this.$textToken[token.type]) { + var classes = "ace_" + token.type.replace(/\./g, " ace_"); + var style = ""; + if (token.type == "fold") + style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' "; + stringBuilder.push("", output, ""); + } + else { + stringBuilder.push(output); + } + return screenColumn + value.length; + }; + + this.renderIndentGuide = function(stringBuilder, value, max) { + var cols = value.search(this.$indentGuideRe); + if (cols <= 0 || cols >= max) + return value; + if (value[0] == " ") { + cols -= cols % this.tabSize; + stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize)); + return value.substr(cols); + } else if (value[0] == "\t") { + stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols)); + return value.substr(cols); + } + return value; + }; + + this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) { + var chars = 0; + var split = 0; + var splitChars = splits[0]; + var screenColumn = 0; + + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + var value = token.value; + if (i == 0 && this.displayIndentGuides) { + chars = value.length; + value = this.renderIndentGuide(stringBuilder, value, splitChars); + if (!value) + continue; + chars -= value.length; + } + + if (chars + value.length < splitChars) { + screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + chars += value.length; + } else { + while (chars + value.length >= splitChars) { + screenColumn = this.$renderToken( + stringBuilder, screenColumn, + token, value.substring(0, splitChars - chars) + ); + value = value.substring(splitChars - chars); + chars = splitChars; + + if (!onlyContents) { + stringBuilder.push("
", + "
" + ); + } + + stringBuilder.push(lang.stringRepeat("\xa0", splits.indent)); + + split ++; + screenColumn = 0; + splitChars = splits[split] || Number.MAX_VALUE; + } + if (value.length != 0) { + chars += value.length; + screenColumn = this.$renderToken( + stringBuilder, screenColumn, token, value + ); + } + } + } + }; + + this.$renderSimpleLine = function(stringBuilder, tokens) { + var screenColumn = 0; + var token = tokens[0]; + var value = token.value; + if (this.displayIndentGuides) + value = this.renderIndentGuide(stringBuilder, value); + if (value) + screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + for (var i = 1; i < tokens.length; i++) { + token = tokens[i]; + value = token.value; + screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + } + }; + + // row is either first row of foldline or not in fold + this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) { + if (!foldLine && foldLine != false) + foldLine = this.session.getFoldLine(row); + + if (foldLine) + var tokens = this.$getFoldLineTokens(row, foldLine); + else + var tokens = this.session.getTokens(row); + + + if (!onlyContents) { + stringBuilder.push( + "
" + ); + } + + if (tokens.length) { + var splits = this.session.getRowSplitData(row); + if (splits && splits.length) + this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents); + else + this.$renderSimpleLine(stringBuilder, tokens); + } + + if (this.showInvisibles) { + if (foldLine) + row = foldLine.end.row; + + stringBuilder.push( + "", + row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, + "" + ); + } + if (!onlyContents) + stringBuilder.push("
"); + }; + + this.$getFoldLineTokens = function(row, foldLine) { + var session = this.session; + var renderTokens = []; + + function addTokens(tokens, from, to) { + var idx = 0, col = 0; + while ((col + tokens[idx].value.length) < from) { + col += tokens[idx].value.length; + idx++; + + if (idx == tokens.length) + return; + } + if (col != from) { + var value = tokens[idx].value.substring(from - col); + // Check if the token value is longer then the from...to spacing. + if (value.length > (to - from)) + value = value.substring(0, to - from); + + renderTokens.push({ + type: tokens[idx].type, + value: value + }); + + col = from + value.length; + idx += 1; + } + + while (col < to && idx < tokens.length) { + var value = tokens[idx].value; + if (value.length + col > to) { + renderTokens.push({ + type: tokens[idx].type, + value: value.substring(0, to - col) + }); + } else + renderTokens.push(tokens[idx]); + col += value.length; + idx += 1; + } + } + + var tokens = session.getTokens(row); + foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) { + if (placeholder != null) { + renderTokens.push({ + type: "fold", + value: placeholder + }); + } else { + if (isNewRow) + tokens = session.getTokens(row); + + if (tokens.length) + addTokens(tokens, lastColumn, column); + } + }, foldLine.end.row, this.session.getLine(foldLine.end.row).length); + + return renderTokens; + }; + + this.$useLineGroups = function() { + // For the updateLines function to work correctly, it's important that the + // child nodes of this.element correspond on a 1-to-1 basis to rows in the + // document (as distinct from lines on the screen). For sessions that are + // wrapped, this means we need to add a layer to the node hierarchy (tagged + // with the class name ace_line_group). + return this.session.getUseWrapMode(); + }; + + this.destroy = function() { + clearInterval(this.$pollSizeChangesTimer); + if (this.$measureNode) + this.$measureNode.parentNode.removeChild(this.$measureNode); + delete this.$measureNode; + }; + +}).call(Text.prototype); + +exports.Text = Text; + +}); diff --git a/public/lib/ace/layer/text_test.js b/public/lib/ace/layer/text_test.js new file mode 100644 index 0000000..b7dbcc0 --- /dev/null +++ b/public/lib/ace/layer/text_test.js @@ -0,0 +1,126 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("../test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +var assert = require("../test/assertions"); +var EditSession = require("../edit_session").EditSession; +var TextLayer = require("./text").Text; +var JavaScriptMode = require("../mode/javascript").Mode; + +module.exports = { + + setUp: function(next) { + this.session = new EditSession(""); + this.session.setMode(new JavaScriptMode()); + this.textLayer = new TextLayer(document.createElement("div")); + this.textLayer.setSession(this.session); + this.textLayer.config = { + characterWidth: 10, + lineHeight: 20 + }; + next(); + }, + + "test: render line with hard tabs should render the same as lines with soft tabs" : function() { + this.session.setValue("a\ta\ta\t\na a a \n"); + this.textLayer.$computeTabString(); + + // row with hard tabs + var stringBuilder = []; + this.textLayer.$renderLine(stringBuilder, 0); + + // row with soft tabs + var stringBuilder2 = []; + this.textLayer.$renderLine(stringBuilder2, 1); + assert.equal(stringBuilder.join(""), stringBuilder2.join("")); + }, + + "test rendering width of ideographic space (U+3000)" : function() { + this.session.setValue("\u3000"); + + var stringBuilder = []; + this.textLayer.$renderLine(stringBuilder, 0, true); + assert.equal(stringBuilder.join(""), ""); + + this.textLayer.setShowInvisibles(true); + var stringBuilder = []; + this.textLayer.$renderLine(stringBuilder, 0, true); + assert.equal( + stringBuilder.join(""), + "" + this.textLayer.SPACE_CHAR + "" + + "\xB6" + ); + }, + + "test rendering of indent guides" : function() { + var textLayer = this.textLayer; + var EOL = "" + textLayer.EOL_CHAR + ""; + var SPACE = function(i) {return Array(i+1).join(" ");}; + var DOT = function(i) {return Array(i+1).join(textLayer.SPACE_CHAR);}; + var TAB = function(i) {return Array(i+1).join(textLayer.TAB_CHAR);}; + function testRender(results) { + for (var i = results.length; i--; ) { + var stringBuilder = []; + textLayer.$renderLine(stringBuilder, i, true); + assert.equal(stringBuilder.join(""), results[i]); + } + } + + this.session.setValue(" \n\t\tf\n "); + testRender([ + "" + SPACE(4) + "" + SPACE(2), + "" + SPACE(4) + "" + SPACE(4) + "f", + SPACE(3) + ]); + this.textLayer.setShowInvisibles(true); + testRender([ + "" + DOT(4) + "" + DOT(2) + "" + EOL, + "" + TAB(4) + "" + TAB(4) + "f" + EOL + ]); + this.textLayer.setDisplayIndentGuides(false); + testRender([ + "" + DOT(6) + "" + EOL, + "" + TAB(4) + "" + TAB(4) + "f" + EOL + ]); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/lib/app_config.js b/public/lib/ace/lib/app_config.js new file mode 100644 index 0000000..4fe78a1 --- /dev/null +++ b/public/lib/ace/lib/app_config.js @@ -0,0 +1,157 @@ +/* ***** 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) { +"no use strict"; + +var oop = require("./oop"); +var EventEmitter = require("./event_emitter").EventEmitter; + +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) { + return warn('misspelled option "' + name + '"'); + } + 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) { + return warn('misspelled option "' + name + '"'); + } + if (opt.forwardTo) + return this[opt.forwardTo] && this[opt.forwardTo].getOption(name); + return opt && opt.get ? opt.get.call(this) : this["$" + name]; + } +}; + +function warn(message) { + if (typeof console != "undefined" && console.warn) + console.warn.apply(console, arguments); +} + +function reportError(msg, data) { + var e = new Error(msg); + e.data = data; + if (typeof console == "object" && console.error) + console.error(e); + setTimeout(function() { throw e; }); +} + +var AppConfig = function() { + this.$defaultOptions = {}; +}; + +(function() { + // module loading + oop.implement(this, EventEmitter); + /* + * option {name, value, initialValue, setterName, set, get } + */ + this.defineOptions = function(obj, path, options) { + if (!obj.$options) + this.$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; + }; + + this.resetOptions = function(obj) { + Object.keys(obj.$options).forEach(function(key) { + var opt = obj.$options[key]; + if ("value" in opt) + obj.setOption(key, opt.value); + }); + }; + + this.setDefaultValue = function(path, name, value) { + var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {}); + if (opts[name]) { + if (opts.forwardTo) + this.setDefaultValue(opts.forwardTo, name, value); + else + opts[name].value = value; + } + }; + + this.setDefaultValues = function(path, optionHash) { + Object.keys(optionHash).forEach(function(key) { + this.setDefaultValue(path, key, optionHash[key]); + }, this); + }; + + this.warn = warn; + this.reportError = reportError; + +}).call(AppConfig.prototype); + +exports.AppConfig = AppConfig; + +}); diff --git a/public/lib/ace/lib/bidiutil.js b/public/lib/ace/lib/bidiutil.js new file mode 100644 index 0000000..522a8df --- /dev/null +++ b/public/lib/ace/lib/bidiutil.js @@ -0,0 +1,406 @@ +/* ***** 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 ArabicAlefBetIntervalsBegine = ['\u0621', '\u0641']; +var ArabicAlefBetIntervalsEnd = ['\u063A', '\u064a']; +var dir = 0, hiLevel = 0; +var lastArabic = false, hasUBAT_AL = false, hasUBAT_B = false, hasUBAT_S = false, hasBlockSep = false, hasSegSep = false; + +var impTab_LTR = [ + /* L, R, EN, AN, N, IL, Cond */ +/* 0 LTR text */ [ 0, 3, 0, 1, 0, 0, 0 ], +/* 1 LTR+AN */ [ 0, 3, 0, 1, 2, 2, 0 ], +/* 2 LTR+AN+N */ [ 0, 3, 0, 0x11, 2, 0, 1 ], +/* 3 RTL text */ [ 0, 3, 5, 5, 4, 1, 0 ], +/* 4 RTL cont */ [ 0, 3, 0x15, 0x15, 4, 0, 1 ], +/* 5 RTL+EN/AN */ [ 0, 3, 5, 5, 4, 2, 0 ] +]; + +var impTab_RTL = [ + /* L, R, EN, AN, N, IL, Cond */ +/* 0 RTL text */ [ 2, 0, 1, 1, 0, 1, 0 ], +/* 1 RTL+EN/AN */ [ 2, 0, 1, 1, 0, 2, 0 ], +/* 2 LTR text */ [ 2, 0, 2, 1, 3, 2, 0 ], +/* 3 LTR+cont */ [ 2, 0, 2, 0x21, 3, 1, 1 ] +]; + +var LTR = 0, RTL = 1; + +var L = 0; /* left to right */ +var R = 1; /* right to left */ +var EN = 2; /* European digit */ +var AN = 3; /* Arabic-Indic digit */ +var ON = 4; /* neutral */ +var B = 5; /* block separator */ +var S = 6; /* segment separator */ +var AL = 7; /* Arabic Letter */ +var WS = 8; /* white space */ +var CS = 9; /* common digit separator */ +var ES = 10; /* European digit separator */ +var ET = 11; /* European digit terminator */ +var NSM = 12; /* Non Spacing Mark */ +var LRE = 13; /* LRE */ +var RLE = 14; /* RLE */ +var PDF = 15; /* PDF */ +var LRO = 16; /* LRO */ +var RLO = 17; /* RLO */ +var BN = 18; /* Boundary Neutral */ + +var UnicodeTBL00 = [ +BN,BN,BN,BN,BN,BN,BN,BN,BN,S,B,S,WS,B,BN,BN, +BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,B,B,B,S, +WS,ON,ON,ET,ET,ET,ON,ON,ON,ON,ON,ES,CS,ES,CS,CS, +EN,EN,EN,EN,EN,EN,EN,EN,EN,EN,CS,ON,ON,ON,ON,ON, +ON,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L, +L,L,L,L,L,L,L,L,L,L,L,ON,ON,ON,ON,ON, +ON,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L, +L,L,L,L,L,L,L,L,L,L,L,ON,ON,ON,ON,BN, +BN,BN,BN,BN,BN,B,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN, +BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN, +CS,ON,ET,ET,ET,ET,ON,ON,ON,ON,L,ON,ON,BN,ON,ON, +ET,ET,EN,EN,ON,L,ON,ON,ON,EN,L,ON,ON,ON,ON,ON +]; + +var UnicodeTBL20 = [ +WS,WS,WS,WS,WS,WS,WS,WS,WS,WS,WS,BN,BN,BN,L,R , +ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON, +ON,ON,ON,ON,ON,ON,ON,ON,WS,B,LRE,RLE,PDF,LRO,RLO,CS, +ET,ET,ET,ET,ET,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON, +ON,ON,ON,ON,CS,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON, +ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,WS +]; + +function _computeLevels(chars, levels, len, charTypes) { + var impTab = dir ? impTab_RTL : impTab_LTR + , prevState = null, newClass = null, newLevel = null, newState = 0 + , action = null, cond = null, condPos = -1, i = null, ix = null, classes = []; + + if (!charTypes) { + for (i = 0, charTypes = []; i < len; i++) { + charTypes[i] = _getCharacterType(chars[i]); + } + } + hiLevel = dir; + lastArabic = false; + hasUBAT_AL = false; + hasUBAT_B = false; + hasUBAT_S = false; + for (ix = 0; ix < len; ix++){ + prevState = newState; + classes[ix] = newClass = _getCharClass(chars, charTypes, classes, ix); + newState = impTab[prevState][newClass]; + action = newState & 0xF0; + newState &= 0x0F; + levels[ix] = newLevel = impTab[newState][5]; + if (action > 0){ + if (action == 0x10){ + for(i = condPos; i < ix; i++){ + levels[i] = 1; + } + condPos = -1; + } else { + condPos = -1; + } + } + cond = impTab[newState][6]; + if (cond){ + if(condPos == -1){ + condPos = ix; + } + }else{ + if (condPos > -1){ + for(i = condPos; i < ix; i++){ + levels[i] = newLevel; + } + condPos = -1; + } + } + if (charTypes[ix] == B){ + levels[ix] = 0; + } + hiLevel |= newLevel; + } + if (hasUBAT_S){ + for(i = 0; i < len; i++){ + if(charTypes[i] == S){ + levels[i] = dir; + for(var j = i - 1; j >= 0; j--){ + if(charTypes[j] == WS){ + levels[j] = dir; + }else{ + break; + } + } + } + } + } +} + +function _invertLevel(lev, levels, _array) { + if (hiLevel < lev){ + return; + } + if (lev == 1 && dir == RTL && !hasUBAT_B){ + _array.reverse(); + return; + } + var len = _array.length, start = 0, end, lo, hi, tmp; + while(start < len){ + if (levels[start] >= lev){ + end = start + 1; + while(end < len && levels[end] >= lev){ + end++; + } + for(lo = start, hi = end - 1 ; lo < hi; lo++, hi--){ + tmp = _array[lo]; + _array[lo] = _array[hi]; + _array[hi] = tmp; + } + start = end; + } + start++; + } +} + +function _getCharClass(chars, types, classes, ix) { + var cType = types[ix], wType, nType, len, i; + switch(cType){ + case L: + case R: + lastArabic = false; + case ON: + case AN: + return cType; + case EN: + return lastArabic ? AN : EN; + case AL: + lastArabic = true; + hasUBAT_AL = true; + return R; + case WS: + return ON; + case CS: + if (ix < 1 || (ix + 1) >= types.length || + ((wType = classes[ix - 1]) != EN && wType != AN) || + ((nType = types[ix + 1]) != EN && nType != AN)){ + return ON; + } + if (lastArabic){nType = AN;} + return nType == wType ? nType : ON; + case ES: + wType = ix > 0 ? classes[ix - 1] : B; + if (wType == EN && (ix + 1) < types.length && types[ix + 1] == EN){ + return EN; + } + return ON; + case ET: + if (ix > 0 && classes[ix - 1] == EN){ + return EN; + } + if (lastArabic){ + return ON; + } + i = ix + 1; + len = types.length; + while (i < len && types[i] == ET){ + i++; + } + if (i < len && types[i] == EN){ + return EN; + } + return ON; + case NSM: + len = types.length; + i = ix + 1; + while (i < len && types[i] == NSM){ + i++; + } + if (i < len){ + var c = chars[ix], rtlCandidate = (c >= 0x0591 && c <= 0x08FF) || c == 0xFB1E; + + wType = types[i]; + if (rtlCandidate && (wType == R || wType == AL)){ + return R; + } + } + + if (ix < 1 || (wType = types[ix - 1]) == B){ + return ON; + } + return classes[ix - 1]; + case B: + lastArabic = false; + hasUBAT_B = true; + return dir; + case S: + hasUBAT_S = true; + return ON; + case LRE: + case RLE: + case LRO: + case RLO: + case PDF: + lastArabic = false; + case BN: + return ON; + } +} + +function _getCharacterType( ch ) { + var uc = ch.charCodeAt(0), hi = uc >> 8; + + if (hi == 0) { + return ((uc > 0x00BF) ? L : UnicodeTBL00[uc]); + } else if (hi == 5) { + return (/[\u0591-\u05f4]/.test(ch) ? R : L); + } else if (hi == 6) { + if (/[\u0610-\u061a\u064b-\u065f\u06d6-\u06e4\u06e7-\u06ed]/.test(ch)) + return NSM; + else if (/[\u0660-\u0669\u066b-\u066c]/.test(ch)) + return AN; + else if (uc == 0x066A) + return ET; + else if (/[\u06f0-\u06f9]/.test(ch)) + return EN; + else + return AL; + } else if (hi == 0x20 && uc <= 0x205F) { + return UnicodeTBL20[uc & 0xFF]; + } else if (hi == 0xFE) { + return (uc >= 0xFE70 ? AL : ON); + } + return ON; +} + +function _isArabicDiacritics( ch ) { + return (ch >= '\u064b' && ch <= '\u0655'); +} + +/* Strong LTR character (0 - even), regular width */ +exports.L = L; +/* Strong RTL character (1 - odd), Bidi width */ +exports.R = R; +/* European digit (2 - even), regular width */ +exports.EN = EN; +/* Neutral RTL-by-context character (3 - odd), regular width */ +exports.ON_R = 3; +/* Hindi (Arabic) digit (4 - even), Bidi width */ +exports.AN = 4; +/* Arabic LamAlef (5 - odd), Half Bidi width */ +exports.R_H = 5; +/* invisible EOL (6 - even), zero width */ +exports.B = 6; + +exports.DOT = "\xB7"; + +/** + * Performs text reordering by implementing Unicode Bidi algorithm + * with aim to produce logical<->visual map and Bidi levels + * @param {String} text string to be reordered + * @param {Array} unicode character types produced by call to 'hasBidiCharacters' + * @param {Boolean} 'true' for right-to-left text direction, otherwise 'false' + * + * @return {Object} An object containing logicalFromVisual map and Bidi levels + **/ +exports.doBidiReorder = function(text, textCharTypes, isRtl) { + if (text.length < 2) + return {}; + + var chars = text.split(""), logicalFromVisual = new Array(chars.length), + bidiLevels = new Array(chars.length), levels = []; + + dir = isRtl ? RTL : LTR; + + _computeLevels(chars, levels, chars.length, textCharTypes); + + for (var i = 0; i < logicalFromVisual.length; logicalFromVisual[i] = i, i++); + + _invertLevel(2, levels, logicalFromVisual); + _invertLevel(1, levels, logicalFromVisual); + + for (var i = 0; i < logicalFromVisual.length - 1; i++) { //fix levels to reflect character width + if (textCharTypes[i] === AN) { + levels[i] = exports.AN; + } else if (levels[i] === R && ((textCharTypes[i] > AL && textCharTypes[i] < LRE) + || textCharTypes[i] === ON || textCharTypes[i] === BN)) { + levels[i] = exports.ON_R; + } else if ((i > 0 && chars[i - 1] === '\u0644') && /\u0622|\u0623|\u0625|\u0627/.test(chars[i])) { + levels[i - 1] = levels[i] = exports.R_H; + i++; + } + } + /* fix level to mark zero length EOL */ + if (chars[chars.length - 1] === exports.DOT) + levels[chars.length - 1] = exports.B; + + for (var i = 0; i < logicalFromVisual.length; i++) { + bidiLevels[i] = levels[logicalFromVisual[i]]; + } + + return {'logicalFromVisual': logicalFromVisual, 'bidiLevels': bidiLevels}; +}; + +/** + * Performs character classification, to be used in Unicode Bidi algorithm. + * @param {String} text string to be reordered + * @param {Array} unicode character types (to be filled by this method) + * + * @return {Boolean} 'true' if text contains Bidi characters, otherwise 'false' + **/ +exports.hasBidiCharacters = function(text, textCharTypes){ + var ret = false; + for (var i = 0; i < text.length; i++){ + textCharTypes[i] = _getCharacterType(text.charAt(i)); + if (!ret && (textCharTypes[i] == R || textCharTypes[i] == AL)) + ret = true; + } + return ret; +}; + +/** + * Returns visual index corresponding to logical index basing on logicalFromvisual + * map provided by Unicode Bidi algorithm. + * @param {int} logical index of character in text buffer + * @param {Object} object containing logicalFromVisual map + * + * @return {int} visual index (on display) corresponding to logical index + **/ +exports.getVisualFromLogicalIdx = function(logIdx, rowMap) { + for (var i = 0; i < rowMap.logicalFromVisual.length; i++) { + if (rowMap.logicalFromVisual[i] == logIdx) + return i; + } + return 0; +}; + +}); diff --git a/public/lib/ace/lib/dom.js b/public/lib/ace/lib/dom.js new file mode 100644 index 0000000..69c4cb9 --- /dev/null +++ b/public/lib/ace/lib/dom.js @@ -0,0 +1,286 @@ +/* ***** 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 XHTML_NS = "http://www.w3.org/1999/xhtml"; + +exports.getDocumentHead = function(doc) { + if (!doc) + doc = document; + return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement; +}; + +exports.createElement = function(tag, ns) { + return document.createElementNS ? + document.createElementNS(ns || XHTML_NS, tag) : + document.createElement(tag); +}; + +exports.hasCssClass = function(el, name) { + var classes = (el.className + "").split(/\s+/g); + return classes.indexOf(name) !== -1; +}; + +/* +* Add a CSS class to the list of classes on the given node +*/ +exports.addCssClass = function(el, name) { + if (!exports.hasCssClass(el, name)) { + el.className += " " + name; + } +}; + +/* +* Remove a CSS class from the list of classes on the given node +*/ +exports.removeCssClass = function(el, name) { + var classes = el.className.split(/\s+/g); + while (true) { + var index = classes.indexOf(name); + if (index == -1) { + break; + } + classes.splice(index, 1); + } + el.className = classes.join(" "); +}; + +exports.toggleCssClass = function(el, name) { + var classes = el.className.split(/\s+/g), add = true; + while (true) { + var index = classes.indexOf(name); + if (index == -1) { + break; + } + add = false; + classes.splice(index, 1); + } + if (add) + classes.push(name); + + el.className = classes.join(" "); + return add; +}; + + +/* + * Add or remove a CSS class from the list of classes on the given node + * depending on the value of include + */ +exports.setCssClass = function(node, className, include) { + if (include) { + exports.addCssClass(node, className); + } else { + exports.removeCssClass(node, className); + } +}; + +exports.hasCssString = function(id, doc) { + var index = 0, sheets; + doc = doc || document; + + if (doc.createStyleSheet && (sheets = doc.styleSheets)) { + while (index < sheets.length) + if (sheets[index++].owningElement.id === id) return true; + } else if ((sheets = doc.getElementsByTagName("style"))) { + while (index < sheets.length) + if (sheets[index++].id === id) return true; + } + + return false; +}; + +exports.importCssString = function importCssString(cssText, id, doc) { + doc = doc || document; + // If style is already imported return immediately. + if (id && exports.hasCssString(id, doc)) + return null; + + var style; + + if (id) + cssText += "\n/*# sourceURL=ace/css/" + id + " */"; + + if (doc.createStyleSheet) { + style = doc.createStyleSheet(); + style.cssText = cssText; + if (id) + style.owningElement.id = id; + } else { + style = exports.createElement("style"); + style.appendChild(doc.createTextNode(cssText)); + if (id) + style.id = id; + + exports.getDocumentHead(doc).appendChild(style); + } +}; + +exports.importCssStylsheet = function(uri, doc) { + if (doc.createStyleSheet) { + doc.createStyleSheet(uri); + } else { + var link = exports.createElement('link'); + link.rel = 'stylesheet'; + link.href = uri; + + exports.getDocumentHead(doc).appendChild(link); + } +}; + +exports.getInnerWidth = function(element) { + return ( + parseInt(exports.computedStyle(element, "paddingLeft"), 10) + + parseInt(exports.computedStyle(element, "paddingRight"), 10) + + element.clientWidth + ); +}; + +exports.getInnerHeight = function(element) { + return ( + parseInt(exports.computedStyle(element, "paddingTop"), 10) + + parseInt(exports.computedStyle(element, "paddingBottom"), 10) + + element.clientHeight + ); +}; + +exports.scrollbarWidth = function(document) { + var inner = exports.createElement("ace_inner"); + inner.style.width = "100%"; + inner.style.minWidth = "0px"; + inner.style.height = "200px"; + inner.style.display = "block"; + + var outer = exports.createElement("ace_outer"); + var style = outer.style; + + style.position = "absolute"; + style.left = "-10000px"; + style.overflow = "hidden"; + style.width = "200px"; + style.minWidth = "0px"; + style.height = "150px"; + style.display = "block"; + + outer.appendChild(inner); + + var body = document.documentElement; + body.appendChild(outer); + + var noScrollbar = inner.offsetWidth; + + style.overflow = "scroll"; + var withScrollbar = inner.offsetWidth; + + if (noScrollbar == withScrollbar) { + withScrollbar = outer.clientWidth; + } + + body.removeChild(outer); + + return noScrollbar-withScrollbar; +}; + +if (typeof document == "undefined") { + exports.importCssString = function() {}; + return; +} + +if (window.pageYOffset !== undefined) { + exports.getPageScrollTop = function() { + return window.pageYOffset; + }; + + exports.getPageScrollLeft = function() { + return window.pageXOffset; + }; +} +else { + exports.getPageScrollTop = function() { + return document.body.scrollTop; + }; + + exports.getPageScrollLeft = function() { + return document.body.scrollLeft; + }; +} + +if (window.getComputedStyle) + exports.computedStyle = function(element, style) { + if (style) + return (window.getComputedStyle(element, "") || {})[style] || ""; + return window.getComputedStyle(element, "") || {}; + }; +else + exports.computedStyle = function(element, style) { + if (style) + return element.currentStyle[style]; + return element.currentStyle; + }; + +/* + * Optimized set innerHTML. This is faster than plain innerHTML if the element + * already contains a lot of child elements. + * + * See http://blog.stevenlevithan.com/archives/faster-than-innerhtml for details + */ +exports.setInnerHtml = function(el, innerHtml) { + var element = el.cloneNode(false);//document.createElement("div"); + element.innerHTML = innerHtml; + el.parentNode.replaceChild(element, el); + return element; +}; + +if ("textContent" in document.documentElement) { + exports.setInnerText = function(el, innerText) { + el.textContent = innerText; + }; + + exports.getInnerText = function(el) { + return el.textContent; + }; +} +else { + exports.setInnerText = function(el, innerText) { + el.innerText = innerText; + }; + + exports.getInnerText = function(el) { + return el.innerText; + }; +} + +exports.getParentWindow = function(document) { + return document.defaultView || document.parentWindow; +}; + +}); diff --git a/public/lib/ace/lib/es5-shim.js b/public/lib/ace/lib/es5-shim.js new file mode 100644 index 0000000..217bdc6 --- /dev/null +++ b/public/lib/ace/lib/es5-shim.js @@ -0,0 +1,1062 @@ +// https://github.com/kriskowal/es5-shim +// Copyright 2009-2012 by contributors, MIT License + +define(function(require, exports, module) { + +/* + * Brings an environment as close to ECMAScript 5 compliance + * as is possible with the facilities of erstwhile engines. + * + * Annotated ES5: http://es5.github.com/ (specific links below) + * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf + * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/ + */ + +// +// Function +// ======== +// + +// ES-5 15.3.4.5 +// http://es5.github.com/#x15.3.4.5 + +function Empty() {} + +if (!Function.prototype.bind) { + Function.prototype.bind = function bind(that) { // .length is 1 + // 1. Let Target be the this value. + var target = this; + // 2. If IsCallable(Target) is false, throw a TypeError exception. + if (typeof target != "function") { + throw new TypeError("Function.prototype.bind called on incompatible " + target); + } + // 3. Let A be a new (possibly empty) internal list of all of the + // argument values provided after thisArg (arg1, arg2 etc), in order. + // XXX slicedArgs will stand in for "A" if used + var args = slice.call(arguments, 1); // for normal call + // 4. Let F be a new native ECMAScript object. + // 11. Set the [[Prototype]] internal property of F to the standard + // built-in Function prototype object as specified in 15.3.3.1. + // 12. Set the [[Call]] internal property of F as described in + // 15.3.4.5.1. + // 13. Set the [[Construct]] internal property of F as described in + // 15.3.4.5.2. + // 14. Set the [[HasInstance]] internal property of F as described in + // 15.3.4.5.3. + var bound = function () { + + if (this instanceof bound) { + // 15.3.4.5.2 [[Construct]] + // When the [[Construct]] internal method of a function object, + // F that was created using the bind function is called with a + // list of arguments ExtraArgs, the following steps are taken: + // 1. Let target be the value of F's [[TargetFunction]] + // internal property. + // 2. If target has no [[Construct]] internal method, a + // TypeError exception is thrown. + // 3. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Construct]] internal + // method of target providing args as the arguments. + + var result = target.apply( + this, + args.concat(slice.call(arguments)) + ); + if (Object(result) === result) { + return result; + } + return this; + + } else { + // 15.3.4.5.1 [[Call]] + // When the [[Call]] internal method of a function object, F, + // which was created using the bind function is called with a + // this value and a list of arguments ExtraArgs, the following + // steps are taken: + // 1. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 2. Let boundThis be the value of F's [[BoundThis]] internal + // property. + // 3. Let target be the value of F's [[TargetFunction]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Call]] internal method + // of target providing boundThis as the this value and + // providing args as the arguments. + + // equiv: target.call(this, ...boundArgs, ...args) + return target.apply( + that, + args.concat(slice.call(arguments)) + ); + + } + + }; + if(target.prototype) { + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + // Clean up dangling references. + Empty.prototype = null; + } + // XXX bound.length is never writable, so don't even try + // + // 15. If the [[Class]] internal property of Target is "Function", then + // a. Let L be the length property of Target minus the length of A. + // b. Set the length own property of F to either 0 or L, whichever is + // larger. + // 16. Else set the length own property of F to 0. + // 17. Set the attributes of the length own property of F to the values + // specified in 15.3.5.1. + + // TODO + // 18. Set the [[Extensible]] internal property of F to true. + + // TODO + // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3). + // 20. Call the [[DefineOwnProperty]] internal method of F with + // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]: + // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and + // false. + // 21. Call the [[DefineOwnProperty]] internal method of F with + // arguments "arguments", PropertyDescriptor {[[Get]]: thrower, + // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, + // and false. + + // TODO + // NOTE Function objects created using Function.prototype.bind do not + // have a prototype property or the [[Code]], [[FormalParameters]], and + // [[Scope]] internal properties. + // XXX can't delete prototype in pure-js. + + // 22. Return F. + return bound; + }; +} + +// Shortcut to an often accessed properties, in order to avoid multiple +// dereference that costs universally. +// _Please note: Shortcuts are defined after `Function.prototype.bind` as we +// us it in defining shortcuts. +var call = Function.prototype.call; +var prototypeOfArray = Array.prototype; +var prototypeOfObject = Object.prototype; +var slice = prototypeOfArray.slice; +// Having a toString local variable name breaks in Opera so use _toString. +var _toString = call.bind(prototypeOfObject.toString); +var owns = call.bind(prototypeOfObject.hasOwnProperty); + +// If JS engine supports accessors creating shortcuts. +var defineGetter; +var defineSetter; +var lookupGetter; +var lookupSetter; +var supportsAccessors; +if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) { + defineGetter = call.bind(prototypeOfObject.__defineGetter__); + defineSetter = call.bind(prototypeOfObject.__defineSetter__); + lookupGetter = call.bind(prototypeOfObject.__lookupGetter__); + lookupSetter = call.bind(prototypeOfObject.__lookupSetter__); +} + +// +// Array +// ===== +// + +// ES5 15.4.4.12 +// http://es5.github.com/#x15.4.4.12 +// Default value for second param +// [bugfix, ielt9, old browsers] +// IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12" +if ([1,2].splice(0).length != 2) { + if(function() { // test IE < 9 to splice bug - see issue #138 + function makeArray(l) { + var a = new Array(l+2); + a[0] = a[1] = 0; + return a; + } + var array = [], lengthBefore; + + array.splice.apply(array, makeArray(20)); + array.splice.apply(array, makeArray(26)); + + lengthBefore = array.length; //46 + array.splice(5, 0, "XXX"); // add one element + + lengthBefore + 1 == array.length + + if (lengthBefore + 1 == array.length) { + return true;// has right splice implementation without bugs + } + // else { + // IE8 bug + // } + }()) {//IE 6/7 + var array_splice = Array.prototype.splice; + Array.prototype.splice = function(start, deleteCount) { + if (!arguments.length) { + return []; + } else { + return array_splice.apply(this, [ + start === void 0 ? 0 : start, + deleteCount === void 0 ? (this.length - start) : deleteCount + ].concat(slice.call(arguments, 2))) + } + }; + } else {//IE8 + // taken from http://docs.sencha.com/ext-js/4-1/source/Array2.html + Array.prototype.splice = function(pos, removeCount){ + var length = this.length; + if (pos > 0) { + if (pos > length) + pos = length; + } else if (pos == void 0) { + pos = 0; + } else if (pos < 0) { + pos = Math.max(length + pos, 0); + } + + if (!(pos+removeCount < length)) + removeCount = length - pos; + + var removed = this.slice(pos, pos+removeCount); + var insert = slice.call(arguments, 2); + var add = insert.length; + + // we try to use Array.push when we can for efficiency... + if (pos === length) { + if (add) { + this.push.apply(this, insert); + } + } else { + var remove = Math.min(removeCount, length - pos); + var tailOldPos = pos + remove; + var tailNewPos = tailOldPos + add - remove; + var tailCount = length - tailOldPos; + var lengthAfterRemove = length - remove; + + if (tailNewPos < tailOldPos) { // case A + for (var i = 0; i < tailCount; ++i) { + this[tailNewPos+i] = this[tailOldPos+i]; + } + } else if (tailNewPos > tailOldPos) { // case B + for (i = tailCount; i--; ) { + this[tailNewPos+i] = this[tailOldPos+i]; + } + } // else, add == remove (nothing to do) + + if (add && pos === lengthAfterRemove) { + this.length = lengthAfterRemove; // truncate array + this.push.apply(this, insert); + } else { + this.length = lengthAfterRemove + add; // reserves space + for (i = 0; i < add; ++i) { + this[pos+i] = insert[i]; + } + } + } + return removed; + }; + } +} + +// ES5 15.4.3.2 +// http://es5.github.com/#x15.4.3.2 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray +if (!Array.isArray) { + Array.isArray = function isArray(obj) { + return _toString(obj) == "[object Array]"; + }; +} + +// The IsCallable() check in the Array functions +// has been replaced with a strict check on the +// internal class of the object to trap cases where +// the provided function was actually a regular +// expression literal, which in V8 and +// JavaScriptCore is a typeof "function". Only in +// V8 are regular expression literals permitted as +// reduce parameters, so it is desirable in the +// general case for the shim to match the more +// strict and common behavior of rejecting regular +// expressions. + +// ES5 15.4.4.18 +// http://es5.github.com/#x15.4.4.18 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach + +// Check failure of by-index access of string characters (IE < 9) +// and failure of `0 in boxedString` (Rhino) +var boxedString = Object("a"), + splitString = boxedString[0] != "a" || !(0 in boxedString); + +if (!Array.prototype.forEach) { + Array.prototype.forEach = function forEach(fun /*, thisp*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + thisp = arguments[1], + i = -1, + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (_toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + while (++i < length) { + if (i in self) { + // Invoke the callback function with call, passing arguments: + // context, property value, property key, thisArg object + // context + fun.call(thisp, self[i], i, object); + } + } + }; +} + +// ES5 15.4.4.19 +// http://es5.github.com/#x15.4.4.19 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map +if (!Array.prototype.map) { + Array.prototype.map = function map(fun /*, thisp*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + result = Array(length), + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self) + result[i] = fun.call(thisp, self[i], i, object); + } + return result; + }; +} + +// ES5 15.4.4.20 +// http://es5.github.com/#x15.4.4.20 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter +if (!Array.prototype.filter) { + Array.prototype.filter = function filter(fun /*, thisp */) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + result = [], + value, + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self) { + value = self[i]; + if (fun.call(thisp, value, i, object)) { + result.push(value); + } + } + } + return result; + }; +} + +// ES5 15.4.4.16 +// http://es5.github.com/#x15.4.4.16 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every +if (!Array.prototype.every) { + Array.prototype.every = function every(fun /*, thisp */) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self && !fun.call(thisp, self[i], i, object)) { + return false; + } + } + return true; + }; +} + +// ES5 15.4.4.17 +// http://es5.github.com/#x15.4.4.17 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some +if (!Array.prototype.some) { + Array.prototype.some = function some(fun /*, thisp */) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self && fun.call(thisp, self[i], i, object)) { + return true; + } + } + return false; + }; +} + +// ES5 15.4.4.21 +// http://es5.github.com/#x15.4.4.21 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce +if (!Array.prototype.reduce) { + Array.prototype.reduce = function reduce(fun /*, initial*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + // no value to return if no initial value and an empty array + if (!length && arguments.length == 1) { + throw new TypeError("reduce of empty array with no initial value"); + } + + var i = 0; + var result; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i++]; + break; + } + + // if array contains no values, no initial value to return + if (++i >= length) { + throw new TypeError("reduce of empty array with no initial value"); + } + } while (true); + } + + for (; i < length; i++) { + if (i in self) { + result = fun.call(void 0, result, self[i], i, object); + } + } + + return result; + }; +} + +// ES5 15.4.4.22 +// http://es5.github.com/#x15.4.4.22 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight +if (!Array.prototype.reduceRight) { + Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + // no value to return if no initial value, empty array + if (!length && arguments.length == 1) { + throw new TypeError("reduceRight of empty array with no initial value"); + } + + var result, i = length - 1; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i--]; + break; + } + + // if array contains no values, no initial value to return + if (--i < 0) { + throw new TypeError("reduceRight of empty array with no initial value"); + } + } while (true); + } + + do { + if (i in this) { + result = fun.call(void 0, result, self[i], i, object); + } + } while (i--); + + return result; + }; +} + +// ES5 15.4.4.14 +// http://es5.github.com/#x15.4.4.14 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf +if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) { + Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) { + var self = splitString && _toString(this) == "[object String]" ? + this.split("") : + toObject(this), + length = self.length >>> 0; + + if (!length) { + return -1; + } + + var i = 0; + if (arguments.length > 1) { + i = toInteger(arguments[1]); + } + + // handle negative indices + i = i >= 0 ? i : Math.max(0, length + i); + for (; i < length; i++) { + if (i in self && self[i] === sought) { + return i; + } + } + return -1; + }; +} + +// ES5 15.4.4.15 +// http://es5.github.com/#x15.4.4.15 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf +if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) { + Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) { + var self = splitString && _toString(this) == "[object String]" ? + this.split("") : + toObject(this), + length = self.length >>> 0; + + if (!length) { + return -1; + } + var i = length - 1; + if (arguments.length > 1) { + i = Math.min(i, toInteger(arguments[1])); + } + // handle negative indices + i = i >= 0 ? i : length - Math.abs(i); + for (; i >= 0; i--) { + if (i in self && sought === self[i]) { + return i; + } + } + return -1; + }; +} + +// +// Object +// ====== +// + +// ES5 15.2.3.2 +// http://es5.github.com/#x15.2.3.2 +if (!Object.getPrototypeOf) { + // https://github.com/kriskowal/es5-shim/issues#issue/2 + // http://ejohn.org/blog/objectgetprototypeof/ + // recommended by fschaefer on github + Object.getPrototypeOf = function getPrototypeOf(object) { + return object.__proto__ || ( + object.constructor ? + object.constructor.prototype : + prototypeOfObject + ); + }; +} + +// ES5 15.2.3.3 +// http://es5.github.com/#x15.2.3.3 +if (!Object.getOwnPropertyDescriptor) { + var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " + + "non-object: "; + Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT + object); + // If object does not owns property return undefined immediately. + if (!owns(object, property)) + return; + + var descriptor, getter, setter; + + // If object has a property then it's for sure both `enumerable` and + // `configurable`. + descriptor = { enumerable: true, configurable: true }; + + // If JS engine supports accessor properties then property may be a + // getter or setter. + if (supportsAccessors) { + // Unfortunately `__lookupGetter__` will return a getter even + // if object has own non getter property along with a same named + // inherited getter. To avoid misbehavior we temporary remove + // `__proto__` so that `__lookupGetter__` will return getter only + // if it's owned by an object. + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + + var getter = lookupGetter(object, property); + var setter = lookupSetter(object, property); + + // Once we have getter and setter we can put values back. + object.__proto__ = prototype; + + if (getter || setter) { + if (getter) descriptor.get = getter; + if (setter) descriptor.set = setter; + + // If it was accessor property we're done and return here + // in order to avoid adding `value` to the descriptor. + return descriptor; + } + } + + // If we got this far we know that object has an own property that is + // not an accessor so we set it as a value and return descriptor. + descriptor.value = object[property]; + return descriptor; + }; +} + +// ES5 15.2.3.4 +// http://es5.github.com/#x15.2.3.4 +if (!Object.getOwnPropertyNames) { + Object.getOwnPropertyNames = function getOwnPropertyNames(object) { + return Object.keys(object); + }; +} + +// ES5 15.2.3.5 +// http://es5.github.com/#x15.2.3.5 +if (!Object.create) { + var createEmpty; + if (Object.prototype.__proto__ === null) { + createEmpty = function () { + return { "__proto__": null }; + }; + } else { + // In old IE __proto__ can't be used to manually set `null` + createEmpty = function () { + var empty = {}; + for (var i in empty) + empty[i] = null; + empty.constructor = + empty.hasOwnProperty = + empty.propertyIsEnumerable = + empty.isPrototypeOf = + empty.toLocaleString = + empty.toString = + empty.valueOf = + empty.__proto__ = null; + return empty; + } + } + + Object.create = function create(prototype, properties) { + var object; + if (prototype === null) { + object = createEmpty(); + } else { + if (typeof prototype != "object") + throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); + var Type = function () {}; + Type.prototype = prototype; + object = new Type(); + // IE has no built-in implementation of `Object.getPrototypeOf` + // neither `__proto__`, but this manually setting `__proto__` will + // guarantee that `Object.getPrototypeOf` will work as expected with + // objects created using `Object.create` + object.__proto__ = prototype; + } + if (properties !== void 0) + Object.defineProperties(object, properties); + return object; + }; +} + +// ES5 15.2.3.6 +// http://es5.github.com/#x15.2.3.6 + +// Patch for WebKit and IE8 standard mode +// Designed by hax +// related issue: https://github.com/kriskowal/es5-shim/issues#issue/5 +// IE8 Reference: +// http://msdn.microsoft.com/en-us/library/dd282900.aspx +// http://msdn.microsoft.com/en-us/library/dd229916.aspx +// WebKit Bugs: +// https://bugs.webkit.org/show_bug.cgi?id=36423 + +function doesDefinePropertyWork(object) { + try { + Object.defineProperty(object, "sentinel", {}); + return "sentinel" in object; + } catch (exception) { + // returns falsy + } +} + +// check whether defineProperty works if it's given. Otherwise, +// shim partially. +if (Object.defineProperty) { + var definePropertyWorksOnObject = doesDefinePropertyWork({}); + var definePropertyWorksOnDom = typeof document == "undefined" || + doesDefinePropertyWork(document.createElement("div")); + if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { + var definePropertyFallback = Object.defineProperty; + } +} + +if (!Object.defineProperty || definePropertyFallback) { + var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: "; + var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: " + var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " + + "on this javascript engine"; + + Object.defineProperty = function defineProperty(object, property, descriptor) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT_TARGET + object); + if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) + throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); + + // make a valiant attempt to use the real defineProperty + // for I8's DOM elements. + if (definePropertyFallback) { + try { + return definePropertyFallback.call(Object, object, property, descriptor); + } catch (exception) { + // try the shim if the real one doesn't work + } + } + + // If it's a data property. + if (owns(descriptor, "value")) { + // fail silently if "writable", "enumerable", or "configurable" + // are requested but not supported + /* + // alternate approach: + if ( // can't implement these features; allow false but not true + !(owns(descriptor, "writable") ? descriptor.writable : true) || + !(owns(descriptor, "enumerable") ? descriptor.enumerable : true) || + !(owns(descriptor, "configurable") ? descriptor.configurable : true) + ) + throw new RangeError( + "This implementation of Object.defineProperty does not " + + "support configurable, enumerable, or writable." + ); + */ + + if (supportsAccessors && (lookupGetter(object, property) || + lookupSetter(object, property))) + { + // As accessors are supported only on engines implementing + // `__proto__` we can safely override `__proto__` while defining + // a property to make sure that we don't hit an inherited + // accessor. + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + // Deleting a property anyway since getter / setter may be + // defined on object itself. + delete object[property]; + object[property] = descriptor.value; + // Setting original `__proto__` back now. + object.__proto__ = prototype; + } else { + object[property] = descriptor.value; + } + } else { + if (!supportsAccessors) + throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); + // If we got that far then getters and setters can be defined !! + if (owns(descriptor, "get")) + defineGetter(object, property, descriptor.get); + if (owns(descriptor, "set")) + defineSetter(object, property, descriptor.set); + } + + return object; + }; +} + +// ES5 15.2.3.7 +// http://es5.github.com/#x15.2.3.7 +if (!Object.defineProperties) { + Object.defineProperties = function defineProperties(object, properties) { + for (var property in properties) { + if (owns(properties, property)) + Object.defineProperty(object, property, properties[property]); + } + return object; + }; +} + +// ES5 15.2.3.8 +// http://es5.github.com/#x15.2.3.8 +if (!Object.seal) { + Object.seal = function seal(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// ES5 15.2.3.9 +// http://es5.github.com/#x15.2.3.9 +if (!Object.freeze) { + Object.freeze = function freeze(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// detect a Rhino bug and patch it +try { + Object.freeze(function () {}); +} catch (exception) { + Object.freeze = (function freeze(freezeObject) { + return function freeze(object) { + if (typeof object == "function") { + return object; + } else { + return freezeObject(object); + } + }; + })(Object.freeze); +} + +// ES5 15.2.3.10 +// http://es5.github.com/#x15.2.3.10 +if (!Object.preventExtensions) { + Object.preventExtensions = function preventExtensions(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// ES5 15.2.3.11 +// http://es5.github.com/#x15.2.3.11 +if (!Object.isSealed) { + Object.isSealed = function isSealed(object) { + return false; + }; +} + +// ES5 15.2.3.12 +// http://es5.github.com/#x15.2.3.12 +if (!Object.isFrozen) { + Object.isFrozen = function isFrozen(object) { + return false; + }; +} + +// ES5 15.2.3.13 +// http://es5.github.com/#x15.2.3.13 +if (!Object.isExtensible) { + Object.isExtensible = function isExtensible(object) { + // 1. If Type(O) is not Object throw a TypeError exception. + if (Object(object) === object) { + throw new TypeError(); // TODO message + } + // 2. Return the Boolean value of the [[Extensible]] internal property of O. + var name = ''; + while (owns(object, name)) { + name += '?'; + } + object[name] = true; + var returnValue = owns(object, name); + delete object[name]; + return returnValue; + }; +} + +// ES5 15.2.3.14 +// http://es5.github.com/#x15.2.3.14 +if (!Object.keys) { + // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation + var hasDontEnumBug = true, + dontEnums = [ + "toString", + "toLocaleString", + "valueOf", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "constructor" + ], + dontEnumsLength = dontEnums.length; + + for (var key in {"toString": null}) { + hasDontEnumBug = false; + } + + Object.keys = function keys(object) { + + if ( + (typeof object != "object" && typeof object != "function") || + object === null + ) { + throw new TypeError("Object.keys called on a non-object"); + } + + var keys = []; + for (var name in object) { + if (owns(object, name)) { + keys.push(name); + } + } + + if (hasDontEnumBug) { + for (var i = 0, ii = dontEnumsLength; i < ii; i++) { + var dontEnum = dontEnums[i]; + if (owns(object, dontEnum)) { + keys.push(dontEnum); + } + } + } + return keys; + }; + +} + +// +// most of es5-shim Date section is removed since ace doesn't need it, it is too intrusive and it causes problems for users +// ==== +// + +// ES5 15.9.4.4 +// http://es5.github.com/#x15.9.4.4 +if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; +} + + +// +// String +// ====== +// + +// ES5 15.5.4.20 +// http://es5.github.com/#x15.5.4.20 +var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" + + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + + "\u2029\uFEFF"; +if (!String.prototype.trim || ws.trim()) { + // http://blog.stevenlevithan.com/archives/faster-trim-javascript + // http://perfectionkills.com/whitespace-deviations/ + ws = "[" + ws + "]"; + var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), + trimEndRegexp = new RegExp(ws + ws + "*$"); + String.prototype.trim = function trim() { + return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); + }; +} + +// +// Util +// ====== +// + +// ES5 9.4 +// http://es5.github.com/#x9.4 +// http://jsperf.com/to-integer + +function toInteger(n) { + n = +n; + if (n !== n) { // isNaN + n = 0; + } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + return n; +} + +function isPrimitive(input) { + var type = typeof input; + return ( + input === null || + type === "undefined" || + type === "boolean" || + type === "number" || + type === "string" + ); +} + +function toPrimitive(input) { + var val, valueOf, toString; + if (isPrimitive(input)) { + return input; + } + valueOf = input.valueOf; + if (typeof valueOf === "function") { + val = valueOf.call(input); + if (isPrimitive(val)) { + return val; + } + } + toString = input.toString; + if (typeof toString === "function") { + val = toString.call(input); + if (isPrimitive(val)) { + return val; + } + } + throw new TypeError(); +} + +// ES5 9.9 +// http://es5.github.com/#x9.9 +var toObject = function (o) { + if (o == null) { // this matches both null and undefined + throw new TypeError("can't convert "+o+" to object"); + } + return Object(o); +}; + +}); diff --git a/public/lib/ace/lib/event.js b/public/lib/ace/lib/event.js new file mode 100644 index 0000000..fbbf7f7 --- /dev/null +++ b/public/lib/ace/lib/event.js @@ -0,0 +1,400 @@ +/* ***** 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 keys = require("./keys"); +var useragent = require("./useragent"); + +var pressedKeys = null; +var ts = 0; + +exports.addListener = function(elem, type, callback) { + if (elem.addEventListener) { + return elem.addEventListener(type, callback, false); + } + if (elem.attachEvent) { + var wrapper = function() { + callback.call(elem, window.event); + }; + callback._wrapper = wrapper; + elem.attachEvent("on" + type, wrapper); + } +}; + +exports.removeListener = function(elem, type, callback) { + if (elem.removeEventListener) { + return elem.removeEventListener(type, callback, false); + } + if (elem.detachEvent) { + elem.detachEvent("on" + type, callback._wrapper || callback); + } +}; + +/* +* Prevents propagation and clobbers the default action of the passed event +*/ +exports.stopEvent = function(e) { + exports.stopPropagation(e); + exports.preventDefault(e); + return false; +}; + +exports.stopPropagation = function(e) { + if (e.stopPropagation) + e.stopPropagation(); + else + e.cancelBubble = true; +}; + +exports.preventDefault = function(e) { + if (e.preventDefault) + e.preventDefault(); + else + e.returnValue = false; +}; + +/* + * @return {Number} 0 for left button, 1 for middle button, 2 for right button + */ +exports.getButton = function(e) { + if (e.type == "dblclick") + return 0; + if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey))) + return 2; + + // DOM Event + if (e.preventDefault) { + return e.button; + } + // old IE + else { + return {1:0, 2:2, 4:1}[e.button]; + } +}; + +exports.capture = function(el, eventHandler, releaseCaptureHandler) { + function onMouseUp(e) { + eventHandler && eventHandler(e); + releaseCaptureHandler && releaseCaptureHandler(e); + + exports.removeListener(document, "mousemove", eventHandler, true); + exports.removeListener(document, "mouseup", onMouseUp, true); + exports.removeListener(document, "dragstart", onMouseUp, true); + } + + exports.addListener(document, "mousemove", eventHandler, true); + exports.addListener(document, "mouseup", onMouseUp, true); + exports.addListener(document, "dragstart", onMouseUp, true); + + return onMouseUp; +}; + +exports.addTouchMoveListener = function (el, callback) { + var startx, starty; + exports.addListener(el, "touchstart", function (e) { + var touches = e.touches; + var touchObj = touches[0]; + startx = touchObj.clientX; + starty = touchObj.clientY; + }); + exports.addListener(el, "touchmove", function (e) { + var touches = e.touches; + if (touches.length > 1) return; + + var touchObj = touches[0]; + + e.wheelX = startx - touchObj.clientX; + e.wheelY = starty - touchObj.clientY; + + startx = touchObj.clientX; + starty = touchObj.clientY; + + callback(e); + }); +}; + +exports.addMouseWheelListener = function(el, callback) { + if ("onmousewheel" in el) { + exports.addListener(el, "mousewheel", function(e) { + var factor = 8; + if (e.wheelDeltaX !== undefined) { + e.wheelX = -e.wheelDeltaX / factor; + e.wheelY = -e.wheelDeltaY / factor; + } else { + e.wheelX = 0; + e.wheelY = -e.wheelDelta / factor; + } + callback(e); + }); + } else if ("onwheel" in el) { + exports.addListener(el, "wheel", function(e) { + var factor = 0.35; + switch (e.deltaMode) { + case e.DOM_DELTA_PIXEL: + e.wheelX = e.deltaX * factor || 0; + e.wheelY = e.deltaY * factor || 0; + break; + case e.DOM_DELTA_LINE: + case e.DOM_DELTA_PAGE: + e.wheelX = (e.deltaX || 0) * 5; + e.wheelY = (e.deltaY || 0) * 5; + break; + } + + callback(e); + }); + } else { + exports.addListener(el, "DOMMouseScroll", function(e) { + if (e.axis && e.axis == e.HORIZONTAL_AXIS) { + e.wheelX = (e.detail || 0) * 5; + e.wheelY = 0; + } else { + e.wheelX = 0; + e.wheelY = (e.detail || 0) * 5; + } + callback(e); + }); + } +}; + +exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, callbackName) { + var clicks = 0; + var startX, startY, timer; + var eventNames = { + 2: "dblclick", + 3: "tripleclick", + 4: "quadclick" + }; + + function onMousedown(e) { + if (exports.getButton(e) !== 0) { + clicks = 0; + } else if (e.detail > 1) { + clicks++; + if (clicks > 4) + clicks = 1; + } else { + clicks = 1; + } + if (useragent.isIE) { + var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5; + if (!timer || isNewClick) + clicks = 1; + if (timer) + clearTimeout(timer); + timer = setTimeout(function() {timer = null;}, timeouts[clicks - 1] || 600); + + if (clicks == 1) { + startX = e.clientX; + startY = e.clientY; + } + } + + e._clicks = clicks; + + eventHandler[callbackName]("mousedown", e); + + if (clicks > 4) + clicks = 0; + else if (clicks > 1) + return eventHandler[callbackName](eventNames[clicks], e); + } + function onDblclick(e) { + clicks = 2; + if (timer) + clearTimeout(timer); + timer = setTimeout(function() {timer = null;}, timeouts[clicks - 1] || 600); + eventHandler[callbackName]("mousedown", e); + eventHandler[callbackName](eventNames[clicks], e); + } + if (!Array.isArray(elements)) + elements = [elements]; + elements.forEach(function(el) { + exports.addListener(el, "mousedown", onMousedown); + if (useragent.isOldIE) + exports.addListener(el, "dblclick", onDblclick); + }); +}; + +var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window) + ? function(e) { + return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0); + } + : function(e) { + return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0); + }; + +exports.getModifierString = function(e) { + return keys.KEY_MODS[getModifierHash(e)]; +}; + +function normalizeCommandKeys(callback, e, keyCode) { + var hashId = getModifierHash(e); + + if (!useragent.isMac && pressedKeys) { + if (e.getModifierState && (e.getModifierState("OS") || e.getModifierState("Win"))) + hashId |= 8; + if (pressedKeys.altGr) { + if ((3 & hashId) != 3) + pressedKeys.altGr = 0; + else + return; + } + if (keyCode === 18 || keyCode === 17) { + var location = "location" in e ? e.location : e.keyLocation; + if (keyCode === 17 && location === 1) { + if (pressedKeys[keyCode] == 1) + ts = e.timeStamp; + } else if (keyCode === 18 && hashId === 3 && location === 2) { + var dt = e.timeStamp - ts; + if (dt < 50) + pressedKeys.altGr = true; + } + } + } + + if (keyCode in keys.MODIFIER_KEYS) { + keyCode = -1; + } + + // keyCode of right command is 93 on mac and 92 on windows. + // keyCode of left command key is 91 + if (hashId & 8 && (keyCode >= 91 && keyCode <= 93)) { + keyCode = -1; + } + + if (!hashId && keyCode === 13) { + var location = "location" in e ? e.location : e.keyLocation; + if (location === 3) { + callback(e, hashId, -keyCode); + if (e.defaultPrevented) + return; + } + } + + if (useragent.isChromeOS && hashId & 8) { + callback(e, hashId, keyCode); + if (e.defaultPrevented) + return; + else + hashId &= ~8; + } + + // If there is no hashId and the keyCode is not a function key, then + // we don't call the callback as we don't handle a command key here + // (it's a normal key/character input). + if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) { + return false; + } + + return callback(e, hashId, keyCode); +} + + +exports.addCommandKeyListener = function(el, callback) { + var addListener = exports.addListener; + if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) { + // Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown + // event if the user pressed the key for a longer time. Instead, the + // keydown event was fired once and later on only the keypress event. + // To emulate the 'right' keydown behavior, the keyCode of the initial + // keyDown event is stored and in the following keypress events the + // stores keyCode is used to emulate a keyDown event. + var lastKeyDownKeyCode = null; + addListener(el, "keydown", function(e) { + lastKeyDownKeyCode = e.keyCode; + }); + addListener(el, "keypress", function(e) { + return normalizeCommandKeys(callback, e, lastKeyDownKeyCode); + }); + } else { + var lastDefaultPrevented = null; + + addListener(el, "keydown", function(e) { + pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1; + var result = normalizeCommandKeys(callback, e, e.keyCode); + lastDefaultPrevented = e.defaultPrevented; + return result; + }); + + addListener(el, "keypress", function(e) { + if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) { + exports.stopEvent(e); + lastDefaultPrevented = null; + } + }); + + addListener(el, "keyup", function(e) { + pressedKeys[e.keyCode] = null; + }); + + if (!pressedKeys) { + resetPressedKeys(); + addListener(window, "focus", resetPressedKeys); + } + } +}; +function resetPressedKeys() { + // console.log("resetting") + pressedKeys = Object.create(null); +} + +if (typeof window == "object" && window.postMessage && !useragent.isOldIE) { + var postMessageId = 1; + exports.nextTick = function(callback, win) { + win = win || window; + var messageName = "zero-timeout-message-" + postMessageId; + exports.addListener(win, "message", function listener(e) { + if (e.data == messageName) { + exports.stopPropagation(e); + exports.removeListener(win, "message", listener); + callback(); + } + }); + win.postMessage(messageName, "*"); + }; +} + + +exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame + || window.mozRequestAnimationFrame + || window.webkitRequestAnimationFrame + || window.msRequestAnimationFrame + || window.oRequestAnimationFrame); + +if (exports.nextFrame) + exports.nextFrame = exports.nextFrame.bind(window); +else + exports.nextFrame = function(callback) { + setTimeout(callback, 17); + }; +}); diff --git a/public/lib/ace/lib/event_emitter.js b/public/lib/ace/lib/event_emitter.js new file mode 100644 index 0000000..4412e2b --- /dev/null +++ b/public/lib/ace/lib/event_emitter.js @@ -0,0 +1,155 @@ +/* ***** 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 EventEmitter = {}; +var stopPropagation = function() { this.propagationStopped = true; }; +var preventDefault = function() { this.defaultPrevented = true; }; + +EventEmitter._emit = +EventEmitter._dispatchEvent = function(eventName, e) { + this._eventRegistry || (this._eventRegistry = {}); + this._defaultHandlers || (this._defaultHandlers = {}); + + var listeners = this._eventRegistry[eventName] || []; + var defaultHandler = this._defaultHandlers[eventName]; + if (!listeners.length && !defaultHandler) + return; + + if (typeof e != "object" || !e) + e = {}; + + if (!e.type) + e.type = eventName; + if (!e.stopPropagation) + e.stopPropagation = stopPropagation; + if (!e.preventDefault) + e.preventDefault = preventDefault; + + listeners = listeners.slice(); + for (var i=0; i 0) { + if (count & 1) + result += string; + + if (count >>= 1) + string += string; + } + return result; +}; + +var trimBeginRegexp = /^\s\s*/; +var trimEndRegexp = /\s\s*$/; + +exports.stringTrimLeft = function (string) { + return string.replace(trimBeginRegexp, ''); +}; + +exports.stringTrimRight = function (string) { + return string.replace(trimEndRegexp, ''); +}; + +exports.copyObject = function(obj) { + var copy = {}; + for (var key in obj) { + copy[key] = obj[key]; + } + return copy; +}; + +exports.copyArray = function(array){ + var copy = []; + for (var i=0, l=array.length; i + * Provides an augmented, extensible, cross-browser implementation of regular expressions, + * including support for additional syntax, flags, and methods + */ + +define(function(require, exports, module) { +"use strict"; + + //--------------------------------- + // Private variables + //--------------------------------- + + var real = { + exec: RegExp.prototype.exec, + test: RegExp.prototype.test, + match: String.prototype.match, + replace: String.prototype.replace, + split: String.prototype.split + }, + compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups + compliantLastIndexIncrement = function () { + var x = /^/g; + real.test.call(x, ""); + return !x.lastIndex; + }(); + + if (compliantLastIndexIncrement && compliantExecNpcg) + return; + + //--------------------------------- + // Overriden native methods + //--------------------------------- + + // Adds named capture support (with backreferences returned as `result.name`), and fixes two + // cross-browser issues per ES3: + // - Captured values for nonparticipating capturing groups should be returned as `undefined`, + // rather than the empty string. + // - `lastIndex` should not be incremented after zero-length matches. + RegExp.prototype.exec = function (str) { + var match = real.exec.apply(this, arguments), + name, r2; + if ( typeof(str) == 'string' && match) { + // Fix browsers whose `exec` methods don't consistently return `undefined` for + // nonparticipating capturing groups + if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) { + r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", "")); + // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed + // matching due to characters outside the match + real.replace.call(str.slice(match.index), r2, function () { + for (var i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) + match[i] = undefined; + } + }); + } + // Attach named capture properties + if (this._xregexp && this._xregexp.captureNames) { + for (var i = 1; i < match.length; i++) { + name = this._xregexp.captureNames[i - 1]; + if (name) + match[name] = match[i]; + } + } + // Fix browsers that increment `lastIndex` after zero-length matches + if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + } + return match; + }; + + // Don't override `test` if it won't change anything + if (!compliantLastIndexIncrement) { + // Fix browser bug in native method + RegExp.prototype.test = function (str) { + // Use the native `exec` to skip some processing overhead, even though the overriden + // `exec` would take care of the `lastIndex` fix + var match = real.exec.call(this, str); + // Fix browsers that increment `lastIndex` after zero-length matches + if (match && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + return !!match; + }; + } + + //--------------------------------- + // Private helper functions + //--------------------------------- + + function getNativeFlags (regex) { + return (regex.global ? "g" : "") + + (regex.ignoreCase ? "i" : "") + + (regex.multiline ? "m" : "") + + (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3 + (regex.sticky ? "y" : ""); + } + + function indexOf (array, item, from) { + if (Array.prototype.indexOf) // Use the native array method if available + return array.indexOf(item, from); + for (var i = from || 0; i < array.length; i++) { + if (array[i] === item) + return i; + } + return -1; + } + +}); diff --git a/public/lib/ace/lib/useragent.js b/public/lib/ace/lib/useragent.js new file mode 100644 index 0000000..e3e068b --- /dev/null +++ b/public/lib/ace/lib/useragent.js @@ -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"; + +/* + * I hate doing this, but we need some way to determine if the user is on a Mac + * The reason is that users have different expectations of their key combinations. + * + * Take copy as an example, Mac people expect to use CMD or APPLE + C + * Windows folks expect to use CTRL + C + */ +exports.OS = { + LINUX: "LINUX", + MAC: "MAC", + WINDOWS: "WINDOWS" +}; + +/* + * Return an exports.OS constant + */ +exports.getOS = function() { + if (exports.isMac) { + return exports.OS.MAC; + } else if (exports.isLinux) { + return exports.OS.LINUX; + } else { + return exports.OS.WINDOWS; + } +}; + +// this can be called in non browser environments (e.g. from ace/requirejs/text) +if (typeof navigator != "object") + return; + +var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase(); +var ua = navigator.userAgent; + +// Is the user using a browser that identifies itself as Windows +exports.isWin = (os == "win"); + +// Is the user using a browser that identifies itself as Mac OS +exports.isMac = (os == "mac"); + +// Is the user using a browser that identifies itself as Linux +exports.isLinux = (os == "linux"); + +// Windows Store JavaScript apps (aka Metro apps written in HTML5 and JavaScript) do not use the "Microsoft Internet Explorer" string in their user agent, but "MSAppHost" instead. +exports.isIE = + (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0) + ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]) + : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie + +exports.isOldIE = exports.isIE && exports.isIE < 9; + +// Is this Firefox or related? +exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko"; + +// oldGecko == rev < 2.0 +exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv:(\d+)/)||[])[1], 10) < 4; + +// Is this Opera +exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]"; + +// Is the user using a browser that identifies itself as WebKit +exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined; + +exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined; + +exports.isAIR = ua.indexOf("AdobeAIR") >= 0; + +exports.isIPad = ua.indexOf("iPad") >= 0; + +exports.isChromeOS = ua.indexOf(" CrOS ") >= 0; + +exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window.MSStream; + +if (exports.isIOS) exports.isMac = true; + +}); diff --git a/public/lib/ace/line_widgets.js b/public/lib/ace/line_widgets.js new file mode 100644 index 0000000..a7ba708 --- /dev/null +++ b/public/lib/ace/line_widgets.js @@ -0,0 +1,386 @@ +/* ***** 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 oop = require("./lib/oop"); +var dom = require("./lib/dom"); +var Range = require("./range").Range; + + +function LineWidgets(session) { + this.session = session; + this.session.widgetManager = this; + this.session.getRowLength = this.getRowLength; + this.session.$getWidgetScreenLength = this.$getWidgetScreenLength; + this.updateOnChange = this.updateOnChange.bind(this); + this.renderWidgets = this.renderWidgets.bind(this); + this.measureWidgets = this.measureWidgets.bind(this); + this.session._changedWidgets = []; + this.$onChangeEditor = this.$onChangeEditor.bind(this); + + this.session.on("change", this.updateOnChange); + this.session.on("changeFold", this.updateOnFold); + this.session.on("changeEditor", this.$onChangeEditor); +} + +(function() { + this.getRowLength = function(row) { + var h; + if (this.lineWidgets) + h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0; + else + h = 0; + if (!this.$useWrapMode || !this.$wrapData[row]) { + return 1 + h; + } else { + return this.$wrapData[row].length + 1 + h; + } + }; + + this.$getWidgetScreenLength = function() { + var screenRows = 0; + this.lineWidgets.forEach(function(w){ + if (w && w.rowCount && !w.hidden) + screenRows += w.rowCount; + }); + return screenRows; + }; + + this.$onChangeEditor = function(e) { + this.attach(e.editor); + }; + + this.attach = function(editor) { + if (editor && editor.widgetManager && editor.widgetManager != this) + editor.widgetManager.detach(); + + if (this.editor == editor) + return; + + this.detach(); + this.editor = editor; + + if (editor) { + editor.widgetManager = this; + editor.renderer.on("beforeRender", this.measureWidgets); + editor.renderer.on("afterRender", this.renderWidgets); + } + }; + this.detach = function(e) { + var editor = this.editor; + if (!editor) + return; + + this.editor = null; + editor.widgetManager = null; + + editor.renderer.off("beforeRender", this.measureWidgets); + editor.renderer.off("afterRender", this.renderWidgets); + var lineWidgets = this.session.lineWidgets; + lineWidgets && lineWidgets.forEach(function(w) { + if (w && w.el && w.el.parentNode) { + w._inDocument = false; + w.el.parentNode.removeChild(w.el); + } + }); + }; + + this.updateOnFold = function(e, session) { + var lineWidgets = session.lineWidgets; + if (!lineWidgets || !e.action) + return; + var fold = e.data; + var start = fold.start.row; + var end = fold.end.row; + var hide = e.action == "add"; + for (var i = start + 1; i < end; i++) { + if (lineWidgets[i]) + lineWidgets[i].hidden = hide; + } + if (lineWidgets[end]) { + if (hide) { + if (!lineWidgets[start]) + lineWidgets[start] = lineWidgets[end]; + else + lineWidgets[end].hidden = hide; + } else { + if (lineWidgets[start] == lineWidgets[end]) + lineWidgets[start] = undefined; + lineWidgets[end].hidden = hide; + } + } + }; + + this.updateOnChange = function(delta) { + var lineWidgets = this.session.lineWidgets; + if (!lineWidgets) return; + + var startRow = delta.start.row; + var len = delta.end.row - startRow; + + if (len === 0) { + // return + } else if (delta.action == 'remove') { + var removed = lineWidgets.splice(startRow + 1, len); + removed.forEach(function(w) { + w && this.removeLineWidget(w); + }, this); + this.$updateRows(); + } else { + var args = new Array(len); + args.unshift(startRow, 0); + lineWidgets.splice.apply(lineWidgets, args); + this.$updateRows(); + } + }; + + this.$updateRows = function() { + var lineWidgets = this.session.lineWidgets; + if (!lineWidgets) return; + var noWidgets = true; + lineWidgets.forEach(function(w, i) { + if (w) { + noWidgets = false; + w.row = i; + while (w.$oldWidget) { + w.$oldWidget.row = i; + w = w.$oldWidget; + } + } + }); + if (noWidgets) + this.session.lineWidgets = null; + }; + + this.addLineWidget = function(w) { + if (!this.session.lineWidgets) + this.session.lineWidgets = new Array(this.session.getLength()); + + var old = this.session.lineWidgets[w.row]; + if (old) { + w.$oldWidget = old; + if (old.el && old.el.parentNode) { + old.el.parentNode.removeChild(old.el); + old._inDocument = false; + } + } + + this.session.lineWidgets[w.row] = w; + + w.session = this.session; + + var renderer = this.editor.renderer; + if (w.html && !w.el) { + w.el = dom.createElement("div"); + w.el.innerHTML = w.html; + } + if (w.el) { + dom.addCssClass(w.el, "ace_lineWidgetContainer"); + w.el.style.position = "absolute"; + w.el.style.zIndex = 5; + renderer.container.appendChild(w.el); + w._inDocument = true; + } + + if (!w.coverGutter) { + w.el.style.zIndex = 3; + } + if (w.pixelHeight == null) { + w.pixelHeight = w.el.offsetHeight; + } + if (w.rowCount == null) { + w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight; + } + + var fold = this.session.getFoldAt(w.row, 0); + w.$fold = fold; + if (fold) { + var lineWidgets = this.session.lineWidgets; + if (w.row == fold.end.row && !lineWidgets[fold.start.row]) + lineWidgets[fold.start.row] = w; + else + w.hidden = true; + } + + this.session._emit("changeFold", {data:{start:{row: w.row}}}); + + this.$updateRows(); + this.renderWidgets(null, renderer); + this.onWidgetChanged(w); + return w; + }; + + this.removeLineWidget = function(w) { + w._inDocument = false; + w.session = null; + if (w.el && w.el.parentNode) + w.el.parentNode.removeChild(w.el); + if (w.editor && w.editor.destroy) try { + w.editor.destroy(); + } catch(e){} + if (this.session.lineWidgets) { + var w1 = this.session.lineWidgets[w.row]; + if (w1 == w) { + this.session.lineWidgets[w.row] = w.$oldWidget; + if (w.$oldWidget) + this.onWidgetChanged(w.$oldWidget); + } else { + while (w1) { + if (w1.$oldWidget == w) { + w1.$oldWidget = w.$oldWidget; + break; + } + w1 = w1.$oldWidget; + } + } + } + this.session._emit("changeFold", {data:{start:{row: w.row}}}); + this.$updateRows(); + }; + + this.getWidgetsAtRow = function(row) { + var lineWidgets = this.session.lineWidgets; + var w = lineWidgets && lineWidgets[row]; + var list = []; + while (w) { + list.push(w); + w = w.$oldWidget; + } + return list; + }; + + this.onWidgetChanged = function(w) { + this.session._changedWidgets.push(w); + this.editor && this.editor.renderer.updateFull(); + }; + + this.measureWidgets = function(e, renderer) { + var changedWidgets = this.session._changedWidgets; + var config = renderer.layerConfig; + + if (!changedWidgets || !changedWidgets.length) return; + var min = Infinity; + for (var i = 0; i < changedWidgets.length; i++) { + var w = changedWidgets[i]; + if (!w || !w.el) continue; + if (w.session != this.session) continue; + if (!w._inDocument) { + if (this.session.lineWidgets[w.row] != w) + continue; + w._inDocument = true; + renderer.container.appendChild(w.el); + } + + w.h = w.el.offsetHeight; + + if (!w.fixedWidth) { + w.w = w.el.offsetWidth; + w.screenWidth = Math.ceil(w.w / config.characterWidth); + } + + var rowCount = w.h / config.lineHeight; + if (w.coverLine) { + rowCount -= this.session.getRowLineCount(w.row); + if (rowCount < 0) + rowCount = 0; + } + if (w.rowCount != rowCount) { + w.rowCount = rowCount; + if (w.row < min) + min = w.row; + } + } + if (min != Infinity) { + this.session._emit("changeFold", {data:{start:{row: min}}}); + this.session.lineWidgetWidth = null; + } + this.session._changedWidgets = []; + }; + + this.renderWidgets = function(e, renderer) { + var config = renderer.layerConfig; + var lineWidgets = this.session.lineWidgets; + if (!lineWidgets) + return; + var first = Math.min(this.firstRow, config.firstRow); + var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length); + + while (first > 0 && !lineWidgets[first]) + first--; + + this.firstRow = config.firstRow; + this.lastRow = config.lastRow; + + renderer.$cursorLayer.config = config; + for (var i = first; i <= last; i++) { + var w = lineWidgets[i]; + if (!w || !w.el) continue; + if (w.hidden) { + w.el.style.top = -100 - (w.pixelHeight || 0) + "px"; + continue; + } + if (!w._inDocument) { + w._inDocument = true; + renderer.container.appendChild(w.el); + } + var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top; + if (!w.coverLine) + top += config.lineHeight * this.session.getRowLineCount(w.row); + w.el.style.top = top - config.offset + "px"; + + var left = w.coverGutter ? 0 : renderer.gutterWidth; + if (!w.fixedWidth) + left -= renderer.scrollLeft; + w.el.style.left = left + "px"; + + if (w.fullWidth && w.screenWidth) { + w.el.style.minWidth = config.width + 2 * config.padding + "px"; + } + + if (w.fixedWidth) { + w.el.style.right = renderer.scrollBar.getWidth() + "px"; + } else { + w.el.style.right = ""; + } + } + }; + +}).call(LineWidgets.prototype); + + +exports.LineWidgets = LineWidgets; + +}); + + + + diff --git a/public/lib/ace/mode/_test/Readme.md b/public/lib/ace/mode/_test/Readme.md new file mode 100644 index 0000000..c2871c0 --- /dev/null +++ b/public/lib/ace/mode/_test/Readme.md @@ -0,0 +1,9 @@ +`tokens_.json` files keep information about correct tokens and tokenizer states for all modes supported by ace. +They are generated from `text_.txt` or `demo/kitchen-sink/doc/*` with + +```sh +node highlight_rules_test.js -gen +``` + +command. + diff --git a/public/lib/ace/mode/_test/highlight_rules_test.js b/public/lib/ace/mode/_test/highlight_rules_test.js new file mode 100644 index 0000000..d9d4a35 --- /dev/null +++ b/public/lib/ace/mode/_test/highlight_rules_test.js @@ -0,0 +1,250 @@ +var fs = require("fs"); +var path = require("path"); +if (!fs.existsSync) + fs.existsSync = path.existsSync; + +require("amd-loader"); + +var cwd = __dirname + "/"; +var root = path.normalize(cwd + Array(5).join("../")); + +function jsFileList(path, filter) { + if (!filter) filter = /_test/; + return fs.readdirSync(path).map(function(x) { + if (x.slice(-3) == ".js" && !filter.test(x) && !/\s/.test(x)) + return x.slice(0, -3); + }).filter(Boolean); +} + +function modeList() { + return jsFileList(cwd + "../", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/); +} + +function checkModes() { + modeList().forEach(function(modeName, i) { + console.log(padNumber(i+1, 3) + ") check: \u001b[33m" + modeName + "\u001b[0m"); + try { + var Mode = require("../" + modeName).Mode; + } catch(e) { + console.warn("Can't load mode :" + modeName, e); + return; + } + var m = new Mode(); + if (!("lineCommentStart" in m) && !("blockComment" in m)) + console.warn("missing comment in " + modeName); + if (!m.$id) + console.warn("missing id in " + modeName); + var tokenizer = (new Mode).getTokenizer(); + + testComments(m.lineCommentStart, testLineComment, tokenizer, modeName); + testComments(m.blockComment, testBlockComment, tokenizer, modeName); + }); + + function testComments(desc, fn, tokenizer, modeName) { + if (desc) { + if (Array.isArray(desc)) { + desc.forEach(function(x) { + fn(tokenizer, x, modeName); + }); + } else { + fn(tokenizer, desc, modeName); + } + } + } + + function testBlockComment(tokenizer, blockComment, modeName) { + if (blockComment.lineStartOnly) + return; // TODO test + var str = blockComment.start + " " + blockComment.end; + str = blockComment.start + str; + if (blockComment.nestable) + str += blockComment.end; + var data = tokenizer.getLineTokens(str, "start"); + var isBroken = data.tokens.some(function(t) { return !/comment/.test(t.type); }); + if (isBroken) + console.warn("broken blockComment in " + modeName, data); + if (!/start/.test(data.state)) + console.warn("broken state after blockComment in " + modeName, data); + } + + function testLineComment(tokenizer, commentStart, modeName) { + var tokens = tokenizer.getLineTokens(commentStart + " ", "start").tokens; + if (!/comment/.test(tokens[0].type)) + console.warn("broken lineCommentStart in " + modeName); + } +} + +function generateTestData(names, force) { + var docRoot = root + "/demo/kitchen-sink/docs"; + var docs = fs.readdirSync(docRoot); + var specialDocs = fs.readdirSync(cwd); + var modes = modeList(); + + // console.log("Docs:", docs); + // console.log("Modes:", modes); + + docs.forEach(function(docName) { + var p = docName.toLowerCase().split("."); + if (!p[1]) + return; + var modeName; + if (modes.indexOf(p[0]) != -1) + modeName = p[0]; + else if (modes.indexOf(p[1]) != -1) + modeName = p[1]; + else + modeName = {"txt": "text", cpp: "c_cpp"}[p[1]]; + + if (names && names.length && names.indexOf(modeName) == -1) + return; + + var outputPath = cwd + "tokens_" + modeName + ".json"; + try { + var oldOutput = require(outputPath); + } catch(e) {} + if (oldOutput && !force) { + var oldText = oldOutput.map(function(x) { + if (x.length > 1 && typeof x[x.length - 1] == "string") + return x[x.length - 1]; + return x.slice(1).map(function(tok) { + return tok[1]; + }).join(""); + }).join("\n"); + } + + var filePath = "text_" + modeName + ".txt"; + if (specialDocs.indexOf(filePath) !== -1) { + filePath = cwd + filePath; + } else { + filePath = docRoot + "/" + docName; + // oldText = ""; + } + var text = oldText ||fs.readFileSync(filePath, "utf8"); + + try { + var Mode = require("../" + modeName).Mode; + } catch(e) { + console.warn("Can't load mode :" + modeName, p, e); + return; + } + console.log(modeName); + var tokenizer = new Mode().getTokenizer(); + + var state = "start"; + var data = text.split(/\r\n|\r|\n/).map(function(line) { + var data = tokenizer.getLineTokens(line, state); + var tmp = []; + tmp.push(JSON.stringify(data.state)); + var tokenizedLine = ""; + data.tokens.forEach(function(x) { + tokenizedLine += x.value; + tmp.push(JSON.stringify([x.type, x.value])); + }); + if (tokenizedLine != line) + tmp.push(JSON.stringify(line)); + state = data.state; + return tmp.join(",\n "); + }); + + var jsonStr = "[[\n " + data.join("\n],[\n ") + "\n]]"; + + if (oldOutput && JSON.stringify(JSON.parse(jsonStr)) == JSON.stringify(oldOutput)) + return; + + fs.writeFileSync(outputPath, jsonStr, "utf8"); + }); +} + +function test(startAt) { + var modes = fs.readdirSync(cwd).map(function(x) { + return (x.match(/tokens_(.*).json/) || {})[1]; + }).filter(function(x){return !!x;}); + + for (var i = Math.max(0, startAt||0); i < modes.length; i++) + testMode(modes[i], i); + + console.log("\u001b[32m" + "all ok" + "\u001b[0m"); +} +function testMode(modeName, i) { + console.log(padNumber(i+1, 3) + ") testing: \u001b[33m" + modeName + "\u001b[0m"); + + var text = fs.readFileSync(cwd + "tokens_" + modeName + ".json", "utf8"); + var data = JSON.parse(text); + var Mode = require("../" + modeName).Mode; + var tokenizer = new Mode().getTokenizer(); + + var state = "start"; + data.forEach(function(lineData) { + lineData.values = []; + lineData.types = []; + lineData.state = lineData.shift(); + var line = null; + if (typeof lineData[lineData.length - 1] == "string") + line = lineData.pop(); + lineData.forEach(function(x) { + lineData.types.push(x[0]); + lineData.values.push(x[1]); + }); + if (typeof line != "string") + line = lineData.values.join(""); + + var tokens = tokenizer.getLineTokens(line, state); + var values = tokens.tokens.map(function(x) {return x.value;}); + var types = tokens.tokens.map(function(x) {return x.type;}); + + var err = testEqual([ + JSON.stringify(lineData.state), JSON.stringify(tokens.state), + lineData.types, types, + lineData.values, values]); + + if (err) { + console.log(line); + throw "error"; + } + + state = tokens.state; + }); +} +function testEqual(a) { + var err; + if (a[0] + "" !== a[1] + "") { + console.log(a[0],a[1]); + err = 1; + } + + if ( a[2] + "" !== a[3] + "" || a[4] + "" !== a[5] + "") { + arrayDiff(a[2],a[3]); + arrayDiff(a[4],a[5]); + err = 1; + } + return err; +} +function arrayDiff(a1, a2) { + var l = Math.max(a1.length, a2.length); + var out = []; + for (var i = 0; i < l; i++) { + out.push("\n", padNumber(i+1, 3), ") "); + if (a1[i] !== a2[i]) + out.push("\u001b[31m", a1[i], "\u001b[0m != \u001b[32m", a2[i], "\u001b[0m"); + else + out.push(a1[i]); + } + console.log(out.join("")); +} +function padNumber(num, digits) { + return (" " + num).slice(-digits); +} + +// cli +var arg = process.argv[2]; +if (!arg) { + test(); + checkModes(); +} else if (/--?g(en)?/.test(arg)) + generateTestData(process.argv.splice(3)); +else if (/--?c(heck)?/.test(arg)) + checkModes(); +else if (/\d+/.test(arg)) + test(parseInt(process.argv[2],10) || 0); +else + testMode(arg, -1); \ No newline at end of file diff --git a/public/lib/ace/mode/_test/package.json b/public/lib/ace/mode/_test/package.json new file mode 100644 index 0000000..3fdc706 --- /dev/null +++ b/public/lib/ace/mode/_test/package.json @@ -0,0 +1,8 @@ +{ + "name": "ace-mode-creator", + "version": "0.1.0", + "dependencies": { + "connect": "", + "socket.io": "" + } +} \ No newline at end of file diff --git a/public/lib/ace/mode/_test/text_asciidoc.txt b/public/lib/ace/mode/_test/text_asciidoc.txt new file mode 100644 index 0000000..af7eaec --- /dev/null +++ b/public/lib/ace/mode/_test/text_asciidoc.txt @@ -0,0 +1,111 @@ +------------------------------------ +----------------------------------- +_ita_lic_, *bo*ld*, +mo+no+, normal. +``double quoted'', `single quoted'. + normal, ^super^, ~sub~. + +'''' +Escaped: +\_italic_, +++_italic_+++, +t\__e__st, +++t__e__st+++, ++++bold+++, $$normal$$ +\¶ ¶ +\`not single quoted' +\`\`not double quoted'' + + +[fffff] ++++++++++++++++++++++++++++++++++++++ +(C) {ss} ss ++++++++++++++++++++++++++++++++++++++ + +............. +callout <1> +.............. + +> 1 +1> 2 +<2> 3 + +Escaped: +\_italic_, +t\__e__st, o__ + +.optional title +............. +callout <1> +.............. + + +:macro: dddd + +.lists +. 1 +.. 2 +... d +..... big ++ +continue + +next line +xi) no ++la+tin++ + +xi) la++tin++ +2. num__ber__ [red]#red# +-- + 5. f <> {macro} +-- +image::path[beauty] ->--<= -- replacements + + image::s +sssss +sss +sssss + + +== 1 + heading +=== not a heading +==================================== + +================================== +====4 +NOTE: above + +NOTE: above + +[[x6]] +WARNING: + +[options[]] +--------------------------- +literal +--------------------------- + + += Tables +|==================================== +| _italic_ | *bold* | text | (R) + +|==================================== + + +[more, options] +/////////// +comment +/////////// +// one line comment + + + +[red]#red text# [yellow-background]#on yellow# +[big]#large# [red yellow-background big]*all bold* + + +https://site text callto:ace http://ace.ajaxorg.com[awesome] + .still normal text +.break out thoug should not +--------------------------- +/////////////////////////// +--------------------------- + + diff --git a/public/lib/ace/mode/_test/text_coffee.txt b/public/lib/ace/mode/_test/text_coffee.txt new file mode 100644 index 0000000..2d9ba5a --- /dev/null +++ b/public/lib/ace/mode/_test/text_coffee.txt @@ -0,0 +1,57 @@ +#test: tokenize keyword + for (i 1..2) +#test: tokenize regexp +/"[a]/ +#test: tokenize functions +foo = ({args}) -> + foo = ({a1, a2}) -> + foo = ({@a1, a2}) -> + foo : ({args}) -> + foo = ({args}) -> + foo = ({0abc}) -> + foo = ({/abc}) => + foo = ({abc/}) -> + foo = ({#abc}) -> + foo = ({abc#}) -> + foo = ({)abc}) -> + foo = ({abc)}) -> + foo = ({a{bc}) -> + foo = ({}) -> + foo = ({ }) -> + foo : ({}) -> + foo = (args) -> + foo = (arg1, arg2) -> + foo = (arg1 = 1, arg2 = 'name') -> + foo = (@arg1 = /abc/, arg2 = 'name') -> + #test: tokenize function: invalid case: + foo=(/args) -> + foo = () -> + foo = ( ) -> + foo : ( ) -> + window.foo = (args) -> + foo = -> + foo = -> + foo : -> + #test: tokenize callback function + foo bar: 1, (args) -> + foo = (1, 2 (x) -> +#test: tokenize class +class Foo +class Foo extends Bar +#test: tokenize illegal name property +foo.static.function +#!test tokenize string with interpolation +a = "#{ 22 / 7 + {x: "#{a + b}"} + 2}" +" #{ "" + {} } )" +"""heredoc + """ +do -> + ### + herecomment + ### + re = /regex/imgy.test /// + heregex # comment + ///imgy + this isnt: `just + JavaScript` + undefined diff --git a/public/lib/ace/mode/_test/text_coldfusion.txt b/public/lib/ace/mode/_test/text_coldfusion.txt new file mode 100644 index 0000000..9dd432b --- /dev/null +++ b/public/lib/ace/mode/_test/text_coldfusion.txt @@ -0,0 +1,8 @@ + + + z ---> welcome="Hello World!"> + z --> +#welcome# + + Dateformat(now()) + \ No newline at end of file diff --git a/public/lib/ace/mode/_test/text_curly.txt b/public/lib/ace/mode/_test/text_curly.txt new file mode 100644 index 0000000..1be54b5 --- /dev/null +++ b/public/lib/ace/mode/_test/text_curly.txt @@ -0,0 +1,9 @@ +tokenize Curly template{{test}} +tokenize embedded script +'123' +tokenize multiline attribute value with double quotes + +tokenize multiline attribute value with single quotes + diff --git a/public/lib/ace/mode/_test/text_ejs.txt b/public/lib/ace/mode/_test/text_ejs.txt new file mode 100644 index 0000000..0c6c8c3 --- /dev/null +++ b/public/lib/ace/mode/_test/text_ejs.txt @@ -0,0 +1,39 @@ + + + + Cloud9 Rocks! + + + + + + + + + <% if (!isRoot) { %> + + + + + <% } %> + <% entries.forEach(function(entry) { %> + + + + + <% }) %> +
NameSize
..
+ + <%= entry.name %> + <%= entry.size %>
+ +value="<%=window%>" +<% + } +%> + /> + + \ No newline at end of file diff --git a/public/lib/ace/mode/_test/text_gobstones.txt b/public/lib/ace/mode/_test/text_gobstones.txt new file mode 100644 index 0000000..4768d5f --- /dev/null +++ b/public/lib/ace/mode/_test/text_gobstones.txt @@ -0,0 +1,19 @@ +program { + /* + * A gobstons multiline comment + * Taken from: + * http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/" + */ + sumar(2, 3) + } + function sumar(a, b) { + r := a + b + } + // unreachable code + -- unreachable code + # unreachable code + procedure hacerAlgo() { + Mover(Este) + Poner(Rojo) + Sacar(Azul) + } \ No newline at end of file diff --git a/public/lib/ace/mode/_test/text_html.txt b/public/lib/ace/mode/_test/text_html.txt new file mode 100644 index 0000000..d2ce8aa --- /dev/null +++ b/public/lib/ace/mode/_test/text_html.txt @@ -0,0 +1,10 @@ + + +'123' + +
+ + + \ No newline at end of file diff --git a/public/lib/ace/mode/_test/text_javascript.txt b/public/lib/ace/mode/_test/text_javascript.txt new file mode 100644 index 0000000..390709c --- /dev/null +++ b/public/lib/ace/mode/_test/text_javascript.txt @@ -0,0 +1,100 @@ +//test: tokenize 'standard' functions +string.charCodeAt(23); document.getElementById('test'); console.log('Here it is');"; +test: /**tokenize doc*/ comment +/**tokenize doc comment with @tag {}*/ +//test: tokenize parens + var $line$ = "[{( )}]"; +//test tokenize arithmetic expression which looks like a regexp +a/b/c +a/=b/c +//test tokenize reg exps +a=/b/g +a+/b/g +a = 1 + /2 + 1/gimyxk +a=/a/ / /a/ +case /a/.test(c) +//test tokenize multi-line comment containing a single line comment +noRegex +/* foo // bar */ +canBeRegex; +/* foo // bar */ +// test tokenize identifier with umlauts +fu?e +// test // is not a regexp +{ // 123 +//test skipping escaped chars +'Meh\\nNeh' +console.log('\\u1232Feh' +"test multiline\ + strings" +a=' +b="\ +still a string + + +function foo(items, nada) { + for (var i=0; i>=t<>r>>>s>=0b1 + +foo.protoype.d = function(a, b, + c, d) +foo.d =function(a, b) +foo.d =function(a, /*****/ d"string" + +
{2} + }> +1 { ++x } +
+ +var o = { + t:`${[].map(x => { + return x + })}` +}; diff --git a/public/lib/ace/mode/_test/text_livescript.txt b/public/lib/ace/mode/_test/text_livescript.txt new file mode 100644 index 0000000..308ec1d --- /dev/null +++ b/public/lib/ace/mode/_test/text_livescript.txt @@ -0,0 +1 @@ +# comment diff --git a/public/lib/ace/mode/_test/text_lucene.txt b/public/lib/ace/mode/_test/text_lucene.txt new file mode 100644 index 0000000..c71f268 --- /dev/null +++ b/public/lib/ace/mode/_test/text_lucene.txt @@ -0,0 +1,16 @@ +test: recognises AND as keyword +test: recognises OR as keyword +test: recognises NOT as keyword +test: recognises "hello this is dog" as string +test: recognises -"hello this is dog" as negation with string +test: recognises ~100 as text with proximity +test: recognises "hello this is dog"~100 as string with proximity +test: recognises raw:"hello this is dog" as keyword +test: recognises raw:foo as"keyword' +test: recognises "(" as opening parenthesis +test: recognises ")" as closing parenthesis +test: recognises foo* as text with asterisk +test: recognises foo? as text with interro +test: recognises single word as text + foo + \ No newline at end of file diff --git a/public/lib/ace/mode/_test/text_markdown.txt b/public/lib/ace/mode/_test/text_markdown.txt new file mode 100644 index 0000000..0450c82 --- /dev/null +++ b/public/lib/ace/mode/_test/text_markdown.txt @@ -0,0 +1,22 @@ +test: header 1 +#f +test: header 2 +## foo +test: header ends with ' #' +# # # +test: header ends with '#' +#foo# +test: 6+ #s is not a valid header +####### foo +test: # followed be only space is not a valid header +# +test: only space between #s is not a valid header +# # + +# test links [Cloud9 IDE](http://www.c9.io/) # +* [demo](http://ajaxorg.github.com/ace/) [+](escape(\) ) [+](a "title") [+](a "space" ) +* usually *work* fine (_em_) +in lists + +in plain text http://ace.ajaxorg.com + diff --git a/public/lib/ace/mode/_test/text_php.txt b/public/lib/ace/mode/_test/text_php.txt new file mode 100644 index 0000000..b76aa8a --- /dev/null +++ b/public/lib/ace/mode/_test/text_php.txt @@ -0,0 +1,24 @@ + not &js; diff --git a/public/lib/ace/mode/_test/text_ruby.txt b/public/lib/ace/mode/_test/text_ruby.txt new file mode 100644 index 0000000..c16ff7c --- /dev/null +++ b/public/lib/ace/mode/_test/text_ruby.txt @@ -0,0 +1,34 @@ + #test: symbol tokenizer + [:@thing, :$thing, :_thing, :thing, :Thing, :thing1, :thing_a, + :THING, :thing!, :thing=, :thing?, :t?, + :, :@, :$, :1, :1thing, :th?ing, :thi=ng, :1thing, + :th!ing, :thing# + ] + + #test: namespaces aren't symbols" : function() { + Namespaced::Class + #test: hex tokenizer + 0x9a, 0XA1, 0x9_a, 0x, 0x_9a, 0x9a_, + #test: float tokenizer + [1, +1, -1, 12_345, 0.000_1, + _, 3_1, 1_2, 1_.0, 0._1]; + +{:id => ?", :key => "value", anotherKey: [x, y?]} + +=begin +=end + +=begin x +=end- +=end x + + herDocs = [<<'FOO', <(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] { + let mut accumulator = ~[]; + for vec::each(vector) |element| { + accumulator.push(function(element)); + } + return accumulator; +} + + +// numbers +14E-111_f64; 45isize 0x1i32 0o777u32 0b01 14f32 1_2.78f32 1_2.3E+7f32 + +// not numbers +14._E-111_f64; 0xi32; 0b777u + +// identifiers ending in constant.numeric +foo1; foo1u32; foo1f32; foo0xF; foo1.0 diff --git a/public/lib/ace/mode/_test/text_wollok.txt b/public/lib/ace/mode/_test/text_wollok.txt new file mode 100644 index 0000000..6c7a0a7 --- /dev/null +++ b/public/lib/ace/mode/_test/text_wollok.txt @@ -0,0 +1,28 @@ +class Actividad { + method calcularMejora() +} + +class EstudiarMateria inherits Actividad { + var materia + var puntos = 0 + + new(m, p) { + materia = m + puntos = p + } + + override method calcularMejora() = puntos +} + +class EjercitarEnSimulador inherits Actividad { + var horas = 0 + new(h) { horas = h } + override method calcularMejora() = 10 * horas +} + +object pepita { + var energia = 100 + method volar(m) { + energia -= m + } +} \ No newline at end of file diff --git a/public/lib/ace/mode/_test/text_xml.txt b/public/lib/ace/mode/_test/text_xml.txt new file mode 100644 index 0000000..01f7b8a --- /dev/null +++ b/public/lib/ace/mode/_test/text_xml.txt @@ -0,0 +1,7 @@ +//Juhu Kinners +test: two tags in the same lines should be in separate tokens" + +test: multiline attributes" + \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_abap.json b/public/lib/ace/mode/_test/tokens_abap.json new file mode 100644 index 0000000..2afe165 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_abap.json @@ -0,0 +1,213 @@ +[[ + "start", + ["doc.comment","***************************************"] +],[ + "start", + ["doc.comment","** Program: EXAMPLE **"] +],[ + "start", + ["doc.comment","** Author: Joe Byte, 07-Jul-2007 **"] +],[ + "start", + ["doc.comment","***************************************"] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword","REPORT"], + ["text"," BOOKINGS"], + ["keyword.operator","."] +],[ + "start", + ["text"," "] +],[ + "start", + ["doc.comment","* Read flight bookings from the database"] +],[ + "start", + ["keyword","SELECT"], + ["keyword.operator"," * "], + ["keyword","FROM"], + ["text"," FLIGHTINFO"] +],[ + "start", + ["text"," "], + ["keyword","WHERE"], + ["text"," "], + ["keyword","CLASS"], + ["keyword.operator"," = "], + ["string","'Y'"], + ["text"," "], + ["comment","\"Y = economy"] +],[ + "start", + ["text"," "], + ["keyword","OR"], + ["text"," "], + ["keyword","CLASS"], + ["keyword.operator"," = "], + ["string","'C'"], + ["keyword.operator","."], + ["text"," "], + ["comment","\"C = business"] +],[ + "start", + ["paren.lparen","("], + ["invalid","..."], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["keyword","REPORT"], + ["text"," TEST"], + ["keyword.operator","."] +],[ + "start", + ["keyword","WRITE"], + ["text"," "], + ["string","'Hello World'"], + ["keyword.operator","."] +],[ + "start" +],[ + "start", + ["text","USERPROMPT"], + ["keyword.operator"," = "], + ["string","'Please double-click on a line in the output list '"], + ["text"," "], + ["keyword.operator","&"] +],[ + "start", + ["text"," "], + ["string","'to see the complete details of the transaction.'"], + ["keyword.operator","."] +],[ + "start" +],[ + "start" +],[ + "start", + ["keyword","DATA"], + ["text"," LAST_EOM "], + ["keyword","TYPE"], + ["text"," "], + ["support.type","D"], + ["keyword.operator","."], + ["text"," "], + ["comment","\"last end-of-month date"] +],[ + "start", + ["text"," "] +],[ + "start", + ["doc.comment","* Start from today's date"] +],[ + "start", + ["text"," LAST_EOM"], + ["keyword.operator"," = "], + ["variable.parameter","SY"], + ["keyword.operator","-"], + ["text","DATUM"], + ["keyword.operator","."] +],[ + "start", + ["doc.comment","* Set characters 6 and 7 (0-relative) of the YYYYMMDD string to \"01\","] +],[ + "start", + ["doc.comment","* giving the first day of the current month"] +],[ + "start", + ["text"," LAST_EOM"], + ["constant.numeric","+6"], + ["paren.lparen","("], + ["constant.numeric","2"], + ["paren.rparen",")"], + ["keyword.operator"," = "], + ["string","'01'"], + ["keyword.operator","."] +],[ + "start", + ["doc.comment","* Subtract one day"] +],[ + "start", + ["text"," LAST_EOM"], + ["keyword.operator"," = "], + ["text","LAST_EOM"], + ["keyword.operator"," - "], + ["constant.numeric","1"], + ["keyword.operator","."] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","WRITE"], + ["keyword.operator",":"], + ["text"," "], + ["string","'Last day of previous month was'"], + ["keyword.operator",","], + ["text"," LAST_EOM"], + ["keyword.operator","."] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword","DATA"], + ["text"," "], + ["keyword.operator",":"], + ["text"," "], + ["keyword","BEGIN OF"], + ["text"," I_VBRK "], + ["keyword","OCCURS"], + ["text"," "], + ["constant.numeric","0"], + ["keyword.operator",","] +],[ + "start", + ["text"," VBELN "], + ["keyword","LIKE"], + ["text"," "], + ["variable.parameter","VBRK-VBELN"], + ["keyword.operator",","] +],[ + "start", + ["text"," ZUONR "], + ["keyword","LIKE"], + ["text"," "], + ["variable.parameter","VBRK-ZUONR"], + ["keyword.operator",","] +],[ + "start", + ["text"," "], + ["keyword","END OF"], + ["text"," I_VBRK"], + ["keyword.operator","."] +],[ + "start" +],[ + "start", + ["keyword","SORT"], + ["text"," i_vbrk "], + ["keyword","BY"], + ["text"," vbeln "], + ["keyword","ASCENDING"], + ["keyword.operator","."] +],[ + "start", + ["keyword","SORT"], + ["text"," i_vbrk "], + ["keyword","BY"], + ["text"," vbeln "], + ["keyword","DESCENDING"], + ["keyword.operator","."] +],[ + "start" +],[ + "start", + ["keyword","RETURN"], + ["keyword.operator","."] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_abc.json b/public/lib/ace/mode/_test/tokens_abc.json new file mode 100644 index 0000000..c65ae2a --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_abc.json @@ -0,0 +1,2207 @@ +[[ + "start", + ["comment.line.percentage","%abc-2.1"] +],[ + "start", + ["information.keyword","H:"], + ["information.argument.string.unquoted","This file contains some example English tunes"] +],[ + "start", + ["comment.line.percentage","% note that the comments (like this one) are to highlight usages"] +],[ + "start", + ["comment.line.percentage","% and would not normally be included in such detail"] +],[ + "start", + ["information.keyword","O:"], + ["information.argument.string.unquoted","England "], + ["comment.line.percentage","% the origin of all tunes is England"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","1 "], + ["comment.line.percentage","% tune no 1"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Dusty Miller, The "], + ["comment.line.percentage","% title"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Binny's Jig "], + ["comment.line.percentage","% an alternative title"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad. "], + ["comment.line.percentage","% traditional"] +],[ + "start", + ["information.keyword","R:"], + ["information.argument.string.unquoted","DH "], + ["comment.line.percentage","% double hornpipe"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","3/4 "], + ["comment.line.percentage","% meter"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G "], + ["comment.line.percentage","% key"] +],[ + "start", + ["pitch.constant.numeric","B"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","a"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/2"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/2"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["information.keyword","W:"], + ["information.argument.string.unquoted","Hey, the dusty miller, and his dusty coat;"] +],[ + "start", + ["information.keyword","W:"], + ["information.argument.string.unquoted","He will win a shilling, or he spend a groat."] +],[ + "start", + ["information.keyword","W:"], + ["information.argument.string.unquoted","Dusty was the coat, dusty was the colour;"] +],[ + "start", + ["information.keyword","W:"], + ["information.argument.string.unquoted","Dusty was the kiss, that I got frae the miller."] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","2"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Old Sir Simon the King"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad."] +],[ + "start", + ["information.keyword","S:"], + ["information.argument.string.unquoted","Offord MSS "], + ["comment.line.percentage","% from Offord manuscript"] +],[ + "start", + ["information.keyword","N:"], + ["information.argument.string.unquoted","see also Playford "], + ["comment.line.percentage","% reference note"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","9/8"] +],[ + "start", + ["information.keyword","R:"], + ["information.argument.string.unquoted","SJ "], + ["comment.line.percentage","% slip jig"] +],[ + "start", + ["information.keyword","N:"], + ["information.argument.string.unquoted","originally in C "], + ["comment.line.percentage","% transcription note"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G"] +],[ + "start", + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|[1"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["text","["], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","G"], + ["text","] "], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"], + ["text","\\ "], + ["comment.line.percentage","% no line-break in score"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","12/8 "], + ["comment.line.percentage","% change of meter"] +],[ + "start", + ["barline.keyword.operator","[2"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["text","\\ "], + ["comment.line.percentage","% no line-break in score"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","9/8 "], + ["comment.line.percentage","% change of meter"] +],[ + "start", + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|]"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","3"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","William and Nancy"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","New Mown Hay"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Legacy, The"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad."] +],[ + "start", + ["information.keyword","O:"], + ["information.argument.string.unquoted","England; Gloucs; Bledington "], + ["comment.line.percentage","% place of origin"] +],[ + "start", + ["information.keyword","B:"], + ["information.argument.string.unquoted","Sussex Tune Book "], + ["comment.line.percentage","% can be found in these books"] +],[ + "start", + ["information.keyword","B:"], + ["information.argument.string.unquoted","Mally's Cotswold Morris vol.1 2"] +],[ + "start", + ["information.keyword","D:"], + ["information.argument.string.unquoted","Morris On "], + ["comment.line.percentage","% can be heard on this record"] +],[ + "start", + ["information.keyword","P:"], + ["information.argument.string.unquoted","(AB)2(AC)2A "], + ["comment.line.percentage","% play the parts in this order"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","6/8"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G "] +],[ + "start", + ["information.keyword.embedded","[P:"], + ["information.argument.string.unquoted","A]"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","F"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["information.keyword.embedded","[P:"], + ["information.argument.string.unquoted","B]"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","F"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["comment.line.percentage","% changes of meter, using inline fields"] +],[ + "start", + ["information.keyword.embedded","[T:"], + ["information.argument.string.unquoted","Slows]"], + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","4/4]"], + ["information.keyword.embedded","[L:"], + ["information.argument.string.unquoted","1/4]"], + ["information.keyword.embedded","[P:"], + ["information.argument.string.unquoted","C]"], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["string.quoted","\"Em\""], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text"," "], + ["string.quoted","\"A7\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["text","\\"] +],[ + "start", + ["text"," "], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","3/8]"], + ["information.keyword.embedded","[L:"], + ["information.argument.string.unquoted","1/8]"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["text"," "], + ["barline.keyword.operator","|"], + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","6/8]"], + ["text"," "], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","F"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","4"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","South Downs Jig"] +],[ + "start", + ["information.keyword","R:"], + ["information.argument.string.unquoted","jig"] +],[ + "start", + ["information.keyword","S:"], + ["information.argument.string.unquoted","Robert Harbron"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","6/8"] +],[ + "start", + ["information.keyword","L:"], + ["information.argument.string.unquoted","1/8"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G"] +],[ + "start", + ["barline.keyword.operator","|:"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["barline.keyword.operator","|"] +],[ + "start", + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator",":|"] +],[ + "start", + ["pitch.constant.numeric","B"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","9/8]"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","6/8]"], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","D"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["barline.keyword.operator","|1"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator",":|2"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|]"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","5"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Atholl Brose"] +],[ + "start", + ["comment.line.percentage","% in this example, which reproduces Highland Bagpipe gracing,"] +],[ + "start", + ["comment.line.percentage","% the large number of grace notes mean that it is more convenient to be specific about"] +],[ + "start", + ["comment.line.percentage","% score line-breaks (using the $ symbol), rather than using code line breaks to indicate them"] +],[ + "start", + ["information.keyword","I:"], + ["information.argument.string.unquoted","linebreak $"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","D"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","f"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric",">"], + ["text","{"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","B"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","G"], + ["text"," {"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["text","}"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator",":|"], + ["text","$"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","2"], + ["text"," {"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","f"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","G"], + ["text"," {"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["text","}"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","2"], + ["text"," {"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","a"], + ["text"," {"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","g"], + ["text"," {"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["text","}"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","c"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","G"], + ["text"," {"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["text","}"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|]"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","6"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Untitled Reel"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad."] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","D"] +],[ + "start", + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","b"], + ["text"," "], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","b"], + ["pitch.constant.numeric","g"], + ["text"," "], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"], + ["text","\\"] +],[ + "start", + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G"] +],[ + "start", + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","7"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Kitchen Girl"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad."] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","D"] +],[ + "start", + ["text","["], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","4"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","4"], + ["text","] ["], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","4"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","4"], + ["text","]"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","b"], + ["pitch.constant.numeric","a"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"] +],[ + "start", + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","4"], + ["text"," "], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G"] +],[ + "start", + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","3"], + ["pitch.constant.numeric","f"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"] +],[ + "start", + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","4"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator",":|"] +],[ + "start" +],[ + "start", + ["comment.line.percentage","%abc-2.1"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","pagewidth 21cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","pageheight 29.7cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","topspace 0.5cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","topmargin 1cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","botmargin 0cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","leftmargin 1cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","rightmargin 1cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","titlespace 0cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","titlefont Times-Bold 32"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","subtitlefont Times-Bold 24"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","composerfont Times 16"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","vocalfont Times-Roman 14"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","staffsep 60pt"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","sysstaffsep 20pt"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","musicspace 1cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","vocalspace 5pt"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","measurenb 0"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","barsperstaff 5"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","scale 0.7"] +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted"," 1"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted"," Canzonetta a tre voci"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted"," Claudio Monteverdi (1567-1643)"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted"," C"] +],[ + "start", + ["information.keyword","L:"], + ["information.argument.string.unquoted"," 1/4"] +],[ + "start", + ["information.keyword","Q:"], + ["information.argument.string.unquoted"," \"Andante mosso\" 1/4 = 110"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","score [1 2 3]"] +],[ + "start", + ["information.keyword","V:"], + ["information.argument.string.unquoted"," 1 clef=treble name=\"Soprano\"sname=\"A\""] +],[ + "start", + ["information.keyword","V:"], + ["information.argument.string.unquoted"," 2 clef=treble name=\"Alto\" sname=\"T\""] +],[ + "start", + ["information.keyword","V:"], + ["information.argument.string.unquoted"," 3 clef=bass middle=d name=\"Tenor\" sname=\"B\""] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","MIDI program 1 75 % recorder"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","MIDI program 2 75"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","MIDI program 3 75"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted"," Eb"] +],[ + "start", + ["comment.line.percentage","% 1 - 4"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 1]"], + ["text"," "], + ["barline.keyword.operator","|:"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","4"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","4"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Son que-sti~i cre-spi cri-ni~e"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Que-sti son gli~oc-chi che mi-"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 2]"], + ["text"," "], + ["barline.keyword.operator","|:"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","c"], + ["barline.keyword.operator","|"], + ["text","("], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","/"], + ["text",")"], + ["pitch.constant.numeric","c"], + ["accent.constant.language","="], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Son que-sti~i cre-spi cri-ni~e que - - - - sto~il vi-so e"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Que-sti son~gli oc-chi che mi-ran - - - - do fi-so mi-"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 3]"], + ["text"," "], + ["barline.keyword.operator","|:"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","4"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["barline.keyword.operator","|"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","f"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text","("], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","/"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","/"], + ["text",")"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","f"], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Son que-sti~i cre-spi cri-ni~e que - - - - sto~il"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Que-sti son~gli oc-chi che mi-ran - - - - do"] +],[ + "start", + ["comment.line.percentage","% 5 - 9"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 1]"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","3"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["string.quoted","!fermata!"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","z"], + ["text"," "], + ["barline.keyword.operator","::"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," ran-do fi-so, tut-to re-stai con-qui-so."] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 2]"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","3"], + ["pitch.constant.numeric","F"], + ["barline.keyword.operator","|"], + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["string.quoted","!fermata!"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","z"], + ["barline.keyword.operator","::"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," ran-do fi-so tut-to re-stai con-qui-so."] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 3]"], + ["text"," ("], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["text",")"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","3"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["string.quoted","!fermata!"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","z"], + ["text"," "], + ["barline.keyword.operator","::"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," vi - - - so ond' io ti-man-go~uc-ci-so. Deh,"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," fi - - - so tut-to re-stai con-qui-so."] +],[ + "start", + ["comment.line.percentage","% 10 - 15"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 1]"], + ["text"," "], + ["pitch.constant.numeric","f"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","z"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text","\\"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," dim-me-lo ben mi-o, che que-sto"], + ["text","\\"] +],[ + "start", + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator","|1"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|2"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","8"], + ["barline.keyword.operator","|]"], + ["text"," "], + ["comment.line.percentage","% more notes"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," sol de-si-o_. "], + ["comment.line.percentage","% more lyrics"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 2]"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text","("], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","3/2"], + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","//"], + ["pitch.constant.numeric","D"], + ["duration.constant.numeric","//"], + ["pitch.constant.numeric","E"], + ["text",")"], + ["barline.keyword.operator","|1"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|2"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","8"], + ["barline.keyword.operator","|]"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," dim-me-lo ben mi-o, che que-sto sol de-si - - - - o_."] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 3]"], + ["text"," "], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["barline.keyword.operator","|"], + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","c"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","4"], + ["text"," "], + ["barline.keyword.operator","|1"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|2"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","8"], + ["barline.keyword.operator","|]"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," dim-me-lo ben mi-o, che que-sto sol de-si-o_."] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_actionscript.json b/public/lib/ace/mode/_test/tokens_actionscript.json new file mode 100644 index 0000000..e3fad38 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_actionscript.json @@ -0,0 +1,263 @@ +[[ + "start", + ["text","package code"] +],[ + "start", + ["text","{"] +],[ + "punctuation.definition.comment.actionscript.2", + ["text"," "], + ["punctuation.definition.comment.actionscript.2","/*"], + ["comment.block.actionscript.2","****************************************"] +],[ + "punctuation.definition.comment.actionscript.2", + ["comment.block.actionscript.2","\t * based on textmate actionscript bundle"] +],[ + "start", + ["comment.block.actionscript.2","\t ***************************************"], + ["punctuation.definition.comment.actionscript.2","*/"] +],[ + "start", + ["text","\t "] +],[ + "start", + ["text","\t"], + ["keyword.control.actionscript.2","import"], + ["text"," fl.events.SliderEvent;"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["text","\t"], + ["keyword.control.actionscript.2","public"], + ["text"," "], + ["storage.type.class.actionscript.2","class"], + ["meta.class.actionscript.2"," "], + ["entity.name.type.class.actionscript.2","Foo"], + ["meta.class.actionscript.2"," "], + ["storage.modifier.extends.actionscript.2","extends"], + ["meta.class.actionscript.2"," "], + ["entity.other.inherited-class.actionscript.2","MovieClip"] +],[ + "start", + ["text","\t{"] +],[ + "start", + ["text","\t\t"], + ["punctuation.definition.comment.actionscript.2","//*************************"] +],[ + "start", + ["text","\t\t"], + ["punctuation.definition.comment.actionscript.2","// Properties:"] +],[ + "start", + ["text","\t\t"] +],[ + "start", + ["text","\t\t"], + ["keyword.control.actionscript.2","public"], + ["text"," "], + ["keyword.control.actionscript.2","var"], + ["text"," activeSwatch"], + ["keyword.operator.symbolic.actionscript.2",":"], + ["support.class.actionscript.2","MovieClip"], + ["text",";"] +],[ + "start", + ["text","\t\t"] +],[ + "start", + ["text","\t\t"], + ["punctuation.definition.comment.actionscript.2","// Color offsets"] +],[ + "start", + ["text","\t\t"], + ["keyword.control.actionscript.2","public"], + ["text"," "], + ["keyword.control.actionscript.2","var"], + ["text"," c1"], + ["keyword.operator.symbolic.actionscript.2",":"], + ["storage.type.actionscript.2","Number"], + ["text"," "], + ["keyword.operator.symbolic.actionscript.2","="], + ["text"," "], + ["constant.numeric.actionscript.2","0"], + ["text",";\t"], + ["punctuation.definition.comment.actionscript.2","// R"] +],[ + "start", + ["text","\t\t"] +],[ + "start", + ["text","\t\t"], + ["punctuation.definition.comment.actionscript.2","//*************************"] +],[ + "start", + ["text","\t\t"], + ["punctuation.definition.comment.actionscript.2","// Constructor:"] +],[ + "start", + ["text","\t\t"] +],[ + "start", + ["text","\t\t"], + ["keyword.control.actionscript.2","public"], + ["text"," "], + ["storage.type.function.actionscript.2","function"], + ["meta.function.actionscript.2"," "], + ["entity.name.function.actionscript.2","Foo"], + ["punctuation.definition.parameters.begin.actionscript.2","("], + ["punctuation.definition.parameters.end.actionscript.2",")"] +],[ + "start", + ["text","\t\t{"] +],[ + "start", + ["text","\t\t\t"], + ["punctuation.definition.comment.actionscript.2","// Respond to mouse events"] +],[ + "start", + ["text","\t\t\tswatch1_btn."], + ["support.function.actionscript.2","addEventListener"], + ["text","(MouseEvent.CLICK,swatchHandler,"], + ["constant.language.actionscript.2","false"], + ["text",","], + ["constant.numeric.actionscript.2","0"], + ["text",","], + ["constant.language.actionscript.2","false"], + ["text",");"] +],[ + "start", + ["text","\t\t\tpreviewBox_btn."], + ["support.function.actionscript.2","addEventListener"], + ["text","(MouseEvent.MOUSE_DOWN,dragPressHandler);"] +],[ + "start", + ["text","\t\t\t"] +],[ + "start", + ["text","\t\t\t"], + ["punctuation.definition.comment.actionscript.2","// Respond to drag events"] +],[ + "start", + ["text","\t\t\tred_slider."], + ["support.function.actionscript.2","addEventListener"], + ["text","(SliderEvent.THUMB_DRAG,sliderHandler);"] +],[ + "start", + ["text","\t\t\t"] +],[ + "start", + ["text","\t\t\t"], + ["punctuation.definition.comment.actionscript.2","// Draw a frame later"] +],[ + "start", + ["text","\t\t\t"], + ["support.function.actionscript.2","addEventListener"], + ["text","(Event.ENTER_FRAME,"], + ["support.function.actionscript.2","draw"], + ["text",");"] +],[ + "start", + ["text","\t\t}"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text","\t\tprotected "], + ["storage.type.function.actionscript.2","function"], + ["meta.function.actionscript.2"," "], + ["entity.name.function.actionscript.2","clickHandler"], + ["punctuation.definition.parameters.begin.actionscript.2","("], + ["variable.parameter.function.actionscript.2","event:MouseEvent"], + ["punctuation.definition.parameters.end.actionscript.2",")"], + ["keyword.operator.symbolic.actionscript.2",":"], + ["support.function.actionscript.2","void"] +],[ + "start", + ["text","\t\t{"] +],[ + "start", + ["text","\t\t\tcar.transform.colorTransform "], + ["keyword.operator.symbolic.actionscript.2","="], + ["text"," "], + ["keyword.control.actionscript.2","new"], + ["text"," ColorTransform("], + ["constant.numeric.actionscript.2","0"], + ["text",","], + ["constant.numeric.actionscript.2","0"], + ["text",","], + ["constant.numeric.actionscript.2","0"], + ["text",","], + ["constant.numeric.actionscript.2","1"], + ["text",",c1,c2,c3);"] +],[ + "start", + ["text","\t\t}"] +],[ + "start", + ["text","\t\t"] +],[ + "start", + ["text","\t\tprotected "], + ["storage.type.function.actionscript.2","function"], + ["meta.function.actionscript.2"," "], + ["entity.name.function.actionscript.2","changeRGBHandler"], + ["punctuation.definition.parameters.begin.actionscript.2","("], + ["variable.parameter.function.actionscript.2","event:Event"], + ["punctuation.definition.parameters.end.actionscript.2",")"], + ["keyword.operator.symbolic.actionscript.2",":"], + ["support.function.actionscript.2","void"] +],[ + "start", + ["text","\t\t{"] +],[ + "start", + ["text","\t\t\tc1 "], + ["keyword.operator.symbolic.actionscript.2","="], + ["text"," "], + ["storage.type.actionscript.2","Number"], + ["text","(c1_txt."], + ["support.function.actionscript.2","text"], + ["text",");"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text","\t\t\t"], + ["keyword.control.actionscript.2","if"], + ["text","("], + ["keyword.operator.symbolic.actionscript.2","!"], + ["text","(c1>"], + ["keyword.operator.symbolic.actionscript.2","="], + ["constant.numeric.actionscript.2","0"], + ["text",")){"] +],[ + "start", + ["text","\t\t\t\tc1 "], + ["keyword.operator.symbolic.actionscript.2","="], + ["text"," "], + ["constant.numeric.actionscript.2","0"], + ["text",";"] +],[ + "start", + ["text","\t\t\t}\t\t\t"] +],[ + "start", + ["text","\t\t\t"] +],[ + "start", + ["text","\t\t\tupdateSliders();"] +],[ + "start", + ["text","\t\t}"] +],[ + "start", + ["text","\t}"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_ada.json b/public/lib/ace/mode/_test/tokens_ada.json new file mode 100644 index 0000000..bdef725 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_ada.json @@ -0,0 +1,39 @@ +[[ + "start", + ["keyword","with"], + ["text"," "], + ["identifier","Ada"], + ["text","."], + ["identifier","Text_IO"], + ["text","; "], + ["keyword","use"], + ["text"," "], + ["identifier","Ada"], + ["text","."], + ["identifier","Text_IO"], + ["text",";"] +],[ + "start", + ["keyword","procedure"], + ["text"," "], + ["identifier","Hello"], + ["text"," "], + ["keyword","is"] +],[ + "start", + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["identifier","Put_Line"], + ["paren.lparen","("], + ["string","\"Hello, world!\""], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["keyword","end"], + ["text"," "], + ["identifier","Hello"], + ["text",";"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_asciidoc.json b/public/lib/ace/mode/_test/tokens_asciidoc.json new file mode 100644 index 0000000..f54c355 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_asciidoc.json @@ -0,0 +1,422 @@ +[[ + "literalBlock", + ["support.function","------------------------------------"] +],[ + "dissallowDelimitedBlock", + ["support.function","-----------------------------------"] +],[ + "text", + ["string.italic","_ita_lic_"], + ["text",", "], + ["keyword.bold","*bo*ld*"], + ["text",", "], + ["support.function","+mo+no+"], + ["text",", normal. "] +],[ + "text", + ["keyword","``"], + ["text","double quoted"], + ["keyword","''"], + ["text",", `single quoted'."] +],[ + "text", + ["text"," normal, ^super^, "], + ["keyword","~sub~"], + ["text","."] +],[ + "start" +],[ + "text", + ["text","''''"] +],[ + "text", + ["text","Escaped:"] +],[ + "text", + ["constant.language.escape","\\_"], + ["text","italic_, "], + ["support.function","+++"], + ["text","_italic_"], + ["support.function","+++"], + ["text",","] +],[ + "smallPassthrough", + ["text","t"], + ["constant.language.escape","\\_"], + ["text","_e"], + ["string.italic","__st, +++t__"], + ["text","e__st"], + ["support.function","+++"], + ["text",","] +],[ + "smallPassthrough", + ["support.function","+++"], + ["text","bold"], + ["support.function","+++"], + ["text",", $$<"], + ["support.function","b"], + ["text",">"], + ["support.function","normal"], + ["text","$$"] +],[ + "smallPassthrough", + ["text","\\&#"], + ["support.function","182"], + ["text","; &#"], + ["support.function","182"], + ["text",";"] +],[ + "smallPassthrough", + ["text","\\`"], + ["support.function","not"], + ["text"," "], + ["support.function","single"], + ["text"," "], + ["support.function","quoted"], + ["text","'"] +],[ + "smallPassthrough", + ["text","\\`\\`"], + ["support.function","not"], + ["text"," "], + ["support.function","double"], + ["text"," "], + ["support.function","quoted"], + ["text","''"] +],[ + "dissallowDelimitedBlock" +],[ + "text" +],[ + "start", + ["string.regexp","[fffff]"] +],[ + "passthroughBlock", + ["string","+++++++++++++++++++++++++++++++++++++"] +],[ + "passthroughBlock", + ["support.function","(C) "], + ["constant.character","{ss}"], + ["support.function"," ss"] +],[ + "dissallowDelimitedBlock", + ["support.function","+++++++++++++++++++++++++++++++++++++"] +],[ + "text" +],[ + "listingBlock", + ["support.function","............."] +],[ + "listingBlock", + ["support.function","callout "], + ["constant.numeric","<1>"] +],[ + "dissallowDelimitedBlock", + ["support.function",".............."] +],[ + "text" +],[ + "text", + ["text","> 1"] +],[ + "text", + ["text","1> 2"] +],[ + "text", + ["text","<2> 3"] +],[ + "start" +],[ + "text", + ["text","Escaped:"] +],[ + "text", + ["constant.language.escape","\\_"], + ["text","italic_,"] +],[ + "text", + ["text","t"], + ["constant.language.escape","\\_"], + ["text","_e"], + ["string.italic","__st, o__"] +],[ + "start" +],[ + "start", + ["constant.numeric",".optional title"] +],[ + "listingBlock", + ["support.function","............."] +],[ + "listingBlock", + ["support.function","callout "], + ["constant.numeric","<1>"] +],[ + "dissallowDelimitedBlock", + ["support.function",".............."] +],[ + "text" +],[ + "start" +],[ + "text", + ["keyword",":macro:"], + ["text"," dddd"] +],[ + "start" +],[ + "start", + ["constant.numeric",".lists"] +],[ + "listText", + ["keyword",". "], + ["text","1"] +],[ + "listText", + ["keyword",".. "], + ["text","2"] +],[ + "listText", + ["keyword","... "], + ["text","d"] +],[ + "listText", + ["keyword","..... "], + ["text","big"] +],[ + "start", + ["keyword","+"] +],[ + "text", + ["text","continue"], + ["keyword"," +"] +],[ + "text", + ["text","next line"] +],[ + "text", + ["text","xi) no "], + ["support.function","++la+tin++"] +],[ + "start" +],[ + "listText", + ["keyword","xi) "], + ["text","la"], + ["support.function","++tin++"] +],[ + "listText", + ["keyword","2. "], + ["text","num"], + ["string.italic","__ber__"], + ["text"," [red]"], + ["keyword","#"], + ["text","red"], + ["keyword","#"] +],[ + "start", + ["keyword","--"] +],[ + "listText", + ["keyword"," 5. "], + ["text","f "], + ["keyword","<>"], + ["text"," "], + ["constant.character","{macro}"] +],[ + "start", + ["keyword","--"] +],[ + "text", + ["markup.list.macro","image::"], + ["keyword","path"], + ["string","[beauty]"], + ["text"," "], + ["constant.language.escape","->"], + ["text","--"], + ["constant.language.escape","<= --"], + ["text"," replacements"] +],[ + "start" +],[ + "indentedBlock", + ["support.function"," image::s"] +],[ + "indentedBlock", + ["support.function","sssss"] +],[ + "indentedBlock", + ["support.function","sss "] +],[ + "indentedBlock", + ["support.function","sssss"] +],[ + "start" +],[ + "start" +],[ + "start", + ["markup.heading","== 1"] +],[ + "indentedBlock", + ["support.function"," heading"] +],[ + "start", + ["markup.heading","=== not a heading"] +],[ + "start", + ["keyword","===================================="] +],[ + "start" +],[ + "start", + ["keyword","=================================="] +],[ + "text", + ["text","====4 "] +],[ + "text", + ["text","NOTE: above"] +],[ + "start" +],[ + "text", + ["keyword","NOTE:"], + ["text"," above"] +],[ + "start" +],[ + "start", + ["string.regexp","[[x6]]"] +],[ + "text", + ["keyword","WARNING:"], + ["text"," "] +],[ + "start" +],[ + "start", + ["string.regexp","[options[]]"] +],[ + "literalBlock", + ["support.function","---------------------------"] +],[ + "literalBlock", + ["support.function","literal"] +],[ + "dissallowDelimitedBlock", + ["support.function","---------------------------"] +],[ + "text" +],[ + "start" +],[ + "start", + ["markup.heading","= Tables"] +],[ + "tableBlock", + ["doc.comment","|===================================="] +],[ + "tableBlock", + ["doc.comment","|"], + ["text"," "], + ["string.italic","_italic_"], + ["text"," "], + ["doc.comment","|"], + ["text"," "], + ["keyword.bold","*bold*"], + ["text"," "], + ["doc.comment","|"], + ["text"," text "], + ["doc.comment","|"], + ["text"," "], + ["constant.language.escape","(R)"] +],[ + "tableBlock" +],[ + "dissallowDelimitedBlock", + ["doc.comment","|===================================="] +],[ + "text" +],[ + "start" +],[ + "start", + ["string.regexp","[more, options]"] +],[ + "commentBlock", + ["doc.comment","///////////"] +],[ + "commentBlock", + ["doc.comment","comment"] +],[ + "dissallowDelimitedBlock", + ["doc.comment","///////////"] +],[ + "text", + ["comment","// one line comment"] +],[ + "start" +],[ + "start" +],[ + "start" +],[ + "text", + ["text","[red]"], + ["keyword","#"], + ["text","red text"], + ["keyword","#"], + ["text"," [yellow-background]"], + ["keyword","#"], + ["text","on yellow"], + ["keyword","#"] +],[ + "text", + ["text","[big]"], + ["keyword","#"], + ["text","large"], + ["keyword","#"], + ["text"," [red yellow-background big]"], + ["keyword.bold","*all bold*"] +],[ + "start" +],[ + "start", + ["text","\t"] +],[ + "text", + ["markup.underline.list","https://site"], + ["text"," text <"], + ["markup.underline.list","mail@i.am"], + ["text","> "], + ["markup.underline.list","callto:ace"], + ["text"," "], + ["link","http://ace.ajaxorg.com"], + ["variable.language","[awesome]"] +],[ + "text", + ["text"," .still normal text"] +],[ + "start", + ["constant.numeric",".break out thoug should not"] +],[ + "literalBlock", + ["support.function","---------------------------"] +],[ + "literalBlock", + ["support.function","///////////////////////////"] +],[ + "dissallowDelimitedBlock", + ["support.function","---------------------------"] +],[ + "text" +],[ + "start" +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_assembly_x86.json b/public/lib/ace/mode/_test/tokens_assembly_x86.json new file mode 100644 index 0000000..5da0470 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_assembly_x86.json @@ -0,0 +1,114 @@ +[[ + "start", + ["support.function.directive.assembly","section"], + ["text","\t.text"] +],[ + "start", + ["text"," "], + ["support.function.directive.assembly","global"], + ["text"," "], + ["entity.name.function.assembly","main"], + ["text"," "], + ["comment.assembly",";must be declared for using gcc"] +],[ + "start" +],[ + "start", + ["entity.name.function.assembly","main:"], + ["text","\t "], + ["comment.assembly",";tell linker entry point"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","edx"], + ["text",", len\t "], + ["comment.assembly",";message length"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","ecx"], + ["text",", msg\t "], + ["comment.assembly",";message to write"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","ebx"], + ["text",", "], + ["constant.character.decimal.assembly","1"], + ["text","\t "], + ["comment.assembly",";file descriptor (stdout)"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","eax"], + ["text",", "], + ["constant.character.decimal.assembly","4"], + ["text","\t "], + ["comment.assembly",";system call number (sys_write)"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","int"], + ["text","\t"], + ["constant.character.hexadecimal.assembly","0x80"], + ["text","\t "], + ["comment.assembly",";call kernel"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","eax"], + ["text",", "], + ["constant.character.decimal.assembly","1"], + ["text","\t "], + ["comment.assembly",";system call number (sys_exit)"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","int"], + ["text","\t"], + ["constant.character.hexadecimal.assembly","0x80"], + ["text","\t "], + ["comment.assembly",";call kernel"] +],[ + "start" +],[ + "start", + ["support.function.directive.assembly","section"], + ["text","\t.data"] +],[ + "start" +],[ + "start", + ["entity.name.function.assembly","msg"], + ["text","\t"], + ["support.function.directive.assembly","db"], + ["text","\t"], + ["string.assembly","'Hello, world!'"], + ["text",","], + ["constant.character.hexadecimal.assembly","0xa"], + ["text","\t"], + ["comment.assembly",";our dear string"] +],[ + "start", + ["entity.name.function.assembly","len"], + ["text","\t"], + ["support.function.directive.assembly","equ"], + ["text","\t$ - msg\t\t\t"], + ["comment.assembly",";length of our dear string"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_autohotkey.json b/public/lib/ace/mode/_test/tokens_autohotkey.json new file mode 100644 index 0000000..374310f --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_autohotkey.json @@ -0,0 +1,261 @@ +[[ + "start", + ["punctuation.ahk","#"], + ["keyword.command.ahk","NoEnv"] +],[ + "start", + ["keyword.command.ahk","SetBatchLines"], + ["text"," "], + ["constant.numeric","-1"] +],[ + "start" +],[ + "start", + ["keyword.command.ahk","CoordMode"], + ["text"," "], + ["variable.parameter","Mouse"], + ["punctuation.ahk",","], + ["text"," "], + ["variable.parameter","Screen"] +],[ + "start", + ["keyword.command.ahk","OnExit"], + ["text"," "], + ["variable.parameter","GuiClose"] +],[ + "start" +],[ + "start", + ["text","zoom "], + ["keyword.operator.ahk",":="], + ["text"," 9"] +],[ + "start" +],[ + "start", + ["text","computeSize"], + ["punctuation.ahk","(){"] +],[ + "start", + ["text","\t"], + ["keyword.control.ahk","global"], + ["text"," as_x"] +],[ + "start", + ["text","\tas_x "], + ["keyword.operator.ahk",":="], + ["text"," "], + ["support.function.ahk","Round"], + ["punctuation.ahk","("], + ["text","ws_x"], + ["keyword.operator.ahk","/"], + ["text","zoom"], + ["keyword.operator.ahk","/"], + ["text","2 "], + ["keyword.operator.ahk","-"], + ["text"," 0.5"], + ["punctuation.ahk",")"] +],[ + "start", + ["text","\t"], + ["keyword.control.ahk","if"], + ["text"," "], + ["punctuation.ahk","("], + ["text","zoom"], + ["keyword.operator.ahk",">"], + ["text","1"], + ["punctuation.ahk",")"], + ["text"," "], + ["punctuation.ahk","{"] +],[ + "start", + ["text","\t\tpix "], + ["keyword.operator.ahk",":="], + ["text"," "], + ["support.function.ahk","Round"], + ["punctuation.ahk","("], + ["text","zoom"], + ["punctuation.ahk",")"] +],[ + "start", + ["text","\t"], + ["punctuation.ahk","}"], + ["text"," ele "], + ["punctuation.ahk","{"] +],[ + "start", + ["text","\t\tpix "], + ["keyword.operator.ahk",":="], + ["text"," 1"] +],[ + "start", + ["text","\t"], + ["punctuation.ahk","}"] +],[ + "start", + ["text"," "], + ["keyword.command.ahk","ToolTip"], + ["text"," Message "], + ["punctuation.ahk","%"], + ["text","as_x"], + ["punctuation.ahk","%"], + ["text"," "], + ["punctuation.ahk","%"], + ["text","zoom"], + ["punctuation.ahk","%"], + ["text"," "], + ["punctuation.ahk","%"], + ["text","ws_x"], + ["punctuation.ahk","%"], + ["text"," "], + ["punctuation.ahk","%"], + ["text","hws_x"], + ["punctuation.ahk","%"], + ["text"," "] +],[ + "start", + ["punctuation.ahk","}"] +],[ + "start" +],[ + "start", + ["text","hdc_frame "], + ["keyword.operator.ahk",":="], + ["text"," "], + ["support.function.ahk","DllCall"], + ["punctuation.ahk","("], + ["punctuation.quote.double","\""], + ["string.quoted.ahk","GetDC"], + ["punctuation.quote.double","\""], + ["punctuation.ahk",","], + ["text"," UInt"], + ["punctuation.ahk",","], + ["text"," MagnifierID"], + ["punctuation.ahk",")"] +],[ + "start" +],[ + "start", + ["comment.line.ahk","; comment"] +],[ + "start", + ["text","DrawCross"], + ["punctuation.ahk","("], + ["keyword.control.ahk","byRef"], + ["text"," x"], + ["keyword.operator.ahk","="], + ["punctuation.quote.double","\""], + ["punctuation.quote.double","\""], + ["punctuation.ahk",","], + ["text"," rX"], + ["punctuation.ahk",","], + ["text","rY"], + ["punctuation.ahk",","], + ["text","z"], + ["punctuation.ahk",","], + ["text"," dc"], + ["punctuation.ahk","){"] +],[ + "start", + ["text"," "], + ["comment.line.ahk"," ;specify the style, thickness and color of the cross lines"] +],[ + "start", + ["text"," h_pen "], + ["keyword.operator.ahk",":="], + ["text"," "], + ["support.function.ahk","DllCall"], + ["punctuation.ahk","("], + ["text"," "], + ["punctuation.quote.double","\""], + ["string.quoted.ahk","gdi32.dll\\CreatePen"], + ["punctuation.quote.double","\""], + ["punctuation.ahk",","], + ["text"," "], + ["constant.language","Int"], + ["punctuation.ahk",","], + ["text"," 0"], + ["punctuation.ahk",","], + ["text"," "], + ["constant.language","Int"], + ["punctuation.ahk",","], + ["text"," 1"], + ["punctuation.ahk",","], + ["text"," UInt"], + ["punctuation.ahk",","], + ["text"," 0x0000FF"], + ["punctuation.ahk",")"] +],[ + "start", + ["punctuation.ahk","}"] +],[ + "start" +],[ + "start", + ["comment.line.ahk",";Ctrl ^; Shift +; Win #; Alt !"] +],[ + "start", + ["text","^"], + ["support.constant.ahk","NumPadAdd"], + ["keyword.operator.ahk","::"] +],[ + "start", + ["text","^"], + ["support.constant.ahk","WheelUp"], + ["keyword.operator.ahk","::"], + ["text"," "] +],[ + "start", + ["text","^;"], + ["keyword.operator.ahk","::"], + ["text"," "], + ["comment.line.ahk"," ;comment"] +],[ + "start", + ["text"," "], + ["keyword.control.ahk","If"], + ["punctuation.ahk","("], + ["text","zoom "], + ["keyword.operator.ahk","<"], + ["text"," ws_x "], + ["variable.parameter","and"], + ["text"," "], + ["punctuation.ahk","("], + ["text"," "], + ["variable.predefined.ahk","A_ThisHotKey"], + ["text"," "], + ["keyword.operator.ahk","="], + ["text"," "], + ["punctuation.quote.double","\""], + ["string.quoted.ahk","^WheelUp"], + ["punctuation.quote.double","\""], + ["text"," "], + ["variable.parameter","or"], + ["text"," "], + ["variable.predefined.ahk","A_ThisHotKey"], + ["text"," "], + ["keyword.operator.ahk","="], + ["punctuation.quote.double","\""], + ["string.quoted.ahk","^NumPadAdd"], + ["punctuation.quote.double","\""], + ["punctuation.ahk",")"], + ["text"," "], + ["punctuation.ahk",")"] +],[ + "start", + ["text","\t\tzoom "], + ["keyword.operator.ahk","*="], + ["text"," 1.189207115 "], + ["comment.line.ahk"," ; sqrt(sqrt(2))"] +],[ + "start", + ["text","\t"], + ["keyword.command.ahk","Gosub"], + ["punctuation.ahk",","], + ["text","setZoom"] +],[ + "start", + ["keyword.control.ahk","return"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_batchfile.json b/public/lib/ace/mode/_test/tokens_batchfile.json new file mode 100644 index 0000000..0f1f138 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_batchfile.json @@ -0,0 +1,70 @@ +[[ + "start", + ["comment.line.colons.dosbatch",":: batch file highlighting in Ace!"] +],[ + "start", + ["text","@"], + ["keyword.command.dosbatch","echo"], + ["text"," off"] +],[ + "start" +],[ + "start", + ["keyword.control.statement.dosbatch","CALL"], + ["text"," "], + ["keyword.command.dosbatch","set"], + ["text"," var1="], + ["constant.numeric","%cd%"] +],[ + "start", + ["keyword.command.dosbatch","echo"], + ["text"," unhide everything in "], + ["constant.numeric","%var1%"], + ["text","!"] +],[ + "start" +],[ + "start", + ["comment.line.colons.dosbatch",":: FOR loop in bat is super strange!"] +],[ + "start", + ["keyword.control.repeat.dosbatch","FOR"], + ["text"," /f "], + ["punctuation.definition.string.begin.shell","\""], + ["string.quoted.double.dosbatch","tokens=*"], + ["punctuation.definition.string.end.shell","\""], + ["text"," "], + ["constant.numeric","%%G"], + ["text"," IN ('"], + ["keyword.command.dosbatch","dir"], + ["text"," /A:D /b') DO ("] +],[ + "start", + ["keyword.command.dosbatch","echo"], + ["text"," "], + ["constant.numeric","%var1%%%G"] +],[ + "start", + ["keyword.command.dosbatch","attrib"], + ["text"," -r -a -h -s "], + ["punctuation.definition.string.begin.shell","\""], + ["constant.numeric","%var1%%%G"], + ["punctuation.definition.string.end.shell","\""], + ["text"," /D /S"] +],[ + "start", + ["text",")"] +],[ + "start" +],[ + "start", + ["keyword.command.dosbatch","pause"] +],[ + "start" +],[ + "start", + ["doc.comment","REM"], + ["comment"," that's all"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_c9search.json b/public/lib/ace/mode/_test/tokens_c9search.json new file mode 100644 index 0000000..902d8dc --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_c9search.json @@ -0,0 +1,131 @@ +[[ + ["start",{}], + ["text","Searching for '"], + ["text","var"], + ["text","' in"], + ["text"," /.c9/metadata/workspace/plugins "], + ["text","(regexp, case sensitive, whole word)"], + "Searching for \u0001var\u0001 in\u0001/.c9/metadata/workspace/plugins\u0001\u0001regexp, case sensitive, whole word\u0001" +],[ + ["start",{}] +],[ + ["start",{}], + ["string","configs/default.js"], + ["text",":"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric"," 1"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," fs = require(\"fs\");"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t2"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," argv = require('optimist').argv;"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t3"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," path = require(\"path\");"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t5"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," clientExtensions = {};"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t6"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," clientDirs = fs.readdirSync(__dirname + \"/../plugins-client\");"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t7"], + ["c9searchresults.text",": "], + ["c9searchresults.text","for ("], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," i = 0; i < clientDirs.length; i++) {"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t8"], + ["c9searchresults.text",": "], + ["c9searchresults.text"," "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," dir = clientDirs[i];"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t12"], + ["c9searchresults.text",": "], + ["c9searchresults.text"," "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," name = dir.split(\".\")[1];"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t16"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," projectDir = (argv.w && path.resolve(process.cwd(), argv.w)) || process.cwd();"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t17"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," fsUrl = \"/workspace\";"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t19"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," port = argv.p || process.env.PORT || 3131;"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t20"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," host = argv.l || \"localhost\";"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t22"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," config = {"] +],[ + ["start",{}] +],[ + ["start",{}], + ["string","configs/local.js"], + ["text",":"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t2"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," config = require(\"./default\");"] +],[ + ["start",{}] +],[ + ["start",{}], + ["string","configs/packed.js"], + ["text",":"] +],[ + ["start",{}], + ["c9searchresults.constant.numeric","\t1"], + ["c9searchresults.text",": "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," config = require(\"./default\");"] +],[ + ["start",{}] +],[ + ["start",{}] +],[ + ["start",{}], + ["text","Found "], + ["constant.numeric","15"], + ["text"," matches in "], + ["constant.numeric","3"], + ["text"," files"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_c_cpp.json b/public/lib/ace/mode/_test/tokens_c_cpp.json new file mode 100644 index 0000000..2442a78 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_c_cpp.json @@ -0,0 +1,201 @@ +[[ + "start", + ["comment","// compound assignment operators"] +],[ + "start" +],[ + "start", + ["keyword","#include"], + ["constant.other"," "] +],[ + "start" +],[ + "directive", + ["keyword","#include"], + ["constant.other.multiline"," \\"] +],[ + "start", + ["constant.other"," "] +],[ + "start" +],[ + "directive", + ["keyword","#include"], + ["constant.other.multiline"," \\"] +],[ + "directive", + ["constant.other.multiline"," \\"] +],[ + "start", + ["constant.other"," "] +],[ + "start" +],[ + "directive", + ["keyword","#include"], + ["constant.other.multiline"," \\"] +],[ + "directive", + ["constant.other.multiline"," \\"] +],[ + "start", + ["constant.other"," \"iostream\""] +],[ + "start" +],[ + "start", + ["keyword","#include"], + ["constant.other"," "] +],[ + "start", + ["keyword","#include"], + ["constant.other"," \"boost/asio/io_service.hpp\""] +],[ + "start" +],[ + "directive", + ["keyword","#include"], + ["constant.other.multiline"," \\"] +],[ + "directive", + ["constant.other.multiline"," \\"] +],[ + "directive", + ["constant.other.multiline"," \"iostream\" \\"] +],[ + "directive", + ["constant.other.multiline"," \"string\" \\"] +],[ + "start", + ["constant.other"," "] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword.control","using"], + ["text"," "], + ["keyword.operator","namespace"], + ["text"," "], + ["identifier","std"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["comment","//"] +],[ + "start", + ["storage.type","int"], + ["text"," "], + ["identifier","main"], + ["text"," "], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.type","int"], + ["text"," "], + ["identifier","a"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","b"], + ["keyword.operator","="], + ["constant.numeric","3"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","/* foobar */"] +],[ + "singleLineComment", + ["text"," "], + ["identifier","a"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","b"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","// single line comment\\"] +],[ + "start", + ["comment"," continued"] +],[ + "start", + ["text"," "], + ["identifier","a"], + ["keyword.operator","+="], + ["constant.numeric","2"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","// equivalent to a=a+2"] +],[ + "start", + ["text"," "], + ["identifier","cout"], + ["text"," "], + ["keyword.operator","<<"], + ["text"," "], + ["identifier","a"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","#if"], + ["text"," "], + ["identifier","VERBOSE"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","2"] +],[ + "start", + ["text"," "], + ["identifier","prints"], + ["paren.lparen","("], + ["string.start","\""], + ["string","trace message"], + ["constant.language.escape","\\n"], + ["string.end","\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","#endif"] +],[ + "start", + ["text"," "], + ["keyword.control","return"], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment","/* Print an error message and get out */"] +],[ + "directive", + ["keyword","#define"], + ["constant.other.multiline"," ABORT \\"] +],[ + "directive", + ["constant.other.multiline"," do { \\"] +],[ + "directive", + ["constant.other.multiline"," print( \"Abort\\n\" ); \\"] +],[ + "directive", + ["constant.other.multiline"," exit(8); \\"] +],[ + "start", + ["constant.other","} while (0) "], + ["comment","/* Note: No semicolon */"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_cirru.json b/public/lib/ace/mode/_test/tokens_cirru.json new file mode 100644 index 0000000..de4852e --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_cirru.json @@ -0,0 +1,267 @@ +[[ + "start", + ["comment.line.double-dash","-- https://github.com/Cirru/cirru-gopher/blob/master/code/scope.cr,"] +],[ + "start" +],[ + "line", + ["support.function","set"], + ["text"," "], + ["variable.parameter","a"], + ["text"," "], + ["storage.modifier","("], + ["support.function","int"], + ["text"," "], + ["constant.numeric","2"], + ["storage.modifier",")"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","("], + ["support.function","self"], + ["storage.modifier",")"] +],[ + "start" +],[ + "line", + ["support.function","set"], + ["text"," "], + ["variable.parameter","c"], + ["text"," "], + ["storage.modifier","("], + ["support.function","child"], + ["storage.modifier",")"] +],[ + "start" +],[ + "line", + ["support.function","under"], + ["text"," "], + ["variable.parameter","c"] +],[ + "line", + ["markup.raw"," "], + ["support.function","under"], + ["text"," "], + ["variable.parameter","parent"] +],[ + "line", + ["markup.raw"," "], + ["support.function","print"], + ["text"," "], + ["variable.parameter","a"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","get"], + ["text"," "], + ["variable.parameter","c"], + ["text"," "], + ["variable.parameter","a"] +],[ + "start" +],[ + "line", + ["support.function","set"], + ["text"," "], + ["variable.parameter","c"], + ["text"," "], + ["variable.parameter","x"], + ["text"," "], + ["storage.modifier","("], + ["support.function","int"], + ["text"," "], + ["constant.numeric","3"], + ["storage.modifier",")"] +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","get"], + ["text"," "], + ["variable.parameter","c"], + ["text"," "], + ["variable.parameter","x"] +],[ + "start" +],[ + "line", + ["support.function","set"], + ["text"," "], + ["variable.parameter","just-print"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","code"] +],[ + "line", + ["markup.raw"," "], + ["support.function","print"], + ["text"," "], + ["variable.parameter","a"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["variable.parameter","just-print"] +],[ + "start" +],[ + "line", + ["support.function","eval"], + ["text"," "], + ["storage.modifier","("], + ["support.function","self"], + ["storage.modifier",")"], + ["text"," "], + ["variable.parameter","just-print"] +],[ + "line", + ["support.function","eval"], + ["text"," "], + ["variable.parameter","just-print"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","("], + ["support.function","string"], + ["text"," "], + ["string.quoted.double","\"string with space\""], + ["storage.modifier",")"] +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","("], + ["support.function","string"], + ["text"," "], + ["string.quoted.double","\"escapes "], + ["constant.character.escape","\\n"], + ["string.quoted.double"," "], + ["constant.character.escape","\\\"\\\\"], + ["string.quoted.double","\""], + ["storage.modifier",")"] +],[ + "start" +],[ + "start", + ["support.function","brackets"], + ["text"," "], + ["storage.modifier","((((()))))"] +],[ + "start" +],[ + "line", + ["string.quoted.double","\"eval\""], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","string"], + ["text"," "], + ["string.quoted.double","\"eval\""] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","("], + ["support.function","add"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["storage.modifier","("], + ["support.function","int"], + ["text"," "], + ["constant.numeric","1"], + ["storage.modifier",")"], + ["text"," "], + ["storage.modifier","("], + ["support.function","int"], + ["text"," "], + ["constant.numeric","2"], + ["storage.modifier","))"] +],[ + "start" +],[ + "start", + ["support.function","print"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","unwrap"], + ["text"," "], + ["storage.modifier","$"] +],[ + "line", + ["text"," "], + ["support.function","map"], + ["text"," "], + ["storage.modifier","("], + ["support.function","a"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","int"], + ["text"," "], + ["constant.numeric","1"], + ["storage.modifier",")"], + ["text"," "], + ["storage.modifier","("], + ["support.function","b"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","int"], + ["text"," "], + ["constant.numeric","2"], + ["storage.modifier",")"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["variable.parameter","a"] +],[ + "line", + ["markup.raw"," "], + ["support.function","int"], + ["text"," "], + ["constant.numeric","1"] +],[ + "line", + ["markup.raw"," "], + ["storage.modifier",","], + ["text"," "], + ["variable.parameter","b"], + ["text"," "], + ["variable.parameter","c"] +],[ + "line", + ["markup.raw"," "], + ["support.function","int"], + ["text"," "], + ["constant.numeric","2"] +],[ + "line", + ["markup.raw"," "], + ["storage.modifier",","], + ["text"," "], + ["variable.parameter","d"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_clojure.json b/public/lib/ace/mode/_test/tokens_clojure.json new file mode 100644 index 0000000..824cba5 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_clojure.json @@ -0,0 +1,162 @@ +[[ + "start", + ["keyword","("], + ["support.function","defn"], + ["text"," "], + ["identifier","parting"] +],[ + "start", + ["text"," "], + ["string","\"returns a String parting in a given language\""] +],[ + "start", + ["text"," "], + ["keyword","([]"], + ["text"," "], + ["keyword","("], + ["identifier","parting"], + ["text"," "], + ["string","\"World\""], + ["keyword","))"] +],[ + "start", + ["text"," "], + ["keyword","(["], + ["support.function","name"], + ["keyword","]"], + ["text"," "], + ["keyword","("], + ["identifier","parting"], + ["text"," "], + ["support.function","name"], + ["text"," "], + ["string","\"en\""], + ["keyword","))"] +],[ + "start", + ["text"," "], + ["keyword","(["], + ["support.function","name"], + ["text"," "], + ["identifier","language"], + ["keyword","]"] +],[ + "start", + ["text"," "], + ["comment","; condp is similar to a case statement in other languages."] +],[ + "start", + ["text"," "], + ["comment","; It is described in more detail later."] +],[ + "start", + ["text"," "], + ["comment","; It is used here to take different actions based on whether the"] +],[ + "start", + ["text"," "], + ["comment","; parameter \"language\" is set to \"en\", \"es\" or something else."] +],[ + "start", + ["text"," "], + ["keyword","("], + ["support.function","condp"], + ["text"," "], + ["constant.language","="], + ["text"," "], + ["identifier","language"] +],[ + "start", + ["text"," "], + ["string","\"en\""], + ["text"," "], + ["keyword","("], + ["support.function","str"], + ["text"," "], + ["string","\"Goodbye, \""], + ["text"," "], + ["support.function","name"], + ["keyword",")"] +],[ + "start", + ["text"," "], + ["string","\"es\""], + ["text"," "], + ["keyword","("], + ["support.function","str"], + ["text"," "], + ["string","\"Adios, \""], + ["text"," "], + ["support.function","name"], + ["keyword",")"] +],[ + "start", + ["text"," "], + ["keyword","(throw"], + ["text"," "], + ["keyword","("], + ["identifier","IllegalArgumentException"], + ["text","."] +],[ + "start", + ["text"," "], + ["keyword","("], + ["support.function","str"], + ["text"," "], + ["string","\"unsupported language \""], + ["text"," "], + ["identifier","language"], + ["keyword","))))))"] +],[ + "start" +],[ + "start", + ["keyword","("], + ["support.function","println"], + ["text"," "], + ["keyword","("], + ["identifier","parting"], + ["keyword","))"], + ["text"," "], + ["comment","; -> Goodbye, World"] +],[ + "start", + ["keyword","("], + ["support.function","println"], + ["text"," "], + ["keyword","("], + ["identifier","parting"], + ["text"," "], + ["string","\"Mark\""], + ["keyword","))"], + ["text"," "], + ["comment","; -> Goodbye, Mark"] +],[ + "start", + ["keyword","("], + ["support.function","println"], + ["text"," "], + ["keyword","("], + ["identifier","parting"], + ["text"," "], + ["string","\"Mark\""], + ["text"," "], + ["string","\"es\""], + ["keyword","))"], + ["text"," "], + ["comment","; -> Adios, Mark"] +],[ + "start", + ["keyword","("], + ["support.function","println"], + ["text"," "], + ["keyword","("], + ["identifier","parting"], + ["text"," "], + ["string","\"Mark\""], + ["text",", "], + ["string","\"xy\""], + ["keyword","))"], + ["text"," "], + ["comment","; -> java.lang.IllegalArgumentException: unsupported language xy"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_cobol.json b/public/lib/ace/mode/_test/tokens_cobol.json new file mode 100644 index 0000000..9909ead --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_cobol.json @@ -0,0 +1,4 @@ +[[ + "start", + ["identifier","TODO"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_coffee.json b/public/lib/ace/mode/_test/tokens_coffee.json new file mode 100644 index 0000000..cf02463 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_coffee.json @@ -0,0 +1,545 @@ +[[ + "start", + ["comment","#test: tokenize keyword"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["paren.lparen","("], + ["identifier","i"], + ["text"," "], + ["constant.numeric","1"], + ["punctuation.operator",".."], + ["constant.numeric","2"], + ["paren.rparen",")"] +],[ + "start", + ["comment","#test: tokenize regexp"] +],[ + "start", + ["string.regex","/\"[a]/"] +],[ + "start", + ["comment","#test: tokenize functions"] +],[ + "start", + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{args}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{a1, a2}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{@a1, a2}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator",":"], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{args}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{args}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{0abc}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["identifier","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["paren","{"], + ["keyword.operator","/"], + ["identifier","abc"], + ["paren","}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","=>"] +],[ + "start", + ["text"," "], + ["identifier","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["paren","{"], + ["identifier","abc"], + ["keyword.operator","/"], + ["paren","}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{#abc}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{abc#}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["identifier","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["paren","{"], + ["paren.rparen",")"], + ["identifier","abc"], + ["paren","}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["identifier","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["paren","{"], + ["identifier","abc"], + ["paren.rparen",")"], + ["paren","}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{a{bc}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{ }"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator",":"], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","{}"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","args"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","arg1, arg2"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","arg1 = 1, arg2 = 'name'"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","@arg1 = /abc/, arg2 = 'name'"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["comment","#test: tokenize function: invalid case:"] +],[ + "start", + ["text"," "], + ["identifier","foo"], + ["keyword.operator","="], + ["paren.lparen","("], + ["keyword.operator","/"], + ["identifier","args"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter"," "], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator",":"], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter"," "], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["variable.language","window"], + ["punctuation.operator","."], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","args"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["entity.name.function","foo"], + ["text"," "], + ["keyword.operator",":"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["comment","#test: tokenize callback function"] +],[ + "start", + ["text"," "], + ["identifier","foo"], + ["text"," "], + ["identifier","bar"], + ["keyword.operator",":"], + ["text"," "], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","args"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["text"," "], + ["identifier","foo"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","2"], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter","x"], + ["paren.rparen",")"], + ["text"," "], + ["storage.type","->"] +],[ + "start", + ["comment","#test: tokenize class"] +],[ + "start", + ["keyword","class"], + ["text"," "], + ["language.support.class","Foo"] +],[ + "start", + ["keyword","class"], + ["text"," "], + ["language.support.class","Foo"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["language.support.class","Bar"] +],[ + "start", + ["comment","#test: tokenize illegal name property"] +],[ + "start", + ["identifier","foo"], + ["punctuation.operator","."], + ["identifier","static"], + ["punctuation.operator","."], + ["identifier","function"] +],[ + "start", + ["comment","#!test tokenize string with interpolation"] +],[ + "start", + ["identifier","a"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.start","\""], + ["paren.string","#{"], + ["text"," "], + ["constant.numeric","22"], + ["text"," "], + ["keyword.operator","/"], + ["text"," "], + ["constant.numeric","7"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["paren","{"], + ["identifier","x"], + ["keyword.operator",":"], + ["text"," "], + ["string.start","\""], + ["paren.string","#{"], + ["identifier","a"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["identifier","b"], + ["paren.string","}"], + ["string.end","\""], + ["paren","}"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","2"], + ["paren.string","}"], + ["string.end","\""] +],[ + "start", + ["string.start","\""], + ["string"," "], + ["paren.string","#{"], + ["text"," "], + ["string.start","\""], + ["string.end","\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["paren","{}"], + ["text"," "], + ["paren.string","}"], + ["string"," )"], + ["string.end","\""], + ["text"," "] +],[ + "qqdoc", + ["string","\"\"\"heredoc"] +],[ + "start", + ["string"," \"\"\""] +],[ + "start", + ["keyword","do"], + ["text"," "], + ["storage.type","->"] +],[ + "comment", + ["text"," "], + ["comment","###"] +],[ + "comment", + ["comment"," herecomment"] +],[ + "start", + ["comment"," ###"] +],[ + "heregex", + ["text"," "], + ["identifier","re"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.regex","/regex/imgy"], + ["punctuation.operator","."], + ["identifier","test"], + ["text"," "], + ["string.regex","///"] +],[ + "heregex", + ["comment.regex"," "], + ["string.regex","heregex"], + ["comment.regex"," # comment"] +],[ + "start", + ["string.regex"," ///imgy"] +],[ + "js", + ["text"," "], + ["keyword","this"], + ["text"," "], + ["keyword","isnt"], + ["keyword.operator",":"], + ["text"," "], + ["string","`just "] +],[ + "start", + ["string"," JavaScript`"] +],[ + "start", + ["text"," "], + ["constant.language","undefined"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_coldfusion.json b/public/lib/ace/mode/_test/tokens_coldfusion.json new file mode 100644 index 0000000..d20d8f3 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_coldfusion.json @@ -0,0 +1,61 @@ +[[ + "start", + ["comment.start",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["keyword.tag-name.xml","cfset"], + ["text.tag-whitespace.xml"," "], + ["comment.start",""], + ["comment"," z "], + ["comment.end","--->"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","welcome"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"Hello World!\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["comment.start.xml",""], + ["comment.xml"," z "], + ["comment.end.xml","-->"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["keyword.tag-name.xml","cfoutput"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","#welcome#"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "cfjs-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.cfscript.tag-name.xml","cfscript"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "cfjs-no_regex", + ["text"," "], + ["identifier","Dateformat"], + ["paren.lparen","("], + ["identifier","now"], + ["paren.lparen","("], + ["paren.rparen","))"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_csharp.json b/public/lib/ace/mode/_test/tokens_csharp.json new file mode 100644 index 0000000..dcc6d0e --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_csharp.json @@ -0,0 +1,31 @@ +[[ + "start", + ["keyword","public"], + ["text"," "], + ["keyword","void"], + ["text"," "], + ["identifier","HelloWorld"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["comment","//Say Hello!"] +],[ + "start", + ["text"," "], + ["identifier","Console"], + ["punctuation.operator","."], + ["identifier","WriteLine"], + ["paren.lparen","("], + ["string.start","\""], + ["string","Hello World"], + ["string.end","\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_csound_document.json b/public/lib/ace/mode/_test/tokens_csound_document.json new file mode 100644 index 0000000..1baf49d --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_csound_document.json @@ -0,0 +1,92 @@ +[[ + "start", + ["text.csound-document","/*"] +],[ + "start", + ["text.csound-document"," * comment"] +],[ + "start", + ["text.csound-document"," */"] +],[ + "start", + ["text.csound-document","; comment"] +],[ + "start", + ["text.csound-document","// comment"] +],[ + "start", + ["text.csound-document","/"] +],[ + "synthesizer", + ["meta.tag.punctuation.tag-open.csound-document","<"], + ["entity.name.tag.begin.csound-document","CsoundSynthesizer"], + ["meta.tag.punctuation.tag-close.csound-document",">"] +],[ + "csound-start", + ["meta.tag.punctuation.tag-open.csound-document","<"], + ["entity.name.tag.begin.csound-document","CsInstruments"], + ["meta.tag.punctuation.tag-close.csound-document",">"] +],[ + "csound-start", + ["variable.language.csound","0dbfs"], + ["text"," "], + ["keyword.operator.csound","="], + ["text"," "], + ["constant.numeric.integer.decimal.csound","1"] +],[ + "csound-start", + ["support.function.csound","prints"], + ["text"," "], + ["punctuation.definition.string.begin.csound","\""], + ["string.quoted.csound","hello, world"], + ["constant.character.escape.csound","\\n"], + ["punctuation.definition.string.end.csound","\""] +],[ + "synthesizer", + ["meta.tag.punctuation.end-tag-open.csound-document",""] +],[ + "csound-score-start", + ["meta.tag.punctuation.tag-open.csound-document","<"], + ["entity.name.tag.begin.csound-document","CsScore"], + ["meta.tag.punctuation.tag-close.csound-document",">"] +],[ + "csound-score-start", + ["keyword.control.csound-score","i"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","1"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0"] +],[ + "synthesizer", + ["meta.tag.punctuation.end-tag-open.csound-document",""] +],[ + "html-start", + ["meta.tag.punctuation.tag-open.csound-document","<"], + ["entity.name.tag.begin.csound-document","html"], + ["meta.tag.punctuation.tag-close.csound-document",">"] +],[ + "html-start", + ["xml-pe.doctype.xml",""] +],[ + "synthesizer", + ["meta.tag.punctuation.end-tag-open.csound-document",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.csound-document",""] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_csound_orchestra.json b/public/lib/ace/mode/_test/tokens_csound_orchestra.json new file mode 100644 index 0000000..410bbc7 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_csound_orchestra.json @@ -0,0 +1,514 @@ +[[ + "punctuation.definition.comment.begin.csound", + ["punctuation.definition.comment.begin.csound","/*"] +],[ + "punctuation.definition.comment.begin.csound", + ["comment.block.csound"," * comment"] +],[ + "start", + ["comment.block.csound"," "], + ["punctuation.definition.comment.end.csound","*/"] +],[ + "start", + ["comment.line.semicolon.csound","; comment"] +],[ + "start", + ["comment.line.double-slash.csound","// comment"] +],[ + "start" +],[ + "start", + ["keyword.function.csound","instr"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["entity.name.function.csound","1"], + ["text",","], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["entity.name.function.csound","N_a_M_e_"], + ["text",","], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["text","+"], + ["entity.name.function.csound","Name"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["comment.line.double-slash.csound","//"] +],[ + "start", + ["text"," "], + ["text.csound","iDuration"], + ["text"," "], + ["keyword.operator.csound","="], + ["text"," "], + ["support.variable.csound","p3"] +],[ + "start", + ["text"," "], + ["support.function.csound","outc"], + ["punctuation.type-annotation.csound",":"], + ["type-annotation.storage.type.csound","a"], + ["text","("], + ["text.csound","aSignal"], + ["text",")"] +],[ + "start", + ["keyword.other.csound","endin"] +],[ + "start" +],[ + "start", + ["keyword.function.csound","opcode"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["entity.name.function.opcode.csound","aUDO"], + ["text",","], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["storage.type.csound","i[]"], + ["text",","], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["storage.type.csound","aik"], + ["comment.line.double-slash.csound","//"] +],[ + "start", + ["text"," "], + ["text.csound","aUDO"] +],[ + "start", + ["keyword.other.csound","endop"] +],[ + "start" +],[ + "start", + ["constant.numeric.integer.decimal.csound","123"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0123456789"] +],[ + "start", + ["storage.type.number.csound","0x"], + ["constant.numeric.integer.hexadecimal.csound","abcdef0123456789"], + ["text"," "], + ["storage.type.number.csound","0X"], + ["constant.numeric.integer.hexadecimal.csound","ABCDEF"] +],[ + "start", + ["constant.numeric.float.csound","1e2"], + ["text"," "], + ["constant.numeric.float.csound","3e+4"], + ["text"," "], + ["constant.numeric.float.csound","5e-6"], + ["text"," "], + ["constant.numeric.float.csound","7E8"], + ["text"," "], + ["constant.numeric.float.csound","9E+0"], + ["text"," "], + ["constant.numeric.float.csound","1E-2"], + ["text"," "], + ["constant.numeric.float.csound","3."], + ["text"," "], + ["constant.numeric.float.csound","4.56"], + ["text"," "], + ["constant.numeric.float.csound",".789"] +],[ + "start" +],[ + "start", + ["punctuation.definition.string.begin.csound","\""], + ["string.quoted.csound","characters"], + ["entity.name.function.preprocessor.csound","$MACRO."], + ["punctuation.definition.string.end.csound","\""] +],[ + "start", + ["punctuation.definition.string.begin.csound","\""], + ["constant.character.escape.csound","\\\\\\a\\b\\n\\r\\t\\012\\345\\67\\\""], + ["punctuation.definition.string.end.csound","\""] +],[ + "start" +],[ + ["#tmp","braced string","start","braced string"], + ["punctuation.definition.string.begin.csound","{{"] +],[ + ["#tmp","braced string","start","braced string"], + ["string.braced.csound","characters$MACRO."] +],[ + "start", + ["punctuation.definition.string.end.csound","}}"] +],[ + "start", + ["punctuation.definition.string.begin.csound","{{"], + ["constant.character.escape.csound","\\\\\\a\\b\\n\\r\\t\\\"\\012\\345\\67"], + ["punctuation.definition.string.end.csound","}}"] +],[ + "start" +],[ + "start", + ["keyword.operator.csound","+"], + ["text"," "], + ["keyword.operator.csound","-"], + ["text"," "], + ["keyword.operator.csound","~"], + ["text"," "], + ["keyword.operator.csound","¬"], + ["text"," "], + ["keyword.operator.csound","!"], + ["text"," "], + ["keyword.operator.csound","*"], + ["text"," "], + ["keyword.operator.csound","/"], + ["text"," "], + ["keyword.operator.csound","^"], + ["text"," "], + ["keyword.operator.csound","%"], + ["text"," "], + ["keyword.operator.csound","<<"], + ["text"," "], + ["keyword.operator.csound",">>"], + ["text"," "], + ["keyword.operator.csound","<"], + ["text"," "], + ["keyword.operator.csound",">"], + ["text"," "], + ["keyword.operator.csound","<="], + ["text"," "], + ["keyword.operator.csound",">="], + ["text"," "], + ["keyword.operator.csound","=="], + ["text"," "], + ["keyword.operator.csound","!="], + ["text"," "], + ["keyword.operator.csound","&"], + ["text"," "], + ["keyword.operator.csound","#"], + ["text"," "], + ["keyword.operator.csound","|"], + ["text"," "], + ["keyword.operator.csound","&&"], + ["text"," "], + ["keyword.operator.csound","||"], + ["text"," "], + ["keyword.operator.csound","?"], + ["text"," "], + ["keyword.operator.csound",":"], + ["text"," "], + ["keyword.operator.csound","+="], + ["text"," "], + ["keyword.operator.csound","-="], + ["text"," "], + ["keyword.operator.csound","*="], + ["text"," "], + ["keyword.operator.csound","/="] +],[ + "start" +],[ + "start", + ["variable.language.csound","0dbfs"], + ["text"," "], + ["variable.language.csound","A4"], + ["text"," "], + ["variable.language.csound","kr"], + ["text"," "], + ["variable.language.csound","ksmps"], + ["text"," "], + ["variable.language.csound","nchnls"], + ["text"," "], + ["variable.language.csound","nchnls_i"], + ["text"," "], + ["variable.language.csound","sr"] +],[ + "start" +],[ + "start", + ["keyword.control.csound","do"], + ["text"," "], + ["keyword.control.csound","else"], + ["text"," "], + ["keyword.control.csound","elseif"], + ["text"," "], + ["keyword.control.csound","endif"], + ["text"," "], + ["keyword.control.csound","enduntil"], + ["text"," "], + ["keyword.control.csound","fi"], + ["text"," "], + ["keyword.control.csound","if"], + ["text"," "], + ["keyword.control.csound","ithen"], + ["text"," "], + ["keyword.control.csound","kthen"], + ["text"," "], + ["keyword.control.csound","od"], + ["text"," "], + ["keyword.control.csound","then"], + ["text"," "], + ["keyword.control.csound","until"], + ["text"," "], + ["keyword.control.csound","while"] +],[ + "start", + ["keyword.control.csound","return"], + ["text"," "], + ["keyword.control.csound","rireturn"] +],[ + "start" +],[ + "start", + ["entity.name.label.csound","aLabel"], + ["entity.punctuation.label.csound",":"] +],[ + "start", + ["text.csound"," "], + ["entity.name.label.csound","label2"], + ["entity.punctuation.label.csound",":"] +],[ + "start" +],[ + "start", + ["keyword.control.csound","goto"], + ["text.csound"," "], + ["entity.name.label.csound","aLabel"] +],[ + "start", + ["keyword.control.csound","reinit"], + ["text.csound"," "], + ["entity.name.label.csound","aLabel"] +],[ + "start", + ["keyword.control.csound","cggoto"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","1"], + ["keyword.operator.csound","=="], + ["constant.numeric.integer.decimal.csound","0"], + ["text.csound",", "], + ["entity.name.label.csound","aLabel"] +],[ + "start", + ["keyword.control.csound","timout"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0"], + ["text.csound",","], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0"], + ["text.csound",", "], + ["entity.name.label.csound","aLabel"] +],[ + "start", + ["keyword.control.csound","loop_ge"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0"], + ["text.csound",","], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0"], + ["text.csound",","], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0"], + ["text.csound",", "], + ["entity.name.label.csound","aLabel"] +],[ + "start" +],[ + ["#tmp","csound-score-start","start","Csound score opcode"], + ["support.function.csound","readscore"], + ["text"," "], + ["punctuation.definition.string.begin.csound","{{"] +],[ + ["#tmp","csound-score-start","start","Csound score opcode"], + ["keyword.control.csound-score","i"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","1"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0"] +],[ + "start", + ["punctuation.definition.string.end.csound","}}"] +],[ + ["#tmp","python-start","start","Python opcode"], + ["support.function.csound","pyrun"], + ["text"," "], + ["punctuation.definition.string.begin.csound","{{"] +],[ + ["#tmp","python-start","start","Python opcode"], + ["comment","# Python"] +],[ + "start", + ["punctuation.definition.string.end.csound","}}"] +],[ + ["#tmp","lua-start","start","Lua opcode"], + ["support.function.csound","lua_exec"], + ["text"," "], + ["punctuation.definition.string.begin.csound","{{"] +],[ + ["#tmp","lua-start","start","Lua opcode"], + ["comment","-- Lua"] +],[ + "start", + ["punctuation.definition.string.end.csound","}}"] +],[ + "start" +],[ + "start", + ["keyword.preprocessor.csound","#include"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["string.csound","\"file.udo\""] +],[ + "start", + ["keyword.preprocessor.csound","#include"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["string.csound","|file.udo|"] +],[ + "start" +],[ + "start", + ["keyword.preprocessor.csound","#ifdef"], + ["text"," "], + ["entity.name.function.preprocessor.csound","MACRO"] +],[ + "start", + ["keyword.preprocessor.csound","#else"] +],[ + "start", + ["keyword.preprocessor.csound","#ifndef"], + ["text"," "], + ["entity.name.function.preprocessor.csound","MACRO"] +],[ + "start", + ["keyword.preprocessor.csound","#endif"] +],[ + "start", + ["keyword.preprocessor.csound","#undef"], + ["text"," "], + ["entity.name.function.preprocessor.csound","MACRO"] +],[ + "start" +],[ + "start", + ["keyword.preprocessor.csound","# define"], + ["text"," "], + ["entity.name.function.preprocessor.csound","MACRO"], + ["punctuation.definition.macro.begin.csound","#"], + ["text.csound","macro_body"], + ["punctuation.definition.macro.end.csound","#"] +],[ + "define directive", + ["keyword.preprocessor.csound","#define"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"] +],[ + "define directive", + ["entity.name.function.preprocessor.csound","MACRO"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"] +],[ + "macro body", + ["punctuation.definition.macro.begin.csound","#"], + ["constant.character.escape.csound","\\#"], + ["text.csound","macro"] +],[ + "start", + ["text.csound","body"], + ["constant.character.escape.csound","\\#"], + ["punctuation.definition.macro.end.csound","#"] +],[ + "start" +],[ + "start", + ["keyword.preprocessor.csound","#define"], + ["text"," "], + ["entity.name.function.preprocessor.csound","MACRO"], + ["punctuation.definition.macro-parameter-name-list.begin.csound","("], + ["variable.parameter.preprocessor.csound","ARG1"], + ["text","#"], + ["variable.parameter.preprocessor.csound","ARG2"], + ["punctuation.definition.macro-parameter-name-list.end.csound",")"], + ["text"," "], + ["punctuation.definition.macro.begin.csound","#"], + ["text.csound","macro_body"], + ["punctuation.definition.macro.end.csound","#"] +],[ + "define directive", + ["keyword.preprocessor.csound","#define"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"] +],[ + "define directive", + ["entity.name.function.preprocessor.csound","MACRO"], + ["punctuation.definition.macro-parameter-name-list.begin.csound","("], + ["variable.parameter.preprocessor.csound","ARG1"], + ["text","'"], + ["variable.parameter.preprocessor.csound","ARG2"], + ["text","'"], + ["variable.parameter.preprocessor.csound","ARG3"], + ["punctuation.definition.macro-parameter-name-list.end.csound",")"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"] +],[ + "macro body", + ["punctuation.definition.macro.begin.csound","#"], + ["constant.character.escape.csound","\\#"], + ["text.csound","macro"] +],[ + "start", + ["text.csound","body"], + ["constant.character.escape.csound","\\#"], + ["punctuation.definition.macro.end.csound","#"] +],[ + "start" +],[ + "start", + ["entity.name.function.preprocessor.csound","$MACRO"], + ["text"," "], + ["entity.name.function.preprocessor.csound","$MACRO."] +],[ + "start", + ["entity.name.function.preprocessor.csound","$MACRO"], + ["punctuation.definition.macro-parameter-value-list.begin.csound","("], + ["text","x"], + ["punctuation.definition.macro-parameter-value-list.end.csound",")"] +],[ + "start", + ["keyword.preprocessor.csound","@0"] +],[ + "start", + ["keyword.preprocessor.csound","@@ 1"] +],[ + "start", + ["entity.name.function.preprocessor.csound","$MACRO."], + ["punctuation.definition.macro-parameter-value-list.begin.csound","("], + ["punctuation.macro-parameter-value-parenthetical.begin.csound","(("], + ["text.csound","x"], + ["keyword.operator.csound","#"], + ["text.csound","y"], + ["constant.character.escape.csound","\\)"], + ["punctuation.macro-parameter-value-parenthetical.end.csound","))"], + ["punctuation.macro-parameter-value-separator.csound","'"], + ["text"," "], + ["punctuation.definition.string.begin.csound","\""], + ["invalid.illegal.csound","(#'"], + ["string.quoted.csound","x"], + ["invalid.illegal.csound",")"], + ["constant.character.escape.csound","\\)"], + ["string.quoted.csound","x"], + ["constant.character.escape.csound","\\)"], + ["invalid.illegal.csound",")"], + ["punctuation.definition.string.end.csound","\""], + ["punctuation.macro-parameter-value-separator.csound","#"], + ["text"," "], + ["punctuation.definition.string.begin.csound","{{"], + ["string.braced.csound","x"], + ["constant.character.escape.csound","\\)"], + ["invalid.illegal.csound.csound",")"], + ["string.braced.csound","x"], + ["invalid.illegal.csound.csound",")"], + ["constant.character.escape.csound","\\)"], + ["invalid.illegal.csound.csound","(#'"], + ["punctuation.definition.string.end.csound","}}"], + ["punctuation.definition.macro-parameter-value-list.end.csound",")"], + ["comment.line.semicolon.csound",";"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_csound_score.json b/public/lib/ace/mode/_test/tokens_csound_score.json new file mode 100644 index 0000000..6de013a --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_csound_score.json @@ -0,0 +1,158 @@ +[[ + "punctuation.definition.comment.begin.csound", + ["punctuation.definition.comment.begin.csound","/*"] +],[ + "punctuation.definition.comment.begin.csound", + ["comment.block.csound"," * comment"] +],[ + "start", + ["comment.block.csound"," "], + ["punctuation.definition.comment.end.csound","*/"] +],[ + "start", + ["comment.line.semicolon.csound","; comment"] +],[ + "start", + ["comment.line.double-slash.csound","// comment"] +],[ + "start", + ["keyword.control.csound-score","a"], + ["text"," "], + ["keyword.control.csound-score","b"], + ["text"," "], + ["keyword.control.csound-score","C"], + ["text"," "], + ["keyword.control.csound-score","d"], + ["text"," "], + ["keyword.control.csound-score","e"], + ["text"," "], + ["keyword.control.csound-score","f"], + ["text"," "], + ["keyword.control.csound-score","i"], + ["text"," "], + ["keyword.control.csound-score","q"], + ["text"," "], + ["keyword.control.csound-score","s"], + ["text"," "], + ["keyword.control.csound-score","t"], + ["text"," "], + ["keyword.control.csound-score","v"], + ["text"," "], + ["keyword.control.csound-score","x"], + ["text"," "], + ["keyword.control.csound-score","y"] +],[ + "start", + ["constant.numeric.language.csound-score","z"] +],[ + "start", + ["keyword.control.csound-score","np"], + ["constant.numeric.integer.decimal.csound-score","0"], + ["text"," "], + ["keyword.control.csound-score","nP"], + ["constant.numeric.integer.decimal.csound-score","1"], + ["text"," "], + ["keyword.control.csound-score","Np"], + ["constant.numeric.integer.decimal.csound-score","2"], + ["text"," "], + ["keyword.control.csound-score","NP"], + ["constant.numeric.integer.decimal.csound-score","3"] +],[ + "start", + ["keyword.other.csound-score","m"], + ["punctuation.definition.comment.begin.csound","/*"], + ["punctuation.definition.comment.end.csound","*/"], + ["entity.name.label.csound-score","label"], + ["comment.line.semicolon.csound",";"] +],[ + "start", + ["keyword.other.csound-score","n"], + ["text"," "], + ["entity.name.label.csound-score","label"] +],[ + "start", + ["constant.numeric.integer.decimal.csound","123"], + ["text"," "], + ["constant.numeric.integer.decimal.csound","0123456789"] +],[ + "start", + ["storage.type.number.csound","0x"], + ["constant.numeric.integer.hexadecimal.csound","abcdef0123456789"], + ["text"," "], + ["storage.type.number.csound","0X"], + ["constant.numeric.integer.hexadecimal.csound","ABCDEF"] +],[ + "start", + ["constant.numeric.float.csound","1e2"], + ["text"," "], + ["constant.numeric.float.csound","3e+4"], + ["text"," "], + ["constant.numeric.float.csound","5e-6"], + ["text"," "], + ["constant.numeric.float.csound","7E8"], + ["text"," "], + ["constant.numeric.float.csound","9E+0"], + ["text"," "], + ["constant.numeric.float.csound","1E-2"], + ["text"," "], + ["constant.numeric.float.csound","3."], + ["text"," "], + ["constant.numeric.float.csound","4.56"], + ["text"," "], + ["constant.numeric.float.csound",".789"] +],[ + "start", + ["punctuation.definition.string.begin.csound-score","\""], + ["string.quoted.csound-score","characters"], + ["entity.name.function.preprocessor.csound","$MACRO."], + ["punctuation.definition.string.end.csound-score","\""] +],[ + ["#tmp","loop after macro name","start","loop after macro name"], + ["punctuation.braced-loop.begin.csound-score","{"], + ["text"," "], + ["constant.numeric.integer.decimal.csound-score","1"], + ["text"," "], + ["entity.name.function.preprocessor.csound-score","I"] +],[ + ["#tmp","loop after macro name","start","loop after macro name","loop after macro name"], + ["text"," "], + ["punctuation.braced-loop.begin.csound-score","{"], + ["text"," "], + ["constant.numeric.integer.decimal.csound-score","2"], + ["text"," "], + ["entity.name.function.preprocessor.csound-score","J"] +],[ + ["#tmp","loop after macro name","start","loop after macro name","loop after macro name","loop after macro name"], + ["text"," "], + ["punctuation.braced-loop.begin.csound-score","{"], + ["text"," "], + ["constant.numeric.integer.decimal.csound-score","3"], + ["text"," "], + ["entity.name.function.preprocessor.csound-score","K"] +],[ + ["#tmp","loop after macro name","start","loop after macro name","loop after macro name","loop after macro name"], + ["text"," "], + ["entity.name.function.preprocessor.csound","$I"], + ["text"," "], + ["entity.name.function.preprocessor.csound","$J"], + ["text"," "], + ["entity.name.function.preprocessor.csound","$K"] +],[ + ["#tmp","loop after macro name","start","loop after macro name","loop after macro name"], + ["text"," "], + ["punctuation.braced-loop.end.csound-score","}"] +],[ + ["#tmp","loop after macro name","start","loop after macro name"], + ["text"," "], + ["punctuation.braced-loop.end.csound-score","}"] +],[ + "start", + ["punctuation.braced-loop.end.csound-score","}"] +],[ + "start", + ["keyword.preprocessor.csound","#include"], + ["text"," "], + ["string.csound","\"score.sco\""] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_css.json b/public/lib/ace/mode/_test/tokens_css.json new file mode 100644 index 0000000..e735de9 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_css.json @@ -0,0 +1,221 @@ +[[ + "ruleset", + ["variable",".text-layer"], + ["text"," "], + ["paren.lparen","{"] +],[ + "ruleset", + ["text"," "], + ["support.type","font"], + ["text",": "], + ["constant.numeric","12"], + ["keyword","px"], + ["text"," Monaco, "], + ["string.start","\""], + ["string","Courier New"], + ["string.end","\""], + ["text",", "], + ["support.constant.fonts","monospace"], + ["text",";"] +],[ + "ruleset", + ["text"," "], + ["support.type","cursor"], + ["text",": "], + ["support.constant","text"], + ["text",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "ruleset", + ["variable",".blinker"], + ["text"," "], + ["paren.lparen","{"] +],[ + "ruleset", + ["text"," "], + ["support.type","animation"], + ["text",": blink "], + ["constant.numeric","1"], + ["keyword","s"], + ["text"," "], + ["support.constant","linear"], + ["text"," infinite alternate;"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["string","@"], + ["keyword","keyframes"], + ["text"," blink "], + ["paren.lparen","{"] +],[ + "ruleset", + ["text"," "], + ["constant.numeric","0"], + ["keyword","%"], + ["text",", "], + ["constant.numeric","40"], + ["keyword","%"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["comment","ruleset"], + ["text"," "], + ["support.type","opacity"], + ["text",": "], + ["constant.numeric","0"], + ["text","; "], + ["comment","/*"] +],[ + "ruleset", + ["comment"," */"] +],[ + "ruleset", + ["text"," "], + ["support.type","opacity"], + ["text",": "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "ruleset", + ["text"," "], + ["constant.numeric","40.5"], + ["keyword","%"], + ["text",", "], + ["constant.numeric","100"], + ["keyword","%"], + ["text"," "], + ["paren.lparen","{"] +],[ + "ruleset", + ["text"," "], + ["support.type","opacity"], + ["text",": "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "media", + ["string","@"], + ["keyword","document"], + ["text"," "], + ["support.function","url("], + ["string","http://c9.io/"], + ["support.function",")"], + ["text",", "], + ["support.function","url-prefix("], + ["string","http://ace.c9.io/build/"], + ["support.function",")"], + ["text",","] +],[ + "media", + ["text"," "], + ["support.function","domain("], + ["string","c9.io"], + ["support.function",")"], + ["text",", "], + ["support.function","regexp("], + ["string","\"https:.*\""], + ["support.function",")"], + ["text"," "], + ["comment","/**/"] +],[ + "start", + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["comment","/**/"] +],[ + "start", + ["text"," "], + ["constant","img"], + ["text","["], + ["constant","title"], + ["text","]"], + ["string",":before"], + ["text"," "] +],[ + "ruleset", + ["text"," "], + ["paren.lparen","{"] +],[ + ["string.start0","ruleset"], + ["text"," "], + ["support.type","content"], + ["text",": "], + ["support.function","attr"], + ["text","(title) "], + ["string.start","\""], + ["constant.language.escape","\\A"], + ["string","Image "], + ["constant.language.escape","\\"] +],[ + "ruleset", + ["string"," retrieved from"], + ["string.end","\""] +],[ + ["comment","ruleset"], + ["text"," "], + ["support.function","attr"], + ["text","(src); "], + ["comment","/*"] +],[ + "ruleset", + ["comment"," */"] +],[ + "ruleset", + ["text"," "], + ["support.type","white-space"], + ["text",": "], + ["support.constant","pre"], + ["text",";"] +],[ + "ruleset", + ["text"," "], + ["support.type","display"], + ["text",": "], + ["support.constant","block"], + ["text",";"] +],[ + "ruleset", + ["text"," "], + ["support.type","background"], + ["text",": "], + ["support.function","url("], + ["string","asdasd"], + ["support.function",")"], + ["text","; "], + ["string.start","\""], + ["string","err"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_curly.json b/public/lib/ace/mode/_test/tokens_curly.json new file mode 100644 index 0000000..d87a627 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_curly.json @@ -0,0 +1,56 @@ +[[ + "start", + ["text.xml","tokenize Curly template"], + ["variable","{{"], + ["text","test"], + ["variable","}}"] +],[ + "start", + ["text.xml","tokenize embedded script"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","a"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","'a'"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["storage.type","var"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml","'123'"] +],[ + "start", + ["text.xml","tokenize multiline attribute value with double quotes"] +],[ + ["string.attribute-value.xml0","tag_stuff"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"abc{{xyz}}"] +],[ + "start", + ["string.attribute-value.xml","def\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml","tokenize multiline attribute value with single quotes"] +],[ + ["string.attribute-value.xml","tag_stuff"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","'abc"] +],[ + "start", + ["string.attribute-value.xml","def\\\"'"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_d.json b/public/lib/ace/mode/_test/tokens_d.json new file mode 100644 index 0000000..85831cc --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_d.json @@ -0,0 +1,111 @@ +[[ + "start", + ["comment.shebang","#!/usr/bin/env rdmd"] +],[ + "start", + ["comment","// Computes average line length for standard input."] +],[ + "start", + ["keyword","import"], + ["text"," "], + ["variable.module","std.stdio"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword.type","void"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.type","ulong"], + ["text"," "], + ["identifier","lines"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.type","double"], + ["text"," "], + ["identifier","sumLength"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.control","foreach"], + ["text"," "], + ["paren.lparen","("], + ["identifier","line"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","stdin"], + ["punctuation.operator","."], + ["identifier","byLine"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.operator","++"], + ["identifier","lines"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["identifier","sumLength"], + ["text"," "], + ["keyword.operator","+="], + ["text"," "], + ["identifier","line"], + ["punctuation.operator","."], + ["identifier","length"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["identifier","writeln"], + ["paren.lparen","("], + ["string","\"Average line length: \""], + ["punctuation.operator",","] +],[ + "start", + ["text"," "], + ["identifier","lines"], + ["text"," "], + ["keyword.operator","?"], + ["text"," "], + ["identifier","sumLength"], + ["text"," "], + ["keyword.operator","/"], + ["text"," "], + ["identifier","lines"], + ["text"," "], + ["punctuation.operator",":"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_dart.json b/public/lib/ace/mode/_test/tokens_dart.json new file mode 100644 index 0000000..37cdc32 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_dart.json @@ -0,0 +1,368 @@ +[[ + "start", + ["identifier","main"], + ["text","() {"] +],[ + "start", + ["text"," "], + ["identifier","print"], + ["text","("], + ["string","'Hello World!'"], + ["text",");"] +],[ + "start", + ["text","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["storage.type.primitive.dart","int"], + ["text"," "], + ["identifier","fib"], + ["text","("], + ["storage.type.primitive.dart","int"], + ["text"," "], + ["identifier","n"], + ["text",") "], + ["keyword.operator.assignment.dart","="], + ["keyword.operator.comparison.dart",">"], + ["text"," ("], + ["identifier","n"], + ["text"," "], + ["keyword.operator.comparison.dart",">"], + ["text"," "], + ["constant.numeric","1"], + ["text",") "], + ["keyword.control.ternary.dart","?"], + ["text"," ("], + ["identifier","fib"], + ["text","("], + ["identifier","n"], + ["text"," "], + ["keyword.operator.arithmetic.dart","-"], + ["text"," "], + ["constant.numeric","1"], + ["text",") "], + ["keyword.operator.arithmetic.dart","+"], + ["text"," "], + ["identifier","fib"], + ["text","("], + ["identifier","n"], + ["text"," "], + ["keyword.operator.arithmetic.dart","-"], + ["text"," "], + ["constant.numeric","2"], + ["text",")) "], + ["keyword.control.ternary.dart",":"], + ["text"," "], + ["identifier","n"], + ["text",";"] +],[ + "start", + ["identifier","main"], + ["text","() {"] +],[ + "start", + ["text"," "], + ["identifier","print"], + ["text","("], + ["string","'fib(20) = ${fib(20)}'"], + ["text",");"] +],[ + "start", + ["text","}"] +],[ + "comment", + ["comment","/*asd"] +],[ + "comment", + ["comment","asdad"] +],[ + "start", + ["comment","*/"] +],[ + "start", + ["constant.numeric","0.67"] +],[ + "start", + ["constant.numeric","77"] +],[ + "start", + ["text","."], + ["constant.numeric","86"] +],[ + "start" +],[ + "start", + ["keyword.other.import.dart","import"], + ["text","("], + ["string","\"http://dartwatch.com/myOtherLibrary.dart\""], + ["text",");"] +],[ + "start", + ["keyword.other.import.dart","import"], + ["text","("], + ["string","\"myOtherLibrary.dart\""], + ["text",", "], + ["keyword.other.import.dart","prefix"], + ["text",":"], + ["string","\"lib1\""], + ["text",");"] +],[ + "start" +],[ + "qqdoc", + ["string","\"\"\"asdasdads"] +],[ + "qqdoc", + ["string","asdadsadsasd"] +],[ + "start", + ["string","asdasdasdad\"\"\""] +],[ + "start", + ["text"," "] +],[ + "start", + ["string","'23424'"] +],[ + "start" +],[ + "start", + ["constant.numeric","0x234"] +],[ + "start" +],[ + "start", + ["identifier","foo"], + ["text"," "], + ["keyword.operator.dart","is"], + ["text"," "], + ["identifier","bar"] +],[ + "start" +],[ + "start", + ["storage.type.primitive.dart","int"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator.assignment.dart","="], + ["text"," "], + ["constant.numeric","4"], + ["text"," "], + ["keyword.operator.bitwise.dart","<<"], + ["text"," "], + ["constant.numeric","10"], + ["text"," "] +],[ + "start", + ["comment","// Create a class for Point."] +],[ + "start", + ["keyword.declaration.dart","class"], + ["text"," "], + ["identifier","Point"], + ["text"," {"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["comment","// Final variables cannot be changed once they are assigned."] +],[ + "start", + ["text"," "], + ["comment","// Create two instance variables."] +],[ + "start", + ["text"," "], + ["storage.modifier.dart","final"], + ["text"," "], + ["storage.type.primitive.dart","num"], + ["text"," "], + ["identifier","x"], + ["text",", "], + ["identifier","y"], + ["text",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["comment","// A constructor, with syntactic sugar for setting instance variables."] +],[ + "start", + ["text"," "], + ["identifier","Point"], + ["text","("], + ["variable.language.dart","this"], + ["text","."], + ["identifier","x"], + ["text",", "], + ["variable.language.dart","this"], + ["text","."], + ["identifier","y"], + ["text",");"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["comment","// A named constructor with an initializer list."] +],[ + "start", + ["text"," "], + ["identifier","Point"], + ["text","."], + ["identifier","origin"], + ["text","() "], + ["keyword.control.ternary.dart",":"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator.assignment.dart","="], + ["text"," "], + ["constant.numeric","0"], + ["text",", "], + ["identifier","y"], + ["text"," "], + ["keyword.operator.assignment.dart","="], + ["text"," "], + ["constant.numeric","0"], + ["text",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["comment","// A method."] +],[ + "start", + ["text"," "], + ["storage.type.primitive.dart","num"], + ["text"," "], + ["identifier","distanceTo"], + ["text","("], + ["identifier","Point"], + ["text"," "], + ["identifier","other"], + ["text",") {"] +],[ + "start", + ["text"," "], + ["storage.type.primitive.dart","var"], + ["text"," "], + ["identifier","dx"], + ["text"," "], + ["keyword.operator.assignment.dart","="], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator.arithmetic.dart","-"], + ["text"," "], + ["identifier","other"], + ["text","."], + ["identifier","x"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.primitive.dart","var"], + ["text"," "], + ["identifier","dy"], + ["text"," "], + ["keyword.operator.assignment.dart","="], + ["text"," "], + ["identifier","y"], + ["text"," "], + ["keyword.operator.arithmetic.dart","-"], + ["text"," "], + ["identifier","other"], + ["text","."], + ["identifier","y"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.control.dart","return"], + ["text"," "], + ["identifier","sqrt"], + ["text","("], + ["identifier","dx"], + ["text"," "], + ["keyword.operator.arithmetic.dart","*"], + ["text"," "], + ["identifier","dx"], + ["text"," "], + ["keyword.operator.arithmetic.dart","+"], + ["text"," "], + ["identifier","dy"], + ["text"," "], + ["keyword.operator.arithmetic.dart","*"], + ["text"," "], + ["identifier","dy"], + ["text",");"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text","}"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["comment","// Check for null."] +],[ + "start", + ["storage.type.primitive.dart","var"], + ["text"," "], + ["identifier","unicorn"], + ["text",";"] +],[ + "start", + ["keyword.control.dart","assert"], + ["text","("], + ["identifier","unicorn"], + ["text"," "], + ["keyword.operator.comparison.dart","=="], + ["text"," "], + ["constant.language.dart","null"], + ["text",");"] +],[ + "start" +],[ + "start", + ["comment","// Check for NaN."] +],[ + "start", + ["storage.type.primitive.dart","var"], + ["text"," "], + ["identifier","iMeantToDoThis"], + ["text"," "], + ["keyword.operator.assignment.dart","="], + ["text"," "], + ["constant.numeric","0"], + ["keyword.operator.arithmetic.dart","/"], + ["constant.numeric","0"], + ["text",";"] +],[ + "start", + ["keyword.control.dart","assert"], + ["text","("], + ["identifier","iMeantToDoThis"], + ["text","."], + ["identifier","isNaN"], + ["text","());"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_diff.json b/public/lib/ace/mode/_test/tokens_diff.json new file mode 100644 index 0000000..6c36f5f --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_diff.json @@ -0,0 +1,262 @@ +[[ + "start", + ["variable","diff"], + ["variable"," --git"], + ["keyword"," a/lib/ace/edit_session.js"], + ["variable"," b/lib/ace/edit_session.js"] +],[ + "start", + ["variable","index 23fc3fc..ed3b273 100644"] +],[ + "start", + ["constant.numeric","---"], + ["meta.tag"," a/lib/ace/edit_session.js"] +],[ + "start", + ["constant.numeric","+++"], + ["meta.tag"," b/lib/ace/edit_session.js"] +],[ + "start", + ["constant","@@"], + ["constant.numeric"," -51,6 +51,7 "], + ["constant","@@"], + ["comment.doc.tag"," var TextMode = require(\"./mode/text\").Mode;"] +],[ + "start", + ["invisible"," var Range = require(\"./range\").Range;"] +],[ + "start", + ["invisible"," var Document = require(\"./document\").Document;"] +],[ + "start", + ["invisible"," var BackgroundTokenizer = require(\"./background_tokenizer\").BackgroundTokenizer;"] +],[ + "start", + ["support.constant","+"], + ["text","var SearchHighlight = require(\"./search_highlight\").SearchHighlight;"] +],[ + "start", + ["text"," "] +],[ + "start", + ["invisible"," /**"] +],[ + "start", + ["invisible"," * class EditSession"] +],[ + "start", + ["constant","@@"], + ["constant.numeric"," -307,6 +308,13 "], + ["constant","@@"], + ["comment.doc.tag"," var EditSession = function(text, mode) {"] +],[ + "start", + ["invisible"," return token;"] +],[ + "start", + ["invisible"," };"] +],[ + "start", + ["text"," "] +],[ + "start", + ["support.constant","+"], + ["text"," this.highlight = function(re) {"] +],[ + "start", + ["support.constant","+"], + ["text"," if (!this.$searchHighlight) {"] +],[ + "start", + ["support.constant","+"], + ["text"," var highlight = new SearchHighlight(null, \"ace_selected-word\", \"text\");"] +],[ + "start", + ["support.constant","+"], + ["text"," this.$searchHighlight = this.addDynamicMarker(highlight);"] +],[ + "start", + ["support.constant","+"], + ["text"," }"] +],[ + "start", + ["support.constant","+"], + ["text"," this.$searchHighlight.setRegexp(re);"] +],[ + "start", + ["support.constant","+"], + ["text"," }"] +],[ + "start", + ["invisible"," /**"] +],[ + "start", + ["invisible"," * EditSession.setUndoManager(undoManager)"] +],[ + "start", + ["invisible"," * - undoManager (UndoManager): The new undo manager"] +],[ + "start", + ["constant","@@"], + ["constant.numeric"," -556,7 +564,8 "], + ["constant","@@"], + ["comment.doc.tag"," var EditSession = function(text, mode) {"] +],[ + "start", + ["invisible"," type : type || \"line\","] +],[ + "start", + ["invisible"," renderer: typeof type == \"function\" ? type : null,"] +],[ + "start", + ["invisible"," clazz : clazz,"] +],[ + "start", + ["support.function","-"], + ["string"," inFront: !!inFront"] +],[ + "start", + ["support.constant","+"], + ["text"," inFront: !!inFront,"] +],[ + "start", + ["support.constant","+"], + ["text"," id: id"] +],[ + "start", + ["invisible"," }"] +],[ + "start", + ["text"," "] +],[ + "start", + ["invisible"," if (inFront) {"] +],[ + "start", + ["variable","diff"], + ["variable"," --git"], + ["keyword"," a/lib/ace/editor.js"], + ["variable"," b/lib/ace/editor.js"] +],[ + "start", + ["variable","index 834e603..b27ec73 100644"] +],[ + "start", + ["constant.numeric","---"], + ["meta.tag"," a/lib/ace/editor.js"] +],[ + "start", + ["constant.numeric","+++"], + ["meta.tag"," b/lib/ace/editor.js"] +],[ + "start", + ["constant","@@"], + ["constant.numeric"," -494,7 +494,7 "], + ["constant","@@"], + ["comment.doc.tag"," var Editor = function(renderer, session) {"] +],[ + "start", + ["invisible"," * Emitted when a selection has changed."] +],[ + "start", + ["invisible"," **/"] +],[ + "start", + ["invisible"," this.onSelectionChange = function(e) {"] +],[ + "start", + ["support.function","-"], + ["string"," var session = this.getSession();"] +],[ + "start", + ["support.constant","+"], + ["text"," var session = this.session;"] +],[ + "start", + ["text"," "] +],[ + "start", + ["invisible"," if (session.$selectionMarker) {"] +],[ + "start", + ["invisible"," session.removeMarker(session.$selectionMarker);"] +],[ + "start", + ["constant","@@"], + ["constant.numeric"," -509,12 +509,40 "], + ["constant","@@"], + ["comment.doc.tag"," var Editor = function(renderer, session) {"] +],[ + "start", + ["invisible"," this.$updateHighlightActiveLine();"] +],[ + "start", + ["invisible"," }"] +],[ + "start", + ["text"," "] +],[ + "start", + ["support.function","-"], + ["string"," var self = this;"] +],[ + "start", + ["support.function","-"], + ["string"," if (this.$highlightSelectedWord && !this.$wordHighlightTimer)"] +],[ + "start", + ["support.function","-"], + ["string"," this.$wordHighlightTimer = setTimeout(function() {"] +],[ + "start", + ["support.function","-"], + ["string"," self.session.$mode.highlightSelection(self);"] +],[ + "start", + ["support.function","-"], + ["string"," self.$wordHighlightTimer = null;"] +],[ + "start", + ["support.function","-"], + ["string"," }, 30, this);"] +],[ + "start", + ["support.constant","+"], + ["text"," var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp()"] +],[ + "start", + ["invisible"," };"] +],[ + "start", + ["variable","diff"], + ["variable"," --git"], + ["keyword"," a/lib/ace/search_highlight.js"], + ["variable"," b/lib/ace/search_highlight.js"] +],[ + "start", + ["invisible","new file mode 100644"] +],[ + "start", + ["variable","index 0000000..b2df779"] +],[ + "start", + ["constant.numeric","---"], + ["meta.tag"," /dev/null"] +],[ + "start", + ["constant.numeric","+++"], + ["meta.tag"," b/lib/ace/search_highlight.js"] +],[ + "start", + ["constant","@@"], + ["constant.numeric"," -0,0 +1,3 "], + ["constant","@@"] +],[ + "start", + ["support.constant","+"], + ["text","new"] +],[ + "start", + ["support.constant","+"], + ["text","empty file"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_dot.json b/public/lib/ace/mode/_test/tokens_dot.json new file mode 100644 index 0000000..fec8b96 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_dot.json @@ -0,0 +1,2254 @@ +[[ + "start", + ["comment","// Original source: http://www.graphviz.org/content/lion_share"] +],[ + "start", + ["comment","##\"A few people in the field of genetics are using dot to draw \"marriage node diagram\" pedigree drawings. Here is one I have done of a test pedigree from the FTREE pedigree drawing package (Lion Share was a racehorse).\" Contributed by David Duffy."] +],[ + "start" +],[ + "start", + ["comment","##Command to get the layout: \"dot -Tpng thisfile > thisfile.png\""] +],[ + "start" +],[ + "start", + ["keyword","digraph"], + ["text"," Ped_Lion_Share "], + ["paren.lparen","{"] +],[ + "start", + ["comment","# page = \"8.2677165,11.692913\" ;"] +],[ + "start", + ["variable","ratio"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"auto\""], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["text","mincross "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","2.0"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["variable","label"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"Pedigree Lion_Share\""], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["string","\"001\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"002\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"003\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"004\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"005\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"006\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"007\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"009\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"014\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"015\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"016\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"ZZ01\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"ZZ02\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"017\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"012\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"008\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"011\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"013\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"010\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"023\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"020\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"021\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"018\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"025\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"019\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"022\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"024\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"027\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","circle "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"026\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","white "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"028\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","box "], + ["punctuation.operator",","], + ["text"," "], + ["variable","regular"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","fillcolor"], + ["keyword.operator","="], + ["text","grey "], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0001\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"001\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0001\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"007\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0001\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0001\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"017\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0002\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"001\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0002\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"ZZ02\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0002\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0002\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"012\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0003\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"002\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0003\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"003\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0003\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0003\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"008\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0004\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"002\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0004\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"006\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0004\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0004\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"011\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0005\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"002\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0005\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"ZZ01\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0005\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0005\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"013\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0006\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"004\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0006\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"009\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0006\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0006\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"010\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0007\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"005\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0007\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"015\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0007\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0007\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"023\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0008\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"005\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0008\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"016\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0008\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0008\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"020\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0009\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"005\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0009\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"012\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0009\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0009\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"021\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0010\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"008\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0010\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"017\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0010\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0010\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"018\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0011\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"011\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0011\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"023\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0011\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0011\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"025\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0012\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"013\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0012\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"014\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0012\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0012\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"019\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0013\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"010\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0013\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"021\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0013\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0013\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"022\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0014\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"019\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0014\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"020\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0014\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0014\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"024\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0015\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"022\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0015\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"025\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0015\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0015\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"027\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0016\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"024\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0016\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"018\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0016\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0016\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"026\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0017\""], + ["text"," "], + ["paren.lparen","["], + ["variable","shape"], + ["keyword.operator","="], + ["text","diamond"], + ["punctuation.operator",","], + ["variable","style"], + ["keyword.operator","="], + ["text","filled"], + ["punctuation.operator",","], + ["variable","label"], + ["keyword.operator","="], + ["string","\"\""], + ["punctuation.operator",","], + ["variable","height"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["variable","width"], + ["keyword.operator","="], + ["text","."], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"026\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0017\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"027\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"marr0017\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["string","\"marr0017\""], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["string","\"028\""], + ["text"," "], + ["paren.lparen","["], + ["variable","dir"], + ["keyword.operator","="], + ["text","none"], + ["punctuation.operator",","], + ["text"," "], + ["variable","weight"], + ["keyword.operator","="], + ["constant.numeric","2"], + ["paren.rparen","]"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_drools.json b/public/lib/ace/mode/_test/tokens_drools.json new file mode 100644 index 0000000..8df6756 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_drools.json @@ -0,0 +1,935 @@ +[[ + "block.comment", + ["comment","/*"] +],[ + "block.comment", + ["comment.block"," * Copyright 2010 JBoss Inc"] +],[ + "block.comment", + ["comment.block"," *"] +],[ + "block.comment", + ["comment.block"," * Licensed under the Apache License, Version 2.0 (the \"License\");"] +],[ + "block.comment", + ["comment.block"," * you may not use this file except in compliance with the License."] +],[ + "block.comment", + ["comment.block"," * You may obtain a copy of the License at"] +],[ + "block.comment", + ["comment.block"," *"] +],[ + "block.comment", + ["comment.block"," * http://www.apache.org/licenses/LICENSE-2.0"] +],[ + "block.comment", + ["comment.block"," *"] +],[ + "block.comment", + ["comment.block"," * Unless required by applicable law or agreed to in writing, software"] +],[ + "block.comment", + ["comment.block"," * distributed under the License is distributed on an \"AS IS\" BASIS,"] +],[ + "block.comment", + ["comment.block"," * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied."] +],[ + "block.comment", + ["comment.block"," * See the License for the specific language governing permissions and"] +],[ + "block.comment", + ["comment.block"," * limitations under the License."] +],[ + "start", + ["comment.block"," */"] +],[ + "start" +],[ + "block.comment", + ["comment","/*"] +],[ + "block.comment", + ["comment.block"," Original source"] +],[ + "block.comment", + ["comment.block"," https://github.com/droolsjbpm/drools/blob/master/drools-examples/"] +],[ + "block.comment", + ["comment.block"," http://docs.jboss.org/drools/"] +],[ + "start", + ["comment.block","*/"] +],[ + "start", + ["keyword","package"], + ["text"," "], + ["entity.name.type","com.example.ace"] +],[ + "start" +],[ + "start", + ["keyword","import"], + ["text"," "], + ["entity.name.type","java.math.BigDecimal"] +],[ + "start", + ["keyword","import"], + ["text"," "], + ["keyword","function"], + ["text"," "], + ["entity.name.type","my.package.Foo.hello"] +],[ + "start" +],[ + "start", + ["keyword","declare"], + ["text"," "], + ["entity.name.type","FactType"] +],[ + "start", + ["text"," "], + ["entity.name.type","@author"], + ["paren.lparen","("], + ["text"," "], + ["identifier","Bob"], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable.other","id"], + ["text"," "], + ["text",":"], + ["text"," "], + ["support.class","String"] +],[ + "start", + ["text"," "], + ["variable.other","name"], + ["text"," "], + ["text",":"], + ["text"," "], + ["support.class","String"], + ["text"," "], + ["entity.name.type","@maxLength"], + ["paren.lparen","("], + ["constant.numeric","100"], + ["paren.rparen",")"], + ["text"," "], + ["entity.name.type","@notnull"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable.other","value"], + ["text"," "], + ["text",":"], + ["text"," "], + ["identifier","BigDecimal"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","declare"], + ["text"," "], + ["entity.name.type","FactType2"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["entity.name.type","AnotherType"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","declare"], + ["text"," "], + ["keyword","trait"], + ["text"," "], + ["entity.name.type","TraitType"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["entity.name.type","com.package.AnotherType"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start" +],[ + "start", + ["keyword","declare"], + ["text"," "], + ["keyword","trait"], + ["text"," "], + ["entity.name.type","GoldenCustomer"] +],[ + "start", + ["text"," "], + ["variable.other","balance"], + ["text"," "], + ["text",":"], + ["text"," "], + ["keyword","long"], + ["text"," "], + ["entity.name.type","@Alias"], + ["paren.lparen","("], + ["text"," "], + ["string","\"org.acme.foo.accountBalance\""], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","global"], + ["text"," "], + ["entity.name.type","org.slf4j.Logger"], + ["text"," "], + ["variable","logger"] +],[ + "start" +],[ + "doc-start", + ["comment.doc","/**"] +],[ + "doc-start", + ["comment.doc"," * "], + ["comment.doc.tag","@param"], + ["comment.doc"," name who we'll salute?"] +],[ + "start", + ["comment.doc"," */"] +],[ + "start", + ["keyword","function"], + ["text"," "], + ["support.class","String"], + ["text"," "], + ["identifier","hello"], + ["paren.lparen","("], + ["support.class","String"], + ["text"," "], + ["identifier","name"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","return"], + ["text"," "], + ["string","\"Hello \""], + ["keyword.operator","+"], + ["identifier","name"], + ["keyword.operator","+"], + ["string","\"!\""], + ["text",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","rule"], + ["text"," "], + ["entity.name","\"Trim all strings\""] +],[ + "start", + ["text"," "], + ["keyword","dialect"], + ["text"," "], + ["string","\"java\""] +],[ + "start", + ["text"," "], + ["keyword","no"], + ["keyword.operator","-"], + ["keyword","loop"] +],[ + "start", + ["keyword","when"], + ["text"," "], + ["comment","// fdsfds"] +],[ + "start", + ["text"," "], + ["variable.other","$s"], + ["text"," "], + ["text",":"], + ["text"," "], + ["support.class","String"], + ["paren.lparen","("], + ["identifier","a"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.language","null"], + ["text"," "], + ["keyword.operator","||"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["string","\"empty\""], + ["text",", "], + ["variable.other","$g"], + ["text"," "], + ["text",":"], + ["text"," "], + ["identifier","size"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","Cheese"], + ["paren.lparen","("], + ["text"," "], + ["identifier","name"], + ["text"," "], + ["keyword","matches"], + ["text"," "], + ["string","\"(Buffalo)?\\\\S*Mozarella\""], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","CheeseCounter"], + ["paren.lparen","("], + ["text"," "], + ["identifier","cheeses"], + ["text"," "], + ["keyword","contains"], + ["text"," "], + ["identifier","$var"], + ["text"," "], + ["paren.rparen",")"], + ["text"," "], + ["comment","// contains with a variable"] +],[ + "start", + ["text"," "], + ["identifier","CheeseCounter"], + ["paren.lparen","("], + ["text"," "], + ["identifier","cheese"], + ["text"," "], + ["keyword","memberof"], + ["text"," "], + ["identifier","$matureCheeses"], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","Cheese"], + ["paren.lparen","("], + ["text"," "], + ["identifier","name"], + ["text"," "], + ["keyword","soundslike"], + ["text"," "], + ["string","'foobar'"], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","Message"], + ["paren.lparen","("], + ["text"," "], + ["identifier","routingValue"], + ["text"," "], + ["keyword","str"], + ["paren.lparen","["], + ["identifier","startsWith"], + ["paren.rparen","]"], + ["text"," "], + ["string","\"R1\""], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","Cheese"], + ["paren.lparen","("], + ["text"," "], + ["identifier","name"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["paren.lparen","("], + ["text"," "], + ["string","\"stilton\""], + ["text",", "], + ["string","\"cheddar\""], + ["text",", "], + ["identifier","$cheese"], + ["text"," "], + ["paren.rparen",")"], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","Person"], + ["paren.lparen","("], + ["text"," "], + ["keyword","eval"], + ["paren.lparen","("], + ["text"," "], + ["identifier","age"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","girlAge"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","2"], + ["text"," "], + ["paren.rparen",")"], + ["text",", "], + ["identifier","sex"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'M'"], + ["text"," "], + ["paren.rparen",")"] +],[ + "java-start", + ["keyword","then"] +],[ + "java-doc-start", + ["text"," "], + ["comment.doc","/**"] +],[ + "java-doc-start", + ["comment.doc"," * "], + ["comment.doc.tag.storage.type","TODO"], + ["comment.doc"," There mus be better way"] +],[ + "java-start", + ["comment.doc"," */"] +],[ + "java-start", + ["text"," "], + ["support.function","retract"], + ["lparen","("], + ["identifier","$s"], + ["rparen",")"], + ["text",";"] +],[ + "java-start", + ["text"," "], + ["support.function","String"], + ["text"," "], + ["identifier","a"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"fd\""], + ["text",";"] +],[ + "java-start", + ["text"," "], + ["identifier","a"], + ["text","."], + ["identifier","toString"], + ["lparen","("], + ["rparen",")"], + ["text",";"] +],[ + "java-start" +],[ + "java-start", + ["text"," "], + ["support.function","insert"], + ["lparen","("], + ["identifier","$s"], + ["text","."], + ["identifier","trim"], + ["lparen","("], + ["rparen","))"], + ["text",";"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","query"], + ["text"," "], + ["entity.name","isContainedIn"], + ["paren.lparen","("], + ["text"," "], + ["support.class","String"], + ["text"," "], + ["identifier","x"], + ["text",", "], + ["support.class","String"], + ["text"," "], + ["identifier","y"], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","Location"], + ["paren.lparen","("], + ["text"," "], + ["identifier","x"], + ["text",", "], + ["identifier","y"], + ["text","; "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","or"] +],[ + "start", + ["text"," "], + ["paren.lparen","("], + ["text"," "], + ["identifier","Location"], + ["paren.lparen","("], + ["text"," "], + ["identifier","z"], + ["text",", "], + ["identifier","y"], + ["text","; "], + ["paren.rparen",")"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["identifier","isContainedIn"], + ["paren.lparen","("], + ["text"," "], + ["identifier","x"], + ["text",", "], + ["identifier","z"], + ["text","; "], + ["paren.rparen",")"], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","rule"], + ["text"," "], + ["entity.name","\"go\""], + ["text"," "], + ["keyword","salience"], + ["text"," "], + ["constant.numeric","10"] +],[ + "start", + ["keyword","when"] +],[ + "start", + ["text"," "], + ["variable.other","$s"], + ["text"," "], + ["text",":"], + ["text"," "], + ["support.class","String"], + ["paren.lparen","("], + ["text"," "], + ["paren.rparen",")"] +],[ + "java-start", + ["keyword","then"] +],[ + "java-start", + ["text"," "], + ["support.function","System"], + ["text","."], + ["identifier","out"], + ["text","."], + ["identifier","println"], + ["lparen","("], + ["text"," "], + ["identifier","$s"], + ["text"," "], + ["rparen",")"], + ["text",";"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","rule"], + ["text"," "], + ["entity.name","\"When all English buses are not red\""] +],[ + "start", + ["keyword","when"] +],[ + "start", + ["text"," "], + ["keyword","not"], + ["paren.lparen","("], + ["keyword","forall"], + ["paren.lparen","("], + ["text"," "], + ["variable.other","$bus"], + ["text"," "], + ["text",":"], + ["text"," "], + ["identifier","Bus"], + ["paren.lparen","("], + ["text"," "], + ["identifier","nationality"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["string","'english'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","Bus"], + ["paren.lparen","("], + ["text"," "], + ["keyword","this"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","$bus"], + ["text",", "], + ["identifier","color"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'red'"], + ["text"," "], + ["paren.rparen",")"], + ["text"," "], + ["paren.rparen","))"] +],[ + "java-start", + ["keyword","then"] +],[ + "java-start", + ["text"," "], + ["comment","// What if all english buses are not red?"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","rule"], + ["text"," "], + ["entity.name","\"go1\""] +],[ + "start", + ["keyword","when"] +],[ + "start", + ["text"," "], + ["support.class","String"], + ["paren.lparen","("], + ["text"," "], + ["keyword","this"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["string","\"go1\""], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","isContainedIn"], + ["paren.lparen","("], + ["string","\"Office\""], + ["text",", "], + ["string","\"House\""], + ["text","; "], + ["paren.rparen",")"] +],[ + "java-start", + ["keyword","then"] +],[ + "java-start", + ["text"," "], + ["support.function","System"], + ["text","."], + ["identifier","out"], + ["text","."], + ["identifier","println"], + ["lparen","("], + ["text"," "], + ["string","\"office is in the house\""], + ["text"," "], + ["rparen",")"], + ["text",";"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","rule"], + ["text"," "], + ["entity.name","\"go2\""] +],[ + "start", + ["keyword","when"] +],[ + "start", + ["text"," "], + ["support.class","String"], + ["paren.lparen","("], + ["text"," "], + ["keyword","this"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["string","\"go2\""], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","isContainedIn"], + ["paren.lparen","("], + ["string","\"Draw\""], + ["text",", "], + ["string","\"House\""], + ["text","; "], + ["paren.rparen",")"] +],[ + "java-start", + ["keyword","then"] +],[ + "java-start", + ["text"," "], + ["support.function","System"], + ["text","."], + ["identifier","out"], + ["text","."], + ["identifier","println"], + ["lparen","("], + ["text"," "], + ["string","\"Draw in the House\""], + ["text"," "], + ["rparen",")"], + ["text",";"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "doc-start", + ["comment.doc","/**"] +],[ + "doc-start", + ["comment.doc"," * Go Right"] +],[ + "start", + ["comment.doc"," */"] +],[ + "start", + ["keyword","rule"], + ["text"," "], + ["entity.name","GoRight"], + ["text"," "], + ["keyword","dialect"], + ["text"," "], + ["string","\"mvel\""], + ["text"," "], + ["keyword","salience"], + ["text"," "], + ["paren.lparen","("], + ["support.class","Math"], + ["text","."], + ["identifier","abs"], + ["paren.lparen","("], + ["text"," "], + ["identifier","$df"], + ["text","."], + ["identifier","colDiff"], + ["text"," "], + ["paren.rparen","))"], + ["text"," "], + ["keyword","when"] +],[ + "start", + ["text"," "], + ["variable.other","$df"], + ["text"," "], + ["text",":"], + ["text"," "], + ["identifier","DirectionDiff"], + ["paren.lparen","("], + ["identifier","colDiff"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable.other","$target"], + ["text"," "], + ["text",":"], + ["text"," "], + ["identifier","Cell"], + ["paren.lparen","("], + ["text"," "], + ["identifier","row"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","$df"], + ["text","."], + ["identifier","row"], + ["text",", "], + ["identifier","col"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["paren.lparen","("], + ["identifier","$df"], + ["text","."], + ["identifier","col"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["paren.rparen",")"], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","CellContents"], + ["paren.lparen","("], + ["text"," "], + ["identifier","cell"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","$target"], + ["text",", "], + ["identifier","cellType"], + ["text"," "], + ["keyword.operator","!="], + ["text"," "], + ["identifier","CellType"], + ["text","."], + ["identifier","WALL"], + ["text"," "], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","not"], + ["text"," "], + ["identifier","Direction"], + ["paren.lparen","("], + ["identifier","character"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","$df"], + ["text","."], + ["identifier","fromChar"], + ["text",", "], + ["identifier","horizontal"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","Direction"], + ["text","."], + ["identifier","RIGHT"], + ["text"," "], + ["paren.rparen",")"] +],[ + "java-start", + ["keyword","then"] +],[ + "java-start", + ["text"," "], + ["support.function","System"], + ["text","."], + ["identifier","out"], + ["text","."], + ["identifier","println"], + ["lparen","("], + ["text"," "], + ["string","\"monster right\""], + ["text"," "], + ["rparen",")"], + ["text",";"] +],[ + "java-start", + ["text"," "], + ["support.function","retract"], + ["lparen","("], + ["text"," "], + ["identifier","$df"], + ["text"," "], + ["rparen",")"], + ["text",";"] +],[ + "java-start", + ["text"," "], + ["support.function","insert"], + ["lparen","("], + ["text"," "], + ["keyword","new"], + ["text"," "], + ["identifier","Direction"], + ["lparen","("], + ["identifier","$df"], + ["text","."], + ["identifier","fromChar"], + ["text",", "], + ["identifier","Direction"], + ["text","."], + ["identifier","RIGHT"], + ["text",", "], + ["identifier","Direction"], + ["text","."], + ["identifier","NONE"], + ["text"," "], + ["rparen",")"], + ["text"," "], + ["rparen",")"], + ["text",";"] +],[ + "start", + ["keyword","end"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_eiffel.json b/public/lib/ace/mode/_test/tokens_eiffel.json new file mode 100644 index 0000000..344dbc6 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_eiffel.json @@ -0,0 +1,141 @@ +[[ + "start", + ["keyword","note"] +],[ + "start", + ["text","\t"], + ["identifier","description"], + ["keyword.operator",":"], + ["text"," "], + ["string.quoted.double","\"Represents a person.\""] +],[ + "start" +],[ + "start", + ["keyword","class"] +],[ + "start", + ["text","\t"], + ["entity.name.type","PERSON"] +],[ + "start" +],[ + "start", + ["keyword","create"] +],[ + "start", + ["text","\t"], + ["identifier","make"], + ["keyword.operator",","], + ["text"," "], + ["identifier","make_unknown"] +],[ + "start" +],[ + "start", + ["keyword","feature"], + ["text"," "], + ["paren.lparen","{"], + ["entity.name.type","NONE"], + ["paren.rparen","}"], + ["text"," "], + ["comment.line.double-dash","-- Creation"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["identifier","make"], + ["text"," "], + ["paren.lparen","("], + ["identifier","a_name"], + ["keyword.operator",":"], + ["text"," "], + ["keyword","like"], + ["text"," "], + ["identifier","name"], + ["paren.rparen",")"] +],[ + "start", + ["text","\t\t\t"], + ["comment.line.double-dash","-- Create a person with `a_name' as `name'."] +],[ + "start", + ["text","\t\t"], + ["keyword","do"] +],[ + "start", + ["text","\t\t\t"], + ["identifier","name"], + ["text"," "], + ["keyword.operator",":="], + ["text"," "], + ["identifier","a_name"] +],[ + "start", + ["text","\t\t"], + ["keyword","ensure"] +],[ + "start", + ["text","\t\t\t"], + ["identifier","name"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","a_name"] +],[ + "start", + ["text","\t\t"], + ["keyword","end"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["identifier","make_unknown"] +],[ + "start", + ["text","\t\t"], + ["keyword","do"], + ["text"," "], + ["keyword","ensure"] +],[ + "start", + ["text","\t\t\t"], + ["identifier","name"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.language","Void"] +],[ + "start", + ["text","\t\t"], + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","feature"], + ["text"," "], + ["comment.line.double-dash","-- Access"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["identifier","name"], + ["keyword.operator",":"], + ["text"," "], + ["keyword","detachable"], + ["text"," "], + ["entity.name.type","STRING"] +],[ + "start", + ["text","\t\t\t"], + ["comment.line.double-dash","-- Full name or Void if unknown."] +],[ + "start" +],[ + "start", + ["keyword","end"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_ejs.json b/public/lib/ace/mode/_test/tokens_ejs.json new file mode 100644 index 0000000..7e54af9 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_ejs.json @@ -0,0 +1,296 @@ +[[ + "start", + ["xml-pe.doctype.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Cloud9 Rocks!"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","table"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"table\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Name"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Size"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["markup.list.meta.tag","<%"], + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["keyword.operator","!"], + ["identifier","isRoot"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["markup.list.meta.tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"..\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml",".."], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["markup.list.meta.tag","<%"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["markup.list.meta.tag","%>"] +],[ + "start", + ["text.xml"," "], + ["markup.list.meta.tag","<%"], + ["text"," "], + ["identifier","entries"], + ["punctuation.operator","."], + ["identifier","forEach"], + ["paren.lparen","("], + ["storage.type","function"], + ["paren.lparen","("], + ["identifier","entry"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["markup.list.meta.tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","span"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"glyphicon "], + ["markup.list.meta.tag","<%="], + ["text"," "], + ["identifier","entry"], + ["punctuation.operator","."], + ["identifier","mime"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["string","'directory'"], + ["text"," "], + ["punctuation.operator","?"], + ["text"," "], + ["string","'folder'"], + ["punctuation.operator",":"], + ["text"," "], + ["string","'file'"], + ["markup.list.meta.tag","%>"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["markup.list.meta.tag","<%="], + ["text"," "], + ["identifier","entry"], + ["punctuation.operator","."], + ["identifier","name"], + ["text"," "], + ["markup.list.meta.tag","%>"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["markup.list.meta.tag","<%="], + ["text"," "], + ["identifier","entry"], + ["punctuation.operator","."], + ["identifier","name"], + ["text"," "], + ["markup.list.meta.tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["markup.list.meta.tag","<%="], + ["text"," "], + ["identifier","entry"], + ["punctuation.operator","."], + ["identifier","size"], + ["text"," "], + ["markup.list.meta.tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["markup.list.meta.tag","<%"], + ["text"," "], + ["paren.rparen","})"], + ["text"," "], + ["markup.list.meta.tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_elixir.json b/public/lib/ace/mode/_test/tokens_elixir.json new file mode 100644 index 0000000..cbbe1fe --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_elixir.json @@ -0,0 +1,196 @@ +[[ + "start", + ["keyword.control.module.elixir","defmodule"], + ["meta.module.elixir"," "], + ["entity.name.type.module.elixir","HelloModule"], + ["text"," "], + ["keyword.control.elixir","do"] +],[ + "comment.documentation.heredoc", + ["text"," "], + ["comment.documentation.heredoc","@moduledoc \"\"\""] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," This is supposed to be `markdown`."] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," __Yes__ this is [mark](http://down.format)"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," # Truly"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," ## marked"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," * with lists"] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," * more"] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," * and more"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," Even.with(code)"] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," blocks |> with |> samples"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," _Docs are first class citizens in Elixir_ (Jose Valim)"] +],[ + "start", + ["comment.documentation.heredoc"," \"\"\""] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.elixir","#"], + ["comment.line.number-sign.elixir"," A \"Hello world\" function"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","def"], + ["text"," some_fun "], + ["keyword.control.elixir","do"] +],[ + "start", + ["text"," "], + ["variable.other.constant.elixir","IO"], + ["punctuation.separator.method.elixir","."], + ["text","puts "], + ["punctuation.definition.string.begin.elixir","\""], + ["string.quoted.double.elixir","Juhu Kinners!"], + ["punctuation.definition.string.end.elixir","\""] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","end"] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.elixir","#"], + ["comment.line.number-sign.elixir"," A private function"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","defp"], + ["text"," priv "], + ["keyword.control.elixir","do"] +],[ + "punctuation.definition.string.begin.elixir7", + ["text"," is_regex "], + ["punctuation.definition.string.begin.elixir","~r\"\"\""] +],[ + "punctuation.definition.string.begin.elixir7", + ["string.quoted.double.heredoc.elixir"," This is a regex"] +],[ + "punctuation.definition.string.begin.elixir7", + ["string.quoted.double.heredoc.elixir"," spanning several"] +],[ + "punctuation.definition.string.begin.elixir7", + ["string.quoted.double.heredoc.elixir"," lines."] +],[ + "start", + ["punctuation.definition.string.end.elixir"," \"\"\""] +],[ + "start", + ["text"," x "], + ["keyword.operator.assignment.elixir","="], + ["text"," elem"], + ["punctuation.section.function.elixir","("], + ["punctuation.section.scope.elixir","{"], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","a"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","b"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","c"], + ["text"," "], + ["punctuation.section.scope.elixir","}"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["constant.numeric.elixir","0"], + ["punctuation.section.function.elixir",")"], + ["text"," "], + ["punctuation.definition.comment.elixir","#"], + ["comment.line.number-sign.elixir","=> :a"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","end"] +],[ + "start", + ["keyword.control.elixir","end"] +],[ + "start" +],[ + "start", + ["text","test_fun "], + ["keyword.operator.assignment.elixir","="], + ["text"," "], + ["keyword.control.elixir","fn"], + ["punctuation.section.function.elixir","("], + ["text","x"], + ["punctuation.section.function.elixir",")"], + ["text"," "], + ["keyword.operator.arithmetic.elixir","-"], + ["keyword.operator.comparison.elixir",">"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","cond"], + ["text"," "], + ["keyword.control.elixir","do"] +],[ + "start", + ["text"," x "], + ["keyword.operator.comparison.elixir",">"], + ["text"," "], + ["constant.numeric.elixir","10"], + ["text"," "], + ["keyword.operator.arithmetic.elixir","-"], + ["keyword.operator.comparison.elixir",">"] +],[ + "start", + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","greater_than_ten"] +],[ + "start", + ["text"," "], + ["constant.language.elixir","true"], + ["text"," "], + ["keyword.operator.arithmetic.elixir","-"], + ["keyword.operator.comparison.elixir",">"] +],[ + "start", + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","maybe_ten"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","end"] +],[ + "start", + ["keyword.control.elixir","end"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_elm.json b/public/lib/ace/mode/_test/tokens_elm.json new file mode 100644 index 0000000..b39de92 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_elm.json @@ -0,0 +1,198 @@ +[[ + "start", + ["comment.start","{-"], + ["comment"," Ace "], + ["comment.start","{-"], + ["comment"," 4 "], + ["comment.end","-}"], + ["comment"," Elm "], + ["comment.end","-}"] +],[ + "start", + ["constant.language","main"], + ["text"," "], + ["keyword","="], + ["text"," "], + ["identifier","lift"], + ["text"," "], + ["identifier","clock"], + ["text"," "], + ["paren.lparen","("], + ["identifier","every"], + ["text"," "], + ["identifier","second"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["constant.language","clock"], + ["text"," "], + ["identifier","t"], + ["text"," "], + ["keyword","="], + ["text"," "], + ["identifier","collage"], + ["text"," "], + ["constant.numeric","400"], + ["text"," "], + ["constant.numeric","400"], + ["text"," "], + ["paren.lparen","["], + ["text"," "], + ["identifier","filled"], + ["text"," "], + ["identifier","lightGrey"], + ["text"," "], + ["paren.lparen","("], + ["identifier","ngon"], + ["text"," "], + ["constant.numeric","12"], + ["text"," "], + ["constant.numeric","110"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["operator.punctuation",","], + ["text"," "], + ["identifier","outlined"], + ["text"," "], + ["paren.lparen","("], + ["identifier","solid"], + ["text"," "], + ["identifier","grey"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","("], + ["identifier","ngon"], + ["text"," "], + ["constant.numeric","12"], + ["text"," "], + ["constant.numeric","110"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["operator.punctuation",","], + ["text"," "], + ["identifier","hand"], + ["text"," "], + ["identifier","orange"], + ["text"," "], + ["constant.numeric","100"], + ["text"," "], + ["identifier","t"] +],[ + "start", + ["text"," "], + ["operator.punctuation",","], + ["text"," "], + ["identifier","hand"], + ["text"," "], + ["identifier","charcoal"], + ["text"," "], + ["constant.numeric","100"], + ["text"," "], + ["paren.lparen","("], + ["identifier","t"], + ["keyword.operator","/"], + ["constant.numeric","60"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["operator.punctuation",","], + ["text"," "], + ["identifier","hand"], + ["text"," "], + ["identifier","charcoal"], + ["text"," "], + ["constant.numeric","60"], + ["text"," "], + ["paren.lparen","("], + ["identifier","t"], + ["keyword.operator","/"], + ["constant.numeric","720"], + ["paren.rparen",")"], + ["text"," "], + ["paren.rparen","]"] +],[ + "start" +],[ + "start", + ["constant.language","hand"], + ["text"," "], + ["identifier","clr"], + ["text"," "], + ["identifier","len"], + ["text"," "], + ["identifier","time"], + ["text"," "], + ["keyword","="] +],[ + "start", + ["text"," "], + ["keyword","let"], + ["text"," "], + ["identifier","angle"], + ["text"," "], + ["keyword","="], + ["text"," "], + ["identifier","degrees"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","90"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["constant.numeric","6"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["identifier","inSeconds"], + ["text"," "], + ["identifier","time"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","in"], + ["text"," "], + ["identifier","traced"], + ["text"," "], + ["paren.lparen","("], + ["identifier","solid"], + ["text"," "], + ["identifier","clr"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","<|"], + ["text"," "], + ["identifier","segment"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","0"], + ["operator.punctuation",","], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","("], + ["identifier","len"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["identifier","cos"], + ["text"," "], + ["identifier","angle"], + ["operator.punctuation",","], + ["text"," "], + ["identifier","len"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["identifier","sin"], + ["text"," "], + ["identifier","angle"], + ["paren.rparen",")"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_erlang.json b/public/lib/ace/mode/_test/tokens_erlang.json new file mode 100644 index 0000000..8a82897 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_erlang.json @@ -0,0 +1,166 @@ +[[ + "start", + ["text"," "], + ["punctuation.definition.comment.erlang","%% A process whose only job is to keep a counter."] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.erlang","%% First version"] +],[ + "start", + ["meta.directive.module.erlang"," "], + ["punctuation.section.directive.begin.erlang","-"], + ["keyword.control.directive.module.erlang","module"], + ["punctuation.definition.parameters.begin.erlang","("], + ["entity.name.type.class.module.definition.erlang","counter"], + ["punctuation.definition.parameters.end.erlang",")"], + ["punctuation.section.directive.end.erlang","."] +],[ + "start", + ["meta.directive.export.erlang"," "], + ["punctuation.section.directive.begin.erlang","-"], + ["keyword.control.directive.export.erlang","export"], + ["punctuation.definition.parameters.begin.erlang","("], + ["punctuation.definition.list.begin.erlang","["], + ["entity.name.function.erlang","start"], + ["punctuation.separator.function-arity.erlang","/"], + ["constant.numeric.integer.decimal.erlang","0"], + ["punctuation.separator.list.erlang",","], + ["meta.structure.list.function.erlang"," "], + ["entity.name.function.erlang","codeswitch"], + ["punctuation.separator.function-arity.erlang","/"], + ["constant.numeric.integer.decimal.erlang","1"], + ["punctuation.definition.list.end.erlang","]"], + ["punctuation.definition.parameters.end.erlang",")"], + ["punctuation.section.directive.end.erlang","."] +],[ + "start", + ["text"," "] +],[ + "start", + ["meta.function.erlang"," "], + ["entity.name.function.definition.erlang","start"], + ["punctuation.section.expression.begin.erlang","("], + ["punctuation.section.expression.end.erlang",")"], + ["text"," "], + ["keyword.operator.symbolic.erlang","->"], + ["text"," "], + ["entity.name.function.erlang","loop"], + ["punctuation.definition.parameters.begin.erlang","("], + ["constant.numeric.integer.decimal.erlang","0"], + ["punctuation.definition.parameters.end.erlang",")"], + ["punctuation.terminator.function.erlang","."] +],[ + "start", + ["text"," "] +],[ + ["text6","meta.function.erlang"], + ["meta.function.erlang"," "], + ["entity.name.function.definition.erlang","loop"], + ["punctuation.section.expression.begin.erlang","("], + ["variable.other.erlang","Sum"], + ["punctuation.section.expression.end.erlang",")"], + ["text"," "], + ["keyword.operator.symbolic.erlang","->"] +],[ + ["keyword.control.receive.erlang","text6","text6","meta.function.erlang"], + ["text"," "], + ["keyword.control.receive.erlang","receive"] +],[ + ["keyword.control.receive.erlang","text6","text6","meta.function.erlang"], + ["meta.expression.receive.erlang"," "], + ["punctuation.definition.tuple.begin.erlang","{"], + ["constant.other.symbol.unquoted.erlang","increment"], + ["punctuation.separator.tuple.erlang",","], + ["meta.structure.tuple.erlang"," "], + ["variable.other.erlang","Count"], + ["punctuation.definition.tuple.end.erlang","}"], + ["meta.expression.receive.erlang"," "], + ["punctuation.separator.clause-head-body.erlang","->"] +],[ + ["keyword.control.receive.erlang","text6","text6","meta.function.erlang"], + ["meta.expression.receive.erlang"," "], + ["entity.name.function.erlang","loop"], + ["punctuation.definition.parameters.begin.erlang","("], + ["variable.other.erlang","Sum"], + ["keyword.operator.symbolic.erlang","+"], + ["variable.other.erlang","Count"], + ["punctuation.definition.parameters.end.erlang",")"], + ["punctuation.separator.clauses.erlang",";"] +],[ + ["keyword.control.receive.erlang","text6","text6","meta.function.erlang"], + ["meta.expression.receive.erlang"," "], + ["punctuation.definition.tuple.begin.erlang","{"], + ["constant.other.symbol.unquoted.erlang","counter"], + ["punctuation.separator.tuple.erlang",","], + ["meta.structure.tuple.erlang"," "], + ["variable.other.erlang","Pid"], + ["punctuation.definition.tuple.end.erlang","}"], + ["meta.expression.receive.erlang"," "], + ["punctuation.separator.clause-head-body.erlang","->"] +],[ + ["keyword.control.receive.erlang","text6","text6","meta.function.erlang"], + ["meta.expression.receive.erlang"," "], + ["variable.other.erlang","Pid"], + ["meta.expression.receive.erlang"," "], + ["keyword.operator.symbolic.erlang","!"], + ["meta.expression.receive.erlang"," "], + ["punctuation.definition.tuple.begin.erlang","{"], + ["constant.other.symbol.unquoted.erlang","counter"], + ["punctuation.separator.tuple.erlang",","], + ["meta.structure.tuple.erlang"," "], + ["variable.other.erlang","Sum"], + ["punctuation.definition.tuple.end.erlang","}"], + ["punctuation.separator.expressions.erlang",","] +],[ + ["keyword.control.receive.erlang","text6","text6","meta.function.erlang"], + ["meta.expression.receive.erlang"," "], + ["entity.name.function.erlang","loop"], + ["punctuation.definition.parameters.begin.erlang","("], + ["variable.other.erlang","Sum"], + ["punctuation.definition.parameters.end.erlang",")"], + ["punctuation.separator.clauses.erlang",";"] +],[ + ["keyword.control.receive.erlang","text6","text6","meta.function.erlang"], + ["meta.expression.receive.erlang"," "], + ["constant.other.symbol.unquoted.erlang","code_switch"], + ["meta.expression.receive.erlang"," "], + ["punctuation.separator.clause-head-body.erlang","->"] +],[ + ["keyword.control.receive.erlang","text6","text6","meta.function.erlang"], + ["meta.expression.receive.erlang"," "], + ["keyword.operator.macro.erlang","?"], + ["entity.name.function.macro.erlang","MODULE"], + ["meta.expression.receive.erlang",":"], + ["entity.name.function.erlang","codeswitch"], + ["punctuation.definition.parameters.begin.erlang","("], + ["variable.other.erlang","Sum"], + ["punctuation.definition.parameters.end.erlang",")"] +],[ + ["keyword.control.receive.erlang","text6","text6","meta.function.erlang"], + ["meta.expression.receive.erlang"," "], + ["punctuation.definition.comment.erlang","% Force the use of 'codeswitch/1' from the latest MODULE version"] +],[ + "start", + ["meta.expression.receive.erlang"," "], + ["keyword.control.end.erlang","end"], + ["punctuation.terminator.function.erlang","."] +],[ + "start", + ["text"," "] +],[ + "start", + ["meta.function.erlang"," "], + ["entity.name.function.definition.erlang","codeswitch"], + ["punctuation.section.expression.begin.erlang","("], + ["variable.other.erlang","Sum"], + ["punctuation.section.expression.end.erlang",")"], + ["text"," "], + ["keyword.operator.symbolic.erlang","->"], + ["text"," "], + ["entity.name.function.erlang","loop"], + ["punctuation.definition.parameters.begin.erlang","("], + ["variable.other.erlang","Sum"], + ["punctuation.definition.parameters.end.erlang",")"], + ["punctuation.terminator.function.erlang","."] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_forth.json b/public/lib/ace/mode/_test/tokens_forth.json new file mode 100644 index 0000000..8c8a007 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_forth.json @@ -0,0 +1,219 @@ +[[ + "start", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","HELLO"], + ["meta.block.forth"," "], + ["comment.line.parentheses.forth"," ( -- )"], + ["meta.block.forth"," CR "], + ["string.quoted.double.forth",".\" Hello, world!\""], + ["meta.block.forth"," "], + ["keyword.other.compile-only.forth",";"], + ["text"," "] +],[ + "start" +],[ + "start", + ["text","HELLO "] +],[ + "start", + ["text","Hello, world!"] +],[ + "start" +],[ + "start", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","[CHAR]"], + ["meta.block.forth"," "], + ["keyword.other.non-immediate.forth"," CHAR"], + ["meta.block.forth"," "], + ["keyword.other.compile-only.forth"," POSTPONE"], + ["meta.block.forth"," LITERAL "], + ["keyword.other.compile-only.forth",";"], + ["keyword.other.immediate.forth"," IMMEDIATE"] +],[ + "start" +],[ + "start", + ["constant.numeric.forth","0"], + ["storage.type.forth"," value"], + ["text"," ii "], + ["constant.numeric.forth"," 0"], + ["storage.type.forth"," value"], + ["text"," jj"] +],[ + "start", + ["constant.numeric.forth","0"], + ["storage.type.forth"," value"], + ["text"," KeyAddr "], + ["constant.numeric.forth"," 0"], + ["storage.type.forth"," value"], + ["text"," KeyLen"] +],[ + "start", + ["storage.type.forth","create"], + ["text"," SArray "], + ["constant.numeric.forth"," 256"], + ["text"," allot "], + ["comment.line.backslash.forth"," \\ state array of 256 bytes"] +],[ + "start", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","KeyArray"], + ["meta.block.forth"," KeyLen mod KeyAddr "], + ["keyword.other.compile-only.forth",";"] +],[ + "start" +],[ + "start", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","get_byte"], + ["meta.block.forth"," + c@ "], + ["keyword.other.compile-only.forth",";"] +],[ + "start", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","set_byte"], + ["meta.block.forth"," + c! "], + ["keyword.other.compile-only.forth",";"] +],[ + "start", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","as_byte"], + ["meta.block.forth"," "], + ["constant.numeric.forth"," 255"], + ["meta.block.forth"," and "], + ["keyword.other.compile-only.forth",";"] +],[ + "start", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","reset_ij"], + ["meta.block.forth"," "], + ["constant.numeric.forth"," 0"], + ["keyword.other.immediate.forth"," TO"], + ["meta.block.forth"," ii "], + ["constant.numeric.forth"," 0"], + ["keyword.other.immediate.forth"," TO"], + ["meta.block.forth"," jj "], + ["keyword.other.compile-only.forth",";"] +],[ + "start", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","i_update"], + ["meta.block.forth"," "], + ["constant.numeric.forth"," 1"], + ["meta.block.forth"," + as_byte"], + ["keyword.other.immediate.forth"," TO"], + ["meta.block.forth"," ii "], + ["keyword.other.compile-only.forth",";"] +],[ + "start", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","j_update"], + ["meta.block.forth"," ii SArray get_byte + as_byte"], + ["keyword.other.immediate.forth"," TO"], + ["meta.block.forth"," jj "], + ["keyword.other.compile-only.forth",";"] +],[ + "keyword.other.compile-only.forth", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","swap_s_ij"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," jj SArray get_byte"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," ii SArray get_byte jj SArray set_byte"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," ii SArray set_byte"] +],[ + "start", + ["keyword.other.compile-only.forth",";"] +],[ + "start" +],[ + "keyword.other.compile-only.forth", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","rc4_init"], + ["comment.line.parentheses.forth"," ( KeyAddr KeyLen -- )"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," "], + ["constant.numeric.forth"," 256"], + ["meta.block.forth"," min"], + ["keyword.other.immediate.forth"," TO"], + ["meta.block.forth"," KeyLen "], + ["keyword.other.immediate.forth"," TO"], + ["meta.block.forth"," KeyAddr"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," "], + ["constant.numeric.forth"," 256 0"], + ["keyword.control.compile-only.forth"," DO"], + ["meta.block.forth"," "], + ["variable.language.forth","i"], + ["meta.block.forth"," "], + ["variable.language.forth","i"], + ["meta.block.forth"," SArray set_byte "], + ["keyword.control.compile-only.forth"," LOOP"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," reset_ij"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," "], + ["keyword.control.compile-only.forth"," BEGIN"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," ii KeyArray get_byte jj + j_update"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," swap_s_ij"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," ii"], + ["constant.numeric.forth"," 255"], + ["meta.block.forth"," <"], + ["keyword.control.compile-only.forth"," WHILE"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," ii i_update"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," "], + ["keyword.control.compile-only.forth"," REPEAT"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," reset_ij"] +],[ + "start", + ["keyword.other.compile-only.forth",";"] +],[ + "keyword.other.compile-only.forth", + ["keyword.other.compile-only.forth",":"], + ["meta.block.forth"," "], + ["entity.name.function.forth","rc4_byte"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," ii i_update jj j_update"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," swap_s_ij"] +],[ + "keyword.other.compile-only.forth", + ["meta.block.forth"," ii SArray get_byte jj SArray get_byte + as_byte SArray get_byte xor"] +],[ + "start", + ["keyword.other.compile-only.forth",";"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_fortran.json b/public/lib/ace/mode/_test/tokens_fortran.json new file mode 100644 index 0000000..ae28769 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_fortran.json @@ -0,0 +1,219 @@ +[[ + "start", + ["keyword","#include"], + ["text"," "], + ["string","\"globalDefines.h\""] +],[ + "start" +],[ + "start", + ["comment","!========================================================="] +],[ + "start", + ["keyword","program"], + ["text"," "], + ["identifier","main"] +],[ + "start", + ["comment","!========================================================= "] +],[ + "start", + ["text"," "], + ["keyword","use"], + ["text"," "], + ["identifier","params_module"], + ["text",", "], + ["keyword","only"], + ["text"," : "], + ["identifier","nx"], + ["text",", "], + ["identifier","ny"], + ["text",", "], + ["identifier","nz"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","implicit"], + ["text"," "], + ["keyword","none"] +],[ + "start" +],[ + "start", + ["text"," "], + ["storage.type","integer"], + ["text",", "], + ["storage.modifier","parameter"], + ["text"," :: "], + ["identifier","g"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","9.81"] +],[ + "start", + ["text"," "], + ["storage.type","real"], + ["text",", "], + ["storage.modifier","allocatable"], + ["text",", "], + ["storage.modifier","dimension"], + ["paren.lparen","("], + ["text",":,:,:"], + ["paren.rparen",")"], + ["text"," :: "], + ["identifier","array"] +],[ + "start", + ["text"," "], + ["storage.type","integer"], + ["text"," :: "], + ["identifier","a"], + ["text",", "], + ["identifier","b"], + ["text",", "], + ["identifier","c"] +],[ + "start", + ["text"," "], + ["storage.type","real"], + ["keyword.operator","*"], + ["constant.numeric","8"], + ["text"," :: "], + ["identifier","x"], + ["text",", "], + ["identifier","y"], + ["text",", "], + ["identifier","z"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["identifier","b"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","5"] +],[ + "start", + ["text"," "], + ["identifier","c"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","7"] +],[ + "start" +],[ + "start", + ["keyword","#ifdef"], + ["text"," "], + ["identifier","ARRAY_COMP"] +],[ + "start", + ["text"," "], + ["support.function","allocate"], + ["paren.lparen","("], + ["identifier","array"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["text",","], + ["constant.numeric","10"], + ["text",","], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text",", "], + ["keyword","status"], + ["keyword.operator","="], + ["identifier","a"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","write"], + ["paren.lparen","("], + ["identifier","c"], + ["text",","], + ["string","'(i5.5)'"], + ["paren.rparen",")"], + ["text"," "], + ["identifier","b"] +],[ + "start", + ["keyword","#endif"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["paren.lparen","("], + ["identifier","x"], + ["text","."], + ["keyword.operator","lt"], + ["constant.numeric",".5.0"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["identifier","array"], + ["paren.lparen","("], + ["text",":,:,:"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","g"] +],[ + "start", + ["text"," "], + ["keyword","else"] +],[ + "start", + ["text"," "], + ["identifier","array"], + ["paren.lparen","("], + ["text",":,:,:"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["identifier","y"] +],[ + "start", + ["text"," "], + ["keyword","endif"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","return"] +],[ + "start", + ["comment","!======================================================== "] +],[ + "start", + ["keyword","end"], + ["text"," "], + ["keyword","program"], + ["text"," "], + ["identifier","main"] +],[ + "start", + ["comment","!========================================================"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_ftl.json b/public/lib/ace/mode/_test/tokens_ftl.json new file mode 100644 index 0000000..75e7a6f --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_ftl.json @@ -0,0 +1,341 @@ +[[ + "start", + ["keyword.function","<#ftl"], + ["text"," "], + ["entity.other.attribute-name","encoding"], + ["keyword.operator","="], + ["string","\"utf-8\""], + ["text"," "], + ["keyword","/>"] +],[ + "start", + ["keyword.function","<#setting"], + ["text"," "], + ["entity.other.attribute-name","locale"], + ["keyword.operator","="], + ["string","\"en_US\""], + ["text"," "], + ["keyword","/>"] +],[ + "start", + ["keyword.function","<#import"], + ["text"," "], + ["string","\"library\""], + ["text"," "], + ["keyword.operator","as"], + ["text"," "], + ["variable","lib"], + ["text"," "], + ["keyword","/>"] +],[ + "ftl-dcomment", + ["comment","<#--"] +],[ + "ftl-dcomment", + ["comment"," FreeMarker comment"] +],[ + "ftl-dcomment", + ["comment"," ${abc} <#assign a=12 />"] +],[ + "start", + ["comment","-->"] +],[ + "start" +],[ + "start", + ["xml-pe.doctype.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","lang"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"en-us\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","meta"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","charset"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"utf-8\""], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["string.interpolated","${"], + ["variable","title"], + ["keyword.operator","!"], + ["string","\"FreeMarker\""], + ["string.interpolated","}"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h1"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Hello "], + ["string.interpolated","${"], + ["variable","name"], + ["keyword.operator","!"], + ["string","\"\""], + ["string.interpolated","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Today is: "], + ["string.interpolated","${"], + ["language.variable",".now"], + ["support.function","?date"], + ["string.interpolated","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["keyword.function","<#assign"], + ["text"," "], + ["variable","x"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","13"], + ["keyword",">"] +],[ + "start", + ["text.xml"," "], + ["keyword.function","<#if"], + ["text"," "], + ["variable","x"], + ["text"," "], + ["constant.character.entity",">"], + ["text"," "], + ["constant.numeric","12"], + ["text"," "], + ["keyword.operator","&&"], + ["text"," "], + ["variable","x"], + ["text"," "], + ["keyword.operator","lt"], + ["text"," "], + ["constant.numeric","14"], + ["keyword",">"], + ["text.xml","x equals 13: "], + ["string.interpolated","${"], + ["variable","x"], + ["string.interpolated","}"], + ["keyword.function",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","ul"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["keyword.function","<#list"], + ["text"," "], + ["variable","items"], + ["text"," "], + ["keyword.operator","as"], + ["text"," "], + ["variable","item"], + ["keyword",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","li"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["string.interpolated","${"], + ["variable","item_index"], + ["string.interpolated","}"], + ["text.xml",": "], + ["string.interpolated","${"], + ["variable","item.name"], + ["keyword.operator","!"], + ["support.function","?split"], + ["paren.lparen","("], + ["string","\""], + ["constant.character.escape","\\n"], + ["string","\""], + ["paren.rparen",")"], + ["paren.lparen","["], + ["constant.numeric","0"], + ["paren.rparen","]"], + ["string.interpolated","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["keyword.function",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," User directive: "], + ["keyword.other","<@lib.function"], + ["text"," "], + ["variable","attr1"], + ["keyword.operator","="], + ["constant.language","true"], + ["text"," "], + ["variable","attr2"], + ["keyword.operator","="], + ["string","'value'"], + ["text"," "], + ["variable","attr3"], + ["keyword.operator","="], + ["constant.numeric","-42.12"], + ["keyword",">"], + ["text.xml","Test"], + ["keyword.other",""] +],[ + "start", + ["text.xml"," "], + ["keyword.other","<@anotherOne"], + ["text"," "], + ["keyword","/>"] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["keyword.function","<#if"], + ["text"," "], + ["variable","variable"], + ["support.function.deprecated","?exists"], + ["keyword",">"] +],[ + "start", + ["text.xml"," Deprecated"] +],[ + "start", + ["text.xml"," "], + ["keyword.function","<#elseif"], + ["text"," "], + ["variable","variable"], + ["support.function","??"], + ["keyword",">"] +],[ + "start", + ["text.xml"," Better"] +],[ + "start", + ["text.xml"," "], + ["keyword.function","<#else"], + ["keyword",">"] +],[ + "start", + ["text.xml"," Default"] +],[ + "start", + ["text.xml"," "], + ["keyword.function",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.image.tag-name.xml","img"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","src"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"images/"], + ["string.interpolated","${"], + ["variable","user.id"], + ["string.interpolated","}"], + ["string.attribute-value.xml",".png\""], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_gcode.json b/public/lib/ace/mode/_test/tokens_gcode.json new file mode 100644 index 0000000..d622747 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_gcode.json @@ -0,0 +1,296 @@ +[[ + "start", + ["identifier","O"], + ["constant.numeric","003"], + ["text"," "], + ["comment","(DIAMOND SQUARE)"] +],[ + "start", + ["comment","N2"], + ["text"," "], + ["string","G54"], + ["text"," "], + ["string","G90"], + ["text"," "], + ["string","G49"], + ["text"," "], + ["string","G80"] +],[ + "start", + ["comment","N3"], + ["text"," "], + ["string","M6"], + ["text"," "], + ["identifier","T"], + ["constant.numeric","1"], + ["text"," "], + ["comment","(1.ENDMILL)"] +],[ + "start", + ["comment","N4"], + ["text"," "], + ["string","M3"], + ["text"," "], + ["identifier","S"], + ["constant.numeric","1800"] +],[ + "start", + ["comment","N5"], + ["text"," "], + ["string","G0"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","-.6"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","2.050"] +],[ + "start", + ["comment","N6"], + ["text"," "], + ["string","G43"], + ["text"," "], + ["identifier","H"], + ["constant.numeric","1"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric",".1"] +],[ + "start", + ["comment","N7"], + ["text"," "], + ["string","G1"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric","-.3"], + ["text"," "], + ["identifier","F"], + ["constant.numeric","50."] +],[ + "start", + ["comment","N8"], + ["text"," "], + ["string","G41"], + ["text"," "], + ["identifier","D"], + ["constant.numeric","1"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","1.45"] +],[ + "start", + ["comment","N9"], + ["text"," "], + ["string","G1"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","0"], + ["text"," "], + ["identifier","F"], + ["constant.numeric","20."] +],[ + "start", + ["comment","N10"], + ["text"," "], + ["string","G2"], + ["text"," "], + ["identifier","J"], + ["constant.numeric","-1.45"] +],[ + "start", + ["comment","(CUTTER COMP CANCEL)"] +],[ + "start", + ["comment","N11"], + ["text"," "], + ["string","G1"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric","-.2"], + ["text"," "], + ["identifier","F"], + ["constant.numeric","50."] +],[ + "start", + ["comment","N12"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","-.990"] +],[ + "start", + ["comment","N13"], + ["text"," "], + ["string","G40"] +],[ + "start", + ["comment","N14"], + ["text"," "], + ["string","G0"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","-.6"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","1.590"] +],[ + "start", + ["comment","N15"], + ["text"," "], + ["string","G0"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric",".1"] +],[ + "start", + ["comment","N16"], + ["text"," "], + ["string","M5"], + ["text"," "], + ["string","G49"], + ["text"," "], + ["string","G28"], + ["text"," "], + ["string","G91"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric","0"] +],[ + "start", + ["comment","N17"], + ["text"," "], + ["identifier","CALL"], + ["text"," "], + ["identifier","O"], + ["constant.numeric","9456"] +],[ + "start", + ["comment","N18"], + ["text"," #"], + ["constant.numeric","500"], + ["text","="], + ["constant.numeric","0.004"] +],[ + "start", + ["comment","N19"], + ["text"," #"], + ["constant.numeric","503"], + ["text","="], + ["paren.lparen","["], + ["text","#"], + ["constant.numeric","500"], + ["text","+#"], + ["constant.numeric","501"], + ["paren.rparen","]"] +],[ + "start", + ["comment","N20"], + ["text"," "], + ["identifier","VC"], + ["constant.numeric","45"], + ["text","="], + ["constant.numeric","0.0006"] +],[ + "start", + ["identifier","VS"], + ["constant.numeric","4"], + ["text","="], + ["constant.numeric","0.0007"] +],[ + "start", + ["comment","N21"], + ["text"," "], + ["string","G90"], + ["text"," "], + ["string","G10"], + ["text"," "], + ["identifier","L"], + ["constant.numeric","20"], + ["text"," "], + ["identifier","P"], + ["constant.numeric","3"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","5."], + ["identifier","Y"], + ["constant.numeric","4."], + ["text"," "], + ["identifier","Z"], + ["constant.numeric","6.567"] +],[ + "start", + ["comment","N22"], + ["text"," "], + ["string","G0"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","5000"] +],[ + "start", + ["comment","N23"], + ["text"," "], + ["identifier","IF"], + ["text"," "], + ["paren.lparen","["], + ["text","#"], + ["constant.numeric","1"], + ["text"," "], + ["identifier","LT"], + ["text"," "], + ["constant.numeric","0.370"], + ["paren.rparen","]"], + ["text"," "], + ["identifier","GOTO"], + ["text"," "], + ["constant.numeric","49"] +],[ + "start", + ["comment","N24"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","-0.678"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","+.990"] +],[ + "start", + ["comment","N25"], + ["text"," "], + ["string","G84.3"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","-0.1"] +],[ + "start", + ["comment","N26"], + ["text"," #"], + ["constant.numeric","4"], + ["text","=#"], + ["constant.numeric","5"], + ["text","*"], + ["identifier","COS"], + ["paren.lparen","["], + ["constant.numeric","45"], + ["paren.rparen","]"] +],[ + "start", + ["comment","N27"], + ["text"," #"], + ["constant.numeric","4"], + ["text","=#"], + ["constant.numeric","5"], + ["text","*"], + ["identifier","SIN"], + ["paren.lparen","["], + ["constant.numeric","45"], + ["paren.rparen","]"] +],[ + "start", + ["comment","N28"], + ["text"," "], + ["identifier","VZOFZ"], + ["text","="], + ["constant.numeric","652.9658"] +],[ + "start", + ["text","%"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_gherkin.json b/public/lib/ace/mode/_test/tokens_gherkin.json new file mode 100644 index 0000000..fa556b5 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_gherkin.json @@ -0,0 +1,142 @@ +[[ + "start", + ["variable.parameter","@these"], + ["text"," "], + ["variable.parameter","@_are_"], + ["text"," "], + ["variable.parameter","@tags"] +],[ + "start", + ["keyword","Feature:"], + ["text"," Serve coffee"] +],[ + "start", + ["text"," Coffee should not be served until paid for"] +],[ + "start", + ["text"," Coffee should not be served until the button has been pressed"] +],[ + "start", + ["text"," If there is no coffee left then money should be refunded"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","Scenario Outline:"], + ["text"," Eating"] +],[ + "start", + ["text"," "], + ["keyword","Given"], + ["text"," there are "], + ["comment",""], + ["text"," cucumbers"] +],[ + "start", + ["text"," "], + ["keyword","When"], + ["text"," I eat "], + ["comment",""], + ["text"," cucumbers"] +],[ + "start", + ["text"," "], + ["keyword","Then"], + ["text"," I should have "], + ["comment",""], + ["text"," cucumbers"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","Examples:"] +],[ + "start", + ["text"," "], + ["comment","|"], + ["string"," start "], + ["comment","|"], + ["string"," eat "], + ["comment","|"], + ["string"," left "], + ["comment","|"] +],[ + "start", + ["text"," "], + ["comment","|"], + ["string"," 12 "], + ["comment","|"], + ["string"," 5 "], + ["comment","|"], + ["string"," 7 "], + ["comment","|"] +],[ + "start", + ["text"," "], + ["comment","|"], + ["string"," @20 "], + ["comment","|"], + ["string"," 5 "], + ["comment","|"], + ["string"," 15 "], + ["comment","|"], + ["string"," "] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","Scenario:"], + ["text"," Buy last coffee"] +],[ + "start", + ["text"," "], + ["keyword","Given"], + ["text"," there are "], + ["constant.numeric","1"], + ["text"," coffees left in the machine"] +],[ + "start", + ["text"," "], + ["keyword","And"], + ["text"," I have deposited "], + ["constant.numeric","1"], + ["text","$ "] +],[ + "start", + ["text"," "], + ["keyword","When"], + ["text"," I press the coffee button"] +],[ + "start", + ["text"," "], + ["keyword","Then"], + ["text"," I should be served a "], + ["string","\"coffee\""] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["comment","# this a comment"] +],[ + "start", + ["text"," "] +],[ + "qqstring3", + ["text"," "], + ["string","\"\"\""] +],[ + "qqstring3", + ["string"," this is a "] +],[ + "qqstring3", + ["string"," pystring"] +],[ + "start", + ["string"," \"\"\""] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_gitignore.json b/public/lib/ace/mode/_test/tokens_gitignore.json new file mode 100644 index 0000000..8689a72 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_gitignore.json @@ -0,0 +1,33 @@ +[[ + "start", + ["comment","# A sample .gitignore file."] +],[ + "start" +],[ + "start", + ["text",".buildlog"] +],[ + "start", + ["text",".DS_Store"] +],[ + "start", + ["text",".svn"] +],[ + "start" +],[ + "start", + ["comment","# Negated patterns:"] +],[ + "start", + ["keyword","!foo.bar"] +],[ + "start" +],[ + "start", + ["comment","# Also ignore user settings..."] +],[ + "start", + ["text","/.settings"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_glsl.json b/public/lib/ace/mode/_test/tokens_glsl.json new file mode 100644 index 0000000..ce8a4d1 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_glsl.json @@ -0,0 +1,127 @@ +[[ + "start", + ["keyword","uniform"], + ["text"," "], + ["keyword","float"], + ["text"," "], + ["identifier","amplitude"], + ["punctuation.operator",";"] +],[ + "start", + ["keyword","attribute"], + ["text"," "], + ["keyword","float"], + ["text"," "], + ["identifier","displacement"], + ["punctuation.operator",";"] +],[ + "start", + ["keyword","varying"], + ["text"," "], + ["keyword","vec3"], + ["text"," "], + ["identifier","vNormal"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","void"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start" +],[ + "start", + ["text"," "], + ["identifier","vNormal"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","normal"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["comment","// multiply our displacement by the"] +],[ + "start", + ["text"," "], + ["comment","// amplitude. The amp will get animated"] +],[ + "start", + ["text"," "], + ["comment","// so we'll have animated displacement"] +],[ + "start", + ["text"," "], + ["keyword","vec3"], + ["text"," "], + ["identifier","newPosition"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","position"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "] +],[ + "start", + ["text"," "], + ["identifier","normal"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","vec3"], + ["paren.lparen","("], + ["identifier","displacement"], + ["text"," "], + ["keyword.operator","*"] +],[ + "start", + ["text"," "], + ["identifier","amplitude"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["constant.language","gl_Position"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","projectionMatrix"], + ["text"," "], + ["keyword.operator","*"] +],[ + "start", + ["text"," "], + ["identifier","modelViewMatrix"], + ["text"," "], + ["keyword.operator","*"] +],[ + "start", + ["text"," "], + ["keyword","vec4"], + ["paren.lparen","("], + ["identifier","newPosition"], + ["punctuation.operator",","], + ["constant.numeric","1.0"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_gobstones.json b/public/lib/ace/mode/_test/tokens_gobstones.json new file mode 100644 index 0000000..4ecb2c4 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_gobstones.json @@ -0,0 +1,113 @@ +[[ + "start", + ["keyword","program"], + ["text"," "], + ["lparen","{"] +],[ + "comment", + ["text"," "], + ["comment","/*"] +],[ + "comment", + ["comment"," * A gobstons multiline comment"] +],[ + "comment", + ["comment"," * Taken from:"] +],[ + "comment", + ["comment"," * http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/\""] +],[ + "start", + ["comment"," */"] +],[ + "start", + ["text"," "], + ["identifier","sumar"], + ["lparen","("], + ["constant.numeric","2"], + ["keyword.operator",","], + ["text"," "], + ["constant.numeric","3"], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","function"], + ["text"," "], + ["identifier","sumar"], + ["lparen","("], + ["identifier","a"], + ["keyword.operator",","], + ["text"," "], + ["identifier","b"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","r"], + ["text"," "], + ["keyword.operator",":="], + ["text"," "], + ["identifier","a"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["identifier","b"] +],[ + "start", + ["text"," "], + ["rparen","}"] +],[ + "start", + ["text"," "], + ["comment","// unreachable code"] +],[ + "start", + ["text"," "], + ["comment","-- unreachable code"] +],[ + "start", + ["text"," "], + ["comment","# unreachable code"] +],[ + "start", + ["text"," "], + ["keyword","procedure"], + ["text"," "], + ["identifier","hacerAlgo"], + ["lparen","("], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["support.function","Mover"], + ["lparen","("], + ["support.type","Este"], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["support.function","Poner"], + ["lparen","("], + ["support.type","Rojo"], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["support.function","Sacar"], + ["lparen","("], + ["support.type","Azul"], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_golang.json b/public/lib/ace/mode/_test/tokens_golang.json new file mode 100644 index 0000000..7fbd38e --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_golang.json @@ -0,0 +1,256 @@ +[[ + "start", + ["comment","// Concurrent computation of pi."] +],[ + "start", + ["comment","// See http://goo.gl/ZuTZM."] +],[ + "start", + ["comment","//"] +],[ + "start", + ["comment","// This demonstrates Go's ability to handle"] +],[ + "start", + ["comment","// large numbers of concurrent processes."] +],[ + "start", + ["comment","// It is an unreasonable way to calculate pi."] +],[ + "start", + ["keyword","package"], + ["text"," "], + ["identifier","main"] +],[ + "start" +],[ + "start", + ["keyword","import"], + ["text"," "], + ["paren.lparen","("] +],[ + "start", + ["text"," "], + ["string","\"fmt\""] +],[ + "start", + ["text"," "], + ["string","\"math\""] +],[ + "start", + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["keyword","func"], + ["text"," "], + ["entity.name.function","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","fmt"], + ["punctuation.operator","."], + ["support.function","Println"], + ["paren.lparen","("], + ["support.function","pi"], + ["paren.lparen","("], + ["constant.numeric","5000"], + ["paren.rparen","))"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment","// pi launches n goroutines to compute an"] +],[ + "start", + ["comment","// approximation of pi."] +],[ + "start", + ["keyword","func"], + ["text"," "], + ["entity.name.function","pi"], + ["paren.lparen","("], + ["identifier","n"], + ["text"," "], + ["support.type","int"], + ["paren.rparen",")"], + ["text"," "], + ["support.type","float64"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","ch"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword.operator","="], + ["text"," "], + ["support.function","make"], + ["paren.lparen","("], + ["keyword","chan"], + ["text"," "], + ["support.type","float64"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["identifier","k"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","k"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","n"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","k"], + ["keyword.operator","++"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","go"], + ["text"," "], + ["support.function","term"], + ["paren.lparen","("], + ["identifier","ch"], + ["punctuation.operator",","], + ["text"," "], + ["support.type","float64"], + ["paren.lparen","("], + ["identifier","k"], + ["paren.rparen","))"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["identifier","f"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0.0"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["identifier","k"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","k"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","n"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","k"], + ["keyword.operator","++"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","f"], + ["text"," "], + ["keyword.operator","+="], + ["text"," "], + ["keyword.operator","<-"], + ["identifier","ch"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","return"], + ["text"," "], + ["identifier","f"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","func"], + ["text"," "], + ["entity.name.function","term"], + ["paren.lparen","("], + ["identifier","ch"], + ["text"," "], + ["keyword","chan"], + ["text"," "], + ["support.type","float64"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","k"], + ["text"," "], + ["support.type","float64"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","ch"], + ["text"," "], + ["keyword.operator","<-"], + ["text"," "], + ["constant.numeric","4"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["identifier","math"], + ["punctuation.operator","."], + ["support.function","Pow"], + ["paren.lparen","("], + ["constant.numeric","-1"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","k"], + ["paren.rparen",")"], + ["text"," / "], + ["paren.lparen","("], + ["constant.numeric","2"], + ["keyword.operator","*"], + ["identifier","k"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_groovy.json b/public/lib/ace/mode/_test/tokens_groovy.json new file mode 100644 index 0000000..c7dae6b --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_groovy.json @@ -0,0 +1,410 @@ +[[ + "start", + ["comment","//http://groovy.codehaus.org/Martin+Fowler%27s+closure+examples+in+Groovy"] +],[ + "start" +],[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","Employee"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","def"], + ["text"," "], + ["identifier","name"], + ["text",", "], + ["identifier","salary"] +],[ + "start", + ["text"," "], + ["keyword","boolean"], + ["text"," "], + ["identifier","manager"] +],[ + "start", + ["text"," "], + ["support.function","String"], + ["text"," "], + ["identifier","toString"], + ["lparen","("], + ["rparen",")"], + ["text"," "], + ["lparen","{"], + ["text"," "], + ["keyword","return"], + ["text"," "], + ["identifier","name"], + ["text"," "], + ["rparen","}"] +],[ + "start", + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","def"], + ["text"," "], + ["identifier","emps"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["lparen","["], + ["keyword","new"], + ["text"," "], + ["identifier","Employee"], + ["lparen","("], + ["identifier","name"], + ["text",":"], + ["string","'Guillaume'"], + ["text",", "], + ["identifier","manager"], + ["text",":"], + ["constant.language.boolean","true"], + ["text",", "], + ["identifier","salary"], + ["text",":"], + ["constant.numeric","200"], + ["rparen",")"], + ["text",","] +],[ + "start", + ["text"," "], + ["keyword","new"], + ["text"," "], + ["identifier","Employee"], + ["lparen","("], + ["identifier","name"], + ["text",":"], + ["string","'Graeme'"], + ["text",", "], + ["identifier","manager"], + ["text",":"], + ["constant.language.boolean","true"], + ["text",", "], + ["identifier","salary"], + ["text",":"], + ["constant.numeric","200"], + ["rparen",")"], + ["text",","] +],[ + "start", + ["text"," "], + ["keyword","new"], + ["text"," "], + ["identifier","Employee"], + ["lparen","("], + ["identifier","name"], + ["text",":"], + ["string","'Dierk'"], + ["text",", "], + ["identifier","manager"], + ["text",":"], + ["constant.language.boolean","false"], + ["text",", "], + ["identifier","salary"], + ["text",":"], + ["constant.numeric","151"], + ["rparen",")"], + ["text",","] +],[ + "start", + ["text"," "], + ["keyword","new"], + ["text"," "], + ["identifier","Employee"], + ["lparen","("], + ["identifier","name"], + ["text",":"], + ["string","'Bernd'"], + ["text",", "], + ["identifier","manager"], + ["text",":"], + ["constant.language.boolean","false"], + ["text",", "], + ["identifier","salary"], + ["text",":"], + ["constant.numeric","50"], + ["rparen",")]"] +],[ + "start" +],[ + "start", + ["keyword","def"], + ["text"," "], + ["identifier","managers"], + ["lparen","("], + ["identifier","emps"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","emps"], + ["text","."], + ["identifier","findAll"], + ["text"," "], + ["lparen","{"], + ["text"," "], + ["identifier","e"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["identifier","e"], + ["text","."], + ["identifier","isManager"], + ["lparen","("], + ["rparen",")"], + ["text"," "], + ["rparen","}"] +],[ + "start", + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","assert"], + ["text"," "], + ["identifier","emps"], + ["lparen","["], + ["constant.numeric","0"], + ["text",".."], + ["constant.numeric","1"], + ["rparen","]"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","managers"], + ["lparen","("], + ["identifier","emps"], + ["rparen",")"], + ["text"," "], + ["comment","// [Guillaume, Graeme]"] +],[ + "start" +],[ + "start", + ["keyword","def"], + ["text"," "], + ["identifier","highPaid"], + ["lparen","("], + ["identifier","emps"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","threshold"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","150"] +],[ + "start", + ["text"," "], + ["identifier","emps"], + ["text","."], + ["identifier","findAll"], + ["text"," "], + ["lparen","{"], + ["text"," "], + ["identifier","e"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["identifier","e"], + ["text","."], + ["identifier","salary"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["identifier","threshold"], + ["text"," "], + ["rparen","}"] +],[ + "start", + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","assert"], + ["text"," "], + ["identifier","emps"], + ["lparen","["], + ["constant.numeric","0"], + ["text",".."], + ["constant.numeric","2"], + ["rparen","]"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","highPaid"], + ["lparen","("], + ["identifier","emps"], + ["rparen",")"], + ["text"," "], + ["comment","// [Guillaume, Graeme, Dierk]"] +],[ + "start" +],[ + "start", + ["keyword","def"], + ["text"," "], + ["identifier","paidMore"], + ["lparen","("], + ["identifier","amount"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["lparen","{"], + ["text"," "], + ["identifier","e"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["identifier","e"], + ["text","."], + ["identifier","salary"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["identifier","amount"], + ["rparen","}"] +],[ + "start", + ["rparen","}"] +],[ + "start", + ["keyword","def"], + ["text"," "], + ["identifier","highPaid"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","paidMore"], + ["lparen","("], + ["constant.numeric","150"], + ["rparen",")"] +],[ + "start" +],[ + "start", + ["keyword","assert"], + ["text"," "], + ["identifier","highPaid"], + ["lparen","("], + ["identifier","emps"], + ["lparen","["], + ["constant.numeric","0"], + ["rparen","])"], + ["text"," "], + ["comment","// true"] +],[ + "start", + ["keyword","assert"], + ["text"," "], + ["identifier","emps"], + ["lparen","["], + ["constant.numeric","0"], + ["text",".."], + ["constant.numeric","2"], + ["rparen","]"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","emps"], + ["text","."], + ["identifier","findAll"], + ["lparen","("], + ["identifier","highPaid"], + ["rparen",")"] +],[ + "start" +],[ + "start", + ["keyword","def"], + ["text"," "], + ["identifier","filename"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'test.txt'"] +],[ + "start", + ["keyword","new"], + ["text"," "], + ["identifier","File"], + ["lparen","("], + ["identifier","filename"], + ["rparen",")"], + ["text","."], + ["identifier","withReader"], + ["lparen","{"], + ["text"," "], + ["identifier","reader"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["identifier","doSomethingWith"], + ["lparen","("], + ["identifier","reader"], + ["rparen",")"], + ["text"," "], + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","def"], + ["text"," "], + ["identifier","readersText"] +],[ + "start", + ["keyword","def"], + ["text"," "], + ["identifier","doSomethingWith"], + ["lparen","("], + ["identifier","reader"], + ["rparen",")"], + ["text"," "], + ["lparen","{"], + ["text"," "], + ["identifier","readersText"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","reader"], + ["text","."], + ["identifier","text"], + ["text"," "], + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","assert"], + ["text"," "], + ["keyword","new"], + ["text"," "], + ["identifier","File"], + ["lparen","("], + ["identifier","filename"], + ["rparen",")"], + ["text","."], + ["identifier","text"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["identifier","readersText"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_haml.json b/public/lib/ace/mode/_test/tokens_haml.json new file mode 100644 index 0000000..5a22e90 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_haml.json @@ -0,0 +1,259 @@ +[[ + "start", + ["keyword.other.doctype","!!!5"] +],[ + "start" +],[ + "embedded_ruby", + ["text","# "] +],[ + "embedded_ruby", + ["text","# "] +],[ + "embedded_ruby", + ["text","# "] +],[ + "embedded_ruby", + ["text","# <"], + ["identifier","html"], + ["text"," "], + ["keyword","class"], + ["text","="], + ["string","\"no-js\""], + ["text"," "], + ["identifier","lang"], + ["text","="], + ["string","\"en\""], + ["text","> "] +],[ + "start" +],[ + "start" +],[ + "start", + ["comment.line","/adasdasdad"] +],[ + "embedded_ruby", + ["meta.tag.haml","%div"], + ["text","{"], + ["constant.other.symbol.ruby",":id"], + ["text"," => "], + ["string","\"#{@item.type}_#{@item.number}\""], + ["text",", :"], + ["keyword","class"], + ["text"," => "], + ["string","'#{@item.type} #{@item.urgency}'"], + ["text",", :"], + ["identifier","phoney"], + ["text"," => "], + ["string","`asdasdasd`"], + ["text","}"] +],[ + "start", + ["comment.line","/ file: app/views/movies/index.html.haml"] +],[ + "start", + ["text","\\d"] +],[ + "embedded_ruby", + ["meta.tag.haml","%ads:"], + ["text","{"], + ["constant.other.symbol.ruby",":bleh"], + ["text"," => "], + ["constant.numeric","33"], + ["text","}"] +],[ + "embedded_ruby", + ["meta.tag.haml","%p"], + ["text","=="], + ["identifier","ddd"], + ["text","=="] +],[ + "start", + ["text"," Date"], + ["comment.line","/Time:"] +],[ + "embedded_ruby", + ["text"," - "], + ["identifier","now"], + ["text"," = "], + ["support.class","DateTime"], + ["text","."], + ["identifier","now"], + ["text"," "] +],[ + "embedded_ruby", + ["text"," "], + ["meta.tag.haml","%strong"], + ["text","= "], + ["identifier","now"] +],[ + "embedded_ruby", + ["text"," = "], + ["keyword","if"], + ["text"," "], + ["identifier","now"], + ["text"," "], + ["support.class","DateTime"], + ["text","."], + ["identifier","parse"], + ["text","("], + ["string","\"December 31, 2006\""], + ["text",")"] +],[ + "embedded_ruby", + ["text"," = "], + ["string","\"Happy new \""], + ["text"," + "], + ["string","\"year!\""] +],[ + "start", + ["meta.tag.haml","%sfd"], + ["keyword.attribute-name.class.haml",".dfdfg"] +],[ + "element_class", + ["keyword.attribute-name.id.haml","#content"] +],[ + "start", + ["text"," "], + ["keyword.attribute-name.class.haml",".title"] +],[ + "embedded_ruby", + ["text"," "], + ["meta.tag.haml","%h1"], + ["text","= "], + ["variable.instance","@title"] +],[ + "embedded_ruby", + ["text"," = "], + ["support.function","link_to"], + ["text"," "], + ["string","'Home'"], + ["text",", "], + ["identifier","home_url"] +],[ + "start" +],[ + "element_class", + ["text"," "], + ["keyword.attribute-name.id.haml","#contents"] +],[ + "element_class", + ["meta.tag.haml","%div"], + ["keyword.attribute-name.id.haml","#content"] +],[ + "start", + ["text"," "], + ["meta.tag.haml","%div"], + ["keyword.attribute-name.class.haml",".articles"] +],[ + "start", + ["text"," "], + ["meta.tag.haml","%div"], + ["keyword.attribute-name.class.haml",".article.title"], + ["text"," Blah"] +],[ + "start", + ["text"," "], + ["meta.tag.haml","%div"], + ["keyword.attribute-name.class.haml",".article.date"], + ["text"," "], + ["constant.numeric","2006-11-05"] +],[ + "start", + ["text"," "], + ["meta.tag.haml","%div"], + ["keyword.attribute-name.class.haml",".article.entry"] +],[ + "start", + ["text"," Neil Patrick Harris "] +],[ + "start" +],[ + "start", + ["meta.tag.haml","%div"], + ["text","[@user, "], + ["constant.other.symbol.ruby",":greeting"], + ["text","]"] +],[ + "start", + ["text"," "], + ["meta.tag.haml","%bar"], + ["text","["], + ["constant.numeric","290"], + ["text","]"], + ["comment.line","/"] +],[ + "embedded_ruby", + ["text"," =="], + ["support.class","Hello"], + ["text","!=="] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_handlebars.json b/public/lib/ace/mode/_test/tokens_handlebars.json new file mode 100644 index 0000000..1ec7913 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_handlebars.json @@ -0,0 +1,81 @@ +[[ + "start", + ["comment.start","{{!--"], + ["comment"," Ace + :-}} "], + ["comment.end","--}}"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"comments\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["storage.type.start","{{#"], + ["variable.parameter","each"], + ["text"," "], + ["variable.parameter","comments"], + ["storage.type.end","}}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"/posts/"], + ["storage.type.start","{{"], + ["text","../"], + ["variable.parameter","permalink"], + ["storage.type.end","}}"], + ["string.attribute-value.xml","#"], + ["storage.type.start","{{"], + ["variable.parameter","id"], + ["storage.type.end","}}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["storage.type.start","{{"], + ["variable.parameter","title"], + ["storage.type.end","}}"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.function","{{{"], + ["variable.parameter","body"], + ["support.function","}}}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["storage.type.start","{{/"], + ["variable.parameter","each"], + ["storage.type.end","}}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_haskell.json b/public/lib/ace/mode/_test/tokens_haskell.json new file mode 100644 index 0000000..8f9a2b3 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_haskell.json @@ -0,0 +1,156 @@ +[[ + "start", + ["punctuation.definition.comment.haskell","-- Type annotation (optional)"] +],[ + "start", + ["entity.name.function.haskell","fib"], + ["meta.function.type-declaration.haskell"," "], + ["keyword.other.double-colon.haskell","::"], + ["meta.function.type-declaration.haskell"," "], + ["support.type.prelude.haskell","Int"], + ["meta.function.type-declaration.haskell"," "], + ["keyword.other.arrow.haskell","->"], + ["meta.function.type-declaration.haskell"," "], + ["support.type.prelude.haskell","Integer"] +],[ + "start", + ["text"," "] +],[ + "start", + ["punctuation.definition.comment.haskell","-- With self-referencing data"] +],[ + "start", + ["text","fib n "], + ["keyword.operator.haskell","="], + ["text"," fibs "], + ["keyword.operator.haskell","!!"], + ["text"," n"] +],[ + "start", + ["text"," "], + ["keyword.other.haskell","where"], + ["text"," fibs "], + ["keyword.operator.haskell","="], + ["text"," "], + ["constant.numeric.haskell","0"], + ["text"," "], + ["keyword.operator.haskell",":"], + ["text"," "], + ["support.function.prelude.haskell","scanl"], + ["text"," "], + ["entity.name.function.infix.haskell","(+)"], + ["text"," "], + ["constant.numeric.haskell","1"], + ["text"," fibs"] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.haskell","-- 0,1,1,2,3,5,..."] +],[ + "start", + ["text"," "] +],[ + "start", + ["punctuation.definition.comment.haskell","-- Same, coded directly"] +],[ + "start", + ["text","fib n "], + ["keyword.operator.haskell","="], + ["text"," fibs "], + ["keyword.operator.haskell","!!"], + ["text"," n"] +],[ + "start", + ["text"," "], + ["keyword.other.haskell","where"], + ["text"," fibs "], + ["keyword.operator.haskell","="], + ["text"," "], + ["constant.numeric.haskell","0"], + ["text"," "], + ["keyword.operator.haskell",":"], + ["text"," "], + ["constant.numeric.haskell","1"], + ["text"," "], + ["keyword.operator.haskell",":"], + ["text"," next fibs"] +],[ + "start", + ["text"," next (a "], + ["keyword.operator.haskell",":"], + ["text"," t@(b"], + ["keyword.operator.haskell",":"], + ["text","_)) "], + ["keyword.operator.haskell","="], + ["text"," (a"], + ["keyword.operator.haskell","+"], + ["text","b) "], + ["keyword.operator.haskell",":"], + ["text"," next t"] +],[ + "start", + ["text"," "] +],[ + "start", + ["punctuation.definition.comment.haskell","-- Similar idea, using zipWith"] +],[ + "start", + ["text","fib n "], + ["keyword.operator.haskell","="], + ["text"," fibs "], + ["keyword.operator.haskell","!!"], + ["text"," n"] +],[ + "start", + ["text"," "], + ["keyword.other.haskell","where"], + ["text"," fibs "], + ["keyword.operator.haskell","="], + ["text"," "], + ["constant.numeric.haskell","0"], + ["text"," "], + ["keyword.operator.haskell",":"], + ["text"," "], + ["constant.numeric.haskell","1"], + ["text"," "], + ["keyword.operator.haskell",":"], + ["text"," "], + ["support.function.prelude.haskell","zipWith"], + ["text"," "], + ["entity.name.function.infix.haskell","(+)"], + ["text"," fibs ("], + ["support.function.prelude.haskell","tail"], + ["text"," fibs)"] +],[ + "start", + ["text"," "] +],[ + "start", + ["punctuation.definition.comment.haskell","-- Using a generator function"] +],[ + "start", + ["text","fib n "], + ["keyword.operator.haskell","="], + ["text"," fibs ("], + ["constant.numeric.haskell","0"], + ["punctuation.separator.comma.haskell",","], + ["constant.numeric.haskell","1"], + ["text",") "], + ["keyword.operator.haskell","!!"], + ["text"," n"] +],[ + "start", + ["text"," "], + ["keyword.other.haskell","where"], + ["text"," fibs (a"], + ["punctuation.separator.comma.haskell",","], + ["text","b) "], + ["keyword.operator.haskell","="], + ["text"," a "], + ["keyword.operator.haskell",":"], + ["text"," fibs (b"], + ["punctuation.separator.comma.haskell",","], + ["text","a"], + ["keyword.operator.haskell","+"], + ["text","b)"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_haxe.json b/public/lib/ace/mode/_test/tokens_haxe.json new file mode 100644 index 0000000..f0f79a4 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_haxe.json @@ -0,0 +1,143 @@ +[[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","Haxe"], + ["text"," "] +],[ + "start", + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","public"], + ["text"," "], + ["keyword","static"], + ["text"," "], + ["keyword","function"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["comment","// Say Hello!"] +],[ + "start", + ["text"," "], + ["keyword","var"], + ["text"," "], + ["identifier","greeting"], + ["punctuation.operator",":"], + ["keyword","String"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"Hello World\""], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","trace"], + ["paren.lparen","("], + ["identifier","greeting"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","var"], + ["text"," "], + ["identifier","targets"], + ["punctuation.operator",":"], + ["keyword","Array"], + ["keyword.operator","<"], + ["keyword","String"], + ["keyword.operator",">"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","["], + ["string","\"Flash\""], + ["punctuation.operator",","], + ["string","\"Javascript\""], + ["punctuation.operator",","], + ["string","\"PHP\""], + ["punctuation.operator",","], + ["string","\"Neko\""], + ["punctuation.operator",","], + ["string","\"C++\""], + ["punctuation.operator",","], + ["string","\"iOS\""], + ["punctuation.operator",","], + ["string","\"Android\""], + ["punctuation.operator",","], + ["string","\"webOS\""], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","trace"], + ["paren.lparen","("], + ["string","\"Haxe is a great language that can target:\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["paren.lparen","("], + ["identifier","target"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["identifier","targets"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","trace"], + ["text"," "], + ["paren.lparen","("], + ["string","\" - \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["identifier","target"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","trace"], + ["paren.lparen","("], + ["string","\"And many more!\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_html.json b/public/lib/ace/mode/_test/tokens_html.json new file mode 100644 index 0000000..c5f75ef --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_html.json @@ -0,0 +1,63 @@ +[[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","scripts"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","a"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","'a'"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["storage.type","var"], + ["text"," "], + ["string","\""], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml","'123'"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + ["string.attribute-value.xml0","tag_stuff"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"abc"] +],[ + "start", + ["string.attribute-value.xml"," def\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + ["string.attribute-value.xml","tag_stuff"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","'abc"] +],[ + "start", + ["string.attribute-value.xml","def\\'"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_html_elixir.json b/public/lib/ace/mode/_test/tokens_html_elixir.json new file mode 100644 index 0000000..f7e6b9b --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_html_elixir.json @@ -0,0 +1,294 @@ +[[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h1"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Listing Books"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","table"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Title"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Summary"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start", + ["support.elixir_tag","<%="], + ["text"," "], + ["keyword.control.elixir","for"], + ["text"," book "], + ["keyword.operator.comparison.elixir","<"], + ["keyword.operator.arithmetic.elixir","-"], + ["text"," "], + ["punctuation.definition.variable.elixir","@"], + ["variable.other.readwrite.module.elixir","books"], + ["text"," "], + ["keyword.control.elixir","do"], + ["text"," "], + ["support.elixir_tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["comment.start.eex","<%#"], + ["comment"," comment "], + ["comment.end.eex","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.elixir_tag","<%="], + ["text"," book"], + ["punctuation.separator.method.elixir","."], + ["text","title "], + ["support.elixir_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.elixir_tag","<%="], + ["text"," book"], + ["punctuation.separator.method.elixir","."], + ["text","content "], + ["support.elixir_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.elixir_tag","<%="], + ["text"," link "], + ["punctuation.definition.string.begin.elixir","\""], + ["string.quoted.double.elixir","Show"], + ["punctuation.definition.string.end.elixir","\""], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir","to:"], + ["text"," book_path"], + ["punctuation.section.function.elixir","("], + ["punctuation.definition.variable.elixir","@"], + ["variable.other.readwrite.module.elixir","conn"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","show"], + ["punctuation.separator.object.elixir",","], + ["text"," book"], + ["punctuation.section.function.elixir",")"], + ["text"," "], + ["support.elixir_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.elixir_tag","<%="], + ["text"," link "], + ["punctuation.definition.string.begin.elixir","\""], + ["string.quoted.double.elixir","Edit"], + ["punctuation.definition.string.end.elixir","\""], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir","to:"], + ["text"," book_path"], + ["punctuation.section.function.elixir","("], + ["punctuation.definition.variable.elixir","@"], + ["variable.other.readwrite.module.elixir","conn"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","edit"], + ["punctuation.separator.object.elixir",","], + ["text"," book"], + ["punctuation.section.function.elixir",")"], + ["text"," "], + ["support.elixir_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.elixir_tag","<%="], + ["text"," link "], + ["punctuation.definition.string.begin.elixir","\""], + ["string.quoted.double.elixir","Delete"], + ["punctuation.definition.string.end.elixir","\""], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir","to:"], + ["text"," book_path"], + ["punctuation.section.function.elixir","("], + ["punctuation.definition.variable.elixir","@"], + ["variable.other.readwrite.module.elixir","conn"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","delete"], + ["punctuation.separator.object.elixir",","], + ["text"," book"], + ["punctuation.section.function.elixir",")"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir","method:"], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","delete"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir","data:"], + ["text"," "], + ["punctuation.section.array.elixir","["], + ["punctuation.definition.constant.elixir","confirm:"], + ["text"," "], + ["punctuation.definition.string.begin.elixir","\""], + ["string.quoted.double.elixir","Are you sure?"], + ["punctuation.definition.string.end.elixir","\""], + ["punctuation.section.array.elixir","]"], + ["text"," "], + ["support.elixir_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["support.elixir_tag","<%"], + ["text"," "], + ["keyword.control.elixir","end"], + ["text"," "], + ["support.elixir_tag","%>"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","br"], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["support.elixir_tag","<%="], + ["text"," link "], + ["punctuation.definition.string.begin.elixir","\""], + ["string.quoted.double.elixir","New book"], + ["punctuation.definition.string.end.elixir","\""], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir","to:"], + ["text"," book_path"], + ["punctuation.section.function.elixir","("], + ["punctuation.definition.variable.elixir","@"], + ["variable.other.readwrite.module.elixir","conn"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","new"], + ["punctuation.section.function.elixir",")"], + ["text"," "], + ["support.elixir_tag","%>"] +],[ + "start" +]] diff --git a/public/lib/ace/mode/_test/tokens_html_ruby.json b/public/lib/ace/mode/_test/tokens_html_ruby.json new file mode 100644 index 0000000..8ff5f6e --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_html_ruby.json @@ -0,0 +1,257 @@ +[[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h1"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Listing Books"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","table"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Title"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Summary"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["support.ruby_tag","<%"], + ["text"," "], + ["variable.instance","@books"], + ["text","."], + ["identifier","each"], + ["text"," "], + ["keyword","do"], + ["text"," |"], + ["identifier","book"], + ["text","| "], + ["support.ruby_tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["comment.start.erb","<%#"], + ["comment"," comment "], + ["comment.end.erb","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["identifier","book"], + ["text","."], + ["identifier","title"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["identifier","book"], + ["text","."], + ["identifier","content"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["support.function","link_to"], + ["text"," "], + ["string.start","'"], + ["string","Show"], + ["string.end","'"], + ["text",", "], + ["identifier","book"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["support.function","link_to"], + ["text"," "], + ["string.start","'"], + ["string","Edit"], + ["string.end","'"], + ["text",", "], + ["identifier","edit_book_path"], + ["paren.lparen","("], + ["identifier","book"], + ["paren.rparen",")"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["support.function","link_to"], + ["text"," "], + ["string.start","'"], + ["string","Remove"], + ["string.end","'"], + ["text",", "], + ["identifier","book"], + ["text",", "], + ["constant.other.symbol.ruby",":confirm"], + ["text"," "], + ["punctuation.separator.key-value","=>"], + ["text"," "], + ["string.start","'"], + ["string","Are you sure?"], + ["string.end","'"], + ["text",", "], + ["constant.other.symbol.ruby",":method"], + ["text"," "], + ["punctuation.separator.key-value","=>"], + ["text"," "], + ["constant.other.symbol.ruby",":delete"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["support.ruby_tag","<%"], + ["text"," "], + ["keyword","end"], + ["text"," "], + ["support.ruby_tag","%>"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","br"], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["support.ruby_tag","<%="], + ["text"," "], + ["support.function","link_to"], + ["text"," "], + ["string.start","'"], + ["string","New book"], + ["string.end","'"], + ["text",", "], + ["identifier","new_book_path"], + ["text"," "], + ["support.ruby_tag","%>"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_ini.json b/public/lib/ace/mode/_test/tokens_ini.json new file mode 100644 index 0000000..11d2801 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_ini.json @@ -0,0 +1,23 @@ +[[ + "start", + ["punctuation.definition.entity.ini","["], + ["constant.section.group-title.ini",".ShellClassInfo"], + ["punctuation.definition.entity.ini","]"] +],[ + "start", + ["keyword.other.definition.ini","IconResource"], + ["punctuation.separator.key-value.ini","="], + ["text","..\\logo.png"] +],[ + "start", + ["punctuation.definition.entity.ini","["], + ["constant.section.group-title.ini","ViewState"], + ["punctuation.definition.entity.ini","]"] +],[ + "start", + ["keyword.other.definition.ini","FolderType"], + ["punctuation.separator.key-value.ini","="], + ["text","Generic"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_io.json b/public/lib/ace/mode/_test/tokens_io.json new file mode 100644 index 0000000..b83a675 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_io.json @@ -0,0 +1,49 @@ +[[ + "start", + ["punctuation.definition.comment.io","//"], + ["comment.line.double-slash.io"," computes factorial of a number"] +],[ + "start", + ["text","factorial "], + ["keyword.operator.io",":="], + ["text"," "], + ["support.function.io","method"], + ["text","(n,"] +],[ + "start", + ["text"," "], + ["keyword.control.io","if"], + ["text","(n "], + ["keyword.operator.io","=="], + ["text"," "], + ["constant.numeric.io","0"], + ["text",", "], + ["keyword.control.io","return"], + ["text"," "], + ["constant.numeric.io","1"], + ["text",")"] +],[ + "start", + ["text"," res "], + ["keyword.operator.io",":="], + ["text"," "], + ["constant.numeric.io","1"] +],[ + "start", + ["text"," "], + ["support.class.io","Range"], + ["text"," "], + ["constant.numeric.io","1"], + ["text"," "], + ["support.function.io","to"], + ["text","(n) "], + ["keyword.control.io","foreach"], + ["text","(i, res "], + ["keyword.operator.io","="], + ["text"," res "], + ["keyword.operator.io","*"], + ["text"," i)"] +],[ + "start", + ["text",")"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_jack.json b/public/lib/ace/mode/_test/tokens_jack.json new file mode 100644 index 0000000..c3d694d --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_jack.json @@ -0,0 +1,1786 @@ +[[ + "start", + ["keyword","vars"], + ["text"," "], + ["variable","it"], + ["text",", "], + ["variable","p"] +],[ + "start" +],[ + "start", + ["variable","p"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","label"], + ["text",", "], + ["variable","value"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\""], + ["constant.language.escape","\\n"], + ["string","\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","label"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["language.builtin","inspect"], + ["paren.lparen","("], + ["variable","value"], + ["paren.rparen","))"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["comment","-- Create an array from 0 to 15"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"range\""], + ["text",", "], + ["language.builtin","i-collect"], + ["paren.lparen","("], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","5"], + ["paren.rparen",")))"] +],[ + "start" +],[ + "start", + ["comment","-- Create an array from 0 to 15 and break up in chunks of 4"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"chunked range\""], + ["text",", "], + ["language.builtin","i-collect"], + ["paren.lparen","("], + ["language.builtin","i-chunk"], + ["paren.lparen","("], + ["constant.numeric","4"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","16"], + ["paren.rparen","))))"] +],[ + "start" +],[ + "start", + ["comment","-- Check if all or none items in stream pass test."] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"all < 60 in range(60)\""], + ["text",", "], + ["variable","i-all?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator","<"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","60"], + ["paren.rparen",")))"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"any < 60 in range(60)\""], + ["text",", "], + ["variable","i-any?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator",">"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","60"], + ["paren.rparen",")))"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"all < 60 in range(70)\""], + ["text",", "], + ["variable","i-all?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator","<"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","70"], + ["paren.rparen",")))"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"any < 60 in range(70)\""], + ["text",", "], + ["variable","i-any?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator",">"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","70"], + ["paren.rparen",")))"] +],[ + "start" +],[ + "start", + ["comment","-- Zip three different collections together"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"zipped\""], + ["text",", "], + ["language.builtin","i-collect"], + ["paren.lparen","("], + ["language.builtin","i-zip"], + ["paren.lparen","("] +],[ + "start", + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text",","] +],[ + "start", + ["text"," "], + ["paren.lparen","["], + ["constant.numeric","1"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["constant.numeric","3"], + ["text",","], + ["constant.numeric","4"], + ["text",","], + ["constant.numeric","5"], + ["paren.rparen","]"], + ["text",","] +],[ + "start", + ["text"," "], + ["language.builtin","i-map"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator","*"], + ["variable","i"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen","))"] +],[ + "start", + ["paren.rparen",")))"] +],[ + "start" +],[ + "start", + ["keyword","vars"], + ["text"," "], + ["variable","names"], + ["text",", "], + ["variable","person"], + ["text",", "], + ["variable","i"], + ["text",", "], + ["variable","doubles"], + ["text",", "], + ["variable","lengths"], + ["text",", "], + ["variable","cubeRange"] +],[ + "start", + ["variable","names"], + ["text"," = "], + ["paren.lparen","["], + ["string","\"Thorin\""], + ["text",", "], + ["string","\"Dwalin\""], + ["text",", "], + ["string","\"Balin\""], + ["text",", "], + ["string","\"Bifur\""], + ["text",", "], + ["string","\"Bofur\""], + ["text",", "], + ["string","\"Bombur\""], + ["text",", "], + ["string","\"Oin\""], + ["text",","] +],[ + "start", + ["text"," "], + ["string","\"Gloin\""], + ["text",", "], + ["string","\"Ori\""], + ["text",", "], + ["string","\"Nori\""], + ["text",", "], + ["string","\"Dori\""], + ["text",", "], + ["string","\"Fili\""], + ["text",", "], + ["string","\"Kili\""], + ["text",", "], + ["string","\"Bilbo\""], + ["text",", "], + ["string","\"Gandalf\""], + ["paren.rparen","]"] +],[ + "start" +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","names"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","!="], + ["text"," "], + ["string","\"Bilbo\""], + ["text"," "], + ["keyword.operator","&&"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","!="], + ["text"," "], + ["string","\"Gandalf\""], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["variable","person"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","name"], + ["text",": "], + ["string","\"Tim\""], + ["text",", "], + ["variable","age"], + ["text",": "], + ["constant.numeric","30"], + ["paren.rparen","}"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","key"], + ["text",", "], + ["variable","value"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","person"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","key"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\" = \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","value"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["variable","i"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["keyword","while"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword.operator","<"], + ["text"," "], + ["constant.numeric","10"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","i"], + ["text"," = "], + ["variable","i"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","i"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"range\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","i"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["variable","i"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment","-- Dynamic object that gives the first 10 doubles"] +],[ + "start", + ["variable","doubles"], + ["text"," = "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.form","@len"], + ["text",": "], + ["paren.lparen","{"], + ["text","| "], + ["constant.numeric","10"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["storage.form","@get"], + ["text",": "], + ["paren.lparen","{"], + ["variable","key"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["keyword","is"], + ["text"," "], + ["storage.type","Integer"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"#doubles\""], + ["text",", "], + ["keyword.operator","#"], + ["variable","doubles"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"Doubles\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","doubles"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment","-- Dynamic object that has names list as keys and string lenth as values"] +],[ + "start", + ["variable","lengths"], + ["text"," = "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.form","@keys"], + ["text",": "], + ["paren.lparen","{"], + ["text","| "], + ["variable","names"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["storage.form","@get"], + ["text",": "], + ["paren.lparen","{"], + ["variable","key"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["keyword","is"], + ["text"," "], + ["storage.type","String"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["keyword.operator","#"], + ["variable","key"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["text"," "], + ["paren.lparen","("], + ["string","\"Lengths\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","lengths"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["variable","cubeRange"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","n"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","vars"], + ["text"," "], + ["variable","i"], + ["text",", "], + ["variable","v"] +],[ + "start", + ["text"," "], + ["variable","i"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.form","@call"], + ["text",": "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["variable","v"], + ["text"," = "], + ["variable","i"] +],[ + "start", + ["text"," "], + ["variable","i"], + ["text"," = "], + ["variable","i"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["keyword.operator","<"], + ["text"," "], + ["variable","n"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"Cubes\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","cubeRange"], + ["paren.lparen","("], + ["constant.numeric","5"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"String\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["string","\"Hello World\""], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","i"], + ["text"," "], + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")])"] +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","i"], + ["text"," "], + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","20"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword.operator","%"], + ["text"," "], + ["constant.numeric","3"], + ["paren.rparen","])"] +],[ + "start" +],[ + "start" +],[ + "start" +],[ + "start", + ["comment","-- Example showing how to do parallel work using split..and"] +],[ + "start", + ["variable","base"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","bootstrap"], + ["text",", "], + ["variable","target-dir"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","split"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","copy"], + ["paren.lparen","("], + ["string","\"res\""], + ["text",", "], + ["variable","target-dir"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","newer"], + ["paren.lparen","("], + ["string","\"src/*.less\""], + ["text",", "], + ["variable","target-dir"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"/style.css\""], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","lessc"], + ["paren.lparen","("], + ["string","\"src/\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","bootstrap"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\".less\""], + ["text",", "], + ["variable","target-dir"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"/style.css\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","build"], + ["paren.lparen","("], + ["string","\"src/\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","bootstrap"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\".js\""], + ["text",", "], + ["variable","target-dir"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"/app.js\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["keyword","vars"], + ["text"," "], + ["variable","Dragon"], + ["text",", "], + ["variable","pet"] +],[ + "start" +],[ + "start", + ["variable","Dragon"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","name"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","vars"], + ["text"," "], + ["variable","asleep"], + ["text",", "], + ["variable","stuff-in-belly"], + ["text",", "], + ["variable","stuff-in-intestine"], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","feed"], + ["text",", "], + ["variable","walk"], + ["text",", "], + ["variable","put-to-bed"], + ["text",", "], + ["variable","toss"], + ["text",", "], + ["variable","rock"], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","hungry?"], + ["text",", "], + ["variable","poopy?"], + ["text",", "], + ["variable","passage-of-time"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," = "], + ["constant.numeric","10"], + ["text"," "], + ["comment","-- He's full."] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["constant.numeric","0"], + ["text"," "], + ["comment","-- He doesn't need to go."] +],[ + "start" +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' is born.'"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","feed"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You feed '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","'.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," = "], + ["constant.numeric","10"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","walk"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You walk '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\".\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","put-to-bed"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You put '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' to bed.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","true"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","3"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' snores, filling the room with smoke.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' wakes up slowly.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","toss"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You toss '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' up into the air.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He giggles, which singes your eyebrows.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","rock"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You rock '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' gently.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","true"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He briefly dozes off...'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'...but wakes when you stop.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","hungry?"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["constant.numeric","2"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","poopy?"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","8"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["comment","-- Move food from belly to intestine"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," = "], + ["variable","stuff-in-belly"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["variable","stuff-in-intestine"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["comment","-- Our dragon is starving!"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He wakes up suddenly!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' is starving! In desperation, he ate YOU!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","abort"], + ["text"," "], + ["string","\"died\""] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","10"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'Whoops! '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' had an accident...'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","hungry?"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He wakes up suddenly!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"'s stomach grumbles...\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","poopy?"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He wakes up suddenly!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' does the potty dance...'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","-- Export the public interface to this closure object."] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","feed"], + ["text",": "], + ["variable","feed"] +],[ + "start", + ["text"," "], + ["variable","walk"], + ["text",": "], + ["variable","walk"] +],[ + "start", + ["text"," "], + ["variable","put-to-bed"], + ["text",": "], + ["variable","put-to-bed"] +],[ + "start", + ["text"," "], + ["variable","toss"], + ["text",": "], + ["variable","toss"] +],[ + "start", + ["text"," "], + ["variable","rock"], + ["text",": "], + ["variable","rock"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["variable","pet"], + ["text"," = "], + ["variable","Dragon"], + ["paren.lparen","("], + ["string","'Norbert'"], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","feed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","toss"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","walk"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","rock"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_jade.json b/public/lib/ace/mode/_test/tokens_jade.json new file mode 100644 index 0000000..c40ea24 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_jade.json @@ -0,0 +1,187 @@ +[[ + "start", + ["keyword.other.doctype.jade","!!!doctype"] +],[ + "start", + ["keyword.other.doctype.jade","!!!5"] +],[ + "start", + ["keyword.other.doctype.jade","!!!"] +],[ + "start" +],[ + "start", + ["keyword.control.import.include.jade","include"], + ["text"," something"] +],[ + "start" +],[ + "start", + ["keyword.control.import.include.jade"," include"], + ["text"," another_thing"] +],[ + "start" +],[ + ["comment_block",2,"start"], + ["comment"," // let's talk about it"] +],[ + "start" +],[ + ["comment_block",0,"start"], + ["comment","// "] +],[ + ["comment_block",0,"start"], + ["comment"," here it is. a block comment!"] +],[ + ["comment_block",0,"start"], + ["comment"," and another row!"] +],[ + "start", + ["meta.tag.any.jade","but"], + ["text"," not here."] +],[ + "start" +],[ + ["comment_block",5,"start"], + ["comment"," // "] +],[ + ["comment_block",5,"start"], + ["comment"," a far spaced"] +],[ + "start", + ["text"," should be lack of block"] +],[ + "start" +],[ + ["comment_block",3,"start"], + ["comment"," // also not a comment"] +],[ + ["comment_block",3,"start"], + ["comment"," div.attemptAtBlock"] +],[ + "start", + ["text"," "] +],[ + "start", + ["meta.tag.any.jade"," span"], + ["entity.other.attribute-name.id.jade","#myName"] +],[ + "start" +],[ + "start", + ["text"," "], + ["string.interpolated.jade","#{implicit}"] +],[ + "start", + ["text"," "], + ["string.interpolated.jade","!{more_explicit}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["suport.type.attribute.id.jade","#idDiv"] +],[ + "start" +],[ + "start", + ["text"," "], + ["suport.type.attribute.class.jade",".idDiv"] +],[ + "start" +],[ + "start", + ["meta.tag.any.jade"," test"], + ["punctuation","("], + ["entity.other.attribute-name.jade","id"], + ["punctuation","="], + ["string","\"tag\""], + ["punctuation",")"] +],[ + "start", + ["meta.tag.any.jade"," header"], + ["punctuation","("], + ["entity.other.attribute-name.jade","id"], + ["punctuation","="], + ["string","\"tag\""], + ["text",", "], + ["entity.other.attribute-name.jade","blah"], + ["punctuation","="], + ["string","\"foo\""], + ["text",", "], + ["entity.other.attribute-name.jade","meh"], + ["punctuation","="], + ["string","\"aads\""], + ["punctuation",")"] +],[ + "start", + ["storage.type.function.jade","mixin"], + ["entity.name.function.jade"," article"], + ["punctuation.definition.parameters.begin.jade","("], + ["variable.parameter.function.jade","obj, parents"], + ["punctuation.definition.parameters.end.jade",")"] +],[ + "start" +],[ + "start", + ["storage.type.function.jade"," mixin"], + ["entity.name.function.jade"," bleh"], + ["punctuation.definition.parameters.begin.jade","("], + ["punctuation.definition.parameters.end.jade",")"] +],[ + "start" +],[ + "start", + ["storage.type.function.jade"," mixin"], + ["entity.name.function.jade"," clever-name"] +],[ + "start" +],[ + "start", + ["source.js.embedded.jade"," -"], + ["storage.type","var"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"0\""], + ["text",";"] +],[ + "start", + ["source.js.embedded.jade"," -"], + ["text"," "], + ["identifier","y"], + ["text"," "], + ["identifier","each"], + ["text"," z"] +],[ + "start" +],[ + "start", + ["source.js.embedded.jade"," -"], + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","items"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","["], + ["string","\"one\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"two\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"three\""], + ["text","]"] +],[ + "start", + ["meta.tag.any.jade"," each"], + ["text"," item in items"] +],[ + "start", + ["meta.tag.any.jade"," li"], + ["text","= item"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_java.json b/public/lib/ace/mode/_test/tokens_java.json new file mode 100644 index 0000000..799ebdb --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_java.json @@ -0,0 +1,95 @@ +[[ + "start", + ["keyword","public"], + ["text"," "], + ["keyword","class"], + ["text"," "], + ["identifier","InfiniteLoop"], + ["text"," "], + ["lparen","{"] +],[ + "start" +],[ + "comment", + ["text"," "], + ["comment","/*"] +],[ + "comment", + ["comment"," * This will cause the program to hang..."] +],[ + "comment", + ["comment"," *"] +],[ + "comment", + ["comment"," * Taken from:"] +],[ + "comment", + ["comment"," * http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/"] +],[ + "start", + ["comment"," */"] +],[ + "start", + ["text"," "], + ["keyword","public"], + ["text"," "], + ["keyword","static"], + ["text"," "], + ["keyword","void"], + ["text"," "], + ["identifier","main"], + ["lparen","("], + ["support.function","String"], + ["lparen","["], + ["rparen","]"], + ["text"," "], + ["identifier","args"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","double"], + ["text"," "], + ["identifier","d"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","Double"], + ["text","."], + ["identifier","parseDouble"], + ["lparen","("], + ["string","\"2.2250738585072012e-308\""], + ["rparen",")"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","// unreachable code"] +],[ + "start", + ["text"," "], + ["support.function","System"], + ["text","."], + ["identifier","out"], + ["text","."], + ["identifier","println"], + ["lparen","("], + ["string","\"Value: \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["identifier","d"], + ["rparen",")"], + ["text",";"] +],[ + "start", + ["text"," "], + ["rparen","}"] +],[ + "start", + ["rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_javascript.json b/public/lib/ace/mode/_test/tokens_javascript.json new file mode 100644 index 0000000..8759595 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_javascript.json @@ -0,0 +1,736 @@ +[[ + "start", + ["comment","//test: tokenize 'standard' functions"] +],[ + "no_regex", + ["identifier","string"], + ["punctuation.operator","."], + ["support.function","charCodeAt"], + ["paren.lparen","("], + ["constant.numeric","23"], + ["paren.rparen",")"], + ["punctuation.operator",";"], + ["text"," "], + ["variable.language","document"], + ["punctuation.operator","."], + ["support.function.dom","getElementById"], + ["paren.lparen","("], + ["string","'test'"], + ["paren.rparen",")"], + ["punctuation.operator",";"], + ["text"," "], + ["storage.type","console"], + ["punctuation.operator","."], + ["support.function.firebug","log"], + ["paren.lparen","("], + ["string","'Here it is'"], + ["paren.rparen",")"], + ["punctuation.operator",";"], + ["string","\";"] +],[ + "no_regex", + ["identifier","test"], + ["punctuation.operator",":"], + ["text"," "], + ["comment.doc","/**tokenize doc*/"], + ["text"," "], + ["identifier","comment"] +],[ + "no_regex", + ["comment.doc","/**tokenize doc comment with "], + ["comment.doc.tag","@tag"], + ["comment.doc"," {}*/"] +],[ + "no_regex", + ["comment","//test: tokenize parens"] +],[ + "start", + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","$line$"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"[{( )}]\""], + ["punctuation.operator",";"] +],[ + "start", + ["comment","//test tokenize arithmetic expression which looks like a regexp"] +],[ + "no_regex", + ["identifier","a"], + ["keyword.operator","/"], + ["identifier","b"], + ["keyword.operator","/"], + ["identifier","c"] +],[ + "no_regex", + ["identifier","a"], + ["keyword.operator","/="], + ["identifier","b"], + ["keyword.operator","/"], + ["identifier","c"] +],[ + "no_regex", + ["comment","//test tokenize reg exps"] +],[ + "no_regex", + ["identifier","a"], + ["keyword.operator","="], + ["string.regexp","/b/g"] +],[ + "no_regex", + ["identifier","a"], + ["keyword.operator","+"], + ["string.regexp","/b/g"] +],[ + "no_regex", + ["identifier","a"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string.regexp","/2 "], + ["constant.language.escape","+"], + ["string.regexp"," 1/gimyx"], + ["identifier","k"] +],[ + "no_regex", + ["identifier","a"], + ["keyword.operator","="], + ["string.regexp","/a/"], + ["text"," "], + ["keyword.operator","/"], + ["text"," "], + ["string.regexp","/a/"] +],[ + "no_regex", + ["keyword","case"], + ["text"," "], + ["string.regexp","/a/"], + ["punctuation.operator","."], + ["support.function","test"], + ["paren.lparen","("], + ["identifier","c"], + ["paren.rparen",")"] +],[ + "no_regex", + ["comment","//test tokenize multi-line comment containing a single line comment"] +],[ + "no_regex", + ["identifier","noRegex"] +],[ + "no_regex", + ["comment","/* foo // bar */"] +],[ + "start", + ["identifier","canBeRegex"], + ["punctuation.operator",";"] +],[ + "start", + ["comment","/* foo // bar */"] +],[ + "start", + ["comment","// test tokenize identifier with umlauts"] +],[ + "no_regex", + ["identifier","fu"], + ["punctuation.operator","?"], + ["identifier","e"] +],[ + "no_regex", + ["comment","// test // is not a regexp"] +],[ + "start", + ["paren.lparen","{"], + ["text"," "], + ["comment","// 123"] +],[ + "start", + ["comment","//test skipping escaped chars"] +],[ + "no_regex", + ["string","'Meh"], + ["constant.language.escape","\\\\"], + ["string","nNeh'"] +],[ + "no_regex", + ["storage.type","console"], + ["punctuation.operator","."], + ["support.function.firebug","log"], + ["paren.lparen","("], + ["string","'"], + ["constant.language.escape","\\\\"], + ["string","u1232Feh'"] +],[ + "qqstring", + ["string","\"test multiline\\"] +],[ + "no_regex", + ["string"," strings\""] +],[ + "no_regex", + ["identifier","a"], + ["keyword.operator","="], + ["text","'"] +],[ + "qqstring", + ["identifier","b"], + ["keyword.operator","="], + ["string","\"\\"] +],[ + "no_regex", + ["string","still a string"] +],[ + "no_regex", + ["text"," "] +],[ + "no_regex", + ["text"," "] +],[ + "start", + ["storage.type","function"], + ["text"," "], + ["entity.name.function","foo"], + ["paren.lparen","("], + ["variable.parameter","items"], + ["punctuation.operator",", "], + ["variable.parameter","nada"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["paren.lparen","("], + ["storage.type","var"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","="], + ["constant.numeric","0"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","<"], + ["identifier","items"], + ["punctuation.operator","."], + ["support.constant","length"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","++"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.function","alert"], + ["paren.lparen","("], + ["identifier","items"], + ["paren.lparen","["], + ["identifier","i"], + ["paren.rparen","]"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"juhu"], + ["constant.language.escape","\\n"], + ["string","\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"], + ["text","\t"], + ["comment","// Real Tab."] +],[ + "no_regex", + ["paren.rparen","}"] +],[ + "no_regex" +],[ + "no_regex", + ["identifier","regexp"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.regexp","/p"], + ["constant.language.delimiter","|"], + ["string.regexp","p/"], + ["text"," "], + ["comment","// ends here"] +],[ + "no_regex" +],[ + "no_regex", + ["identifier","r"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.regexp","/d"], + ["constant.language.escape","{1,2}?"], + ["string.regexp","f{e}"], + ["invalid","++"], + ["string.regexp","r"], + ["constant.language.escape","*?"], + ["regexp.keyword.operator","\\d"], + ["constant.language.escape","+?[]"], + ["string.regexp","r"], + ["constant.language.escape","[^"], + ["string.regexp.charachterclass","r"], + ["constant.language.escape","-"], + ["string.regexp.charachterclass","o"], + ["regexp.charclass.keyword.operator","\\f\\f"], + ["string.regexp.charachterclass","["], + ["regexp.charclass.keyword.operator","\\f"], + ["constant.language.escape","]?"], + ["string.regexp","r"], + ["invalid","{7}+"], + ["string.regexp","r"], + ["regexp.keyword.operator","\\{"], + ["string.regexp","7}"], + ["constant.language.escape","+"], + ["string.regexp","rr--rr"], + ["constant.language.escape","$^(?:"], + ["string.regexp","d"], + ["constant.language.delimiter","|"], + ["string.regexp","s"], + ["constant.language.escape",")(?="], + ["string.regexp","a"], + ["constant.language.delimiter","|"], + ["constant.language.escape",")(?!"], + ["string.regexp","y"], + ["constant.language.escape",")[]"], + ["constant.language.delimiter","|"], + ["invalid","$?"], + ["constant.language.delimiter","|"], + ["invalid","^*"], + ["string.regexp","/"], + ["text"," "], + ["identifier","o"] +],[ + "no_regex", + ["identifier","a"], + ["keyword.operator","="], + ["string.regexp","/a/"], + ["text"," "], + ["identifier","jk"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.regexp","/ /"], + ["text"," "], + ["keyword.operator","/"], + ["text"," "], + ["string.regexp","/ /"] +],[ + "no_regex", + ["text"," "], + ["comment.doc","/************************************/"] +],[ + "no_regex", + ["comment.doc","/** total mess, tricky to highlight**/"] +],[ + "no_regex" +],[ + "start", + ["storage.type","function"], + ["text"," "], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "doc-start", + ["text","\t"], + ["comment.doc","/**"] +],[ + "doc-start", + ["comment.doc","\t * docComment"] +],[ + "no_regex", + ["comment.doc","\t **/"] +],[ + "no_regex", + ["text","\t"], + ["identifier","r"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.regexp","/u"], + ["regexp.keyword.operator","\\t"], + ["constant.language.escape","*"], + ["string.regexp","/"] +],[ + "no_regex", + ["text","\t"], + ["identifier","g"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1.00"], + ["identifier","E"], + ["keyword.operator","^"], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","y"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1.2"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1."], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric",".2"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","052"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","0O7"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","0x25"] +],[ + "no_regex", + ["text","\t"], + ["identifier","t"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","["], + ["string","'d'"], + ["punctuation.operator",","], + ["text"," "], + ["string","''"], + ["paren.rparen","]"] +],[ + "no_regex", + ["paren.rparen","}"] +],[ + "start", + ["storage.type","function"], + ["text"," "], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["comment","/* eee */"] +],[ + "no_regex", + ["paren.rparen","}"] +],[ + "no_regex" +],[ + "qqstring", + ["string","\"s\\"] +],[ + "no_regex", + ["string","s"], + ["constant.language.escape","\\u7824"], + ["string","sss"], + ["constant.language.escape","\\u"], + ["string","1\""] +],[ + "no_regex" +],[ + "qstring", + ["string","'\\"] +],[ + "no_regex", + ["string","string'"] +],[ + "no_regex" +],[ + "no_regex", + ["text","'"] +],[ + "no_regex", + ["identifier","string"], + ["text","'"] +],[ + "no_regex" +],[ + "no_regex", + ["string","\"trailing space"], + ["constant.language.escape","\\ "], + ["string"," "] +],[ + "no_regex", + ["string","\" \""], + ["text"," "], + ["keyword.operator","/"], + ["identifier","not"], + ["text"," "], + ["identifier","a"], + ["text"," "], + ["identifier","regexp"], + ["keyword.operator","/"], + ["identifier","g"] +],[ + "no_regex" +],[ + "doc-start", + ["comment.doc","/**"] +],[ + "doc-start", + ["comment.doc"," *doc"] +],[ + "no_regex", + ["comment.doc"," */"] +],[ + "no_regex" +],[ + "start", + ["identifier","a"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["string","'a'"], + ["punctuation.operator",":"], + ["text"," "], + ["identifier","b"], + ["punctuation.operator",","] +],[ + "no_regex", + ["text","\t"], + ["string","'g'"], + ["text",":"], + ["text"," "], + ["storage.type","function"], + ["paren.lparen","("], + ["variable.parameter","t"], + ["paren.rparen",")"] +],[ + "no_regex", + ["text","\t"], + ["entity.name.function","gta"], + ["punctuation.operator",":"], + ["storage.type","function"], + ["paren.lparen","("], + ["variable.parameter","a"], + ["punctuation.operator",","], + ["variable.parameter","b"], + ["paren.rparen",")"] +],[ + "no_regex", + ["paren.rparen","}"] +],[ + "no_regex" +],[ + "no_regex", + ["identifier","z"], + ["keyword.operator",">>="], + ["identifier","t"], + ["keyword.operator","<<"], + ["identifier","f"], + ["keyword.operator",">>"], + ["identifier","r"], + ["keyword.operator",">>>"], + ["identifier","s"], + ["keyword.operator",">="], + ["constant.numeric","0b1"] +],[ + "no_regex" +],[ + "function_arguments", + ["identifier","foo"], + ["punctuation.operator","."], + ["storage.type","protoype"], + ["punctuation.operator","."], + ["entity.name.function","d"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["storage.type","function"], + ["paren.lparen","("], + ["variable.parameter","a"], + ["punctuation.operator",", "], + ["variable.parameter","b"], + ["punctuation.operator",","] +],[ + "no_regex", + ["punctuation.operator"," "], + ["variable.parameter","c"], + ["punctuation.operator",", "], + ["variable.parameter","d"], + ["paren.rparen",")"] +],[ + "no_regex", + ["storage.type","foo"], + ["punctuation.operator","."], + ["entity.name.function","d"], + ["text"," "], + ["keyword.operator","="], + ["storage.type","function"], + ["paren.lparen","("], + ["variable.parameter","a"], + ["punctuation.operator",", "], + ["variable.parameter","b"], + ["paren.rparen",")"] +],[ + "no_regex", + ["storage.type","foo"], + ["punctuation.operator","."], + ["entity.name.function","d"], + ["text"," "], + ["keyword.operator","="], + ["storage.type","function"], + ["paren.lparen","("], + ["variable.parameter","a"], + ["punctuation.operator",", "], + ["comment.doc","/*****/"], + ["text"," "], + ["identifier","d"], + ["string","\"string\""], + ["text"," "] +],[ + "no_regex" +],[ + "no_regex", + ["keyword.operator","<"], + ["identifier","div"] +],[ + ["start","jsxAttributes","jsxAttributes","jsx",1], + ["identifier","z"], + ["keyword.operator","="], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["paren.quasi.start","{"], + ["keyword.operator","..."], + ["variable.language","this"], + ["punctuation.operator","."], + ["identifier","props"], + ["paren.quasi.end","}"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","x"], + ["keyword.operator.attribute-equals.xml","="], + ["paren.quasi.start","{"], + ["constant.numeric","1"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","2"], + ["paren.quasi.end","}"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","y"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"z{a}b"], + ["constant.language.escape.reference.xml","&"], + ["string.attribute-value.xml","\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","t"], + ["keyword.operator.attribute-equals.xml","="], + ["paren.quasi.start","{"] +],[ + ["start","jsxAttributes","jsxAttributes","jsx",1], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","a"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["paren.quasi.start","{"], + ["constant.numeric","2"], + ["paren.quasi.end","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + ["jsx",1], + ["text"," "], + ["paren.quasi.end","}"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + ["jsx",1], + ["string","1 "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","a"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["string"," "], + ["paren.quasi.start","{"], + ["text"," "], + ["keyword.operator","++"], + ["identifier","x"], + ["text"," "], + ["paren.quasi.end","}"], + ["string"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start", + ["storage.type","var"], + ["text"," "], + ["identifier","o"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"] +],[ + ["start","no_regex","start","string.quasi.start","string.quasi.start","no_regex"], + ["text"," "], + ["identifier","t"], + ["punctuation.operator",":"], + ["string.quasi.start","`"], + ["paren.quasi.start","${"], + ["paren.lparen","["], + ["paren.rparen","]"], + ["punctuation.operator","."], + ["identifier","map"], + ["paren.lparen","("], + ["identifier","x"], + ["text"," "], + ["storage.type","=>"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["#tmp","no_regex","start","no_regex","start","string.quasi.start","string.quasi.start","no_regex"], + ["text"," "], + ["keyword","return"], + ["text"," "], + ["identifier","x"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","})"], + ["paren.quasi.end","}"], + ["string.quasi.end","`"] +],[ + "start", + ["paren.rparen","}"], + ["punctuation.operator",";"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_json.json b/public/lib/ace/mode/_test/tokens_json.json new file mode 100644 index 0000000..4420a74 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_json.json @@ -0,0 +1,412 @@ +[[ + "start", + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","\"query\""], + ["text",": "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","\"count\""], + ["text",": "], + ["constant.numeric","10"], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"created\""], + ["text",": "], + ["string","\"2011-06-21T08:10:46Z\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"lang\""], + ["text",": "], + ["string","\"en-US\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"results\""], + ["text",": "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","\"photo\""], + ["text",": "], + ["paren.lparen","["] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","\"farm\""], + ["text",": "], + ["string","\"6\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"id\""], + ["text",": "], + ["string","\"5855620975\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfamily\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfriend\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"ispublic\""], + ["text",": "], + ["string","\"1\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"owner\""], + ["text",": "], + ["string","\"32021554@N04\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"secret\""], + ["text",": "], + ["string","\"f1f5e8515d\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"server\""], + ["text",": "], + ["string","\"5110\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"title\""], + ["text",": "], + ["string","\"7087 bandit cat\""] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text",","] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","\"farm\""], + ["text",": "], + ["string","\"4\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"id\""], + ["text",": "], + ["string","\"5856170534\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfamily\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfriend\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"ispublic\""], + ["text",": "], + ["string","\"1\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"owner\""], + ["text",": "], + ["string","\"32021554@N04\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"secret\""], + ["text",": "], + ["string","\"ff1efb2a6f\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"server\""], + ["text",": "], + ["string","\"3217\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"title\""], + ["text",": "], + ["string","\"6975 rusty cat\""] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text",","] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","\"farm\""], + ["text",": "], + ["string","\"6\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"id\""], + ["text",": "], + ["string","\"5856172972\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfamily\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfriend\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"ispublic\""], + ["text",": "], + ["string","\"1\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"owner\""], + ["text",": "], + ["string","\"51249875@N03\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"secret\""], + ["text",": "], + ["string","\"6c6887347c\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"server\""], + ["text",": "], + ["string","\"5192\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"title\""], + ["text",": "], + ["string","\"watermarked-cats\""] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text",","] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","\"farm\""], + ["text",": "], + ["string","\"6\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"id\""], + ["text",": "], + ["string","\"5856168328\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfamily\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfriend\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"ispublic\""], + ["text",": "], + ["string","\"1\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"owner\""], + ["text",": "], + ["string","\"32021554@N04\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"secret\""], + ["text",": "], + ["string","\"0c1cfdf64c\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"server\""], + ["text",": "], + ["string","\"5078\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"title\""], + ["text",": "], + ["string","\"7020 mandy cat\""] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text",","] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","\"farm\""], + ["text",": "], + ["string","\"3\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"id\""], + ["text",": "], + ["string","\"5856171774\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfamily\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"isfriend\""], + ["text",": "], + ["string","\"0\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"ispublic\""], + ["text",": "], + ["string","\"1\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"owner\""], + ["text",": "], + ["string","\"32021554@N04\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"secret\""], + ["text",": "], + ["string","\"7f5a3180ab\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"server\""], + ["text",": "], + ["string","\"2696\""], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","\"title\""], + ["text",": "], + ["string","\"7448 bobby cat\""] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","]"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_jsoniq.json b/public/lib/ace/mode/_test/tokens_jsoniq.json new file mode 100644 index 0000000..0f4ee6e --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_jsoniq.json @@ -0,0 +1,4 @@ +[[ + "[\"start\"]", + ["support.function","TODO"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_jsp.json b/public/lib/ace/mode/_test/tokens_jsp.json new file mode 100644 index 0000000..7b0d2f4 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_jsp.json @@ -0,0 +1,435 @@ +[[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "js-start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "js-start", + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"abc\""], + ["punctuation.operator",";"] +],[ + "js-start", + ["text"," "], + ["storage.type","function"], + ["text"," "], + ["identifier","y"], + ["text"," "], + ["paren.lparen","{"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "css-start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.style.tag-name.xml","style"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "css-ruleset", + ["text"," "], + ["variable",".class"], + ["text"," "], + ["paren.lparen","{"] +],[ + "css-ruleset", + ["text"," "], + ["support.type","background"], + ["text",": "], + ["constant.numeric","#124356"], + ["text",";"] +],[ + "css-start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," Today's date: "], + ["meta.tag","<%"], + ["keyword.operator","="], + ["text"," "], + ["lparen","("], + ["keyword","new"], + ["text"," "], + ["identifier","java"], + ["text","."], + ["identifier","util"], + ["text","."], + ["identifier","Date"], + ["lparen","("], + ["rparen","))"], + ["text","."], + ["identifier","toLocaleString"], + ["lparen","("], + ["rparen",")"], + ["meta.tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag","<%"], + ["keyword.operator","!"], + ["text"," "], + ["keyword","int"], + ["text"," "], + ["identifier","i"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["text","; "], + ["meta.tag","%>"] +],[ + "jsp-start", + ["text.xml"," "], + ["meta.tag",""] +],[ + "jsp-start", + ["text"," "], + ["keyword","int"], + ["text"," "], + ["identifier","j"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","10"], + ["text",";"] +],[ + "start", + ["text"," "], + ["meta.tag",""] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["comment","<%-- This is JSP comment --%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag","<%@"], + ["text"," "], + ["identifier","directive"], + ["text"," "], + ["identifier","attribute"], + ["keyword.operator","="], + ["string","\"value\""], + ["text"," "], + ["meta.tag","%>"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Select Languages:"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","form"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","ACTION"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"jspCheckBox.jsp\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"Java\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," Java"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\".NET\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," .NET"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"PHP\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," PHP"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"C/C++\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," C/C++"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"PERL\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," PERL "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"submit\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"Submit\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "jsp-start", + ["text.xml"," "], + ["meta.tag","<%"] +],[ + "jsp-start", + ["text"," "], + ["support.function","String"], + ["text"," "], + ["identifier","select"], + ["lparen","["], + ["rparen","]"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["variable.language","request"], + ["text","."], + ["identifier","getParameterValues"], + ["lparen","("], + ["string","\"id\""], + ["rparen",")"], + ["text","; "] +],[ + "jsp-start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["lparen","("], + ["identifier","select"], + ["text"," "], + ["keyword.operator","!="], + ["text"," "], + ["constant.language","null"], + ["text"," "], + ["keyword.operator","&&"], + ["text"," "], + ["identifier","select"], + ["text","."], + ["identifier","length"], + ["text"," "], + ["keyword.operator","!="], + ["text"," "], + ["constant.numeric","0"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "jsp-start", + ["text"," "], + ["variable.language","out"], + ["text","."], + ["identifier","println"], + ["lparen","("], + ["string","\"You have selected: \""], + ["rparen",")"], + ["text",";"] +],[ + "jsp-start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["lparen","("], + ["keyword","int"], + ["text"," "], + ["identifier","i"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["text","; "], + ["identifier","i"], + ["text"," "], + ["keyword.operator","<"], + ["text"," "], + ["identifier","select"], + ["text","."], + ["identifier","length"], + ["text","; "], + ["identifier","i"], + ["keyword.operator","++"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "jsp-start", + ["text"," "], + ["variable.language","out"], + ["text","."], + ["identifier","println"], + ["lparen","("], + ["identifier","select"], + ["lparen","["], + ["identifier","i"], + ["rparen","])"], + ["text","; "] +],[ + "jsp-start", + ["text"," "], + ["rparen","}"] +],[ + "jsp-start", + ["text"," "], + ["rparen","}"] +],[ + "start", + ["text"," "], + ["meta.tag","%>"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_jsx.json b/public/lib/ace/mode/_test/tokens_jsx.json new file mode 100644 index 0000000..d1a740b --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_jsx.json @@ -0,0 +1,51 @@ +[[ + "comment", + ["comment","/*EXPECTED"] +],[ + "comment", + ["comment","hello world!"] +],[ + "start", + ["comment","*/"] +],[ + "start", + ["keyword","class"], + ["text"," "], + ["language.support.class","Test"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","static"], + ["text"," "], + ["storage.type","function"], + ["text"," "], + ["entity.name.function","run"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["punctuation.operator",":"], + ["text"," "], + ["keyword","void"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["comment","// console.log(\"hello world!\");"] +],[ + "start", + ["text"," "], + ["keyword","log"], + ["text"," "], + ["string","\"hello world!\""], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_julia.json b/public/lib/ace/mode/_test/tokens_julia.json new file mode 100644 index 0000000..5aaef6f --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_julia.json @@ -0,0 +1,111 @@ +[[ + "start", + ["keyword.control.julia","for"], + ["text"," op "], + ["keyword.operator.update.julia","="], + ["text"," ("], + ["keyword.operator.ternary.julia",":"], + ["keyword.operator.arithmetic.julia","+"], + ["text",", "], + ["keyword.operator.ternary.julia",":"], + ["keyword.operator.arithmetic.julia","*"], + ["text",", "], + ["keyword.operator.ternary.julia",":"], + ["keyword.operator.bitwise.julia","&"], + ["text",", "], + ["keyword.operator.ternary.julia",":"], + ["keyword.operator.bitwise.julia","|"], + ["text",", "], + ["keyword.operator.ternary.julia",":"], + ["keyword.operator.interpolation.julia","$"], + ["text",")"] +],[ + "start", + ["text"," "], + ["variable.macro.julia","@eval"], + ["text"," ("], + ["keyword.operator.interpolation.julia","$"], + ["text","op)(a,b,c) "], + ["keyword.operator.update.julia","="], + ["text"," ("], + ["keyword.operator.interpolation.julia","$"], + ["text","op)(("], + ["keyword.operator.interpolation.julia","$"], + ["text","op)(a,b),c)"] +],[ + "start", + ["keyword.control.julia","end"] +],[ + "start" +],[ + "start", + ["text","v "], + ["keyword.operator.update.julia","="], + ["text"," "], + ["variable","α"], + ["keyword.operator.transposed-variable.julia","'"], + ["text",";"] +],[ + "start", + ["keyword.other.julia","function"], + ["meta.function.julia"," "], + ["entity.name.function.julia","g"], + ["text","("], + ["text","x,y)"] +],[ + "start", + ["text"," "], + ["keyword.control.julia","return"], + ["text"," x "], + ["keyword.operator.arithmetic.julia","*"], + ["text"," y"] +],[ + "start", + ["text"," x "], + ["keyword.operator.arithmetic.julia","+"], + ["text"," y"] +],[ + "start", + ["keyword.control.julia","end"] +],[ + "start" +],[ + "start", + ["support.function.julia","cd"], + ["text","("], + ["punctuation.definition.string.begin.julia","\""], + ["string.quoted.double.julia","data"], + ["punctuation.definition.string.end.julia","\""], + ["text",") "], + ["keyword.control.julia","do"] +],[ + "start", + ["text"," "], + ["support.function.julia","open"], + ["text","("], + ["punctuation.definition.string.begin.julia","\""], + ["string.quoted.double.julia","outfile"], + ["punctuation.definition.string.end.julia","\""], + ["text",", "], + ["punctuation.definition.string.begin.julia","\""], + ["string.quoted.double.julia","w"], + ["punctuation.definition.string.end.julia","\""], + ["text",") "], + ["keyword.control.julia","do"], + ["text"," f"] +],[ + "start", + ["text"," "], + ["support.function.julia","write"], + ["text","("], + ["text","f, data)"] +],[ + "start", + ["text"," "], + ["keyword.control.julia","end"] +],[ + "start", + ["keyword.control.julia","end"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_latex.json b/public/lib/ace/mode/_test/tokens_latex.json new file mode 100644 index 0000000..52508e0 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_latex.json @@ -0,0 +1,127 @@ +[[ + "start", + ["keyword","\\usepackage"], + ["lparen","{"], + ["storage.type","amsmath"], + ["rparen","}"] +],[ + "start", + ["storage.type","\\title"], + ["lparen","{"], + ["storage.type","\\LaTeX"], + ["rparen","}"] +],[ + "start", + ["storage.type","\\date"], + ["lparen","{"], + ["rparen","}"] +],[ + "start", + ["storage.type","\\begin"], + ["lparen","{"], + ["variable.parameter","document"], + ["rparen","}"] +],[ + "start", + ["text"," "], + ["storage.type","\\maketitle"] +],[ + "start", + ["text"," "], + ["storage.type","\\LaTeX"], + ["lparen","{"], + ["rparen","}"], + ["text"," is a document preparation system for the "], + ["storage.type","\\TeX"], + ["lparen","{"], + ["rparen","}"] +],[ + "start", + ["text"," typesetting program. It offers programmable desktop publishing"] +],[ + "start", + ["text"," features and extensive facilities for automating most aspects of"] +],[ + "start", + ["text"," typesetting and desktop publishing, including numbering and"] +],[ + "start", + ["text"," cross-referencing, tables and figures, page layout, bibliographies,"] +],[ + "start", + ["text"," and much more. "], + ["storage.type","\\LaTeX"], + ["lparen","{"], + ["rparen","}"], + ["text"," was originally written in 1984 by Leslie"] +],[ + "start", + ["text"," Lamport and has become the dominant method for using "], + ["storage.type","\\TeX"], + ["text","; few"] +],[ + "start", + ["text"," people write in plain "], + ["storage.type","\\TeX"], + ["lparen","{"], + ["rparen","}"], + ["text"," anymore. The current version is"] +],[ + "start", + ["text"," "], + ["storage.type","\\LaTeXe"], + ["text","."] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["comment","% This is a comment; it will not be shown in the final output."] +],[ + "start", + ["text"," "], + ["comment","% The following shows a little of the typesetting power of LaTeX:"] +],[ + "start", + ["text"," "], + ["storage.type","\\begin"], + ["lparen","{"], + ["variable.parameter","align"], + ["rparen","}"] +],[ + "start", + ["text"," E &= mc^2 "], + ["constant.character.escape","\\\\"] +],[ + "start", + ["text"," m &= "], + ["storage.type","\\frac"], + ["lparen","{"], + ["text","m_0"], + ["rparen","}"], + ["lparen","{"], + ["storage.type","\\sqrt"], + ["lparen","{"], + ["text","1-"], + ["storage.type","\\frac"], + ["lparen","{"], + ["text","v^2"], + ["rparen","}"], + ["lparen","{"], + ["text","c^2"], + ["rparen","}}}"] +],[ + "start", + ["text"," "], + ["storage.type","\\end"], + ["lparen","{"], + ["variable.parameter","align"], + ["rparen","}"] +],[ + "start", + ["storage.type","\\end"], + ["lparen","{"], + ["variable.parameter","document"], + ["rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_less.json b/public/lib/ace/mode/_test/tokens_less.json new file mode 100644 index 0000000..5e7f60b --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_less.json @@ -0,0 +1,224 @@ +[[ + "start", + ["comment","/* styles.less */"] +],[ + "start" +],[ + "start", + ["variable","@base"], + ["text",": "], + ["constant.numeric","#f938ab"], + ["text",";"] +],[ + "start" +],[ + "start", + ["variable.language",".box-shadow"], + ["paren.lparen","("], + ["variable","@style"], + ["text",", "], + ["variable","@c"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","when"], + ["text"," "], + ["paren.lparen","("], + ["support.function","iscolor"], + ["paren.lparen","("], + ["variable","@c"], + ["paren.rparen","))"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.type.property","box-shadow"], + ["text",":"], + ["text"," "], + ["variable","@style"], + ["text"," "], + ["variable","@c"], + ["text",";"] +],[ + "start", + ["text"," "], + ["support.type.unknownProperty","-webkit-box-shadow"], + ["text",":"], + ["text"," "], + ["variable","@style"], + ["text"," "], + ["variable","@c"], + ["text",";"] +],[ + "start", + ["text"," "], + ["support.type.unknownProperty","-moz-box-shadow"], + ["text",":"], + ["text"," "], + ["variable","@style"], + ["text"," "], + ["variable","@c"], + ["text",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["variable.language",".box-shadow"], + ["paren.lparen","("], + ["variable","@style"], + ["text",", "], + ["variable","@alpha"], + ["text",": "], + ["constant.numeric","50"], + ["keyword","%"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","when"], + ["text"," "], + ["paren.lparen","("], + ["support.function","isnumber"], + ["paren.lparen","("], + ["variable","@alpha"], + ["paren.rparen","))"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable.language",".box-shadow"], + ["paren.lparen","("], + ["variable","@style"], + ["text",", "], + ["support.function","rgba"], + ["paren.lparen","("], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0"], + ["text",", "], + ["variable","@alpha"], + ["paren.rparen","))"], + ["text",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment","// Box styles"] +],[ + "start", + ["variable.language",".box"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "] +],[ + "start", + ["text"," "], + ["support.type.property","color"], + ["text",":"], + ["text"," "], + ["support.function","saturate"], + ["paren.lparen","("], + ["variable","@base"], + ["text",", "], + ["constant.numeric","5"], + ["keyword","%"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text"," "], + ["support.type.property","border-color"], + ["text",":"], + ["text"," "], + ["support.function","lighten"], + ["paren.lparen","("], + ["variable","@base"], + ["text",", "], + ["constant.numeric","30"], + ["keyword","%"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["identifier","div"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["variable.language",".box-shadow"], + ["paren.lparen","("], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","5"], + ["keyword","px"], + ["text",", "], + ["constant.numeric","30"], + ["keyword","%"], + ["paren.rparen",")"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["identifier","a"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.type.property","color"], + ["text",":"], + ["text"," "], + ["variable","@base"], + ["text",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","&"], + ["variable.language",":hover"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.type.property","color"], + ["text",":"], + ["text"," "], + ["support.function","lighten"], + ["paren.lparen","("], + ["variable","@base"], + ["text",", "], + ["constant.numeric","50"], + ["keyword","%"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_liquid.json b/public/lib/ace/mode/_test/tokens_liquid.json new file mode 100644 index 0000000..30d003c --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_liquid.json @@ -0,0 +1,551 @@ +[[ + "start", + ["text.xml","The following examples can be found in full at http://liquidmarkup.org/"] +],[ + "start" +],[ + "start", + ["text.xml","Liquid is an extraction from the e-commerce system Shopify."] +],[ + "start", + ["text.xml","Shopify powers many thousands of e-commerce stores which all call for unique designs."] +],[ + "start", + ["text.xml","For this we developed Liquid which allows our customers complete design freedom while"] +],[ + "start", + ["text.xml","maintaining the integrity of our servers."] +],[ + "start" +],[ + "start", + ["text.xml","Liquid has been in production use since June 2006 and is now used by many other"] +],[ + "start", + ["text.xml","hosted web applications."] +],[ + "start" +],[ + "start", + ["text.xml","It was developed for usage in Ruby on Rails web applications and integrates seamlessly"] +],[ + "start", + ["text.xml","as a plugin but it also works excellently as a stand alone library."] +],[ + "start" +],[ + "start", + ["text.xml","Here's what it looks like:"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","ul"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"products\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","for"], + ["text"," "], + ["identifier","product"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["identifier","products"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","li"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["variable","{{"], + ["text"," "], + ["identifier","product"], + ["text","."], + ["identifier","title"], + ["text"," "], + ["variable","}}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," Only "], + ["variable","{{"], + ["text"," "], + ["identifier","product"], + ["text","."], + ["identifier","price"], + ["text"," | "], + ["identifier","format_as_money"], + ["text"," "], + ["variable","}}"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["variable","{{"], + ["text"," "], + ["identifier","product"], + ["text","."], + ["identifier","description"], + ["text"," | "], + ["identifier","prettyprint"], + ["text"," | "], + ["support.function","truncate"], + ["text",": "], + ["constant.numeric","200"], + ["text"," "], + ["variable","}}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","endfor"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start" +],[ + "start", + ["text.xml","Some more features include:"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Filters"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," The word \"tobi\" in uppercase: "], + ["variable","{{"], + ["text"," "], + ["string","'tobi'"], + ["text"," | "], + ["support.function","upcase"], + ["text"," "], + ["variable","}}"], + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","The word \"tobi\" has "], + ["variable","{{"], + ["text"," "], + ["string","'tobi'"], + ["text"," | "], + ["support.function","size"], + ["text"," "], + ["variable","}}"], + ["text.xml"," letters! "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Change \"Hello world\" to \"Hi world\": "], + ["variable","{{"], + ["text"," "], + ["string","'Hello world'"], + ["text"," | "], + ["support.function","replace"], + ["text",": "], + ["string","'Hello'"], + ["text",", "], + ["string","'Hi'"], + ["text"," "], + ["variable","}}"], + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","The date today is "], + ["variable","{{"], + ["text"," "], + ["string","'now'"], + ["text"," | "], + ["support.function","date"], + ["text",": "], + ["string","\"%Y %b %d\""], + ["text"," "], + ["variable","}}"], + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","If"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","if"], + ["text"," "], + ["identifier","user"], + ["text","."], + ["identifier","name"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["string","'tobi'"], + ["text"," "], + ["identifier","or"], + ["text"," "], + ["identifier","user"], + ["text","."], + ["identifier","name"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["string","'marc'"], + ["text"," "], + ["variable","%}"], + ["text.xml"," "] +],[ + "start", + ["text.xml"," hi marc or tobi"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","endif"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Case"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","case"], + ["text"," "], + ["identifier","template"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","when"], + ["text"," "], + ["string","'index'"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," Welcome"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","when"], + ["text"," "], + ["string","'product'"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," "], + ["variable","{{"], + ["text"," "], + ["identifier","product"], + ["text","."], + ["identifier","vendor"], + ["text"," | "], + ["identifier","link_to_vendor"], + ["text"," "], + ["variable","}}"], + ["text.xml"," / "], + ["variable","{{"], + ["text"," "], + ["identifier","product"], + ["text","."], + ["identifier","title"], + ["text"," "], + ["variable","}}"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," "], + ["variable","{{"], + ["text"," "], + ["identifier","page_title"], + ["text"," "], + ["variable","}}"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","endcase"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","For Loops"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","for"], + ["text"," "], + ["identifier","item"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["identifier","array"], + ["text"," "], + ["variable","%}"], + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["variable","{{"], + ["text"," "], + ["identifier","item"], + ["text"," "], + ["variable","}}"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","endfor"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Tables"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","tablerow"], + ["text"," "], + ["identifier","item"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["identifier","items"], + ["text"," "], + ["identifier","cols"], + ["text",": "], + ["constant.numeric","3"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable.language","tablerowloop"], + ["text","."], + ["identifier","col_first"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," First column: "], + ["variable","{{"], + ["text"," "], + ["identifier","item"], + ["text","."], + ["identifier","variable"], + ["text"," "], + ["variable","}}"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," Different column: "], + ["variable","{{"], + ["text"," "], + ["identifier","item"], + ["text","."], + ["identifier","variable"], + ["text"," "], + ["variable","}}"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","endif"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["text.xml"," "], + ["variable","{%"], + ["text"," "], + ["keyword","endtablerow"], + ["text"," "], + ["variable","%}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_lisp.json b/public/lib/ace/mode/_test/tokens_lisp.json new file mode 100644 index 0000000..2e70a55 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_lisp.json @@ -0,0 +1,248 @@ +[[ + "start", + ["text","("], + ["storage.type.function-type.lisp","defun"], + ["text"," "], + ["entity.name.function.lisp","prompt-for-cd"], + ["text"," ()"] +],[ + "start", + ["text"," "], + ["string","\"Prompts"] +],[ + "start", + ["text"," "], + ["identifier","for"], + ["text"," "], + ["identifier","CD"], + ["text","\""] +],[ + "start", + ["text"," ("], + ["identifier","prompt"], + ["text","-"], + ["identifier","read"], + ["text"," "], + ["string","\"Title\""], + ["text"," "], + ["constant.numeric","1.53"], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","2"], + ["text","/"], + ["constant.numeric","4"], + ["text"," "], + ["constant.numeric","1.7"], + ["text"," "], + ["constant.numeric","1.7e0"], + ["text"," "], + ["constant.numeric","2.9E-4"], + ["text"," "], + ["constant.numeric","+42"], + ["text"," "], + ["constant.numeric","-7"], + ["text"," "], + ["punctuation.definition.constant.character.lisp","#"], + ["constant.character.lisp","b001"], + ["text"," "], + ["punctuation.definition.constant.character.lisp","#"], + ["constant.character.lisp","b001/100"], + ["text"," "], + ["punctuation.definition.constant.character.lisp","#"], + ["constant.character.lisp","o777"], + ["text"," "], + ["punctuation.definition.constant.character.lisp","#"], + ["constant.character.lisp","O777"], + ["text"," "], + ["punctuation.definition.constant.character.lisp","#"], + ["constant.character.lisp","xabc55"], + ["text"," "], + ["punctuation.definition.constant.character.lisp","#"], + ["constant.character.lisp","c"], + ["text","("], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","-5.6"], + ["text","))"] +],[ + "start", + ["text"," ("], + ["identifier","prompt"], + ["text","-"], + ["identifier","read"], + ["text"," "], + ["string","\"Artist\""], + ["text"," &"], + ["identifier","rest"], + ["text",")"] +],[ + "start", + ["text"," ("], + ["keyword.operator","or"], + ["text"," ("], + ["identifier","parse"], + ["text","-"], + ["identifier","integer"], + ["text"," ("], + ["identifier","prompt"], + ["text","-"], + ["identifier","read"], + ["text"," "], + ["string","\"Rating\""], + ["text",") :"], + ["identifier","junk"], + ["text","-"], + ["identifier","allowed"], + ["text"," "], + ["support.function","t"], + ["text",") "], + ["constant.numeric","0"], + ["text",")"] +],[ + "start", + ["text"," ("], + ["keyword.control","if"], + ["text"," "], + ["identifier","x"], + ["text"," ("], + ["support.function","format"], + ["text"," "], + ["support.function","t"], + ["text"," "], + ["string","\"yes\""], + ["text",") ("], + ["support.function","format"], + ["text"," "], + ["support.function","t"], + ["text"," "], + ["string","\"no\""], + ["text"," "], + ["constant.language","nil"], + ["text",") "], + ["comment",";and here comment"] +],[ + "start", + ["text"," ) "], + ["constant.numeric","0xFFLL"], + ["text"," "], + ["constant.numeric","-23ull"] +],[ + "start", + ["text"," "], + ["comment",";; second line comment"] +],[ + "start", + ["text"," '(+ "], + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","2"], + ["text",")"] +],[ + "start", + ["text"," ("], + ["identifier","defvar"], + ["text"," "], + ["punctuation.definition.variable.lisp","*"], + ["variable.other.global.lisp","lines"], + ["punctuation.definition.variable.lisp","*"], + ["text",") "], + ["comment","; list of all lines"] +],[ + "start", + ["text"," ("], + ["identifier","position"], + ["text","-"], + ["keyword.control","if"], + ["text","-"], + ["identifier","not"], + ["text"," "], + ["punctuation.definition.constant.character.lisp","#"], + ["constant.character.lisp","'sys::whitespacep"], + ["text"," "], + ["identifier","line"], + ["text"," :"], + ["identifier","start"], + ["text"," "], + ["identifier","beg"], + ["text","))"] +],[ + "start", + ["text"," ("], + ["support.function","quote"], + ["text"," ("], + ["identifier","privet"], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","2"], + ["text"," "], + ["constant.numeric","3"], + ["text","))"] +],[ + "start", + ["text"," '("], + ["identifier","hello"], + ["text"," "], + ["identifier","world"], + ["text",")"] +],[ + "start", + ["text"," (* "], + ["constant.numeric","5"], + ["text"," "], + ["constant.numeric","7"], + ["text",")"] +],[ + "start", + ["text"," ("], + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","2"], + ["text"," "], + ["constant.numeric","34"], + ["text"," "], + ["constant.numeric","5"], + ["text",")"] +],[ + "start", + ["text"," (:"], + ["identifier","use"], + ["text"," "], + ["string","\"aaaa\""], + ["text",")"] +],[ + "start", + ["text"," ("], + ["keyword.control","let"], + ["text"," (("], + ["identifier","x"], + ["text"," "], + ["constant.numeric","10"], + ["text",") ("], + ["identifier","y"], + ["text"," "], + ["constant.numeric","20"], + ["text","))"] +],[ + "start", + ["text"," ("], + ["identifier","print"], + ["text"," (+ "], + ["identifier","x"], + ["text"," "], + ["identifier","y"], + ["text","))"] +],[ + "start", + ["text"," ) "], + ["support.function","LAmbDa"] +],[ + "start" +],[ + "start", + ["text"," "], + ["string","\"asdad"], + ["constant.character.escape.lisp","\\0"], + ["string","eqweqe\""] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_livescript.json b/public/lib/ace/mode/_test/tokens_livescript.json new file mode 100644 index 0000000..c2bd83d --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_livescript.json @@ -0,0 +1,6 @@ +[[ + "start", + ["comment","# comment"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_logiql.json b/public/lib/ace/mode/_test/tokens_logiql.json new file mode 100644 index 0000000..5f7eda4 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_logiql.json @@ -0,0 +1,190 @@ +[[ + "start", + ["comment.single","// ancestors"] +],[ + "start", + ["entity.name","parentof"], + ["text","("], + ["string","\"douglas\""], + ["keyword.other",","], + ["text"," "], + ["string","\"john\""], + ["text",")"], + ["keyword.end","."] +],[ + "start", + ["entity.name","parentof"], + ["text","("], + ["string","\"john\""], + ["keyword.other",","], + ["text"," "], + ["string","\"bob\""], + ["text",")"], + ["keyword.end","."] +],[ + "start", + ["entity.name","parentof"], + ["text","("], + ["string","\"bob\""], + ["keyword.other",","], + ["text"," "], + ["string","\"ebbon\""], + ["text",")"], + ["keyword.end","."] +],[ + "start" +],[ + "start", + ["entity.name","parentof"], + ["text","("], + ["string","\"douglas\""], + ["keyword.other",","], + ["text"," "], + ["string","\"jane\""], + ["text",")"], + ["keyword.end","."] +],[ + "start", + ["entity.name","parentof"], + ["text","("], + ["string","\"jane\""], + ["keyword.other",","], + ["text"," "], + ["string","\"jan\""], + ["text",")"], + ["keyword.end","."] +],[ + "start" +],[ + "start", + ["entity.name","ancestorof"], + ["text","("], + ["variable.parameter","A"], + ["keyword.other",","], + ["text"," "], + ["variable.parameter","B"], + ["text",") "], + ["keyword.start","<-"], + ["text"," "], + ["entity.name","parentof"], + ["text","("], + ["variable.parameter","A"], + ["keyword.other",","], + ["text"," "], + ["variable.parameter","B"], + ["text",")"], + ["keyword.end","."] +],[ + "start", + ["entity.name","ancestorof"], + ["text","("], + ["variable.parameter","A"], + ["keyword.other",","], + ["text"," "], + ["variable.parameter","C"], + ["text",") "], + ["keyword.start","<-"], + ["text"," "], + ["entity.name","ancestorof"], + ["text","("], + ["variable.parameter","A"], + ["keyword.other",","], + ["text"," "], + ["variable.parameter","B"], + ["text",")"], + ["keyword.other",","], + ["text"," "], + ["entity.name","parentof"], + ["text","("], + ["variable.parameter","B"], + ["keyword.other",","], + ["variable.parameter","C"], + ["text",")"], + ["keyword.end","."] +],[ + "start" +],[ + "start", + ["entity.name","grandparentof"], + ["text","("], + ["variable.parameter","A"], + ["keyword.other",","], + ["text"," "], + ["variable.parameter","B"], + ["text",") "], + ["keyword.start","<-"], + ["text"," "], + ["entity.name","parentof"], + ["text","("], + ["variable.parameter","A"], + ["keyword.other",","], + ["text"," "], + ["variable.parameter","C"], + ["text",")"], + ["keyword.other",","], + ["text"," "], + ["entity.name","parentof"], + ["text","("], + ["variable.parameter","C"], + ["keyword.other",","], + ["text"," "], + ["variable.parameter","B"], + ["text",")"], + ["keyword.end","."] +],[ + "start" +],[ + "start", + ["entity.name","cousins"], + ["text","("], + ["variable.parameter","A"], + ["keyword.other",","], + ["variable.parameter","B"], + ["text",") "], + ["keyword.start","<-"], + ["text"," "], + ["entity.name","grandparentof"], + ["text","("], + ["variable.parameter","C"], + ["keyword.other",","], + ["variable.parameter","A"], + ["text",")"], + ["keyword.other",","], + ["text"," "], + ["entity.name","grandparentof"], + ["text","("], + ["variable.parameter","C"], + ["keyword.other",","], + ["variable.parameter","B"], + ["text",")"], + ["keyword.end","."] +],[ + "start" +],[ + "start", + ["entity.name","parentof"], + ["text","["], + ["entity.name.type.logicblox","`arg"], + ["text","]("], + ["variable.parameter","A"], + ["keyword.other",","], + ["text"," "], + ["variable.parameter","B"], + ["text",") "], + ["keyword.start","->"], + ["text"," "], + ["entity.name","int"], + ["text","["], + ["constant.numeric","32"], + ["text","]("], + ["variable.parameter","A"], + ["text",")"], + ["keyword.other",","], + ["text"," "], + ["keyword.other","!"], + ["entity.name","string"], + ["text","("], + ["variable.parameter","B"], + ["text",")"], + ["keyword.end","."] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_lsl.json b/public/lib/ace/mode/_test/tokens_lsl.json new file mode 100644 index 0000000..2248a60 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_lsl.json @@ -0,0 +1,503 @@ +[[ + "comment", + ["comment.block.begin.lsl","/*"] +],[ + "comment", + ["comment.block.lsl"," Testing syntax highlighting"] +],[ + "comment", + ["comment.block.lsl"," of Ace Editor"] +],[ + "comment", + ["comment.block.lsl"," for the Linden Scripting Language"] +],[ + "start", + ["comment.block.end.lsl","*/"] +],[ + "start" +],[ + "start", + ["storage.type.lsl","integer"], + ["text.lsl"," "], + ["identifier","someIntNormal"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.numeric.lsl","3672"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["storage.type.lsl","integer"], + ["text.lsl"," "], + ["identifier","someIntHex"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.numeric.lsl","0x00000000"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["storage.type.lsl","integer"], + ["text.lsl"," "], + ["identifier","someIntMath"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.language.float.lsl","PI_BY_TWO"], + ["punctuation.operator.lsl",";"] +],[ + "start" +],[ + "start", + ["storage.type.lsl","integer"], + ["text.lsl"," "], + ["invalid.illegal.lsl","event"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.numeric.lsl","5673"], + ["punctuation.operator.lsl",";"], + ["text.lsl"," "], + ["comment.line.double-slash.lsl","// invalid.illegal"] +],[ + "start" +],[ + "start", + ["storage.type.lsl","key"], + ["text.lsl"," "], + ["identifier","someKeyTexture"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.language.string.lsl","TEXTURE_DEFAULT"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["storage.type.lsl","string"], + ["text.lsl"," "], + ["identifier","someStringSpecial"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.language.string.lsl","EOF"], + ["punctuation.operator.lsl",";"] +],[ + "start" +],[ + "start", + ["identifier","some_user_defined_function_without_return_type"], + ["paren.lparen.lsl","("], + ["storage.type.lsl","string"], + ["text.lsl"," "], + ["identifier","inputAsString"], + ["paren.rparen.lsl",")"] +],[ + "start", + ["paren.lparen.lsl","{"] +],[ + "start", + ["text.lsl"," "], + ["support.function.lsl","llSay"], + ["paren.lparen.lsl","("], + ["constant.language.integer.lsl","PUBLIC_CHANNEL"], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["identifier","inputAsString"], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["paren.rparen.lsl","}"] +],[ + "start" +],[ + "start", + ["storage.type.lsl","string"], + ["text.lsl"," "], + ["identifier","user_defined_function_returning_a_string"], + ["paren.lparen.lsl","("], + ["storage.type.lsl","key"], + ["text.lsl"," "], + ["identifier","inputAsKey"], + ["paren.rparen.lsl",")"] +],[ + "start", + ["paren.lparen.lsl","{"] +],[ + "start", + ["text.lsl"," "], + ["keyword.control.lsl","return"], + ["text.lsl"," "], + ["paren.lparen.lsl","("], + ["storage.type.lsl","string"], + ["paren.rparen.lsl",")"], + ["identifier","inputAsKey"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["paren.rparen.lsl","}"] +],[ + "start" +],[ + "start", + ["entity.name.state.lsl","default"] +],[ + "start", + ["paren.lparen.lsl","{"] +],[ + "start", + ["text.lsl"," "], + ["support.function.event.lsl","state_entry"], + ["paren.lparen.lsl","("], + ["paren.rparen.lsl",")"] +],[ + "start", + ["text.lsl"," "], + ["paren.lparen.lsl","{"] +],[ + "start", + ["text.lsl"," "], + ["storage.type.lsl","key"], + ["text.lsl"," "], + ["identifier","someKey"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.language.string.lsl","NULL_KEY"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["identifier","someKey"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["support.function.lsl","llGetOwner"], + ["paren.lparen.lsl","("], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",";"] +],[ + "start" +],[ + "start", + ["text.lsl"," "], + ["storage.type.lsl","string"], + ["text.lsl"," "], + ["identifier","someString"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["identifier","user_defined_function_returning_a_string"], + ["paren.lparen.lsl","("], + ["identifier","someKey"], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",";"] +],[ + "start" +],[ + "start", + ["text.lsl"," "], + ["identifier","some_user_defined_function_without_return_type"], + ["paren.lparen.lsl","("], + ["identifier","someString"], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["paren.rparen.lsl","}"] +],[ + "start" +],[ + "start", + ["text.lsl"," "], + ["support.function.event.lsl","touch_start"], + ["paren.lparen.lsl","("], + ["storage.type.lsl","integer"], + ["text.lsl"," "], + ["identifier","num_detected"], + ["paren.rparen.lsl",")"] +],[ + "start", + ["text.lsl"," "], + ["paren.lparen.lsl","{"] +],[ + "start", + ["text.lsl"," "], + ["storage.type.lsl","list"], + ["text.lsl"," "], + ["identifier","agentsInRegion"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["support.function.lsl","llGetAgentList"], + ["paren.lparen.lsl","("], + ["constant.language.integer.lsl","AGENT_LIST_REGION"], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["paren.lparen.lsl","["], + ["paren.rparen.lsl","])"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["storage.type.lsl","integer"], + ["text.lsl"," "], + ["identifier","numOfAgents"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["support.function.lsl","llGetListLength"], + ["paren.lparen.lsl","("], + ["identifier","agentsInRegion"], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",";"] +],[ + "start" +],[ + "start", + ["text.lsl"," "], + ["storage.type.lsl","integer"], + ["text.lsl"," "], + ["identifier","index"], + ["punctuation.operator.lsl",";"], + ["text.lsl"," "], + ["comment.line.double-slash.lsl","// defaults to 0"] +],[ + "start", + ["text.lsl"," "], + ["keyword.control.lsl","for"], + ["text.lsl"," "], + ["paren.lparen.lsl","("], + ["punctuation.operator.lsl",";"], + ["text.lsl"," "], + ["identifier","index"], + ["text.lsl"," "], + ["keyword.operator.lsl","<="], + ["text.lsl"," "], + ["identifier","numOfAgents"], + ["text.lsl"," "], + ["keyword.operator.lsl","-"], + ["text.lsl"," "], + ["constant.numeric.lsl","1"], + ["punctuation.operator.lsl",";"], + ["text.lsl"," "], + ["identifier","index"], + ["keyword.operator.lsl","++"], + ["paren.rparen.lsl",")"], + ["text.lsl"," "], + ["comment.line.double-slash.lsl","// for each agent in region"] +],[ + "start", + ["text.lsl"," "], + ["paren.lparen.lsl","{"] +],[ + "start", + ["text.lsl"," "], + ["support.function.lsl","llRegionSayTo"], + ["paren.lparen.lsl","("], + ["support.function.lsl","llList2Key"], + ["paren.lparen.lsl","("], + ["identifier","agentsInRegion"], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["identifier","index"], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["constant.language.integer.lsl","PUBLIC_CHANNEL"], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["string.quoted.double.lsl.start","\""], + ["string.quoted.double.lsl","Hello, Avatar!"], + ["string.quoted.double.lsl.end","\""], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["paren.rparen.lsl","}"] +],[ + "start", + ["text.lsl"," "], + ["paren.rparen.lsl","}"] +],[ + "start" +],[ + "start", + ["text.lsl"," "], + ["support.function.event.lsl","touch_end"], + ["paren.lparen.lsl","("], + ["storage.type.lsl","integer"], + ["text.lsl"," "], + ["identifier","num_detected"], + ["paren.rparen.lsl",")"] +],[ + "start", + ["text.lsl"," "], + ["paren.lparen.lsl","{"] +],[ + "start", + ["text.lsl"," "], + ["identifier","someIntNormal"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.numeric.lsl","3672"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["identifier","someIntHex"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.numeric.lsl","0x00000000"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["identifier","someIntMath"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.language.float.lsl","PI_BY_TWO"], + ["punctuation.operator.lsl",";"] +],[ + "start" +],[ + "start", + ["text.lsl"," "], + ["invalid.illegal.lsl","event"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.numeric.lsl","5673"], + ["punctuation.operator.lsl",";"], + ["text.lsl"," "], + ["comment.line.double-slash.lsl","// invalid.illegal"] +],[ + "start" +],[ + "start", + ["text.lsl"," "], + ["identifier","someKeyTexture"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.language.string.lsl","TEXTURE_DEFAULT"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["identifier","someStringSpecial"], + ["text.lsl"," "], + ["keyword.operator.lsl","="], + ["text.lsl"," "], + ["constant.language.string.lsl","EOF"], + ["punctuation.operator.lsl",";"] +],[ + "start" +],[ + "start", + ["text.lsl"," "], + ["reserved.godmode.lsl","llSetInventoryPermMask"], + ["paren.lparen.lsl","("], + ["string.quoted.double.lsl.start","\""], + ["string.quoted.double.lsl","some item"], + ["string.quoted.double.lsl.end","\""], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["constant.language.integer.lsl","MASK_NEXT"], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["constant.language.integer.lsl","PERM_ALL"], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",";"], + ["text.lsl"," "], + ["comment.line.double-slash.lsl","// reserved.godmode"] +],[ + "start" +],[ + "start", + ["text.lsl"," "], + ["support.function.lsl","llWhisper"], + ["paren.lparen.lsl","("], + ["constant.language.integer.lsl","PUBLIC_CHANNEL"], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["string.quoted.double.lsl.start","\""], + ["string.quoted.double.lsl","Leaving "], + ["constant.character.escape.lsl","\\\""], + ["string.quoted.double.lsl","default"], + ["constant.character.escape.lsl","\\\""], + ["string.quoted.double.lsl"," now..."], + ["string.quoted.double.lsl.end","\""], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["entity.name.state.lsl","state other"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["paren.rparen.lsl","}"] +],[ + "start", + ["paren.rparen.lsl","}"] +],[ + "start" +],[ + "start", + ["entity.name.state.lsl","state other"] +],[ + "start", + ["paren.lparen.lsl","{"] +],[ + "start", + ["text.lsl"," "], + ["support.function.event.lsl","state_entry"], + ["paren.lparen.lsl","("], + ["paren.rparen.lsl",")"] +],[ + "start", + ["text.lsl"," "], + ["paren.lparen.lsl","{"] +],[ + "start", + ["text.lsl"," "], + ["support.function.lsl","llWhisper"], + ["paren.lparen.lsl","("], + ["constant.language.integer.lsl","PUBLIC_CHANNEL"], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["string.quoted.double.lsl.start","\""], + ["string.quoted.double.lsl","Entered "], + ["constant.character.escape.lsl","\\\""], + ["string.quoted.double.lsl","state other"], + ["constant.character.escape.lsl","\\\""], + ["string.quoted.double.lsl",", returning to "], + ["constant.character.escape.lsl","\\\""], + ["string.quoted.double.lsl","default"], + ["constant.character.escape.lsl","\\\""], + ["string.quoted.double.lsl"," again..."], + ["string.quoted.double.lsl.end","\""], + ["paren.rparen.lsl",")"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["entity.name.state.lsl","state default"], + ["punctuation.operator.lsl",";"] +],[ + "start", + ["text.lsl"," "], + ["paren.rparen.lsl","}"] +],[ + "start", + ["paren.rparen.lsl","}"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_lua.json b/public/lib/ace/mode/_test/tokens_lua.json new file mode 100644 index 0000000..cc6d849 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_lua.json @@ -0,0 +1,348 @@ +[[ + ["bracketedComment",2,"start"], + ["comment","--[[--"] +],[ + ["bracketedComment",2,"start"], + ["comment","num_args takes in 5.1 byte code and extracts the number of arguments"] +],[ + ["bracketedComment",2,"start"], + ["comment","from its function header."] +],[ + "start", + ["comment","--]]--"] +],[ + "start" +],[ + "start", + ["keyword","function"], + ["text"," "], + ["identifier","int"], + ["paren.lparen","("], + ["identifier","t"], + ["paren.rparen",")"] +],[ + "start", + ["text","\t"], + ["keyword","return"], + ["text"," "], + ["identifier","t"], + ["keyword.operator",":"], + ["support.function","byte"], + ["paren.lparen","("], + ["constant.numeric","1"], + ["paren.rparen",")"], + ["keyword.operator","+"], + ["identifier","t"], + ["keyword.operator",":"], + ["support.function","byte"], + ["paren.lparen","("], + ["constant.numeric","2"], + ["paren.rparen",")"], + ["keyword.operator","*"], + ["constant.numeric","0x100"], + ["keyword.operator","+"], + ["identifier","t"], + ["keyword.operator",":"], + ["support.function","byte"], + ["paren.lparen","("], + ["constant.numeric","3"], + ["paren.rparen",")"], + ["keyword.operator","*"], + ["constant.numeric","0x10000"], + ["keyword.operator","+"], + ["identifier","t"], + ["keyword.operator",":"], + ["support.function","byte"], + ["paren.lparen","("], + ["constant.numeric","4"], + ["paren.rparen",")"], + ["keyword.operator","*"], + ["constant.numeric","0x1000000"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","function"], + ["text"," "], + ["identifier","num_args"], + ["paren.lparen","("], + ["identifier","func"], + ["paren.rparen",")"] +],[ + "start", + ["text","\t"], + ["keyword","local"], + ["text"," "], + ["support.function","dump"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.library","string"], + ["text","."], + ["support.function","dump"], + ["paren.lparen","("], + ["identifier","func"], + ["paren.rparen",")"] +],[ + "start", + ["text","\t"], + ["keyword","local"], + ["text"," "], + ["identifier","offset"], + ["text",", "], + ["identifier","cursor"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","int"], + ["paren.lparen","("], + ["support.function","dump"], + ["keyword.operator",":"], + ["support.function","sub"], + ["paren.lparen","("], + ["constant.numeric","13"], + ["paren.rparen","))"], + ["text",", "], + ["identifier","offset"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","26"] +],[ + "start", + ["text","\t"], + ["comment","--Get the params and var flag (whether there's a ... in the param)"] +],[ + "start", + ["text","\t"], + ["keyword","return"], + ["text"," "], + ["support.function","dump"], + ["keyword.operator",":"], + ["support.function","sub"], + ["paren.lparen","("], + ["identifier","cursor"], + ["paren.rparen",")"], + ["keyword.operator",":"], + ["support.function","byte"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text",", "], + ["support.function","dump"], + ["keyword.operator",":"], + ["support.function","sub"], + ["paren.lparen","("], + ["identifier","cursor"], + ["keyword.operator","+"], + ["constant.numeric","1"], + ["paren.rparen",")"], + ["keyword.operator",":"], + ["support.function","byte"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["comment","-- Usage:"] +],[ + "start", + ["identifier","num_args"], + ["paren.lparen","("], + ["keyword","function"], + ["paren.lparen","("], + ["identifier","a"], + ["text",","], + ["identifier","b"], + ["text",","], + ["identifier","c"], + ["text",","], + ["identifier","d"], + ["text",", "], + ["keyword.operator","..."], + ["paren.rparen",")"], + ["text"," "], + ["keyword","end"], + ["paren.rparen",")"], + ["text"," "], + ["comment","-- return 4, 7"] +],[ + "start" +],[ + "start", + ["comment","-- Python styled string format operator"] +],[ + "start", + ["keyword","local"], + ["text"," "], + ["identifier","gm"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.library","debug"], + ["text","."], + ["support.function","getmetatable"], + ["paren.lparen","("], + ["string","\"\""], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["identifier","gm"], + ["text","."], + ["support.function","__mod"], + ["keyword.operator","="], + ["keyword","function"], + ["paren.lparen","("], + ["variable.language","self"], + ["text",", "], + ["identifier","other"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["support.function","type"], + ["paren.lparen","("], + ["identifier","other"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","~="], + ["text"," "], + ["string","\"table\""], + ["text"," "], + ["keyword","then"], + ["text"," "], + ["identifier","other"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"], + ["identifier","other"], + ["paren.rparen","}"], + ["text"," "], + ["keyword","end"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["identifier","i"], + ["text",","], + ["identifier","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["support.function","ipairs"], + ["paren.lparen","("], + ["identifier","other"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","do"], + ["text"," "], + ["identifier","other"], + ["paren.lparen","["], + ["identifier","i"], + ["paren.rparen","]"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","tostring"], + ["paren.lparen","("], + ["identifier","v"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","end"] +],[ + "start", + ["text"," "], + ["keyword","return"], + ["text"," "], + ["variable.language","self"], + ["keyword.operator",":"], + ["support.function","format"], + ["paren.lparen","("], + ["support.function","unpack"], + ["paren.lparen","("], + ["identifier","other"], + ["paren.rparen","))"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + ["bracketedString",5,"start"], + ["support.function","print"], + ["paren.lparen","("], + ["string.start","[===["] +],[ + ["bracketedString",5,"start"], + ["string"," blah blah %s, (%d %d)"] +],[ + "start", + ["string.end","]===]"], + ["keyword.operator","%"], + ["paren.lparen","{"], + ["string","\"blah\""], + ["text",", "], + ["identifier","num_args"], + ["paren.lparen","("], + ["identifier","int"], + ["paren.rparen",")})"] +],[ + "start" +],[ + ["bracketedComment",3,"start"], + ["comment","--[=[--"] +],[ + ["bracketedComment",3,"start"], + ["comment","table.maxn is deprecated, use # instead."] +],[ + "start", + ["comment","--]=]--"] +],[ + "start", + ["support.function","print"], + ["paren.lparen","("], + ["constant.library","table"], + ["text","."], + ["keyword.deprecated","maxn"], + ["paren.lparen","{"], + ["constant.numeric","1"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["paren.lparen","["], + ["constant.numeric","4"], + ["paren.rparen","]"], + ["keyword.operator","="], + ["constant.numeric","4"], + ["text",","], + ["paren.lparen","["], + ["constant.numeric","8"], + ["paren.rparen","]"], + ["keyword.operator","="], + ["constant.numeric","8"], + ["paren.rparen",")"], + ["text"," "], + ["comment","-- outputs 8 instead of 2"] +],[ + "start" +],[ + "start", + ["support.function","print"], + ["paren.lparen","("], + ["constant.numeric","5"], + ["text"," "], + ["comment","--[[ blah ]]"], + ["paren.rparen",")"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_luapage.json b/public/lib/ace/mode/_test/tokens_luapage.json new file mode 100644 index 0000000..fda36eb --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_luapage.json @@ -0,0 +1,651 @@ +[[ + "doctype", + ["text.xml",""], + ["xml-pe.doctype.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + ["lua-bracketedComment",2,"lua-start"], + ["keyword","<%"], + ["text"," "], + ["comment","--[[--"] +],[ + ["lua-bracketedComment",2,"lua-start"], + ["comment"," index.lp from the Kepler Project's LuaDoc HTML doclet."] +],[ + ["lua-bracketedComment",2,"lua-start"], + ["comment"," http://keplerproject.github.com/luadoc/"] +],[ + "start", + ["comment","--]]"], + ["text"," "], + ["keyword","%>"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Reference"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","link"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","rel"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"stylesheet\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["keyword","<%="], + ["identifier","luadoc"], + ["text","."], + ["identifier","doclet"], + ["text","."], + ["identifier","html"], + ["text","."], + ["identifier","link"], + ["paren.lparen","("], + ["string","\"luadoc.css\""], + ["paren.rparen",")"], + ["keyword","%>"], + ["string.attribute-value.xml","\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"text/css\""], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"] +],[ + "start", + ["text.xml","\t"], + ["comment.start.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"container\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"product\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"product_logo\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"product_name\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","big"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","b"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"product_description\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.start.xml",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"main\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"navigation\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["keyword","<%="], + ["identifier","luadoc"], + ["text","."], + ["identifier","doclet"], + ["text","."], + ["identifier","html"], + ["text","."], + ["identifier","include"], + ["paren.lparen","("], + ["string","\"menu.lp\""], + ["text",", "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","doc"], + ["keyword.operator","="], + ["identifier","doc"], + ["text"," "], + ["paren.rparen","})"], + ["keyword","%>"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.start.xml",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"content\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +],[ + "start" +],[ + "start", + ["keyword","<%if"], + ["text"," "], + ["keyword","not"], + ["text"," "], + ["identifier","options"], + ["text","."], + ["identifier","nomodules"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["keyword.operator","#"], + ["identifier","doc"], + ["text","."], + ["identifier","modules"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["keyword","then%>"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Modules"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","table"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"module_list\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["comment.start.xml",""] +],[ + "start", + ["keyword","<%for"], + ["text"," "], + ["identifier","_"], + ["text",", "], + ["identifier","modulename"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["support.function","ipairs"], + ["paren.lparen","("], + ["identifier","doc"], + ["text","."], + ["identifier","modules"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","do%>"] +],[ + "start", + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml","\t\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"name\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["keyword","<%="], + ["identifier","luadoc"], + ["text","."], + ["identifier","doclet"], + ["text","."], + ["identifier","html"], + ["text","."], + ["identifier","module_link"], + ["paren.lparen","("], + ["identifier","modulename"], + ["text",", "], + ["identifier","doc"], + ["paren.rparen",")"], + ["keyword","%>"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["keyword","<%="], + ["identifier","modulename"], + ["keyword","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml","\t\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"summary\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["keyword","<%="], + ["identifier","doc"], + ["text","."], + ["identifier","modules"], + ["paren.lparen","["], + ["identifier","modulename"], + ["paren.rparen","]"], + ["text","."], + ["identifier","summary"], + ["keyword","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml","\t"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["keyword","<%end%>"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["keyword","<%end%>"] +],[ + "start" +],[ + "start" +],[ + "start" +],[ + "start", + ["keyword","<%if"], + ["text"," "], + ["keyword","not"], + ["text"," "], + ["identifier","options"], + ["text","."], + ["identifier","nofiles"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["keyword.operator","#"], + ["identifier","doc"], + ["text","."], + ["identifier","files"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["keyword","then%>"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Files"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","table"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"file_list\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["comment.start.xml",""] +],[ + "start", + ["keyword","<%for"], + ["text"," "], + ["identifier","_"], + ["text",", "], + ["identifier","filepath"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["support.function","ipairs"], + ["paren.lparen","("], + ["identifier","doc"], + ["text","."], + ["identifier","files"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","do%>"] +],[ + "start", + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml","\t\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"name\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["keyword","<%="], + ["identifier","luadoc"], + ["text","."], + ["identifier","doclet"], + ["text","."], + ["identifier","html"], + ["text","."], + ["identifier","file_link"], + ["paren.lparen","("], + ["identifier","filepath"], + ["paren.rparen",")"], + ["keyword","%>"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["keyword","<%="], + ["identifier","filepath"], + ["keyword","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml","\t\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"summary\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml","\t"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["keyword","<%end%>"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["keyword","<%end%>"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.start.xml",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.start.xml",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"about\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"http://validator.w3.org/check?uri=referer\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.image.tag-name.xml","img"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","src"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"http://www.w3.org/Icons/valid-xhtml10\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","alt"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"Valid XHTML 1.0!\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","height"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"31\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","width"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"88\""], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.start.xml",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.start.xml",""], + ["text.xml","\t"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_lucene.json b/public/lib/ace/mode/_test/tokens_lucene.json new file mode 100644 index 0000000..1f6d298 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_lucene.json @@ -0,0 +1,92 @@ +[[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["keyword.operator","AND"], + ["text"," as keyword"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["keyword.operator","OR"], + ["text"," as keyword"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["keyword.operator","NOT"], + ["text"," as keyword"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["string","\"hello this is dog\""], + ["text"," as string"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["constant.character.negation","-"], + ["string","\"hello this is dog\""], + ["text"," as negation with string"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["constant.character.proximity","~100"], + ["text"," as text with proximity"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["string","\"hello this is dog\""], + ["constant.character.proximity","~100"], + ["text"," as string with proximity"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["keyword","raw:"], + ["string","\"hello this is dog\""], + ["text"," as keyword"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["keyword","raw:"], + ["text","foo as\"keyword'"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["string","\"(\""], + ["text"," as opening parenthesis"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises "], + ["string","\")\""], + ["text"," as closing parenthesis"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises foo"], + ["constant.character.asterisk","*"], + ["text"," as text with asterisk"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises foo"], + ["constant.character.interro","?"], + ["text"," as text with interro"] +],[ + "start", + ["keyword","test:"], + ["text"," recognises single word as text"] +],[ + "start", + ["text"," foo"] +],[ + "start", + ["text"," "] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_markdown.json b/public/lib/ace/mode/_test/tokens_markdown.json new file mode 100644 index 0000000..3ac5c13 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_markdown.json @@ -0,0 +1,114 @@ +[[ + "start", + ["text.xml","test: header 1 "] +],[ + "start", + ["markup.heading.1","#"], + ["heading","f"] +],[ + "start", + ["text.xml","test: header 2"] +],[ + "start", + ["markup.heading.2","##"], + ["heading"," foo"] +],[ + "start", + ["text.xml","test: header ends with ' #'"] +],[ + "start", + ["markup.heading.1","#"], + ["heading"," # # "] +],[ + "start", + ["text.xml","test: header ends with '#'"] +],[ + "start", + ["markup.heading.1","#"], + ["heading","foo# "] +],[ + "start", + ["text.xml","test: 6+ #s is not a valid header"] +],[ + "start", + ["text.xml","####### foo"] +],[ + "start", + ["text.xml","test: # followed be only space is not a valid header"] +],[ + "start", + ["text.xml","# "] +],[ + "start", + ["text.xml","test: only space between #s is not a valid header"] +],[ + "start", + ["text.xml","# #"] +],[ + "allowBlock" +],[ + "start", + ["markup.heading.1","#"], + ["heading"," test links "], + ["text","["], + ["string","Cloud9 IDE"], + ["text","]("], + ["markup.underline","http://www.c9.io/"], + ["text",")"], + ["heading"," #"] +],[ + "listblock", + ["markup.list","* "], + ["text","["], + ["string","demo"], + ["text","]("], + ["markup.underline","http://ajaxorg.github.com/ace/"], + ["text",")"], + ["list"," "], + ["text","["], + ["string","+"], + ["text","]("], + ["markup.underline","escape(\\) "], + ["text",")"], + ["list"," "], + ["text","["], + ["string","+"], + ["text","]("], + ["markup.underline","a"], + ["string"," \"title\""], + ["text",")"], + ["list"," "], + ["text","["], + ["string","+"], + ["text","]("], + ["markup.underline","a"], + ["string"," \"space\" "], + ["text",")"] +],[ + "listblock", + ["markup.list","* "], + ["list","usually "], + ["string.emphasis","*work*"], + ["list"," fine ("], + ["string.emphasis","_em_"], + ["list",")"] +],[ + "listblock", + ["list","in lists"] +],[ + "start" +],[ + "start", + ["text.xml","in plain text "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","b"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","http://ace.ajaxorg.com"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","b"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "allowBlock" +],[ + "allowBlock" +]] diff --git a/public/lib/ace/mode/_test/tokens_mask.json b/public/lib/ace/mode/_test/tokens_mask.json new file mode 100644 index 0000000..13ca983 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_mask.json @@ -0,0 +1,302 @@ +[[ + "start", + ["comment","/* Mask Syntax Demo */"] +],[ + "start" +],[ + "start", + ["keyword.support.constant.language","div"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","'"], + ["string"," Test "], + ["paren.lparen.markup.italic","~["], + ["identifier","name"], + ["paren.rparen.markup.italic","]"], + ["string.end","'"], + ["paren.rparen",";"] +],[ + "start" +],[ + "start", + ["keyword","define"], + ["text"," :"], + ["support.variable.class","userProfile"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["keyword.support.constant.language","header"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t"], + ["keyword.support.constant.language","h4"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["support.function.markup.bold","@title"], + ["paren.lparen",";"] +],[ + "start", + ["text","\t\t"], + ["keyword.support.constant.language","button"], + ["support.variable.class",".close"], + ["paren.lparen",";"] +],[ + "start", + ["text","\t"], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["support.function.markup.bold",":userProfile"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["support.function.markup.bold","@title"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","'"], + ["string"," Hello "], + ["paren.lparen.markup.italic","~["], + ["keyword.control.markup.italic",":"], + ["text"," "], + ["identifier","username"], + ["punctuation.operator","."], + ["support.function","toUpperCase"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["paren.rparen.markup.italic","]"], + ["string.end","'"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + ["paren.lparen52","constant.language40"], + ["constant.language","style"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["#tmp","css-block-ruleset","paren.lparen52","constant.language40"], + ["text"," "], + ["constant","html"], + ["text",", "], + ["constant","body"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["#tmp","css-block-ruleset","paren.lparen52","constant.language40"], + ["text"," "], + ["support.type","background"], + ["text",": "], + ["support.function","url("], + ["string","'name.png'"], + ["support.function",")"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["support.constant","no-repeat"], + ["text",";"] +],[ + ["#tmp","css-block-start","paren.lparen52","constant.language40"], + ["text"," "], + ["paren.rparen","}"] +],[ + ["#tmp","css-block-end","paren.lparen52","constant.language40"], + ["paren.rparen","}"] +],[ + ["#tmp","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen52","constant.language40"], + ["keyword.support.constant.language","button"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text","\t"], + ["constant.language","event"], + ["text"," "], + ["support.variable.class","click"], + ["text"," "], + ["paren.lparen","("], + ["identifier","e"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["#tmp","js-block-start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text","\t "], + ["variable.language","this"], + ["punctuation.operator","."], + ["identifier","textContent"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.quasi.start","`"], + ["string.quasi","name "], + ["paren.quasi.start","${"], + ["identifier","e"], + ["punctuation.operator","."], + ["identifier","clientX"], + ["paren.quasi.end","}"], + ["string.quasi"," !"], + ["string.quasi.end","`"], + ["punctuation.operator",";"] +],[ + ["#tmp","js-block-end","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text","\t"], + ["paren.rparen","}"] +],[ + ["#tmp","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["paren.rparen","}"] +],[ + ["#tmp","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["constant.language","md"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["paren.lparen","\"\"\""] +],[ + ["#tmp","md-multiline-allowBlock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["markup.list","- "], + ["list","div"] +],[ + ["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["markup.list","- "], + ["list","span"] +],[ + ["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["list"," "] +],[ + ["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["list","Hello"] +],[ + ["#tmp","md-multiline-start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","md-multiline-start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text","["], + ["string","one"], + ["text","]("], + ["markup.underline","http://google.com"], + ["text",")"] +],[ + ["#tmp","md-multiline-allowBlock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["paren.rparen","\"\"\";"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["keyword.support.constant.language","header"], + ["text"," "], + ["support.variable.class",".foo"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","'"], + ["string","Heading"], + ["string.end","'"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["keyword.support.constant.language","button"], + ["text"," "], + ["support.variable.class",".baz"], + ["text"," "], + ["support.variable.class.markup.bold","x-signal"], + ["keyword.operator","="], + ["string.start","'"], + ["string","click: test"], + ["string.end","'"], + ["text"," "], + ["support.variable.class","disabled"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","\""] +],[ + ["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["string","\tHello,"] +],[ + ["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["string","\tworld "] +],[ + ["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["string","\t"], + ["string.escape","\\\""], + ["string","Buddy"], + ["string.escape","\\\""] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["string.end","\""] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","js-statement-start","start","js-statement-no_regex","constant.language53","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["constant.language","var"], + ["text"," "], + ["identifier","a"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"] +],[ + ["#tmp","js-statement-no_regex","start","js-statement-no_regex","constant.language53","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text"," "], + ["identifier","name"], + ["punctuation.operator",":"], + ["text"," "], + ["string.quasi.start","`"], + ["string.quasi","name "], + ["paren.quasi.start","${"], + ["variable.language","window"], + ["punctuation.operator","."], + ["support.constant","innerWidth"], + ["paren.rparen","}"], + ["string.quasi.end","`"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["paren.rparen","};"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["keyword.support.constant.language","span"], + ["text"," "], + ["support.variable.class",".foo"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","\""], + ["paren.lparen.markup.italic","~["], + ["keyword.control.markup.italic","bind:"], + ["text"," "], + ["identifier","a"], + ["punctuation.operator","."], + ["identifier","name"], + ["paren.rparen.markup.italic","]"], + ["string.end","\""] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_matlab.json b/public/lib/ace/mode/_test/tokens_matlab.json new file mode 100644 index 0000000..6b4a856 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_matlab.json @@ -0,0 +1,90 @@ +[[ + ["blockComment","noQstring"], + ["comment.start","%{"] +],[ + ["blockComment","blockComment","blockComment","noQstring"], + ["comment.start"," %{"] +],[ + ["blockComment","blockComment","blockComment","noQstring"], + ["comment"," Ace Matlab demo"] +],[ + ["blockComment","noQstring"], + ["comment.end"," %}"] +],[ + "noQstring", + ["comment.end","%}"] +],[ + "start" +],[ + "start", + ["keyword","classdef"], + ["text"," "], + ["identifier","hello"] +],[ + "start", + ["text"," "], + ["support.function","methods"] +],[ + "start", + ["text"," "], + ["keyword","function"], + ["text"," "], + ["identifier","greet"], + ["paren.lparen","("], + ["identifier","this"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["support.function","disp"], + ["paren.lparen","("], + ["string","'Hello!'"], + ["paren.rparen",")"], + ["text"," "], + ["comment","% say hi"] +],[ + "start", + ["text"," "], + ["keyword","end"] +],[ + "start", + ["text"," "], + ["keyword","end"] +],[ + "start", + ["keyword","end"] +],[ + "noQstring" +],[ + "start", + ["comment","% transpose "] +],[ + "qqstring", + ["identifier","a"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","["], + ["text"," "], + ["string","'x"], + ["constant.language.escape","''"], + ["string","y'"], + ["punctuation.operator",","], + ["text"," "], + ["string","\"x"], + ["constant.language.escape","\\n"], + ["string","\\"] +],[ + "start", + ["string"," y\""], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","1"], + ["text","' "], + ["paren.rparen","]"], + ["text","' "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","2"], + ["text","'"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_maze.json b/public/lib/ace/mode/_test/tokens_maze.json new file mode 100644 index 0000000..473418f --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_maze.json @@ -0,0 +1,241 @@ +[[ + "start", + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","()"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","^^"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"] +],[ + "start", + ["keyword.control","##"], + ["text"," "], + ["entity.name.function","H1"], + ["text"," "], + ["entity.name.function","C2"], + ["text"," "], + ["entity.name.function","S1"], + ["text"," "], + ["keyword.control","<>"], + ["text"," "], + ["entity.name.function","S2"], + ["text"," "], + ["entity.name.function","H2"], + ["text"," "], + ["entity.name.function","DN"], + ["text"," "], + ["keyword.control","##"] +],[ + "start", + ["keyword.control","##"], + ["text"," "], + ["constant.language","%U"], + ["text"," "], + ["keyword.control","<>"], + ["text"," "], + ["constant.language","%D"], + ["text"," "], + ["entity.name.tag","*2"], + ["text"," "], + ["constant.language","%L"], + ["text"," "], + ["entity.name.function","IZ"], + ["text"," "], + ["entity.name.tag",".."], + ["text"," "], + ["keyword.control","##"] +],[ + "start", + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["entity.name.tag",".."], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["entity.name.function","DN"], + ["text"," "], + ["entity.name.tag","*3"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"] +],[ + "start", + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["constant.language","%R"], + ["text"," "], + ["entity.name.function","C1"], + ["text"," "], + ["entity.name.function","IZ"], + ["text"," "], + ["keyword.control","()"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"] +],[ + "start", + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["keyword.control","##"], + ["text"," "], + ["support.function",">/"], + ["text"," "], + ["entity.name.tag","*1"] +],[ + "start", + ["keyword.control","##"], + ["text"," "], + ["keyword.control","()"], + ["text"," "], + ["entity.name.tag","*3"], + ["text"," "], + ["entity.name.tag","*1"], + ["text"," "], + ["constant.language","%L"], + ["text"," "], + ["keyword.control","()"] +],[ + "start" +],[ + "start" +],[ + "start", + ["comment.line.double-slash","// Set divisor and dividend"] +],[ + "start", + ["entity.name.function","S1"], + ["keyword.other","-> "], + ["keyword.operator","="], + ["keyword.other"," "], + ["constant.numeric","9"] +],[ + "start", + ["entity.name.function","S2"], + ["keyword.other","-> "], + ["keyword.operator","="], + ["keyword.other"," "], + ["constant.numeric","24"] +],[ + "start" +],[ + "start", + ["comment.line.double-slash","// Holding cells"] +],[ + "start", + ["entity.name.function","H1"], + ["keyword.other","-> "], + ["keyword.control","IF"], + ["keyword.other"," "], + ["entity.name.tag","*1"], + ["keyword.other"," "], + ["keyword.control","THEN"], + ["keyword.other"," "], + ["constant.language","%R"], + ["keyword.other"," "], + ["keyword.control","ELSE"], + ["keyword.other"," "], + ["constant.language","%N"] +],[ + "start", + ["entity.name.function","H2"], + ["keyword.other","-> "], + ["keyword.control","IF"], + ["keyword.other"," "], + ["entity.name.tag","*2"], + ["keyword.other"," "], + ["keyword.control","THEN"], + ["keyword.other"," "], + ["constant.language","%R"], + ["keyword.other"," "], + ["keyword.control","ELSE"], + ["keyword.other"," "], + ["constant.language","%N"] +],[ + "start" +],[ + "start", + ["comment.line.double-slash","// Arithmetic"] +],[ + "start", + ["entity.name.function","DN"], + ["keyword.other","-> "], + ["keyword.operator","-="], + ["keyword.other"," "], + ["constant.numeric","1"] +],[ + "start", + ["entity.name.function","IZ"], + ["keyword.other","-> "], + ["keyword.control","IF"], + ["keyword.other"," "], + ["keyword.operator","<="], + ["keyword.other"," "], + ["constant.numeric","0"], + ["keyword.other"," "], + ["keyword.control","THEN"], + ["keyword.other"," "], + ["constant.language","%D"], + ["keyword.other"," "], + ["keyword.control","ELSE"], + ["keyword.other"," "], + ["constant.language","%U"] +],[ + "start" +],[ + "start", + ["entity.name.function","C1"], + ["keyword.other","-> "], + ["keyword.control","IF"], + ["keyword.other"," "], + ["entity.name.tag","*3"], + ["keyword.other"," "], + ["keyword.control","THEN"], + ["keyword.other"," "], + ["constant.language","%D"], + ["keyword.other"," "], + ["keyword.control","ELSE"], + ["keyword.other"," "], + ["constant.language","%R"] +],[ + "start", + ["entity.name.function","C2"], + ["keyword.other","-> "], + ["keyword.control","IF"], + ["keyword.other"," "], + ["entity.name.tag","*3"], + ["keyword.other"," "], + ["keyword.control","THEN"], + ["keyword.other"," "], + ["constant.language","%U"], + ["keyword.other"," "], + ["keyword.control","ELSE"], + ["keyword.other"," "], + ["constant.language","%D"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_mel.json b/public/lib/ace/mode/_test/tokens_mel.json new file mode 100644 index 0000000..d5bb79b --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_mel.json @@ -0,0 +1,255 @@ +[[ + "start", + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," animated duplicates, instances script"] +],[ + "start", + ["keyword.other.mel","proc"], + ["storage.type.mel"," "], + ["entity.name.function.mel","animatedDuplication"], + ["punctuation.section.function.mel"," ("], + ["meta.function.mel","int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance"], + ["punctuation.section.function.mel",")"] +],[ + "start", + ["text","{"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","rangeStart"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_end"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","rangeEnd"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","num_of_duplicates"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","numOfDuplicates"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","step_size"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_end"], + ["text"," "], + ["keyword.operator.symbolic.mel","-"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text",") "], + ["keyword.operator.symbolic.mel","/"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","num_of_duplicates"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["constant.numeric.mel","0"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","temp"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["support.function.mel","currentTime"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text","; "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," set to range start"] +],[ + "start" +],[ + "start", + ["text"," "], + ["storage.type.mel","string"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text","[]; "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," to store selected objects"] +],[ + "start", + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," `"], + ["support.function.mel","ls"], + ["text"," "], + ["keyword.operator.symbolic.mel","-"], + ["text","sl`; "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," store selected objects"] +],[ + "start", + ["text"," "], + ["support.function.mel","select"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword.control.mel","while"], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["text"," <"], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","num_of_duplicates"], + ["text",")"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","temp"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text"," "], + ["keyword.operator.symbolic.mel","+"], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","step_size"], + ["text"," "], + ["keyword.operator.symbolic.mel","*"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["text",");"] +],[ + "start", + ["text"," "], + ["support.function.mel","currentTime"], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","temp"], + ["text",");"] +],[ + "start", + ["text"," "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," seleced the objects to duplicate or instance"] +],[ + "start", + ["text"," "], + ["support.function.mel","select"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.control.mel","if"], + ["text","("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","duplicateOrInstance"], + ["text"," "], + ["keyword.operator.symbolic.mel","=="], + ["text"," "], + ["constant.numeric.mel","0"], + ["text",")"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["support.function.mel","duplicate"], + ["text",";"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text"," "], + ["keyword.control.mel","else"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["support.function.mel","instance"], + ["text",";"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["keyword.operator.symbolic.mel","++"], + ["text",";"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_mushcode.json b/public/lib/ace/mode/_test/tokens_mushcode.json new file mode 100644 index 0000000..9f8e7cc --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_mushcode.json @@ -0,0 +1,790 @@ +[[ + "start", + ["text","@"], + ["support.function","create"], + ["text"," "], + ["identifier","phone"] +],[ + "start", + ["text","&"], + ["identifier","pickup"], + ["text"," "], + ["identifier","phone"], + ["keyword.operator","="], + ["identifier","$pick"], + ["text"," "], + ["identifier","up"], + ["text",":@"], + ["support.function","ifelse"], + ["text"," "], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","is"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","mode"], + ["paren.rparen",")"], + ["text",","], + ["identifier","ICC"], + ["paren.rparen",")]"], + ["keyword.operator","="], + ["paren.lparen","{"], + ["text","@"], + ["support.function","pemit"], + ["text"," "], + ["keyword.operator","%#="], + ["identifier","You"], + ["text"," "], + ["support.function","pick"], + ["text"," "], + ["identifier","up"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["paren.lparen","["], + ["support.function","fullname"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")]"], + ["text","."], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["identifier","me"], + ["text",","], + ["identifier","PHONER"], + ["text",":"], + ["keyword.operator","%#"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["identifier","me"], + ["text",","], + ["identifier","MODE"], + ["text",":"], + ["identifier","CIP"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","(["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","INCOMING"], + ["paren.rparen",")]"], + ["text",","], + ["identifier","CONNECTED"], + ["text",":"], + ["paren.lparen","["], + ["support.function","num"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["identifier","me"], + ["text",","], + ["identifier","CONNECTED"], + ["text",":"], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","INCOMING"], + ["paren.rparen",")])]"], + ["variable","%r"], + ["paren.lparen","["], + ["support.function","showpicture"], + ["paren.lparen","("], + ["identifier","PICPICKUP"], + ["paren.rparen",")]"], + ["variable","%r"], + ["identifier","Use"], + ["text"," '"], + ["paren.lparen","["], + ["identifier","color"], + ["paren.lparen","("], + ["identifier","green"], + ["text",","], + ["identifier","black"], + ["text",","], + ["identifier","psay"], + ["text"," "], + ["keyword.operator","<"], + ["identifier","message"], + ["keyword.operator",">"], + ["paren.rparen",")]"], + ["text","' "], + ["paren.lparen","("], + ["support.function","or"], + ["text"," '"], + ["paren.lparen","["], + ["identifier","color"], + ["paren.lparen","("], + ["identifier","green"], + ["text",","], + ["identifier","black"], + ["text",","], + ["identifier","p"], + ["text"," "], + ["keyword.operator","<"], + ["identifier","message"], + ["keyword.operator",">"], + ["paren.rparen",")]"], + ["text","'"], + ["paren.rparen",")"], + ["text"," "], + ["identifier","to"], + ["text"," "], + ["identifier","talk"], + ["text"," "], + ["identifier","into"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["identifier","phone"], + ["text",".;@"], + ["support.function","oemit"], + ["text"," "], + ["keyword.operator","%#="], + ["variable","%N"], + ["text"," "], + ["identifier","picks"], + ["text"," "], + ["identifier","up"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["paren.lparen","["], + ["support.function","fullname"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")]"], + ["text","."], + ["paren.rparen","}"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","pemit"], + ["text"," "], + ["keyword.operator","%#="], + ["identifier","You"], + ["text"," "], + ["support.function","pick"], + ["text"," "], + ["identifier","up"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["identifier","phone"], + ["text"," "], + ["identifier","but"], + ["text"," "], + ["identifier","no"], + ["text"," "], + ["identifier","one"], + ["text"," "], + ["identifier","is"], + ["text"," "], + ["identifier","there"], + ["text",". "], + ["identifier","You"], + ["text"," "], + ["identifier","hear"], + ["text"," "], + ["identifier","a"], + ["text"," "], + ["identifier","dialtone"], + ["text"," "], + ["support.function","and"], + ["text"," "], + ["identifier","then"], + ["text"," "], + ["identifier","hang"], + ["text"," "], + ["identifier","up"], + ["text",". "], + ["paren.lparen","["], + ["support.function","play"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","DIALTONE"], + ["paren.rparen","))]"], + ["text",";@"], + ["support.function","oemit"], + ["text"," "], + ["keyword.operator","%#="], + ["variable","%N"], + ["text"," "], + ["identifier","picks"], + ["text"," "], + ["identifier","up"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["identifier","phone"], + ["text",", "], + ["identifier","but"], + ["text"," "], + ["identifier","no"], + ["text"," "], + ["identifier","one"], + ["text"," "], + ["identifier","is"], + ["text"," "], + ["identifier","on"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["identifier","other"], + ["text"," "], + ["identifier","end"], + ["text","."], + ["paren.rparen","}"] +],[ + "start", + ["text","&"], + ["identifier","ringfun"], + ["text"," "], + ["identifier","phone"], + ["keyword.operator","="], + ["paren.lparen","["], + ["support.function","ifelse"], + ["paren.lparen","("], + ["support.function","eq"], + ["paren.lparen","("], + ["support.function","comp"], + ["paren.lparen","(["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone"], + ["paren.rparen",")]"], + ["text",","], + ["identifier","off"], + ["paren.rparen",")"], + ["text",","], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text",","], + ["paren.lparen","["], + ["identifier","color"], + ["paren.lparen","("], + ["identifier","black"], + ["text",","], + ["identifier","cyan"], + ["text",","], + ["identifier","INCOMING"], + ["text"," "], + ["identifier","CALL"], + ["text"," "], + ["identifier","FROM"], + ["text"," "], + ["variable","%1"], + ["paren.rparen",")]"], + ["text",","], + ["paren.lparen","["], + ["support.function","play"], + ["paren.lparen","(["], + ["support.function","switch"], + ["paren.lparen","(["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","1"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone1"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone2"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","3"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone3"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","4"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone4"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","5"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone5"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","6"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone6"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","7"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone7"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","8"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone8"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","9"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone9"], + ["paren.rparen",")]"], + ["text",","], + ["identifier","custom"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","customtone"], + ["paren.rparen",")]"], + ["text",","], + ["identifier","vibrate"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","vibrate"], + ["paren.rparen",")])])]"] +],[ + "start", + ["text","&"], + ["identifier","ringloop"], + ["text"," "], + ["identifier","phone"], + ["keyword.operator","="], + ["text","@"], + ["support.function","switch"], + ["text"," "], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","ringstate"], + ["paren.rparen",")]"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","emit"], + ["text"," "], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["identifier","q"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","connecting"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","rangs"], + ["text",":"], + ["constant.numeric","0"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","mode"], + ["text",":"], + ["identifier","WFC"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","INCOMING"], + ["text",":"], + ["paren.rparen",")]"], + ["text",";@"], + ["support.function","ifelse"], + ["text"," "], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","HASVMB"], + ["paren.rparen",")]"], + ["keyword.operator","="], + ["paren.lparen","{"], + ["text","@"], + ["support.function","tr"], + ["text"," "], + ["identifier","me"], + ["keyword.operator","/"], + ["identifier","ROUTEVMB"], + ["keyword.operator","="], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","connecting"], + ["paren.rparen",")]"], + ["text",";"], + ["paren.rparen","}"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","pemit"], + ["text"," "], + ["keyword.operator","%#="], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","MSGCNC"], + ["paren.rparen",")]"], + ["text",";"], + ["paren.rparen","}}"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","pemit"], + ["text"," "], + ["keyword.operator","%#="], + ["identifier","The"], + ["text"," "], + ["identifier","call"], + ["text"," "], + ["identifier","is"], + ["text"," "], + ["identifier","connected"], + ["text","."], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["identifier","q"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","CONNECTING"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["identifier","me"], + ["text",","], + ["identifier","CONNECTED"], + ["text",":"], + ["variable","%qq"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","CONNECTED"], + ["text",":"], + ["paren.lparen","["], + ["support.function","num"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","MODE"], + ["text",":"], + ["identifier","CIP"], + ["paren.rparen",")]"], + ["text",";@"], + ["support.function","tr"], + ["text"," "], + ["identifier","me"], + ["keyword.operator","/"], + ["identifier","ciploop"], + ["text",";@"], + ["support.function","tr"], + ["text"," "], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","ciploop"], + ["text",";"], + ["paren.rparen","}"], + ["text",","], + ["constant.numeric","3"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","emit"], + ["text"," "], + ["identifier","On"], + ["text"," "], + ["paren.lparen","["], + ["support.function","fullname"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")]"], + ["text","'"], + ["support.function","s"], + ["text"," "], + ["identifier","earpiece"], + ["text"," "], + ["identifier","you"], + ["text"," "], + ["identifier","hear"], + ["text"," "], + ["identifier","a"], + ["text"," "], + ["identifier","ringing"], + ["text"," "], + ["identifier","sound"], + ["text","."], + ["paren.lparen","["], + ["support.function","play"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","LINETONE"], + ["paren.rparen","))]"], + ["text",";@"], + ["support.function","tr"], + ["text"," "], + ["identifier","me"], + ["keyword.operator","/"], + ["identifier","ringhere"], + ["text",";@"], + ["identifier","increment"], + ["text"," "], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","connecting"], + ["paren.rparen",")]"], + ["keyword.operator","/"], + ["identifier","RANGS"], + ["text",";@"], + ["identifier","wait"], + ["text"," "], + ["constant.numeric","5"], + ["keyword.operator","="], + ["paren.lparen","{"], + ["text","@"], + ["support.function","tr"], + ["text"," "], + ["identifier","me"], + ["keyword.operator","/"], + ["identifier","ringloop"], + ["paren.rparen","}"], + ["text",";"], + ["paren.rparen","}"], + ["text",","], + ["constant.numeric","4"], + ["text",","], + ["paren.lparen","{"], + ["paren.rparen","}"] +],[ + "start", + ["text","&"], + ["identifier","ringstate"], + ["text"," "], + ["identifier","phone"], + ["keyword.operator","="], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["identifier","q"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","connecting"], + ["paren.rparen","))]"], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["constant.numeric","1"], + ["text",","], + ["paren.lparen","["], + ["support.function","gt"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","rangs"], + ["paren.rparen",")"], + ["text",","], + ["support.function","sub"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","rings"], + ["paren.rparen",")"], + ["text",","], + ["constant.numeric","1"], + ["paren.rparen","))])]"], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["constant.numeric","2"], + ["text",","], + ["paren.lparen","["], + ["support.function","and"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","is"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","MODE"], + ["paren.rparen",")"], + ["text",","], + ["identifier","CIP"], + ["paren.rparen",")"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","is"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","INCOMING"], + ["paren.rparen",")"], + ["text",","], + ["paren.lparen","["], + ["support.function","num"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")]))]"], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["constant.numeric","3"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","is"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","MODE"], + ["paren.rparen",")"], + ["text",","], + ["identifier","ICC"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","ifelse"], + ["paren.lparen","("], + ["variable","%q1"], + ["text",","], + ["constant.numeric","1"], + ["text",","], + ["support.function","ifelse"], + ["paren.lparen","("], + ["variable","%q2"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["support.function","ifelse"], + ["paren.lparen","("], + ["variable","%q3"], + ["text",","], + ["constant.numeric","3"], + ["text",","], + ["constant.numeric","4"], + ["paren.rparen",")))]"] +],[ + "start", + ["text",";"], + ["identifier","comment"] +],[ + "start", + ["text","@@"], + ["paren.lparen","("], + ["identifier","comment"], + ["paren.rparen",")"] +],[ + "start", + ["keyword","say"], + ["text"," "], + ["paren.lparen","["], + ["support.function","time"], + ["paren.lparen","("], + ["paren.rparen",")]"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_mysql.json b/public/lib/ace/mode/_test/tokens_mysql.json new file mode 100644 index 0000000..9909ead --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_mysql.json @@ -0,0 +1,4 @@ +[[ + "start", + ["identifier","TODO"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_nix.json b/public/lib/ace/mode/_test/tokens_nix.json new file mode 100644 index 0000000..b942445 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_nix.json @@ -0,0 +1,360 @@ +[[ + "start", + ["text","{"] +],[ + "start", + ["text"," "], + ["comment","# Name of our deployment"] +],[ + "start", + ["text"," "], + ["identifier","network"], + ["text","."], + ["identifier","description"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"HelloWorld\""], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# Enable rolling back to previous versions of our infrastructure"] +],[ + "start", + ["text"," "], + ["identifier","network"], + ["text","."], + ["identifier","enableRollback"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["constant.language.nix","true"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","# It consists of a single server named 'helloserver'"] +],[ + "start", + ["text"," "], + ["identifier","helloserver"], + ["text"," "], + ["keyword.operator.assignment.nix","="] +],[ + "start", + ["text"," "], + ["comment","# Every server gets passed a few arguments, including a reference"] +],[ + "start", + ["text"," "], + ["comment","# to nixpkgs (pkgs)"] +],[ + "start", + ["text"," { "], + ["identifier","config"], + ["text",", "], + ["identifier","pkgs"], + ["text",", ... }:"] +],[ + "start", + ["text"," "], + ["keyword.declaration.nix","let"] +],[ + "start", + ["text"," "], + ["comment","# We import our custom packages from ./default passing pkgs as argument"] +],[ + "start", + ["text"," "], + ["identifier","packages"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["keyword.control.nix","import"], + ["text"," ./"], + ["identifier","default"], + ["text","."], + ["identifier","nix"], + ["text"," { "], + ["identifier","pkgs"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["identifier","pkgs"], + ["text","; };"] +],[ + "start", + ["text"," "], + ["comment","# This is the nodejs version specified in default.nix"] +],[ + "start", + ["text"," "], + ["identifier","nodejs"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["identifier","packages"], + ["text","."], + ["identifier","nodejs"], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# And this is the application we'd like to deploy"] +],[ + "start", + ["text"," "], + ["identifier","app"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["identifier","packages"], + ["text","."], + ["identifier","app"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.nix","in"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["comment","# We'll be running our application on port 8080, because a regular"] +],[ + "start", + ["text"," "], + ["comment","# user cannot bind to port 80"] +],[ + "start", + ["text"," "], + ["comment","# Then, using some iptables magic we'll forward traffic designated to port 80 to 8080"] +],[ + "start", + ["text"," "], + ["identifier","networking"], + ["text","."], + ["identifier","firewall"], + ["text","."], + ["identifier","enable"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["constant.language.nix","true"], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# We will open up port 22 (SSH) as well otherwise we're locking ourselves out"] +],[ + "start", + ["text"," "], + ["identifier","networking"], + ["text","."], + ["identifier","firewall"], + ["text","."], + ["identifier","allowedTCPPorts"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," [ "], + ["constant.numeric","80"], + ["text"," "], + ["constant.numeric","8080"], + ["text"," "], + ["constant.numeric","22"], + ["text"," ];"] +],[ + "start", + ["text"," "], + ["identifier","networking"], + ["text","."], + ["identifier","firewall"], + ["text","."], + ["identifier","allowPing"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["constant.language.nix","true"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","# Port forwarding using iptables"] +],[ + "qqdoc", + ["text"," "], + ["identifier","networking"], + ["text","."], + ["identifier","firewall"], + ["text","."], + ["identifier","extraCommands"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","''"] +],[ + "qqdoc", + ["string"," iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080"] +],[ + "start", + ["string"," ''"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","# To run our node.js program we're going to use a systemd service"] +],[ + "start", + ["text"," "], + ["comment","# We can configure the service to automatically start on boot and to restart"] +],[ + "start", + ["text"," "], + ["comment","# the process in case it crashes"] +],[ + "start", + ["text"," "], + ["identifier","systemd"], + ["text","."], + ["identifier","services"], + ["text","."], + ["identifier","helloserver"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," {"] +],[ + "start", + ["text"," "], + ["identifier","description"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"Hello world application\""], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# Start the service after the network is available"] +],[ + "start", + ["text"," "], + ["identifier","after"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," [ "], + ["string","\"network.target\""], + ["text"," ];"] +],[ + "start", + ["text"," "], + ["comment","# We're going to run it on port 8080 in production"] +],[ + "start", + ["text"," "], + ["identifier","environment"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," { "], + ["identifier","PORT"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"8080\""], + ["text","; };"] +],[ + "start", + ["text"," "], + ["identifier","serviceConfig"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," {"] +],[ + "start", + ["text"," "], + ["comment","# The actual command to run"] +],[ + "start", + ["text"," "], + ["identifier","ExecStart"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\""], + ["constant.language.escape","${"], + ["identifier","nodejs"], + ["constant.language.escape","}"], + ["string","/bin/node "], + ["constant.language.escape","${"], + ["identifier","app"], + ["constant.language.escape","}"], + ["string","/server.js\""], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# For security reasons we'll run this process as a special 'nodejs' user"] +],[ + "start", + ["text"," "], + ["identifier","User"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"nodejs\""], + ["text",";"] +],[ + "start", + ["text"," "], + ["identifier","Restart"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"always\""], + ["text",";"] +],[ + "start", + ["text"," };"] +],[ + "start", + ["text"," };"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","# And lastly we ensure the user we run our application as is created"] +],[ + "start", + ["text"," "], + ["identifier","users"], + ["text","."], + ["identifier","extraUsers"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," {"] +],[ + "start", + ["text"," "], + ["identifier","nodejs"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," { };"] +],[ + "start", + ["text"," };"] +],[ + "start", + ["text"," };"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_nsis.json b/public/lib/ace/mode/_test/tokens_nsis.json new file mode 100644 index 0000000..0f1c73d --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_nsis.json @@ -0,0 +1,133 @@ +[[ + "punctuation.definition.comment.nsis", + ["punctuation.definition.comment.nsis","/*"] +],[ + "punctuation.definition.comment.nsis", + ["comment.block.nsis"," NSIS Mode"] +],[ + "punctuation.definition.comment.nsis", + ["comment.block.nsis"," for Ace"] +],[ + "start", + ["punctuation.definition.comment.nsis","*/"] +],[ + "start" +],[ + "start", + ["punctuation.definition.comment.nsis",";"], + ["comment.line.nsis"," Includes"] +],[ + "start", + ["keyword.compiler.nsis","!include"], + ["text"," MUI2.nsh"] +],[ + "start" +],[ + "start", + ["punctuation.definition.comment.nsis",";"], + ["comment.line.nsis"," Settings"] +],[ + "start", + ["keyword.command.nsis","Name"], + ["text"," "], + ["punctuation.definition.string.begin.nsis","\""], + ["string.quoted.double.nsis","installer_name"], + ["punctuation.definition.string.end.nsis","\""] +],[ + "start", + ["keyword.command.nsis","OutFile"], + ["text"," "], + ["punctuation.definition.string.begin.nsis","\""], + ["string.quoted.double.nsis","installer_name.exe"], + ["punctuation.definition.string.end.nsis","\""] +],[ + "start", + ["keyword.command.nsis","RequestExecutionLevel"], + ["text"," "], + ["constant.language.option.nsis","user"] +],[ + "start", + ["keyword.command.nsis","CRCCheck"], + ["text"," "], + ["constant.language.boolean.true.nsis","on"] +],[ + "start", + ["keyword.control.nsis","!ifdef"], + ["text"," x64"] +],[ + "start", + ["keyword.command.nsis"," InstallDir"], + ["text"," "], + ["punctuation.definition.string.begin.nsis","\""], + ["string.quoted.double.nsis","$PROGRAMFILES64\\installer_name"], + ["punctuation.definition.string.end.nsis","\""] +],[ + "start", + ["keyword.control.nsis","!else"] +],[ + "start", + ["keyword.command.nsis"," InstallDir"], + ["text"," "], + ["punctuation.definition.string.begin.nsis","\""], + ["string.quoted.double.nsis","$PROGRAMFILES\\installer_name"], + ["punctuation.definition.string.end.nsis","\""] +],[ + "start", + ["keyword.control.nsis","!endif"] +],[ + "start" +],[ + "start", + ["punctuation.definition.comment.nsis",";"], + ["comment.line.nsis"," Pages"] +],[ + "start", + ["keyword.compiler.nsis","!insertmacro"], + ["text"," MUI_PAGE_INSTFILES"] +],[ + "start" +],[ + "start", + ["punctuation.definition.comment.nsis",";"], + ["comment.line.nsis"," Sections"] +],[ + "start", + ["support.function.nsis","Section"], + ["text"," "], + ["punctuation.definition.string.begin.nsis","\""], + ["string.quoted.double.nsis","section_name"], + ["punctuation.definition.string.end.nsis","\""], + ["text"," section_index"] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.nsis","#"], + ["comment.line.nsis"," your code here"] +],[ + "start", + ["support.function.nsis","SectionEnd"] +],[ + "start" +],[ + "start", + ["punctuation.definition.comment.nsis",";"], + ["comment.line.nsis"," Functions"] +],[ + "start", + ["support.function.nsis","Function"], + ["text"," .onInit"] +],[ + "start", + ["keyword.command.nsis"," MessageBox"], + ["text"," "], + ["constant.nsis","MB_OK"], + ["text"," "], + ["punctuation.definition.string.begin.nsis","\""], + ["string.quoted.double.nsis","Here comes a"], + ["constant.character.escape.nsis","$\\n$\\r"], + ["string.quoted.double.nsis","line-break!"], + ["punctuation.definition.string.end.nsis","\""] +],[ + "start", + ["support.function.nsis","FunctionEnd"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_objectivec.json b/public/lib/ace/mode/_test/tokens_objectivec.json new file mode 100644 index 0000000..c50da43 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_objectivec.json @@ -0,0 +1,798 @@ +[[ + "start", + ["storage.type.objc","@"], + ["punctuation.definition.storage.type.objc","protocol"], + ["entity.name.type.objc"," Printing"], + ["text",": "], + ["entity.other.inherited-class.objc","someParent"] +],[ + "start", + ["meta.function.objc","-"], + ["paren.lparen","("], + ["storage.type","void"], + ["paren.rparen",")"], + ["text"," "], + ["identifier","print"], + ["punctuation.operator",";"] +],[ + "start", + ["storage.type.objc","@end"] +],[ + "start" +],[ + "start", + ["storage.type.objc","@"], + ["punctuation.definition.storage.type.objc","interface"], + ["entity.name.type.objc"," Fraction"], + ["text",": "], + ["entity.other.inherited-class.objc","NSObject"], + ["text"," "], + ["keyword.operator","<"], + ["identifier","Printing"], + ["punctuation.operator",","], + ["text"," "], + ["support.class.cocoa","NSCopying"], + ["keyword.operator",">"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.type","int"], + ["text"," "], + ["identifier","numerator"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["storage.type","int"], + ["text"," "], + ["identifier","denominator"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["storage.type.objc","@end"] +],[ + "start" +],[ + "start", + ["string.begin.objc","@\""], + ["string","blah"], + ["invalid.illegal.unknown-escape.objc","\\8"], + ["punctuation.definition.string.end","\""], + ["text"," "], + ["string.begin.objc","@\""], + ["string","a"], + ["constant.character.escape.objc","\\222"], + ["string","sd"], + ["invalid.illegal.unknown-escape.objc","\\d"], + ["punctuation.definition.string.end","\""], + ["text"," "], + ["string.begin.objc","@\""], + ["constant.character.escape.objc","\\f"], + ["string","aw"], + ["constant.character.escape.objc","\\\"\\?"], + ["string"," "], + ["constant.character.escape.objc","\\'"], + ["string"," "], + ["constant.character.escape.objc","\\4"], + ["string"," n"], + ["constant.character.escape.objc","\\\\"], + ["punctuation.definition.string.end","\""], + ["text"," "], + ["string.begin.objc","@\""], + ["constant.character.escape.objc","\\56"], + ["punctuation.definition.string.end","\""] +],[ + "start", + ["string.begin.objc","@\""], + ["constant.character.escape.objc","\\xSF42"], + ["punctuation.definition.string.end","\""] +],[ + "start" +],[ + "start", + ["meta.function.objc","-"], + ["paren.lparen","("], + ["support.class.cocoa","NSDecimalNumber"], + ["keyword.operator","*"], + ["paren.rparen",")"], + ["identifier","addCount"], + ["punctuation.operator",":"], + ["paren.lparen","("], + ["storage.type.id.objc","id"], + ["paren.rparen",")"], + ["identifier","addObject"], + ["paren.lparen","{"] +],[ + "start" +],[ + "start", + ["keyword.control","return"], + ["text"," "], + ["punctuation.section.scope.begin.objc","["], + ["identifier","count"], + ["text"," "], + ["support.function.any-method.objc","decimalNumberByAdding:"], + ["identifier","addObject"], + ["punctuation.operator","."], + ["identifier","count"], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword.control.macro.objc","NS_DURING"], + ["text"," "], + ["keyword.control.macro.objc","NS_HANDLER"], + ["text"," "], + ["keyword.control.macro.objc","NS_ENDHANDLER"] +],[ + "start" +],[ + "start", + ["punctuation.definition.keyword.objc","@"], + ["keyword.control.exception.objc","try"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.control","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","argc"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","1"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["punctuation.definition.keyword.objc","@"], + ["keyword.control.exception.objc","throw"], + ["text"," "], + ["punctuation.section.scope.begin.objc","["], + ["support.class.cocoa","NSException"], + ["text"," "], + ["support.function.any-method.objc","exceptionWithName:"], + ["string.begin.objc","@\""], + ["string","Throwing a test exception"], + ["punctuation.definition.string.end","\""], + ["text"," "], + ["identifier","reason"], + ["punctuation.operator",":"], + ["string.begin.objc","@\""], + ["string","Testing the @throw directive."], + ["punctuation.definition.string.end","\""], + ["text"," "], + ["identifier","userInfo"], + ["punctuation.operator",":"], + ["constant.language.objc","nil"], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"], + ["text"," "] +],[ + "start", + ["punctuation.definition.keyword.objc","@"], + ["keyword.control.exception.objc","catch"], + ["text"," "], + ["paren.lparen","("], + ["storage.type.id.objc","id"], + ["text"," "], + ["identifier","theException"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.function.cocoa","NSLog"], + ["paren.lparen","("], + ["string.begin.objc","@\""], + ["string","%@"], + ["punctuation.definition.string.end","\""], + ["punctuation.operator",","], + ["text"," "], + ["identifier","theException"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["identifier","result"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"], + ["text"," "] +],[ + "start", + ["punctuation.definition.keyword.objc","@"], + ["keyword.control.exception.objc","finally"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.function.cocoa","NSLog"], + ["paren.lparen","("], + ["string.begin.objc","@\""], + ["string","This always happens."], + ["punctuation.definition.string.end","\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["identifier","result"], + ["text"," "], + ["keyword.operator","+="], + ["text"," "], + ["constant.numeric","2"], + ["text"," "], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["punctuation.definition.storage.modifier.objc","@"], + ["storage.modifier.objc","synchronized"], + ["paren.lparen","("], + ["identifier","lock"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.function.cocoa","NSLog"], + ["paren.lparen","("], + ["string.begin.objc","@\""], + ["string","Hello World"], + ["punctuation.definition.string.end","\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["storage.type","struct"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["punctuation.definition.keyword.objc","@"], + ["keyword.other.objc","defs"], + ["paren.lparen","("], + ["text"," "], + ["support.class.cocoa","NSObject"], + ["paren.rparen",")"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["storage.type","char"], + ["text"," "], + ["keyword.operator","*"], + ["identifier","enc1"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.definition.keyword.objc","@"], + ["keyword.other.objc","encode"], + ["paren.lparen","("], + ["storage.type","int"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["storage.type.objc","IBOutlet"], + ["keyword.operator","|"], + ["storage.type.objc","IBAction"], + ["keyword.operator","|"], + ["storage.type.objc","BOOL"], + ["keyword.operator","|"], + ["storage.type.objc","SEL"], + ["keyword.operator","|"], + ["storage.type.id.objc","id"], + ["keyword.operator","|"], + ["storage.type.objc","unichar"], + ["keyword.operator","|"], + ["storage.type.objc","IMP"], + ["keyword.operator","|"], + ["storage.type.objc","Class"], + ["text"," "] +],[ + "start" +],[ + "start" +],[ + "start", + ["text"," "], + ["punctuation.definition.storage.type.objc","@"], + ["storage.type.objc","class"], + ["text"," "], + ["punctuation.definition.storage.type.objc","@"], + ["storage.type.objc","protocol"] +],[ + "start" +],[ + "start", + ["punctuation.definition.storage.modifier.objc","@"], + ["storage.modifier.objc","public"] +],[ + "start", + ["text"," "], + ["comment","// instance variables"] +],[ + "start", + ["punctuation.definition.storage.modifier.objc","@"], + ["storage.modifier.objc","package"] +],[ + "start", + ["text"," "], + ["comment","// instance variables"] +],[ + "start", + ["punctuation.definition.storage.modifier.objc","@"], + ["storage.modifier.objc","protected"] +],[ + "start", + ["text"," "], + ["comment","// instance variables"] +],[ + "start", + ["punctuation.definition.storage.modifier.objc","@"], + ["storage.modifier.objc","private"] +],[ + "start", + ["text"," "], + ["comment","// instance variables"] +],[ + "start" +],[ + "start", + ["text"," "], + ["constant.language.objc","YES"], + ["text"," "], + ["constant.language.objc","NO"], + ["text"," "], + ["constant.language.objc","Nil"], + ["text"," "], + ["constant.language.objc","nil"] +],[ + "start", + ["support.variable.foundation","NSApp"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["support.function.cocoa.leopard","NSRectToCGRect"], + ["text"," "], + ["paren.lparen","("], + ["identifier","Protocol"], + ["text"," "], + ["identifier","ProtocolFromString"], + ["punctuation.operator",":"], + ["string.start","\""], + ["string","NSTableViewDelegate"], + ["string.end","\""], + ["paren.rparen","))"] +],[ + "start" +],[ + "start", + ["punctuation.section.scope.begin.objc","["], + ["identifier","SPPoint"], + ["text"," "], + ["support.function.any-method.objc","pointFromCGPoint:"], + ["identifier","self"], + ["punctuation.operator","."], + ["identifier","position"], + ["paren.rparen","]"] +],[ + "start" +],[ + "start", + ["support.function.cocoa","NSRoundDownToMultipleOfPageSize"] +],[ + "start" +],[ + "start", + ["keyword","#import"], + ["constant.other"," "] +],[ + "start" +],[ + "start", + ["storage.type","int"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["text"," "], + ["storage.type","int"], + ["text"," "], + ["identifier","argc"], + ["punctuation.operator",","], + ["text"," "], + ["storage.modifier","const"], + ["text"," "], + ["storage.type","char"], + ["text"," "], + ["keyword.operator","*"], + ["identifier","argv"], + ["punctuation.section.scope.begin.objc","["], + ["punctuation.section.scope.end.objc","]"], + ["text"," "], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.function.C99.c","printf"], + ["paren.lparen","("], + ["text"," "], + ["string.start","\""], + ["string","hello world"], + ["constant.language.escape","\\n"], + ["string.end","\""], + ["text"," "], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.control","return"], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["support.class.cocoa","NSChangeSpelling"] +],[ + "start" +],[ + "start", + ["string.begin.objc","@\""], + ["string","0 != SUBQUERY(image, $x, 0 != SUBQUERY($x.bookmarkItems, $y, $y.@count == 0).@count).@count"], + ["punctuation.definition.string.end","\""] +],[ + "start" +],[ + "start", + ["punctuation.definition.storage.type.objc","@selector"], + ["punctuation","("], + ["support.function.any-method.name-of-parameter.objc","lowercaseString"], + ["punctuation",")"], + ["text"," "], + ["punctuation.definition.storage.type.objc","@selector"], + ["punctuation","("], + ["support.function.any-method.name-of-parameter.objc","uppercaseString:"], + ["punctuation",")"] +],[ + "start" +],[ + "start", + ["identifier","NSFetchRequest"], + ["text"," "], + ["keyword.operator","*"], + ["identifier","localRequest"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.section.scope.begin.objc","[["], + ["identifier","NSFetchRequest"], + ["text"," "], + ["support.function.any-method.objc","alloc"], + ["paren.rparen","]"], + ["text"," "], + ["identifier","init"], + ["paren.rparen","]"], + ["punctuation.operator",";"], + ["text"," "] +],[ + "start", + ["identifier","localRequest"], + ["punctuation.operator","."], + ["identifier","entity"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.section.scope.begin.objc","["], + ["identifier","NSEntityDescription"], + ["text"," "], + ["support.function.any-method.objc","entityForName:"], + ["string.begin.objc","@\""], + ["string","VNSource"], + ["punctuation.definition.string.end","\""], + ["text"," "], + ["identifier","inManagedObjectContext"], + ["punctuation.operator",":"], + ["identifier","context"], + ["paren.rparen","]"], + ["punctuation.operator",";"], + ["text"," "] +],[ + "start", + ["identifier","localRequest"], + ["punctuation.operator","."], + ["identifier","sortDescriptors"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.section.scope.begin.objc","["], + ["support.class.cocoa","NSArray"], + ["text"," "], + ["support.function.any-method.objc","arrayWithObject:"], + ["punctuation.section.scope.begin.objc","["], + ["support.class.cocoa","NSSortDescriptor"], + ["text"," "], + ["support.function.any-method.objc","sortDescriptorWithKey:"], + ["string.begin.objc","@\""], + ["string","resolution"], + ["punctuation.definition.string.end","\""], + ["text"," "], + ["identifier","ascending"], + ["punctuation.operator",":"], + ["constant.language.objc","YES"], + ["paren.rparen","]]"], + ["punctuation.operator",";"], + ["text"," "] +],[ + "start", + ["support.class.cocoa","NSPredicate"], + ["text"," "], + ["keyword.operator","*"], + ["identifier","predicate"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.section.scope.begin.objc","["], + ["support.class.cocoa","NSPredicate"], + ["text"," "], + ["support.function.any-method.objc","predicateWithFormat:"], + ["string.begin.objc","@\""], + ["string","0 != SUBQUERY(image, $x, 0 != SUBQUERY($x.bookmarkItems, $y, $y.@count == 0).@count).@count"], + ["punctuation.definition.string.end","\""], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start", + ["punctuation.section.scope.begin.objc","["], + ["support.class.cocoa","NSPredicate"], + ["text"," "], + ["support.function.any-method.objc","predicateWithFormat:"], + ["paren.rparen","]"] +],[ + "start", + ["support.class.cocoa","NSString"], + ["text"," "], + ["keyword.operator","*"], + ["identifier","predicateString"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.section.scope.begin.objc","["], + ["support.class.cocoa","NSString"], + ["text"," "], + ["support.function.any-method.objc","stringWithFormat:"], + ["string.begin.objc","@\""], + ["string","SELF beginsWith[cd] %@"], + ["punctuation.definition.string.end","\""], + ["punctuation.operator",","], + ["text"," "], + ["identifier","searchString"], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start", + ["support.class.cocoa","NSPredicate"], + ["text"," "], + ["keyword.operator","*"], + ["identifier","pred"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.section.scope.begin.objc","["], + ["support.class.cocoa","NSPredicate"], + ["text"," "], + ["support.function.any-method.objc","predicateWithFormat:"], + ["identifier","predicateString"], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start", + ["support.class.cocoa","NSArray"], + ["text"," "], + ["keyword.operator","*"], + ["identifier","filteredKeys"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.section.scope.begin.objc","[["], + ["identifier","myMutableDictionary"], + ["text"," "], + ["support.function.any-method.objc","allKeys"], + ["paren.rparen","]"], + ["text"," "], + ["identifier","filteredArrayUsingPredicate"], + ["punctuation.operator",":"], + ["identifier","pred"], + ["paren.rparen","]"], + ["punctuation.operator",";"], + ["text"," "] +],[ + "start" +],[ + "start", + ["identifier","localRequest"], + ["punctuation.operator","."], + ["identifier","predicate"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.section.scope.begin.objc","["], + ["support.class.cocoa","NSPredicate"], + ["text"," "], + ["support.function.any-method.objc","predicateWithFormat:"], + ["string.begin.objc","@\""], + ["string","whichChart = %@"], + ["punctuation.definition.string.end","\""], + ["text"," "], + ["identifier","argumentArray"], + ["punctuation.operator",":"], + ["text"," "], + ["identifier","listChartToDownload"], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start", + ["identifier","localRequest"], + ["punctuation.operator","."], + ["identifier","fetchBatchSize"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","100"], + ["punctuation.operator",";"] +],[ + "start", + ["identifier","arrayRequest"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["punctuation.section.scope.begin.objc","["], + ["identifier","context"], + ["text"," "], + ["support.function.any-method.objc","executeFetchRequest:"], + ["identifier","localRequest"], + ["text"," "], + ["identifier","error"], + ["punctuation.operator",":"], + ["keyword.operator","&"], + ["identifier","error1"], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["punctuation.section.scope.begin.objc","["], + ["identifier","localRequest"], + ["text"," "], + ["support.function.any-method.objc","release"], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","#ifndef"], + ["text"," "], + ["constant.language.objc","Nil"] +],[ + "start", + ["keyword","#define"], + ["constant.other"," Nil __DARWIN_NULL "], + ["comment","/* id of Nil class */"] +],[ + "start", + ["keyword","#endif"] +],[ + "start" +],[ + "start", + ["storage.type.objc","@implementation"], + ["entity.name.type.objc"," MyObject"] +],[ + "start", + ["meta.function.objc","- "], + ["paren.lparen","("], + ["storage.type","unsigned"], + ["text"," "], + ["storage.type","int"], + ["paren.rparen",")"], + ["identifier","areaOfWidth"], + ["punctuation.operator",":"], + ["paren.lparen","("], + ["storage.type","unsigned"], + ["text"," "], + ["storage.type","int"], + ["paren.rparen",")"], + ["identifier","width"] +],[ + "start", + ["text"," "], + ["identifier","height"], + ["punctuation.operator",":"], + ["paren.lparen","("], + ["storage.type","unsigned"], + ["text"," "], + ["storage.type","int"], + ["paren.rparen",")"], + ["identifier","height"] +],[ + "start", + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.control","return"], + ["text"," "], + ["identifier","width"], + ["keyword.operator","*"], + ["identifier","height"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["storage.type.objc","@end"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_ocaml.json b/public/lib/ace/mode/_test/tokens_ocaml.json new file mode 100644 index 0000000..73e3cfc --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_ocaml.json @@ -0,0 +1,200 @@ +[[ + "comment", + ["comment","(*"] +],[ + "comment", + ["comment"," * Example of early return implementation taken from"] +],[ + "comment", + ["comment"," * http://ocaml.janestreet.com/?q=node/91"] +],[ + "start", + ["comment"," *)"] +],[ + "start" +],[ + "start", + ["keyword","let"], + ["text"," "], + ["identifier","with_return"], + ["text"," "], + ["paren.lparen","("], + ["keyword","type"], + ["text"," "], + ["identifier","t"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","("], + ["identifier","f"], + ["text"," : "], + ["identifier","_"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["identifier","t"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","="] +],[ + "start", + ["text"," "], + ["keyword","let"], + ["text"," "], + ["keyword","module"], + ["text"," "], + ["identifier","M"], + ["text"," "], + ["keyword.operator","="] +],[ + "start", + ["text"," "], + ["keyword","struct"], + ["text"," "], + ["keyword","exception"], + ["text"," "], + ["identifier","Return"], + ["text"," "], + ["keyword","of"], + ["text"," "], + ["identifier","t"], + ["text"," "], + ["keyword","end"] +],[ + "start", + ["text"," "], + ["keyword","in"] +],[ + "start", + ["text"," "], + ["keyword","let"], + ["text"," "], + ["identifier","return"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","return"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["keyword","fun"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["support.function","raise"], + ["text"," "], + ["paren.lparen","("], + ["identifier","M"], + ["text","."], + ["identifier","Return"], + ["text"," "], + ["identifier","x"], + ["paren.rparen","))"], + ["text","; "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","in"] +],[ + "start", + ["text"," "], + ["keyword","try"], + ["text"," "], + ["identifier","f"], + ["text"," "], + ["identifier","return"], + ["text"," "], + ["keyword","with"], + ["text"," "], + ["identifier","M"], + ["text","."], + ["identifier","Return"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["identifier","x"] +],[ + "start" +],[ + "start" +],[ + "start", + ["comment","(* Function that uses the 'early return' functionality provided by `with_return` *)"] +],[ + "start", + ["keyword","let"], + ["text"," "], + ["identifier","sum_until_first_negative"], + ["text"," "], + ["support.function","list"], + ["text"," "], + ["keyword.operator","="] +],[ + "start", + ["text"," "], + ["identifier","with_return"], + ["text"," "], + ["paren.lparen","("], + ["keyword","fun"], + ["text"," "], + ["identifier","r"], + ["text"," "], + ["keyword.operator","->"] +],[ + "start", + ["text"," "], + ["support.function","List"], + ["text","."], + ["support.function","fold"], + ["text"," "], + ["support.function","list"], + ["text"," "], + ["keyword.operator","~"], + ["support.function","init"], + ["text",":"], + ["constant.numeric","0"], + ["text"," "], + ["keyword.operator","~"], + ["identifier","f"], + ["text",":"], + ["paren.lparen","("], + ["keyword","fun"], + ["text"," "], + ["identifier","acc"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator","->"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["keyword","then"], + ["text"," "], + ["identifier","acc"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["identifier","r"], + ["text","."], + ["identifier","return"], + ["text"," "], + ["identifier","acc"], + ["paren.rparen","))"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_pascal.json b/public/lib/ace/mode/_test/tokens_pascal.json new file mode 100644 index 0000000..22c1f0c --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_pascal.json @@ -0,0 +1,297 @@ +[[ + "punctuation.definition.comment.pascal", + ["punctuation.definition.comment.pascal","(*"], + ["comment.block.pascal.one","****************************************************************************"] +],[ + "punctuation.definition.comment.pascal", + ["comment.block.pascal.one"," * A simple bubble sort program. Reads integers, one per line, and prints *"] +],[ + "punctuation.definition.comment.pascal", + ["comment.block.pascal.one"," * them out in sorted order. Blows up if there are more than 49. *"] +],[ + "start", + ["comment.block.pascal.one"," ****************************************************************************"], + ["punctuation.definition.comment.pascal","*)"] +],[ + "start", + ["keyword.control.pascal","PROGRAM"], + ["text"," Sort(input"], + ["keyword.operator",","], + ["text"," output)"], + ["keyword.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","CONST"] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.pascal","(*"], + ["comment.block.pascal.one"," Max array size. "], + ["punctuation.definition.comment.pascal","*)"] +],[ + "start", + ["text"," MaxElts "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric.pascal","50"], + ["keyword.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","TYPE"], + ["text"," "] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.pascal","(*"], + ["comment.block.pascal.one"," Type of the element array. "], + ["punctuation.definition.comment.pascal","*)"] +],[ + "start", + ["text"," IntArrType "], + ["keyword.operator","="], + ["text"," "], + ["keyword.control.pascal","ARRAY"], + ["text"," ["], + ["constant.numeric.pascal","1"], + ["text","..MaxElts] "], + ["keyword.control.pascal","OF"], + ["text"," Integer"], + ["keyword.operator",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword.control.pascal","VAR"] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.pascal","(*"], + ["comment.block.pascal.one"," Indexes, exchange temp, array size. "], + ["punctuation.definition.comment.pascal","*)"] +],[ + "start", + ["text"," i"], + ["keyword.operator",","], + ["text"," j"], + ["keyword.operator",","], + ["text"," tmp"], + ["keyword.operator",","], + ["text"," size: integer"], + ["keyword.operator",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.pascal","(*"], + ["comment.block.pascal.one"," Array of ints "], + ["punctuation.definition.comment.pascal","*)"] +],[ + "start", + ["text"," arr: IntArrType"], + ["keyword.operator",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.pascal","(*"], + ["comment.block.pascal.one"," Read in the integers. "], + ["punctuation.definition.comment.pascal","*)"] +],[ + "start", + ["text"," "], + ["variable.pascal","PROCEDURE"], + ["text"," "], + ["storage.type.function.pascal","ReadArr"], + ["text","("], + ["keyword.control.pascal","VAR"], + ["text"," size: Integer"], + ["keyword.operator",";"], + ["text"," "], + ["keyword.control.pascal","VAR"], + ["text"," a: IntArrType)"], + ["keyword.operator",";"], + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","BEGIN"] +],[ + "start", + ["text"," size "], + ["keyword.operator",":="], + ["text"," "], + ["constant.numeric.pascal","1"], + ["keyword.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","WHILE"], + ["text"," "], + ["keyword.control.pascal","NOT"], + ["text"," eof "], + ["keyword.control.pascal","DO"], + ["text"," "], + ["keyword.control.pascal","BEGIN"] +],[ + "start", + ["text"," readln(a[size])"], + ["keyword.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","IF"], + ["text"," "], + ["keyword.control.pascal","NOT"], + ["text"," eof "], + ["keyword.control.pascal","THEN"], + ["text"," "] +],[ + "start", + ["text"," size "], + ["keyword.operator",":="], + ["text"," size "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric.pascal","1"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","END"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","END"], + ["keyword.operator",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword.control.pascal","BEGIN"] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.pascal","(*"], + ["comment.block.pascal.one"," Read "], + ["punctuation.definition.comment.pascal","*)"] +],[ + "start", + ["text"," ReadArr(size"], + ["keyword.operator",","], + ["text"," arr)"], + ["keyword.operator",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.pascal","(*"], + ["comment.block.pascal.one"," Sort using bubble sort. "], + ["punctuation.definition.comment.pascal","*)"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","FOR"], + ["text"," i "], + ["keyword.operator",":="], + ["text"," size "], + ["keyword.operator","-"], + ["text"," "], + ["constant.numeric.pascal","1"], + ["text"," DOWNTO "], + ["constant.numeric.pascal","1"], + ["text"," "], + ["keyword.control.pascal","DO"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","FOR"], + ["text"," j "], + ["keyword.operator",":="], + ["text"," "], + ["constant.numeric.pascal","1"], + ["text"," "], + ["keyword.control.pascal","TO"], + ["text"," i "], + ["keyword.control.pascal","DO"], + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","IF"], + ["text"," arr[j] > arr[j "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric.pascal","1"], + ["text","] "], + ["keyword.control.pascal","THEN"], + ["text"," "], + ["keyword.control.pascal","BEGIN"] +],[ + "start", + ["text"," tmp "], + ["keyword.operator",":="], + ["text"," arr[j]"], + ["keyword.operator",";"] +],[ + "start", + ["text"," arr[j] "], + ["keyword.operator",":="], + ["text"," arr[j "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric.pascal","1"], + ["text","]"], + ["keyword.operator",";"] +],[ + "start", + ["text"," arr[j "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric.pascal","1"], + ["text","] "], + ["keyword.operator",":="], + ["text"," tmp"], + ["keyword.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","END"], + ["keyword.operator",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.pascal","(*"], + ["comment.block.pascal.one"," Print. "], + ["punctuation.definition.comment.pascal","*)"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","FOR"], + ["text"," i "], + ["keyword.operator",":="], + ["text"," "], + ["constant.numeric.pascal","1"], + ["text"," "], + ["keyword.control.pascal","TO"], + ["text"," size "], + ["keyword.control.pascal","DO"] +],[ + "start", + ["text"," writeln(arr[i])"] +],[ + "start", + ["text"," "], + ["keyword.control.pascal","END"], + ["text","."] +],[ + "start", + ["text"," "] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_perl.json b/public/lib/ace/mode/_test/tokens_perl.json new file mode 100644 index 0000000..30bb39c --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_perl.json @@ -0,0 +1,227 @@ +[[ + "start", + ["comment","#!/usr/bin/perl"] +],[ + "block_comment", + ["comment.doc","=begin"] +],[ + "block_comment", + ["comment.doc"," perl example code for Ace"] +],[ + "start", + ["comment.doc","=cut"] +],[ + "start" +],[ + "start", + ["keyword","use"], + ["text"," "], + ["identifier","strict"], + ["text",";"] +],[ + "start", + ["keyword","use"], + ["text"," "], + ["identifier","warnings"], + ["text",";"] +],[ + "start", + ["keyword","my"], + ["text"," "], + ["identifier","$num_primes"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["text",";"] +],[ + "start", + ["keyword","my"], + ["text"," @"], + ["identifier","primes"], + ["text",";"] +],[ + "start" +],[ + "start", + ["comment","# Put 2 as the first prime so we won't have an empty array"] +],[ + "start", + ["identifier","$primes"], + ["lparen","["], + ["identifier","$num_primes"], + ["rparen","]"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["identifier","$num_primes"], + ["keyword.operator","++"], + ["text",";"] +],[ + "start" +],[ + "start", + ["identifier","MAIN_LOOP"], + ["text",":"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["keyword","my"], + ["text"," "], + ["identifier","$number_to_check"], + ["text"," "], + ["lparen","("], + ["constant.numeric","3"], + ["text"," "], + ["keyword.operator",".."], + ["text"," "], + ["constant.numeric","200"], + ["rparen",")"] +],[ + "start", + ["lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["keyword","my"], + ["text"," "], + ["identifier","$p"], + ["text"," "], + ["lparen","("], + ["constant.numeric","0"], + ["text"," "], + ["keyword.operator",".."], + ["text"," "], + ["lparen","("], + ["identifier","$num_primes"], + ["constant.numeric","-1"], + ["rparen","))"] +],[ + "start", + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["lparen","("], + ["identifier","$number_to_check"], + ["text"," "], + ["keyword.operator","%"], + ["text"," "], + ["identifier","$primes"], + ["lparen","["], + ["identifier","$p"], + ["rparen","]"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.numeric","0"], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","next"], + ["text"," "], + ["identifier","MAIN_LOOP"], + ["text",";"] +],[ + "start", + ["text"," "], + ["rparen","}"] +],[ + "start", + ["text"," "], + ["rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","# If we reached this point it means $number_to_check is not"] +],[ + "start", + ["text"," "], + ["comment","# divisable by any prime number that came before it."] +],[ + "start", + ["text"," "], + ["identifier","$primes"], + ["lparen","["], + ["identifier","$num_primes"], + ["rparen","]"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","$number_to_check"], + ["text",";"] +],[ + "start", + ["text"," "], + ["identifier","$num_primes"], + ["keyword.operator","++"], + ["text",";"] +],[ + "start", + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","for"], + ["text"," "], + ["keyword","my"], + ["text"," "], + ["identifier","$p"], + ["text"," "], + ["lparen","("], + ["constant.numeric","0"], + ["text"," "], + ["keyword.operator",".."], + ["text"," "], + ["lparen","("], + ["identifier","$num_primes"], + ["constant.numeric","-1"], + ["rparen","))"] +],[ + "start", + ["lparen","{"] +],[ + "start", + ["text"," "], + ["support.function","print"], + ["text"," "], + ["identifier","$primes"], + ["lparen","["], + ["identifier","$p"], + ["rparen","]"], + ["keyword.operator",","], + ["text"," "], + ["string","\", \""], + ["text",";"] +],[ + "start", + ["rparen","}"] +],[ + "start", + ["support.function","print"], + ["text"," "], + ["string","\"\\n\""], + ["text",";"] +],[ + "start" +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_pgsql.json b/public/lib/ace/mode/_test/tokens_pgsql.json new file mode 100644 index 0000000..fef23fd --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_pgsql.json @@ -0,0 +1,889 @@ +[[ + "start" +],[ + "start", + ["keyword.statementBegin","BEGIN"], + ["statementEnd",";"] +],[ + "start" +],[ + "doc-start", + ["comment.doc","/**"] +],[ + "doc-start", + ["comment.doc","* Samples from PostgreSQL src/tutorial/basics.source"] +],[ + "start", + ["comment.doc","*/"] +],[ + "statement", + ["keyword.statementBegin","CREATE"], + ["text"," "], + ["keyword","TABLE"], + ["text"," "], + ["identifier","weather"], + ["text"," "], + ["paren.lparen","("] +],[ + "statement", + ["text","\t"], + ["identifier","city"], + ["text","\t\t"], + ["keyword","varchar"], + ["paren.lparen","("], + ["constant.numeric","80"], + ["paren.rparen",")"], + ["text",","] +],[ + "statement", + ["text","\t"], + ["identifier","temp_lo"], + ["text","\t\t"], + ["keyword","int"], + ["text",",\t\t"], + ["comment","-- low temperature"] +],[ + "statement", + ["text","\t"], + ["identifier","temp_hi"], + ["text","\t\t"], + ["keyword","int"], + ["text",",\t\t"], + ["comment","-- high temperature"] +],[ + "statement", + ["text","\t"], + ["identifier","prcp"], + ["text","\t\t"], + ["keyword","real"], + ["text",",\t\t"], + ["comment","-- precipitation"] +],[ + "statement", + ["text","\t"], + ["variable.language","\"date\""], + ["text","\t\t"], + ["keyword","date"] +],[ + "start", + ["paren.rparen",")"], + ["statementEnd",";"] +],[ + "start" +],[ + "statement", + ["keyword.statementBegin","CREATE"], + ["text"," "], + ["keyword","TABLE"], + ["text"," "], + ["identifier","cities"], + ["text"," "], + ["paren.lparen","("] +],[ + "statement", + ["text","\t"], + ["keyword","name"], + ["text","\t\t"], + ["keyword","varchar"], + ["paren.lparen","("], + ["constant.numeric","80"], + ["paren.rparen",")"], + ["text",","] +],[ + "statement", + ["text","\t"], + ["keyword","location"], + ["text","\t"], + ["keyword","point"] +],[ + "start", + ["paren.rparen",")"], + ["statementEnd",";"] +],[ + "start" +],[ + "start" +],[ + "statement", + ["keyword.statementBegin","INSERT"], + ["text"," "], + ["keyword","INTO"], + ["text"," "], + ["identifier","weather"] +],[ + "start", + ["text"," "], + ["keyword","VALUES"], + ["text"," "], + ["paren.lparen","("], + ["string","'San Francisco'"], + ["text",", "], + ["constant.numeric","46"], + ["text",", "], + ["constant.numeric","50"], + ["text",", "], + ["constant.numeric","0.25"], + ["text",", "], + ["string","'1994-11-27'"], + ["paren.rparen",")"], + ["statementEnd",";"] +],[ + "start" +],[ + "statement", + ["keyword.statementBegin","INSERT"], + ["text"," "], + ["keyword","INTO"], + ["text"," "], + ["identifier","cities"] +],[ + "start", + ["text"," "], + ["keyword","VALUES"], + ["text"," "], + ["paren.lparen","("], + ["string","'San Francisco'"], + ["text",", "], + ["string","'(-194.0, 53.0)'"], + ["paren.rparen",")"], + ["statementEnd",";"] +],[ + "start" +],[ + "statement", + ["keyword.statementBegin","INSERT"], + ["text"," "], + ["keyword","INTO"], + ["text"," "], + ["identifier","weather"], + ["text"," "], + ["paren.lparen","("], + ["identifier","city"], + ["text",", "], + ["identifier","temp_lo"], + ["text",", "], + ["identifier","temp_hi"], + ["text",", "], + ["identifier","prcp"], + ["text",", "], + ["variable.language","\"date\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","VALUES"], + ["text"," "], + ["paren.lparen","("], + ["string","'San Francisco'"], + ["text",", "], + ["constant.numeric","43"], + ["text",", "], + ["constant.numeric","57"], + ["text",", "], + ["constant.numeric","0.0"], + ["text",", "], + ["string","'1994-11-29'"], + ["paren.rparen",")"], + ["statementEnd",";"] +],[ + "start" +],[ + "statement", + ["keyword.statementBegin","INSERT"], + ["text"," "], + ["keyword","INTO"], + ["text"," "], + ["identifier","weather"], + ["text"," "], + ["paren.lparen","("], + ["keyword","date"], + ["text",", "], + ["identifier","city"], + ["text",", "], + ["identifier","temp_hi"], + ["text",", "], + ["identifier","temp_lo"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","VALUES"], + ["text"," "], + ["paren.lparen","("], + ["string","'1994-11-29'"], + ["text",", "], + ["string","'Hayward'"], + ["text",", "], + ["constant.numeric","54"], + ["text",", "], + ["constant.numeric","37"], + ["paren.rparen",")"], + ["statementEnd",";"] +],[ + "start" +],[ + "start" +],[ + "start", + ["keyword.statementBegin","SELECT"], + ["text"," "], + ["identifier","city"], + ["text",", "], + ["paren.lparen","("], + ["identifier","temp_hi"], + ["keyword.operator","+"], + ["identifier","temp_lo"], + ["paren.rparen",")"], + ["keyword.operator","/"], + ["constant.numeric","2"], + ["text"," "], + ["keyword","AS"], + ["text"," "], + ["identifier","temp_avg"], + ["text",", "], + ["variable.language","\"date\""], + ["text"," "], + ["keyword","FROM"], + ["text"," "], + ["identifier","weather"], + ["statementEnd",";"] +],[ + "start" +],[ + "statement", + ["keyword.statementBegin","SELECT"], + ["text"," "], + ["identifier","city"], + ["text",", "], + ["identifier","temp_lo"], + ["text",", "], + ["identifier","temp_hi"], + ["text",", "], + ["identifier","prcp"], + ["text",", "], + ["variable.language","\"date\""], + ["text",", "], + ["keyword","location"] +],[ + "statement", + ["text"," "], + ["keyword","FROM"], + ["text"," "], + ["identifier","weather"], + ["text",", "], + ["identifier","cities"] +],[ + "start", + ["text"," "], + ["keyword","WHERE"], + ["text"," "], + ["identifier","city"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["keyword","name"], + ["statementEnd",";"] +],[ + "start" +],[ + "start" +],[ + "start" +],[ + "doc-start", + ["comment.doc","/**"] +],[ + "doc-start", + ["comment.doc","* Dollar quotes starting at the end of the line are colored as SQL unless"] +],[ + "doc-start", + ["comment.doc","* a special language tag is used. Dollar quote syntax coloring is implemented"] +],[ + "doc-start", + ["comment.doc","* for Perl, Python, JavaScript, and Json."] +],[ + "start", + ["comment.doc","*/"] +],[ + "statement", + ["keyword.statementBegin","create"], + ["text"," "], + ["keyword","or"], + ["text"," "], + ["keyword","replace"], + ["text"," "], + ["keyword","function"], + ["text"," "], + ["identifier","blob_content_chunked"], + ["paren.lparen","("] +],[ + "statement", + ["text"," "], + ["keyword","in"], + ["text"," "], + ["identifier","p_data"], + ["text"," "], + ["keyword","bytea"], + ["text",", "] +],[ + "statement", + ["text"," "], + ["keyword","in"], + ["text"," "], + ["identifier","p_chunk"], + ["text"," "], + ["keyword","integer"], + ["paren.rparen",")"] +],[ + "dollarSql", + ["keyword","returns"], + ["text"," "], + ["keyword","setof"], + ["text"," "], + ["keyword","bytea"], + ["text"," "], + ["keyword","as"], + ["text"," "], + ["string","$$"] +],[ + "dollarSql", + ["comment","-- Still SQL comments"] +],[ + "dollarSql", + ["keyword","declare"] +],[ + "dollarSql", + ["text","\t"], + ["identifier","v_size"], + ["text"," "], + ["keyword","integer"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","octet_length"], + ["paren.lparen","("], + ["identifier","p_data"], + ["paren.rparen",")"], + ["text",";"] +],[ + "dollarSql", + ["keyword","begin"] +],[ + "dollarSql", + ["text","\t"], + ["keyword","for"], + ["text"," "], + ["identifier","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["constant.numeric","1"], + ["text",".."], + ["identifier","v_size"], + ["text"," "], + ["keyword","by"], + ["text"," "], + ["identifier","p_chunk"], + ["text"," "], + ["identifier","loop"] +],[ + "dollarSql", + ["text","\t\t"], + ["identifier","return"], + ["text"," "], + ["keyword","next"], + ["text"," "], + ["keyword","substring"], + ["paren.lparen","("], + ["identifier","p_data"], + ["text"," "], + ["keyword","from"], + ["text"," "], + ["identifier","i"], + ["text"," "], + ["keyword","for"], + ["text"," "], + ["identifier","p_chunk"], + ["paren.rparen",")"], + ["text",";"] +],[ + "dollarSql", + ["text","\t"], + ["keyword","end"], + ["text"," "], + ["identifier","loop"], + ["text",";"] +],[ + "dollarSql", + ["keyword","end"], + ["text",";"] +],[ + "start", + ["string","$$"], + ["text"," "], + ["keyword","language"], + ["text"," "], + ["identifier","plpgsql"], + ["text"," "], + ["keyword","stable"], + ["statementEnd",";"] +],[ + "start" +],[ + "start" +],[ + "start", + ["comment","-- pl/perl"] +],[ + "perl-start", + ["keyword.statementBegin","CREATE"], + ["text"," "], + ["keyword","FUNCTION"], + ["text"," "], + ["identifier","perl_max"], + ["text"," "], + ["paren.lparen","("], + ["keyword","integer"], + ["text",", "], + ["keyword","integer"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","RETURNS"], + ["text"," "], + ["keyword","integer"], + ["text"," "], + ["keyword","AS"], + ["text"," "], + ["string","$perl$"] +],[ + "perl-start", + ["text"," "], + ["comment","# perl comment..."] +],[ + "perl-start", + ["text"," "], + ["keyword","my"], + ["text"," "], + ["lparen","("], + ["identifier","$x"], + ["keyword.operator",","], + ["identifier","$y"], + ["rparen",")"], + ["text"," "], + ["keyword.operator","="], + ["text"," @"], + ["identifier","_"], + ["text",";"] +],[ + "perl-start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["lparen","("], + ["keyword.operator","!"], + ["text"," "], + ["support.function","defined"], + ["text"," "], + ["identifier","$x"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "perl-start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["lparen","("], + ["keyword.operator","!"], + ["text"," "], + ["support.function","defined"], + ["text"," "], + ["identifier","$y"], + ["rparen",")"], + ["text"," "], + ["lparen","{"], + ["text"," "], + ["support.function","return"], + ["text"," "], + ["support.function","undef"], + ["text","; "], + ["rparen","}"] +],[ + "perl-start", + ["text"," "], + ["support.function","return"], + ["text"," "], + ["identifier","$y"], + ["text",";"] +],[ + "perl-start", + ["text"," "], + ["rparen","}"] +],[ + "perl-start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["lparen","("], + ["keyword.operator","!"], + ["text"," "], + ["support.function","defined"], + ["text"," "], + ["identifier","$y"], + ["rparen",")"], + ["text"," "], + ["lparen","{"], + ["text"," "], + ["support.function","return"], + ["text"," "], + ["identifier","$x"], + ["text","; "], + ["rparen","}"] +],[ + "perl-start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["lparen","("], + ["identifier","$x"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["identifier","$y"], + ["rparen",")"], + ["text"," "], + ["lparen","{"], + ["text"," "], + ["support.function","return"], + ["text"," "], + ["identifier","$x"], + ["text","; "], + ["rparen","}"] +],[ + "perl-start", + ["text"," "], + ["support.function","return"], + ["text"," "], + ["identifier","$y"], + ["text",";"] +],[ + "start", + ["string","$perl$"], + ["text"," "], + ["keyword","LANGUAGE"], + ["text"," "], + ["identifier","plperl"], + ["statementEnd",";"] +],[ + "start" +],[ + "start", + ["comment","-- pl/python"] +],[ + "python-start", + ["keyword.statementBegin","CREATE"], + ["text"," "], + ["keyword","FUNCTION"], + ["text"," "], + ["identifier","usesavedplan"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["keyword","RETURNS"], + ["text"," "], + ["keyword","trigger"], + ["text"," "], + ["keyword","AS"], + ["text"," "], + ["string","$python$"] +],[ + "python-start", + ["text"," "], + ["comment","# python comment..."] +],[ + "python-start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["identifier","SD"], + ["text","."], + ["identifier","has_key"], + ["paren.lparen","("], + ["string","\"plan\""], + ["paren.rparen",")"], + ["text",":"] +],[ + "python-start", + ["text"," "], + ["identifier","plan"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","SD"], + ["paren.lparen","["], + ["string","\"plan\""], + ["paren.rparen","]"] +],[ + "python-start", + ["text"," "], + ["keyword","else"], + ["text",":"] +],[ + "python-start", + ["text"," "], + ["identifier","plan"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","plpy"], + ["text","."], + ["identifier","prepare"], + ["paren.lparen","("], + ["string","\"SELECT 1\""], + ["paren.rparen",")"] +],[ + "python-start", + ["text"," "], + ["identifier","SD"], + ["paren.lparen","["], + ["string","\"plan\""], + ["paren.rparen","]"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","plan"] +],[ + "start", + ["string","$python$"], + ["text"," "], + ["keyword","LANGUAGE"], + ["text"," "], + ["identifier","plpythonu"], + ["statementEnd",";"] +],[ + "start" +],[ + "start", + ["comment","-- pl/v8 (javascript)"] +],[ + "javascript-start", + ["keyword.statementBegin","CREATE"], + ["text"," "], + ["keyword","FUNCTION"], + ["text"," "], + ["identifier","plv8_test"], + ["paren.lparen","("], + ["identifier","keys"], + ["text"," "], + ["keyword","text"], + ["text","[], "], + ["identifier","vals"], + ["text"," "], + ["keyword","text"], + ["text","[]"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","RETURNS"], + ["text"," "], + ["keyword","text"], + ["text"," "], + ["keyword","AS"], + ["text"," "], + ["string","$javascript$"] +],[ + "javascript-start", + ["storage.type","var"], + ["text"," "], + ["identifier","o"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"], + ["paren.rparen","}"], + ["punctuation.operator",";"] +],[ + "javascript-start", + ["keyword","for"], + ["paren.lparen","("], + ["storage.type","var"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","="], + ["constant.numeric","0"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","<"], + ["identifier","keys"], + ["punctuation.operator","."], + ["support.constant","length"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","++"], + ["paren.rparen",")"], + ["paren.lparen","{"] +],[ + "javascript-start", + ["text"," "], + ["identifier","o"], + ["paren.lparen","["], + ["identifier","keys"], + ["paren.lparen","["], + ["identifier","i"], + ["paren.rparen","]]"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","vals"], + ["paren.lparen","["], + ["identifier","i"], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "javascript-no_regex", + ["paren.rparen","}"] +],[ + "javascript-start", + ["keyword","return"], + ["text"," "], + ["variable.language","JSON"], + ["punctuation.operator","."], + ["identifier","stringify"], + ["paren.lparen","("], + ["identifier","o"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["string","$javascript$"], + ["text"," "], + ["keyword","LANGUAGE"], + ["text"," "], + ["identifier","plv8"], + ["text"," "], + ["keyword","IMMUTABLE"], + ["text"," "], + ["keyword","STRICT"], + ["statementEnd",";"] +],[ + "start" +],[ + "start", + ["comment","-- json"] +],[ + "json-start", + ["keyword.statementBegin","select"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["keyword","from"], + ["text"," "], + ["support.function","json_object_keys"], + ["paren.lparen","("], + ["string","$json$"] +],[ + "json-start", + ["paren.lparen","{"] +],[ + "json-start", + ["text"," "], + ["variable","\"f1\""], + ["text",": "], + ["constant.numeric","5"], + ["text",","] +],[ + "json-start", + ["text"," "], + ["variable","\"f2\""], + ["text",": "], + ["string","\"test\""], + ["text",","] +],[ + "json-start", + ["text"," "], + ["variable","\"f3\""], + ["text",": "], + ["paren.lparen","{"], + ["paren.rparen","}"] +],[ + "json-start", + ["paren.rparen","}"] +],[ + "start", + ["string","$json$"], + ["paren.rparen",")"], + ["statementEnd",";"] +],[ + "start" +],[ + "start" +],[ + "start", + ["comment","-- psql commands"] +],[ + "start", + ["support.buildin","\\df cash*"] +],[ + "start" +],[ + "start" +],[ + "start", + ["comment","-- Some string samples."] +],[ + "start", + ["keyword.statementBegin","select"], + ["text"," "], + ["string","'don''t do it now;'"], + ["text"," "], + ["keyword.operator","||"], + ["text"," "], + ["string","'maybe later'"], + ["statementEnd",";"] +],[ + "start", + ["keyword.statementBegin","select"], + ["text"," "], + ["identifier","E"], + ["string","'dont\\'t do it'"], + ["statementEnd",";"] +],[ + "start", + ["keyword.statementBegin","select"], + ["text"," "], + ["support.function","length"], + ["paren.lparen","("], + ["string","'some other''s stuff'"], + ["text"," "], + ["keyword.operator","||"], + ["text"," "], + ["string","$$cat in hat's stuff $$"], + ["paren.rparen",")"], + ["statementEnd",";"] +],[ + "start" +],[ + "dollarStatementString", + ["keyword.statementBegin","select"], + ["text"," "], + ["string","$$ strings"] +],[ + "dollarStatementString", + ["string","over multiple "] +],[ + "dollarStatementString", + ["string","lines - use dollar quotes"] +],[ + "start", + ["string","$$"], + ["statementEnd",";"] +],[ + "start" +],[ + "start", + ["keyword.statementBegin","END"], + ["statementEnd",";"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_php.json b/public/lib/ace/mode/_test/tokens_php.json new file mode 100644 index 0000000..3269125 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_php.json @@ -0,0 +1,171 @@ +[[ + "php-start", + ["support.php_tag",""], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text"," "], + ["support.php_tag",""] +],[ + "js-comment1", + ["comment","/*this is js "], + ["support.php_tag",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," not "], + ["constant.language.escape.reference.xml","&js;"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_powershell.json b/public/lib/ace/mode/_test/tokens_powershell.json new file mode 100644 index 0000000..43b77db --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_powershell.json @@ -0,0 +1,184 @@ +[[ + "start", + ["comment","# This is a simple comment"] +],[ + "start", + ["keyword","function"], + ["text"," "], + ["identifier","Hello"], + ["lparen","("], + ["variable.instance","$name"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","Write-host"], + ["text"," "], + ["string","\"Hello $name\""] +],[ + "start", + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","function"], + ["text"," "], + ["identifier","add"], + ["lparen","("], + ["variable.instance","$left"], + ["text",", "], + ["variable.instance","$right"], + ["keyword.operator","="], + ["constant.numeric","4"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["lparen","("], + ["variable.instance","$right"], + ["text"," "], + ["keyword.operator","-ne"], + ["text"," "], + ["constant.numeric","4"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","return"], + ["text"," "], + ["variable.instance","$left"] +],[ + "start", + ["text"," "], + ["rparen","}"], + ["text"," "], + ["keyword","elseif"], + ["text"," "], + ["lparen","("], + ["variable.instance","$left"], + ["text"," "], + ["keyword.operator","-eq"], + ["text"," "], + ["constant.language","$null"], + ["text"," "], + ["keyword.operator","-and"], + ["text"," "], + ["variable.instance","$right"], + ["text"," "], + ["keyword.operator","-eq"], + ["text"," "], + ["constant.numeric","2"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","return"], + ["text"," "], + ["constant.numeric","3"] +],[ + "start", + ["text"," "], + ["rparen","}"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","return"], + ["text"," "], + ["constant.numeric","2"] +],[ + "start", + ["text"," "], + ["rparen","}"] +],[ + "start", + ["rparen","}"] +],[ + "start" +],[ + "start", + ["variable.instance","$number"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["variable.instance","$number"], + ["text"," "], + ["keyword.operator","+="], + ["text"," "], + ["constant.numeric","3"] +],[ + "start" +],[ + "start", + ["support.function","Write-Host"], + ["text"," "], + ["identifier","Hello"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","name"], + ["text"," "], + ["string","\"World\""] +],[ + "start" +],[ + "start", + ["variable.instance","$an_array"], + ["text"," "], + ["keyword.operator","="], + ["text"," @"], + ["lparen","("], + ["constant.numeric","1"], + ["text",", "], + ["constant.numeric","2"], + ["text",", "], + ["constant.numeric","3"], + ["rparen",")"] +],[ + "start", + ["variable.instance","$a_hash"], + ["text"," "], + ["keyword.operator","="], + ["text"," @"], + ["lparen","{"], + ["string","\"something\""], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"something else\""], + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword.operator","&"], + ["text"," "], + ["identifier","notepad"], + ["text"," .\\"], + ["identifier","readme"], + ["text","."], + ["identifier","md"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_praat.json b/public/lib/ace/mode/_test/tokens_praat.json new file mode 100644 index 0000000..2dff34b --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_praat.json @@ -0,0 +1,955 @@ +[[ + "form", + ["keyword","form"], + ["text"," "], + ["entity.name.section","Highlighter test"] +],[ + "form", + ["text"," "], + ["keyword","sentence "], + ["text","My_sentence "], + ["string","This should all be a string"] +],[ + "form", + ["text"," "], + ["keyword","text "], + ["text","My_text "], + ["string","This should also all be a string"] +],[ + "form", + ["text"," "], + ["keyword","word "], + ["text","My_word "], + ["string","Only"], + ["invalid.illegal"," the first word is a string, the rest is invalid"] +],[ + "form", + ["text"," "], + ["keyword","boolean "], + ["text","Binary "], + ["constant.language","1"] +],[ + "form", + ["text"," "], + ["keyword","boolean "], + ["text","Text "], + ["constant.language","no"] +],[ + "form", + ["text"," "], + ["keyword","boolean "], + ["text","Quoted "], + ["constant.language","\"yes\""] +],[ + "form", + ["text"," "], + ["keyword","comment "], + ["string","This should be a string"] +],[ + "form", + ["text"," "], + ["keyword","real "], + ["text","left_Range "], + ["constant.numeric","-123.6"] +],[ + "form", + ["text"," "], + ["keyword","positive "], + ["text","right_Range_max "], + ["constant.numeric","3.3"] +],[ + "form", + ["text"," "], + ["keyword","integer "], + ["text","Int "], + ["constant.numeric","4"] +],[ + "form", + ["text"," "], + ["keyword","natural "], + ["text","Nat "], + ["constant.numeric","4"] +],[ + "start", + ["keyword","endform"] +],[ + "start" +],[ + "start", + ["comment","# External scripts"] +],[ + "start", + ["keyword","include"], + ["text"," "], + ["string","/path/to/file"] +],[ + "start", + ["support.function","runScript"], + ["text",":"], + ["text"," "], + ["string","\"/path/to/file\""] +],[ + "start", + ["keyword","execute"], + ["text"," "], + ["string","/path/to/file"] +],[ + "start" +],[ + "start", + ["keyword","stopwatch"] +],[ + "start" +],[ + "start", + ["comment","# old-style procedure call"] +],[ + "start", + ["keyword","call"], + ["text"," "], + ["entity.name.function","oldStyle"], + ["text"," "], + ["string","\"quoted\""], + ["text"," "], + ["constant.numeric","2"], + ["text"," unquoted string"] +],[ + "start", + ["keyword","assert"], + ["text"," oldStyle.local"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"] +],[ + "start" +],[ + "start", + ["comment","# New-style procedure call with parens"] +],[ + "start", + ["entity.name.function","@newStyle"], + ["text","("], + ["string","\"quoted\""], + ["text",", "], + ["constant.numeric","2"], + ["text",", "], + ["string","\"quoted string\""], + ["text",")"] +],[ + "start", + ["keyword","if"], + ["text"," "], + ["variable.language","praatVersion"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","5364"], + ["text"," "] +],[ + "start", + ["comment"," # New-style procedure call with colon"] +],[ + "start", + ["text"," "], + ["entity.name.function","@newStyle"], + ["text",":"], + ["text"," "], + ["string","\"quoted\""], + ["text",", "], + ["constant.numeric","2"], + ["text",", "], + ["string","\"quoted string\""] +],[ + "start", + ["keyword","endif"] +],[ + "start" +],[ + "start", + ["comment","# if-block with built-in variables"] +],[ + "start", + ["keyword","if"], + ["text"," "], + ["variable.language","windows"] +],[ + "start", + ["comment"," # We are on Windows"] +],[ + "start", + ["keyword","elsif"], + ["text"," "], + ["variable.language","unix"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["keyword.operator","or"], + ["text"," "], + ["text","!"], + ["variable.language","macintosh"] +],[ + "start", + ["text"," "], + ["support.function","exitScript"], + ["text",":"], + ["text"," "], + ["string","\"We are on Linux\""] +],[ + "start", + ["keyword","else"], + ["text"," "], + ["variable.language","macintosh"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","exit"], + ["text"," "], + ["string","We are on Mac"] +],[ + "start", + ["keyword","endif"] +],[ + "start" +],[ + "start", + ["comment","# inline if with inline comment"] +],[ + "start", + ["text","var"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable.language","macintosh"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["keyword","then"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["keyword","fi"], + ["text"," "], + ["comment","; This is an inline comment"] +],[ + "start" +],[ + "start", + ["comment","# for-loop with explicit from using local variable"] +],[ + "start", + ["comment","# and paren-style function calls and variable interpolation"] +],[ + "start", + ["text","n"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","numberOfSelected"], + ["text","("], + ["string","\"Sound\""], + ["text",")"] +],[ + "start", + ["keyword","for"], + ["text"," i "], + ["keyword","from"], + ["text"," newStyle.local "], + ["keyword","to"], + ["text"," n"] +],[ + "start", + ["text"," sound"], + ["string.interpolated","'i'"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","selected"], + ["text","("], + ["string","\"Sound\""], + ["text",", i)"] +],[ + "start", + ["text"," sound[i]"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["text","sound"], + ["string.interpolated","'i'"] +],[ + "start", + ["keyword","endfor"] +],[ + "start" +],[ + "start", + ["keyword","for"], + ["text"," i "], + ["keyword","from"], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["keyword","to"], + ["text"," n"] +],[ + "start", + ["comment"," # Different styles of object selection"] +],[ + "start", + ["text"," "], + ["keyword","select"], + ["text"," sound"], + ["string.interpolated","'i'"] +],[ + "start", + ["text"," sound"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","selected"], + ["text","("], + ["text",")"] +],[ + "start", + ["text"," sound$"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","selected$"], + ["text","("], + ["string","\"Sound\""], + ["text",")"] +],[ + "start", + ["text"," "], + ["keyword","select"], + ["text"," "], + ["entity.name.type","Sound"], + ["text"," "], + ["string.interpolated","'sound$'"] +],[ + "start", + ["text"," "], + ["support.function","selectObject"], + ["text","("], + ["text","sound[i])"] +],[ + "start", + ["text"," "], + ["support.function","selectObject"], + ["text",":"], + ["text"," sound"] +],[ + "start", + ["text"," "] +],[ + "start", + ["comment"," # Pause commands"] +],[ + "start", + ["text"," "], + ["support.function","beginPause"], + ["text","("], + ["string","\"Viewing \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["text","sound$)"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," i"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," button"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","endPause"], + ["text","("], + ["string","\"Stop\""], + ["text",", "], + ["string","\"Previous\""], + ["text",","] +],[ + "start", + ["text"," ..."], + ["keyword","if"], + ["text"," i"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["text","total_sounds "], + ["keyword","then"], + ["text"," "], + ["string","\"Finish\""], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["string","\"Next\""], + ["text"," "], + ["keyword","fi"], + ["text",","] +],[ + "start", + ["text"," ..."], + ["constant.numeric","3"], + ["text",", "], + ["constant.numeric","1"], + ["text",")"] +],[ + "start", + ["text"," "], + ["keyword","else"] +],[ + "start", + ["text"," button"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","endPause"], + ["text","("], + ["string","\"Stop\""], + ["text",","] +],[ + "start", + ["text"," ..."], + ["keyword","if"], + ["text"," i"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["text","total_sounds "], + ["keyword","then"], + ["text"," "], + ["string","\"Finish\""], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["string","\"Next\""], + ["text"," "], + ["keyword","fi"], + ["text",","] +],[ + "start", + ["text"," ..."], + ["constant.numeric","2"], + ["text",", "], + ["constant.numeric","1"], + ["text",") "] +],[ + "start", + ["text"," "], + ["keyword","endif"] +],[ + "start", + ["text"," editor_name$"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["keyword","if"], + ["text"," total_textgrids "], + ["keyword","then"], + ["text"," "], + ["string","\"TextGrid \""], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["string","\"Sound \""], + ["text"," "], + ["keyword","fi"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["text","name$"] +],[ + "start", + ["text"," nocheck editor "], + ["string.interpolated","'editor_name$'"] +],[ + "start", + ["text"," "], + ["keyword","nocheck"], + ["text"," "], + ["keyword","Close"] +],[ + "start", + ["text"," nocheck endeditor"] +],[ + "start", + ["text"," "] +],[ + "start", + ["comment"," # New-style standalone command call"] +],[ + "start", + ["text"," "], + ["keyword","Rename:"], + ["text"," "], + ["string","\"SomeName\""] +],[ + "start" +],[ + "start", + ["comment"," # Command call with assignment"] +],[ + "start", + ["text"," "], + ["text","duration "], + ["keyword.operator","="], + ["text"," "], + ["keyword","Get total duration"] +],[ + "start", + ["text"," "] +],[ + "start", + ["comment"," # Multi-line command with modifier"] +],[ + "start", + ["text"," "], + ["text","pitch "], + ["keyword.operator","="], + ["text"," "], + ["keyword","noprogress"], + ["text"," "], + ["keyword","To Pitch (ac):"], + ["text"," "], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","75"], + ["text",", "], + ["constant.numeric","15"], + ["text",", "], + ["string","\"no\""], + ["text",","] +],[ + "start", + ["text"," ..."], + ["constant.numeric","0.03"], + ["text",", "], + ["constant.numeric","0.45"], + ["text",", "], + ["constant.numeric","0.01"], + ["text",", "], + ["constant.numeric","0.35"], + ["text",", "], + ["constant.numeric","0.14"], + ["text",", "], + ["constant.numeric","600"] +],[ + "start", + ["text"," "] +],[ + "start", + ["comment"," # do-style command with assignment"] +],[ + "start", + ["text"," minimum"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","do"], + ["text","("], + ["string","\"Get minimum...\""], + ["text",", "], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0"], + ["text",", "], + ["string","\"Hertz\""], + ["text",", "], + ["string","\"Parabolic\""], + ["text",")"] +],[ + "start" +],[ + "start", + ["comment"," # New-style multi-line command call with broken strings"] +],[ + "start", + ["text"," "], + ["text","table "], + ["keyword.operator","="], + ["text"," "], + ["keyword","Create Table with column names:"], + ["text"," "], + ["string","\"table\""], + ["text",", "], + ["constant.numeric","0"], + ["text",","] +],[ + "brokenstring", + ["text"," ..."], + ["string","\"file subject speaker"] +],[ + "start", + ["text"," ..."], + ["string","f0 f1 f2 f3 "], + ["string","\""], + ["text"," +"] +],[ + "start", + ["text"," ..."], + ["string","\"duration response\""] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["support.function","removeObject"], + ["text",":"], + ["text"," pitch, table"] +],[ + "start", + ["text"," "] +],[ + "start", + ["comment"," # Picture window commands"] +],[ + "start", + ["text"," "], + ["support.function","selectObject"], + ["text",":"], + ["text"," sound"] +],[ + "start", + ["comment"," # do-style command"] +],[ + "start", + ["text"," "], + ["support.function","do"], + ["text","("], + ["string","\"Select inner viewport...\""], + ["text",", "], + ["constant.numeric","1"], + ["text",", "], + ["constant.numeric","6"], + ["text",", "], + ["constant.numeric","0.5"], + ["text",", "], + ["constant.numeric","1.5"], + ["text",")"] +],[ + "start", + ["text"," "], + ["keyword","Black"] +],[ + "start", + ["text"," "], + ["keyword","Draw..."], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["string","\"no\""], + ["text"," Curve"] +],[ + "start", + ["text"," "], + ["keyword","Draw inner box"] +],[ + "start", + ["text"," "], + ["keyword","Text bottom:"], + ["text"," "], + ["string","\"yes\""], + ["text",", sound$"] +],[ + "start", + ["text"," "], + ["keyword","Erase all"] +],[ + "start", + ["text"," "] +],[ + "start", + ["comment"," # Demo window commands"] +],[ + "start", + ["text"," "], + ["keyword","demo"], + ["text"," "], + ["keyword","Erase all"] +],[ + "start", + ["text"," "], + ["keyword","demo"], + ["text"," "], + ["keyword","Select inner viewport..."], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","100"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","100"] +],[ + "start", + ["text"," "], + ["keyword","demo"], + ["text"," "], + ["keyword","Axes..."], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","100"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","100"] +],[ + "start", + ["text"," "], + ["keyword","demo"], + ["text"," "], + ["keyword","Paint rectangle..."], + ["text"," white "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","100"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","100"] +],[ + "start", + ["text"," "], + ["keyword","demo"], + ["text"," "], + ["keyword","Text..."], + ["text"," "], + ["constant.numeric","50"], + ["text"," centre "], + ["constant.numeric","50"], + ["text"," half Click to finish"] +],[ + "start", + ["text"," "], + ["support.function","demoWaitForInput"], + ["text"," ("], + ["text"," )"] +],[ + "start", + ["text"," "], + ["keyword","demo"], + ["text"," "], + ["keyword","Erase all"] +],[ + "start", + ["text"," "], + ["keyword","demo"], + ["text"," "], + ["keyword","Text:"], + ["text"," "], + ["constant.numeric","50"], + ["text",", "], + ["string","\"centre\""], + ["text",", "], + ["constant.numeric","50"], + ["text",", "], + ["string","\"half\""], + ["text",", "], + ["string","\"Finished\""] +],[ + "start", + ["keyword","endfor"] +],[ + "start" +],[ + "start", + ["comment","# An old-style sendpraat block"] +],[ + "start", + ["keyword","sendpraat"], + ["text"," "], + ["string","Praat"] +],[ + "start", + ["text"," ..."], + ["string.interpolated","'newline$'"], + ["text"," Create "], + ["entity.name.type","Sound"], + ["text"," as pure tone... "], + ["string","\"tone\""], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0.4"], + ["text"," "], + ["constant.numeric","44100"], + ["text"," "], + ["constant.numeric","440"], + ["text"," "], + ["constant.numeric","0.2"], + ["text"," "], + ["constant.numeric","0.01"], + ["text"," "], + ["constant.numeric","0.01"] +],[ + "start", + ["text"," ..."], + ["string.interpolated","'newline$'"], + ["text"," Play"] +],[ + "start", + ["text"," ..."], + ["string.interpolated","'newline$'"], + ["text"," Remove"] +],[ + "start" +],[ + "start", + ["comment","# A new-style sendpraat block"] +],[ + "start", + ["support.function","beginSendPraat"], + ["text",":"], + ["text"," "], + ["string","\"Praat\""] +],[ + "start", + ["text"," "], + ["keyword","Create Sound as pure tone:"], + ["text"," "], + ["string","\"tone\""], + ["text",", "], + ["constant.numeric","1"], + ["text",", "], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0.4"], + ["text",", "], + ["constant.numeric","44100"], + ["text",", "], + ["constant.numeric","440"], + ["text",", "], + ["constant.numeric","0.2"], + ["text",", "], + ["constant.numeric","0.01"], + ["text",", "], + ["constant.numeric","0.01"] +],[ + "start", + ["text"," "], + ["text","duration "], + ["keyword.operator","="], + ["text"," "], + ["keyword","Get total duration"] +],[ + "start", + ["text"," "], + ["keyword","Remove"] +],[ + "start", + ["support.function","endSendPraat"], + ["text",":"], + ["text"," "], + ["string","\"duration\""] +],[ + "start", + ["support.function","appendInfoLine"], + ["text",":"], + ["text"," "], + ["string","\"The generated sound lasted for \""], + ["text",", duration, "], + ["string","\"seconds\""] +],[ + "start" +],[ + "start", + ["text","time "], + ["keyword.operator","="], + ["text"," "], + ["keyword","stopwatch"] +],[ + "start", + ["keyword","clearinfo"] +],[ + "start", + ["keyword","echo"], + ["text"," "], + ["string","This script took "] +],[ + "start", + ["keyword","print"], + ["text"," "], + ["string","'time' seconds to "] +],[ + "start", + ["keyword","printline"], + ["text"," "], + ["string","execute."] +],[ + "start" +],[ + "start", + ["comment","# Old-style procedure declaration"] +],[ + "start", + ["keyword","procedure"], + ["text"," "], + ["entity.name.function","oldStyle"], + ["text"," .str1$ .num .str2$"] +],[ + "start", + ["text"," .local"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["keyword","endproc"] +],[ + "start" +],[ + "start", + ["comment","# New-style procedure declaration"] +],[ + "start", + ["keyword","procedure"], + ["text"," "], + ["entity.name.function","newStyle"], + ["text"," (.str1$, .num, .str2$)"] +],[ + "start", + ["text"," .local"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["keyword","endproc"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_prolog.json b/public/lib/ace/mode/_test/tokens_prolog.json new file mode 100644 index 0000000..4c0f5c5 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_prolog.json @@ -0,0 +1,245 @@ +[[ + "start", + ["entity.name.function.fact.prolog","partition"], + ["punctuation.begin.fact.parameters.prolog","("], + ["punctuation.begin.list.prolog","["], + ["punctuation.end.list.prolog","]"], + ["punctuation.separator.parameters.prolog",","], + ["meta.fact.prolog"," "], + ["variable.language.anonymous.prolog","_"], + ["punctuation.separator.parameters.prolog",","], + ["meta.fact.prolog"," "], + ["punctuation.begin.list.prolog","["], + ["punctuation.end.list.prolog","]"], + ["punctuation.separator.parameters.prolog",","], + ["meta.fact.prolog"," "], + ["punctuation.begin.list.prolog","["], + ["punctuation.end.list.prolog","]"], + ["punctuation.end.fact.parameters.prolog",")"], + ["punctuation.end.fact.prolog","."] +],[ + ["keyword.operator.definition.prolog","meta.rule.prolog"], + ["entity.name.function.rule.prolog","partition"], + ["punctuation.rule.parameters.begin.prolog","("], + ["punctuation.begin.list.prolog","["], + ["variable.other.prolog","X"], + ["punctuation.concat.list.prolog","|"], + ["variable.other.prolog","Xs"], + ["punctuation.end.list.prolog","]"], + ["punctuation.separator.parameters.prolog",","], + ["meta.rule.parameters.prolog"," "], + ["variable.parameter.prolog","Pivot"], + ["punctuation.separator.parameters.prolog",","], + ["meta.rule.parameters.prolog"," "], + ["variable.parameter.prolog","Smalls"], + ["punctuation.separator.parameters.prolog",","], + ["meta.rule.parameters.prolog"," "], + ["variable.parameter.prolog","Bigs"], + ["punctuation.rule.parameters.end.prolog",")"], + ["meta.rule.signature.prolog"," "], + ["keyword.operator.definition.prolog",":-"] +],[ + ["meta.expression.prolog","keyword.operator.definition.prolog","keyword.operator.definition.prolog","meta.rule.prolog"], + ["meta.rule.definition.prolog"," "], + ["meta.expression.prolog","( "], + ["variable.other.prolog","X"], + ["meta.expression.prolog"," @"], + ["keyword.operator.prolog","<"], + ["meta.expression.prolog"," "], + ["variable.other.prolog","Pivot"], + ["meta.expression.prolog"," "], + ["keyword.operator.prolog","->"] +],[ + ["meta.expression.prolog","keyword.operator.definition.prolog","keyword.operator.definition.prolog","meta.rule.prolog"], + ["meta.expression.prolog"," "], + ["variable.other.prolog","Smalls"], + ["meta.expression.prolog"," "], + ["keyword.operator.prolog","="], + ["meta.expression.prolog"," "], + ["punctuation.begin.list.prolog","["], + ["variable.other.prolog","X"], + ["punctuation.concat.list.prolog","|"], + ["variable.other.prolog","Rest"], + ["punctuation.end.list.prolog","]"], + ["punctuation.control.and.prolog",","] +],[ + ["meta.expression.prolog","keyword.operator.definition.prolog","keyword.operator.definition.prolog","meta.rule.prolog"], + ["meta.expression.prolog"," "], + ["constant.other.atom.prolog","partition"], + ["punctuation.begin.statement.parameters.prolog","("], + ["variable.other.prolog","Xs"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","Pivot"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","Rest"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","Bigs"], + ["punctuation.end.statement.parameters.prolog",")"] +],[ + ["meta.expression.prolog","keyword.operator.definition.prolog","keyword.operator.definition.prolog","meta.rule.prolog"], + ["meta.expression.prolog"," "], + ["punctuation.control.or.prolog",";"], + ["meta.expression.prolog"," "], + ["variable.other.prolog","Bigs"], + ["meta.expression.prolog"," "], + ["keyword.operator.prolog","="], + ["meta.expression.prolog"," "], + ["punctuation.begin.list.prolog","["], + ["variable.other.prolog","X"], + ["punctuation.concat.list.prolog","|"], + ["variable.other.prolog","Rest"], + ["punctuation.end.list.prolog","]"], + ["punctuation.control.and.prolog",","] +],[ + ["meta.expression.prolog","keyword.operator.definition.prolog","keyword.operator.definition.prolog","meta.rule.prolog"], + ["meta.expression.prolog"," "], + ["constant.other.atom.prolog","partition"], + ["punctuation.begin.statement.parameters.prolog","("], + ["variable.other.prolog","Xs"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","Pivot"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","Smalls"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","Rest"], + ["punctuation.end.statement.parameters.prolog",")"] +],[ + "start", + ["meta.expression.prolog"," )"], + ["punctuation.rule.end.prolog","."] +],[ + "start", + ["text"," "] +],[ + "start", + ["entity.name.function.fact.prolog","quicksort"], + ["punctuation.begin.fact.parameters.prolog","("], + ["punctuation.begin.list.prolog","["], + ["punctuation.end.list.prolog","]"], + ["punctuation.end.fact.parameters.prolog",")"], + ["text"," --> []."] +],[ + "start", + ["entity.name.function.fact.prolog","quicksort"], + ["punctuation.begin.fact.parameters.prolog","("], + ["punctuation.begin.list.prolog","["], + ["variable.other.prolog","X"], + ["punctuation.concat.list.prolog","|"], + ["variable.other.prolog","Xs"], + ["punctuation.end.list.prolog","]"], + ["punctuation.end.fact.parameters.prolog",")"], + ["text"," -->"] +],[ + "start", + ["text"," { "], + ["entity.name.function.fact.prolog","partition"], + ["punctuation.begin.fact.parameters.prolog","("], + ["variable.parameter.prolog","Xs"], + ["punctuation.separator.parameters.prolog",","], + ["meta.fact.prolog"," "], + ["variable.parameter.prolog","X"], + ["punctuation.separator.parameters.prolog",","], + ["meta.fact.prolog"," "], + ["variable.parameter.prolog","Smaller"], + ["punctuation.separator.parameters.prolog",","], + ["meta.fact.prolog"," "], + ["variable.parameter.prolog","Bigger"], + ["punctuation.end.fact.parameters.prolog",")"], + ["text"," },"] +],[ + "start", + ["text"," "], + ["entity.name.function.fact.prolog","quicksort"], + ["punctuation.begin.fact.parameters.prolog","("], + ["variable.parameter.prolog","Smaller"], + ["punctuation.end.fact.parameters.prolog",")"], + ["text",", [X], "], + ["entity.name.function.fact.prolog","quicksort"], + ["punctuation.begin.fact.parameters.prolog","("], + ["variable.parameter.prolog","Bigger"], + ["punctuation.end.fact.parameters.prolog",")"], + ["punctuation.end.fact.prolog","."] +],[ + "start" +],[ + ["keyword.operator.definition.prolog","meta.rule.prolog"], + ["entity.name.function.rule.prolog","perfect"], + ["punctuation.rule.parameters.begin.prolog","("], + ["variable.parameter.prolog","N"], + ["punctuation.rule.parameters.end.prolog",")"], + ["meta.rule.signature.prolog"," "], + ["keyword.operator.definition.prolog",":-"] +],[ + ["keyword.operator.definition.prolog","meta.rule.prolog"], + ["meta.rule.definition.prolog"," "], + ["constant.other.atom.prolog","between"], + ["punctuation.begin.statement.parameters.prolog","("], + ["constant.numeric.prolog","1"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["constant.other.atom.prolog","inf"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","N"], + ["punctuation.end.statement.parameters.prolog",")"], + ["punctuation.control.and.prolog",","], + ["meta.rule.definition.prolog"," "], + ["variable.other.prolog","U"], + ["meta.rule.definition.prolog"," "], + ["keyword.operator.prolog","is"], + ["meta.rule.definition.prolog"," "], + ["variable.other.prolog","N"], + ["meta.rule.definition.prolog"," // "], + ["constant.numeric.prolog","2"], + ["punctuation.control.and.prolog",","] +],[ + ["keyword.operator.definition.prolog","meta.rule.prolog"], + ["meta.rule.definition.prolog"," "], + ["constant.other.atom.prolog","findall"], + ["punctuation.begin.statement.parameters.prolog","("], + ["variable.other.prolog","D"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," ("], + ["constant.other.atom.prolog","between"], + ["punctuation.begin.statement.parameters.prolog","("], + ["constant.numeric.prolog","1"], + ["punctuation.separator.statement.prolog",","], + ["variable.other.prolog","U"], + ["punctuation.separator.statement.prolog",","], + ["variable.other.prolog","D"], + ["punctuation.end.statement.parameters.prolog",")"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","N"], + ["meta.statement.parameters.prolog"," "], + ["constant.other.atom.prolog","mod"], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","D"], + ["meta.statement.parameters.prolog"," "], + ["keyword.operator.prolog","=:="], + ["meta.statement.parameters.prolog"," "], + ["constant.numeric.prolog","0"], + ["punctuation.end.statement.parameters.prolog",")"], + ["punctuation.control.and.prolog",","], + ["meta.rule.definition.prolog"," "], + ["variable.other.prolog","Ds"], + ["meta.rule.definition.prolog",")"], + ["punctuation.control.and.prolog",","] +],[ + "start", + ["meta.rule.definition.prolog"," "], + ["constant.other.atom.prolog","sumlist"], + ["punctuation.begin.statement.parameters.prolog","("], + ["variable.other.prolog","Ds"], + ["punctuation.separator.statement.prolog",","], + ["meta.statement.parameters.prolog"," "], + ["variable.other.prolog","N"], + ["punctuation.end.statement.parameters.prolog",")"], + ["punctuation.rule.end.prolog","."] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_properties.json b/public/lib/ace/mode/_test/tokens_properties.json new file mode 100644 index 0000000..8831045 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_properties.json @@ -0,0 +1,68 @@ +[[ + "start", + ["comment","# You are reading the \".properties\" entry."] +],[ + "start", + ["comment","! The exclamation mark can also mark text as comments."] +],[ + "start", + ["comment","# The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly loaded."] +],[ + "start", + ["variable","website "], + ["keyword","="], + ["string"," http"], + ["constant.language.escape","\\"], + ["string","://en.wikipedia.org/"] +],[ + "start", + ["variable","language "], + ["keyword","="], + ["string"," English"] +],[ + "start", + ["comment","# The backslash below tells the application to continue reading"] +],[ + "start", + ["comment","# the value onto the next line."] +],[ + "value", + ["variable","message "], + ["keyword","="], + ["string"," Welcome to \\"] +],[ + "start", + ["string"," Wikipedia!"] +],[ + "start", + ["comment","# Add spaces to the key"] +],[ + "start", + ["variable","key"], + ["constant.language.escape","\\"], + ["variable"," with"], + ["constant.language.escape","\\"], + ["variable"," spaces "], + ["keyword","="], + ["string"," This is the value that could be looked up with the key \"key with spaces\"."] +],[ + "start", + ["comment","# Unicode"] +],[ + "start", + ["variable","tab "], + ["keyword",":"], + ["string"," "], + ["constant.language.escape","\\u0009"] +],[ + "start", + ["variable","empty-key"], + ["keyword","="] +],[ + "start", + ["variable","last.line"], + ["keyword","="], + ["string","value"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_protobuf.json b/public/lib/ace/mode/_test/tokens_protobuf.json new file mode 100644 index 0000000..469dba0 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_protobuf.json @@ -0,0 +1,136 @@ +[[ + "start", + ["keyword.declaration.protobuf","message"], + ["text"," "], + ["identifier","Point"], + ["text"," {"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["support.type","int32"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","1"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["support.type","int32"], + ["text"," "], + ["identifier","y"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","optional"], + ["text"," "], + ["support.type","string"], + ["text"," "], + ["identifier","label"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","3"], + ["text",";"] +],[ + "start", + ["text","}"] +],[ + "start" +],[ + "start", + ["keyword.declaration.protobuf","message"], + ["text"," "], + ["identifier","Line"], + ["text"," {"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["identifier","Point"], + ["text"," "], + ["identifier","start"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","1"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["identifier","Point"], + ["text"," "], + ["identifier","end"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","optional"], + ["text"," "], + ["support.type","string"], + ["text"," "], + ["identifier","label"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","3"], + ["text",";"] +],[ + "start", + ["text","}"] +],[ + "start" +],[ + "start", + ["keyword.declaration.protobuf","message"], + ["text"," "], + ["identifier","Polyline"], + ["text"," {"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","repeated"], + ["text"," "], + ["identifier","Point"], + ["text"," "], + ["identifier","point"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","1"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","optional"], + ["text"," "], + ["support.type","string"], + ["text"," "], + ["identifier","label"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_python.json b/public/lib/ace/mode/_test/tokens_python.json new file mode 100644 index 0000000..293c8ff --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_python.json @@ -0,0 +1,152 @@ +[[ + "start", + ["comment","#!/usr/local/bin/python"] +],[ + "start" +],[ + "start", + ["keyword","import"], + ["text"," "], + ["identifier","string"], + ["text",", "], + ["identifier","sys"] +],[ + "start" +],[ + "start", + ["comment","# If no arguments were given, print a helpful message"] +],[ + "start", + ["keyword","if"], + ["text"," "], + ["support.function","len"], + ["paren.lparen","("], + ["identifier","sys"], + ["text","."], + ["identifier","argv"], + ["paren.rparen",")"], + ["keyword.operator","=="], + ["constant.numeric","1"], + ["text",":"] +],[ + "qstring3", + ["text"," "], + ["keyword","print"], + ["text"," "], + ["string","'''Usage:"] +],[ + "start", + ["string","celsius temp1 temp2 ...'''"] +],[ + "start", + ["text"," "], + ["identifier","sys"], + ["text","."], + ["identifier","exit"], + ["paren.lparen","("], + ["constant.numeric","0"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["comment","# Loop over the arguments"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["identifier","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["identifier","sys"], + ["text","."], + ["identifier","argv"], + ["paren.lparen","["], + ["constant.numeric","1"], + ["text",":"], + ["paren.rparen","]"], + ["text",":"] +],[ + "start", + ["text"," "], + ["keyword","try"], + ["text",":"] +],[ + "start", + ["text"," "], + ["identifier","fahrenheit"], + ["keyword.operator","="], + ["support.function","float"], + ["paren.lparen","("], + ["identifier","string"], + ["text","."], + ["identifier","atoi"], + ["paren.lparen","("], + ["identifier","i"], + ["paren.rparen","))"] +],[ + "start", + ["text"," "], + ["keyword","except"], + ["text"," "], + ["identifier","string"], + ["text","."], + ["identifier","atoi_error"], + ["text",":"] +],[ + "start", + ["text"," "], + ["keyword","print"], + ["text"," "], + ["support.function","repr"], + ["paren.lparen","("], + ["identifier","i"], + ["paren.rparen",")"], + ["text",", "], + ["string","\"not a numeric value\""] +],[ + "start", + ["text"," "], + ["keyword","else"], + ["text",":"] +],[ + "start", + ["text"," "], + ["identifier","celsius"], + ["keyword.operator","="], + ["paren.lparen","("], + ["identifier","fahrenheit"], + ["keyword.operator","-"], + ["constant.numeric","32"], + ["paren.rparen",")"], + ["keyword.operator","*"], + ["constant.numeric","5.0"], + ["keyword.operator","/"], + ["constant.numeric","9.0"] +],[ + "start", + ["text"," "], + ["keyword","print"], + ["text"," "], + ["string","'%i"], + ["constant.language.escape","\\260"], + ["string","F = %i"], + ["constant.language.escape","\\260"], + ["string","C'"], + ["text"," "], + ["keyword.operator","%"], + ["text"," "], + ["paren.lparen","("], + ["support.function","int"], + ["paren.lparen","("], + ["identifier","fahrenheit"], + ["paren.rparen",")"], + ["text",", "], + ["support.function","int"], + ["paren.lparen","("], + ["identifier","celsius"], + ["keyword.operator","+"], + ["constant.numeric",".5"], + ["paren.rparen","))"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_r.json b/public/lib/ace/mode/_test/tokens_r.json new file mode 100644 index 0000000..2d446bc --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_r.json @@ -0,0 +1,235 @@ +[[ + "start", + ["identifier","Call"], + ["keyword.operator",":"] +],[ + "start", + ["identifier","lm"], + ["paren.keyword.operator","("], + ["identifier","formula"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","y"], + ["text"," "], + ["keyword.operator","~"], + ["text"," "], + ["identifier","x"], + ["paren.keyword.operator",")"] +],[ + "start", + ["text"," "] +],[ + "start", + ["identifier","Residuals"], + ["keyword.operator",":"] +],[ + "start", + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","2"], + ["text"," "], + ["constant.numeric","3"], + ["text"," "], + ["constant.numeric","4"], + ["text"," "], + ["constant.numeric","5"], + ["text"," "], + ["constant.numeric","6"] +],[ + "start", + ["constant.numeric","3.3333"], + ["text"," "], + ["keyword.operator","-"], + ["constant.numeric","0.6667"], + ["text"," "], + ["keyword.operator","-"], + ["constant.numeric","2.6667"], + ["text"," "], + ["keyword.operator","-"], + ["constant.numeric","2.6667"], + ["text"," "], + ["keyword.operator","-"], + ["constant.numeric","0.6667"], + ["text"," "], + ["constant.numeric","3.3333"] +],[ + "start", + ["text"," "] +],[ + "start", + ["identifier","Coefficients"], + ["keyword.operator",":"] +],[ + "start", + ["text"," "], + ["identifier","Estimate"], + ["text"," "], + ["identifier","Std"], + ["text",". "], + ["identifier","Error"], + ["text"," "], + ["identifier","t"], + ["text"," "], + ["identifier","value"], + ["text"," "], + ["identifier","Pr"], + ["paren.keyword.operator","("], + ["keyword.operator",">|"], + ["identifier","t"], + ["keyword.operator","|"], + ["paren.keyword.operator",")"] +],[ + "start", + ["paren.keyword.operator","("], + ["identifier","Intercept"], + ["paren.keyword.operator",")"], + ["text"," "], + ["keyword.operator","-"], + ["constant.numeric","9.3333"], + ["text"," "], + ["constant.numeric","2.8441"], + ["text"," "], + ["keyword.operator","-"], + ["constant.numeric","3.282"], + ["text"," "], + ["constant.numeric","0.030453"], + ["text"," "], + ["keyword.operator","*"] +],[ + "start", + ["identifier","x"], + ["text"," "], + ["constant.numeric","7.0000"], + ["text"," "], + ["constant.numeric","0.7303"], + ["text"," "], + ["constant.numeric","9.585"], + ["text"," "], + ["constant.numeric","0.000662"], + ["text"," "], + ["keyword.operator","***"] +],[ + "start", + ["keyword.operator","---"] +],[ + "start", + ["identifier","Signif"], + ["text",". "], + ["identifier","codes"], + ["keyword.operator",":"], + ["text"," "], + ["constant.numeric","0"], + ["text"," ‘"], + ["keyword.operator","***"], + ["text","’ "], + ["constant.numeric","0.001"], + ["text"," ‘"], + ["keyword.operator","**"], + ["text","’ "], + ["constant.numeric","0.01"], + ["text"," ‘"], + ["keyword.operator","*"], + ["text","’ "], + ["constant.numeric","0.05"], + ["text"," ‘.’ "], + ["constant.numeric","0.1"], + ["text"," ‘ ’ "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "] +],[ + "start", + ["identifier","Residual"], + ["text"," "], + ["identifier","standard"], + ["text"," "], + ["identifier","error"], + ["keyword.operator",":"], + ["text"," "], + ["constant.numeric","3.055"], + ["text"," "], + ["identifier","on"], + ["text"," "], + ["constant.numeric","4"], + ["text"," "], + ["identifier","degrees"], + ["text"," "], + ["identifier","of"], + ["text"," "], + ["identifier","freedom"] +],[ + "start", + ["identifier","Multiple"], + ["text"," "], + ["identifier","R"], + ["keyword.operator","-"], + ["identifier","squared"], + ["keyword.operator",":"], + ["text"," "], + ["constant.numeric","0.9583"], + ["text",", "], + ["identifier","Adjusted"], + ["text"," "], + ["identifier","R"], + ["keyword.operator","-"], + ["identifier","squared"], + ["keyword.operator",":"], + ["text"," "], + ["constant.numeric","0.9478"] +],[ + "start", + ["constant.language.boolean","F"], + ["keyword.operator","-"], + ["identifier","statistic"], + ["keyword.operator",":"], + ["text"," "], + ["constant.numeric","91.88"], + ["text"," "], + ["identifier","on"], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["identifier","and"], + ["text"," "], + ["constant.numeric","4"], + ["text"," "], + ["identifier","DF"], + ["text",", "], + ["identifier","p"], + ["keyword.operator","-"], + ["identifier","value"], + ["keyword.operator",":"], + ["text"," "], + ["constant.numeric","0.000662"] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword.operator",">"], + ["text"," "], + ["identifier","par"], + ["paren.keyword.operator","("], + ["identifier","mfrow"], + ["keyword.operator","="], + ["identifier","c"], + ["paren.keyword.operator","("], + ["constant.numeric","2"], + ["text",", "], + ["constant.numeric","2"], + ["paren.keyword.operator","))"], + ["text"," "], + ["comment","# Request 2x2 plot layout"] +],[ + "start", + ["keyword.operator",">"], + ["text"," "], + ["identifier","plot"], + ["paren.keyword.operator","("], + ["identifier","lm_1"], + ["paren.keyword.operator",")"], + ["text"," "], + ["comment","# Diagnostic plot of regression model"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_razor.json b/public/lib/ace/mode/_test/tokens_razor.json new file mode 100644 index 0000000..e91f82e --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_razor.json @@ -0,0 +1,17 @@ +[[ + ["razor-block-start","@{"], + ["punctuation.block.razor","@{"] +],[ + ["razor-block-start","@{"], + ["text","\t"], + ["identifier","Layout"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.start","\""], + ["string","~/layout"], + ["string.end","\""] +],[ + "start", + ["punctuation.block.razor","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_rdoc.json b/public/lib/ace/mode/_test/tokens_rdoc.json new file mode 100644 index 0000000..0c75743 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_rdoc.json @@ -0,0 +1,441 @@ +[[ + "start", + ["keyword","\\name"], + ["paren.keyword.operator","{"], + ["nospell.text","picker"], + ["paren.keyword.operator","}"] +],[ + "start", + ["keyword","\\alias"], + ["paren.keyword.operator","{"], + ["nospell.text","picker"], + ["paren.keyword.operator","}"] +],[ + "start", + ["keyword","\\title"], + ["paren.keyword.operator","{"], + ["text","Create a picker control"], + ["paren.keyword.operator","}"] +],[ + "start", + ["keyword","\\description"], + ["paren.keyword.operator","{"] +],[ + "start", + ["text"," Create a picker control to enable manipulation of plot variables based on a set of fixed choices."] +],[ + "start", + ["paren.keyword.operator","}"] +],[ + "start" +],[ + "nospell", + ["keyword","\\usage"], + ["paren.keyword.operator","{"] +],[ + "nospell", + ["nospell.text","picker"], + ["paren.keyword.operator","("], + ["text","...,"], + ["nospell.text"," initial "], + ["text","="], + ["nospell.text"," NULL"], + ["text",","], + ["nospell.text"," label "], + ["text","="], + ["nospell.text"," NULL"], + ["paren.keyword.operator",")"] +],[ + "start", + ["paren.keyword.operator","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["keyword","\\arguments"], + ["paren.keyword.operator","{"] +],[ + "start", + ["text"," "], + ["keyword","\\item"], + ["paren.keyword.operator","{"], + ["keyword","\\dots"], + ["paren.keyword.operator","}{"] +],[ + "start", + ["text"," Arguments containing objects to be presented as choices for the picker "], + ["paren.keyword.operator","("], + ["text","or a list containing the choices"], + ["paren.keyword.operator",")"], + ["text",". If an element is named then the name is used to display it within the picker. If an element is not named then it is displayed within the picker using "], + ["keyword","\\code"], + ["paren.keyword.operator","{"], + ["keyword","\\link"], + ["paren.keyword.operator","{"], + ["nospell.text","as"], + ["text","."], + ["nospell.text","character"], + ["paren.keyword.operator","}}"], + ["text",". "] +],[ + "start", + ["paren.keyword.operator","}"] +],[ + "start", + ["text"," "], + ["keyword","\\item"], + ["paren.keyword.operator","{"], + ["nospell.text","initial"], + ["paren.keyword.operator","}{"] +],[ + "start", + ["text"," Initial value for picker. Value must be present in the list of choices specified. If not specified defaults to the first choice."] +],[ + "start", + ["paren.keyword.operator","}"] +],[ + "start", + ["text"," "], + ["keyword","\\item"], + ["paren.keyword.operator","{"], + ["nospell.text","label"], + ["paren.keyword.operator","}{"] +],[ + "start", + ["text"," Display label for picker. Defaults to the variable name if not specified."] +],[ + "start", + ["paren.keyword.operator","}"] +],[ + "start", + ["paren.keyword.operator","}"] +],[ + "start" +],[ + "start", + ["keyword","\\value"], + ["paren.keyword.operator","{"] +],[ + "start", + ["text"," An object of class \"manipulator.picker\" which can be passed to the "], + ["keyword","\\code"], + ["paren.keyword.operator","{"], + ["keyword","\\link"], + ["paren.keyword.operator","{"], + ["nospell.text","manipulate"], + ["paren.keyword.operator","}}"], + ["text"," function."] +],[ + "start", + ["paren.keyword.operator","}"] +],[ + "start" +],[ + "start", + ["keyword","\\seealso"], + ["paren.keyword.operator","{"] +],[ + "start", + ["keyword","\\code"], + ["paren.keyword.operator","{"], + ["keyword","\\link"], + ["paren.keyword.operator","{"], + ["nospell.text","manipulate"], + ["paren.keyword.operator","}}"], + ["text",", "], + ["keyword","\\code"], + ["paren.keyword.operator","{"], + ["keyword","\\link"], + ["paren.keyword.operator","{"], + ["nospell.text","slider"], + ["paren.keyword.operator","}}"], + ["text",", "], + ["keyword","\\code"], + ["paren.keyword.operator","{"], + ["keyword","\\link"], + ["paren.keyword.operator","{"], + ["nospell.text","checkbox"], + ["paren.keyword.operator","}}"], + ["text",", "], + ["keyword","\\code"], + ["paren.keyword.operator","{"], + ["keyword","\\link"], + ["paren.keyword.operator","{"], + ["nospell.text","button"], + ["paren.keyword.operator","}}"] +],[ + "start", + ["paren.keyword.operator","}"] +],[ + "start" +],[ + "start" +],[ + "nospell", + ["keyword","\\examples"], + ["paren.keyword.operator","{"] +],[ + "nospell", + ["keyword","\\dontrun"], + ["paren.keyword.operator","{"] +],[ + "nospell" +],[ + "nospell", + ["text","##"], + ["nospell.text"," Filtering data with a picker"] +],[ + "nospell", + ["nospell.text","manipulate"], + ["paren.keyword.operator","("] +],[ + "nospell", + ["nospell.text"," barplot"], + ["paren.keyword.operator","("], + ["nospell.text","as"], + ["text","."], + ["nospell.text","matrix"], + ["paren.keyword.operator","("], + ["nospell.text","longley"], + ["paren.keyword.operator","["], + ["text",","], + ["nospell.text","factor"], + ["paren.keyword.operator","])"], + ["text",","], + ["nospell.text"," "] +],[ + "nospell", + ["nospell.text"," beside "], + ["text","="], + ["nospell.text"," TRUE"], + ["text",","], + ["nospell.text"," main "], + ["text","="], + ["nospell.text"," factor"], + ["paren.keyword.operator",")"], + ["text",","] +],[ + "nospell", + ["nospell.text"," factor "], + ["text","="], + ["nospell.text"," picker"], + ["paren.keyword.operator","("], + ["text","\""], + ["nospell.text","GNP"], + ["text","\","], + ["nospell.text"," "], + ["text","\""], + ["nospell.text","Unemployed"], + ["text","\","], + ["nospell.text"," "], + ["text","\""], + ["nospell.text","Employed"], + ["text","\""], + ["paren.keyword.operator","))"] +],[ + "nospell" +],[ + "nospell", + ["text","##"], + ["nospell.text"," Create a picker with labels"] +],[ + "nospell", + ["nospell.text","manipulate"], + ["paren.keyword.operator","("] +],[ + "nospell", + ["nospell.text"," plot"], + ["paren.keyword.operator","("], + ["nospell.text","pressure"], + ["text",","], + ["nospell.text"," type "], + ["text","="], + ["nospell.text"," type"], + ["paren.keyword.operator",")"], + ["text",","], + ["nospell.text"," "] +],[ + "nospell", + ["nospell.text"," type "], + ["text","="], + ["nospell.text"," picker"], + ["paren.keyword.operator","("], + ["text","\""], + ["nospell.text","points"], + ["text","\""], + ["nospell.text"," "], + ["text","="], + ["nospell.text"," "], + ["text","\""], + ["nospell.text","p"], + ["text","\","], + ["nospell.text"," "], + ["text","\""], + ["nospell.text","line"], + ["text","\""], + ["nospell.text"," "], + ["text","="], + ["nospell.text"," "], + ["text","\""], + ["nospell.text","l"], + ["text","\","], + ["nospell.text"," "], + ["text","\""], + ["nospell.text","step"], + ["text","\""], + ["nospell.text"," "], + ["text","="], + ["nospell.text"," "], + ["text","\""], + ["nospell.text","s"], + ["text","\""], + ["paren.keyword.operator","))"] +],[ + "nospell", + ["nospell.text"," "] +],[ + "nospell", + ["text","##"], + ["nospell.text"," Picker with groups"] +],[ + "nospell", + ["nospell.text","manipulate"], + ["paren.keyword.operator","("] +],[ + "nospell", + ["nospell.text"," barplot"], + ["paren.keyword.operator","("], + ["nospell.text","as"], + ["text","."], + ["nospell.text","matrix"], + ["paren.keyword.operator","("], + ["nospell.text","mtcars"], + ["paren.keyword.operator","["], + ["nospell.text","group"], + ["text",",\""], + ["nospell.text","mpg"], + ["text","\""], + ["paren.keyword.operator","])"], + ["text",","], + ["nospell.text"," beside"], + ["text","="], + ["nospell.text","TRUE"], + ["paren.keyword.operator",")"], + ["text",","] +],[ + "nospell", + ["nospell.text"," group "], + ["text","="], + ["nospell.text"," picker"], + ["paren.keyword.operator","("], + ["text","\""], + ["nospell.text","Group 1"], + ["text","\""], + ["nospell.text"," "], + ["text","="], + ["nospell.text"," 1"], + ["text",":"], + ["nospell.text","11"], + ["text",","], + ["nospell.text"," "] +],[ + "nospell", + ["nospell.text"," "], + ["text","\""], + ["nospell.text","Group 2"], + ["text","\""], + ["nospell.text"," "], + ["text","="], + ["nospell.text"," 12"], + ["text",":"], + ["nospell.text","22"], + ["text",","], + ["nospell.text"," "] +],[ + "nospell", + ["nospell.text"," "], + ["text","\""], + ["nospell.text","Group 3"], + ["text","\""], + ["nospell.text"," "], + ["text","="], + ["nospell.text"," 23"], + ["text",":"], + ["nospell.text","32"], + ["paren.keyword.operator","))"] +],[ + "nospell" +],[ + "nospell", + ["text","##"], + ["nospell.text"," Histogram w"], + ["text","/"], + ["nospell.text"," picker to select type"] +],[ + "nospell", + ["nospell.text","require"], + ["paren.keyword.operator","("], + ["nospell.text","lattice"], + ["paren.keyword.operator",")"] +],[ + "nospell", + ["nospell.text","require"], + ["paren.keyword.operator","("], + ["nospell.text","stats"], + ["paren.keyword.operator",")"] +],[ + "nospell", + ["nospell.text","manipulate"], + ["paren.keyword.operator","("] +],[ + "nospell", + ["nospell.text"," histogram"], + ["paren.keyword.operator","("], + ["text","~"], + ["nospell.text"," height "], + ["text","|"], + ["nospell.text"," voice"], + ["text","."], + ["nospell.text","part"], + ["text",","], + ["nospell.text"," "] +],[ + "nospell", + ["nospell.text"," data "], + ["text","="], + ["nospell.text"," singer"], + ["text",","], + ["nospell.text"," type "], + ["text","="], + ["nospell.text"," type"], + ["paren.keyword.operator",")"], + ["text",","] +],[ + "nospell", + ["nospell.text"," type "], + ["text","="], + ["nospell.text"," picker"], + ["paren.keyword.operator","("], + ["text","\""], + ["nospell.text","percent"], + ["text","\","], + ["nospell.text"," "], + ["text","\""], + ["nospell.text","count"], + ["text","\","], + ["nospell.text"," "], + ["text","\""], + ["nospell.text","density"], + ["text","\""], + ["paren.keyword.operator","))"] +],[ + "nospell" +],[ + "start", + ["paren.keyword.operator","}"] +],[ + "start", + ["paren.keyword.operator","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_rhtml.json b/public/lib/ace/mode/_test/tokens_rhtml.json new file mode 100644 index 0000000..a536f85 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_rhtml.json @@ -0,0 +1,106 @@ +[[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Title"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","This is an R HTML document. When you click the "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","b"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Knit HTML"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "r-start", + ["support.function.codebegin",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","You can also embed plots, for example:"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "r-start", + ["support.function.codebegin",""] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_ruby.json b/public/lib/ace/mode/_test/tokens_ruby.json new file mode 100644 index 0000000..f9991e9 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_ruby.json @@ -0,0 +1,242 @@ +[[ + "start", + ["text"," "], + ["comment","#test: symbol tokenizer"] +],[ + "start", + ["text"," "], + ["paren.lparen","["], + ["constant.other.symbol.ruby",":@thing"], + ["text",", "], + ["constant.other.symbol.ruby",":$thing"], + ["text",", "], + ["constant.other.symbol.ruby",":_thing"], + ["text",", "], + ["constant.other.symbol.ruby",":thing"], + ["text",", "], + ["constant.other.symbol.ruby",":Thing"], + ["text",", "], + ["constant.other.symbol.ruby",":thing1"], + ["text",", "], + ["constant.other.symbol.ruby",":thing_a"], + ["text",","] +],[ + "start", + ["text"," "], + ["constant.other.symbol.ruby",":THING"], + ["text",", "], + ["constant.other.symbol.ruby",":thing!"], + ["text",", "], + ["constant.other.symbol.ruby",":thing="], + ["text",", "], + ["constant.other.symbol.ruby",":thing?"], + ["text",", "], + ["constant.other.symbol.ruby",":t?"], + ["text",","] +],[ + "start", + ["text"," :, :@, :"], + ["keyword.operator","$"], + ["text",", :"], + ["constant.numeric","1"], + ["text",", :1"], + ["identifier","thing"], + ["text",", "], + ["constant.other.symbol.ruby",":th?"], + ["identifier","ing"], + ["text",", "], + ["constant.other.symbol.ruby",":thi="], + ["identifier","ng"], + ["text",", :1"], + ["identifier","thing"], + ["text",","] +],[ + "start", + ["text"," "], + ["constant.other.symbol.ruby",":th!"], + ["identifier","ing"], + ["text",", "], + ["constant.other.symbol.ruby",":thing"], + ["comment","#"] +],[ + "start", + ["text"," "], + ["paren.rparen","]"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","#test: namespaces aren't symbols\" : function() {"] +],[ + "start", + ["text"," "], + ["support.class","Namespaced"], + ["text","::"], + ["support.class","Class"] +],[ + "start", + ["text"," "], + ["comment","#test: hex tokenizer "] +],[ + "start", + ["text"," "], + ["constant.numeric","0x9a"], + ["text",", "], + ["constant.numeric","0XA1"], + ["text",", "], + ["constant.numeric","0x9_a"], + ["text",", 0"], + ["identifier","x"], + ["text",", 0"], + ["identifier","x_9a"], + ["text",", 0"], + ["identifier","x9a_"], + ["text",","] +],[ + "start", + ["text"," "], + ["comment","#test: float tokenizer"] +],[ + "start", + ["text"," "], + ["paren.lparen","["], + ["constant.numeric","1"], + ["text",", "], + ["constant.numeric","+1"], + ["text",", "], + ["constant.numeric","-1"], + ["text",", "], + ["constant.numeric","12_345"], + ["text",", "], + ["constant.numeric","0.000_1"], + ["text",","] +],[ + "start", + ["text"," "], + ["identifier","_"], + ["text",", "], + ["constant.numeric","3_1"], + ["text",", "], + ["constant.numeric","1_2"], + ["text",", 1"], + ["identifier","_"], + ["text","."], + ["constant.numeric","0"], + ["text",", "], + ["constant.numeric","0"], + ["text","."], + ["identifier","_1"], + ["paren.rparen","]"], + ["text",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["paren.lparen","{"], + ["constant.other.symbol.ruby",":id"], + ["text"," "], + ["punctuation.separator.key-value","=>"], + ["text"," "], + ["string.character","?\""], + ["text",", "], + ["constant.other.symbol.ruby",":key"], + ["text"," "], + ["punctuation.separator.key-value","=>"], + ["text"," "], + ["string.start","\""], + ["string","value"], + ["string.end","\""], + ["text",", "], + ["identifier","anotherKey"], + ["text",": "], + ["paren.lparen","["], + ["identifier","x"], + ["text",", "], + ["identifier","y"], + ["text","?"], + ["paren.rparen","]}"] +],[ + "start" +],[ + "comment", + ["comment","=begin"] +],[ + "start", + ["comment","=end"] +],[ + "start" +],[ + "comment", + ["comment","=begin x"] +],[ + "comment", + ["comment","=end-"] +],[ + "start", + ["comment","=end x"] +],[ + "start" +],[ + ["heredoc","FOO","heredoc","BAR","indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["text"," "], + ["identifier","herDocs"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","["], + ["constant","<<"], + ["string","'"], + ["support.class","FOO"], + ["string","'"], + ["text",", "], + ["constant","<<"], + ["string",""], + ["support.class","BAR"], + ["string",""], + ["text",", "], + ["constant","<<-"], + ["string",""], + ["support.class","BAZ"], + ["string",""], + ["text",", "], + ["constant","<<-"], + ["string","`"], + ["support.class","EXEC"], + ["string","`"], + ["paren.rparen","]"], + ["text"," "], + ["comment","#comment"] +],[ + ["heredoc","FOO","heredoc","BAR","indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["string"," FOO #{literal}"] +],[ + ["heredoc","BAR","indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["support.class","FOO"] +],[ + ["heredoc","BAR","indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["string"," BAR #{fact(10)}"] +],[ + ["indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["support.class","BAR"] +],[ + ["indentedHeredoc","BAZ","indentedHeredoc","EXEC"], + ["string"," BAZ indented"] +],[ + ["indentedHeredoc","EXEC"], + ["string"," "], + ["support.class","BAZ"] +],[ + ["indentedHeredoc","EXEC"], + ["string"," echo hi"] +],[ + "start", + ["string"," "], + ["support.class","EXEC"] +],[ + "start", + ["support.function","puts"], + ["text"," "], + ["identifier","herDocs"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_rust.json b/public/lib/ace/mode/_test/tokens_rust.json new file mode 100644 index 0000000..68add46 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_rust.json @@ -0,0 +1,299 @@ +[[ + "start", + ["keyword.source.rust","use"], + ["text"," "], + ["support.constant","core::rand::"], + ["text","RngUtil"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword.source.rust","fn"], + ["text"," "], + ["entity.name.function.source.rust","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.source.rust","for"], + ["text"," "], + ["paren.lparen","["], + ["string.quoted.double.source.rust","\"Alice\""], + ["punctuation.operator",","], + ["text"," "], + ["string.quoted.double.source.rust","\"Bob\""], + ["punctuation.operator",","], + ["text"," "], + ["string.quoted.double.source.rust","\"Carol\""], + ["paren.rparen","]"], + ["punctuation.operator","."], + ["text","each "], + ["keyword.operator","|&"], + ["text","name"], + ["keyword.operator","|"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.source.rust","do"], + ["text"," spawn "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.source.rust","let"], + ["text"," v "], + ["keyword.operator","="], + ["text"," "], + ["support.constant","rand::"], + ["text","Rng"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["punctuation.operator","."], + ["text","shuffle"], + ["paren.lparen","(["], + ["constant.numeric.source.rust","1"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric.source.rust","2"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric.source.rust","3"], + ["paren.rparen","])"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.source.rust","for"], + ["text"," v"], + ["punctuation.operator","."], + ["text","each "], + ["keyword.operator","|&"], + ["text","num"], + ["keyword.operator","|"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," print"], + ["paren.lparen","("], + ["text","fmt"], + ["keyword.operator","!"], + ["paren.lparen","("], + ["string.quoted.double.source.rust","\"%s says: '%d'"], + ["constant.character.escape.source.rust","\\n\\\\"], + ["string.quoted.double.source.rust","\""], + ["punctuation.operator",","], + ["text"," name"], + ["punctuation.operator",","], + ["text"," num "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric.source.rust","1"], + ["paren.rparen","))"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["keyword.source.rust","let"], + ["text"," _ "], + ["punctuation.operator",":"], + ["storage.type.source.rust","i128"], + ["keyword.operator","=-"], + ["constant.numeric.source.rust","42i128"], + ["punctuation.operator",";"] +],[ + "start", + ["keyword.source.rust","let"], + ["text"," _ "], + ["punctuation.operator",":"], + ["storage.type.source.rust","u128"], + ["keyword.operator","="], + ["constant.numeric.source.rust","42u128"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + ["comment","comment"], + ["comment.start.block.source.rust","/*"], + ["comment.block.source.rust"," nested "], + ["comment.start.block.source.rust","/*"], + ["comment.block.source.rust"," "] +],[ + "start", + ["comment.block.source.rust"," comments "], + ["comment.end.block.source.rust","*/"], + ["comment.block.source.rust"," "], + ["comment.end.block.source.rust","*/"] +],[ + "start" +],[ + "start", + ["keyword.source.rust","fn"], + ["text"," "], + ["entity.name.function.source.rust","map"], + ["keyword.operator","<"], + ["text","T"], + ["punctuation.operator",","], + ["text"," U"], + ["keyword.operator",">"], + ["paren.lparen","("], + ["text","vector"], + ["punctuation.operator",":"], + ["text"," "], + ["keyword.operator","&"], + ["paren.lparen","["], + ["text","T"], + ["paren.rparen","]"], + ["punctuation.operator",","], + ["text"," function"], + ["punctuation.operator",":"], + ["text"," "], + ["keyword.operator","&"], + ["text","fn"], + ["paren.lparen","("], + ["text","v"], + ["punctuation.operator",":"], + ["text"," "], + ["keyword.operator","&"], + ["text","T"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","->"], + ["text"," U"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","->"], + ["text"," ~"], + ["paren.lparen","["], + ["text","U"], + ["paren.rparen","]"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.source.rust","let"], + ["text"," "], + ["keyword.source.rust","mut"], + ["text"," accumulator "], + ["keyword.operator","="], + ["text"," ~"], + ["paren.lparen","["], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.source.rust","for"], + ["text"," "], + ["support.constant","vec::"], + ["text","each"], + ["paren.lparen","("], + ["text","vector"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","|"], + ["text","element"], + ["keyword.operator","|"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," accumulator"], + ["punctuation.operator","."], + ["text","push"], + ["paren.lparen","("], + ["text","function"], + ["paren.lparen","("], + ["text","element"], + ["paren.rparen","))"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword.source.rust","return"], + ["text"," accumulator"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["comment.line.double-dash.source.rust","// numbers"] +],[ + "start", + ["constant.numeric.source.rust","14E-111_f64"], + ["punctuation.operator",";"], + ["text"," "], + ["constant.numeric.source.rust","45isize"], + ["text"," "], + ["constant.numeric.source.rust","0x1i32"], + ["text"," "], + ["constant.numeric.source.rust","0o777u32"], + ["text"," "], + ["constant.numeric.source.rust","0b01"], + ["text"," "], + ["constant.numeric.source.rust","14f32"], + ["text"," "], + ["constant.numeric.source.rust","1_2.78f32"], + ["text"," "], + ["constant.numeric.source.rust","1_2.3E+7f32"] +],[ + "start" +],[ + "start", + ["comment.line.double-dash.source.rust","// not numbers"] +],[ + "start", + ["constant.numeric.source.rust","14"], + ["punctuation.operator","."], + ["text","_E"], + ["keyword.operator","-"], + ["constant.numeric.source.rust","111_f64"], + ["punctuation.operator",";"], + ["text","0xi32"], + ["punctuation.operator",";"], + ["text","0b777u"] +],[ + "start", + ["text","foo1"], + ["punctuation.operator",";"], + ["text","foo1u32"], + ["punctuation.operator",";"], + ["text","foo1f32"], + ["punctuation.operator",";"], + ["text","foo0xF"], + ["punctuation.operator",";"], + ["text","foo1"], + ["punctuation.operator","."], + ["constant.numeric.source.rust","0"] +]] diff --git a/public/lib/ace/mode/_test/tokens_sass.json b/public/lib/ace/mode/_test/tokens_sass.json new file mode 100644 index 0000000..c0b8568 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_sass.json @@ -0,0 +1,229 @@ +[[ + "start", + ["comment","// sass ace mode;"] +],[ + "start" +],[ + "start", + ["keyword","@import"], + ["text"," "], + ["support.function","url("], + ["string","http://fonts.googleapis.com/css?family=Ace:700"], + ["support.function",")"] +],[ + "start" +],[ + "start", + ["variable.language","html"], + ["text",", "], + ["variable.language","body"] +],[ + "start", + ["support.type"," :background-color "], + ["constant.numeric","#ace"] +],[ + "start", + ["text"," "], + ["support.type","text-align"], + ["text",": "], + ["constant.language","center"] +],[ + "start", + ["text"," "], + ["support.type","height"], + ["text",": "], + ["constant.numeric","100%"] +],[ + ["comment",-1,2,"start"], + ["comment"," /*;*********;"] +],[ + ["comment",3,2,"start"], + ["comment"," ;comment ;"] +],[ + ["comment",3,2,"start"], + ["comment"," ;*********;"] +],[ + "start" +],[ + "start", + ["variable.language",".toggle"] +],[ + "start", + ["text"," "], + ["variable","$size"], + ["text",": "], + ["constant.numeric","14px"] +],[ + "start" +],[ + "start", + ["support.type"," :background "], + ["support.function","url("], + ["string","http://subtlepatterns.com/patterns/dark_stripes.png"], + ["support.function",")"] +],[ + "start", + ["text"," "], + ["support.type","border-radius"], + ["text",": "], + ["constant.numeric","8px"] +],[ + "start", + ["text"," "], + ["support.type","height"], + ["text",": "], + ["variable","$size"] +],[ + "start" +],[ + "start", + ["text"," &"], + ["variable.language",":before"] +],[ + "start", + ["text"," "], + ["variable","$radius"], + ["text",": "], + ["variable","$size"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["constant.numeric","0.845"] +],[ + "start", + ["text"," "], + ["variable","$glow"], + ["text",": "], + ["variable","$size"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["constant.numeric","0.125"] +],[ + "start" +],[ + "start", + ["text"," "], + ["support.type","box-shadow"], + ["text",": "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["variable","$glow"], + ["text"," "], + ["variable","$glow"], + ["text"," / "], + ["constant.numeric","2"], + ["text"," "], + ["constant.numeric","#fff"] +],[ + "start", + ["text"," "], + ["support.type","border-radius"], + ["text",": "], + ["variable","$radius"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," &"], + ["variable.language",":active"] +],[ + "start", + ["text"," ~ "], + ["variable.language",".button"] +],[ + "start", + ["text"," "], + ["support.type","box-shadow"], + ["text",": "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","15px"], + ["text"," "], + ["constant.numeric","25px"], + ["text"," "], + ["constant.numeric","-4px"], + ["text"," "], + ["support.function","rgba"], + ["paren.lparen","("], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0.4"], + ["paren.rparen",")"], + ["text"," "] +],[ + "start", + ["text"," ~ "], + ["variable.language",".label"] +],[ + "start", + ["text"," "], + ["support.type","font-size"], + ["text",": "], + ["constant.numeric","40px"] +],[ + "start", + ["text"," "], + ["support.type","color"], + ["text",": "], + ["support.function","rgba"], + ["paren.lparen","("], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0.45"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["text"," &"], + ["variable.language",":checked"], + ["text"," "] +],[ + "start", + ["text"," ~ "], + ["variable.language",".button"] +],[ + "start", + ["text"," "], + ["support.type","box-shadow"], + ["text",": "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","15px"], + ["text"," "], + ["constant.numeric","25px"], + ["text"," "], + ["constant.numeric","-4px"], + ["text"," "], + ["constant.numeric","#ace"] +],[ + "start", + ["text"," ~ "], + ["variable.language",".label"] +],[ + "start", + ["text"," "], + ["support.type","font-size"], + ["text",": "], + ["constant.numeric","40px"] +],[ + "start", + ["text"," "], + ["support.type","color"], + ["text",": "], + ["constant.numeric","#c9c9c9"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_scad.json b/public/lib/ace/mode/_test/tokens_scad.json new file mode 100644 index 0000000..8f0ff63 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_scad.json @@ -0,0 +1,194 @@ +[[ + "start", + ["comment","// ace can highlight scad!"] +],[ + "start", + ["keyword","module"], + ["text"," "], + ["identifier","Element"], + ["paren.lparen","("], + ["identifier","xpos"], + ["text",", "], + ["identifier","ypos"], + ["text",", "], + ["identifier","zpos"], + ["paren.rparen",")"], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["identifier","translate"], + ["paren.lparen","(["], + ["identifier","xpos"], + ["text",","], + ["identifier","ypos"], + ["text",","], + ["identifier","zpos"], + ["paren.rparen","])"], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t"], + ["identifier","union"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t\t"], + ["identifier","cube"], + ["paren.lparen","(["], + ["constant.numeric","10"], + ["text",","], + ["constant.numeric","10"], + ["text",","], + ["constant.numeric","4"], + ["paren.rparen","]"], + ["text",","], + ["identifier","true"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text","\t\t\t"], + ["identifier","cylinder"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["text",","], + ["constant.numeric","15"], + ["text",","], + ["constant.numeric","5"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text","\t\t\t"], + ["identifier","translate"], + ["paren.lparen","(["], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","10"], + ["paren.rparen","])"], + ["identifier","sphere"], + ["paren.lparen","("], + ["constant.numeric","5"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text","\t\t"], + ["paren.rparen","}"] +],[ + "start", + ["text","\t"], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["identifier","union"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["keyword","for"], + ["paren.lparen","("], + ["identifier","i"], + ["keyword.operator","="], + ["paren.lparen","["], + ["constant.numeric","0"], + ["text",":"], + ["constant.numeric","30"], + ["paren.rparen","])"], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t# "], + ["identifier","Element"], + ["paren.lparen","("], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text","\t\t"], + ["identifier","Element"], + ["paren.lparen","("], + ["constant.numeric","15"], + ["keyword.operator","*"], + ["identifier","i"], + ["text",","], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text","\t"], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","for"], + ["text"," "], + ["paren.lparen","("], + ["identifier","i"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","["], + ["constant.numeric","3"], + ["text",", "], + ["constant.numeric","5"], + ["text",", "], + ["constant.numeric","7"], + ["text",", "], + ["constant.numeric","11"], + ["paren.rparen","])"], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["identifier","rotate"], + ["paren.lparen","(["], + ["identifier","i"], + ["keyword.operator","*"], + ["constant.numeric","10"], + ["text",","], + ["constant.numeric","0"], + ["text",","], + ["constant.numeric","0"], + ["paren.rparen","])"], + ["identifier","scale"], + ["paren.lparen","(["], + ["constant.numeric","1"], + ["text",","], + ["constant.numeric","1"], + ["text",","], + ["identifier","i"], + ["paren.rparen","])"], + ["identifier","cube"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_scala.json b/public/lib/ace/mode/_test/tokens_scala.json new file mode 100644 index 0000000..e59e55d --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_scala.json @@ -0,0 +1,542 @@ +[[ + "start", + ["comment","// http://www.scala-lang.org/node/54"] +],[ + "start" +],[ + "start", + ["keyword","package"], + ["text"," "], + ["identifier","examples"], + ["text","."], + ["identifier","actors"] +],[ + "start" +],[ + "start", + ["keyword","import"], + ["text"," "], + ["identifier","scala"], + ["text","."], + ["identifier","actors"], + ["text","."], + ["identifier","Actor"] +],[ + "start", + ["keyword","import"], + ["text"," "], + ["identifier","scala"], + ["text","."], + ["identifier","actors"], + ["text","."], + ["identifier","Actor"], + ["text","."], + ["identifier","_"] +],[ + "start" +],[ + "start", + ["keyword","abstract"], + ["text"," "], + ["keyword","class"], + ["text"," "], + ["identifier","PingMessage"] +],[ + "start", + ["keyword","case"], + ["text"," "], + ["keyword","object"], + ["text"," "], + ["identifier","Start"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["identifier","PingMessage"] +],[ + "start", + ["keyword","case"], + ["text"," "], + ["keyword","object"], + ["text"," "], + ["identifier","SendPing"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["identifier","PingMessage"] +],[ + "start", + ["keyword","case"], + ["text"," "], + ["keyword","object"], + ["text"," "], + ["identifier","Pong"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["identifier","PingMessage"] +],[ + "start" +],[ + "start", + ["keyword","abstract"], + ["text"," "], + ["keyword","class"], + ["text"," "], + ["identifier","PongMessage"] +],[ + "start", + ["keyword","case"], + ["text"," "], + ["keyword","object"], + ["text"," "], + ["identifier","Ping"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["identifier","PongMessage"] +],[ + "start", + ["keyword","case"], + ["text"," "], + ["keyword","object"], + ["text"," "], + ["identifier","Stop"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["identifier","PongMessage"] +],[ + "start" +],[ + "start", + ["keyword","object"], + ["text"," "], + ["identifier","pingpong"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["support.function","Application"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","val"], + ["text"," "], + ["identifier","pong"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["keyword","new"], + ["text"," "], + ["identifier","Pong"] +],[ + "start", + ["text"," "], + ["keyword","val"], + ["text"," "], + ["identifier","ping"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["keyword","new"], + ["text"," "], + ["identifier","Ping"], + ["paren.lparen","("], + ["constant.numeric","100000"], + ["text",", "], + ["identifier","pong"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","ping"], + ["text","."], + ["identifier","start"] +],[ + "start", + ["text"," "], + ["identifier","pong"], + ["text","."], + ["identifier","start"] +],[ + "start", + ["text"," "], + ["identifier","ping"], + ["text"," "], + ["keyword.operator","!"], + ["text"," "], + ["identifier","Start"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","Ping"], + ["paren.lparen","("], + ["identifier","count"], + ["text",": "], + ["support.function","Int"], + ["text",", "], + ["identifier","pong"], + ["text",": "], + ["identifier","Actor"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["identifier","Actor"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","def"], + ["text"," "], + ["identifier","act"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","println"], + ["paren.lparen","("], + ["string","\"Ping: Initializing with count \""], + ["keyword.operator","+"], + ["identifier","count"], + ["keyword.operator","+"], + ["string","\": \""], + ["keyword.operator","+"], + ["identifier","pong"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","var"], + ["text"," "], + ["identifier","pingsLeft"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","count"] +],[ + "start", + ["text"," "], + ["identifier","loop"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","react"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","case"], + ["text"," "], + ["identifier","Start"], + ["text"," "], + ["keyword.operator","=>"] +],[ + "start", + ["text"," "], + ["keyword","println"], + ["paren.lparen","("], + ["string","\"Ping: starting.\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","pong"], + ["text"," "], + ["keyword.operator","!"], + ["text"," "], + ["identifier","Ping"] +],[ + "start", + ["text"," "], + ["identifier","pingsLeft"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","pingsLeft"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","case"], + ["text"," "], + ["identifier","SendPing"], + ["text"," "], + ["keyword.operator","=>"] +],[ + "start", + ["text"," "], + ["identifier","pong"], + ["text"," "], + ["keyword.operator","!"], + ["text"," "], + ["identifier","Ping"] +],[ + "start", + ["text"," "], + ["identifier","pingsLeft"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","pingsLeft"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","case"], + ["text"," "], + ["identifier","Pong"], + ["text"," "], + ["keyword.operator","=>"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","pingsLeft"], + ["text"," "], + ["keyword.operator","%"], + ["text"," "], + ["constant.numeric","1000"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","println"], + ["paren.lparen","("], + ["string","\"Ping: pong from: \""], + ["keyword.operator","+"], + ["identifier","sender"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","pingsLeft"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","self"], + ["text"," "], + ["keyword.operator","!"], + ["text"," "], + ["identifier","SendPing"] +],[ + "start", + ["text"," "], + ["keyword","else"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","println"], + ["paren.lparen","("], + ["string","\"Ping: Stop.\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","pong"], + ["text"," "], + ["keyword.operator","!"], + ["text"," "], + ["identifier","Stop"] +],[ + "start", + ["text"," "], + ["identifier","exit"], + ["paren.lparen","("], + ["symbol.constant","'stop"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","Pong"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["identifier","Actor"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","def"], + ["text"," "], + ["identifier","act"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","var"], + ["text"," "], + ["identifier","pongCount"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["identifier","loop"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","react"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","case"], + ["text"," "], + ["identifier","Ping"], + ["text"," "], + ["keyword.operator","=>"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","pongCount"], + ["text"," "], + ["keyword.operator","%"], + ["text"," "], + ["constant.numeric","1000"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","println"], + ["paren.lparen","("], + ["string","\"Pong: ping \""], + ["keyword.operator","+"], + ["identifier","pongCount"], + ["keyword.operator","+"], + ["string","\" from \""], + ["keyword.operator","+"], + ["identifier","sender"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","sender"], + ["text"," "], + ["keyword.operator","!"], + ["text"," "], + ["identifier","Pong"] +],[ + "start", + ["text"," "], + ["identifier","pongCount"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","pongCount"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","case"], + ["text"," "], + ["identifier","Stop"], + ["text"," "], + ["keyword.operator","=>"] +],[ + "start", + ["text"," "], + ["keyword","println"], + ["paren.lparen","("], + ["string","\"Pong: Stop.\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","exit"], + ["paren.lparen","("], + ["symbol.constant","'stop"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_scheme.json b/public/lib/ace/mode/_test/tokens_scheme.json new file mode 100644 index 0000000..42f4aa6 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_scheme.json @@ -0,0 +1,216 @@ +[[ + "start", + ["text","("], + ["storage.type.function-type.scheme","define"], + ["text"," "], + ["text","("], + ["identifier","prompt-for-cd"], + ["text",")"] +],[ + "start", + ["text"," "], + ["string","\"Prompts"] +],[ + "start", + ["text"," "], + ["identifier","for"], + ["text"," "], + ["identifier","CD"], + ["text","\""] +],[ + "start", + ["text"," ("], + ["identifier","prompt-read"], + ["text"," "], + ["string","\"Title\""], + ["text"," "], + ["constant.numeric","1.53"], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","2"], + ["text","/"], + ["constant.numeric","4"], + ["text"," "], + ["constant.numeric","1.7"], + ["text"," "], + ["constant.numeric","1.7e0"], + ["text"," "], + ["constant.numeric","2.9E-4"], + ["text"," "], + ["constant.numeric","+42"], + ["text"," "], + ["constant.numeric","-7"], + ["text"," "], + ["constant.numeric","#b001"], + ["text"," "], + ["constant.numeric","#b001"], + ["text","/"], + ["constant.numeric","100"], + ["text"," "], + ["constant.numeric","#o777"], + ["text"," "], + ["constant.numeric","#O777"], + ["text"," "], + ["constant.numeric","#xabc55"], + ["text"," "], + ["identifier","#c"], + ["text","("], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","-5.6"], + ["text","))"] +],[ + "start", + ["text"," ("], + ["identifier","prompt-read"], + ["text"," "], + ["string","\"Artist\""], + ["text",")"] +],[ + "start", + ["text"," ("], + ["keyword.operator","or"], + ["text"," ("], + ["identifier","parse-integer"], + ["text"," ("], + ["identifier","prompt-read"], + ["text"," "], + ["string","\"Rating\""], + ["text",") "], + ["punctuation.definition.constant.character.scheme","#:junk-allowed"], + ["text"," "], + ["constant.language","#t"], + ["text",") "], + ["constant.numeric","0"], + ["text",")"] +],[ + "start", + ["text"," ("], + ["keyword.control","if"], + ["text"," "], + ["identifier","x"], + ["text"," ("], + ["support.function","format"], + ["text"," "], + ["constant.language","#t"], + ["text"," "], + ["string","\"yes\""], + ["text",") ("], + ["support.function","format"], + ["text"," "], + ["constant.language","#f"], + ["text"," "], + ["string","\"no\""], + ["text",") "], + ["comment",";and here comment"] +],[ + "start", + ["text"," ) "] +],[ + "start", + ["text"," "], + ["comment",";; second line comment"] +],[ + "start", + ["text"," '(+ "], + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","2"], + ["text",")"] +],[ + "start", + ["text"," ("], + ["identifier","position-if-not"], + ["text"," "], + ["identifier","char-set"], + ["text",":"], + ["identifier","whitespace"], + ["text"," "], + ["identifier","line"], + ["text"," "], + ["punctuation.definition.constant.character.scheme","#:start"], + ["text"," "], + ["identifier","beg"], + ["text","))"] +],[ + "start", + ["text"," ("], + ["support.function","quote"], + ["text"," ("], + ["identifier","privet"], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","2"], + ["text"," "], + ["constant.numeric","3"], + ["text","))"] +],[ + "start", + ["text"," '("], + ["identifier","hello"], + ["text"," "], + ["identifier","world"], + ["text",")"] +],[ + "start", + ["text"," (* "], + ["constant.numeric","5"], + ["text"," "], + ["constant.numeric","7"], + ["text",")"] +],[ + "start", + ["text"," ("], + ["constant.numeric","1"], + ["text"," "], + ["constant.numeric","2"], + ["text"," "], + ["constant.numeric","34"], + ["text"," "], + ["constant.numeric","5"], + ["text",")"] +],[ + "start", + ["text"," ("], + ["punctuation.definition.constant.character.scheme","#:use"], + ["text"," "], + ["string","\"aaaa\""], + ["text",")"] +],[ + "start", + ["text"," ("], + ["keyword.control","let"], + ["text"," (("], + ["identifier","x"], + ["text"," "], + ["constant.numeric","10"], + ["text",") ("], + ["identifier","y"], + ["text"," "], + ["constant.numeric","20"], + ["text","))"] +],[ + "start", + ["text"," ("], + ["identifier","display"], + ["text"," (+ "], + ["identifier","x"], + ["text"," "], + ["identifier","y"], + ["text","))"] +],[ + "start", + ["text"," ) "] +],[ + "start" +],[ + "start", + ["text"," "], + ["string","\"asdad"], + ["constant.character.escape.scheme","\\0"], + ["string","eqweqe\""] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_scss.json b/public/lib/ace/mode/_test/tokens_scss.json new file mode 100644 index 0000000..7e92f15 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_scss.json @@ -0,0 +1,123 @@ +[[ + "start", + ["comment","/* style.scss */"] +],[ + "start" +],[ + "start", + ["variable.language","#navbar"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","$navbar-width"], + ["text",": "], + ["constant.numeric","800px"], + ["text",";"] +],[ + "start", + ["text"," "], + ["variable","$items"], + ["text",": "], + ["constant.numeric","5"], + ["text",";"] +],[ + "start", + ["text"," "], + ["variable","$navbar-color"], + ["text",": "], + ["constant.numeric","#ce4dd6"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["support.type","width"], + ["text",": "], + ["variable","$navbar-width"], + ["text",";"] +],[ + "start", + ["text"," "], + ["support.type","border-bottom"], + ["text",": "], + ["constant.numeric","2px"], + ["text"," "], + ["constant.language","solid"], + ["text"," "], + ["variable","$navbar-color"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable.language","li"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.type","float"], + ["text",": "], + ["support.type","left"], + ["text",";"] +],[ + "start", + ["text"," "], + ["support.type","width"], + ["text",": "], + ["variable","$navbar-width"], + ["text","/"], + ["variable","$items"], + ["text"," "], + ["constant","-"], + ["text"," "], + ["constant.numeric","10px"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["support.type","background-color"], + ["text",": "], + ["support.function","lighten"], + ["paren.lparen","("], + ["variable","$navbar-color"], + ["text",", "], + ["constant.numeric","20%"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text"," &"], + ["variable.language",":hover"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.type","background-color"], + ["text",": "], + ["support.function","lighten"], + ["paren.lparen","("], + ["variable","$navbar-color"], + ["text",", "], + ["constant.numeric","10%"], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_sh.json b/public/lib/ace/mode/_test/tokens_sh.json new file mode 100644 index 0000000..4ec172b --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_sh.json @@ -0,0 +1,397 @@ +[[ + "start", + ["comment","#!/bin/sh"] +],[ + "start" +],[ + "start", + ["comment","# Script to open a browser to current branch"] +],[ + "start", + ["comment","# Repo formats:"] +],[ + "start", + ["comment","# ssh git@github.com:richo/gh_pr.git"] +],[ + "start", + ["comment","# http https://richoH@github.com/richo/gh_pr.git"] +],[ + "start", + ["comment","# git git://github.com/richo/gh_pr.git"] +],[ + "start" +],[ + "start", + ["variable","username"], + ["keyword.operator","=`"], + ["identifier","git"], + ["text"," "], + ["identifier","config"], + ["text"," "], + ["keyword.operator","--"], + ["identifier","get"], + ["text"," "], + ["identifier","github"], + ["text","."], + ["identifier","user"], + ["keyword.operator","`"] +],[ + "start" +],[ + "start", + ["support.function","get_repo()"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","git"], + ["text"," "], + ["identifier","remote"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","v"], + ["text"," "], + ["keyword.operator","|"], + ["text"," "], + ["identifier","grep"], + ["text"," "], + ["variable","$"], + ["paren.lparen","{"], + ["variable","@"], + ["keyword.operator",":-"], + ["variable","$username"], + ["paren.rparen","}"], + ["text"," "], + ["keyword.operator","|"], + ["text"," "], + ["keyword","while"], + ["text"," "], + ["keyword","read"], + ["text"," "], + ["identifier","remote"], + ["punctuation.operator",";"], + ["text"," "], + ["keyword","do"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","repo"], + ["keyword.operator","=`"], + ["support.function.builtin","echo"], + ["text"," "], + ["variable","$remote"], + ["text"," "], + ["keyword.operator","|"], + ["text"," "], + ["identifier","grep"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","E"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","o"], + ["text"," "], + ["string.start","\""], + ["string","git@github.com:[^ ]*"], + ["string.end","\""], + ["keyword.operator","`"], + ["punctuation.operator",";"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["support.function.builtin","echo"], + ["text"," "], + ["variable","$repo"], + ["text"," "], + ["keyword.operator","|"], + ["text"," "], + ["identifier","sed"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","e"], + ["text"," "], + ["string.start","\""], + ["string","s/^git@github\\.com://"], + ["string.end","\""], + ["text"," "], + ["keyword.operator","-"], + ["identifier","e"], + ["text"," "], + ["string.start","\""], + ["string","s/\\.git$//"], + ["string.end","\""] +],[ + "start", + ["text"," "], + ["support.function.builtin","exit"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","fi"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","repo"], + ["keyword.operator","=`"], + ["support.function.builtin","echo"], + ["text"," "], + ["variable","$remote"], + ["text"," "], + ["keyword.operator","|"], + ["text"," "], + ["identifier","grep"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","E"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","o"], + ["text"," "], + ["string.start","\""], + ["string","https?://([^@]*@)?github.com/[^ ]*\\.git"], + ["string.end","\""], + ["keyword.operator","`"], + ["punctuation.operator",";"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["support.function.builtin","echo"], + ["text"," "], + ["variable","$repo"], + ["text"," "], + ["keyword.operator","|"], + ["text"," "], + ["identifier","sed"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","e"], + ["text"," "], + ["string.start","\""], + ["string","s|^https?://||"], + ["string.end","\""], + ["text"," "], + ["keyword.operator","-"], + ["identifier","e"], + ["text"," "], + ["string.start","\""], + ["string","s/^.*github\\.com\\///"], + ["string.end","\""], + ["text"," "], + ["keyword.operator","-"], + ["identifier","e"], + ["text"," "], + ["string.start","\""], + ["string","s/\\.git$//"], + ["string.end","\""] +],[ + "start", + ["text"," "], + ["support.function.builtin","exit"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","fi"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","repo"], + ["keyword.operator","=`"], + ["support.function.builtin","echo"], + ["text"," "], + ["variable","$remote"], + ["text"," "], + ["keyword.operator","|"], + ["text"," "], + ["identifier","grep"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","E"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","o"], + ["text"," "], + ["string.start","\""], + ["string","git://github.com/[^ ]*\\.git"], + ["string.end","\""], + ["keyword.operator","`"], + ["punctuation.operator",";"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["support.function.builtin","echo"], + ["text"," "], + ["variable","$repo"], + ["text"," "], + ["keyword.operator","|"], + ["text"," "], + ["identifier","sed"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","e"], + ["text"," "], + ["string.start","\""], + ["string","s|^git://github.com/||"], + ["string.end","\""], + ["text"," "], + ["keyword.operator","-"], + ["identifier","e"], + ["text"," "], + ["string.start","\""], + ["string","s/\\.git$//"], + ["string.end","\""] +],[ + "start", + ["text"," "], + ["support.function.builtin","exit"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","fi"] +],[ + "start", + ["text"," "], + ["keyword","done"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","["], + ["text"," "], + ["variable.language","$?"], + ["text"," "], + ["keyword.operator","-"], + ["identifier","eq"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["paren.rparen","]"], + ["punctuation.operator",";"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["support.function.builtin","echo"], + ["text"," "], + ["string.start","\""], + ["string","Couldn't find a valid remote"], + ["string.end","\""], + ["text"," "], + ["keyword.operator",">"], + ["support.function","&2"] +],[ + "start", + ["text"," "], + ["support.function.builtin","exit"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","fi"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["support.function.builtin","echo"], + ["text"," "], + ["variable","$"], + ["paren.lparen","{"], + ["keyword.operator","#"], + ["variable","x"], + ["paren.lparen","["], + ["text","@"], + ["paren.rparen","]}"] +],[ + "start" +],[ + "start", + ["keyword","if"], + ["text"," "], + ["variable","repo"], + ["keyword.operator","=`"], + ["identifier","get_repo"], + ["text"," "], + ["variable","$@"], + ["keyword.operator","`"], + ["punctuation.operator",";"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["variable","branch"], + ["keyword.operator","=`"], + ["identifier","git"], + ["text"," "], + ["identifier","symbolic"], + ["keyword.operator","-"], + ["identifier","ref"], + ["text"," "], + ["identifier","HEAD"], + ["text"," "], + ["constant.numeric","2"], + ["keyword.operator",">/"], + ["identifier","dev"], + ["keyword.operator","/"], + ["identifier","null"], + ["keyword.operator","`"] +],[ + "start", + ["text"," "], + ["support.function.builtin","echo"], + ["text"," "], + ["string.start","\""], + ["string","http://github.com/"], + ["variable","$repo"], + ["string","/pull/new/"], + ["variable","$"], + ["paren.lparen","{"], + ["variable","branch"], + ["keyword.operator","##"], + ["identifier","refs"], + ["keyword.operator","/"], + ["identifier","heads"], + ["keyword.operator","/"], + ["paren.rparen","}"], + ["string.end","\""] +],[ + "start", + ["keyword","else"] +],[ + "start", + ["text"," "], + ["support.function.builtin","exit"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["keyword","fi"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_sjs.json b/public/lib/ace/mode/_test/tokens_sjs.json new file mode 100644 index 0000000..5cd9645 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_sjs.json @@ -0,0 +1,276 @@ +[[ + "start", + ["storage.type","var"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","each"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","map"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","require"], + ["paren.lparen","("], + ["string","'sjs:sequence'"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["storage.type","var"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["keyword","get"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","require"], + ["paren.lparen","("], + ["string","'sjs:http'"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["storage.type","function"], + ["text"," "], + ["entity.name.function","foo"], + ["paren.lparen","("], + ["variable.parameter","items"], + ["punctuation.operator",", "], + ["variable.parameter","nada"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","component"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","name"], + ["punctuation.operator",":"], + ["text"," "], + ["string","\"Ace\""], + ["punctuation.operator",","], + ["text"," "], + ["identifier","role"], + ["punctuation.operator",":"], + ["text"," "], + ["string","\"Editor\""], + ["text"," "], + ["paren.rparen","}"], + ["punctuation.operator",";"] +],[ + ["qqstring","no_regex"], + ["text"," "], + ["storage.type","console"], + ["punctuation.operator","."], + ["support.function.firebug","log"], + ["paren.lparen","("], + ["string","\""] +],[ + ["qqstring","no_regex"], + ["string"," Welcome, "], + ["paren.lparen","#{"], + ["identifier","component"], + ["text","."], + ["identifier","name"], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["string"," \""], + ["punctuation.operator","."], + ["identifier","trim"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["punctuation.operator",";"] +],[ + ["no_regex"] +],[ + ["no_regex"], + ["text"," "], + ["identifier","logging"], + ["punctuation.operator","."], + ["identifier","debug"], + ["paren.lparen","("], + ["string","`Component added: "], + ["paren.lparen","$"], + ["identifier","String"], + ["paren.lparen","("], + ["identifier","component"], + ["paren.rparen",")"], + ["string"," ("], + ["paren.lparen","${"], + ["identifier","component"], + ["paren.rparen","}"], + ["string",")`"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"] +],[ + ["bstring","no_regex"], + ["text"," "], + ["storage.type","console"], + ["punctuation.operator","."], + ["support.function.firebug","log"], + ["paren.lparen","("], + ["string","`"] +],[ + ["string_interp","string_interp","bstring","no_regex"], + ["string"," Welcome, {"], + ["paren.lparen","${"], + ["storage.type","function"], + ["text","() "], + ["paren.lparen","{"] +],[ + ["string_interp","string_interp","bstring","no_regex"], + ["text"," "], + ["keyword","return"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","x"], + ["text",": "], + ["constant.numeric","1"], + ["text",", "], + ["identifier","y"], + ["text",": "], + ["string","\"why?}\""], + ["paren.rparen","}"], + ["text",";"] +],[ + ["bstring","no_regex"], + ["text"," "], + ["paren.rparen","}"], + ["text","()"], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["string"," `"], + ["punctuation.operator","."], + ["identifier","trim"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["punctuation.operator",";"] +],[ + ["no_regex"] +],[ + ["no_regex"], + ["text"," "], + ["keyword","waitfor"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["identifier","items"], + ["text"," "], + ["keyword.operator",".."], + ["text"," "], + ["identifier","each"], + ["punctuation.operator","."], + ["identifier","par"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["paren.rparen","|"], + ["variable.parameter","item"], + ["paren.rparen","|"] +],[ + ["no_regex"], + ["text"," "], + ["keyword","get"], + ["paren.lparen","("], + ["identifier","item"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","lengths"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","items"], + ["text"," "], + ["keyword.operator",".."], + ["text"," "], + ["identifier","map"], + ["paren.lparen","("], + ["identifier","i"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["identifier","i"], + ["punctuation.operator","."], + ["support.constant","length"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","or"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["variable.language","hold"], + ["paren.lparen","("], + ["constant.numeric","1500"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["keyword","throw"], + ["text"," "], + ["keyword","new"], + ["text"," "], + ["variable.language","Error"], + ["paren.lparen","("], + ["string","\"timed out\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["paren.rparen","}"], + ["text","\t"], + ["comment","// Real Tab."] +],[ + ["no_regex"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_smarty.json b/public/lib/ace/mode/_test/tokens_smarty.json new file mode 100644 index 0000000..0f56985 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_smarty.json @@ -0,0 +1,98 @@ +[[ + "start", + ["punctuation.section.embedded.begin.smarty","{"], + ["keyword.control.smarty","foreach"], + ["source.smarty"," "], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","foo"], + ["source.smarty"," as "], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["punctuation.section.embedded.end.smarty","}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zig"], + ["punctuation.section.embedded.end.smarty","}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zag"], + ["punctuation.section.embedded.end.smarty","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zig2"], + ["punctuation.section.embedded.end.smarty","}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zag2"], + ["punctuation.section.embedded.end.smarty","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zig3"], + ["punctuation.section.embedded.end.smarty","}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zag3"], + ["punctuation.section.embedded.end.smarty","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["punctuation.section.embedded.begin.smarty","{"], + ["keyword.control.smarty","foreachelse"], + ["punctuation.section.embedded.end.smarty","}"] +],[ + "start", + ["text.xml"," There were no rows found."] +],[ + "start", + ["punctuation.section.embedded.begin.smarty","{"], + ["source.smarty","/"], + ["keyword.control.smarty","foreach"], + ["punctuation.section.embedded.end.smarty","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_snippets.json b/public/lib/ace/mode/_test/tokens_snippets.json new file mode 100644 index 0000000..308683b --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_snippets.json @@ -0,0 +1,159 @@ +[[ + "start", + ["comment","# Function"] +],[ + "start", + ["constant.language.escape","snippet"], + ["text"," fun"] +],[ + "sn-start", + ["text","\tfunction "], + ["markup.list","${"], + ["constant.numeric","1"], + ["text","?:function_name"], + ["markup.list","}"], + ["text","("], + ["markup.list","${"], + ["constant.numeric","2"], + ["punctuation.operator",":"], + ["text","argument"], + ["markup.list","}"], + ["text",") {"] +],[ + "sn-start", + ["text","\t\t"], + ["markup.list","${"], + ["constant.numeric","3"], + ["punctuation.operator",":"], + ["text","// body..."], + ["markup.list","}"] +],[ + "sn-start", + ["text","\t}"] +],[ + "start", + ["comment","# Anonymous Function"] +],[ + "start", + ["constant.language.escape","regex "], + ["keyword","/"], + ["text","((=)\\s*|(:)\\s*|(\\()|\\b)"], + ["keyword","/"], + ["text","f"], + ["keyword","/"], + ["text","(\\))?"], + ["keyword","/"] +],[ + "start", + ["constant.language.escape","name"], + ["text"," f"] +],[ + "sn-start", + ["text","\tfunction"], + ["markup.list","${"], + ["variable","M1"], + ["text","?: "], + ["markup.list","${"], + ["constant.numeric","1"], + ["punctuation.operator",":"], + ["text","functionName"], + ["markup.list","}}"], + ["text","("], + ["variable","$2"], + ["text",") {"] +],[ + "sn-start", + ["text","\t\t"], + ["markup.list","${"], + ["constant.numeric","0"], + ["punctuation.operator",":"], + ["keyword","$TM_SELECTED_TEXT"], + ["markup.list","}"] +],[ + "sn-start", + ["text","\t}"], + ["markup.list","${"], + ["variable","M2"], + ["text","?;"], + ["markup.list","}${"], + ["variable","M3"], + ["text","?,"], + ["markup.list","}${"], + ["variable","M4"], + ["text","?)"], + ["markup.list","}"] +],[ + "start", + ["comment","# Immediate function"] +],[ + "start", + ["constant.language.escape","trigger"], + ["text"," \\(?f\\("] +],[ + "start", + ["constant.language.escape","endTrigger"], + ["text"," \\)?"] +],[ + "start", + ["constant.language.escape","snippet"], + ["text"," f("] +],[ + "sn-start", + ["text","\t(function("], + ["markup.list","${"], + ["constant.numeric","1"], + ["markup.list","}"], + ["text",") {"] +],[ + "sn-start", + ["text","\t\t"], + ["markup.list","${"], + ["constant.numeric","0"], + ["punctuation.operator",":"], + ["markup.list","${"], + ["keyword","TM_SELECTED_TEXT"], + ["punctuation.operator",":"], + ["text","/* code */"], + ["markup.list","}}"] +],[ + "sn-start", + ["text","\t}("], + ["markup.list","${"], + ["constant.numeric","1"], + ["markup.list","}"], + ["text","));"] +],[ + "start", + ["comment","# if"] +],[ + "start", + ["constant.language.escape","snippet"], + ["text"," if"] +],[ + "sn-start", + ["text","\tif ("], + ["markup.list","${"], + ["constant.numeric","1"], + ["punctuation.operator",":"], + ["text","true"], + ["markup.list","}"], + ["text",") {"] +],[ + "sn-start", + ["text","\t\t"], + ["markup.list","${"], + ["constant.numeric","0"], + ["markup.list","}"] +],[ + "sn-start", + ["text","\t}"] +],[ + "sn-start", + ["text","\t"] +],[ + "sn-start", + ["text","\t"] +],[ + "sn-start", + ["text","\t"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_soy_template.json b/public/lib/ace/mode/_test/tokens_soy_template.json new file mode 100644 index 0000000..c4f9509 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_soy_template.json @@ -0,0 +1,286 @@ +[[ + "punctuation.definition.comment.begin.soy1", + ["punctuation.definition.comment.begin.soy","/**"] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * Greets a person using \"Hello\" by default."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param"], + ["text"," "], + ["variable.parameter.soy","name"], + ["comment.block.documentation.soy"," The name of the person."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param?"], + ["text"," "], + ["variable.parameter.soy","greetingWord"], + ["comment.block.documentation.soy"," Optional greeting word to use instead of \"Hello\"."] +],[ + "start", + ["comment.block.documentation.soy"," "], + ["punctuation.definition.comment.end.soy","*/"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","template"], + ["text"," "], + ["entity.name.function.soy",".helloName"], + ["meta.tag.template.soy"," #eee"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","if"], + ["meta.tag.if.soy"," "], + ["keyword.operator.soy","not"], + ["meta.tag.if.soy"," "], + ["variable.other.soy","$greetingWord"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," Hello "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$name"], + ["punctuation.definition.tag.end.soy","}"], + ["text.xml","!"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["text","else"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$greetingWord"], + ["punctuation.definition.tag.end.soy","}"], + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$name"], + ["punctuation.definition.tag.end.soy","}"], + ["text.xml","!"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","if"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.template.soy","template"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "punctuation.definition.comment.begin.soy1", + ["punctuation.definition.comment.begin.soy","/**"] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * Greets a person and optionally a list of other people."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param"], + ["text"," "], + ["variable.parameter.soy","name"], + ["comment.block.documentation.soy"," The name of the person."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param"], + ["text"," "], + ["variable.parameter.soy","additionalNames"], + ["comment.block.documentation.soy"," The additional names to greet. May be an empty list."] +],[ + "start", + ["comment.block.documentation.soy"," "], + ["punctuation.definition.comment.end.soy","*/"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","template"], + ["text"," "], + ["entity.name.function.soy",".helloNames"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["comment.line.double-slash.soy","//"], + ["comment.line.double-slash.soy"," Greet the person."] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","call"], + ["variable.parameter.soy"," .helloName"], + ["meta.tag.call.soy"," "], + ["entity.other.attribute-name.soy","data"], + ["keyword.operator.soy","="], + ["string.quoted.double","\"all\""], + ["meta.tag.call.soy"," /"], + ["punctuation.definition.tag.end.soy","}"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","br"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["comment.line.double-slash.soy","//"], + ["comment.line.double-slash.soy"," Greet the additional people."] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","foreach"], + ["meta.tag.foreach.soy"," "], + ["variable.other.soy","$additionalName"], + ["meta.tag.foreach.soy"," "], + ["keyword.operator.soy","in"], + ["meta.tag.foreach.soy"," "], + ["variable.other.soy","$additionalNames"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","call"], + ["variable.parameter.soy"," .helloName"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","param"], + ["meta.tag.param.soy"," "], + ["entity.other.attribute-name.soy","name"], + ["keyword.operator.soy",":"], + ["meta.tag.param.soy"," "], + ["variable.other.soy","$additionalName"], + ["meta.tag.param.soy"," /"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.call.soy","call"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","if"], + ["meta.tag.if.soy"," "], + ["keyword.operator.soy","not"], + ["meta.tag.if.soy"," "], + ["support.function.soy","isLast"], + ["meta.tag.if.soy","("], + ["variable.other.soy","$additionalName"], + ["meta.tag.if.soy",")"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","br"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," "], + ["comment.line.double-slash.soy","//"], + ["comment.line.double-slash.soy"," break after every line except the last"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","if"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["text","ifempty"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," No additional people to greet."] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","foreach"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.template.soy","template"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","foreach"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","if"], + ["meta.tag.if.soy"," "], + ["support.function.soy","length"], + ["meta.tag.if.soy","("], + ["variable.other.soy","$items"], + ["meta.tag.if.soy",") > 5"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","msg"], + ["meta.tag.msg.soy"," "], + ["entity.other.attribute-name.soy","desc"], + ["keyword.operator.soy","="], + ["string.quoted.double","\"Says hello to the user.\""], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","namespace"], + ["text"," "], + ["variable.parameter.soy","ns"], + ["text"," autoescape=\"contextual\""], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "start", + ["punctuation.definition.comment.begin.soy","/**"], + ["comment.block.documentation.soy"," Example. "], + ["punctuation.definition.comment.end.soy","*/"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","template"], + ["text"," "], + ["entity.name.function.soy",".example"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," foo is "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$ij.foo"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.template.soy","template"], + ["punctuation.definition.tag.end.soy","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_space.json b/public/lib/ace/mode/_test/tokens_space.json new file mode 100644 index 0000000..918b9a6 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_space.json @@ -0,0 +1,322 @@ +[[ + "start", + ["variable","query"] +],[ + "start", + ["empty_line"," "], + ["variable","count"], + ["keyword.operator"," "], + ["string","10"] +],[ + "start", + ["empty_line"," "], + ["variable","created"], + ["keyword.operator"," "], + ["string","2011-06-21T08:10:46Z"] +],[ + "start", + ["empty_line"," "], + ["variable","lang"], + ["keyword.operator"," "], + ["string","en-US"] +],[ + "start", + ["empty_line"," "], + ["variable","results"] +],[ + "start", + ["empty_line"," "], + ["variable","photo"] +],[ + "start", + ["empty_line"," "], + ["variable","0"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","6"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5855620975"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","f1f5e8515d"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","5110"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","7087 bandit cat"] +],[ + "start", + ["empty_line"," "], + ["variable","1"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","4"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856170534"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","ff1efb2a6f"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","3217"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","6975 rusty cat"] +],[ + "start", + ["empty_line"," "], + ["variable","2"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","6"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856172972"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","51249875@N03"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","6c6887347c"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","5192"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","watermarked-cats"] +],[ + "start", + ["empty_line"," "], + ["variable","3"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","6"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856168328"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","0c1cfdf64c"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","5078"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","7020 mandy cat"] +],[ + "start", + ["empty_line"," "], + ["variable","4"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","3"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856171774"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","7f5a3180ab"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","2696"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","7448 bobby cat"] +],[ + "key" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_sql.json b/public/lib/ace/mode/_test/tokens_sql.json new file mode 100644 index 0000000..09a3ef9 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_sql.json @@ -0,0 +1,54 @@ +[[ + "start", + ["keyword","SELECT"], + ["text"," "], + ["identifier","city"], + ["text",", "], + ["support.function","COUNT"], + ["paren.lparen","("], + ["identifier","id"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","AS"], + ["text"," "], + ["identifier","users_count"] +],[ + "start", + ["keyword","FROM"], + ["text"," "], + ["identifier","users"] +],[ + "start", + ["keyword","WHERE"], + ["text"," "], + ["identifier","group_name"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'salesman'"] +],[ + "start", + ["keyword","AND"], + ["text"," "], + ["identifier","created"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["string","'2011-05-21'"] +],[ + "start", + ["keyword","GROUP"], + ["text"," "], + ["keyword","BY"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["keyword","ORDER"], + ["text"," "], + ["keyword","BY"], + ["text"," "], + ["constant.numeric","2"], + ["text"," "], + ["keyword","DESC"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_sqlserver.json b/public/lib/ace/mode/_test/tokens_sqlserver.json new file mode 100644 index 0000000..446f52c --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_sqlserver.json @@ -0,0 +1,457 @@ +[[ + "start", + ["comment","-- ============================================="] +],[ + "start", + ["comment","-- Author:\t\tMorgan Yarbrough"] +],[ + "start", + ["comment","-- Create date: 4/27/2015"] +],[ + "start", + ["comment","-- Description:\tTest procedure that shows off language features."] +],[ + "start", + ["comment","-- \t\t\t\tIncludes non-standard folding with region comments using either"] +],[ + "start", + ["comment","-- \t\t\t\tline comments or block comments (both are demonstrated below)."] +],[ + "start", + ["comment","--\t\t\t\tThis mode imitates SSMS and it designed to be used with SQL Server theme."] +],[ + "start", + ["comment","-- ============================================="] +],[ + "start", + ["keyword","CREATE"], + ["text"," "], + ["keyword","PROCEDURE"], + ["text"," "], + ["identifier","dbo"], + ["text","."], + ["identifier","TestProcedure"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["comment","--#region parameters"] +],[ + "start", + ["text","\t"], + ["identifier","@vint"], + ["text"," "], + ["storage.type","INT"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text","\t"], + ["punctuation",","], + ["identifier","@vdate"], + ["text"," "], + ["storage.type","DATE"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.language","NULL"] +],[ + "start", + ["text","\t"], + ["punctuation",","], + ["identifier","@vdatetime"], + ["text"," "], + ["storage.type","DATETIME"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","DATEADD"], + ["paren.lparen","("], + ["identifier","dd"], + ["punctuation",","], + ["text"," "], + ["constant.numeric","1"], + ["punctuation",","], + ["text"," "], + ["support.function","GETDATE"], + ["paren.lparen","("], + ["paren.rparen","))"] +],[ + "start", + ["text","\t"], + ["punctuation",","], + ["identifier","@vvarchar"], + ["text"," "], + ["storage.type","VARCHAR"], + ["paren.lparen","("], + ["support.function","MAX"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.start","'"], + ["string.end","'"] +],[ + "start", + ["comment","--#endregion"] +],[ + "start" +],[ + "start", + ["keyword","AS"] +],[ + "start", + ["keyword","BEGIN"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["comment.start","/*"], + ["comment","#region set statements "], + ["comment.end","*/"] +],[ + "start", + ["text","\t"], + ["set.statement","SET NOCOUNT"], + ["text"," "], + ["keyword","ON"], + ["punctuation",";"] +],[ + "start", + ["text","\t"], + ["set.statement","SET XACT_ABORT"], + ["text"," "], + ["keyword","ON"], + ["punctuation",";"] +],[ + "start", + ["text","\t"], + ["set.statement","SET QUOTED_IDENTIFIER"], + ["text"," "], + ["keyword","ON"], + ["punctuation",";"] +],[ + "start", + ["text","\t"], + ["comment.start","/*"], + ["comment","#endregion"], + ["comment.end","*/"] +],[ + "start", + ["text","\t"] +],[ + "doc-start", + ["text","\t"], + ["comment.doc","/**"] +],[ + "doc-start", + ["comment.doc","\t * These comments will produce a fold widget"] +],[ + "start", + ["comment.doc","\t */"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["text","\t"], + ["comment","-- folding demonstration"] +],[ + "start", + ["text","\t"], + ["keyword","SET"], + ["text"," "], + ["identifier","@vint"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["keyword","CASE"] +],[ + "start", + ["text","\t\t\t\t\t"], + ["keyword","WHEN"], + ["text"," "], + ["identifier","@vdate"], + ["text"," "], + ["constant.language","IS"], + ["text"," "], + ["constant.language","NULL"] +],[ + "start", + ["text","\t\t\t\t\t\t"], + ["keyword","THEN"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text","\t\t\t\t\t"], + ["keyword","ELSE"], + ["text"," "], + ["constant.numeric","2"] +],[ + "start", + ["text","\t\t\t\t"], + ["keyword","END"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["text","\t"], + ["comment","-- another folding demonstration"] +],[ + "start", + ["text","\t"], + ["keyword","IF"], + ["text"," "], + ["identifier","@vint"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","1"], + ["text"," "] +],[ + "start", + ["text","\t"], + ["keyword","BEGIN"] +],[ + "start", + ["text","\t\t"], + ["keyword","SET"], + ["text"," "], + ["identifier","@vvarchar"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.start","'"], + ["string","one"], + ["string.end","'"] +],[ + "start", + ["text","\t\t"], + ["keyword","SET"], + ["text"," "], + ["identifier","@vint"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["support.function","DATEDIFF"], + ["paren.lparen","("], + ["identifier","dd"], + ["punctuation",","], + ["text"," "], + ["identifier","@vdate"], + ["punctuation",","], + ["text"," "], + ["identifier","@vdatetime"], + ["paren.rparen",")"] +],[ + "start", + ["text","\t"], + ["keyword","END"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["text","\t"], + ["comment","-- this mode handles strings properly"] +],[ + "string.start", + ["text","\t"], + ["keyword","DECLARE"], + ["text"," "], + ["identifier","@sql"], + ["text"," "], + ["storage.type","NVARCHAR"], + ["paren.lparen","("], + ["constant.numeric","4000"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","N"], + ["string.start","'"], + ["string","SELECT TOP(1) OrderID "] +],[ + "string.start", + ["string","\t\t\t\t\t\t\t\t\tFROM Orders"] +],[ + "start", + ["string","\t\t\t\t\t\t\t\t\tWHERE @OrderDate > GETDATE()"], + ["string.end","'"] +],[ + "start", + ["text","\t\t\t\t\t\t\t\t"] +],[ + "start", + ["text","\t"], + ["comment","-- this mode is aware of built in stored procedures "] +],[ + "start", + ["text","\t"], + ["keyword","EXECUTE"], + ["text"," "], + ["support.storedprocedure","sp_executesql"], + ["text"," "], + ["identifier","@sql"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["text","\t"], + ["comment","-- demonstrating some syntax highlighting"] +],[ + "start", + ["text","\t"], + ["keyword","SELECT"], + ["text"," "], + ["identifier","Orders"], + ["text","."], + ["identifier","OrderID"] +],[ + "start", + ["text","\t\t"], + ["punctuation",","], + ["identifier","Customers"], + ["text","."], + ["identifier","CompanyName"] +],[ + "start", + ["text","\t\t"], + ["punctuation",","], + ["support.function","DATEFROMPARTS"], + ["paren.lparen","("], + ["support.function","YEAR"], + ["paren.lparen","("], + ["support.function","GETDATE"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["punctuation",","], + ["text"," "], + ["constant.numeric","1"], + ["punctuation",","], + ["text"," "], + ["constant.numeric","1"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","AS"], + ["text"," "], + ["identifier","FirstDayOfYear"] +],[ + "start", + ["text","\t"], + ["keyword","FROM"], + ["text"," "], + ["identifier","Orders"] +],[ + "start", + ["text","\t"], + ["constant.language","INNER"], + ["text"," "], + ["constant.language","JOIN"], + ["text"," "], + ["identifier","Customers"] +],[ + "start", + ["text","\t\t"], + ["keyword","ON"], + ["text"," "], + ["identifier","Orders"], + ["text","."], + ["identifier","CustomerID"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","Customers"], + ["text","."], + ["identifier","CustomerID"] +],[ + "start", + ["text","\t"], + ["keyword","WHERE"], + ["text"," "], + ["identifier","CompanyName"], + ["text"," "], + ["constant.language","NOT"], + ["text"," "], + ["constant.language","LIKE"], + ["text"," "], + ["string.start","'"], + ["string","%something"], + ["string.end","'"] +],[ + "start", + ["text","\t\t"], + ["constant.language","OR"], + ["text"," "], + ["identifier","CompanyName"], + ["text"," "], + ["constant.language","IS"], + ["text"," "], + ["constant.language","NULL"] +],[ + "start", + ["text","\t\t"], + ["constant.language","OR"], + ["text"," "], + ["identifier","CompanyName"], + ["text"," "], + ["constant.language","IN"], + ["text"," "], + ["paren.lparen","("], + ["string.start","'"], + ["string","bla"], + ["string.end","'"], + ["punctuation",","], + ["text"," "], + ["string.start","'"], + ["string","nothing"], + ["string.end","'"], + ["paren.rparen",")"] +],[ + "start", + ["text","\t\t"] +],[ + "start", + ["text","\t"], + ["comment","-- this mode includes snippets"] +],[ + "start", + ["text","\t"], + ["comment","-- place your cusor at the end of the line below and trigger auto complete (Ctrl+Space)"] +],[ + "start", + ["text","\t"], + ["identifier","createpr"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["text","\t"], + ["comment","-- SQL Server allows using keywords as object names (not recommended) as long as they are wrapped in brackets"] +],[ + "start", + ["text","\t"], + ["keyword","DATABASE"], + ["text"," "], + ["comment","-- keyword"] +],[ + "start", + ["text","\t[DATABASE] "], + ["comment","-- not a keyword"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["keyword","END"] +],[ + "start" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_stylus.json b/public/lib/ace/mode/_test/tokens_stylus.json new file mode 100644 index 0000000..f24993f --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_stylus.json @@ -0,0 +1,271 @@ +[[ + "start", + ["comment","// I'm a comment!"] +],[ + "start" +],[ + "comment", + ["comment","/*"] +],[ + "comment", + ["comment"," * Adds the given numbers together."] +],[ + "start", + ["comment"," */"] +],[ + "start" +],[ + "start" +],[ + "comment", + ["comment","/*!"] +],[ + "comment", + ["comment"," * Adds the given numbers together."] +],[ + "start", + ["comment"," */"] +],[ + "start" +],[ + "start" +],[ + "start", + ["entity.name.function.stylus","asdasdasdad"], + ["text","("], + ["text","df, ad"], + ["keyword.operator.stylus","="], + ["constant.numeric","23"], + ["text",")"] +],[ + "start" +],[ + "start", + ["entity.name.function.stylus","add"], + ["text","("], + ["entity.name.tag.stylus","a"], + ["text",", "], + ["entity.name.tag.stylus","b"], + ["text"," "], + ["keyword.operator.stylus","="], + ["text"," "], + ["entity.name.tag.stylus","a"], + ["text",")"] +],[ + "start", + ["text"," "], + ["entity.name.tag.stylus","a"], + ["text"," "], + ["keyword.operator.stylus","+"], + ["text"," "], + ["entity.name.tag.stylus","b"] +],[ + "start", + ["entity.name.function.stylus","green"], + ["text","("], + ["constant.numeric","#0c0"], + ["text",")"] +],[ + "start", + ["text"," add("], + ["constant.numeric","10"], + ["text",", "], + ["constant.numeric","5"], + ["text",")"] +],[ + "start", + ["text"," "], + ["comment","// => 15"] +],[ + "start" +],[ + "start", + ["text"," add("], + ["constant.numeric","10"], + ["text",")"] +],[ + "start", + ["text"," add("], + ["entity.name.tag.stylus","a"], + ["text",", "], + ["entity.name.tag.stylus","b"], + ["text",")"] +],[ + "start" +],[ + "start", + ["entity.language.stylus"," &"], + ["text","asdasd"] +],[ + "start" +],[ + "start", + ["text"," ("], + ["variable.language.stylus","arguments"], + ["text",")"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword.stylus","@sdfsdf"] +],[ + "start", + ["entity.other.attribute-name.class.stylus",".signatures"] +],[ + "start", + ["text"," "], + ["support.type","background-color"], + ["text"," "], + ["constant.numeric","#e0e8e0"] +],[ + "start", + ["text"," "], + ["support.type","border"], + ["text"," "], + ["constant.numeric","1"], + ["keyword","px"], + ["text"," "], + ["support.constant","solid"], + ["text"," grayLighter"] +],[ + "start", + ["text"," "], + ["support.type","box-shadow"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","3"], + ["keyword","px"], + ["text"," grayLightest"] +],[ + "start", + ["text"," "], + ["support.type","border-radius"], + ["text"," "], + ["constant.numeric","3"], + ["keyword","px"] +],[ + "start", + ["text"," "], + ["support.type","padding"], + ["text"," "], + ["constant.numeric","3"], + ["keyword","px"], + ["text"," "], + ["constant.numeric","5"], + ["keyword","px"] +],[ + "start", + ["text"," "], + ["string","\"adsads\""] +],[ + "start", + ["text"," "], + ["support.type","margin-left"], + ["text"," "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["support.type","list-style"], + ["text"," "], + ["support.constant","none"] +],[ + "start", + ["entity.other.attribute-name.class.stylus",".signature"] +],[ + "start", + ["text"," "], + ["support.type","list-style"], + ["text"," "], + ["support.constant","none"] +],[ + "start", + ["text"," "], + ["support.type","display"], + ["text",": "], + ["support.constant","inline"] +],[ + "start", + ["text"," "], + ["support.type","margin-left"], + ["text"," "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["keyword.operator.stylus",">"], + ["text"," "], + ["entity.name.tag.stylus","li"] +],[ + "start", + ["text"," "], + ["support.type","display"], + ["text"," "], + ["support.constant","inline"] +],[ + "start", + ["keyword.operator.stylus","is"], + ["text"," "], + ["keyword.operator.stylus","not"] +],[ + "start", + ["entity.other.attribute-name.class.stylus",".signature-values"] +],[ + "start", + ["text"," "], + ["support.type","list-style"], + ["text"," "], + ["support.constant","none"] +],[ + "start", + ["text"," "], + ["support.type","display"], + ["text"," "], + ["support.constant","inline"] +],[ + "start", + ["text"," "], + ["support.type","margin-left"], + ["text"," "], + ["constant.numeric","0"] +],[ + "start", + ["entity.language.stylus"," &"], + ["punctuation",":"], + ["entity.other.attribute-name.pseudo-element.css","before"] +],[ + "start", + ["text"," "], + ["support.type","content"], + ["text"," "], + ["string","'→'"] +],[ + "start", + ["text"," "], + ["support.type","margin"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","5"], + ["keyword","px"] +],[ + "start", + ["text"," "], + ["keyword.operator.stylus",">"], + ["text"," "], + ["entity.name.tag.stylus","li"] +],[ + "start", + ["text"," "], + ["keyword.control.stylus","!important"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword.control.stylus","unless"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_svg.json b/public/lib/ace/mode/_test/tokens_svg.json new file mode 100644 index 0000000..01fd72e --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_svg.json @@ -0,0 +1,685 @@ +[[ + "meta.tag.punctuation.tag-open.xml1", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","svg"] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","width"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"800\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","height"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"600\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","xmlns"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"http://www.w3.org/2000/svg\""] +],[ + "start", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","onload"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"StartAnimation(evt)\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Test Tube Progress Bar"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","desc"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Created for the Web Directions SVG competition"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "js-no_regex", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"text/ecmascript\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["string.cdata.xml",""], + ["text"," "], + ["identifier","max_time"], + ["paren.rparen",")"] +],[ + "js-start", + ["text"," "], + ["keyword","return"], + ["punctuation.operator",";"] +],[ + "js-start", + ["text"," "], + ["comment","// Scale the text string gradually until it is 20 times larger"] +],[ + "js-start", + ["text"," "], + ["identifier","scalefactor"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","("], + ["identifier","timevalue"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["constant.numeric","650"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","/"], + ["text"," "], + ["identifier","max_time"], + ["punctuation.operator",";"] +],[ + "js-start" +],[ + "js-start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","timevalue"], + ["text"," "], + ["keyword.operator","<"], + ["text"," "], + ["constant.numeric","30"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "js-start", + ["text"," "], + ["identifier","hickory"], + ["punctuation.operator","."], + ["support.function.dom","setAttribute"], + ["paren.lparen","("], + ["string","\"display\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "js-start", + ["text"," "], + ["identifier","hickory"], + ["punctuation.operator","."], + ["support.function.dom","setAttribute"], + ["paren.lparen","("], + ["string","\"transform\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"translate(\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","600"], + ["keyword.operator","+"], + ["identifier","scalefactor"], + ["keyword.operator","*"], + ["constant.numeric","3"], + ["keyword.operator","*-"], + ["constant.numeric","1"], + ["text"," "], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\", -144 )\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "js-no_regex" +],[ + "js-start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","timevalue"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","30"], + ["text"," "], + ["keyword.operator","&&"], + ["text"," "], + ["identifier","timevalue"], + ["text"," "], + ["keyword.operator","<"], + ["text"," "], + ["constant.numeric","66"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "js-start", + ["text"," "], + ["identifier","dickory"], + ["punctuation.operator","."], + ["support.function.dom","setAttribute"], + ["paren.lparen","("], + ["string","\"display\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "js-start", + ["text"," "], + ["identifier","dickory"], + ["punctuation.operator","."], + ["support.function.dom","setAttribute"], + ["paren.lparen","("], + ["string","\"transform\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"translate(\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["paren.lparen","("], + ["keyword.operator","-"], + ["constant.numeric","795"], + ["keyword.operator","+"], + ["identifier","scalefactor"], + ["keyword.operator","*"], + ["constant.numeric","2"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\", 0 )\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "js-start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","timevalue"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","66"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "js-start", + ["text"," "], + ["identifier","dock"], + ["punctuation.operator","."], + ["support.function.dom","setAttribute"], + ["paren.lparen","("], + ["string","\"display\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "js-start", + ["text"," "], + ["identifier","dock"], + ["punctuation.operator","."], + ["support.function.dom","setAttribute"], + ["paren.lparen","("], + ["string","\"transform\""], + ["punctuation.operator",","], + ["text"," "], + ["string","\"translate(\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","1450"], + ["keyword.operator","+"], + ["identifier","scalefactor"], + ["keyword.operator","*"], + ["constant.numeric","2"], + ["keyword.operator","*-"], + ["constant.numeric","1"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\", 144 )\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "js-no_regex" +],[ + "js-no_regex", + ["text"," "], + ["comment","// Call ShowAndGrowElement again milliseconds later."] +],[ + "js-no_regex", + ["text"," "], + ["identifier","setTimeout"], + ["paren.lparen","("], + ["string","\"ShowAndGrowElement()\""], + ["punctuation.operator",","], + ["text"," "], + ["identifier","timer_increment"], + ["paren.rparen",")"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "js-no_regex", + ["text"," "], + ["variable.language","window"], + ["punctuation.operator","."], + ["identifier","ShowAndGrowElement"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","ShowAndGrowElement"] +],[ + "start", + ["text"," "], + ["string.cdata.xml","]]>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","rect"] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","fill"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"#2e3436\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","fill-rule"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"nonzero\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","stroke-width"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"3\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","y"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"0\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","x"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"0\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","height"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"600\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","width"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"800\""] +],[ + "start", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"rect3590\""], + ["meta.tag.punctuation.tag-close.xml","/>"] +],[ + "start" +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","text"] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","style"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","x"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"50\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","y"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"350\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"hickory\""] +],[ + "start", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","display"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"none\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," Hickory,"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","text"] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","style"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","x"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"50\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","y"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"350\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"dickory\""] +],[ + "start", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","display"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"none\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," dickory,"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","text"] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","style"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","x"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"50\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","y"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"350\""] +],[ + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"dock\""] +],[ + "start", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","display"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"none\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," dock!"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] diff --git a/public/lib/ace/mode/_test/tokens_swift.json b/public/lib/ace/mode/_test/tokens_swift.json new file mode 100644 index 0000000..8af2742 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_swift.json @@ -0,0 +1,171 @@ +[[ + "start", + ["keyword","import"], + ["text"," "], + ["identifier","UIKit"] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","DetailsViewController"], + ["punctuation.operator",":"], + ["text"," "], + ["identifier","UIViewController"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","var"], + ["text"," "], + ["identifier","album"], + ["punctuation.operator",":"], + ["text"," "], + ["identifier","Album"], + ["punctuation.operator","?"] +],[ + "start", + ["text"," "], + ["variable.parameter","@IBOutlet"], + ["text"," "], + ["keyword","weak"], + ["text"," "], + ["keyword","var"], + ["text"," "], + ["identifier","albumCover"], + ["punctuation.operator",":"], + ["text"," "], + ["identifier","UIImageView"], + ["keyword.operator","!"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","required"], + ["text"," "], + ["keyword","init"], + ["paren.lparen","("], + ["identifier","coder"], + ["text"," "], + ["identifier","aDecoder"], + ["punctuation.operator",":"], + ["text"," "], + ["identifier","NSCoder"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["constant.language","super"], + ["punctuation.operator","."], + ["keyword","init"], + ["paren.lparen","("], + ["identifier","coder"], + ["punctuation.operator",":"], + ["text"," "], + ["identifier","aDecoder"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","override"], + ["text"," "], + ["keyword","func"], + ["text"," "], + ["identifier","viewDidLoad"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["constant.language","super"], + ["punctuation.operator","."], + ["identifier","viewDidLoad"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","mLabel"], + ["punctuation.operator","."], + ["identifier","text"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["keyword","self"], + ["punctuation.operator","."], + ["identifier","album"], + ["punctuation.operator","?."], + ["identifier","title"], + ["text"," "], + ["keyword.operator","&&"], + ["text"," "], + ["string.start","\""], + ["string","Juhu "], + ["paren.quasi.start","\\("], + ["text"," "], + ["string.start","\""], + ["string","kinners"], + ["string.end","\""], + ["text"," "], + ["paren.quasi.end",")"], + ["string","! "], + ["string.end","\""] +],[ + "start", + ["text"," "], + ["identifier","albumCover"], + ["punctuation.operator","."], + ["identifier","image"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","UIImage"], + ["paren.lparen","("], + ["identifier","data"], + ["punctuation.operator",":"], + ["text"," "], + ["identifier","NSData"], + ["paren.lparen","("], + ["identifier","contentsOfURL"], + ["punctuation.operator",":"], + ["text"," "], + ["identifier","NSURL"], + ["paren.lparen","("], + ["storage.type","string"], + ["punctuation.operator",":"], + ["text"," "], + ["keyword","self"], + ["punctuation.operator","."], + ["identifier","album"], + ["keyword.operator","!"], + ["punctuation.operator","."], + ["identifier","largeImageURL"], + ["paren.rparen",")"], + ["keyword.operator","!"], + ["paren.rparen",")"], + ["keyword.operator","!"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_tcl.json b/public/lib/ace/mode/_test/tokens_tcl.json new file mode 100644 index 0000000..6a032dd --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_tcl.json @@ -0,0 +1,385 @@ +[[ + "commandItem" +],[ + "commandItem", + ["keyword","proc"], + ["text"," "], + ["identifier","dijkstra"], + ["text"," "], + ["paren.lparen","{"], + ["keyword","graph"], + ["text"," "], + ["identifier","origin"], + ["paren.rparen","}"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["comment","# Initialize"] +],[ + "commandItem", + ["text"," "], + ["keyword","dict"], + ["text"," "], + ["identifier","for"], + ["text"," "], + ["paren.lparen","{"], + ["keyword","vertex"], + ["text"," "], + ["identifier","distmap"], + ["paren.rparen","}"], + ["text"," "], + ["variable.instance","$graph"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["keyword","dict"], + ["text"," "], + ["identifier","set"], + ["text"," "], + ["identifier","dist"], + ["text"," "], + ["variable.instance","$vertex"], + ["text"," "], + ["identifier","Inf"] +],[ + "commandItem", + ["text","\t"], + ["keyword","dict"], + ["text"," "], + ["identifier","set"], + ["text"," "], + ["identifier","path"], + ["text"," "], + ["variable.instance","$vertex"], + ["text"," "], + ["paren.lparen","{"], + ["paren.rparen","}"] +],[ + "commandItem", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","dict"], + ["text"," "], + ["identifier","set"], + ["text"," "], + ["identifier","dist"], + ["text"," "], + ["variable.instance","$origin"], + ["text"," 0"] +],[ + "start", + ["text"," "], + ["keyword","dict"], + ["text"," "], + ["identifier","set"], + ["text"," "], + ["identifier","path"], + ["text"," "], + ["variable.instance","$origin"], + ["text"," "], + ["paren.lparen","["], + ["keyword","list"], + ["text"," "], + ["variable.instance","$origin"], + ["paren.rparen","]"] +],[ + "commandItem", + ["text"," "] +],[ + "commandItem", + ["text"," "], + ["keyword","while"], + ["text"," "], + ["paren.lparen","{"], + ["text","["], + ["keyword","dict"], + ["text"," "], + ["identifier","size"], + ["text"," "], + ["variable.instance","$graph"], + ["paren.rparen","]}"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["comment","# Find unhandled node with least weight"] +],[ + "start", + ["text","\t"], + ["keyword","set"], + ["text"," "], + ["identifier","d"], + ["text"," "], + ["identifier","Inf"] +],[ + "commandItem", + ["text","\t"], + ["keyword","dict"], + ["text"," "], + ["identifier","for"], + ["text"," "], + ["paren.lparen","{"], + ["keyword","uu"], + ["text"," "], + ["support.function","-"], + ["paren.rparen","}"], + ["text"," "], + ["variable.instance","$graph"], + ["text"," "], + ["paren.lparen","{"] +],[ + "commandItem", + ["text","\t "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","{"], + ["variable.instance","$d"], + ["text"," "], + ["support.function",">"], + ["text"," "], + ["paren.lparen","["], + ["keyword","set"], + ["text"," "], + ["identifier","dd"], + ["text"," "], + ["paren.lparen","["], + ["keyword","dict"], + ["text"," "], + ["identifier","get"], + ["text"," "], + ["variable.instance","$dist"], + ["text"," "], + ["variable.instance","$uu"], + ["paren.rparen","]]}"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t"], + ["keyword","set"], + ["text"," "], + ["identifier","u"], + ["text"," "], + ["variable.instance","$uu"] +],[ + "start", + ["text","\t\t"], + ["keyword","set"], + ["text"," "], + ["identifier","d"], + ["text"," "], + ["variable.instance","$dd"] +],[ + "commandItem", + ["text","\t "], + ["paren.rparen","}"] +],[ + "commandItem", + ["text","\t"], + ["paren.rparen","}"] +],[ + "commandItem", + ["text"," "] +],[ + "start", + ["text","\t"], + ["comment","# No such node; graph must be disconnected"] +],[ + "start", + ["text","\t"], + ["keyword","if"], + ["text"," "], + ["paren.lparen","{"], + ["variable.instance","$d"], + ["text"," "], + ["support.function","=="], + ["text"," "], + ["identifier","Inf"], + ["paren.rparen","}"], + ["text"," "], + ["identifier","break"] +],[ + "commandItem", + ["text"," "] +],[ + "commentfollow", + ["text","\t"], + ["comment","# Update the weights for nodes\\"] +],[ + "start", + ["comment","\t lead to by the node we've picked"] +],[ + "commandItem", + ["text","\t"], + ["keyword","dict"], + ["text"," "], + ["identifier","for"], + ["text"," "], + ["paren.lparen","{"], + ["keyword","v"], + ["text"," "], + ["identifier","dd"], + ["paren.rparen","}"], + ["text"," "], + ["paren.lparen","["], + ["keyword","dict"], + ["text"," "], + ["identifier","get"], + ["text"," "], + ["variable.instance","$graph"], + ["text"," "], + ["variable.instance","$u"], + ["paren.rparen","]"], + ["text"," "], + ["paren.lparen","{"] +],[ + "commandItem", + ["text","\t "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","{"], + ["text","["], + ["keyword","dict"], + ["text"," "], + ["identifier","exists"], + ["text"," "], + ["variable.instance","$graph"], + ["text"," "], + ["variable.instance","$v"], + ["paren.rparen","]}"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t"], + ["keyword","set"], + ["text"," "], + ["identifier","alt"], + ["text"," "], + ["paren.lparen","["], + ["keyword","expr"], + ["text"," "], + ["paren.lparen","{"], + ["variable.instance","$d"], + ["text"," "], + ["support.function","+"], + ["text"," "], + ["variable.instance","$dd"], + ["paren.rparen","}]"] +],[ + "commandItem", + ["text","\t\t"], + ["keyword","if"], + ["text"," "], + ["paren.lparen","{"], + ["variable.instance","$alt"], + ["text"," "], + ["support.function","<"], + ["text"," "], + ["paren.lparen","["], + ["keyword","dict"], + ["text"," "], + ["identifier","get"], + ["text"," "], + ["variable.instance","$dist"], + ["text"," "], + ["variable.instance","$v"], + ["paren.rparen","]}"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t "], + ["keyword","dict"], + ["text"," "], + ["identifier","set"], + ["text"," "], + ["identifier","dist"], + ["text"," "], + ["variable.instance","$v"], + ["text"," "], + ["variable.instance","$alt"] +],[ + "start", + ["text","\t\t "], + ["keyword","dict"], + ["text"," "], + ["identifier","set"], + ["text"," "], + ["identifier","path"], + ["text"," "], + ["variable.instance","$v"], + ["text"," "], + ["paren.lparen","["], + ["keyword","list"], + ["text"," "], + ["support.function","{*}"], + ["paren.lparen","["], + ["keyword","dict"], + ["text"," "], + ["identifier","get"], + ["text"," "], + ["variable.instance","$path"], + ["text"," "], + ["variable.instance","$u"], + ["paren.rparen","]"], + ["text"," "], + ["variable.instance","$v"], + ["paren.rparen","]"] +],[ + "commandItem", + ["text","\t\t"], + ["paren.rparen","}"] +],[ + "commandItem", + ["text","\t "], + ["paren.rparen","}"] +],[ + "commandItem", + ["text","\t"], + ["paren.rparen","}"] +],[ + "commandItem", + ["text"," "] +],[ + "start", + ["text","\t"], + ["comment","# Remove chosen node from graph still to be handled"] +],[ + "start", + ["text","\t"], + ["keyword","dict"], + ["text"," "], + ["identifier","unset"], + ["text"," "], + ["identifier","graph"], + ["text"," "], + ["variable.instance","$u"] +],[ + "commandItem", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","return"], + ["text"," "], + ["paren.lparen","["], + ["keyword","list"], + ["text"," "], + ["variable.instance","$dist"], + ["text"," "], + ["variable.instance","$path"], + ["paren.rparen","]"] +],[ + "commandItem", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_tex.json b/public/lib/ace/mode/_test/tokens_tex.json new file mode 100644 index 0000000..a7bdc17 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_tex.json @@ -0,0 +1,129 @@ +[[ + "start", + ["text","The quadratic formula is $$-b "], + ["keyword","\\pm"], + ["text"," "], + ["keyword","\\sqrt"], + ["paren.keyword.operator","{"], + ["text","b^2 - 4ac"], + ["paren.keyword.operator","}"], + ["text"," "], + ["keyword","\\over"], + ["text"," 2a$$"] +],[ + "start", + ["keyword","\\bye"] +],[ + "start" +],[ + "start", + ["keyword","\\makeatletter"] +],[ + "start", + ["text"," "], + ["keyword","\\newcommand"], + ["paren.keyword.operator","{"], + ["keyword","\\be"], + ["paren.keyword.operator","}{"], + ["comment","%"] +],[ + "start", + ["text"," "], + ["keyword","\\begingroup"] +],[ + "start", + ["text"," "], + ["comment","% \\setlength{\\arraycolsep}{2pt}"] +],[ + "start", + ["text"," "], + ["keyword","\\eqnarray"], + ["comment","%"] +],[ + "start", + ["text"," "], + ["keyword","\\@"], + ["text","ifstar"], + ["paren.keyword.operator","{"], + ["keyword","\\nonumber"], + ["paren.keyword.operator","}{}"], + ["comment","%"] +],[ + "start", + ["text"," "], + ["paren.keyword.operator","}"] +],[ + "start", + ["text"," "], + ["keyword","\\newcommand"], + ["paren.keyword.operator","{"], + ["keyword","\\ee"], + ["paren.keyword.operator","}{"], + ["keyword","\\endeqnarray\\endgroup"], + ["paren.keyword.operator","}"] +],[ + "start", + ["text"," "], + ["keyword","\\makeatother"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","\\begin"], + ["paren.keyword.operator","{"], + ["nospell.text","equation"], + ["paren.keyword.operator","}"] +],[ + "start", + ["text"," x="], + ["keyword","\\left"], + ["text", "\\{ "], + ["keyword","\\begin"], + ["paren.keyword.operator","{"], + ["nospell.text","array"], + ["paren.keyword.operator","}{"], + ["text","cl"], + ["paren.keyword.operator","}"] +],[ + "start", + ["text"," 0 & "], + ["keyword","\\textrm"], + ["paren.keyword.operator","{"], + ["text","if "], + ["paren.keyword.operator","}"], + ["text","A="], + ["keyword","\\ldots\\\\"] +],[ + "start", + ["text"," 1 & "], + ["keyword","\\textrm"], + ["paren.keyword.operator","{"], + ["text","if "], + ["paren.keyword.operator","}"], + ["text","B="], + ["keyword","\\ldots\\\\"] +],[ + "start", + ["text"," x & "], + ["keyword","\\textrm"], + ["paren.keyword.operator","{"], + ["text","this runs with as much text as you like, but without an raggeright text"] +],[ + "start", + ["text","."], + ["paren.keyword.operator","}"], + ["keyword","\\end"], + ["paren.keyword.operator","{"], + ["nospell.text","array"], + ["paren.keyword.operator","}"], + ["keyword","\\right"], + ["text","."] +],[ + "start", + ["text"," "], + ["keyword","\\end"], + ["paren.keyword.operator","{"], + ["nospell.text","equation"], + ["paren.keyword.operator","}"] +]] diff --git a/public/lib/ace/mode/_test/tokens_text.json b/public/lib/ace/mode/_test/tokens_text.json new file mode 100644 index 0000000..fff7ef4 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_text.json @@ -0,0 +1,29 @@ +[[ + "start", + ["text","Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."] +],[ + "start" +],[ + "start", + ["text","Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."] +],[ + "start" +],[ + "start", + ["text","Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."] +],[ + "start" +],[ + "start", + ["text","Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat."] +],[ + "start" +],[ + "start", + ["text","Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis."] +],[ + "start" +],[ + "start", + ["text","At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_textile.json b/public/lib/ace/mode/_test/tokens_textile.json new file mode 100644 index 0000000..59000ce --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_textile.json @@ -0,0 +1,113 @@ +[[ + "start", + ["markup.heading.1","h1"], + ["keyword",". "], + ["text","Textile document"] +],[ + "start" +],[ + "start", + ["markup.heading.2","h2"], + ["keyword",". "], + ["text","Heading Two"] +],[ + "start" +],[ + "start", + ["markup.heading.3","h3"], + ["keyword",". "], + ["text","A two-line"] +],[ + "start", + ["text"," header"] +],[ + "start" +],[ + "start", + ["markup.heading.2","h2"], + ["keyword",". "], + ["text","Another two-line"] +],[ + "start", + ["text","header"] +],[ + "start" +],[ + "start", + ["text","Paragraph:"] +],[ + "start", + ["text","one, two,"] +],[ + "start", + ["text","thee lines!"] +],[ + "start" +],[ + "start", + ["markup.heading","p"], + ["keyword","("], + ["string","classone"], + ["text"," "], + ["string","two"], + ["text"," "], + ["string","three"], + ["keyword","). "], + ["text","This is a paragraph with classes"] +],[ + "start" +],[ + "start", + ["markup.heading","p"], + ["keyword","(#"], + ["string","id"], + ["keyword","). "], + ["text","(one with an id)"] +],[ + "start" +],[ + "start", + ["markup.heading","p"], + ["keyword","("], + ["string","one"], + ["text"," "], + ["string","two"], + ["text"," "], + ["string","three"], + ["keyword","#"], + ["string","my_id"], + ["keyword","). "], + ["text","..classes + id"] +],[ + "start" +],[ + "start", + ["keyword","*"], + ["text"," Unordered list"] +],[ + "start", + ["keyword","**"], + ["text"," sublist"] +],[ + "start", + ["keyword","*"], + ["text"," back again!"] +],[ + "start", + ["keyword","**"], + ["text"," sublist again.."] +],[ + "start" +],[ + "start", + ["keyword","#"], + ["text"," ordered"] +],[ + "start" +],[ + "start", + ["text","bg. Blockquote!"] +],[ + "start", + ["text"," This is a two-list blockquote..!"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_toml.json b/public/lib/ace/mode/_test/tokens_toml.json new file mode 100644 index 0000000..ec471f7 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_toml.json @@ -0,0 +1,131 @@ +[[ + "start", + ["comment.toml","# This is a TOML document. Boom."] +],[ + "start" +],[ + "start", + ["identifier","title"], + ["text"," = "], + ["string","\"TOML Example\""] +],[ + "start" +],[ + "start", + ["variable.keygroup.toml","[owner]"] +],[ + "start", + ["identifier","name"], + ["text"," = "], + ["string","\"Tom Preston-Werner\""] +],[ + "start", + ["identifier","organization"], + ["text"," = "], + ["string","\"GitHub\""] +],[ + "start", + ["identifier","bio"], + ["text"," = "], + ["string","\"GitHub Cofounder & CEO"], + ["constant.language.escape","\\n"], + ["string","Likes tater tots and beer.\""] +],[ + "start", + ["identifier","dob"], + ["text"," = "], + ["support.date.toml","1979-05-27T07:32:00Z"], + ["text"," "], + ["comment.toml","# First class dates? Why not?"] +],[ + "start" +],[ + "start", + ["variable.keygroup.toml","[database]"] +],[ + "start", + ["identifier","server"], + ["text"," = "], + ["string","\"192.168.1.1\""] +],[ + "start", + ["identifier","ports"], + ["text"," = [ "], + ["constant.numeric.toml","8001"], + ["text",", "], + ["constant.numeric.toml","8001"], + ["text",", "], + ["constant.numeric.toml","8002"], + ["text"," ]"] +],[ + "start", + ["identifier","connection_max"], + ["text"," = "], + ["constant.numeric.toml","5000"] +],[ + "start", + ["identifier","enabled"], + ["text"," = "], + ["constant.language.boolean","true"] +],[ + "start" +],[ + "start", + ["variable.keygroup.toml","[servers]"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment.toml","# You can indent as you please. Tabs or spaces. TOML don't care."] +],[ + "start", + ["variable.keygroup.toml"," [servers.alpha]"] +],[ + "start", + ["text"," "], + ["identifier","ip"], + ["text"," = "], + ["string","\"10.0.0.1\""] +],[ + "start", + ["text"," "], + ["identifier","dc"], + ["text"," = "], + ["string","\"eqdc10\""] +],[ + "start" +],[ + "start", + ["variable.keygroup.toml"," [servers.beta]"] +],[ + "start", + ["text"," "], + ["identifier","ip"], + ["text"," = "], + ["string","\"10.0.0.2\""] +],[ + "start", + ["text"," "], + ["identifier","dc"], + ["text"," = "], + ["string","\"eqdc10\""] +],[ + "start" +],[ + "start", + ["variable.keygroup.toml","[clients]"] +],[ + "start", + ["identifier","data"], + ["text"," = [ ["], + ["string","\"gamma\""], + ["text",", "], + ["string","\"delta\""], + ["text","], ["], + ["constant.numeric.toml","1"], + ["text",", "], + ["constant.numeric.toml","2"], + ["text","] ] "], + ["comment.toml","# just an update to make sure parsers support it"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_tsx.json b/public/lib/ace/mode/_test/tokens_tsx.json new file mode 100644 index 0000000..62c7f6e --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_tsx.json @@ -0,0 +1,30 @@ +[[ + ["jsx",1], + ["storage.type","var"], + ["text"," "], + ["identifier","mode"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["string"," "] +],[ + ["jsx",1], + ["string"," Typescript + "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","b"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["string"," JSX "], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["string"," "] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["punctuation.operator",";"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_twig.json b/public/lib/ace/mode/_test/tokens_twig.json new file mode 100644 index 0000000..ada8b4a --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_twig.json @@ -0,0 +1,288 @@ +[[ + "start", + ["xml-pe.doctype.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","My Webpage"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","ul"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"navigation\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","for"], + ["text"," "], + ["identifier","item"], + ["text"," "], + ["keyword.operator.twig","in"], + ["text"," "], + ["identifier","navigation"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","li"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","item"], + ["punctuation.operator","."], + ["identifier","href"], + ["keyword.operator.other","|"], + ["support.function.twig","escape"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","item"], + ["punctuation.operator","."], + ["identifier","caption"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","endfor"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","if"], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["keyword.operator.twig","not"], + ["text"," "], + ["keyword.operator.twig","in"], + ["text"," "], + ["paren.lparen","["], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","2"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","3"], + ["paren.rparen","]"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["comment.block.twig","{# is equivalent to #}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","if"], + ["text"," "], + ["keyword.operator.twig","not"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","1"], + ["text"," "], + ["keyword.operator.twig","in"], + ["text"," "], + ["paren.lparen","["], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","2"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","3"], + ["paren.rparen","])"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","autoescape"], + ["text"," "], + ["constant.language.boolean","true"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","var"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"] +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","var"], + ["keyword.operator.other","|"], + ["support.function.twig","raw"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"], + ["text.xml"," "], + ["comment.block.twig","{# var won't be escaped #}"] +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","var"], + ["keyword.operator.other","|"], + ["support.function.twig","escape"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"], + ["text.xml"," "], + ["comment.block.twig","{# var won't be doubled-escaped #}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","endautoescape"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["keyword.control.twig","include"], + ["paren.lparen","("], + ["string","'twig.html'"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","sandboxed"], + ["text"," "], + ["keyword.operator.assignment","="], + ["text"," "], + ["constant.language.boolean","true"], + ["paren.rparen",")"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["string","\"string "], + ["constant.language.escape","#{with}"], + ["string"," "], + ["constant.language.escape","\\\""], + ["string"," escapes\""], + ["text"," "], + ["string","'another#one'"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h1"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","My Webpage"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","a_variable"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_typescript.json b/public/lib/ace/mode/_test/tokens_typescript.json new file mode 100644 index 0000000..1a36879 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_typescript.json @@ -0,0 +1,563 @@ +[[ + "start", + ["keyword.operator.ts","class"], + ["text"," "], + ["identifier","Greeter"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["variable.parameter.function.ts","greeting"], + ["text",": "], + ["variable.parameter.function.ts","string"], + ["punctuation.operator",";"] +],[ + "start", + ["text","\t"], + ["keyword.operator.ts","constructor"], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter.function.ts","message"], + ["text",": "], + ["variable.parameter.function.ts","string"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t"], + ["storage.type.variable.ts","this."], + ["identifier","greeting"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","message"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text","\t"], + ["paren.rparen","}"] +],[ + "start", + ["text","\t"], + ["identifier","greet"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t"], + ["keyword","return"], + ["text"," "], + ["string","\"Hello, \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","greeting"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text","\t"], + ["paren.rparen","}"] +],[ + "no_regex", + ["paren.rparen","}"], + ["text"," "] +],[ + "no_regex" +],[ + "start", + ["storage.type","var"], + ["text"," "], + ["identifier","greeter"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["keyword","new"], + ["text"," "], + ["identifier","Greeter"], + ["paren.lparen","("], + ["string","\"world\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "no_regex", + ["storage.type","var"], + ["text"," "], + ["identifier","button"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["variable.language","document"], + ["punctuation.operator","."], + ["support.function.dom","createElement"], + ["paren.lparen","("], + ["string","'button'"], + ["paren.rparen",")"] +],[ + "start", + ["identifier","button"], + ["punctuation.operator","."], + ["identifier","innerText"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["keyword.operator","<"], + ["storage.type.variable.ts","string"], + ["keyword.operator",">"], + ["string","\"Say Hello\""], + ["punctuation.operator",";"] +],[ + "start", + ["storage.type","button"], + ["punctuation.operator","."], + ["entity.name.function","onclick"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["storage.type","function"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "no_regex", + ["text","\t"], + ["support.function","alert"], + ["paren.lparen","("], + ["entity.name.function.ts","greeter.greet"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["paren.rparen",")"] +],[ + "no_regex", + ["paren.rparen","}"] +],[ + "no_regex" +],[ + "no_regex", + ["variable.language","document"], + ["punctuation.operator","."], + ["identifier","body"], + ["punctuation.operator","."], + ["support.function.dom","appendChild"], + ["paren.lparen","("], + ["identifier","button"], + ["paren.rparen",")"] +],[ + "no_regex" +],[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","Snake"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["identifier","Animal"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["entity.name.function.ts","move"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.function","alert"], + ["paren.lparen","("], + ["string","\"Slithering...\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["storage.type.variable.ts","super"], + ["text","("], + ["keyword.other.ts","5"], + ["text",")"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "no_regex", + ["paren.rparen","}"] +],[ + "no_regex" +],[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","Horse"], + ["text"," "], + ["keyword","extends"], + ["text"," "], + ["identifier","Animal"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["entity.name.function.ts","move"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["support.function","alert"], + ["paren.lparen","("], + ["string","\"Galloping...\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.operator.ts","super"], + ["punctuation.operator","."], + ["identifier","move"], + ["paren.lparen","("], + ["constant.numeric","45"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "no_regex", + ["paren.rparen","}"] +],[ + "no_regex" +],[ + "start", + ["identifier","module"], + ["text"," "], + ["identifier","Sayings"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.operator.ts","export"], + ["text"," "], + ["keyword.operator.ts","class"], + ["text"," "], + ["identifier","Greeter"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable.parameter.function.ts","greeting"], + ["text",": "], + ["variable.parameter.function.ts","string"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.operator.ts","constructor"], + ["text"," "], + ["paren.lparen","("], + ["variable.parameter.function.ts","message"], + ["text",": "], + ["variable.parameter.function.ts","string"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","greeting"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","message"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["identifier","greet"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","return"], + ["text"," "], + ["string","\"Hello, \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","greeting"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "no_regex", + ["paren.rparen","}"] +],[ + "start", + ["identifier","module"], + ["text"," "], + ["identifier","Mankala"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.operator.ts","export"], + ["text"," "], + ["keyword.operator.ts","class"], + ["text"," "], + ["identifier","Features"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.operator.ts","public"], + ["text"," "], + ["identifier","turnContinues"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.language.boolean","false"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.operator.ts","public"], + ["text"," "], + ["identifier","seedStoredCount"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.operator.ts","public"], + ["text"," "], + ["identifier","capturedCount"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.operator.ts","public"], + ["text"," "], + ["identifier","spaceCaptured"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","NoSpace"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword.operator.ts","public"], + ["text"," "], + ["entity.name.function.ts","clear"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","turnContinues"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.language.boolean","false"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","seedStoredCount"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","capturedCount"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","spaceCaptured"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","NoSpace"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "no_regex" +],[ + "start", + ["text"," "], + ["keyword","public"], + ["text"," "], + ["identifier","toString"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","stringBuilder"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","\"\""], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["storage.type.variable.ts","this."], + ["identifier","turnContinues"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","stringBuilder"], + ["text"," "], + ["keyword.operator","+="], + ["text"," "], + ["string","\" turn continues,\""], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["identifier","stringBuilder"], + ["text"," "], + ["keyword.operator","+="], + ["text"," "], + ["string","\" stores \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","seedStoredCount"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["storage.type.variable.ts","this."], + ["identifier","capturedCount"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["identifier","stringBuilder"], + ["text"," "], + ["keyword.operator","+="], + ["text"," "], + ["string","\" captures \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","capturedCount"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\" from space \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["storage.type.variable.ts","this."], + ["identifier","spaceCaptured"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","return"], + ["text"," "], + ["identifier","stringBuilder"], + ["punctuation.operator",";"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "no_regex", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_vala.json b/public/lib/ace/mode/_test/tokens_vala.json new file mode 100644 index 0000000..efe6e7c --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_vala.json @@ -0,0 +1,158 @@ +[[ + "start", + ["meta.using.vala",""], + ["keyword.other.using.vala","using"], + ["meta.using.vala"," "], + ["storage.modifier.using.vala","Gtk"], + ["punctuation.terminator.vala",";"] +],[ + "start", + ["text"," "] +],[ + "text0", + ["storage.type.primitive.array.vala","int"], + ["text"," main ("], + ["storage.type.primitive.array.vala","string"], + ["text","[] args) {"] +],[ + "text0", + ["text"," "], + ["storage.type.vala","Gtk"], + ["keyword.operator.dereference.vala","."], + ["text","init ("], + ["storage.modifier.vala","ref"], + ["text"," args)"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "], + ["storage.type.primitive.vala","var"], + ["text"," foo "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["keyword.control.new.vala","new"], + ["text"," "], + ["storage.type.generic.vala","MyFoo>"], + ["text","()"], + ["punctuation.terminator.vala",";"] +],[ + "text0" +],[ + "text0", + ["text"," "], + ["storage.type.primitive.vala","var"], + ["text"," window "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["keyword.control.new.vala","new"], + ["text"," "], + ["storage.type.vala","Window"], + ["text","()"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","title "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["punctuation.definition.string.begin.vala","\""], + ["string.quoted.double.vala","Hello, World!"], + ["punctuation.definition.string.end.vala","\""], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","border_width "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["constant.numeric.vala","10"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","window_position "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["storage.type.vala","WindowPosition"], + ["keyword.operator.dereference.vala","."], + ["constant.other.vala","CENTER"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","set_default_size("], + ["constant.numeric.vala","350"], + ["text",", "], + ["constant.numeric.vala","70"], + ["text",")"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","destroy"], + ["keyword.operator.dereference.vala","."], + ["text","connect("], + ["storage.type.vala","Gtk"], + ["keyword.operator.dereference.vala","."], + ["text","main_quit)"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "] +],[ + "text0", + ["text"," "], + ["storage.type.primitive.vala","var"], + ["text"," label "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["keyword.control.new.vala","new"], + ["text"," "], + ["storage.type.vala","Label"], + ["text","("], + ["punctuation.definition.string.begin.vala","\""], + ["string.quoted.double.vala","Hello, World!"], + ["punctuation.definition.string.end.vala","\""], + ["text",")"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","add(label)"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","show_all()"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "] +],[ + "text0", + ["text"," "], + ["storage.type.vala","Gtk"], + ["keyword.operator.dereference.vala","."], + ["text","main()"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "], + ["keyword.control.vala","return"], + ["text"," "], + ["constant.numeric.vala","0"], + ["punctuation.terminator.vala",";"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_vbscript.json b/public/lib/ace/mode/_test/tokens_vbscript.json new file mode 100644 index 0000000..b06c245 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_vbscript.json @@ -0,0 +1,255 @@ +[[ + "start", + ["identifier","myfilename"], + ["text"," "], + ["keyword.operator.asp","="], + ["text"," "], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp","C:\\Wikipedia - VBScript - Example - Hello World.txt\""] +],[ + "start", + ["identifier","MakeHelloWorldFile"], + ["text"," "], + ["identifier","myfilename"] +],[ + "state_4", + ["meta.leading-space"," "] +],[ + "start", + ["storage.type.function.asp","Sub"], + ["text"," "], + ["entity.name.function.asp","MakeHelloWorldFile"], + ["text"," "], + ["punctuation.definition.parameters.asp","("], + ["variable.parameter.function.asp","FileName"], + ["punctuation.definition.parameters.asp",")"] +],[ + "start", + ["punctuation.definition.comment.asp","'"], + ["comment.line.apostrophe.asp","Create a new file in C: drive or overwrite existing file"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["storage.type.asp","Set"], + ["text"," "], + ["identifier","FSO"], + ["text"," "], + ["keyword.operator.asp","="], + ["text"," "], + ["support.function.vb.asp","CreateObject"], + ["text","("], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp","Scripting.FileSystemObject\""], + ["text",")"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["keyword.control.asp","If"], + ["text"," "], + ["identifier","FSO"], + ["text","."], + ["identifier","FileExists"], + ["text","("], + ["identifier","FileName"], + ["text",") "], + ["keyword.control.asp","Then"], + ["text"," "] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.even-tab.spaces"," "], + ["meta.odd-tab.spaces"," "], + ["identifier","Answer"], + ["text"," "], + ["keyword.operator.asp","="], + ["text"," "], + ["support.function.vb.asp","MsgBox"], + ["text"," ("], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp","File \""], + ["text"," "], + ["keyword.operator.asp","&"], + ["text"," "], + ["identifier","FileName"], + ["text"," "], + ["keyword.operator.asp","&"], + ["text"," "], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp"," exists ... OK to overwrite?\""], + ["text",", "], + ["identifier","vbOKCancel"], + ["text",")"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.even-tab.spaces"," "], + ["meta.odd-tab.spaces"," "], + ["punctuation.definition.comment.asp","'"], + ["comment.line.apostrophe.asp","If button selected is not OK, then quit now"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.even-tab.spaces"," "], + ["meta.odd-tab.spaces"," "], + ["punctuation.definition.comment.asp","'"], + ["comment.line.apostrophe.asp","vbOK is a language constant"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.even-tab.spaces"," "], + ["meta.odd-tab.spaces"," "], + ["keyword.control.asp","If"], + ["text"," "], + ["identifier","Answer"], + ["text"," "], + ["keyword.operator.asp","<>"], + ["text"," "], + ["identifier","vbOK"], + ["text"," "], + ["keyword.control.asp","Then"], + ["text"," "], + ["keyword.control.asp","Exit"], + ["text"," "], + ["keyword.control.asp","Sub"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["keyword.control.asp","Else"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.even-tab.spaces"," "], + ["meta.odd-tab.spaces"," "], + ["punctuation.definition.comment.asp","'"], + ["comment.line.apostrophe.asp","Confirm OK to create"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.even-tab.spaces"," "], + ["meta.odd-tab.spaces"," "], + ["identifier","Answer"], + ["text"," "], + ["keyword.operator.asp","="], + ["text"," "], + ["support.function.vb.asp","MsgBox"], + ["text"," ("], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp","File \""], + ["text"," "], + ["keyword.operator.asp","&"], + ["text"," "], + ["identifier","FileName"], + ["text"," "], + ["keyword.operator.asp","&"], + ["text"," "], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp"," ... OK to create?\""], + ["text",", "], + ["identifier","vbOKCancel"], + ["text",")"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.even-tab.spaces"," "], + ["meta.odd-tab.spaces"," "], + ["keyword.control.asp","If"], + ["text"," "], + ["identifier","Answer"], + ["text"," "], + ["keyword.operator.asp","<>"], + ["text"," "], + ["identifier","vbOK"], + ["text"," "], + ["keyword.control.asp","Then"], + ["text"," "], + ["keyword.control.asp","Exit"], + ["text"," "], + ["keyword.control.asp","Sub"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["keyword.control.asp","End"], + ["text"," "], + ["keyword.control.asp","If"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["punctuation.definition.comment.asp","'"], + ["comment.line.apostrophe.asp","Create new file (or replace an existing file)"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["storage.type.asp","Set"], + ["text"," "], + ["identifier","FileObject"], + ["text"," "], + ["keyword.operator.asp","="], + ["text"," "], + ["identifier","FSO"], + ["text","."], + ["identifier","CreateTextFile"], + ["text"," ("], + ["identifier","FileName"], + ["text",")"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["identifier","FileObject"], + ["text","."], + ["identifier","WriteLine"], + ["text"," "], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp","Time ... \""], + ["text"," "], + ["keyword.operator.asp","&"], + ["text"," "], + ["support.function.vb.asp","Now"], + ["text","()"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["identifier","FileObject"], + ["text","."], + ["identifier","WriteLine"], + ["text"," "], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp","Hello World\""] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["identifier","FileObject"], + ["text","."], + ["identifier","Close"], + ["text","()"] +],[ + "start", + ["meta.odd-tab.spaces"," "], + ["meta.leading-space"," "], + ["support.function.vb.asp","MsgBox"], + ["text"," "], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp","File \""], + ["text"," "], + ["keyword.operator.asp","&"], + ["text"," "], + ["identifier","FileName"], + ["text"," "], + ["keyword.operator.asp","&"], + ["text"," "], + ["punctuation.definition.string.begin.asp","\""], + ["string.quoted.double.asp"," ... updated.\""] +],[ + "start", + ["keyword.control.asp","End"], + ["text"," "], + ["keyword.control.asp","Sub"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_velocity.json b/public/lib/ace/mode/_test/tokens_velocity.json new file mode 100644 index 0000000..7b2037f --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_velocity.json @@ -0,0 +1,287 @@ +[[ + "vm_comment", + ["comment.block","#*"] +],[ + "vm_comment", + ["comment"," This is a sample comment block that"] +],[ + "vm_comment", + ["comment"," spans multiple lines."] +],[ + "start", + ["comment","*#"] +],[ + "start" +],[ + "start", + ["keyword","#macro"], + ["text"," "], + ["lparen","("], + ["text"," "], + ["identifier","outputItem"], + ["text"," "], + ["variable","$item"], + ["text"," "], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","li"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["variable","${"], + ["identifier","item"], + ["variable","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["keyword","#end"] +],[ + "start" +],[ + "start", + ["comment","## Define the items to iterate"] +],[ + "start", + ["keyword","#set"], + ["text"," "], + ["lparen","("], + ["text"," "], + ["variable","$items"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["lparen","["], + ["constant.numeric","1"], + ["text.xml",","], + ["text"," "], + ["constant.numeric","2"], + ["text.xml",","], + ["text"," "], + ["constant.numeric","3"], + ["text.xml",","], + ["text"," "], + ["constant.numeric","4"], + ["rparen","]"], + ["text"," "], + ["rparen",")"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","ul"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text"," "], + ["comment","## Iterate over the items and output the evens."] +],[ + "start", + ["text"," "], + ["keyword","#foreach"], + ["text"," "], + ["lparen","("], + ["text"," "], + ["variable","$item"], + ["text"," "], + ["identifier","in"], + ["text"," "], + ["variable","$items"], + ["text"," "], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","#if"], + ["text"," "], + ["lparen","("], + ["text"," "], + ["support.function","$_MathTool"], + ["text.xml","."], + ["identifier","mod"], + ["lparen","("], + ["variable","$item"], + ["text.xml",","], + ["text"," "], + ["constant.numeric","2"], + ["rparen",")"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","#outputItem"], + ["text"," "], + ["lparen","("], + ["variable","$item"], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","#end"] +],[ + "start", + ["text"," "], + ["keyword","#end"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "js-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "js-comment1", + ["text"," "], + ["comment","/*"] +],[ + "js-comment1", + ["comment"," A sample function to decomstrate"] +],[ + "js-comment1", + ["comment"," JavaScript highlighting and folding."] +],[ + "js-start", + ["comment"," */"] +],[ + "js-start", + ["text"," "], + ["storage.type","function"], + ["text"," "], + ["entity.name.function","foo"], + ["paren.lparen","("], + ["variable.parameter","items"], + ["punctuation.operator",", "], + ["variable.parameter","nada"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "js-start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["paren.lparen","("], + ["storage.type","var"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","="], + ["constant.numeric","0"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","<"], + ["identifier","items"], + ["punctuation.operator","."], + ["support.constant","length"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","++"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "js-start", + ["text"," "], + ["support.function","alert"], + ["paren.lparen","("], + ["identifier","items"], + ["paren.lparen","["], + ["identifier","i"], + ["paren.rparen","]"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"juhu"], + ["constant.language.escape","\\n"], + ["string","\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "css-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.style.tag-name.xml","style"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + ["css-comment","css-start"], + ["text"," "], + ["comment","/*"] +],[ + ["css-comment","css-start"], + ["comment"," A sample style to decomstrate"] +],[ + ["css-comment","css-start"], + ["comment"," CSS highlighting and folding."] +],[ + "css-start", + ["comment"," */"] +],[ + "css-ruleset", + ["text"," "], + ["variable",".class"], + ["text"," "], + ["paren.lparen","{"] +],[ + "css-ruleset", + ["text"," "], + ["support.type","font-family"], + ["text",": Monaco, "], + ["string.start","\""], + ["string","Courier New"], + ["string.end","\""], + ["text",", "], + ["support.constant.fonts","monospace"], + ["text",";"] +],[ + "css-ruleset", + ["text"," "], + ["support.type","font-size"], + ["text",": "], + ["constant.numeric","12"], + ["keyword","px"], + ["text",";"] +],[ + "css-ruleset", + ["text"," "], + ["support.type","cursor"], + ["text",": "], + ["support.constant","text"], + ["text",";"] +],[ + "css-start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_verilog.json b/public/lib/ace/mode/_test/tokens_verilog.json new file mode 100644 index 0000000..9680a96 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_verilog.json @@ -0,0 +1,113 @@ +[[ + "start", + ["keyword","always"], + ["text"," @"], + ["paren.lparen","("], + ["keyword","negedge"], + ["text"," "], + ["identifier","reset"], + ["text"," "], + ["keyword","or"], + ["text"," "], + ["keyword","posedge"], + ["text"," "], + ["identifier","clk"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","reset"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["identifier","d_out"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["constant.numeric","16"], + ["text","'"], + ["identifier","h0000"], + ["text",";"] +],[ + "start", + ["text"," "], + ["identifier","d_out_mem"], + ["text","["], + ["identifier","resetcount"], + ["text","] "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","d_out"], + ["text",";"] +],[ + "start", + ["text"," "], + ["identifier","laststoredvalue"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","d_out"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["identifier","d_out"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","d_out"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["text","'"], + ["identifier","b1"], + ["text","; "] +],[ + "start", + ["text"," "], + ["keyword","end"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","always"], + ["text"," @"], + ["paren.lparen","("], + ["identifier","bufreadaddr"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","bufreadval"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","d_out_mem"], + ["text","["], + ["identifier","bufreadaddr"], + ["text","];"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_vhdl.json b/public/lib/ace/mode/_test/tokens_vhdl.json new file mode 100644 index 0000000..88c6e22 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_vhdl.json @@ -0,0 +1,271 @@ +[[ + "start", + ["keyword","library"], + ["text"," "], + ["identifier","IEEE"] +],[ + "start", + ["identifier","user"], + ["text"," "], + ["identifier","IEEE"], + ["punctuation.operator","."], + ["identifier","std_logic_1164"], + ["punctuation.operator","."], + ["keyword","all"], + ["punctuation.operator",";"] +],[ + "start", + ["keyword","use"], + ["text"," "], + ["identifier","IEEE"], + ["punctuation.operator","."], + ["identifier","numeric_std"], + ["punctuation.operator","."], + ["keyword","all"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","entity"], + ["text"," "], + ["identifier","COUNT16"], + ["text"," "], + ["keyword","is"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","port"], + ["text"," "], + ["paren.lparen","("] +],[ + "start", + ["text"," "], + ["identifier","cOut"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","out"], + ["text"," "], + ["storage.type","std_logic_vector"], + ["paren.lparen","("], + ["constant.numeric","15"], + ["text"," "], + ["keyword","downto"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","-- counter output"] +],[ + "start", + ["text"," "], + ["identifier","clkEn"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","in"], + ["text"," "], + ["storage.type","std_logic"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","-- count enable"] +],[ + "start", + ["text"," "], + ["identifier","clk"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","in"], + ["text"," "], + ["storage.type","std_logic"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","-- clock input"] +],[ + "start", + ["text"," "], + ["identifier","rst"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","in"], + ["text"," "], + ["storage.type","std_logic"], + ["text"," "], + ["comment","-- reset input"] +],[ + "start", + ["text"," "], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword","end"], + ["text"," "], + ["keyword","entity"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","architecture"], + ["text"," "], + ["identifier","count_rtl"], + ["text"," "], + ["keyword","of"], + ["text"," "], + ["identifier","COUNT16"], + ["text"," "], + ["keyword","is"] +],[ + "start", + ["text"," "], + ["storage.type","signal"], + ["text"," "], + ["identifier","count"], + ["text"," "], + ["punctuation.operator",":"], + ["storage.type","std_logic_vector"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","15"], + ["text"," "], + ["keyword","downto"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["keyword","process"], + ["text"," "], + ["paren.lparen","("], + ["identifier","clk"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","rst"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["paren.lparen","("], + ["identifier","rst"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'1'"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["identifier","count"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["paren.lparen","("], + ["keyword","others"], + ["keyword.operator","=>"], + ["string","'0'"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","elsif"], + ["paren.lparen","("], + ["identifier","rising_edge"], + ["paren.lparen","("], + ["identifier","clk"], + ["paren.rparen","))"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["paren.lparen","("], + ["identifier","clkEn"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'1'"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["identifier","count"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","count"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","if"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","if"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","process"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["identifier","cOut"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","count"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","end"], + ["text"," "], + ["keyword","architecture"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_wollok.json b/public/lib/ace/mode/_test/tokens_wollok.json new file mode 100644 index 0000000..ec59f42 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_wollok.json @@ -0,0 +1,209 @@ +[[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","Actividad"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text","\t"], + ["keyword","method"], + ["text"," "], + ["identifier","calcularMejora"], + ["lparen","("], + ["rparen",")"] +],[ + "start", + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","EstudiarMateria"], + ["text"," "], + ["keyword","inherits"], + ["text"," "], + ["identifier","Actividad"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text","\t"], + ["keyword","var"], + ["text"," "], + ["identifier","materia"] +],[ + "start", + ["text","\t"], + ["keyword","var"], + ["text"," "], + ["identifier","puntos"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["text","\t"], + ["keyword","new"], + ["lparen","("], + ["identifier","m"], + ["keyword.operator",","], + ["text"," "], + ["identifier","p"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text","\t\t"], + ["identifier","materia"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","m"] +],[ + "start", + ["text","\t\t"], + ["identifier","puntos"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","p"] +],[ + "start", + ["text","\t"], + ["rparen","}"] +],[ + "start", + ["text","\t"] +],[ + "start", + ["text","\t"], + ["keyword","override"], + ["text"," "], + ["keyword","method"], + ["text"," "], + ["identifier","calcularMejora"], + ["lparen","("], + ["rparen",")"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","puntos"] +],[ + "start", + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","class"], + ["text"," "], + ["identifier","EjercitarEnSimulador"], + ["text"," "], + ["keyword","inherits"], + ["text"," "], + ["identifier","Actividad"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text","\t"], + ["keyword","var"], + ["text"," "], + ["identifier","horas"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"] +],[ + "start", + ["text","\t"], + ["keyword","new"], + ["lparen","("], + ["identifier","h"], + ["rparen",")"], + ["text"," "], + ["lparen","{"], + ["text"," "], + ["identifier","horas"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","h"], + ["text"," "], + ["rparen","}"] +],[ + "start", + ["text","\t"], + ["keyword","override"], + ["text"," "], + ["keyword","method"], + ["text"," "], + ["identifier","calcularMejora"], + ["lparen","("], + ["rparen",")"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","10"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["identifier","horas"] +],[ + "start", + ["rparen","}"] +],[ + "start" +],[ + "start", + ["keyword","object"], + ["text"," "], + ["identifier","pepita"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text","\t"], + ["keyword","var"], + ["text"," "], + ["identifier","energia"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","100"] +],[ + "start", + ["text","\t"], + ["keyword","method"], + ["text"," "], + ["identifier","volar"], + ["lparen","("], + ["identifier","m"], + ["rparen",")"], + ["text"," "], + ["lparen","{"] +],[ + "start", + ["text","\t\t"], + ["identifier","energia"], + ["text"," "], + ["keyword.operator","-="], + ["text"," "], + ["identifier","m"] +],[ + "start", + ["text","\t"], + ["rparen","}"] +],[ + "start", + ["rparen","}"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_xml.json b/public/lib/ace/mode/_test/tokens_xml.json new file mode 100644 index 0000000..728be4d --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_xml.json @@ -0,0 +1,43 @@ +[[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","Juhu"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","//Juhu Kinners"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml","test: two tags in the same lines should be in separate tokens\""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","Juhu"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","Kinners"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml","test: multiline attributes\""] +],[ + ["string.attribute-value.xml0","meta.tag.punctuation.tag-open.xml"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","copy"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","set"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"{"] +],[ + ["string.attribute-value.xml0","meta.tag.punctuation.tag-open.xml"], + ["string.attribute-value.xml","}\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","undo"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"{"] +],[ + "start", + ["string.attribute-value.xml","}\""], + ["meta.tag.punctuation.tag-close.xml","/>"] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_xquery.json b/public/lib/ace/mode/_test/tokens_xquery.json new file mode 100644 index 0000000..aaf9ab9 --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_xquery.json @@ -0,0 +1,44 @@ +[[ + "[\"start\"]", + ["keyword","xquery"], + ["text"," "], + ["keyword","version"], + ["text"," "], + ["string","\""], + ["string","1.0"], + ["string","\""], + ["text",";"] +],[ + "[\"start\"]" +],[ + "[\"start\"]", + ["keyword","let"], + ["text"," "], + ["variable","$message"], + ["text"," "], + ["keyword.operator",":="], + ["text"," "], + ["string","\""], + ["string","Hello World!"], + ["string","\""] +],[ + "[\"start\",\"StartTag\",\"TagContent\"]", + ["keyword","return"], + ["text"," "], + ["meta.tag",""] +],[ + "[\"start\",\"StartTag\",\"TagContent\"]", + ["text"," "], + ["meta.tag",""], + ["text","{"], + ["variable","$message"], + ["text","}"], + ["meta.tag",""] +],[ + "[\"start\"]", + ["meta.tag",""] +],[ + "[\"start\"]" +]] \ No newline at end of file diff --git a/public/lib/ace/mode/_test/tokens_yaml.json b/public/lib/ace/mode/_test/tokens_yaml.json new file mode 100644 index 0000000..0d2acad --- /dev/null +++ b/public/lib/ace/mode/_test/tokens_yaml.json @@ -0,0 +1,167 @@ +[[ + "start", + ["comment","# This sample document was taken from wikipedia:"] +],[ + "start", + ["comment","# http://en.wikipedia.org/wiki/YAML#Sample_document"] +],[ + "start", + ["list.markup","---"] +],[ + "start", + ["meta.tag","receipt"], + ["keyword",":"], + ["text"," Oz-Ware Purchase Invoice"] +],[ + "start", + ["meta.tag","date"], + ["keyword",":"], + ["text"," 2007-08-06"] +],[ + "start", + ["meta.tag","customer"], + ["keyword",":"] +],[ + "start", + ["meta.tag"," given"], + ["keyword",":"], + ["text"," Dorothy"] +],[ + "start", + ["meta.tag"," family"], + ["keyword",":"], + ["text"," Gale"] +],[ + "start" +],[ + "start", + ["meta.tag","items"], + ["keyword",":"] +],[ + "start", + ["list.markup"," - "], + ["meta.tag","part_no"], + ["keyword",":"], + ["text"," "], + ["string","'A4786'"] +],[ + "start", + ["meta.tag"," descrip"], + ["keyword",":"], + ["text"," Water Bucket "], + ["paren.lparen","("], + ["text","Filled)"] +],[ + "start", + ["meta.tag"," price"], + ["keyword",":"], + ["text"," "], + ["constant.numeric","1.47"] +],[ + "start", + ["meta.tag"," quantity"], + ["keyword",":"], + ["text"," "], + ["constant.numeric","4"] +],[ + "start" +],[ + "start", + ["list.markup"," - "], + ["meta.tag","part_no"], + ["keyword",":"], + ["text"," "], + ["string","'E1628'"] +],[ + "start", + ["meta.tag"," descrip"], + ["keyword",":"], + ["text"," High Heeled "], + ["string","\"Ruby\""], + ["text"," Slippers"] +],[ + "start", + ["meta.tag"," size"], + ["keyword",":"], + ["text"," "], + ["constant.numeric","8"] +],[ + "start", + ["meta.tag"," price"], + ["keyword",":"], + ["text"," "], + ["constant.numeric","100.27"] +],[ + "start", + ["meta.tag"," quantity"], + ["keyword",":"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start" +],[ + "start", + ["meta.tag","bill-to"], + ["keyword",":"], + ["text"," "], + ["constant.language","&id001"] +],[ + ["mlString",4], + ["meta.tag"," street"], + ["keyword",":"], + ["text"," "], + ["string","|"] +],[ + ["mlString",4], + ["indent"," "], + ["string","123 Tornado Alley"] +],[ + ["mlString",4], + ["indent"," "], + ["string","Suite 16"] +],[ + "start", + ["indent"," "], + ["meta.tag","city"], + ["keyword",":"], + ["text"," East Centerville"] +],[ + "start", + ["meta.tag"," state"], + ["keyword",":"], + ["text"," KS"] +],[ + "start" +],[ + "start", + ["meta.tag","ship-to"], + ["keyword",":"], + ["text"," "], + ["constant.language","*id001"] +],[ + "start" +],[ + ["mlString",0], + ["meta.tag","specialDelivery"], + ["keyword",":"], + ["text"," "], + ["string",">"] +],[ + ["mlString",0], + ["indent"," "], + ["string","Follow the Yellow Brick"] +],[ + ["mlString",0], + ["indent"," "], + ["string","Road to the Emerald City."] +],[ + ["mlString",0], + ["indent"," "], + ["string","Pay no attention to the"] +],[ + ["mlString",0], + ["indent"," "], + ["string","man behind the curtain."] +],[ + ["mlString",0] +]] \ No newline at end of file diff --git a/public/lib/ace/mode/abap.js b/public/lib/ace/mode/abap.js new file mode 100644 index 0000000..33d85e8 --- /dev/null +++ b/public/lib/ace/mode/abap.js @@ -0,0 +1,61 @@ +/* ***** 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 Rules = require("./abap_highlight_rules").AbapHighlightRules; +var FoldMode = require("./folding/coffee").FoldMode; +var Range = require("../range").Range; +var TextMode = require("./text").Mode; +var oop = require("../lib/oop"); + +function Mode() { + this.HighlightRules = Rules; + this.foldingRules = new FoldMode(); +} + +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = '"'; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + return indent; + }; + + this.$id = "ace/mode/abap"; +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); diff --git a/public/lib/ace/mode/abap_highlight_rules.js b/public/lib/ace/mode/abap_highlight_rules.js new file mode 100644 index 0000000..a3d1ca8 --- /dev/null +++ b/public/lib/ace/mode/abap_highlight_rules.js @@ -0,0 +1,134 @@ +/* ***** 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 ***** */ + +/* + * based on + * " Vim ABAP syntax file + * " Language: SAP - ABAP/R4 + * " Revision: 2.1 + * " Maintainer: Marius Piedallu van Wyk + * " Last Change: 2012 Oct 23 + */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var AbapHighlightRules = function() { + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": + "ADD ALIAS ALIASES ASCENDING ASSERT ASSIGN ASSIGNING AT BACK" + + " CALL CASE CATCH CHECK CLASS CLEAR CLOSE CNT COLLECT COMMIT COMMUNICATION COMPUTE CONCATENATE CONDENSE CONSTANTS CONTINUE CONTROLS CONVERT CREATE CURRENCY" + + " DATA DEFINE DEFINITION DEFERRED DELETE DESCENDING DESCRIBE DETAIL DIVIDE DO" + + " ELSE ELSEIF ENDAT ENDCASE ENDCLASS ENDDO ENDEXEC ENDFORM ENDFUNCTION ENDIF ENDIFEND ENDINTERFACE ENDLOOP ENDMETHOD ENDMODULE ENDON ENDPROVIDE ENDSELECT ENDTRY ENDWHILE EVENT EVENTS EXEC EXIT EXPORT EXPORTING EXTRACT" + + " FETCH FIELDS FORM FORMAT FREE FROM FUNCTION" + + " GENERATE GET" + + " HIDE" + + " IF IMPORT IMPORTING INDEX INFOTYPES INITIALIZATION INTERFACE INTERFACES INPUT INSERT IMPLEMENTATION" + + " LEAVE LIKE LINE LOAD LOCAL LOOP" + + " MESSAGE METHOD METHODS MODIFY MODULE MOVE MULTIPLY" + + " ON OVERLAY OPTIONAL OTHERS" + + " PACK PARAMETERS PERFORM POSITION PROGRAM PROVIDE PUT" + + " RAISE RANGES READ RECEIVE RECEIVING REDEFINITION REFERENCE REFRESH REJECT REPLACE REPORT RESERVE RESTORE RETURN RETURNING ROLLBACK" + + " SCAN SCROLL SEARCH SELECT SET SHIFT SKIP SORT SORTED SPLIT STANDARD STATICS STEP STOP SUBMIT SUBTRACT SUM SUMMARY SUPPRESS" + + " TABLES TIMES TRANSFER TRANSLATE TRY TYPE TYPES" + + " UNASSIGN ULINE UNPACK UPDATE" + + " WHEN WHILE WINDOW WRITE" + + " OCCURS STRUCTURE OBJECT PROPERTY" + + " CASTING APPEND RAISING VALUE COLOR" + + " CHANGING EXCEPTION EXCEPTIONS DEFAULT CHECKBOX COMMENT" + + " ID NUMBER FOR TITLE OUTPUT" + + " WITH EXIT USING" + + " INTO WHERE GROUP BY HAVING ORDER BY SINGLE" + + " APPENDING CORRESPONDING FIELDS OF TABLE" + + " LEFT RIGHT OUTER INNER JOIN AS CLIENT SPECIFIED BYPASSING BUFFER UP TO ROWS CONNECTING" + + " EQ NE LT LE GT GE NOT AND OR XOR IN LIKE BETWEEN", + "constant.language": + "TRUE FALSE NULL SPACE", + "support.type": + "c n i p f d t x string xstring decfloat16 decfloat34", + "keyword.operator": + "abs sign ceil floor trunc frac acos asin atan cos sin tan" + + " abapOperator cosh sinh tanh exp log log10 sqrt" + + " strlen xstrlen charlen numofchar dbmaxlen lines" + }, "text", true, " "); + + var compoundKeywords = "WITH\\W+(?:HEADER\\W+LINE|FRAME|KEY)|NO\\W+STANDARD\\W+PAGE\\W+HEADING|"+ + "EXIT\\W+FROM\\W+STEP\\W+LOOP|BEGIN\\W+OF\\W+(?:BLOCK|LINE)|BEGIN\\W+OF|"+ + "END\\W+OF\\W+(?:BLOCK|LINE)|END\\W+OF|NO\\W+INTERVALS|"+ + "RESPECTING\\W+BLANKS|SEPARATED\\W+BY|USING\\W+(?:EDIT\\W+MASK)|"+ + "WHERE\\W+(?:LINE)|RADIOBUTTON\\W+GROUP|REF\\W+TO|"+ + "(?:PUBLIC|PRIVATE|PROTECTED)(?:\\W+SECTION)?|DELETING\\W+(?:TRAILING|LEADING)"+ + "(?:ALL\\W+OCCURRENCES)|(?:FIRST|LAST)\\W+OCCURRENCE|INHERITING\\W+FROM|"+ + "LINE-COUNT|ADD-CORRESPONDING|AUTHORITY-CHECK|BREAK-POINT|CLASS-DATA|CLASS-METHODS|"+ + "CLASS-METHOD|DIVIDE-CORRESPONDING|EDITOR-CALL|END-OF-DEFINITION|END-OF-PAGE|END-OF-SELECTION|"+ + "FIELD-GROUPS|FIELD-SYMBOLS|FUNCTION-POOL|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|NEW-LINE|"+ + "NEW-PAGE|NEW-SECTION|PRINT-CONTROL|RP-PROVIDE-FROM-LAST|SELECT-OPTIONS|SELECTION-SCREEN|"+ + "START-OF-SELECTION|SUBTRACT-CORRESPONDING|SYNTAX-CHECK|SYNTAX-TRACE|TOP-OF-PAGE|TYPE-POOL|"+ + "TYPE-POOLS|LINE-SIZE|LINE-COUNT|MESSAGE-ID|DISPLAY-MODE|READ(?:-ONLY)?|"+ + "IS\\W+(?:NOT\\W+)?(?:ASSIGNED|BOUND|INITIAL|SUPPLIED)"; + + this.$rules = { + "start" : [ + {token : "string", regex : "`", next : "string"}, + {token : "string", regex : "'", next : "qstring"}, + {token : "doc.comment", regex : /^\*.+/}, + {token : "comment", regex : /".+$/}, + {token : "invalid", regex: "\\.{2,}"}, + {token : "keyword.operator", regex: /\W[\-+%=<>*]\W|\*\*|[~:,\.&$]|->*?|=>/}, + {token : "paren.lparen", regex : "[\\[({]"}, + {token : "paren.rparen", regex : "[\\])}]"}, + {token : "constant.numeric", regex: "[+-]?\\d+\\b"}, + {token : "variable.parameter", regex : /sy|pa?\d\d\d\d\|t\d\d\d\.|innnn/}, + {token : "keyword", regex : compoundKeywords}, + {token : "variable.parameter", regex : /\w+-\w+(?:-\w+)*/}, + {token : keywordMapper, regex : "\\b\\w+\\b"}, + {caseInsensitive: true} + ], + "qstring" : [ + {token : "constant.language.escape", regex : "''"}, + {token : "string", regex : "'", next : "start"}, + {defaultToken : "string"} + ], + "string" : [ + {token : "constant.language.escape", regex : "``"}, + {token : "string", regex : "`", next : "start"}, + {defaultToken : "string"} + ] + }; +}; +oop.inherits(AbapHighlightRules, TextHighlightRules); + +exports.AbapHighlightRules = AbapHighlightRules; +}); diff --git a/public/lib/ace/mode/abc.js b/public/lib/ace/mode/abc.js new file mode 100644 index 0000000..344c950 --- /dev/null +++ b/public/lib/ace/mode/abc.js @@ -0,0 +1,58 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js + */ + +define(function (require, exports, module) { + "use strict"; + + var oop = require("../lib/oop"); + var TextMode = require("./text").Mode; + var ABCHighlightRules = require("./abc_highlight_rules").ABCHighlightRules; + var FoldMode = require("./folding/cstyle").FoldMode; + + var Mode = function () { + this.HighlightRules = ABCHighlightRules; + this.foldingRules = new FoldMode(); + this.$behaviour = this.$defaultBehaviour; + }; + oop.inherits(Mode, TextMode); + + (function () { + // this.lineCommentStart = ""%.*""; + // this.blockComment = {start: ""/*"", end: ""*/""}; + // Extra logic goes here. + this.$id = "ace/mode/abc"; + }).call(Mode.prototype); + + exports.Mode = Mode; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/abc_highlight_rules.js b/public/lib/ace/mode/abc_highlight_rules.js new file mode 100644 index 0000000..6ffe9c9 --- /dev/null +++ b/public/lib/ace/mode/abc_highlight_rules.js @@ -0,0 +1,114 @@ +/* This file was partially autogenerated from https://github.com/jimhawkridge/SublimeABC + + Modifications + + - more classes to express the abc semantic + - added syntax highlighting for Zupfnoter conventions (https://github.com/bwl21/zupfnoter) + - separate note pitch and note duration - even if it looks the same + + ***********************************************************************************************/ + + +define(function (require, exports, module) { + "use strict"; + + var oop = require("../lib/oop"); + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + var ABCHighlightRules = function () { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + start: [ + { + token: ['zupfnoter.information.comment.line.percentage', 'information.keyword', 'in formation.keyword.embedded'], + regex: '(%%%%)(hn\\.[a-z]*)(.*)', + comment: 'Instruction Comment' + }, + { + token: ['information.comment.line.percentage', 'information.keyword.embedded'], + regex: '(%%)(.*)', + comment: 'Instruction Comment' + }, + + { + token: 'comment.line.percentage', + regex: '%.*', + comment: 'Comments' + }, + + { + token: 'barline.keyword.operator', + regex: '[\\[:]*[|:][|\\]:]*(?:\\[?[0-9]+)?|\\[[0-9]+', + comment: 'Bar lines' + }, + { + token: ['information.keyword.embedded', 'information.argument.string.unquoted'], + regex: '(\\[[A-Za-z]:)([^\\]]*\\])', + comment: 'embedded Header lines' + }, + { + token: ['information.keyword', 'information.argument.string.unquoted'], + regex: '^([A-Za-z]:)([^%\\\\]*)', + comment: 'Header lines' + }, + { + token: ['text', 'entity.name.function', 'string.unquoted', 'text'], + regex: '(\\[)([A-Z]:)(.*?)(\\])', + comment: 'Inline fields' + }, + { + token: ['accent.constant.language', 'pitch.constant.numeric', 'duration.constant.numeric'], + regex: '([\\^=_]*)([A-Ga-gz][,\']*)([0-9]*/*[><0-9]*)', + comment: 'Notes' + }, + { + token: 'zupfnoter.jumptarget.string.quoted', + regex: '[\\"!]\\^\\:.*?[\\"!]', + comment: 'Zupfnoter jumptarget' + }, { + token: 'zupfnoter.goto.string.quoted', + regex: '[\\"!]\\^\\@.*?[\\"!]', + comment: 'Zupfnoter goto' + }, + { + token: 'zupfnoter.annotation.string.quoted', + regex: '[\\"!]\\^\\!.*?[\\"!]', + comment: 'Zupfnoter annoation' + }, + { + token: 'zupfnoter.annotationref.string.quoted', + regex: '[\\"!]\\^\\#.*?[\\"!]', + comment: 'Zupfnoter annotation reference' + }, + { + token: 'chordname.string.quoted', + regex: '[\\"!]\\^.*?[\\"!]', + comment: 'abc chord' + }, + { + token: 'string.quoted', + regex: '[\\"!].*?[\\"!]', + comment: 'abc annotation' + } + + ] + }; + + // this.embedRules(JsonHighlightRules, "json-") + + this.normalizeRules(); + }; + + ABCHighlightRules.metaData = { + fileTypes: ['abc'], + name: 'ABC', + scopeName: 'text.abcnotation' + }; + + + oop.inherits(ABCHighlightRules, TextHighlightRules); + + exports.ABCHighlightRules = ABCHighlightRules; +}); diff --git a/public/lib/ace/mode/actionscript.js b/public/lib/ace/mode/actionscript.js new file mode 100644 index 0000000..70eaaba --- /dev/null +++ b/public/lib/ace/mode/actionscript.js @@ -0,0 +1,58 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js +*/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var ActionScriptHighlightRules = require("./actionscript_highlight_rules").ActionScriptHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = ActionScriptHighlightRules; + this.foldingRules = new FoldMode(); + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "//"; + this.blockComment = {start: "/*", end: "*/"}; + this.$id = "ace/mode/actionscript"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/actionscript_highlight_rules.js b/public/lib/ace/mode/actionscript_highlight_rules.js new file mode 100644 index 0000000..b626af2 --- /dev/null +++ b/public/lib/ace/mode/actionscript_highlight_rules.js @@ -0,0 +1,141 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* This file was autogenerated from tm bundles\actionscript.tmbundle\Syntaxes\ActionScript.plist (uuid: ) */ +/**************************************************************************************** + * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * + * fileTypes * + ****************************************************************************************/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var ActionScriptHighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { start: + [ { token: 'support.class.actionscript.2', + regex: '\\b(?:R(?:ecordset|DBMSResolver|adioButton(?:Group)?)|X(?:ML(?:Socket|Node|Connector)?|UpdateResolverDataHolder)|M(?:M(?:Save|Execute)|icrophoneMicrophone|o(?:use|vieClip(?:Loader)?)|e(?:nu(?:Bar)?|dia(?:Controller|Display|Playback))|ath)|B(?:yName|inding|utton)|S(?:haredObject|ystem|crollPane|t(?:yleSheet|age|ream)|ound|e(?:ndEvent|rviceObject)|OAPCall|lide)|N(?:umericStepper|et(?:stream|S(?:tream|ervices)|Connection|Debug(?:Config)?))|C(?:heckBox|o(?:ntextMenu(?:Item)?|okie|lor|m(?:ponentMixins|boBox))|ustomActions|lient|amera)|T(?:ypedValue|ext(?:Snapshot|Input|F(?:ield|ormat)|Area)|ree|AB)|Object|D(?:ownload|elta(?:Item|Packet)?|at(?:e(?:Chooser|Field)?|a(?:G(?:lue|rid)|Set|Type)))|U(?:RL|TC|IScrollBar)|P(?:opUpManager|endingCall|r(?:intJob|o(?:duct|gressBar)))|E(?:ndPoint|rror)|Video|Key|F(?:RadioButton|GridColumn|MessageBox|BarChart|S(?:croll(?:Bar|Pane)|tyleFormat|plitView)|orm|C(?:heckbox|omboBox|alendar)|unction|T(?:icker|ooltip(?:Lite)?|ree(?:Node)?)|IconButton|D(?:ataGrid|raggablePane)|P(?:ieChart|ushButton|ro(?:gressBar|mptBox))|L(?:i(?:stBox|neChart)|oadingBox)|AdvancedMessageBox)|W(?:indow|SDLURL|ebService(?:Connector)?)|L(?:ist|o(?:calConnection|ad(?:er|Vars)|g)|a(?:unch|bel))|A(?:sBroadcaster|cc(?:ordion|essibility)|S(?:Set(?:Native|PropFlags)|N(?:ew|ative)|C(?:onstructor|lamp(?:2)?)|InstanceOf)|pplication|lert|rray))\\b' }, + { token: 'support.function.actionscript.2', + regex: '\\b(?:s(?:h(?:ift|ow(?:GridLines|Menu|Border|Settings|Headers|ColumnHeaders|Today|Preferences)?|ad(?:ow|ePane))|c(?:hema|ale(?:X|Mode|Y|Content)|r(?:oll(?:Track|Drag)?|een(?:Resolution|Color|DPI)))|t(?:yleSheet|op(?:Drag|A(?:nimation|llSounds|gent))?|epSize|a(?:tus|rt(?:Drag|A(?:nimation|gent))?))|i(?:n|ze|lence(?:TimeOut|Level))|o(?:ngname|urce|rt(?:Items(?:By)?|On(?:HeaderRelease)?|able(?:Columns)?)?)|u(?:ppressInvalidCalls|bstr(?:ing)?)|p(?:li(?:ce|t)|aceCol(?:umnsEqually|lumnsEqually))|e(?:nd(?:DefaultPushButtonEvent|AndLoad)?|curity|t(?:R(?:GB|o(?:otNode|w(?:Height|Count))|esizable(?:Columns)?|a(?:nge|te))|G(?:ain|roupName)|X(?:AxisTitle)?|M(?:i(?:n(?:imum|utes)|lliseconds)|o(?:nth(?:Names)?|tionLevel|de)|ultilineMode|e(?:ssage|nu(?:ItemEnabled(?:At)?|EnabledAt)|dia)|a(?:sk|ximum))|B(?:u(?:tton(?:s|Width)|fferTime)|a(?:seTabIndex|ndwidthLimit|ckground))|S(?:howAsDisabled|croll(?:ing|Speed|Content|Target|P(?:osition|roperties)|barState|Location)|t(?:yle(?:Property)?|opOnFocus|at(?:us|e))|i(?:ze|lenceLevel)|ort(?:able(?:Columns)?|Function)|p(?:litterBarPosition|acing)|e(?:conds|lect(?:Multiple|ion(?:Required|Type)?|Style|Color|ed(?:Node(?:s)?|Cell|I(?:nd(?:ices|ex)|tem(?:s)?))?|able))|kin|m(?:oothness|allScroll))|H(?:ighlight(?:s|Color)|Scroll|o(?:urs|rizontal)|eader(?:Symbol|Height|Text|Property|Format|Width|Location)?|as(?:Shader|CloseBox))|Y(?:ear|AxisTitle)?|N(?:ode(?:Properties|ExpansionHandler)|ewTextFormat)|C(?:h(?:ildNodes|a(?:ngeHandler|rt(?:Title|EventHandler)))|o(?:ntent(?:Size)?|okie|lumns)|ell(?:Symbol|Data)|l(?:i(?:ckHandler|pboard)|oseHandler)|redentials)|T(?:ype(?:dVaule)?|i(?:tle(?:barHeight)?|p(?:Target|Offset)?|me(?:out(?:Handler)?)?)|oggle|extFormat|ransform)|I(?:s(?:Branch|Open)|n(?:terval|putProperty)|con(?:SymbolName)?|te(?:rator|m(?:ByKey|Symbol)))|Orientation|D(?:i(?:splay(?:Range|Graphics|Mode|Clip|Text|edMonth)|rection)|uration|e(?:pth(?:Below|To|Above)|fault(?:GatewayURL|Mappings|NodeIconSymbolName)|l(?:iveryMode|ay)|bug(?:ID)?)|a(?:yOfWeekNames|t(?:e(?:Filter)?|a(?:Mapping(?:s)?|Item(?:Text|Property|Format)|Provider|All(?:Height|Property|Format|Width))?))|ra(?:wConnectors|gContent))|U(?:se(?:Shadow|HandCursor|EchoSuppression|rInput|Fade)|TC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear))|P(?:osition|ercentComplete|an(?:e(?:M(?:inimumSize|aximumSize)|Size|Title))?|ro(?:pert(?:y(?:Data)?|iesAt)|gress))|E(?:nabled|dit(?:Handler|able)|xpand(?:NodeTrigger|erSymbolName))|V(?:Scroll|olume|alue(?:Source)?)|KeyFrameInterval|Quality|F(?:i(?:eld|rst(?:DayOfWeek|VisibleNode))|ocus|ullYear|ps|ade(?:InLength|OutLength)|rame(?:Color|Width))|Width|L(?:ine(?:Color|Weight)|o(?:opback|adTarget)|a(?:rgeScroll|bel(?:Source|Placement)?))|A(?:s(?:Boolean|String|Number)|n(?:yTypedValue|imation)|ctiv(?:e(?:State(?:Handler)?|Handler)|ateHandler)|utoH(?:ideScrollBar|eight)))?|paratorBefore|ek|lect(?:ion(?:Disabled|Unfocused)?|ed(?:Node(?:s)?|Child|I(?:nd(?:ices|ex)|tem(?:s)?)|Dat(?:e|a))?|able(?:Ranges)?)|rver(?:String)?)|kip|qrt|wapDepths|lice|aveToSharedObj|moothing)|h(?:scroll(?:Policy)?|tml(?:Text)?|i(?:t(?:Test(?:TextNearPos)?|Area)|de(?:BuiltInItems|Child)?|ghlight(?:2D|3D)?)|orizontal|e(?:ight|ader(?:Re(?:nderer|lease)|Height|Text))|P(?:osition|ageScrollSize)|a(?:s(?:childNodes|MP3|S(?:creen(?:Broadcast|Playback)|treaming(?:Video|Audio)|ort)|Next|OwnProperty|Pr(?:inting|evious)|EmbeddedVideo|VideoEncoder|A(?:ccesibility|udio(?:Encoder)?))|ndlerName)|LineScrollSize)|ye(?:sLabel|ar)|n(?:o(?:t|de(?:Name|Close|Type|Open|Value)|Label)|u(?:llValue|mChild(?:S(?:creens|lides)|ren|Forms))|e(?:w(?:Item|line|Value|LocationDialog)|xt(?:S(?:cene|ibling|lide)|TabIndex|Value|Frame)?)?|ame(?:s)?)|c(?:h(?:ildNodes|eck|a(?:nge(?:sPending)?|r(?:CodeAt|At))|r)|o(?:s|n(?:st(?:ant|ructor)|nect|c(?:urrency|at)|t(?:ent(?:Type|Path)?|ains|rol(?:Placement|lerPolicy))|denseWhite|version)|py|l(?:or|umn(?:Stretch|Name(?:s)?|Count))|m(?:p(?:onent|lete)|ment))|u(?:stomItems|ePoint(?:s)?|r(?:veTo|Value|rent(?:Slide|ChildSlide|Item|F(?:ocused(?:S(?:creen|lide)|Form)|ps))))|e(?:il|ll(?:Renderer|Press|Edit|Focus(?:In|Out)))|l(?:i(?:ck|ents)|o(?:se(?:Button|Pane)?|ne(?:Node)?)|ear(?:S(?:haredObjects|treams)|Timeout|Interval)?)|a(?:ncelLabel|tch|p(?:tion|abilities)|l(?:cFields|l(?:e(?:e|r))?))|reate(?:GatewayConnection|Menu|Se(?:rver|gment)|C(?:hild(?:AtDepth)?|l(?:ient|ass(?:ChildAtDepth|Object(?:AtDepth)?))|all)|Text(?:Node|Field)|Item|Object(?:AtDepth)?|PopUp|E(?:lement|mptyMovieClip)))|t(?:h(?:is|row)|ype(?:of|Name)?|i(?:tle(?:StyleDeclaration)?|me(?:out)?)|o(?:talTime|String|olTipText|p|UpperCase|ggle(?:HighQuality)?|Lo(?:caleString|werCase))|e(?:st|llTarget|xt(?:RightMargin|Bold|S(?:ize|elected)|Height|Color|I(?:ndent|talic)|Disabled|Underline|F(?:ield|ont)|Width|LeftMargin|Align)?)|a(?:n|rget(?:Path)?|b(?:Stops|Children|Index|Enabled|leName))|r(?:y|igger|ac(?:e|k(?:AsMenu)?)))|i(?:s(?:Running|Branch|NaN|Con(?:soleOpen|nected)|Toggled|Installed|Open|D(?:own|ebugger)|P(?:urchased|ro(?:totypeOf|pertyEnumerable))|Empty|F(?:inite|ullyPopulated)|Local|Active)|n(?:s(?:tall|ertBefore)|cludeDeltaPacketInfo|t|it(?:ialize|Component|Pod|A(?:pplication|gent))?|de(?:nt|terminate|x(?:InParent(?:Slide|Form)?|Of)?)|put|validate|finity|LocalInternetCache)?|con(?:F(?:ield|unction))?|t(?:e(?:ratorScrolled|m(?:s|RollO(?:ut|ver)|ClassName))|alic)|d3|p|fFrameLoaded|gnore(?:Case|White))|o(?:s|n(?:R(?:ollO(?:ut|ver)|e(?:s(?:ize|ult)|l(?:ease(?:Outside)?|aseOutside)))|XML|Mouse(?:Move|Down|Up|Wheel)|S(?:ync|croller|tatus|oundComplete|e(?:tFocus|lect(?:edItem)?))|N(?:oticeEvent|etworkChange)|C(?:hanged|onnect|l(?:ipEvent|ose))|ID3|D(?:isconnect|eactivate|ata|ragO(?:ut|ver))|Un(?:install|load)|P(?:aymentResult|ress)|EnterFrame|K(?:illFocus|ey(?:Down|Up))|Fault|Lo(?:ad|g)|A(?:ctiv(?:ity|ate)|ppSt(?:op|art)))?|pe(?:n|ration)|verLayChildren|kLabel|ldValue|r(?:d)?)|d(?:i(?:s(?:connect|play(?:Normal|ed(?:Month|Year)|Full)|able(?:Shader|d(?:Ranges|Days)|CloseBox|Events))|rection)|o(?:cTypeDecl|tall|Decoding|main|LazyDecoding)|u(?:plicateMovieClip|ration)|e(?:stroy(?:ChildAt|Object)|code|fault(?:PushButton(?:Enabled)?|KeydownHandler)?|l(?:ta(?:Packet(?:Changed)?)?|ete(?:PopUp|All)?)|blocking)|a(?:shBoardSave|yNames|ta(?:Provider)?|rkshadow)|r(?:opdown(?:Width)?|a(?:w|gO(?:ut|ver))))|u(?:se(?:Sort|HandCursor|Codepage|EchoSuppression)|n(?:shift|install|derline|escape|format|watch|lo(?:ck|ad(?:Movie(?:Num)?)?))|pdate(?:Results|Mode|I(?:nputProperties|tem(?:ByIndex)?)|P(?:acket|roperties)|View|AfterEvent)|rl)|join|p(?:ixelAspectRatio|o(?:sition|p|w)|u(?:sh|rge|blish)|ercen(?:tComplete|Loaded)|lay(?:head(?:Change|Time)|ing|Hidden|erType)?|a(?:ssword|use|r(?:se(?:XML|CSS|Int|Float)|ent(?:Node|Is(?:S(?:creen|lide)|Form))|ams))|r(?:int(?:Num|AsBitmap(?:Num)?)?|o(?:to(?:type)?|pert(?:y|ies)|gress)|e(?:ss|v(?:ious(?:S(?:ibling|lide)|Value)?|Scene|Frame)|ferred(?:Height|Width))))|e(?:scape|n(?:code(?:r)?|ter(?:Frame)?|dFill|able(?:Shader|d|CloseBox|Events))|dit(?:able|Field|LocationDialog)|v(?:ent|al(?:uate)?)|q|x(?:tended|p|ec(?:ute)?|actSettings)|m(?:phasized(?:StyleDeclaration)?|bedFonts))|v(?:i(?:sible|ewPod)|ScrollPolicy|o(?:id|lume)|ersion|P(?:osition|ageScrollSize)|a(?:l(?:idat(?:ionError|e(?:Property|ActivationKey)?)|ue(?:Of)?)|riable)|LineScrollSize)|k(?:ind|ey(?:Down|Up|Press|FrameInterval))|q(?:sort|uality)|f(?:scommand|i(?:n(?:d(?:Text|First|Last)?|ally)|eldInfo|lter(?:ed|Func)?|rst(?:Slide|Child|DayOfWeek|VisibleNode)?)|o(?:nt|cus(?:In|edCell|Out|Enabled)|r(?:egroundDisabled|mat(?:ter)?))|unctionName|ps|l(?:oor|ush)|ace|romCharCode)|w(?:i(?:th|dth)|ordWrap|atch|riteAccess)|l(?:t|i(?:st(?:Owner)?|ne(?:Style|To))|o(?:c(?:k|a(?:t(?:ion|eByld)|l(?:ToGlobal|FileReadDisable)))|opback|ad(?:Movie(?:Num)?|S(?:crollContent|ound)|ed|Variables(?:Num)?|Application)?|g(?:Changes)?)|e(?:ngth|ft(?:Margin)?|ading)?|a(?:st(?:Slide|Child|Index(?:Of)?)?|nguage|b(?:el(?:Placement|F(?:ield|unction))?|leField)))|a(?:s(?:scociate(?:Controller|Display)|in|pectRatio|function)|nd|c(?:ceptConnection|tiv(?:ityLevel|ePlayControl)|os)|t(?:t(?:ach(?:Movie|Sound|Video|Audio)|ributes)|an(?:2)?)|dd(?:header|RequestHeader|Menu(?:Item(?:At)?|At)?|Sort|Header|No(?:tice|de(?:At)?)|C(?:olumn(?:At)?|uePoint)|T(?:oLocalInternetCache|reeNode(?:At)?)|I(?:con|tem(?:s(?:At)?|At)?)|DeltaItem|P(?:od|age|roperty)|EventListener|View|FieldInfo|Listener|Animation)?|uto(?:Size|Play|KeyNav|Load)|pp(?:endChild|ly(?:Changes|Updates)?)|vHardwareDisable|fterLoaded|l(?:ternateRowColors|ign|l(?:ow(?:InsecureDomain|Domain)|Transitions(?:InDone|OutDone))|bum)|r(?:tist|row|g(?:uments|List))|gent|bs)|r(?:ight(?:Margin)?|o(?:ot(?:S(?:creen|lide)|Form)|und|w(?:Height|Count)|llO(?:ut|ver))|e(?:s(?:yncDepth|t(?:orePane|artAnimation|rict)|iz(?:e|able(?:Columns)?)|olveDelta|ult(?:s)?|ponse)|c(?:o(?:ncile(?:Results|Updates)|rd)|eive(?:Video|Audio))|draw|jectConnection|place(?:Sel|ItemAt|AllItems)?|ve(?:al(?:Child)?|rse)|quest(?:SizeChange|Payment)?|f(?:errer|resh(?:ScrollContent|Destinations|Pane|FromSources)?)|lease(?:Outside)?|ad(?:Only|Access)|gister(?:SkinElement|C(?:olor(?:Style|Name)|lass)|InheritingStyle|Proxy)|move(?:Range|M(?:ovieClip|enu(?:Item(?:At)?|At))|Background|Sort|No(?:tice|de(?:sAt|At)?)|C(?:olum(?:nAt|At)|uePoints)|T(?:extField|reeNode(?:At)?)|Item(?:At)?|Pod|EventListener|FromLocalInternetCache|Listener|All(?:C(?:olumns|uePoints)|Items)?))|a(?:ndom|te|dioDot))|g(?:t|oto(?:Slide|NextSlide|PreviousSlide|FirstSlide|LastSlide|And(?:Stop|Play))|e(?:nre|t(?:R(?:GB|o(?:otNode|wCount)|e(?:sizable|mote))|X(?:AxisTitle)?|M(?:i(?:n(?:imum(?:Size)?|utes)|lliseconds)|onth(?:Names)?|ultilineMode|e(?:ssage|nu(?:ItemAt|EnabledAt|At))|aximum(?:Size)?)|B(?:ytes(?:Total|Loaded)|ounds|utton(?:s|Width)|eginIndex|a(?:ndwidthLimit|ckground))|S(?:howAsDisabled|croll(?:ing|Speed|Content|Position|barState|Location)|t(?:yle(?:Names)?|opOnFocus|ate)|ize|o(?:urce|rtState)|p(?:litterBarPosition|acing)|e(?:conds|lect(?:Multiple|ion(?:Required|Type)|Style|ed(?:Node(?:s)?|Cell|Text|I(?:nd(?:ices|ex)|tem(?:s)?))?)|rvice)|moothness|WFVersion)|H(?:ighlight(?:s|Color)|ours|e(?:ight|ader(?:Height|Text|Property|Format|Width|Location)?)|as(?:Shader|CloseBox))|Y(?:ear|AxisTitle)?|N(?:o(?:tices|de(?:DisplayedAt|At))|um(?:Children|berAvailable)|e(?:wTextFormat|xtHighestDepth))|C(?:h(?:ild(?:S(?:creen|lide)|Nodes|Form|At)|artTitle)|o(?:n(?:tent|figInfo)|okie|de|unt|lumn(?:Names|Count|Index|At))|uePoint|ellIndex|loseHandler|a(?:ll|retIndex))|T(?:ypedValue|i(?:tle(?:barHeight)?|p(?:Target|Offset)?|me(?:stamp|zoneOffset|out(?:State|Handler)|r)?)|oggle|ext(?:Extent|Format)?|r(?:ee(?:NodeAt|Length)|ans(?:form|actionId)))|I(?:s(?:Branch|Open)|n(?:stanceAtDepth|d(?:icesByKey|exByKey))|con(?:SymbolName)?|te(?:rator|m(?:sByKey|By(?:Name|Key)|id|ID|At))|d)|O(?:utput(?:Parameter(?:s|ByName)?|Value(?:s)?)|peration|ri(?:entation|ginalCellData))|D(?:i(?:s(?:play(?:Range|Mode|Clip|Index|edMonth)|kUsage)|rection)|uration|e(?:pth|faultNodeIconSymbolName|l(?:taPacket|ay)|bug(?:Config|ID)?)|a(?:y(?:OfWeekNames)?|t(?:e|a(?:Mapping(?:s)?|Item(?:Text|Property|Format)|Label|All(?:Height|Property|Format|Width))?))|rawConnectors)|U(?:se(?:Shadow|HandCursor|rInput|Fade)|RL|TC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear))|P(?:o(?:sition|ds)|ercentComplete|a(?:n(?:e(?:M(?:inimums|aximums)|Height|Title|Width))?|rentNode)|r(?:operty(?:Name|Data)?|efer(?:ences|red(?:Height|Width))))|E(?:n(?:dIndex|abled)|ditingData|x(?:panderSymbolName|andNodeTrigger))|V(?:iewed(?:Pods|Applications)|olume|ersion|alue(?:Source)?)|F(?:i(?:eld|rst(?:DayOfWeek|VisibleNode))|o(?:ntList|cus)|ullYear|ade(?:InLength|OutLength)|rame(?:Color|Width))|Width|L(?:ine(?:Color|Weight)|o(?:cal|adTarget)|ength|a(?:stTabIndex|bel(?:Source)?))|A(?:s(?:cii|Boolean|String|Number)|n(?:yTypedValue|imation)|ctiv(?:eState(?:Handler)?|ateHandler)|utoH(?:ideScrollBar|eight)|llItems|gent))?)?|lobal(?:StyleFormat|ToLocal)?|ain|roupName)|x(?:updatePackety|mlDecl)?|m(?:y(?:MethodName|Call)|in(?:imum)?|o(?:nthNames|tion(?:TimeOut|Level)|de(?:lChanged)?|use(?:Move|O(?:ut|ver)|Down(?:Somewhere|Outside)?|Up(?:Somewhere)?|WheelEnabled)|ve(?:To)?)|u(?:ted|lti(?:pleS(?:imultaneousAllowed|elections)|line))|e(?:ssage|nu(?:Show|Hide)?|th(?:od)?|diaType)|a(?:nufacturer|tch|x(?:scroll|hscroll|imum|HPosition|Chars|VPosition)?)|b(?:substring|chr|ord|length))|b(?:ytes(?:Total|Loaded)|indFormat(?:Strings|Function)|o(?:ttom(?:Scroll)?|ld|rder(?:Color)?)|u(?:tton(?:Height|Width)|iltInItems|ffer(?:Time|Length)|llet)|e(?:foreApplyUpdates|gin(?:GradientFill|Fill))|lockIndent|a(?:ndwidth|ckground(?:Style|Color|Disabled)?)|roadcastMessage)|onHTTPStatus)\\b' }, + { token: 'support.constant.actionscript.2', + regex: '\\b(?:__proto__|__resolve|_accProps|_alpha|_changed|_currentframe|_droptarget|_flash|_focusrect|_framesloaded|_global|_height|_highquality|_level|_listeners|_lockroot|_name|_parent|_quality|_root|_rotation|_soundbuftime|_target|_totalframes|_url|_visible|_width|_x|_xmouse|_xscale|_y|_ymouse|_yscale)\\b' }, + { token: 'keyword.control.actionscript.2', + regex: '\\b(?:dynamic|extends|import|implements|interface|public|private|new|static|super|var|for|in|break|continue|while|do|return|if|else|case|switch)\\b' }, + { token: 'storage.type.actionscript.2', + regex: '\\b(?:Boolean|Number|String|Void)\\b' }, + { token: 'constant.language.actionscript.2', + regex: '\\b(?:null|undefined|true|false)\\b' }, + { token: 'constant.numeric.actionscript.2', + regex: '\\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:L|l|UL|ul|u|U|F|f)?\\b' }, + { token: 'punctuation.definition.string.begin.actionscript.2', + regex: '"', + push: + [ { token: 'punctuation.definition.string.end.actionscript.2', + regex: '"', + next: 'pop' }, + { token: 'constant.character.escape.actionscript.2', + regex: '\\\\.' }, + { defaultToken: 'string.quoted.double.actionscript.2' } ] }, + { token: 'punctuation.definition.string.begin.actionscript.2', + regex: '\'', + push: + [ { token: 'punctuation.definition.string.end.actionscript.2', + regex: '\'', + next: 'pop' }, + { token: 'constant.character.escape.actionscript.2', + regex: '\\\\.' }, + { defaultToken: 'string.quoted.single.actionscript.2' } ] }, + { token: 'support.constant.actionscript.2', + regex: '\\b(?:BACKSPACE|CAPSLOCK|CONTROL|DELETEKEY|DOWN|END|ENTER|HOME|INSERT|LEFT|LN10|LN2|LOG10E|LOG2E|MAX_VALUE|MIN_VALUE|NEGATIVE_INFINITY|NaN|PGDN|PGUP|PI|POSITIVE_INFINITY|RIGHT|SPACE|SQRT1_2|SQRT2|UP)\\b' }, + { token: 'punctuation.definition.comment.actionscript.2', + regex: '/\\*', + push: + [ { token: 'punctuation.definition.comment.actionscript.2', + regex: '\\*/', + next: 'pop' }, + { defaultToken: 'comment.block.actionscript.2' } ] }, + { token: 'punctuation.definition.comment.actionscript.2', + regex: '//.*$', + push_: + [ { token: 'comment.line.double-slash.actionscript.2', + regex: '$', + next: 'pop' }, + { defaultToken: 'comment.line.double-slash.actionscript.2' } ] }, + { token: 'keyword.operator.actionscript.2', + regex: '\\binstanceof\\b' }, + { token: 'keyword.operator.symbolic.actionscript.2', + regex: '[-!%&*+=/?:]' }, + { token: + [ 'meta.preprocessor.actionscript.2', + 'punctuation.definition.preprocessor.actionscript.2', + 'meta.preprocessor.actionscript.2' ], + regex: '^([ \\t]*)(#)([a-zA-Z]+)' }, + { token: + [ 'storage.type.function.actionscript.2', + 'meta.function.actionscript.2', + 'entity.name.function.actionscript.2', + 'meta.function.actionscript.2', + 'punctuation.definition.parameters.begin.actionscript.2' ], + regex: '\\b(function)(\\s+)([a-zA-Z_]\\w*)(\\s*)(\\()', + push: + [ { token: 'punctuation.definition.parameters.end.actionscript.2', + regex: '\\)', + next: 'pop' }, + { token: 'variable.parameter.function.actionscript.2', + regex: '[^,)$]+' }, + { defaultToken: 'meta.function.actionscript.2' } ] }, + { token: + [ 'storage.type.class.actionscript.2', + 'meta.class.actionscript.2', + 'entity.name.type.class.actionscript.2', + 'meta.class.actionscript.2', + 'storage.modifier.extends.actionscript.2', + 'meta.class.actionscript.2', + 'entity.other.inherited-class.actionscript.2' ], + regex: '\\b(class)(\\s+)([a-zA-Z_](?:\\w|\\.)*)(?:(\\s+)(extends)(\\s+)([a-zA-Z_](?:\\w|\\.)*))?' } ] }; + + this.normalizeRules(); +}; + +ActionScriptHighlightRules.metaData = { fileTypes: [ 'as' ], + keyEquivalent: '^~A', + name: 'ActionScript', + scopeName: 'source.actionscript.2' }; + + +oop.inherits(ActionScriptHighlightRules, TextHighlightRules); + +exports.ActionScriptHighlightRules = ActionScriptHighlightRules; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/ada.js b/public/lib/ace/mode/ada.js new file mode 100644 index 0000000..fabf04d --- /dev/null +++ b/public/lib/ace/mode/ada.js @@ -0,0 +1,54 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var AdaHighlightRules = require("./ada_highlight_rules").AdaHighlightRules; + +var Mode = function() { + this.HighlightRules = AdaHighlightRules; + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = "--"; + + this.$id = "ace/mode/ada"; +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + diff --git a/public/lib/ace/mode/ada_highlight_rules.js b/public/lib/ace/mode/ada_highlight_rules.js new file mode 100644 index 0000000..b345966 --- /dev/null +++ b/public/lib/ace/mode/ada_highlight_rules.js @@ -0,0 +1,93 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var AdaHighlightRules = function() { +var keywords = "abort|else|new|return|abs|elsif|not|reverse|abstract|end|null|accept|entry|select|" + +"access|exception|of|separate|aliased|exit|or|some|all|others|subtype|and|for|out|synchronized|" + +"array|function|overriding|at|tagged|generic|package|task|begin|goto|pragma|terminate|" + +"body|private|then|if|procedure|type|case|in|protected|constant|interface|until|" + +"|is|raise|use|declare|range|delay|limited|record|when|delta|loop|rem|while|digits|renames|with|do|mod|requeue|xor"; + + var builtinConstants = ( + "true|false|null" + ); + + var builtinFunctions = ( + "count|min|max|avg|sum|rank|now|coalesce|main" + ); + + var keywordMapper = this.createKeywordMapper({ + "support.function": builtinFunctions, + "keyword": keywords, + "constant.language": builtinConstants + }, "identifier", true); + + this.$rules = { + "start" : [ { + token : "comment", + regex : "--.*$" + }, { + token : "string", // " string + regex : '".*?"' + }, { + token : "string", // ' string + regex : "'.*?'" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=" + }, { + token : "paren.lparen", + regex : "[\\(]" + }, { + token : "paren.rparen", + regex : "[\\)]" + }, { + token : "text", + regex : "\\s+" + } ] + }; +}; + +oop.inherits(AdaHighlightRules, TextHighlightRules); + +exports.AdaHighlightRules = AdaHighlightRules; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/apache_conf.js b/public/lib/ace/mode/apache_conf.js new file mode 100644 index 0000000..dec48d1 --- /dev/null +++ b/public/lib/ace/mode/apache_conf.js @@ -0,0 +1,62 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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. + * + * + * Contributor(s): + * + * + * + * ***** END LICENSE BLOCK ***** */ + +/* + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js +*/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var ApacheConfHighlightRules = require("./apache_conf_highlight_rules").ApacheConfHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = ApacheConfHighlightRules; + this.foldingRules = new FoldMode(); + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "#"; + this.$id = "ace/mode/apache_conf"; + // Extra logic goes here. +}).call(Mode.prototype); + +exports.Mode = Mode; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/apache_conf_highlight_rules.js b/public/lib/ace/mode/apache_conf_highlight_rules.js new file mode 100644 index 0000000..8258b1d --- /dev/null +++ b/public/lib/ace/mode/apache_conf_highlight_rules.js @@ -0,0 +1,231 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* This file was autogenerated from https://raw.github.com/colinta/ApacheConf.tmLanguage/master/ApacheConf.tmLanguage (uuid: ) */ +/**************************************************************************************** + * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * + * fileTypes * + ****************************************************************************************/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var ApacheConfHighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { start: + [ { token: + [ 'punctuation.definition.comment.apacheconf', + 'comment.line.hash.ini', + 'comment.line.hash.ini' ], + regex: '^((?:\\s)*)(#)(.*$)' }, + { token: + [ 'punctuation.definition.tag.apacheconf', + 'entity.tag.apacheconf', + 'text', + 'string.value.apacheconf', + 'punctuation.definition.tag.apacheconf' ], + regex: '(<)(Proxy|ProxyMatch|IfVersion|Directory|DirectoryMatch|Files|FilesMatch|IfDefine|IfModule|Limit|LimitExcept|Location|LocationMatch|VirtualHost)(?:(\\s)(.+?))?(>)' }, + { token: + [ 'punctuation.definition.tag.apacheconf', + 'entity.tag.apacheconf', + 'punctuation.definition.tag.apacheconf' ], + regex: '()' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'string.regexp.apacheconf', 'text', + 'string.replacement.apacheconf', 'text' ], + regex: '(Rewrite(?:Rule|Cond))(\\s+)(.+?)(\\s+)(.+?)($|\\s)' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'entity.status.apacheconf', 'text', + 'string.regexp.apacheconf', 'text', + 'string.path.apacheconf', 'text' ], + regex: '(RedirectMatch)(?:(\\s+)(\\d\\d\\d|permanent|temp|seeother|gone))?(\\s+)(.+?)(\\s+)(?:(.+?)($|\\s))?' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'entity.status.apacheconf', 'text', + 'string.path.apacheconf', 'text', + 'string.path.apacheconf', 'text' ], + regex: '(Redirect)(?:(\\s+)(\\d\\d\\d|permanent|temp|seeother|gone))?(\\s+)(.+?)(\\s+)(?:(.+?)($|\\s))?' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'string.regexp.apacheconf', 'text', + 'string.path.apacheconf', 'text' ], + regex: '(ScriptAliasMatch|AliasMatch)(\\s+)(.+?)(\\s+)(?:(.+?)(\\s))?' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'string.path.apacheconf', 'text', + 'string.path.apacheconf', 'text' ], + regex: '(RedirectPermanent|RedirectTemp|ScriptAlias|Alias)(\\s+)(.+?)(\\s+)(?:(.+?)($|\\s))?' }, + { token: 'keyword.core.apacheconf', + regex: '\\b(?:AcceptPathInfo|AccessFileName|AddDefaultCharset|AddOutputFilterByType|AllowEncodedSlashes|AllowOverride|AuthName|AuthType|CGIMapExtension|ContentDigest|DefaultType|DocumentRoot|EnableMMAP|EnableSendfile|ErrorDocument|ErrorLog|FileETag|ForceType|HostnameLookups|IdentityCheck|Include|KeepAlive|KeepAliveTimeout|LimitInternalRecursion|LimitRequestBody|LimitRequestFields|LimitRequestFieldSize|LimitRequestLine|LimitXMLRequestBody|LogLevel|MaxKeepAliveRequests|NameVirtualHost|Options|Require|RLimitCPU|RLimitMEM|RLimitNPROC|Satisfy|ScriptInterpreterSource|ServerAdmin|ServerAlias|ServerName|ServerPath|ServerRoot|ServerSignature|ServerTokens|SetHandler|SetInputFilter|SetOutputFilter|TimeOut|TraceEnable|UseCanonicalName)\\b' }, + { token: 'keyword.mpm.apacheconf', + regex: '\\b(?:AcceptMutex|AssignUserID|BS2000Account|ChildPerUserID|CoreDumpDirectory|EnableExceptionHook|Group|Listen|ListenBacklog|LockFile|MaxClients|MaxMemFree|MaxRequestsPerChild|MaxRequestsPerThread|MaxSpareServers|MaxSpareThreads|MaxThreads|MaxThreadsPerChild|MinSpareServers|MinSpareThreads|NumServers|PidFile|ReceiveBufferSize|ScoreBoardFile|SendBufferSize|ServerLimit|StartServers|StartThreads|ThreadLimit|ThreadsPerChild|ThreadStackSize|User|Win32DisableAcceptEx)\\b' }, + { token: 'keyword.access.apacheconf', + regex: '\\b(?:Allow|Deny|Order)\\b' }, + { token: 'keyword.actions.apacheconf', + regex: '\\b(?:Action|Script)\\b' }, + { token: 'keyword.alias.apacheconf', + regex: '\\b(?:Alias|AliasMatch|Redirect|RedirectMatch|RedirectPermanent|RedirectTemp|ScriptAlias|ScriptAliasMatch)\\b' }, + { token: 'keyword.auth.apacheconf', + regex: '\\b(?:AuthAuthoritative|AuthGroupFile|AuthUserFile)\\b' }, + { token: 'keyword.auth_anon.apacheconf', + regex: '\\b(?:Anonymous|Anonymous_Authoritative|Anonymous_LogEmail|Anonymous_MustGiveEmail|Anonymous_NoUserID|Anonymous_VerifyEmail)\\b' }, + { token: 'keyword.auth_dbm.apacheconf', + regex: '\\b(?:AuthDBMAuthoritative|AuthDBMGroupFile|AuthDBMType|AuthDBMUserFile)\\b' }, + { token: 'keyword.auth_digest.apacheconf', + regex: '\\b(?:AuthDigestAlgorithm|AuthDigestDomain|AuthDigestFile|AuthDigestGroupFile|AuthDigestNcCheck|AuthDigestNonceFormat|AuthDigestNonceLifetime|AuthDigestQop|AuthDigestShmemSize)\\b' }, + { token: 'keyword.auth_ldap.apacheconf', + regex: '\\b(?:AuthLDAPAuthoritative|AuthLDAPBindDN|AuthLDAPBindPassword|AuthLDAPCharsetConfig|AuthLDAPCompareDNOnServer|AuthLDAPDereferenceAliases|AuthLDAPEnabled|AuthLDAPFrontPageHack|AuthLDAPGroupAttribute|AuthLDAPGroupAttributeIsDN|AuthLDAPRemoteUserIsDN|AuthLDAPUrl)\\b' }, + { token: 'keyword.autoindex.apacheconf', + regex: '\\b(?:AddAlt|AddAltByEncoding|AddAltByType|AddDescription|AddIcon|AddIconByEncoding|AddIconByType|DefaultIcon|HeaderName|IndexIgnore|IndexOptions|IndexOrderDefault|ReadmeName)\\b' }, + { token: 'keyword.cache.apacheconf', + regex: '\\b(?:CacheDefaultExpire|CacheDisable|CacheEnable|CacheForceCompletion|CacheIgnoreCacheControl|CacheIgnoreHeaders|CacheIgnoreNoLastMod|CacheLastModifiedFactor|CacheMaxExpire)\\b' }, + { token: 'keyword.cern_meta.apacheconf', + regex: '\\b(?:MetaDir|MetaFiles|MetaSuffix)\\b' }, + { token: 'keyword.cgi.apacheconf', + regex: '\\b(?:ScriptLog|ScriptLogBuffer|ScriptLogLength)\\b' }, + { token: 'keyword.cgid.apacheconf', + regex: '\\b(?:ScriptLog|ScriptLogBuffer|ScriptLogLength|ScriptSock)\\b' }, + { token: 'keyword.charset_lite.apacheconf', + regex: '\\b(?:CharsetDefault|CharsetOptions|CharsetSourceEnc)\\b' }, + { token: 'keyword.dav.apacheconf', + regex: '\\b(?:Dav|DavDepthInfinity|DavMinTimeout|DavLockDB)\\b' }, + { token: 'keyword.deflate.apacheconf', + regex: '\\b(?:DeflateBufferSize|DeflateCompressionLevel|DeflateFilterNote|DeflateMemLevel|DeflateWindowSize)\\b' }, + { token: 'keyword.dir.apacheconf', + regex: '\\b(?:DirectoryIndex|DirectorySlash)\\b' }, + { token: 'keyword.disk_cache.apacheconf', + regex: '\\b(?:CacheDirLength|CacheDirLevels|CacheExpiryCheck|CacheGcClean|CacheGcDaily|CacheGcInterval|CacheGcMemUsage|CacheGcUnused|CacheMaxFileSize|CacheMinFileSize|CacheRoot|CacheSize|CacheTimeMargin)\\b' }, + { token: 'keyword.dumpio.apacheconf', + regex: '\\b(?:DumpIOInput|DumpIOOutput)\\b' }, + { token: 'keyword.env.apacheconf', + regex: '\\b(?:PassEnv|SetEnv|UnsetEnv)\\b' }, + { token: 'keyword.expires.apacheconf', + regex: '\\b(?:ExpiresActive|ExpiresByType|ExpiresDefault)\\b' }, + { token: 'keyword.ext_filter.apacheconf', + regex: '\\b(?:ExtFilterDefine|ExtFilterOptions)\\b' }, + { token: 'keyword.file_cache.apacheconf', + regex: '\\b(?:CacheFile|MMapFile)\\b' }, + { token: 'keyword.headers.apacheconf', + regex: '\\b(?:Header|RequestHeader)\\b' }, + { token: 'keyword.imap.apacheconf', + regex: '\\b(?:ImapBase|ImapDefault|ImapMenu)\\b' }, + { token: 'keyword.include.apacheconf', + regex: '\\b(?:SSIEndTag|SSIErrorMsg|SSIStartTag|SSITimeFormat|SSIUndefinedEcho|XBitHack)\\b' }, + { token: 'keyword.isapi.apacheconf', + regex: '\\b(?:ISAPIAppendLogToErrors|ISAPIAppendLogToQuery|ISAPICacheFile|ISAPIFakeAsync|ISAPILogNotSupported|ISAPIReadAheadBuffer)\\b' }, + { token: 'keyword.ldap.apacheconf', + regex: '\\b(?:LDAPCacheEntries|LDAPCacheTTL|LDAPConnectionTimeout|LDAPOpCacheEntries|LDAPOpCacheTTL|LDAPSharedCacheFile|LDAPSharedCacheSize|LDAPTrustedCA|LDAPTrustedCAType)\\b' }, + { token: 'keyword.log.apacheconf', + regex: '\\b(?:BufferedLogs|CookieLog|CustomLog|LogFormat|TransferLog|ForensicLog)\\b' }, + { token: 'keyword.mem_cache.apacheconf', + regex: '\\b(?:MCacheMaxObjectCount|MCacheMaxObjectSize|MCacheMaxStreamingBuffer|MCacheMinObjectSize|MCacheRemovalAlgorithm|MCacheSize)\\b' }, + { token: 'keyword.mime.apacheconf', + regex: '\\b(?:AddCharset|AddEncoding|AddHandler|AddInputFilter|AddLanguage|AddOutputFilter|AddType|DefaultLanguage|ModMimeUsePathInfo|MultiviewsMatch|RemoveCharset|RemoveEncoding|RemoveHandler|RemoveInputFilter|RemoveLanguage|RemoveOutputFilter|RemoveType|TypesConfig)\\b' }, + { token: 'keyword.misc.apacheconf', + regex: '\\b(?:ProtocolEcho|Example|AddModuleInfo|MimeMagicFile|CheckSpelling|ExtendedStatus|SuexecUserGroup|UserDir)\\b' }, + { token: 'keyword.negotiation.apacheconf', + regex: '\\b(?:CacheNegotiatedDocs|ForceLanguagePriority|LanguagePriority)\\b' }, + { token: 'keyword.nw_ssl.apacheconf', + regex: '\\b(?:NWSSLTrustedCerts|NWSSLUpgradeable|SecureListen)\\b' }, + { token: 'keyword.proxy.apacheconf', + regex: '\\b(?:AllowCONNECT|NoProxy|ProxyBadHeader|ProxyBlock|ProxyDomain|ProxyErrorOverride|ProxyFtpDirCharset|ProxyIOBufferSize|ProxyMaxForwards|ProxyPass|ProxyPassReverse|ProxyPreserveHost|ProxyReceiveBufferSize|ProxyRemote|ProxyRemoteMatch|ProxyRequests|ProxyTimeout|ProxyVia)\\b' }, + { token: 'keyword.rewrite.apacheconf', + regex: '\\b(?:RewriteBase|RewriteCond|RewriteEngine|RewriteLock|RewriteLog|RewriteLogLevel|RewriteMap|RewriteOptions|RewriteRule)\\b' }, + { token: 'keyword.setenvif.apacheconf', + regex: '\\b(?:BrowserMatch|BrowserMatchNoCase|SetEnvIf|SetEnvIfNoCase)\\b' }, + { token: 'keyword.so.apacheconf', + regex: '\\b(?:LoadFile|LoadModule)\\b' }, + { token: 'keyword.ssl.apacheconf', + regex: '\\b(?:SSLCACertificateFile|SSLCACertificatePath|SSLCARevocationFile|SSLCARevocationPath|SSLCertificateChainFile|SSLCertificateFile|SSLCertificateKeyFile|SSLCipherSuite|SSLEngine|SSLMutex|SSLOptions|SSLPassPhraseDialog|SSLProtocol|SSLProxyCACertificateFile|SSLProxyCACertificatePath|SSLProxyCARevocationFile|SSLProxyCARevocationPath|SSLProxyCipherSuite|SSLProxyEngine|SSLProxyMachineCertificateFile|SSLProxyMachineCertificatePath|SSLProxyProtocol|SSLProxyVerify|SSLProxyVerifyDepth|SSLRandomSeed|SSLRequire|SSLRequireSSL|SSLSessionCache|SSLSessionCacheTimeout|SSLUserName|SSLVerifyClient|SSLVerifyDepth)\\b' }, + { token: 'keyword.usertrack.apacheconf', + regex: '\\b(?:CookieDomain|CookieExpires|CookieName|CookieStyle|CookieTracking)\\b' }, + { token: 'keyword.vhost_alias.apacheconf', + regex: '\\b(?:VirtualDocumentRoot|VirtualDocumentRootIP|VirtualScriptAlias|VirtualScriptAliasIP)\\b' }, + { token: + [ 'keyword.php.apacheconf', + 'text', + 'entity.property.apacheconf', + 'text', + 'string.value.apacheconf', + 'text' ], + regex: '\\b(php_value|php_flag)\\b(?:(\\s+)(.+?)(?:(\\s+)(.+?))?)?(\\s)' }, + { token: + [ 'punctuation.variable.apacheconf', + 'variable.env.apacheconf', + 'variable.misc.apacheconf', + 'punctuation.variable.apacheconf' ], + regex: '(%\\{)(?:(HTTP_USER_AGENT|HTTP_REFERER|HTTP_COOKIE|HTTP_FORWARDED|HTTP_HOST|HTTP_PROXY_CONNECTION|HTTP_ACCEPT|REMOTE_ADDR|REMOTE_HOST|REMOTE_PORT|REMOTE_USER|REMOTE_IDENT|REQUEST_METHOD|SCRIPT_FILENAME|PATH_INFO|QUERY_STRING|AUTH_TYPE|DOCUMENT_ROOT|SERVER_ADMIN|SERVER_NAME|SERVER_ADDR|SERVER_PORT|SERVER_PROTOCOL|SERVER_SOFTWARE|TIME_YEAR|TIME_MON|TIME_DAY|TIME_HOUR|TIME_MIN|TIME_SEC|TIME_WDAY|TIME|API_VERSION|THE_REQUEST|REQUEST_URI|REQUEST_FILENAME|IS_SUBREQ|HTTPS)|(.*?))(\\})' }, + { token: [ 'entity.mime-type.apacheconf', 'text' ], + regex: '\\b((?:text|image|application|video|audio)/.+?)(\\s)' }, + { token: 'entity.helper.apacheconf', + regex: '\\b(?:from|unset|set|on|off)\\b', + caseInsensitive: true }, + { token: 'constant.integer.apacheconf', regex: '\\b\\d+\\b' }, + { token: + [ 'text', + 'punctuation.definition.flag.apacheconf', + 'string.flag.apacheconf', + 'punctuation.definition.flag.apacheconf', + 'text' ], + regex: '(\\s)(\\[)(.*?)(\\])(\\s)' } ] }; + + this.normalizeRules(); +}; + +ApacheConfHighlightRules.metaData = { fileTypes: + [ 'conf', + 'CONF', + 'htaccess', + 'HTACCESS', + 'htgroups', + 'HTGROUPS', + 'htpasswd', + 'HTPASSWD', + '.htaccess', + '.HTACCESS', + '.htgroups', + '.HTGROUPS', + '.htpasswd', + '.HTPASSWD' ], + name: 'Apache Conf', + scopeName: 'source.apacheconf' }; + + +oop.inherits(ApacheConfHighlightRules, TextHighlightRules); + +exports.ApacheConfHighlightRules = ApacheConfHighlightRules; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/applescript.js b/public/lib/ace/mode/applescript.js new file mode 100644 index 0000000..90a79fb --- /dev/null +++ b/public/lib/ace/mode/applescript.js @@ -0,0 +1,54 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var AppleScriptHighlightRules = require("./applescript_highlight_rules").AppleScriptHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = AppleScriptHighlightRules; + this.foldingRules = new FoldMode(); + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "--"; + this.blockComment = {start: "(*", end: "*)"}; + this.$id = "ace/mode/applescript"; + // Extra logic goes here. +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/applescript_highlight_rules.js b/public/lib/ace/mode/applescript_highlight_rules.js new file mode 100644 index 0000000..6bcad0f --- /dev/null +++ b/public/lib/ace/mode/applescript_highlight_rules.js @@ -0,0 +1,139 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var AppleScriptHighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + var keywords = ( + "about|above|after|against|and|around|as|at|back|before|beginning|" + + "behind|below|beneath|beside|between|but|by|considering|" + + "contain|contains|continue|copy|div|does|eighth|else|end|equal|" + + "equals|error|every|exit|fifth|first|for|fourth|from|front|" + + "get|given|global|if|ignoring|in|into|is|it|its|last|local|me|" + + "middle|mod|my|ninth|not|of|on|onto|or|over|prop|property|put|ref|" + + "reference|repeat|returning|script|second|set|seventh|since|" + + "sixth|some|tell|tenth|that|the|then|third|through|thru|" + + "timeout|times|to|transaction|try|until|where|while|whose|with|without" + ); + + var builtinConstants = ( + "AppleScript|false|linefeed|return|pi|quote|result|space|tab|true" + ); + + var builtinFunctions = ( + "activate|beep|count|delay|launch|log|offset|read|round|run|say|" + + "summarize|write" + ); + + var builtinTypes = ( + "alias|application|boolean|class|constant|date|file|integer|list|" + + "number|real|record|string|text|character|characters|contents|day|" + + "frontmost|id|item|length|month|name|paragraph|paragraphs|rest|" + + "reverse|running|time|version|weekday|word|words|year" + ); + + var keywordMapper = this.createKeywordMapper({ + "support.function": builtinFunctions, + "constant.language": builtinConstants, + "support.type": builtinTypes, + "keyword": keywords + }, "identifier"); + + this.$rules = { + "start": [ + { + token: "comment", + regex: "--.*$" + }, + { + token : "comment", // multi line comment + regex : "\\(\\*", + next : "comment" + }, + { + token: "string", // " string + regex: '".*?"' + }, + { + token: "support.type", + regex: '\\b(POSIX file|POSIX path|(date|time) string|quoted form)\\b' + }, + { + token: "support.function", + regex: '\\b(clipboard info|the clipboard|info for|list (disks|folder)|' + + 'mount volume|path to|(close|open for) access|(get|set) eof|' + + 'current date|do shell script|get volume settings|random number|' + + 'set volume|system attribute|system info|time to GMT|' + + '(load|run|store) script|scripting components|' + + 'ASCII (character|number)|localized string|' + + 'choose (application|color|file|file name|' + + 'folder|from list|remote application|URL)|' + + 'display (alert|dialog))\\b|^\\s*return\\b' + }, + { + token: "constant.language", + regex: '\\b(text item delimiters|current application|missing value)\\b' + }, + { + token: "keyword", + regex: '\\b(apart from|aside from|instead of|out of|greater than|' + + "isn't|(doesn't|does not) (equal|come before|come after|contain)|" + + '(greater|less) than( or equal)?|(starts?|ends|begins?) with|' + + 'contained by|comes (before|after)|a (ref|reference))\\b' + }, + { + token: keywordMapper, + regex: "[a-zA-Z][a-zA-Z0-9_]*\\b" + } + ], + "comment": [ + { + token: "comment", // closing comment + regex: "\\*\\)", + next: "start" + }, { + defaultToken: "comment" + } + ] + }; + + this.normalizeRules(); +}; + +oop.inherits(AppleScriptHighlightRules, TextHighlightRules); + +exports.AppleScriptHighlightRules = AppleScriptHighlightRules; +}); diff --git a/public/lib/ace/mode/asciidoc.js b/public/lib/ace/mode/asciidoc.js new file mode 100644 index 0000000..894d976 --- /dev/null +++ b/public/lib/ace/mode/asciidoc.js @@ -0,0 +1,64 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var AsciidocHighlightRules = require("./asciidoc_highlight_rules").AsciidocHighlightRules; +var AsciidocFoldMode = require("./folding/asciidoc").FoldMode; + +var Mode = function() { + this.HighlightRules = AsciidocHighlightRules; + + this.foldingRules = new AsciidocFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.type = "text"; + this.getNextLineIndent = function(state, line, tab) { + if (state == "listblock") { + var match = /^((?:.+)?)([-+*][ ]+)/.exec(line); + if (match) { + return new Array(match[1].length + 1).join(" ") + match[2]; + } else { + return ""; + } + } else { + return this.$getIndent(line); + } + }; + this.$id = "ace/mode/asciidoc"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/asciidoc_highlight_rules.js b/public/lib/ace/mode/asciidoc_highlight_rules.js new file mode 100644 index 0000000..4e5fdcb --- /dev/null +++ b/public/lib/ace/mode/asciidoc_highlight_rules.js @@ -0,0 +1,234 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var AsciidocHighlightRules = function() { + var identifierRe = "[a-zA-Z\u00a1-\uffff]+\\b"; + + this.$rules = { + "start": [ + {token: "empty", regex: /$/}, + {token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock"}, + {token: "literal", regex: /^-{4,}\s*$/, next: "literalBlock"}, + {token: "string", regex: /^\+{4,}\s*$/, next: "passthroughBlock"}, + {token: "keyword", regex: /^={4,}\s*$/}, + {token: "text", regex: /^\s*$/}, + // immediately return to the start mode without matching anything + {token: "empty", regex: "", next: "dissallowDelimitedBlock"} + ], + + "dissallowDelimitedBlock": [ + {include: "paragraphEnd"}, + {token: "comment", regex: '^//.+$'}, + {token: "keyword", regex: "^(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION):"}, + + {include: "listStart"}, + {token: "literal", regex: /^\s+.+$/, next: "indentedBlock"}, + {token: "empty", regex: "", next: "text"} + ], + + "paragraphEnd": [ + {token: "doc.comment", regex: /^\/{4,}\s*$/, next: "commentBlock"}, + {token: "tableBlock", regex: /^\s*[|!]=+\s*$/, next: "tableBlock"}, + // open block, ruller + {token: "keyword", regex: /^(?:--|''')\s*$/, next: "start"}, + {token: "option", regex: /^\[.*\]\s*$/, next: "start"}, + {token: "pageBreak", regex: /^>{3,}$/, next: "start"}, + {token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock"}, + {token: "titleUnderline", regex: /^(?:={2,}|-{2,}|~{2,}|\^{2,}|\+{2,})\s*$/, next: "start"}, + {token: "singleLineTitle", regex: /^={1,5}\s+\S.*$/, next: "start"}, + + {token: "otherBlock", regex: /^(?:\*{2,}|_{2,})\s*$/, next: "start"}, + // .optional title + {token: "optionalTitle", regex: /^\.[^.\s].+$/, next: "start"} + ], + + "listStart": [ + {token: "keyword", regex: /^\s*(?:\d+\.|[a-zA-Z]\.|[ixvmIXVM]+\)|\*{1,5}|-|\.{1,5})\s/, next: "listText"}, + {token: "meta.tag", regex: /^.+(?::{2,4}|;;)(?: |$)/, next: "listText"}, + {token: "support.function.list.callout", regex: /^(?:<\d+>|\d+>|>) /, next: "text"}, + // continuation + {token: "keyword", regex: /^\+\s*$/, next: "start"} + ], + + "text": [ + {token: ["link", "variable.language"], regex: /((?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+)(\[.*?\])/}, + {token: "link", regex: /(?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+/}, + {token: "link", regex: /\b[\w\.\/\-]+@[\w\.\/\-]+\b/}, + {include: "macros"}, + {include: "paragraphEnd"}, + {token: "literal", regex:/\+{3,}/, next:"smallPassthrough"}, + {token: "escape", regex: /\((?:C|TM|R)\)|\.{3}|->|<-|=>|<=|&#(?:\d+|x[a-fA-F\d]+);|(?: |^)--(?=\s+\S)/}, + {token: "escape", regex: /\\[_*'`+#]|\\{2}[_*'`+#]{2}/}, + {token: "keyword", regex: /\s\+$/}, + // any word + {token: "text", regex: identifierRe}, + {token: ["keyword", "string", "keyword"], + regex: /(<<[\w\d\-$]+,)(.*?)(>>|$)/}, + {token: "keyword", regex: /<<[\w\d\-$]+,?|>>/}, + {token: "constant.character", regex: /\({2,3}.*?\){2,3}/}, + // Anchor + {token: "keyword", regex: /\[\[.+?\]\]/}, + // bibliography + {token: "support", regex: /^\[{3}[\w\d =\-]+\]{3}/}, + + {include: "quotes"}, + // text block end + {token: "empty", regex: /^\s*$/, next: "start"} + ], + + "listText": [ + {include: "listStart"}, + {include: "text"} + ], + + "indentedBlock": [ + {token: "literal", regex: /^[\s\w].+$/, next: "indentedBlock"}, + {token: "literal", regex: "", next: "start"} + ], + + "listingBlock": [ + {token: "literal", regex: /^\.{4,}\s*$/, next: "dissallowDelimitedBlock"}, + {token: "constant.numeric", regex: '<\\d+>'}, + {token: "literal", regex: '[^<]+'}, + {token: "literal", regex: '<'} + ], + "literalBlock": [ + {token: "literal", regex: /^-{4,}\s*$/, next: "dissallowDelimitedBlock"}, + {token: "constant.numeric", regex: '<\\d+>'}, + {token: "literal", regex: '[^<]+'}, + {token: "literal", regex: '<'} + ], + "passthroughBlock": [ + {token: "literal", regex: /^\+{4,}\s*$/, next: "dissallowDelimitedBlock"}, + {token: "literal", regex: identifierRe + "|\\d+"}, + {include: "macros"}, + {token: "literal", regex: "."} + ], + + "smallPassthrough": [ + {token: "literal", regex: /[+]{3,}/, next: "dissallowDelimitedBlock"}, + {token: "literal", regex: /^\s*$/, next: "dissallowDelimitedBlock"}, + {token: "literal", regex: identifierRe + "|\\d+"}, + {include: "macros"} + ], + + "commentBlock": [ + {token: "doc.comment", regex: /^\/{4,}\s*$/, next: "dissallowDelimitedBlock"}, + {token: "doc.comment", regex: '^.*$'} + ], + "tableBlock": [ + {token: "tableBlock", regex: /^\s*\|={3,}\s*$/, next: "dissallowDelimitedBlock"}, + {token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "innerTableBlock"}, + {token: "tableBlock", regex: /\|/}, + {include: "text", noEscape: true} + ], + "innerTableBlock": [ + {token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "tableBlock"}, + {token: "tableBlock", regex: /^\s*|={3,}\s*$/, next: "dissallowDelimitedBlock"}, + {token: "tableBlock", regex: /!/} + ], + "macros": [ + {token: "macro", regex: /{[\w\-$]+}/}, + {token: ["text", "string", "text", "constant.character", "text"], regex: /({)([\w\-$]+)(:)?(.+)?(})/}, + {token: ["text", "markup.list.macro", "keyword", "string"], regex: /(\w+)(footnote(?:ref)?::?)([^\s\[]+)?(\[.*?\])?/}, + {token: ["markup.list.macro", "keyword", "string"], regex: /([a-zA-Z\-][\w\.\/\-]*::?)([^\s\[]+)(\[.*?\])?/}, + {token: ["markup.list.macro", "keyword"], regex: /([a-zA-Z\-][\w\.\/\-]+::?)(\[.*?\])/}, + {token: "keyword", regex: /^:.+?:(?= |$)/} + ], + + "quotes": [ + {token: "string.italic", regex: /__[^_\s].*?__/}, + {token: "string.italic", regex: quoteRule("_")}, + + {token: "keyword.bold", regex: /\*\*[^*\s].*?\*\*/}, + {token: "keyword.bold", regex: quoteRule("\\*")}, + + {token: "literal", regex: quoteRule("\\+")}, + {token: "literal", regex: /\+\+[^+\s].*?\+\+/}, + {token: "literal", regex: /\$\$.+?\$\$/}, + {token: "literal", regex: quoteRule("`")}, + + {token: "keyword", regex: quoteRule("^")}, + {token: "keyword", regex: quoteRule("~")}, + {token: "keyword", regex: /##?/}, + {token: "keyword", regex: /(?:\B|^)``|\b''/} + ] + + }; + + function quoteRule(ch) { + var prefix = /\w/.test(ch) ? "\\b" : "(?:\\B|^)"; + return prefix + ch + "[^" + ch + "].*?" + ch + "(?![\\w*])"; + } + + //addQuoteBlock("text") + + var tokenMap = { + macro: "constant.character", + tableBlock: "doc.comment", + titleUnderline: "markup.heading", + singleLineTitle: "markup.heading", + pageBreak: "string", + option: "string.regexp", + otherBlock: "markup.list", + literal: "support.function", + optionalTitle: "constant.numeric", + escape: "constant.language.escape", + link: "markup.underline.list" + }; + + for (var state in this.$rules) { + var stateRules = this.$rules[state]; + for (var i = stateRules.length; i--; ) { + var rule = stateRules[i]; + if (rule.include || typeof rule == "string") { + var args = [i, 1].concat(this.$rules[rule.include || rule]); + if (rule.noEscape) { + args = args.filter(function(x) { + return !x.next; + }); + } + stateRules.splice.apply(stateRules, args); + } else if (rule.token in tokenMap) { + rule.token = tokenMap[rule.token]; + } + } + } +}; +oop.inherits(AsciidocHighlightRules, TextHighlightRules); + +exports.AsciidocHighlightRules = AsciidocHighlightRules; +}); diff --git a/public/lib/ace/mode/assembly_x86.js b/public/lib/ace/mode/assembly_x86.js new file mode 100644 index 0000000..21858f4 --- /dev/null +++ b/public/lib/ace/mode/assembly_x86.js @@ -0,0 +1,57 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js +*/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var AssemblyX86HighlightRules = require("./assembly_x86_highlight_rules").AssemblyX86HighlightRules; +var FoldMode = require("./folding/coffee").FoldMode; + +var Mode = function() { + this.HighlightRules = AssemblyX86HighlightRules; + this.foldingRules = new FoldMode(); + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = ";"; + this.$id = "ace/mode/assembly_x86"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/assembly_x86_highlight_rules.js b/public/lib/ace/mode/assembly_x86_highlight_rules.js new file mode 100644 index 0000000..ab11288 --- /dev/null +++ b/public/lib/ace/mode/assembly_x86_highlight_rules.js @@ -0,0 +1,114 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* This file was autogenerated from Assembly x86.tmLanguage (uuid: ) */ +/**************************************************************************************** + * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * + * fileTypes * + ****************************************************************************************/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var AssemblyX86HighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { start: + [ { token: 'keyword.control.assembly', + regex: '\\b(?:aaa|aad|aam|aas|adc|add|addpd|addps|addsd|addss|addsubpd|addsubps|aesdec|aesdeclast|aesenc|aesenclast|aesimc|aeskeygenassist|and|andpd|andps|andnpd|andnps|arpl|blendpd|blendps|blendvpd|blendvps|bound|bsf|bsr|bswap|bt|btc|btr|bts|cbw|cwde|cdqe|clc|cld|cflush|clts|cmc|cmov(?:n?e|ge?|ae?|le?|be?|n?o|n?z)|cmp|cmppd|cmpps|cmps|cnpsb|cmpsw|cmpsd|cmpsq|cmpss|cmpxchg|cmpxchg8b|cmpxchg16b|comisd|comiss|cpuid|crc32|cvtdq2pd|cvtdq2ps|cvtpd2dq|cvtpd2pi|cvtpd2ps|cvtpi2pd|cvtpi2ps|cvtps2dq|cvtps2pd|cvtps2pi|cvtsd2si|cvtsd2ss|cvts2sd|cvtsi2ss|cvtss2sd|cvtss2si|cvttpd2dq|cvtpd2pi|cvttps2dq|cvttps2pi|cvttps2dq|cvttps2pi|cvttsd2si|cvttss2si|cwd|cdq|cqo|daa|das|dec|div|divpd|divps|divsd|divss|dppd|dpps|emms|enter|extractps|f2xm1|fabs|fadd|faddp|fiadd|fbld|fbstp|fchs|fclex|fnclex|fcmov(?:n?e|ge?|ae?|le?|be?|n?o|n?z)|fcom|fcmop|fcompp|fcomi|fcomip|fucomi|fucomip|fcos|fdecstp|fdiv|fdivp|fidiv|fdivr|fdivrp|fidivr|ffree|ficom|ficomp|fild|fincstp|finit|fnint|fist|fistp|fisttp|fld|fld1|fldl2t|fldl2e|fldpi|fldlg2|fldln2|fldz|fldcw|fldenv|fmul|fmulp|fimul|fnop|fpatan|fprem|fprem1|fptan|frndint|frstor|fsave|fnsave|fscale|fsin|fsincos|fsqrt|fst|fstp|fstcw|fnstcw|fstenv|fnstenv|fsts|fnstsw|fsub|fsubp|fisub|fsubr|fsubrp|fisubr|ftst|fucom|fucomp|fucompp|fxam|fxch|fxrstor|fxsave|fxtract|fyl2x|fyl2xp1|haddpd|haddps|husbpd|hsubps|idiv|imul|in|inc|ins|insb|insw|insd|insertps|int|into|invd|invplg|invpcid|iret|iretd|iretq|lahf|lar|lddqu|ldmxcsr|lds|les|lfs|lgs|lss|lea|leave|lfence|lgdt|lidt|llgdt|lmsw|lock|lods|lodsb|lodsw|lodsd|lodsq|lsl|ltr|maskmovdqu|maskmovq|maxpd|maxps|maxsd|maxss|mfence|minpd|minps|minsd|minss|monitor|mov|movapd|movaps|movbe|movd|movq|movddup|movdqa|movdqu|movq2q|movhlps|movhpd|movhps|movlhps|movlpd|movlps|movmskpd|movmskps|movntdqa|movntdq|movnti|movntpd|movntps|movntq|movq|movq2dq|movs|movsb|movsw|movsd|movsq|movsd|movshdup|movsldup|movss|movsx|movsxd|movupd|movups|movzx|mpsadbw|mul|mulpd|mulps|mulsd|mulss|mwait|neg|not|or|orpd|orps|out|outs|outsb|outsw|outsd|pabsb|pabsw|pabsd|packsswb|packssdw|packusdw|packuswbpaddb|paddw|paddd|paddq|paddsb|paddsw|paddusb|paddusw|palignr|pand|pandn|pause|pavgb|pavgw|pblendvb|pblendw|pclmulqdq|pcmpeqb|pcmpeqw|pcmpeqd|pcmpeqq|pcmpestri|pcmpestrm|pcmptb|pcmptgw|pcmpgtd|pcmpgtq|pcmpistri|pcmpisrm|pextrb|pextrd|pextrq|pextrw|phaddw|phaddd|phaddsw|phinposuw|phsubw|phsubd|phsubsw|pinsrb|pinsrd|pinsrq|pinsrw|pmaddubsw|pmadddwd|pmaxsb|pmaxsd|pmaxsw|pmaxsw|pmaxub|pmaxud|pmaxuw|pminsb|pminsd|pminsw|pminub|pminud|pminuw|pmovmskb|pmovsx|pmovzx|pmuldq|pmulhrsw|pmulhuw|pmulhw|pmulld|pmullw|pmuludw|pop|popa|popad|popcnt|popf|popfd|popfq|por|prefetch|psadbw|pshufb|pshufd|pshufhw|pshuflw|pshufw|psignb|psignw|psignd|pslldq|psllw|pslld|psllq|psraw|psrad|psrldq|psrlw|psrld|psrlq|psubb|psubw|psubd|psubq|psubsb|psubsw|psubusb|psubusw|test|ptest|punpckhbw|punpckhwd|punpckhdq|punpckhddq|punpcklbw|punpcklwd|punpckldq|punpckldqd|push|pusha|pushad|pushf|pushfd|pxor|prcl|rcr|rol|ror|rcpps|rcpss|rdfsbase|rdgsbase|rdmsr|rdpmc|rdrand|rdtsc|rdtscp|rep|repe|repz|repne|repnz|roundpd|roundps|roundsd|roundss|rsm|rsqrps|rsqrtss|sahf|sal|sar|shl|shr|sbb|scas|scasb|scasw|scasd|set(?:n?e|ge?|ae?|le?|be?|n?o|n?z)|sfence|sgdt|shld|shrd|shufpd|shufps|sidt|sldt|smsw|sqrtpd|sqrtps|sqrtsd|sqrtss|stc|std|stmxcsr|stos|stosb|stosw|stosd|stosq|str|sub|subpd|subps|subsd|subss|swapgs|syscall|sysenter|sysexit|sysret|teset|ucomisd|ucomiss|ud2|unpckhpd|unpckhps|unpcklpd|unpcklps|vbroadcast|vcvtph2ps|vcvtp2sph|verr|verw|vextractf128|vinsertf128|vmaskmov|vpermilpd|vpermilps|vperm2f128|vtestpd|vtestps|vzeroall|vzeroupper|wait|fwait|wbinvd|wrfsbase|wrgsbase|wrmsr|xadd|xchg|xgetbv|xlat|xlatb|xor|xorpd|xorps|xrstor|xsave|xsaveopt|xsetbv|lzcnt|extrq|insertq|movntsd|movntss|vfmaddpd|vfmaddps|vfmaddsd|vfmaddss|vfmaddsubbpd|vfmaddsubps|vfmsubaddpd|vfmsubaddps|vfmsubpd|vfmsubps|vfmsubsd|vfnmaddpd|vfnmaddps|vfnmaddsd|vfnmaddss|vfnmsubpd|vfnmusbps|vfnmusbsd|vfnmusbss|cvt|xor|cli|sti|hlt|nop|lock|wait|enter|leave|ret|loop(?:n?e|n?z)?|call|j(?:mp|n?e|ge?|ae?|le?|be?|n?o|n?z))\\b', + caseInsensitive: true }, + { token: 'variable.parameter.register.assembly', + regex: '\\b(?:CS|DS|ES|FS|GS|SS|RAX|EAX|RBX|EBX|RCX|ECX|RDX|EDX|RCX|RIP|EIP|IP|RSP|ESP|SP|RSI|ESI|SI|RDI|EDI|DI|RFLAGS|EFLAGS|FLAGS|R8-15|(?:Y|X)MM(?:[0-9]|10|11|12|13|14|15)|(?:A|B|C|D)(?:X|H|L)|CR(?:[0-4]|DR(?:[0-7]|TR6|TR7|EFER)))\\b', + caseInsensitive: true }, + { token: 'constant.character.decimal.assembly', + regex: '\\b[0-9]+\\b' }, + { token: 'constant.character.hexadecimal.assembly', + regex: '\\b0x[A-F0-9]+\\b', + caseInsensitive: true }, + { token: 'constant.character.hexadecimal.assembly', + regex: '\\b[A-F0-9]+h\\b', + caseInsensitive: true }, + { token: 'string.assembly', regex: /'([^\\']|\\.)*'/ }, + { token: 'string.assembly', regex: /"([^\\"]|\\.)*"/ }, + { token: 'support.function.directive.assembly', + regex: '^\\[', + push: + [ { token: 'support.function.directive.assembly', + regex: '\\]$', + next: 'pop' }, + { defaultToken: 'support.function.directive.assembly' } ] }, + { token: + [ 'support.function.directive.assembly', + 'support.function.directive.assembly', + 'entity.name.function.assembly' ], + regex: '(^struc)( )([_a-zA-Z][_a-zA-Z0-9]*)' }, + { token: 'support.function.directive.assembly', + regex: '^endstruc\\b' }, + { token: + [ 'support.function.directive.assembly', + 'entity.name.function.assembly', + 'support.function.directive.assembly', + 'constant.character.assembly' ], + regex: '^(%macro )([_a-zA-Z][_a-zA-Z0-9]*)( )([0-9]+)' }, + { token: 'support.function.directive.assembly', + regex: '^%endmacro' }, + { token: + [ 'text', + 'support.function.directive.assembly', + 'text', + 'entity.name.function.assembly' ], + regex: '(\\s*)(%define|%xdefine|%idefine|%undef|%assign|%defstr|%strcat|%strlen|%substr|%00|%0|%rotate|%rep|%endrep|%include|\\$\\$|\\$|%unmacro|%if|%elif|%else|%endif|%(?:el)?ifdef|%(?:el)?ifmacro|%(?:el)?ifctx|%(?:el)?ifidn|%(?:el)?ifidni|%(?:el)?ifid|%(?:el)?ifnum|%(?:el)?ifstr|%(?:el)?iftoken|%(?:el)?ifempty|%(?:el)?ifenv|%pathsearch|%depend|%use|%push|%pop|%repl|%arg|%stacksize|%local|%error|%warning|%fatal|%line|%!|%comment|%endcomment|__NASM_VERSION_ID__|__NASM_VER__|__FILE__|__LINE__|__BITS__|__OUTPUT_FORMAT__|__DATE__|__TIME__|__DATE_NUM__|_TIME__NUM__|__UTC_DATE__|__UTC_TIME__|__UTC_DATE_NUM__|__UTC_TIME_NUM__|__POSIX_TIME__|__PASS__|ISTRUC|AT|IEND|BITS 16|BITS 32|BITS 64|USE16|USE32|__SECT__|ABSOLUTE|EXTERN|GLOBAL|COMMON|CPU|FLOAT)\\b( ?)((?:[_a-zA-Z][_a-zA-Z0-9]*)?)', + caseInsensitive: true }, + { token: 'support.function.directive.assembly', + regex: '\\b(?:d[bwdqtoy]|res[bwdqto]|equ|times|align|alignb|sectalign|section|ptr|byte|word|dword|qword|incbin)\\b', + caseInsensitive: true }, + { token: 'entity.name.function.assembly', regex: '^\\s*%%[\\w.]+?:$' }, + { token: 'entity.name.function.assembly', regex: '^\\s*%\\$[\\w.]+?:$' }, + { token: 'entity.name.function.assembly', regex: '^[\\w.]+?:' }, + { token: 'entity.name.function.assembly', regex: '^[\\w.]+?\\b' }, + { token: 'comment.assembly', regex: ';.*$' } ] + }; + + this.normalizeRules(); +}; + +AssemblyX86HighlightRules.metaData = { fileTypes: [ 'asm' ], + name: 'Assembly x86', + scopeName: 'source.assembly' }; + + +oop.inherits(AssemblyX86HighlightRules, TextHighlightRules); + +exports.AssemblyX86HighlightRules = AssemblyX86HighlightRules; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/autohotkey.js b/public/lib/ace/mode/autohotkey.js new file mode 100644 index 0000000..3ac647c --- /dev/null +++ b/public/lib/ace/mode/autohotkey.js @@ -0,0 +1,57 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js +*/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var AutoHotKeyHighlightRules = require("./autohotkey_highlight_rules").AutoHotKeyHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = AutoHotKeyHighlightRules; + this.foldingRules = new FoldMode(); + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = ";"; + this.blockComment = {start: "/*", end: "*/"}; + this.$id = "ace/mode/autohotkey"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/autohotkey_highlight_rules.js b/public/lib/ace/mode/autohotkey_highlight_rules.js new file mode 100644 index 0000000..a4b6638 --- /dev/null +++ b/public/lib/ace/mode/autohotkey_highlight_rules.js @@ -0,0 +1,107 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* This file was autogenerated from C:\Users\LED\Desktop\AutoHotKey.tmLanguage (uuid: ) */ +/**************************************************************************************** + * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * + * fileTypes * + ****************************************************************************************/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var AutoHotKeyHighlightRules = function() { + var autoItKeywords = 'And|ByRef|Case|Const|ContinueCase|ContinueLoop|Default|Dim|Do|Else|ElseIf|EndFunc|EndIf|EndSelect|EndSwitch|EndWith|Enum|Exit|ExitLoop|False|For|Func|Global|If|In|Local|Next|Not|Or|ReDim|Return|Select|Step|Switch|Then|To|True|Until|WEnd|While|With|' + + 'Abs|ACos|AdlibDisable|AdlibEnable|Asc|AscW|ASin|Assign|ATan|AutoItSetOption|AutoItWinGetTitle|AutoItWinSetTitle|Beep|Binary|BinaryLen|BinaryMid|BinaryToString|BitAND|BitNOT|BitOR|BitRotate|BitShift|BitXOR|BlockInput|Break|Call|CDTray|Ceiling|Chr|ChrW|ClipGet|ClipPut|ConsoleRead|ConsoleWrite|ConsoleWriteError|ControlClick|ControlCommand|ControlDisable|ControlEnable|ControlFocus|ControlGetFocus|ControlGetHandle|ControlGetPos|ControlGetText|ControlHide|ControlListView|ControlMove|ControlSend|ControlSetText|ControlShow|ControlTreeView|Cos|Dec|DirCopy|DirCreate|DirGetSize|DirMove|DirRemove|DllCall|DllCallbackFree|DllCallbackGetPtr|DllCallbackRegister|DllClose|DllOpen|DllStructCreate|DllStructGetData|DllStructGetPtr|DllStructGetSize|DllStructSetData|DriveGetDrive|DriveGetFileSystem|DriveGetLabel|DriveGetSerial|DriveGetType|DriveMapAdd|DriveMapDel|DriveMapGet|DriveSetLabel|DriveSpaceFree|DriveSpaceTotal|DriveStatus|EnvGet|EnvSet|EnvUpdate|Eval|Execute|Exp|FileChangeDir|FileClose|FileCopy|FileCreateNTFSLink|FileCreateShortcut|FileDelete|FileExists|FileFindFirstFile|FileFindNextFile|FileGetAttrib|FileGetLongName|FileGetShortcut|FileGetShortName|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileOpen|FileOpenDialog|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileSaveDialog|FileSelectFolder|FileSetAttrib|FileSetTime|FileWrite|FileWriteLine|Floor|FtpSetProxy|GUICreate|GUICtrlCreateAvi|GUICtrlCreateButton|GUICtrlCreateCheckbox|GUICtrlCreateCombo|GUICtrlCreateContextMenu|GUICtrlCreateDate|GUICtrlCreateDummy|GUICtrlCreateEdit|GUICtrlCreateGraphic|GUICtrlCreateGroup|GUICtrlCreateIcon|GUICtrlCreateInput|GUICtrlCreateLabel|GUICtrlCreateList|GUICtrlCreateListView|GUICtrlCreateListViewItem|GUICtrlCreateMenu|GUICtrlCreateMenuItem|GUICtrlCreateMonthCal|GUICtrlCreateObj|GUICtrlCreatePic|GUICtrlCreateProgress|GUICtrlCreateRadio|GUICtrlCreateSlider|GUICtrlCreateTab|GUICtrlCreateTabItem|GUICtrlCreateTreeView|GUICtrlCreateTreeViewItem|GUICtrlCreateUpdown|GUICtrlDelete|GUICtrlGetHandle|GUICtrlGetState|GUICtrlRead|GUICtrlRecvMsg|GUICtrlRegisterListViewSort|GUICtrlSendMsg|GUICtrlSendToDummy|GUICtrlSetBkColor|GUICtrlSetColor|GUICtrlSetCursor|GUICtrlSetData|GUICtrlSetFont|GUICtrlSetDefColor|GUICtrlSetDefBkColor|GUICtrlSetGraphic|GUICtrlSetImage|GUICtrlSetLimit|GUICtrlSetOnEvent|GUICtrlSetPos|GUICtrlSetResizing|GUICtrlSetState|GUICtrlSetStyle|GUICtrlSetTip|GUIDelete|GUIGetCursorInfo|GUIGetMsg|GUIGetStyle|GUIRegisterMsg|GUISetAccelerators()|GUISetBkColor|GUISetCoord|GUISetCursor|GUISetFont|GUISetHelp|GUISetIcon|GUISetOnEvent|GUISetState|GUISetStyle|GUIStartGroup|GUISwitch|Hex|HotKeySet|HttpSetProxy|HWnd|InetGet|InetGetSize|IniDelete|IniRead|IniReadSection|IniReadSectionNames|IniRenameSection|IniWrite|IniWriteSection|InputBox|Int|IsAdmin|IsArray|IsBinary|IsBool|IsDeclared|IsDllStruct|IsFloat|IsHWnd|IsInt|IsKeyword|IsNumber|IsObj|IsPtr|IsString|Log|MemGetStats|Mod|MouseClick|MouseClickDrag|MouseDown|MouseGetCursor|MouseGetPos|MouseMove|MouseUp|MouseWheel|MsgBox|Number|ObjCreate|ObjEvent|ObjGet|ObjName|Opt|Ping|PixelChecksum|PixelGetColor|PixelSearch|PluginClose|PluginOpen|ProcessClose|ProcessExists|ProcessGetStats|ProcessList|ProcessSetPriority|ProcessWait|ProcessWaitClose|ProgressOff|ProgressOn|ProgressSet|Ptr|Random|RegDelete|RegEnumKey|RegEnumVal|RegRead|RegWrite|Round|Run|RunAs|RunAsWait|RunWait|Send|SendKeepActive|SetError|SetExtended|ShellExecute|ShellExecuteWait|Shutdown|Sin|Sleep|SoundPlay|SoundSetWaveVolume|SplashImageOn|SplashOff|SplashTextOn|Sqrt|SRandom|StatusbarGetText|StderrRead|StdinWrite|StdioClose|StdoutRead|String|StringAddCR|StringCompare|StringFormat|StringInStr|StringIsAlNum|StringIsAlpha|StringIsASCII|StringIsDigit|StringIsFloat|StringIsInt|StringIsLower|StringIsSpace|StringIsUpper|StringIsXDigit|StringLeft|StringLen|StringLower|StringMid|StringRegExp|StringRegExpReplace|StringReplace|StringRight|StringSplit|StringStripCR|StringStripWS|StringToBinary|StringTrimLeft|StringTrimRight|StringUpper|Tan|TCPAccept|TCPCloseSocket|TCPConnect|TCPListen|TCPNameToIP|TCPRecv|TCPSend|TCPShutdown|TCPStartup|TimerDiff|TimerInit|ToolTip|TrayCreateItem|TrayCreateMenu|TrayGetMsg|TrayItemDelete|TrayItemGetHandle|TrayItemGetState|TrayItemGetText|TrayItemSetOnEvent|TrayItemSetState|TrayItemSetText|TraySetClick|TraySetIcon|TraySetOnEvent|TraySetPauseIcon|TraySetState|TraySetToolTip|TrayTip|UBound|UDPBind|UDPCloseSocket|UDPOpen|UDPRecv|UDPSend|UDPShutdown|UDPStartup|VarGetType|WinActivate|WinActive|WinClose|WinExists|WinFlash|WinGetCaretPos|WinGetClassList|WinGetClientSize|WinGetHandle|WinGetPos|WinGetProcess|WinGetState|WinGetText|WinGetTitle|WinKill|WinList|WinMenuSelectItem|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinSetOnTop|WinSetState|WinSetTitle|WinSetTrans|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive|' + + 'ArrayAdd|ArrayBinarySearch|ArrayConcatenate|ArrayDelete|ArrayDisplay|ArrayFindAll|ArrayInsert|ArrayMax|ArrayMaxIndex|ArrayMin|ArrayMinIndex|ArrayPop|ArrayPush|ArrayReverse|ArraySearch|ArraySort|ArraySwap|ArrayToClip|ArrayToString|ArrayTrim|ChooseColor|ChooseFont|ClipBoard_ChangeChain|ClipBoard_Close|ClipBoard_CountFormats|ClipBoard_Empty|ClipBoard_EnumFormats|ClipBoard_FormatStr|ClipBoard_GetData|ClipBoard_GetDataEx|ClipBoard_GetFormatName|ClipBoard_GetOpenWindow|ClipBoard_GetOwner|ClipBoard_GetPriorityFormat|ClipBoard_GetSequenceNumber|ClipBoard_GetViewer|ClipBoard_IsFormatAvailable|ClipBoard_Open|ClipBoard_RegisterFormat|ClipBoard_SetData|ClipBoard_SetDataEx|ClipBoard_SetViewer|ClipPutFile|ColorConvertHSLtoRGB|ColorConvertRGBtoHSL|ColorGetBlue|ColorGetGreen|ColorGetRed|Date_Time_CompareFileTime|Date_Time_DOSDateTimeToArray|Date_Time_DOSDateTimeToFileTime|Date_Time_DOSDateTimeToStr|Date_Time_DOSDateToArray|Date_Time_DOSDateToStr|Date_Time_DOSTimeToArray|Date_Time_DOSTimeToStr|Date_Time_EncodeFileTime|Date_Time_EncodeSystemTime|Date_Time_FileTimeToArray|Date_Time_FileTimeToDOSDateTime|Date_Time_FileTimeToLocalFileTime|Date_Time_FileTimeToStr|Date_Time_FileTimeToSystemTime|Date_Time_GetFileTime|Date_Time_GetLocalTime|Date_Time_GetSystemTime|Date_Time_GetSystemTimeAdjustment|Date_Time_GetSystemTimeAsFileTime|Date_Time_GetSystemTimes|Date_Time_GetTickCount|Date_Time_GetTimeZoneInformation|Date_Time_LocalFileTimeToFileTime|Date_Time_SetFileTime|Date_Time_SetLocalTime|Date_Time_SetSystemTime|Date_Time_SetSystemTimeAdjustment|Date_Time_SetTimeZoneInformation|Date_Time_SystemTimeToArray|Date_Time_SystemTimeToDateStr|Date_Time_SystemTimeToDateTimeStr|Date_Time_SystemTimeToFileTime|Date_Time_SystemTimeToTimeStr|Date_Time_SystemTimeToTzSpecificLocalTime|Date_Time_TzSpecificLocalTimeToSystemTime|DateAdd|DateDayOfWeek|DateDaysInMonth|DateDiff|DateIsLeapYear|DateIsValid|DateTimeFormat|DateTimeSplit|DateToDayOfWeek|DateToDayOfWeekISO|DateToDayValue|DateToMonth|DayValueToDate|DebugBugReportEnv|DebugOut|DebugSetup|Degree|EventLog__Backup|EventLog__Clear|EventLog__Close|EventLog__Count|EventLog__DeregisterSource|EventLog__Full|EventLog__Notify|EventLog__Oldest|EventLog__Open|EventLog__OpenBackup|EventLog__Read|EventLog__RegisterSource|EventLog__Report|FileCountLines|FileCreate|FileListToArray|FilePrint|FileReadToArray|FileWriteFromArray|FileWriteLog|FileWriteToLine|GDIPlus_ArrowCapCreate|GDIPlus_ArrowCapDispose|GDIPlus_ArrowCapGetFillState|GDIPlus_ArrowCapGetHeight|GDIPlus_ArrowCapGetMiddleInset|GDIPlus_ArrowCapGetWidth|GDIPlus_ArrowCapSetFillState|GDIPlus_ArrowCapSetHeight|GDIPlus_ArrowCapSetMiddleInset|GDIPlus_ArrowCapSetWidth|GDIPlus_BitmapCloneArea|GDIPlus_BitmapCreateFromFile|GDIPlus_BitmapCreateFromGraphics|GDIPlus_BitmapCreateFromHBITMAP|GDIPlus_BitmapCreateHBITMAPFromBitmap|GDIPlus_BitmapDispose|GDIPlus_BitmapLockBits|GDIPlus_BitmapUnlockBits|GDIPlus_BrushClone|GDIPlus_BrushCreateSolid|GDIPlus_BrushDispose|GDIPlus_BrushGetType|GDIPlus_CustomLineCapDispose|GDIPlus_Decoders|GDIPlus_DecodersGetCount|GDIPlus_DecodersGetSize|GDIPlus_Encoders|GDIPlus_EncodersGetCLSID|GDIPlus_EncodersGetCount|GDIPlus_EncodersGetParamList|GDIPlus_EncodersGetParamListSize|GDIPlus_EncodersGetSize|GDIPlus_FontCreate|GDIPlus_FontDispose|GDIPlus_FontFamilyCreate|GDIPlus_FontFamilyDispose|GDIPlus_GraphicsClear|GDIPlus_GraphicsCreateFromHDC|GDIPlus_GraphicsCreateFromHWND|GDIPlus_GraphicsDispose|GDIPlus_GraphicsDrawArc|GDIPlus_GraphicsDrawBezier|GDIPlus_GraphicsDrawClosedCurve|GDIPlus_GraphicsDrawCurve|GDIPlus_GraphicsDrawEllipse|GDIPlus_GraphicsDrawImage|GDIPlus_GraphicsDrawImageRect|GDIPlus_GraphicsDrawImageRectRect|GDIPlus_GraphicsDrawLine|GDIPlus_GraphicsDrawPie|GDIPlus_GraphicsDrawPolygon|GDIPlus_GraphicsDrawRect|GDIPlus_GraphicsDrawString|GDIPlus_GraphicsDrawStringEx|GDIPlus_GraphicsFillClosedCurve|GDIPlus_GraphicsFillEllipse|GDIPlus_GraphicsFillPie|GDIPlus_GraphicsFillRect|GDIPlus_GraphicsGetDC|GDIPlus_GraphicsGetSmoothingMode|GDIPlus_GraphicsMeasureString|GDIPlus_GraphicsReleaseDC|GDIPlus_GraphicsSetSmoothingMode|GDIPlus_GraphicsSetTransform|GDIPlus_ImageDispose|GDIPlus_ImageGetGraphicsContext|GDIPlus_ImageGetHeight|GDIPlus_ImageGetWidth|GDIPlus_ImageLoadFromFile|GDIPlus_ImageSaveToFile|GDIPlus_ImageSaveToFileEx|GDIPlus_MatrixCreate|GDIPlus_MatrixDispose|GDIPlus_MatrixRotate|GDIPlus_ParamAdd|GDIPlus_ParamInit|GDIPlus_PenCreate|GDIPlus_PenDispose|GDIPlus_PenGetAlignment|GDIPlus_PenGetColor|GDIPlus_PenGetCustomEndCap|GDIPlus_PenGetDashCap|GDIPlus_PenGetDashStyle|GDIPlus_PenGetEndCap|GDIPlus_PenGetWidth|GDIPlus_PenSetAlignment|GDIPlus_PenSetColor|GDIPlus_PenSetCustomEndCap|GDIPlus_PenSetDashCap|GDIPlus_PenSetDashStyle|GDIPlus_PenSetEndCap|GDIPlus_PenSetWidth|GDIPlus_RectFCreate|GDIPlus_Shutdown|GDIPlus_Startup|GDIPlus_StringFormatCreate|GDIPlus_StringFormatDispose|GetIP|GUICtrlAVI_Close|GUICtrlAVI_Create|GUICtrlAVI_Destroy|GUICtrlAVI_Open|GUICtrlAVI_OpenEx|GUICtrlAVI_Play|GUICtrlAVI_Seek|GUICtrlAVI_Show|GUICtrlAVI_Stop|GUICtrlButton_Click|GUICtrlButton_Create|GUICtrlButton_Destroy|GUICtrlButton_Enable|GUICtrlButton_GetCheck|GUICtrlButton_GetFocus|GUICtrlButton_GetIdealSize|GUICtrlButton_GetImage|GUICtrlButton_GetImageList|GUICtrlButton_GetState|GUICtrlButton_GetText|GUICtrlButton_GetTextMargin|GUICtrlButton_SetCheck|GUICtrlButton_SetFocus|GUICtrlButton_SetImage|GUICtrlButton_SetImageList|GUICtrlButton_SetSize|GUICtrlButton_SetState|GUICtrlButton_SetStyle|GUICtrlButton_SetText|GUICtrlButton_SetTextMargin|GUICtrlButton_Show|GUICtrlComboBox_AddDir|GUICtrlComboBox_AddString|GUICtrlComboBox_AutoComplete|GUICtrlComboBox_BeginUpdate|GUICtrlComboBox_Create|GUICtrlComboBox_DeleteString|GUICtrlComboBox_Destroy|GUICtrlComboBox_EndUpdate|GUICtrlComboBox_FindString|GUICtrlComboBox_FindStringExact|GUICtrlComboBox_GetComboBoxInfo|GUICtrlComboBox_GetCount|GUICtrlComboBox_GetCurSel|GUICtrlComboBox_GetDroppedControlRect|GUICtrlComboBox_GetDroppedControlRectEx|GUICtrlComboBox_GetDroppedState|GUICtrlComboBox_GetDroppedWidth|GUICtrlComboBox_GetEditSel|GUICtrlComboBox_GetEditText|GUICtrlComboBox_GetExtendedUI|GUICtrlComboBox_GetHorizontalExtent|GUICtrlComboBox_GetItemHeight|GUICtrlComboBox_GetLBText|GUICtrlComboBox_GetLBTextLen|GUICtrlComboBox_GetList|GUICtrlComboBox_GetListArray|GUICtrlComboBox_GetLocale|GUICtrlComboBox_GetLocaleCountry|GUICtrlComboBox_GetLocaleLang|GUICtrlComboBox_GetLocalePrimLang|GUICtrlComboBox_GetLocaleSubLang|GUICtrlComboBox_GetMinVisible|GUICtrlComboBox_GetTopIndex|GUICtrlComboBox_InitStorage|GUICtrlComboBox_InsertString|GUICtrlComboBox_LimitText|GUICtrlComboBox_ReplaceEditSel|GUICtrlComboBox_ResetContent|GUICtrlComboBox_SelectString|GUICtrlComboBox_SetCurSel|GUICtrlComboBox_SetDroppedWidth|GUICtrlComboBox_SetEditSel|GUICtrlComboBox_SetEditText|GUICtrlComboBox_SetExtendedUI|GUICtrlComboBox_SetHorizontalExtent|GUICtrlComboBox_SetItemHeight|GUICtrlComboBox_SetMinVisible|GUICtrlComboBox_SetTopIndex|GUICtrlComboBox_ShowDropDown|GUICtrlComboBoxEx_AddDir|GUICtrlComboBoxEx_AddString|GUICtrlComboBoxEx_BeginUpdate|GUICtrlComboBoxEx_Create|GUICtrlComboBoxEx_CreateSolidBitMap|GUICtrlComboBoxEx_DeleteString|GUICtrlComboBoxEx_Destroy|GUICtrlComboBoxEx_EndUpdate|GUICtrlComboBoxEx_FindStringExact|GUICtrlComboBoxEx_GetComboBoxInfo|GUICtrlComboBoxEx_GetComboControl|GUICtrlComboBoxEx_GetCount|GUICtrlComboBoxEx_GetCurSel|GUICtrlComboBoxEx_GetDroppedControlRect|GUICtrlComboBoxEx_GetDroppedControlRectEx|GUICtrlComboBoxEx_GetDroppedState|GUICtrlComboBoxEx_GetDroppedWidth|GUICtrlComboBoxEx_GetEditControl|GUICtrlComboBoxEx_GetEditSel|GUICtrlComboBoxEx_GetEditText|GUICtrlComboBoxEx_GetExtendedStyle|GUICtrlComboBoxEx_GetExtendedUI|GUICtrlComboBoxEx_GetImageList|GUICtrlComboBoxEx_GetItem|GUICtrlComboBoxEx_GetItemEx|GUICtrlComboBoxEx_GetItemHeight|GUICtrlComboBoxEx_GetItemImage|GUICtrlComboBoxEx_GetItemIndent|GUICtrlComboBoxEx_GetItemOverlayImage|GUICtrlComboBoxEx_GetItemParam|GUICtrlComboBoxEx_GetItemSelectedImage|GUICtrlComboBoxEx_GetItemText|GUICtrlComboBoxEx_GetItemTextLen|GUICtrlComboBoxEx_GetList|GUICtrlComboBoxEx_GetListArray|GUICtrlComboBoxEx_GetLocale|GUICtrlComboBoxEx_GetLocaleCountry|GUICtrlComboBoxEx_GetLocaleLang|GUICtrlComboBoxEx_GetLocalePrimLang|GUICtrlComboBoxEx_GetLocaleSubLang|GUICtrlComboBoxEx_GetMinVisible|GUICtrlComboBoxEx_GetTopIndex|GUICtrlComboBoxEx_InitStorage|GUICtrlComboBoxEx_InsertString|GUICtrlComboBoxEx_LimitText|GUICtrlComboBoxEx_ReplaceEditSel|GUICtrlComboBoxEx_ResetContent|GUICtrlComboBoxEx_SetCurSel|GUICtrlComboBoxEx_SetDroppedWidth|GUICtrlComboBoxEx_SetEditSel|GUICtrlComboBoxEx_SetEditText|GUICtrlComboBoxEx_SetExtendedStyle|GUICtrlComboBoxEx_SetExtendedUI|GUICtrlComboBoxEx_SetImageList|GUICtrlComboBoxEx_SetItem|GUICtrlComboBoxEx_SetItemEx|GUICtrlComboBoxEx_SetItemHeight|GUICtrlComboBoxEx_SetItemImage|GUICtrlComboBoxEx_SetItemIndent|GUICtrlComboBoxEx_SetItemOverlayImage|GUICtrlComboBoxEx_SetItemParam|GUICtrlComboBoxEx_SetItemSelectedImage|GUICtrlComboBoxEx_SetMinVisible|GUICtrlComboBoxEx_SetTopIndex|GUICtrlComboBoxEx_ShowDropDown|GUICtrlDTP_Create|GUICtrlDTP_Destroy|GUICtrlDTP_GetMCColor|GUICtrlDTP_GetMCFont|GUICtrlDTP_GetMonthCal|GUICtrlDTP_GetRange|GUICtrlDTP_GetRangeEx|GUICtrlDTP_GetSystemTime|GUICtrlDTP_GetSystemTimeEx|GUICtrlDTP_SetFormat|GUICtrlDTP_SetMCColor|GUICtrlDTP_SetMCFont|GUICtrlDTP_SetRange|GUICtrlDTP_SetRangeEx|GUICtrlDTP_SetSystemTime|GUICtrlDTP_SetSystemTimeEx|GUICtrlEdit_AppendText|GUICtrlEdit_BeginUpdate|GUICtrlEdit_CanUndo|GUICtrlEdit_CharFromPos|GUICtrlEdit_Create|GUICtrlEdit_Destroy|GUICtrlEdit_EmptyUndoBuffer|GUICtrlEdit_EndUpdate|GUICtrlEdit_Find|GUICtrlEdit_FmtLines|GUICtrlEdit_GetFirstVisibleLine|GUICtrlEdit_GetLimitText|GUICtrlEdit_GetLine|GUICtrlEdit_GetLineCount|GUICtrlEdit_GetMargins|GUICtrlEdit_GetModify|GUICtrlEdit_GetPasswordChar|GUICtrlEdit_GetRECT|GUICtrlEdit_GetRECTEx|GUICtrlEdit_GetSel|GUICtrlEdit_GetText|GUICtrlEdit_GetTextLen|GUICtrlEdit_HideBalloonTip|GUICtrlEdit_InsertText|GUICtrlEdit_LineFromChar|GUICtrlEdit_LineIndex|GUICtrlEdit_LineLength|GUICtrlEdit_LineScroll|GUICtrlEdit_PosFromChar|GUICtrlEdit_ReplaceSel|GUICtrlEdit_Scroll|GUICtrlEdit_SetLimitText|GUICtrlEdit_SetMargins|GUICtrlEdit_SetModify|GUICtrlEdit_SetPasswordChar|GUICtrlEdit_SetReadOnly|GUICtrlEdit_SetRECT|GUICtrlEdit_SetRECTEx|GUICtrlEdit_SetRECTNP|GUICtrlEdit_SetRectNPEx|GUICtrlEdit_SetSel|GUICtrlEdit_SetTabStops|GUICtrlEdit_SetText|GUICtrlEdit_ShowBalloonTip|GUICtrlEdit_Undo|GUICtrlHeader_AddItem|GUICtrlHeader_ClearFilter|GUICtrlHeader_ClearFilterAll|GUICtrlHeader_Create|GUICtrlHeader_CreateDragImage|GUICtrlHeader_DeleteItem|GUICtrlHeader_Destroy|GUICtrlHeader_EditFilter|GUICtrlHeader_GetBitmapMargin|GUICtrlHeader_GetImageList|GUICtrlHeader_GetItem|GUICtrlHeader_GetItemAlign|GUICtrlHeader_GetItemBitmap|GUICtrlHeader_GetItemCount|GUICtrlHeader_GetItemDisplay|GUICtrlHeader_GetItemFlags|GUICtrlHeader_GetItemFormat|GUICtrlHeader_GetItemImage|GUICtrlHeader_GetItemOrder|GUICtrlHeader_GetItemParam|GUICtrlHeader_GetItemRect|GUICtrlHeader_GetItemRectEx|GUICtrlHeader_GetItemText|GUICtrlHeader_GetItemWidth|GUICtrlHeader_GetOrderArray|GUICtrlHeader_GetUnicodeFormat|GUICtrlHeader_HitTest|GUICtrlHeader_InsertItem|GUICtrlHeader_Layout|GUICtrlHeader_OrderToIndex|GUICtrlHeader_SetBitmapMargin|GUICtrlHeader_SetFilterChangeTimeout|GUICtrlHeader_SetHotDivider|GUICtrlHeader_SetImageList|GUICtrlHeader_SetItem|GUICtrlHeader_SetItemAlign|GUICtrlHeader_SetItemBitmap|GUICtrlHeader_SetItemDisplay|GUICtrlHeader_SetItemFlags|GUICtrlHeader_SetItemFormat|GUICtrlHeader_SetItemImage|GUICtrlHeader_SetItemOrder|GUICtrlHeader_SetItemParam|GUICtrlHeader_SetItemText|GUICtrlHeader_SetItemWidth|GUICtrlHeader_SetOrderArray|GUICtrlHeader_SetUnicodeFormat|GUICtrlIpAddress_ClearAddress|GUICtrlIpAddress_Create|GUICtrlIpAddress_Destroy|GUICtrlIpAddress_Get|GUICtrlIpAddress_GetArray|GUICtrlIpAddress_GetEx|GUICtrlIpAddress_IsBlank|GUICtrlIpAddress_Set|GUICtrlIpAddress_SetArray|GUICtrlIpAddress_SetEx|GUICtrlIpAddress_SetFocus|GUICtrlIpAddress_SetFont|GUICtrlIpAddress_SetRange|GUICtrlIpAddress_ShowHide|GUICtrlListBox_AddFile|GUICtrlListBox_AddString|GUICtrlListBox_BeginUpdate|GUICtrlListBox_Create|GUICtrlListBox_DeleteString|GUICtrlListBox_Destroy|GUICtrlListBox_Dir|GUICtrlListBox_EndUpdate|GUICtrlListBox_FindInText|GUICtrlListBox_FindString|GUICtrlListBox_GetAnchorIndex|GUICtrlListBox_GetCaretIndex|GUICtrlListBox_GetCount|GUICtrlListBox_GetCurSel|GUICtrlListBox_GetHorizontalExtent|GUICtrlListBox_GetItemData|GUICtrlListBox_GetItemHeight|GUICtrlListBox_GetItemRect|GUICtrlListBox_GetItemRectEx|GUICtrlListBox_GetListBoxInfo|GUICtrlListBox_GetLocale|GUICtrlListBox_GetLocaleCountry|GUICtrlListBox_GetLocaleLang|GUICtrlListBox_GetLocalePrimLang|GUICtrlListBox_GetLocaleSubLang|GUICtrlListBox_GetSel|GUICtrlListBox_GetSelCount|GUICtrlListBox_GetSelItems|GUICtrlListBox_GetSelItemsText|GUICtrlListBox_GetText|GUICtrlListBox_GetTextLen|GUICtrlListBox_GetTopIndex|GUICtrlListBox_InitStorage|GUICtrlListBox_InsertString|GUICtrlListBox_ItemFromPoint|GUICtrlListBox_ReplaceString|GUICtrlListBox_ResetContent|GUICtrlListBox_SelectString|GUICtrlListBox_SelItemRange|GUICtrlListBox_SelItemRangeEx|GUICtrlListBox_SetAnchorIndex|GUICtrlListBox_SetCaretIndex|GUICtrlListBox_SetColumnWidth|GUICtrlListBox_SetCurSel|GUICtrlListBox_SetHorizontalExtent|GUICtrlListBox_SetItemData|GUICtrlListBox_SetItemHeight|GUICtrlListBox_SetLocale|GUICtrlListBox_SetSel|GUICtrlListBox_SetTabStops|GUICtrlListBox_SetTopIndex|GUICtrlListBox_Sort|GUICtrlListBox_SwapString|GUICtrlListBox_UpdateHScroll|GUICtrlListView_AddArray|GUICtrlListView_AddColumn|GUICtrlListView_AddItem|GUICtrlListView_AddSubItem|GUICtrlListView_ApproximateViewHeight|GUICtrlListView_ApproximateViewRect|GUICtrlListView_ApproximateViewWidth|GUICtrlListView_Arrange|GUICtrlListView_BeginUpdate|GUICtrlListView_CancelEditLabel|GUICtrlListView_ClickItem|GUICtrlListView_CopyItems|GUICtrlListView_Create|GUICtrlListView_CreateDragImage|GUICtrlListView_CreateSolidBitMap|GUICtrlListView_DeleteAllItems|GUICtrlListView_DeleteColumn|GUICtrlListView_DeleteItem|GUICtrlListView_DeleteItemsSelected|GUICtrlListView_Destroy|GUICtrlListView_DrawDragImage|GUICtrlListView_EditLabel|GUICtrlListView_EnableGroupView|GUICtrlListView_EndUpdate|GUICtrlListView_EnsureVisible|GUICtrlListView_FindInText|GUICtrlListView_FindItem|GUICtrlListView_FindNearest|GUICtrlListView_FindParam|GUICtrlListView_FindText|GUICtrlListView_GetBkColor|GUICtrlListView_GetBkImage|GUICtrlListView_GetCallbackMask|GUICtrlListView_GetColumn|GUICtrlListView_GetColumnCount|GUICtrlListView_GetColumnOrder|GUICtrlListView_GetColumnOrderArray|GUICtrlListView_GetColumnWidth|GUICtrlListView_GetCounterPage|GUICtrlListView_GetEditControl|GUICtrlListView_GetExtendedListViewStyle|GUICtrlListView_GetGroupInfo|GUICtrlListView_GetGroupViewEnabled|GUICtrlListView_GetHeader|GUICtrlListView_GetHotCursor|GUICtrlListView_GetHotItem|GUICtrlListView_GetHoverTime|GUICtrlListView_GetImageList|GUICtrlListView_GetISearchString|GUICtrlListView_GetItem|GUICtrlListView_GetItemChecked|GUICtrlListView_GetItemCount|GUICtrlListView_GetItemCut|GUICtrlListView_GetItemDropHilited|GUICtrlListView_GetItemEx|GUICtrlListView_GetItemFocused|GUICtrlListView_GetItemGroupID|GUICtrlListView_GetItemImage|GUICtrlListView_GetItemIndent|GUICtrlListView_GetItemParam|GUICtrlListView_GetItemPosition|GUICtrlListView_GetItemPositionX|GUICtrlListView_GetItemPositionY|GUICtrlListView_GetItemRect|GUICtrlListView_GetItemRectEx|GUICtrlListView_GetItemSelected|GUICtrlListView_GetItemSpacing|GUICtrlListView_GetItemSpacingX|GUICtrlListView_GetItemSpacingY|GUICtrlListView_GetItemState|GUICtrlListView_GetItemStateImage|GUICtrlListView_GetItemText|GUICtrlListView_GetItemTextArray|GUICtrlListView_GetItemTextString|GUICtrlListView_GetNextItem|GUICtrlListView_GetNumberOfWorkAreas|GUICtrlListView_GetOrigin|GUICtrlListView_GetOriginX|GUICtrlListView_GetOriginY|GUICtrlListView_GetOutlineColor|GUICtrlListView_GetSelectedColumn|GUICtrlListView_GetSelectedCount|GUICtrlListView_GetSelectedIndices|GUICtrlListView_GetSelectionMark|GUICtrlListView_GetStringWidth|GUICtrlListView_GetSubItemRect|GUICtrlListView_GetTextBkColor|GUICtrlListView_GetTextColor|GUICtrlListView_GetToolTips|GUICtrlListView_GetTopIndex|GUICtrlListView_GetUnicodeFormat|GUICtrlListView_GetView|GUICtrlListView_GetViewDetails|GUICtrlListView_GetViewLarge|GUICtrlListView_GetViewList|GUICtrlListView_GetViewRect|GUICtrlListView_GetViewSmall|GUICtrlListView_GetViewTile|GUICtrlListView_HideColumn|GUICtrlListView_HitTest|GUICtrlListView_InsertColumn|GUICtrlListView_InsertGroup|GUICtrlListView_InsertItem|GUICtrlListView_JustifyColumn|GUICtrlListView_MapIDToIndex|GUICtrlListView_MapIndexToID|GUICtrlListView_RedrawItems|GUICtrlListView_RegisterSortCallBack|GUICtrlListView_RemoveAllGroups|GUICtrlListView_RemoveGroup|GUICtrlListView_Scroll|GUICtrlListView_SetBkColor|GUICtrlListView_SetBkImage|GUICtrlListView_SetCallBackMask|GUICtrlListView_SetColumn|GUICtrlListView_SetColumnOrder|GUICtrlListView_SetColumnOrderArray|GUICtrlListView_SetColumnWidth|GUICtrlListView_SetExtendedListViewStyle|GUICtrlListView_SetGroupInfo|GUICtrlListView_SetHotItem|GUICtrlListView_SetHoverTime|GUICtrlListView_SetIconSpacing|GUICtrlListView_SetImageList|GUICtrlListView_SetItem|GUICtrlListView_SetItemChecked|GUICtrlListView_SetItemCount|GUICtrlListView_SetItemCut|GUICtrlListView_SetItemDropHilited|GUICtrlListView_SetItemEx|GUICtrlListView_SetItemFocused|GUICtrlListView_SetItemGroupID|GUICtrlListView_SetItemImage|GUICtrlListView_SetItemIndent|GUICtrlListView_SetItemParam|GUICtrlListView_SetItemPosition|GUICtrlListView_SetItemPosition32|GUICtrlListView_SetItemSelected|GUICtrlListView_SetItemState|GUICtrlListView_SetItemStateImage|GUICtrlListView_SetItemText|GUICtrlListView_SetOutlineColor|GUICtrlListView_SetSelectedColumn|GUICtrlListView_SetSelectionMark|GUICtrlListView_SetTextBkColor|GUICtrlListView_SetTextColor|GUICtrlListView_SetToolTips|GUICtrlListView_SetUnicodeFormat|GUICtrlListView_SetView|GUICtrlListView_SetWorkAreas|GUICtrlListView_SimpleSort|GUICtrlListView_SortItems|GUICtrlListView_SubItemHitTest|GUICtrlListView_UnRegisterSortCallBack|GUICtrlMenu_AddMenuItem|GUICtrlMenu_AppendMenu|GUICtrlMenu_CheckMenuItem|GUICtrlMenu_CheckRadioItem|GUICtrlMenu_CreateMenu|GUICtrlMenu_CreatePopup|GUICtrlMenu_DeleteMenu|GUICtrlMenu_DestroyMenu|GUICtrlMenu_DrawMenuBar|GUICtrlMenu_EnableMenuItem|GUICtrlMenu_FindItem|GUICtrlMenu_FindParent|GUICtrlMenu_GetItemBmp|GUICtrlMenu_GetItemBmpChecked|GUICtrlMenu_GetItemBmpUnchecked|GUICtrlMenu_GetItemChecked|GUICtrlMenu_GetItemCount|GUICtrlMenu_GetItemData|GUICtrlMenu_GetItemDefault|GUICtrlMenu_GetItemDisabled|GUICtrlMenu_GetItemEnabled|GUICtrlMenu_GetItemGrayed|GUICtrlMenu_GetItemHighlighted|GUICtrlMenu_GetItemID|GUICtrlMenu_GetItemInfo|GUICtrlMenu_GetItemRect|GUICtrlMenu_GetItemRectEx|GUICtrlMenu_GetItemState|GUICtrlMenu_GetItemStateEx|GUICtrlMenu_GetItemSubMenu|GUICtrlMenu_GetItemText|GUICtrlMenu_GetItemType|GUICtrlMenu_GetMenu|GUICtrlMenu_GetMenuBackground|GUICtrlMenu_GetMenuBarInfo|GUICtrlMenu_GetMenuContextHelpID|GUICtrlMenu_GetMenuData|GUICtrlMenu_GetMenuDefaultItem|GUICtrlMenu_GetMenuHeight|GUICtrlMenu_GetMenuInfo|GUICtrlMenu_GetMenuStyle|GUICtrlMenu_GetSystemMenu|GUICtrlMenu_InsertMenuItem|GUICtrlMenu_InsertMenuItemEx|GUICtrlMenu_IsMenu|GUICtrlMenu_LoadMenu|GUICtrlMenu_MapAccelerator|GUICtrlMenu_MenuItemFromPoint|GUICtrlMenu_RemoveMenu|GUICtrlMenu_SetItemBitmaps|GUICtrlMenu_SetItemBmp|GUICtrlMenu_SetItemBmpChecked|GUICtrlMenu_SetItemBmpUnchecked|GUICtrlMenu_SetItemChecked|GUICtrlMenu_SetItemData|GUICtrlMenu_SetItemDefault|GUICtrlMenu_SetItemDisabled|GUICtrlMenu_SetItemEnabled|GUICtrlMenu_SetItemGrayed|GUICtrlMenu_SetItemHighlighted|GUICtrlMenu_SetItemID|GUICtrlMenu_SetItemInfo|GUICtrlMenu_SetItemState|GUICtrlMenu_SetItemSubMenu|GUICtrlMenu_SetItemText|GUICtrlMenu_SetItemType|GUICtrlMenu_SetMenu|GUICtrlMenu_SetMenuBackground|GUICtrlMenu_SetMenuContextHelpID|GUICtrlMenu_SetMenuData|GUICtrlMenu_SetMenuDefaultItem|GUICtrlMenu_SetMenuHeight|GUICtrlMenu_SetMenuInfo|GUICtrlMenu_SetMenuStyle|GUICtrlMenu_TrackPopupMenu|GUICtrlMonthCal_Create|GUICtrlMonthCal_Destroy|GUICtrlMonthCal_GetColor|GUICtrlMonthCal_GetColorArray|GUICtrlMonthCal_GetCurSel|GUICtrlMonthCal_GetCurSelStr|GUICtrlMonthCal_GetFirstDOW|GUICtrlMonthCal_GetFirstDOWStr|GUICtrlMonthCal_GetMaxSelCount|GUICtrlMonthCal_GetMaxTodayWidth|GUICtrlMonthCal_GetMinReqHeight|GUICtrlMonthCal_GetMinReqRect|GUICtrlMonthCal_GetMinReqRectArray|GUICtrlMonthCal_GetMinReqWidth|GUICtrlMonthCal_GetMonthDelta|GUICtrlMonthCal_GetMonthRange|GUICtrlMonthCal_GetMonthRangeMax|GUICtrlMonthCal_GetMonthRangeMaxStr|GUICtrlMonthCal_GetMonthRangeMin|GUICtrlMonthCal_GetMonthRangeMinStr|GUICtrlMonthCal_GetMonthRangeSpan|GUICtrlMonthCal_GetRange|GUICtrlMonthCal_GetRangeMax|GUICtrlMonthCal_GetRangeMaxStr|GUICtrlMonthCal_GetRangeMin|GUICtrlMonthCal_GetRangeMinStr|GUICtrlMonthCal_GetSelRange|GUICtrlMonthCal_GetSelRangeMax|GUICtrlMonthCal_GetSelRangeMaxStr|GUICtrlMonthCal_GetSelRangeMin|GUICtrlMonthCal_GetSelRangeMinStr|GUICtrlMonthCal_GetToday|GUICtrlMonthCal_GetTodayStr|GUICtrlMonthCal_GetUnicodeFormat|GUICtrlMonthCal_HitTest|GUICtrlMonthCal_SetColor|GUICtrlMonthCal_SetCurSel|GUICtrlMonthCal_SetDayState|GUICtrlMonthCal_SetFirstDOW|GUICtrlMonthCal_SetMaxSelCount|GUICtrlMonthCal_SetMonthDelta|GUICtrlMonthCal_SetRange|GUICtrlMonthCal_SetSelRange|GUICtrlMonthCal_SetToday|GUICtrlMonthCal_SetUnicodeFormat|GUICtrlRebar_AddBand|GUICtrlRebar_AddToolBarBand|GUICtrlRebar_BeginDrag|GUICtrlRebar_Create|GUICtrlRebar_DeleteBand|GUICtrlRebar_Destroy|GUICtrlRebar_DragMove|GUICtrlRebar_EndDrag|GUICtrlRebar_GetBandBackColor|GUICtrlRebar_GetBandBorders|GUICtrlRebar_GetBandBordersEx|GUICtrlRebar_GetBandChildHandle|GUICtrlRebar_GetBandChildSize|GUICtrlRebar_GetBandCount|GUICtrlRebar_GetBandForeColor|GUICtrlRebar_GetBandHeaderSize|GUICtrlRebar_GetBandID|GUICtrlRebar_GetBandIdealSize|GUICtrlRebar_GetBandLength|GUICtrlRebar_GetBandLParam|GUICtrlRebar_GetBandMargins|GUICtrlRebar_GetBandMarginsEx|GUICtrlRebar_GetBandRect|GUICtrlRebar_GetBandRectEx|GUICtrlRebar_GetBandStyle|GUICtrlRebar_GetBandStyleBreak|GUICtrlRebar_GetBandStyleChildEdge|GUICtrlRebar_GetBandStyleFixedBMP|GUICtrlRebar_GetBandStyleFixedSize|GUICtrlRebar_GetBandStyleGripperAlways|GUICtrlRebar_GetBandStyleHidden|GUICtrlRebar_GetBandStyleHideTitle|GUICtrlRebar_GetBandStyleNoGripper|GUICtrlRebar_GetBandStyleTopAlign|GUICtrlRebar_GetBandStyleUseChevron|GUICtrlRebar_GetBandStyleVariableHeight|GUICtrlRebar_GetBandText|GUICtrlRebar_GetBarHeight|GUICtrlRebar_GetBKColor|GUICtrlRebar_GetColorScheme|GUICtrlRebar_GetRowCount|GUICtrlRebar_GetRowHeight|GUICtrlRebar_GetTextColor|GUICtrlRebar_GetToolTips|GUICtrlRebar_GetUnicodeFormat|GUICtrlRebar_HitTest|GUICtrlRebar_IDToIndex|GUICtrlRebar_MaximizeBand|GUICtrlRebar_MinimizeBand|GUICtrlRebar_MoveBand|GUICtrlRebar_SetBandBackColor|GUICtrlRebar_SetBandForeColor|GUICtrlRebar_SetBandHeaderSize|GUICtrlRebar_SetBandID|GUICtrlRebar_SetBandIdealSize|GUICtrlRebar_SetBandLength|GUICtrlRebar_SetBandLParam|GUICtrlRebar_SetBandStyle|GUICtrlRebar_SetBandStyleBreak|GUICtrlRebar_SetBandStyleChildEdge|GUICtrlRebar_SetBandStyleFixedBMP|GUICtrlRebar_SetBandStyleFixedSize|GUICtrlRebar_SetBandStyleGripperAlways|GUICtrlRebar_SetBandStyleHidden|GUICtrlRebar_SetBandStyleHideTitle|GUICtrlRebar_SetBandStyleNoGripper|GUICtrlRebar_SetBandStyleTopAlign|GUICtrlRebar_SetBandStyleUseChevron|GUICtrlRebar_SetBandStyleVariableHeight|GUICtrlRebar_SetBandText|GUICtrlRebar_SetBKColor|GUICtrlRebar_SetColorScheme|GUICtrlRebar_SetTextColor|GUICtrlRebar_SetToolTips|GUICtrlRebar_SetUnicodeFormat|GUICtrlRebar_ShowBand|GUICtrlSlider_ClearSel|GUICtrlSlider_ClearTics|GUICtrlSlider_Create|GUICtrlSlider_Destroy|GUICtrlSlider_GetBuddy|GUICtrlSlider_GetChannelRect|GUICtrlSlider_GetLineSize|GUICtrlSlider_GetNumTics|GUICtrlSlider_GetPageSize|GUICtrlSlider_GetPos|GUICtrlSlider_GetPTics|GUICtrlSlider_GetRange|GUICtrlSlider_GetRangeMax|GUICtrlSlider_GetRangeMin|GUICtrlSlider_GetSel|GUICtrlSlider_GetSelEnd|GUICtrlSlider_GetSelStart|GUICtrlSlider_GetThumbLength|GUICtrlSlider_GetThumbRect|GUICtrlSlider_GetThumbRectEx|GUICtrlSlider_GetTic|GUICtrlSlider_GetTicPos|GUICtrlSlider_GetToolTips|GUICtrlSlider_GetUnicodeFormat|GUICtrlSlider_SetBuddy|GUICtrlSlider_SetLineSize|GUICtrlSlider_SetPageSize|GUICtrlSlider_SetPos|GUICtrlSlider_SetRange|GUICtrlSlider_SetRangeMax|GUICtrlSlider_SetRangeMin|GUICtrlSlider_SetSel|GUICtrlSlider_SetSelEnd|GUICtrlSlider_SetSelStart|GUICtrlSlider_SetThumbLength|GUICtrlSlider_SetTic|GUICtrlSlider_SetTicFreq|GUICtrlSlider_SetTipSide|GUICtrlSlider_SetToolTips|GUICtrlSlider_SetUnicodeFormat|GUICtrlStatusBar_Create|GUICtrlStatusBar_Destroy|GUICtrlStatusBar_EmbedControl|GUICtrlStatusBar_GetBorders|GUICtrlStatusBar_GetBordersHorz|GUICtrlStatusBar_GetBordersRect|GUICtrlStatusBar_GetBordersVert|GUICtrlStatusBar_GetCount|GUICtrlStatusBar_GetHeight|GUICtrlStatusBar_GetIcon|GUICtrlStatusBar_GetParts|GUICtrlStatusBar_GetRect|GUICtrlStatusBar_GetRectEx|GUICtrlStatusBar_GetText|GUICtrlStatusBar_GetTextFlags|GUICtrlStatusBar_GetTextLength|GUICtrlStatusBar_GetTextLengthEx|GUICtrlStatusBar_GetTipText|GUICtrlStatusBar_GetUnicodeFormat|GUICtrlStatusBar_GetWidth|GUICtrlStatusBar_IsSimple|GUICtrlStatusBar_Resize|GUICtrlStatusBar_SetBkColor|GUICtrlStatusBar_SetIcon|GUICtrlStatusBar_SetMinHeight|GUICtrlStatusBar_SetParts|GUICtrlStatusBar_SetSimple|GUICtrlStatusBar_SetText|GUICtrlStatusBar_SetTipText|GUICtrlStatusBar_SetUnicodeFormat|GUICtrlStatusBar_ShowHide|GUICtrlTab_Create|GUICtrlTab_DeleteAllItems|GUICtrlTab_DeleteItem|GUICtrlTab_DeselectAll|GUICtrlTab_Destroy|GUICtrlTab_FindTab|GUICtrlTab_GetCurFocus|GUICtrlTab_GetCurSel|GUICtrlTab_GetDisplayRect|GUICtrlTab_GetDisplayRectEx|GUICtrlTab_GetExtendedStyle|GUICtrlTab_GetImageList|GUICtrlTab_GetItem|GUICtrlTab_GetItemCount|GUICtrlTab_GetItemImage|GUICtrlTab_GetItemParam|GUICtrlTab_GetItemRect|GUICtrlTab_GetItemRectEx|GUICtrlTab_GetItemState|GUICtrlTab_GetItemText|GUICtrlTab_GetRowCount|GUICtrlTab_GetToolTips|GUICtrlTab_GetUnicodeFormat|GUICtrlTab_HighlightItem|GUICtrlTab_HitTest|GUICtrlTab_InsertItem|GUICtrlTab_RemoveImage|GUICtrlTab_SetCurFocus|GUICtrlTab_SetCurSel|GUICtrlTab_SetExtendedStyle|GUICtrlTab_SetImageList|GUICtrlTab_SetItem|GUICtrlTab_SetItemImage|GUICtrlTab_SetItemParam|GUICtrlTab_SetItemSize|GUICtrlTab_SetItemState|GUICtrlTab_SetItemText|GUICtrlTab_SetMinTabWidth|GUICtrlTab_SetPadding|GUICtrlTab_SetToolTips|GUICtrlTab_SetUnicodeFormat|GUICtrlToolbar_AddBitmap|GUICtrlToolbar_AddButton|GUICtrlToolbar_AddButtonSep|GUICtrlToolbar_AddString|GUICtrlToolbar_ButtonCount|GUICtrlToolbar_CheckButton|GUICtrlToolbar_ClickAccel|GUICtrlToolbar_ClickButton|GUICtrlToolbar_ClickIndex|GUICtrlToolbar_CommandToIndex|GUICtrlToolbar_Create|GUICtrlToolbar_Customize|GUICtrlToolbar_DeleteButton|GUICtrlToolbar_Destroy|GUICtrlToolbar_EnableButton|GUICtrlToolbar_FindToolbar|GUICtrlToolbar_GetAnchorHighlight|GUICtrlToolbar_GetBitmapFlags|GUICtrlToolbar_GetButtonBitmap|GUICtrlToolbar_GetButtonInfo|GUICtrlToolbar_GetButtonInfoEx|GUICtrlToolbar_GetButtonParam|GUICtrlToolbar_GetButtonRect|GUICtrlToolbar_GetButtonRectEx|GUICtrlToolbar_GetButtonSize|GUICtrlToolbar_GetButtonState|GUICtrlToolbar_GetButtonStyle|GUICtrlToolbar_GetButtonText|GUICtrlToolbar_GetColorScheme|GUICtrlToolbar_GetDisabledImageList|GUICtrlToolbar_GetExtendedStyle|GUICtrlToolbar_GetHotImageList|GUICtrlToolbar_GetHotItem|GUICtrlToolbar_GetImageList|GUICtrlToolbar_GetInsertMark|GUICtrlToolbar_GetInsertMarkColor|GUICtrlToolbar_GetMaxSize|GUICtrlToolbar_GetMetrics|GUICtrlToolbar_GetPadding|GUICtrlToolbar_GetRows|GUICtrlToolbar_GetString|GUICtrlToolbar_GetStyle|GUICtrlToolbar_GetStyleAltDrag|GUICtrlToolbar_GetStyleCustomErase|GUICtrlToolbar_GetStyleFlat|GUICtrlToolbar_GetStyleList|GUICtrlToolbar_GetStyleRegisterDrop|GUICtrlToolbar_GetStyleToolTips|GUICtrlToolbar_GetStyleTransparent|GUICtrlToolbar_GetStyleWrapable|GUICtrlToolbar_GetTextRows|GUICtrlToolbar_GetToolTips|GUICtrlToolbar_GetUnicodeFormat|GUICtrlToolbar_HideButton|GUICtrlToolbar_HighlightButton|GUICtrlToolbar_HitTest|GUICtrlToolbar_IndexToCommand|GUICtrlToolbar_InsertButton|GUICtrlToolbar_InsertMarkHitTest|GUICtrlToolbar_IsButtonChecked|GUICtrlToolbar_IsButtonEnabled|GUICtrlToolbar_IsButtonHidden|GUICtrlToolbar_IsButtonHighlighted|GUICtrlToolbar_IsButtonIndeterminate|GUICtrlToolbar_IsButtonPressed|GUICtrlToolbar_LoadBitmap|GUICtrlToolbar_LoadImages|GUICtrlToolbar_MapAccelerator|GUICtrlToolbar_MoveButton|GUICtrlToolbar_PressButton|GUICtrlToolbar_SetAnchorHighlight|GUICtrlToolbar_SetBitmapSize|GUICtrlToolbar_SetButtonBitMap|GUICtrlToolbar_SetButtonInfo|GUICtrlToolbar_SetButtonInfoEx|GUICtrlToolbar_SetButtonParam|GUICtrlToolbar_SetButtonSize|GUICtrlToolbar_SetButtonState|GUICtrlToolbar_SetButtonStyle|GUICtrlToolbar_SetButtonText|GUICtrlToolbar_SetButtonWidth|GUICtrlToolbar_SetCmdID|GUICtrlToolbar_SetColorScheme|GUICtrlToolbar_SetDisabledImageList|GUICtrlToolbar_SetDrawTextFlags|GUICtrlToolbar_SetExtendedStyle|GUICtrlToolbar_SetHotImageList|GUICtrlToolbar_SetHotItem|GUICtrlToolbar_SetImageList|GUICtrlToolbar_SetIndent|GUICtrlToolbar_SetIndeterminate|GUICtrlToolbar_SetInsertMark|GUICtrlToolbar_SetInsertMarkColor|GUICtrlToolbar_SetMaxTextRows|GUICtrlToolbar_SetMetrics|GUICtrlToolbar_SetPadding|GUICtrlToolbar_SetParent|GUICtrlToolbar_SetRows|GUICtrlToolbar_SetStyle|GUICtrlToolbar_SetStyleAltDrag|GUICtrlToolbar_SetStyleCustomErase|GUICtrlToolbar_SetStyleFlat|GUICtrlToolbar_SetStyleList|GUICtrlToolbar_SetStyleRegisterDrop|GUICtrlToolbar_SetStyleToolTips|GUICtrlToolbar_SetStyleTransparent|GUICtrlToolbar_SetStyleWrapable|GUICtrlToolbar_SetToolTips|GUICtrlToolbar_SetUnicodeFormat|GUICtrlToolbar_SetWindowTheme|GUICtrlTreeView_Add|GUICtrlTreeView_AddChild|GUICtrlTreeView_AddChildFirst|GUICtrlTreeView_AddFirst|GUICtrlTreeView_BeginUpdate|GUICtrlTreeView_ClickItem|GUICtrlTreeView_Create|GUICtrlTreeView_CreateDragImage|GUICtrlTreeView_CreateSolidBitMap|GUICtrlTreeView_Delete|GUICtrlTreeView_DeleteAll|GUICtrlTreeView_DeleteChildren|GUICtrlTreeView_Destroy|GUICtrlTreeView_DisplayRect|GUICtrlTreeView_DisplayRectEx|GUICtrlTreeView_EditText|GUICtrlTreeView_EndEdit|GUICtrlTreeView_EndUpdate|GUICtrlTreeView_EnsureVisible|GUICtrlTreeView_Expand|GUICtrlTreeView_ExpandedOnce|GUICtrlTreeView_FindItem|GUICtrlTreeView_FindItemEx|GUICtrlTreeView_GetBkColor|GUICtrlTreeView_GetBold|GUICtrlTreeView_GetChecked|GUICtrlTreeView_GetChildCount|GUICtrlTreeView_GetChildren|GUICtrlTreeView_GetCount|GUICtrlTreeView_GetCut|GUICtrlTreeView_GetDropTarget|GUICtrlTreeView_GetEditControl|GUICtrlTreeView_GetExpanded|GUICtrlTreeView_GetFirstChild|GUICtrlTreeView_GetFirstItem|GUICtrlTreeView_GetFirstVisible|GUICtrlTreeView_GetFocused|GUICtrlTreeView_GetHeight|GUICtrlTreeView_GetImageIndex|GUICtrlTreeView_GetImageListIconHandle|GUICtrlTreeView_GetIndent|GUICtrlTreeView_GetInsertMarkColor|GUICtrlTreeView_GetISearchString|GUICtrlTreeView_GetItemByIndex|GUICtrlTreeView_GetItemHandle|GUICtrlTreeView_GetItemParam|GUICtrlTreeView_GetLastChild|GUICtrlTreeView_GetLineColor|GUICtrlTreeView_GetNext|GUICtrlTreeView_GetNextChild|GUICtrlTreeView_GetNextSibling|GUICtrlTreeView_GetNextVisible|GUICtrlTreeView_GetNormalImageList|GUICtrlTreeView_GetParentHandle|GUICtrlTreeView_GetParentParam|GUICtrlTreeView_GetPrev|GUICtrlTreeView_GetPrevChild|GUICtrlTreeView_GetPrevSibling|GUICtrlTreeView_GetPrevVisible|GUICtrlTreeView_GetScrollTime|GUICtrlTreeView_GetSelected|GUICtrlTreeView_GetSelectedImageIndex|GUICtrlTreeView_GetSelection|GUICtrlTreeView_GetSiblingCount|GUICtrlTreeView_GetState|GUICtrlTreeView_GetStateImageIndex|GUICtrlTreeView_GetStateImageList|GUICtrlTreeView_GetText|GUICtrlTreeView_GetTextColor|GUICtrlTreeView_GetToolTips|GUICtrlTreeView_GetTree|GUICtrlTreeView_GetUnicodeFormat|GUICtrlTreeView_GetVisible|GUICtrlTreeView_GetVisibleCount|GUICtrlTreeView_HitTest|GUICtrlTreeView_HitTestEx|GUICtrlTreeView_HitTestItem|GUICtrlTreeView_Index|GUICtrlTreeView_InsertItem|GUICtrlTreeView_IsFirstItem|GUICtrlTreeView_IsParent|GUICtrlTreeView_Level|GUICtrlTreeView_SelectItem|GUICtrlTreeView_SelectItemByIndex|GUICtrlTreeView_SetBkColor|GUICtrlTreeView_SetBold|GUICtrlTreeView_SetChecked|GUICtrlTreeView_SetCheckedByIndex|GUICtrlTreeView_SetChildren|GUICtrlTreeView_SetCut|GUICtrlTreeView_SetDropTarget|GUICtrlTreeView_SetFocused|GUICtrlTreeView_SetHeight|GUICtrlTreeView_SetIcon|GUICtrlTreeView_SetImageIndex|GUICtrlTreeView_SetIndent|GUICtrlTreeView_SetInsertMark|GUICtrlTreeView_SetInsertMarkColor|GUICtrlTreeView_SetItemHeight|GUICtrlTreeView_SetItemParam|GUICtrlTreeView_SetLineColor|GUICtrlTreeView_SetNormalImageList|GUICtrlTreeView_SetScrollTime|GUICtrlTreeView_SetSelected|GUICtrlTreeView_SetSelectedImageIndex|GUICtrlTreeView_SetState|GUICtrlTreeView_SetStateImageIndex|GUICtrlTreeView_SetStateImageList|GUICtrlTreeView_SetText|GUICtrlTreeView_SetTextColor|GUICtrlTreeView_SetToolTips|GUICtrlTreeView_SetUnicodeFormat|GUICtrlTreeView_Sort|GUIImageList_Add|GUIImageList_AddBitmap|GUIImageList_AddIcon|GUIImageList_AddMasked|GUIImageList_BeginDrag|GUIImageList_Copy|GUIImageList_Create|GUIImageList_Destroy|GUIImageList_DestroyIcon|GUIImageList_DragEnter|GUIImageList_DragLeave|GUIImageList_DragMove|GUIImageList_Draw|GUIImageList_DrawEx|GUIImageList_Duplicate|GUIImageList_EndDrag|GUIImageList_GetBkColor|GUIImageList_GetIcon|GUIImageList_GetIconHeight|GUIImageList_GetIconSize|GUIImageList_GetIconSizeEx|GUIImageList_GetIconWidth|GUIImageList_GetImageCount|GUIImageList_GetImageInfoEx|GUIImageList_Remove|GUIImageList_ReplaceIcon|GUIImageList_SetBkColor|GUIImageList_SetIconSize|GUIImageList_SetImageCount|GUIImageList_Swap|GUIScrollBars_EnableScrollBar|GUIScrollBars_GetScrollBarInfoEx|GUIScrollBars_GetScrollBarRect|GUIScrollBars_GetScrollBarRGState|GUIScrollBars_GetScrollBarXYLineButton|GUIScrollBars_GetScrollBarXYThumbBottom|GUIScrollBars_GetScrollBarXYThumbTop|GUIScrollBars_GetScrollInfo|GUIScrollBars_GetScrollInfoEx|GUIScrollBars_GetScrollInfoMax|GUIScrollBars_GetScrollInfoMin|GUIScrollBars_GetScrollInfoPage|GUIScrollBars_GetScrollInfoPos|GUIScrollBars_GetScrollInfoTrackPos|GUIScrollBars_GetScrollPos|GUIScrollBars_GetScrollRange|GUIScrollBars_Init|GUIScrollBars_ScrollWindow|GUIScrollBars_SetScrollInfo|GUIScrollBars_SetScrollInfoMax|GUIScrollBars_SetScrollInfoMin|GUIScrollBars_SetScrollInfoPage|GUIScrollBars_SetScrollInfoPos|GUIScrollBars_SetScrollRange|GUIScrollBars_ShowScrollBar|GUIToolTip_Activate|GUIToolTip_AddTool|GUIToolTip_AdjustRect|GUIToolTip_BitsToTTF|GUIToolTip_Create|GUIToolTip_DelTool|GUIToolTip_Destroy|GUIToolTip_EnumTools|GUIToolTip_GetBubbleHeight|GUIToolTip_GetBubbleSize|GUIToolTip_GetBubbleWidth|GUIToolTip_GetCurrentTool|GUIToolTip_GetDelayTime|GUIToolTip_GetMargin|GUIToolTip_GetMarginEx|GUIToolTip_GetMaxTipWidth|GUIToolTip_GetText|GUIToolTip_GetTipBkColor|GUIToolTip_GetTipTextColor|GUIToolTip_GetTitleBitMap|GUIToolTip_GetTitleText|GUIToolTip_GetToolCount|GUIToolTip_GetToolInfo|GUIToolTip_HitTest|GUIToolTip_NewToolRect|GUIToolTip_Pop|GUIToolTip_PopUp|GUIToolTip_SetDelayTime|GUIToolTip_SetMargin|GUIToolTip_SetMaxTipWidth|GUIToolTip_SetTipBkColor|GUIToolTip_SetTipTextColor|GUIToolTip_SetTitle|GUIToolTip_SetToolInfo|GUIToolTip_SetWindowTheme|GUIToolTip_ToolExists|GUIToolTip_ToolToArray|GUIToolTip_TrackActivate|GUIToolTip_TrackPosition|GUIToolTip_TTFToBits|GUIToolTip_Update|GUIToolTip_UpdateTipText|HexToString|IE_Example|IE_Introduction|IE_VersionInfo|IEAction|IEAttach|IEBodyReadHTML|IEBodyReadText|IEBodyWriteHTML|IECreate|IECreateEmbedded|IEDocGetObj|IEDocInsertHTML|IEDocInsertText|IEDocReadHTML|IEDocWriteHTML|IEErrorHandlerDeRegister|IEErrorHandlerRegister|IEErrorNotify|IEFormElementCheckBoxSelect|IEFormElementGetCollection|IEFormElementGetObjByName|IEFormElementGetValue|IEFormElementOptionSelect|IEFormElementRadioSelect|IEFormElementSetValue|IEFormGetCollection|IEFormGetObjByName|IEFormImageClick|IEFormReset|IEFormSubmit|IEFrameGetCollection|IEFrameGetObjByName|IEGetObjById|IEGetObjByName|IEHeadInsertEventScript|IEImgClick|IEImgGetCollection|IEIsFrameSet|IELinkClickByIndex|IELinkClickByText|IELinkGetCollection|IELoadWait|IELoadWaitTimeout|IENavigate|IEPropertyGet|IEPropertySet|IEQuit|IETableGetCollection|IETableWriteToArray|IETagNameAllGetCollection|IETagNameGetCollection|Iif|INetExplorerCapable|INetGetSource|INetMail|INetSmtpMail|IsPressed|MathCheckDiv|Max|MemGlobalAlloc|MemGlobalFree|MemGlobalLock|MemGlobalSize|MemGlobalUnlock|MemMoveMemory|MemMsgBox|MemShowError|MemVirtualAlloc|MemVirtualAllocEx|MemVirtualFree|MemVirtualFreeEx|Min|MouseTrap|NamedPipes_CallNamedPipe|NamedPipes_ConnectNamedPipe|NamedPipes_CreateNamedPipe|NamedPipes_CreatePipe|NamedPipes_DisconnectNamedPipe|NamedPipes_GetNamedPipeHandleState|NamedPipes_GetNamedPipeInfo|NamedPipes_PeekNamedPipe|NamedPipes_SetNamedPipeHandleState|NamedPipes_TransactNamedPipe|NamedPipes_WaitNamedPipe|Net_Share_ConnectionEnum|Net_Share_FileClose|Net_Share_FileEnum|Net_Share_FileGetInfo|Net_Share_PermStr|Net_Share_ResourceStr|Net_Share_SessionDel|Net_Share_SessionEnum|Net_Share_SessionGetInfo|Net_Share_ShareAdd|Net_Share_ShareCheck|Net_Share_ShareDel|Net_Share_ShareEnum|Net_Share_ShareGetInfo|Net_Share_ShareSetInfo|Net_Share_StatisticsGetSvr|Net_Share_StatisticsGetWrk|Now|NowCalc|NowCalcDate|NowDate|NowTime|PathFull|PathMake|PathSplit|ProcessGetName|ProcessGetPriority|Radian|ReplaceStringInFile|RunDOS|ScreenCapture_Capture|ScreenCapture_CaptureWnd|ScreenCapture_SaveImage|ScreenCapture_SetBMPFormat|ScreenCapture_SetJPGQuality|ScreenCapture_SetTIFColorDepth|ScreenCapture_SetTIFCompression|Security__AdjustTokenPrivileges|Security__GetAccountSid|Security__GetLengthSid|Security__GetTokenInformation|Security__ImpersonateSelf|Security__IsValidSid|Security__LookupAccountName|Security__LookupAccountSid|Security__LookupPrivilegeValue|Security__OpenProcessToken|Security__OpenThreadToken|Security__OpenThreadTokenEx|Security__SetPrivilege|Security__SidToStringSid|Security__SidTypeStr|Security__StringSidToSid|SendMessage|SendMessageA|SetDate|SetTime|Singleton|SoundClose|SoundLength|SoundOpen|SoundPause|SoundPlay|SoundPos|SoundResume|SoundSeek|SoundStatus|SoundStop|SQLite_Changes|SQLite_Close|SQLite_Display2DResult|SQLite_Encode|SQLite_ErrCode|SQLite_ErrMsg|SQLite_Escape|SQLite_Exec|SQLite_FetchData|SQLite_FetchNames|SQLite_GetTable|SQLite_GetTable2d|SQLite_LastInsertRowID|SQLite_LibVersion|SQLite_Open|SQLite_Query|SQLite_QueryFinalize|SQLite_QueryReset|SQLite_QuerySingleRow|SQLite_SaveMode|SQLite_SetTimeout|SQLite_Shutdown|SQLite_SQLiteExe|SQLite_Startup|SQLite_TotalChanges|StringAddComma|StringBetween|StringEncrypt|StringInsert|StringProper|StringRepeat|StringReverse|StringSplit|StringToHex|TCPIpToName|TempFile|TicksToTime|Timer_Diff|Timer_GetTimerID|Timer_Init|Timer_KillAllTimers|Timer_KillTimer|Timer_SetTimer|TimeToTicks|VersionCompare|viClose|viExecCommand|viFindGpib|viGpibBusReset|viGTL|viOpen|viSetAttribute|viSetTimeout|WeekNumberISO|WinAPI_AttachConsole|WinAPI_AttachThreadInput|WinAPI_Beep|WinAPI_BitBlt|WinAPI_CallNextHookEx|WinAPI_Check|WinAPI_ClientToScreen|WinAPI_CloseHandle|WinAPI_CommDlgExtendedError|WinAPI_CopyIcon|WinAPI_CreateBitmap|WinAPI_CreateCompatibleBitmap|WinAPI_CreateCompatibleDC|WinAPI_CreateEvent|WinAPI_CreateFile|WinAPI_CreateFont|WinAPI_CreateFontIndirect|WinAPI_CreateProcess|WinAPI_CreateSolidBitmap|WinAPI_CreateSolidBrush|WinAPI_CreateWindowEx|WinAPI_DefWindowProc|WinAPI_DeleteDC|WinAPI_DeleteObject|WinAPI_DestroyIcon|WinAPI_DestroyWindow|WinAPI_DrawEdge|WinAPI_DrawFrameControl|WinAPI_DrawIcon|WinAPI_DrawIconEx|WinAPI_DrawText|WinAPI_EnableWindow|WinAPI_EnumDisplayDevices|WinAPI_EnumWindows|WinAPI_EnumWindowsPopup|WinAPI_EnumWindowsTop|WinAPI_ExpandEnvironmentStrings|WinAPI_ExtractIconEx|WinAPI_FatalAppExit|WinAPI_FillRect|WinAPI_FindExecutable|WinAPI_FindWindow|WinAPI_FlashWindow|WinAPI_FlashWindowEx|WinAPI_FloatToInt|WinAPI_FlushFileBuffers|WinAPI_FormatMessage|WinAPI_FrameRect|WinAPI_FreeLibrary|WinAPI_GetAncestor|WinAPI_GetAsyncKeyState|WinAPI_GetClassName|WinAPI_GetClientHeight|WinAPI_GetClientRect|WinAPI_GetClientWidth|WinAPI_GetCurrentProcess|WinAPI_GetCurrentProcessID|WinAPI_GetCurrentThread|WinAPI_GetCurrentThreadId|WinAPI_GetCursorInfo|WinAPI_GetDC|WinAPI_GetDesktopWindow|WinAPI_GetDeviceCaps|WinAPI_GetDIBits|WinAPI_GetDlgCtrlID|WinAPI_GetDlgItem|WinAPI_GetFileSizeEx|WinAPI_GetFocus|WinAPI_GetForegroundWindow|WinAPI_GetIconInfo|WinAPI_GetLastError|WinAPI_GetLastErrorMessage|WinAPI_GetModuleHandle|WinAPI_GetMousePos|WinAPI_GetMousePosX|WinAPI_GetMousePosY|WinAPI_GetObject|WinAPI_GetOpenFileName|WinAPI_GetOverlappedResult|WinAPI_GetParent|WinAPI_GetProcessAffinityMask|WinAPI_GetSaveFileName|WinAPI_GetStdHandle|WinAPI_GetStockObject|WinAPI_GetSysColor|WinAPI_GetSysColorBrush|WinAPI_GetSystemMetrics|WinAPI_GetTextExtentPoint32|WinAPI_GetWindow|WinAPI_GetWindowDC|WinAPI_GetWindowHeight|WinAPI_GetWindowLong|WinAPI_GetWindowRect|WinAPI_GetWindowText|WinAPI_GetWindowThreadProcessId|WinAPI_GetWindowWidth|WinAPI_GetXYFromPoint|WinAPI_GlobalMemStatus|WinAPI_GUIDFromString|WinAPI_GUIDFromStringEx|WinAPI_HiWord|WinAPI_InProcess|WinAPI_IntToFloat|WinAPI_InvalidateRect|WinAPI_IsClassName|WinAPI_IsWindow|WinAPI_IsWindowVisible|WinAPI_LoadBitmap|WinAPI_LoadImage|WinAPI_LoadLibrary|WinAPI_LoadLibraryEx|WinAPI_LoadShell32Icon|WinAPI_LoadString|WinAPI_LocalFree|WinAPI_LoWord|WinAPI_MakeDWord|WinAPI_MAKELANGID|WinAPI_MAKELCID|WinAPI_MakeLong|WinAPI_MessageBeep|WinAPI_Mouse_Event|WinAPI_MoveWindow|WinAPI_MsgBox|WinAPI_MulDiv|WinAPI_MultiByteToWideChar|WinAPI_MultiByteToWideCharEx|WinAPI_OpenProcess|WinAPI_PointFromRect|WinAPI_PostMessage|WinAPI_PrimaryLangId|WinAPI_PtInRect|WinAPI_ReadFile|WinAPI_ReadProcessMemory|WinAPI_RectIsEmpty|WinAPI_RedrawWindow|WinAPI_RegisterWindowMessage|WinAPI_ReleaseCapture|WinAPI_ReleaseDC|WinAPI_ScreenToClient|WinAPI_SelectObject|WinAPI_SetBkColor|WinAPI_SetCapture|WinAPI_SetCursor|WinAPI_SetDefaultPrinter|WinAPI_SetDIBits|WinAPI_SetEvent|WinAPI_SetFocus|WinAPI_SetFont|WinAPI_SetHandleInformation|WinAPI_SetLastError|WinAPI_SetParent|WinAPI_SetProcessAffinityMask|WinAPI_SetSysColors|WinAPI_SetTextColor|WinAPI_SetWindowLong|WinAPI_SetWindowPos|WinAPI_SetWindowsHookEx|WinAPI_SetWindowText|WinAPI_ShowCursor|WinAPI_ShowError|WinAPI_ShowMsg|WinAPI_ShowWindow|WinAPI_StringFromGUID|WinAPI_SubLangId|WinAPI_SystemParametersInfo|WinAPI_TwipsPerPixelX|WinAPI_TwipsPerPixelY|WinAPI_UnhookWindowsHookEx|WinAPI_UpdateLayeredWindow|WinAPI_UpdateWindow|WinAPI_ValidateClassName|WinAPI_WaitForInputIdle|WinAPI_WaitForMultipleObjects|WinAPI_WaitForSingleObject|WinAPI_WideCharToMultiByte|WinAPI_WindowFromPoint|WinAPI_WriteConsole|WinAPI_WriteFile|WinAPI_WriteProcessMemory|WinNet_AddConnection|WinNet_AddConnection2|WinNet_AddConnection3|WinNet_CancelConnection|WinNet_CancelConnection2|WinNet_CloseEnum|WinNet_ConnectionDialog|WinNet_ConnectionDialog1|WinNet_DisconnectDialog|WinNet_DisconnectDialog1|WinNet_EnumResource|WinNet_GetConnection|WinNet_GetConnectionPerformance|WinNet_GetLastError|WinNet_GetNetworkInformation|WinNet_GetProviderName|WinNet_GetResourceInformation|WinNet_GetResourceParent|WinNet_GetUniversalName|WinNet_GetUser|WinNet_OpenEnum|WinNet_RestoreConnection|WinNet_UseConnection|Word_VersionInfo|WordAttach|WordCreate|WordDocAdd|WordDocAddLink|WordDocAddPicture|WordDocClose|WordDocFindReplace|WordDocGetCollection|WordDocLinkGetCollection|WordDocOpen|WordDocPrint|WordDocPropertyGet|WordDocPropertySet|WordDocSave|WordDocSaveAs|WordErrorHandlerDeRegister|WordErrorHandlerRegister|WordErrorNotify|WordMacroRun|WordPropertyGet|WordPropertySet|WordQuit|' + + 'ce|comments-end|comments-start|cs|include|include-once|NoTrayIcon|RequireAdmin|' + + 'AutoIt3Wrapper_Au3Check_Parameters|AutoIt3Wrapper_Au3Check_Stop_OnWarning|AutoIt3Wrapper_Change2CUI|AutoIt3Wrapper_Compression|AutoIt3Wrapper_cvsWrapper_Parameters|AutoIt3Wrapper_Icon|AutoIt3Wrapper_Outfile|AutoIt3Wrapper_Outfile_Type|AutoIt3Wrapper_Plugin_Funcs|AutoIt3Wrapper_Res_Comment|AutoIt3Wrapper_Res_Description|AutoIt3Wrapper_Res_Field|AutoIt3Wrapper_Res_File_Add|AutoIt3Wrapper_Res_Fileversion|AutoIt3Wrapper_Res_FileVersion_AutoIncrement|AutoIt3Wrapper_Res_Icon_Add|AutoIt3Wrapper_Res_Language|AutoIt3Wrapper_Res_LegalCopyright|AutoIt3Wrapper_res_requestedExecutionLevel|AutoIt3Wrapper_Res_SaveSource|AutoIt3Wrapper_Run_After|AutoIt3Wrapper_Run_Au3check|AutoIt3Wrapper_Run_Before|AutoIt3Wrapper_Run_cvsWrapper|AutoIt3Wrapper_Run_Debug_Mode|AutoIt3Wrapper_Run_Obfuscator|AutoIt3Wrapper_Run_Tidy|AutoIt3Wrapper_Tidy_Stop_OnError|AutoIt3Wrapper_UseAnsi|AutoIt3Wrapper_UseUpx|AutoIt3Wrapper_UseX64|AutoIt3Wrapper_Version|EndRegion|forceref|Obfuscator_Ignore_Funcs|Obfuscator_Ignore_Variables|Obfuscator_Parameters|Region|Tidy_Parameters'; + var atKeywords = 'AppDataCommonDir|AppDataDir|AutoItExe|AutoItPID|AutoItUnicode|AutoItVersion|AutoItX64|COM_EventObj|CommonFilesDir|Compiled|ComputerName|ComSpec|CR|CRLF|DesktopCommonDir|DesktopDepth|DesktopDir|DesktopHeight|DesktopRefresh|DesktopWidth|DocumentsCommonDir|error|exitCode|exitMethod|extended|FavoritesCommonDir|FavoritesDir|GUI_CtrlHandle|GUI_CtrlId|GUI_DragFile|GUI_DragId|GUI_DropId|GUI_WinHandle|HomeDrive|HomePath|HomeShare|HotKeyPressed|HOUR|InetGetActive|InetGetBytesRead|IPAddress1|IPAddress2|IPAddress3|IPAddress4|KBLayout|LF|LogonDNSDomain|LogonDomain|LogonServer|MDAY|MIN|MON|MyDocumentsDir|NumParams|OSBuild|OSLang|OSServicePack|OSTYPE|OSVersion|ProcessorArch|ProgramFilesDir|ProgramsCommonDir|ProgramsDir|ScriptDir|ScriptFullPath|ScriptLineNumber|ScriptName|SEC|StartMenuCommonDir|StartMenuDir|StartupCommonDir|StartupDir|SW_DISABLE|SW_ENABLE|SW_HIDE|SW_LOCK|SW_MAXIMIZE|SW_MINIMIZE|SW_RESTORE|SW_SHOW|SW_SHOWDEFAULT|SW_SHOWMAXIMIZED|SW_SHOWMINIMIZED|SW_SHOWMINNOACTIVE|SW_SHOWNA|SW_SHOWNOACTIVATE|SW_SHOWNORMAL|SW_UNLOCK|SystemDir|TAB|TempDir|TRAY_ID|TrayIconFlashing|TrayIconVisible|UserName|UserProfileDir|WDAY|WindowsDir|WorkingDir|YDAY|YEAR'; + + this.$rules = { start: + [ { token: 'comment.line.ahk', regex: '(?:^| );.*$' }, + { token: 'comment.block.ahk', + regex: '/\\*', push: + [ { token: 'comment.block.ahk', regex: '\\*/', next: 'pop' }, + { defaultToken: 'comment.block.ahk' } ] }, + { token: 'doc.comment.ahk', + regex: '#cs', push: + [ { token: 'doc.comment.ahk', regex: '#ce', next: 'pop' }, + { defaultToken: 'doc.comment.ahk' } ] }, + { token: 'keyword.command.ahk', + regex: '(?:\\b|^)(?:allowsamelinecomments|clipboardtimeout|commentflag|errorstdout|escapechar|hotkeyinterval|hotkeymodifiertimeout|hotstring|include|includeagain|installkeybdhook|installmousehook|keyhistory|ltrim|maxhotkeysperinterval|maxmem|maxthreads|maxthreadsbuffer|maxthreadsperhotkey|noenv|notrayicon|persistent|singleinstance|usehook|winactivateforce|autotrim|blockinput|click|clipwait|continue|control|controlclick|controlfocus|controlget|controlgetfocus|controlgetpos|controlgettext|controlmove|controlsend|controlsendraw|controlsettext|coordmode|critical|detecthiddentext|detecthiddenwindows|drive|driveget|drivespacefree|edit|endrepeat|envadd|envdiv|envget|envmult|envset|envsub|envupdate|exit|exitapp|fileappend|filecopy|filecopydir|filecreatedir|filecreateshortcut|filedelete|filegetattrib|filegetshortcut|filegetsize|filegettime|filegetversion|fileinstall|filemove|filemovedir|fileread|filereadline|filerecycle|filerecycleempty|fileremovedir|fileselectfile|fileselectfolder|filesetattrib|filesettime|formattime|getkeystate|gosub|goto|groupactivate|groupadd|groupclose|groupdeactivate|gui|guicontrol|guicontrolget|hideautoitwin|hotkey|ifequal|ifexist|ifgreater|ifgreaterorequal|ifinstring|ifless|iflessorequal|ifmsgbox|ifnotequal|ifnotexist|ifnotinstring|ifwinactive|ifwinexist|ifwinnotactive|ifwinnotexist|imagesearch|inidelete|iniread|iniwrite|input|inputbox|keyhistory|keywait|listhotkeys|listlines|listvars|menu|mouseclick|mouseclickdrag|mousegetpos|mousemove|msgbox|onexit|outputdebug|pause|pixelgetcolor|pixelsearch|postmessage|process|progress|random|regdelete|regread|regwrite|reload|repeat|run|runas|runwait|send|sendevent|sendinput|sendmode|sendplay|sendmessage|sendraw|setbatchlines|setcapslockstate|setcontroldelay|setdefaultmousespeed|setenv|setformat|setkeydelay|setmousedelay|setnumlockstate|setscrolllockstate|setstorecapslockmode|settimer|settitlematchmode|setwindelay|setworkingdir|shutdown|sleep|sort|soundbeep|soundget|soundgetwavevolume|soundplay|soundset|soundsetwavevolume|splashimage|splashtextoff|splashtexton|splitpath|statusbargettext|statusbarwait|stringcasesense|stringgetpos|stringleft|stringlen|stringlower|stringmid|stringreplace|stringright|stringsplit|stringtrimleft|stringtrimright|stringupper|suspend|sysget|thread|tooltip|transform|traytip|urldownloadtofile|while|winactivate|winactivatebottom|winclose|winget|wingetactivestats|wingetactivetitle|wingetclass|wingetpos|wingettext|wingettitle|winhide|winkill|winmaximize|winmenuselectitem|winminimize|winminimizeall|winminimizeallundo|winmove|winrestore|winset|winsettitle|winshow|winwait|winwaitactive|winwaitclose|winwaitnotactive)\\b', + caseInsensitive: true }, + { token: 'keyword.control.ahk', + regex: '(?:\\b|^)(?:if|else|return|loop|break|for|while|global|local|byref)\\b', + caseInsensitive: true }, + { token: 'support.function.ahk', + regex: '(?:\\b|^)(?:abs|acos|asc|asin|atan|ceil|chr|cos|dllcall|exp|fileexist|floor|getkeystate|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist)\\b', + caseInsensitive: true }, + { token: 'variable.predefined.ahk', + regex: '(?:\\b|^)(?:a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|programfiles|a_programfiles|a_programs|a_programscommon|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\\b', + caseInsensitive: true }, + { token: 'support.constant.ahk', + regex: '(?:\\b|^)(?:shift|lshift|rshift|alt|lalt|ralt|control|lcontrol|rcontrol|ctrl|lctrl|rctrl|lwin|rwin|appskey|altdown|altup|shiftdown|shiftup|ctrldown|ctrlup|lwindown|lwinup|rwindown|rwinup|lbutton|rbutton|mbutton|wheelup|wheelleft|wheelright|wheeldown|xbutton1|xbutton2|joy1|joy2|joy3|joy4|joy5|joy6|joy7|joy8|joy9|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy30|joy31|joy32|joyx|joyy|joyz|joyr|joyu|joyv|joypov|joyname|joybuttons|joyaxes|joyinfo|space|tab|enter|escape|esc|backspace|bs|delete|del|insert|ins|pgup|pgdn|home|end|up|down|left|right|printscreen|ctrlbreak|pause|scrolllock|capslock|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadmult|numpadadd|numpadsub|numpaddiv|numpaddot|numpaddel|numpadins|numpadclear|numpadup|numpaddown|numpadleft|numpadright|numpadhome|numpadend|numpadpgup|numpadpgdn|numpadenter|f1|f2|f3|f4|f5|f6|f7|f8|f9|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f20|f21|f22|f23|f24|browser_back|browser_forward|browser_refresh|browser_stop|browser_search|browser_favorites|browser_home|volume_mute|volume_down|volume_up|media_next|media_prev|media_stop|media_play_pause|launch_mail|launch_media|launch_app1|launch_app2)\\b', + caseInsensitive: true }, + { token: 'variable.parameter', + regex: '(?:\\b|^)(?:pixel|mouse|screen|relative|rgb|ltrim|rtrim|join|low|belownormal|normal|abovenormal|high|realtime|ahk_id|ahk_pid|ahk_class|ahk_group|between|contains|in|is|integer|float|integerfast|floatfast|number|digit|xdigit|alpha|upper|lower|alnum|time|date|not|or|and|alwaysontop|topmost|top|bottom|transparent|transcolor|redraw|region|id|idlast|processname|minmax|controllist|count|list|capacity|statuscd|eject|lock|unlock|label|filesystem|label|setlabel|serial|type|status|static|seconds|minutes|hours|days|read|parse|logoff|close|error|single|tray|add|rename|check|uncheck|togglecheck|enable|disable|toggleenable|default|nodefault|standard|nostandard|color|delete|deleteall|icon|noicon|tip|click|show|mainwindow|nomainwindow|useerrorlevel|text|picture|pic|groupbox|button|checkbox|radio|dropdownlist|ddl|combobox|listbox|listview|datetime|monthcal|updown|slider|tab|tab2|statusbar|treeview|iconsmall|tile|report|sortdesc|nosort|nosorthdr|grid|hdr|autosize|range|xm|ym|ys|xs|xp|yp|font|resize|owner|submit|nohide|minimize|maximize|restore|noactivate|na|cancel|destroy|center|margin|maxsize|minsize|owndialogs|guiescape|guiclose|guisize|guicontextmenu|guidropfiles|tabstop|section|altsubmit|wrap|hscroll|vscroll|border|top|bottom|buttons|expand|first|imagelist|lines|wantctrla|wantf2|vis|visfirst|number|uppercase|lowercase|limit|password|multi|wantreturn|group|background|bold|italic|strike|underline|norm|backgroundtrans|theme|caption|delimiter|minimizebox|maximizebox|sysmenu|toolwindow|flash|style|exstyle|check3|checked|checkedgray|readonly|password|hidden|left|right|center|notab|section|move|focus|hide|choose|choosestring|text|pos|enabled|disabled|visible|lastfound|lastfoundexist|alttab|shiftalttab|alttabmenu|alttabandmenu|alttabmenudismiss|notimers|interrupt|priority|waitclose|blind|raw|unicode|deref|pow|bitnot|bitand|bitor|bitxor|bitshiftleft|bitshiftright|yes|no|ok|cancel|abort|retry|ignore|tryagain|on|off|all|hkey_local_machine|hkey_users|hkey_current_user|hkey_classes_root|hkey_current_config|hklm|hku|hkcu|hkcr|hkcc|reg_sz|reg_expand_sz|reg_multi_sz|reg_dword|reg_qword|reg_binary|reg_link|reg_resource_list|reg_full_resource_descriptor|reg_resource_requirements_list|reg_dword_big_endian)\\b', + caseInsensitive: true }, + { keywordMap: {"constant.language": autoItKeywords}, regex: '\\w+\\b'}, + { keywordMap: {"variable.function": atKeywords}, regex: '@\\w+\\b'}, + { token : "constant.numeric", regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"}, + { token: 'keyword.operator.ahk', + regex: '=|==|<>|:=|<|>|\\*|\\/|\\+|:|\\?|\\-' }, + { token: 'punctuation.ahk', + regex: '#|`|::|,|\\{|\\}|\\(|\\)|\\%' }, + { token: + [ 'punctuation.quote.double', + 'string.quoted.ahk', + 'punctuation.quote.double' ], + regex: '(")((?:[^"]|"")*)(")' }, + { token: [ 'label.ahk', 'punctuation.definition.label.ahk' ], + regex: '^([^: ]+)(:)(?!:)' } ] }; + + this.normalizeRules(); +}; + +AutoHotKeyHighlightRules.metaData = { name: 'AutoHotKey', + scopeName: 'source.ahk', + fileTypes: [ 'ahk' ], + foldingStartMarker: '^\\s*/\\*|^(?![^{]*?;|[^{]*?/\\*(?!.*?\\*/.*?\\{)).*?\\{\\s*($|;|/\\*(?!.*?\\*/.*\\S))', + foldingStopMarker: '^\\s*\\*/|^\\s*\\}' }; + + +oop.inherits(AutoHotKeyHighlightRules, TextHighlightRules); + +exports.AutoHotKeyHighlightRules = AutoHotKeyHighlightRules; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/batchfile.js b/public/lib/ace/mode/batchfile.js new file mode 100644 index 0000000..052a238 --- /dev/null +++ b/public/lib/ace/mode/batchfile.js @@ -0,0 +1,62 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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. + * + * + * Contributor(s): + * + * + * + * ***** END LICENSE BLOCK ***** */ + +/* + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js +*/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var BatchFileHighlightRules = require("./batchfile_highlight_rules").BatchFileHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = BatchFileHighlightRules; + this.foldingRules = new FoldMode(); + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "::"; + this.blockComment = ""; + this.$id = "ace/mode/batchfile"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/batchfile_highlight_rules.js b/public/lib/ace/mode/batchfile_highlight_rules.js new file mode 100644 index 0000000..af4b0ec --- /dev/null +++ b/public/lib/ace/mode/batchfile_highlight_rules.js @@ -0,0 +1,97 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* This file was autogenerated from C:\Users\LED\AppData\Roaming\Sublime Text 2\Packages\Batch File\Batch File.tmLanguage (uuid: ) */ +/**************************************************************************************** + * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * + * fileTypes * + ****************************************************************************************/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var BatchFileHighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { start: + [ { token: 'keyword.command.dosbatch', + regex: '\\b(?:append|assoc|at|attrib|break|cacls|cd|chcp|chdir|chkdsk|chkntfs|cls|cmd|color|comp|compact|convert|copy|date|del|dir|diskcomp|diskcopy|doskey|echo|endlocal|erase|fc|find|findstr|format|ftype|graftabl|help|keyb|label|md|mkdir|mode|more|move|path|pause|popd|print|prompt|pushd|rd|recover|ren|rename|replace|restore|rmdir|set|setlocal|shift|sort|start|subst|time|title|tree|type|ver|verify|vol|xcopy)\\b', + caseInsensitive: true }, + { token: 'keyword.control.statement.dosbatch', + regex: '\\b(?:goto|call|exit)\\b', + caseInsensitive: true }, + { token: 'keyword.control.conditional.if.dosbatch', + regex: '\\bif\\s+not\\s+(?:exist|defined|errorlevel|cmdextversion)\\b', + caseInsensitive: true }, + { token: 'keyword.control.conditional.dosbatch', + regex: '\\b(?:if|else)\\b', + caseInsensitive: true }, + { token: 'keyword.control.repeat.dosbatch', + regex: '\\bfor\\b', + caseInsensitive: true }, + { token: 'keyword.operator.dosbatch', + regex: '\\b(?:EQU|NEQ|LSS|LEQ|GTR|GEQ)\\b' }, + { token: ['doc.comment', 'comment'], + regex: '(?:^|\\b)(rem)($|\\s.*$)', + caseInsensitive: true }, + { token: 'comment.line.colons.dosbatch', + regex: '::.*$' }, + { include: 'variable' }, + { token: 'punctuation.definition.string.begin.shell', + regex: '"', + push: [ + { token: 'punctuation.definition.string.end.shell', regex: '"', next: 'pop' }, + { include: 'variable' }, + { defaultToken: 'string.quoted.double.dosbatch' } ] }, + { token: 'keyword.operator.pipe.dosbatch', regex: '[|]' }, + { token: 'keyword.operator.redirect.shell', + regex: '&>|\\d*>&\\d*|\\d*(?:>>|>|<)|\\d*<&|\\d*<>' } ], + variable: [ + { token: 'constant.numeric', regex: '%%\\w+|%[*\\d]|%\\w+%'}, + { token: 'constant.numeric', regex: '%~\\d+'}, + { token: ['markup.list', 'constant.other', 'markup.list'], + regex: '(%)(\\w+)(%?)' }]}; + + this.normalizeRules(); +}; + +BatchFileHighlightRules.metaData = { name: 'Batch File', + scopeName: 'source.dosbatch', + fileTypes: [ 'bat' ] }; + + +oop.inherits(BatchFileHighlightRules, TextHighlightRules); + +exports.BatchFileHighlightRules = BatchFileHighlightRules; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/behaviour.js b/public/lib/ace/mode/behaviour.js new file mode 100644 index 0000000..abb5a99 --- /dev/null +++ b/public/lib/ace/mode/behaviour.js @@ -0,0 +1,90 @@ +/* ***** 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 Behaviour = function() { + this.$behaviours = {}; +}; + +(function () { + + this.add = function (name, action, callback) { + switch (undefined) { + case this.$behaviours: + this.$behaviours = {}; + case this.$behaviours[name]: + this.$behaviours[name] = {}; + } + this.$behaviours[name][action] = callback; + }; + + this.addBehaviours = function (behaviours) { + for (var key in behaviours) { + for (var action in behaviours[key]) { + this.add(key, action, behaviours[key][action]); + } + } + }; + + this.remove = function (name) { + if (this.$behaviours && this.$behaviours[name]) { + delete this.$behaviours[name]; + } + }; + + this.inherit = function (mode, filter) { + if (typeof mode === "function") { + var behaviours = new mode().getBehaviours(filter); + } else { + var behaviours = mode.getBehaviours(filter); + } + this.addBehaviours(behaviours); + }; + + this.getBehaviours = function (filter) { + if (!filter) { + return this.$behaviours; + } else { + var ret = {}; + for (var i = 0; i < filter.length; i++) { + if (this.$behaviours[filter[i]]) { + ret[filter[i]] = this.$behaviours[filter[i]]; + } + } + return ret; + } + }; + +}).call(Behaviour.prototype); + +exports.Behaviour = Behaviour; +}); diff --git a/public/lib/ace/mode/behaviour/behaviour_test.js b/public/lib/ace/mode/behaviour/behaviour_test.js new file mode 100644 index 0000000..a100b79 --- /dev/null +++ b/public/lib/ace/mode/behaviour/behaviour_test.js @@ -0,0 +1,212 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("../../test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +require("../../multi_select"); +var assert = require("../../test/assertions"); +var Range = require("../../range").Range; +var Editor = require("../../editor").Editor; +var EditSession = require("../../edit_session").EditSession; +var MockRenderer = require("../../test/mockrenderer").MockRenderer; +var JavaScriptMode = require("../javascript").Mode; +var RustMode = require("../rust").Mode; +var XMLMode = require("../xml").Mode; +var editor; +var exec = function(name, times, args) { + do { + editor.commands.exec(name, editor, args); + } while(times --> 1); +}; +var testRanges = function(str) { + assert.equal(editor.selection.getAllRanges() + "", str + ""); +}; + +module.exports = { + "test: cstyle": function() { + function testValue(line) { + assert.equal(editor.getValue(), Array(4).join(line + "\n")); + } + function testSelection(line, col, inc) { + editor.selection.rangeList.ranges.forEach(function(r) { + assert.range(r, line, col, line, col); + line += (inc || 1); + }); + } + var doc = new EditSession([ + "", + "", + "", + "" + ], new JavaScriptMode()); + editor = new Editor(new MockRenderer(), doc); + editor.setOption("behavioursEnabled", true); + + editor.navigateFileStart(); + exec("addCursorBelow", 2); + + exec("insertstring", 1, "if "); + + // pairing ( + exec("insertstring", 1, "("); + testValue("if ()"); + testSelection(0, 4); + exec("insertstring", 1, ")"); + testValue("if ()"); + testSelection(0, 5); + + // pairing [ + exec("gotoleft", 1); + exec("insertstring", 1, "["); + testValue("if ([])"); + testSelection(0, 5); + + exec("insertstring", 1, "]"); + testValue("if ([])"); + testSelection(0, 6); + + // test deletion + exec("gotoleft", 1); + exec("backspace", 1); + testValue("if ()"); + testSelection(0, 4); + + exec("gotolineend", 1); + exec("insertstring", 1, "{"); + testValue("if (){}"); + testSelection(0, 6); + + exec("insertstring", 1, "}"); + testValue("if (){}"); + testSelection(0, 7); + + exec("gotolinestart", 1); + exec("insertstring", 1, "("); + testValue("(if (){}"); + exec("backspace", 1); + + editor.setValue(""); + exec("insertstring", 1, "{"); + assert.equal(editor.getValue(), "{"); + exec("insertstring", 1, "\n"); + assert.equal(editor.getValue(), "{\n \n}"); + + editor.setValue(""); + exec("insertstring", 1, "("); + exec("insertstring", 1, '"'); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '("")'); + exec("backspace", 1); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '("")'); + + editor.setValue("('foo')", 1); + exec("gotoleft", 1); + exec("selectleft", 1); + exec("selectMoreBefore", 1); + exec("insertstring", 1, "'"); + assert.equal(editor.getValue(), "('foo')"); + exec("selectleft", 1); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '("foo")'); + exec("selectleft", 1); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '("foo")'); + + editor.setValue("", 1); + exec("selectleft", 1); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '""'); + exec("insertstring", 1, '\\'); + exec("insertstring", 1, 'n'); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '"\\n"'); + + }, + "test: xml": function() { + editor = new Editor(new MockRenderer()); + editor.setValue(["", + " " + ].join("\n")); + editor.session.setMode(new XMLMode); + exec("golinedown", 1); + exec("gotolineend", 1); + exec("insertstring", 1, '\n'); + assert.equal(editor.session.getLine(2), " "); + exec("gotolineup", 1); + exec("gotolineend", 1); + exec("insertstring", 1, '\n'); + assert.equal(editor.session.getLine(2), " "); + editor.session.setValue(["'); + assert.equal(editor.session.getLine(1), " "); + }, + "test: quotes": function() { + editor = new Editor(new MockRenderer()); + editor.session.setMode(new RustMode); + editor.setValue(""); + exec("insertstring", 1, '"'); + exec("insertstring", 1, 'a'); + assert.equal(editor.getValue(), '"a"'); + exec("backspace", 2); + exec("insertstring", 1, "'"); + assert.equal(editor.getValue(), "'"); + + editor.session.setMode(new JavaScriptMode); + editor.setValue(""); + exec("insertstring", 1, '"'); + exec("insertstring", 1, 'a'); + assert.equal(editor.getValue(), '"a"'); + exec("backspace", 2); + exec("insertstring", 1, "'"); + assert.equal(editor.getValue(), "''"); + exec("backspace", 1); + exec("insertstring", 1, '`'); + exec("insertstring", 1, 'b'); + assert.equal(editor.getValue(), "`b`"); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/mode/behaviour/css.js b/public/lib/ace/mode/behaviour/css.js new file mode 100644 index 0000000..f947f12 --- /dev/null +++ b/public/lib/ace/mode/behaviour/css.js @@ -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"; + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +var CssBehaviour = function () { + + this.inherit(CstyleBehaviour); + + this.add("colon", "insertion", function (state, action, editor, session, text) { + if (text === ':') { + var cursor = editor.getCursorPosition(); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + if (token && token.value.match(/\s+/)) { + token = iterator.stepBackward(); + } + if (token && token.type === 'support.type') { + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar === ':') { + return { + text: '', + selection: [1, 1] + }; + } + if (!line.substring(cursor.column).match(/^\s*;/)) { + return { + text: ':;', + selection: [1, 1] + }; + } + } + } + }); + + this.add("colon", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected === ':') { + var cursor = editor.getCursorPosition(); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + if (token && token.value.match(/\s+/)) { + token = iterator.stepBackward(); + } + if (token && token.type === 'support.type') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar === ';') { + range.end.column ++; + return range; + } + } + } + }); + + this.add("semicolon", "insertion", function (state, action, editor, session, text) { + if (text === ';') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar === ';') { + return { + text: '', + selection: [1, 1] + }; + } + } + }); + +}; +oop.inherits(CssBehaviour, CstyleBehaviour); + +exports.CssBehaviour = CssBehaviour; +}); diff --git a/public/lib/ace/mode/behaviour/cstyle.js b/public/lib/ace/mode/behaviour/cstyle.js new file mode 100644 index 0000000..317c52c --- /dev/null +++ b/public/lib/ace/mode/behaviour/cstyle.js @@ -0,0 +1,400 @@ +/* ***** 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 oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; +var lang = require("../../lib/lang"); + +var SAFE_INSERT_IN_TOKENS = + ["text", "paren.rparen", "punctuation.operator"]; +var SAFE_INSERT_BEFORE_TOKENS = + ["text", "paren.rparen", "punctuation.operator", "comment"]; + +var context; +var contextCache = {}; +var defaultQuotes = {'"' : '"', "'" : "'"}; + +var initContext = function(editor) { + var id = -1; + if (editor.multiSelect) { + id = editor.selection.index; + if (contextCache.rangeCount != editor.multiSelect.rangeCount) + contextCache = {rangeCount: editor.multiSelect.rangeCount}; + } + if (contextCache[id]) + return context = contextCache[id]; + context = contextCache[id] = { + autoInsertedBrackets: 0, + autoInsertedRow: -1, + autoInsertedLineEnd: "", + maybeInsertedBrackets: 0, + maybeInsertedRow: -1, + maybeInsertedLineStart: "", + maybeInsertedLineEnd: "" + }; +}; + +var getWrapped = function(selection, selected, opening, closing) { + var rowDiff = selection.end.row - selection.start.row; + return { + text: opening + selected + closing, + selection: [ + 0, + selection.start.column + 1, + rowDiff, + selection.end.column + (rowDiff ? 0 : 1) + ] + }; +}; + +var CstyleBehaviour = function(options) { + this.add("braces", "insertion", function(state, action, editor, session, text) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + if (text == '{') { + initContext(editor); + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) { + return getWrapped(selection, selected, '{', '}'); + } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { + if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode || options && options.braces) { + CstyleBehaviour.recordAutoInsert(editor, session, "}"); + return { + text: '{}', + selection: [1, 1] + }; + } else { + CstyleBehaviour.recordMaybeInsert(editor, session, "{"); + return { + text: '{', + selection: [1, 1] + }; + } + } + } else if (text == '}') { + initContext(editor); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { + CstyleBehaviour.popAutoInsertedClosing(); + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n" || text == "\r\n") { + initContext(editor); + var closing = ""; + if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) { + closing = lang.stringRepeat("}", context.maybeInsertedBrackets); + CstyleBehaviour.clearMaybeInsertedClosing(); + } + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar === '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}'); + if (!openBracePos) + return null; + var next_indent = this.$getIndent(session.getLine(openBracePos.row)); + } else if (closing) { + var next_indent = this.$getIndent(line); + } else { + CstyleBehaviour.clearMaybeInsertedClosing(); + return; + } + var indent = next_indent + session.getTabString(); + + return { + text: '\n' + indent + '\n' + next_indent + closing, + selection: [1, indent.length, 1, indent.length] + }; + } else { + CstyleBehaviour.clearMaybeInsertedClosing(); + } + }); + + this.add("braces", "deletion", function(state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + initContext(editor); + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } else { + context.maybeInsertedBrackets--; + } + } + }); + + this.add("parens", "insertion", function(state, action, editor, session, text) { + if (text == '(') { + initContext(editor); + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "" && editor.getWrapBehavioursEnabled()) { + return getWrapped(selection, selected, '(', ')'); + } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { + CstyleBehaviour.recordAutoInsert(editor, session, ")"); + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + initContext(editor); + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { + CstyleBehaviour.popAutoInsertedClosing(); + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function(state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + initContext(editor); + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function(state, action, editor, session, text) { + if (text == '[') { + initContext(editor); + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "" && editor.getWrapBehavioursEnabled()) { + return getWrapped(selection, selected, '[', ']'); + } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { + CstyleBehaviour.recordAutoInsert(editor, session, "]"); + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + initContext(editor); + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { + CstyleBehaviour.popAutoInsertedClosing(); + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function(state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + initContext(editor); + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function(state, action, editor, session, text) { + var quotes = session.$mode.$quotes || defaultQuotes; + if (text.length == 1 && quotes[text]) { + if (this.lineCommentStart && this.lineCommentStart.indexOf(text) != -1) + return; + initContext(editor); + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "" && (selected.length != 1 || !quotes[selected]) && editor.getWrapBehavioursEnabled()) { + return getWrapped(selection, selected, quote, quote); + } else if (!selected) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + var rightChar = line.substring(cursor.column, cursor.column + 1); + + var token = session.getTokenAt(cursor.row, cursor.column); + var rightToken = session.getTokenAt(cursor.row, cursor.column + 1); + // We're escaped. + if (leftChar == "\\" && token && /escape/.test(token.type)) + return null; + + var stringBefore = token && /string|escape/.test(token.type); + var stringAfter = !rightToken || /string|escape/.test(rightToken.type); + + var pair; + if (rightChar == quote) { + pair = stringBefore !== stringAfter; + if (pair && /string\.end/.test(rightToken.type)) + pair = false; + } else { + if (stringBefore && !stringAfter) + return null; // wrap string with different quote + if (stringBefore && stringAfter) + return null; // do not pair quotes inside strings + var wordRe = session.$mode.tokenRe; + wordRe.lastIndex = 0; + var isWordBefore = wordRe.test(leftChar); + wordRe.lastIndex = 0; + var isWordAfter = wordRe.test(leftChar); + if (isWordBefore || isWordAfter) + return null; // before or after alphanumeric + if (rightChar && !/[\s;,.})\]\\]/.test(rightChar)) + return null; // there is rightChar and it isn't closing + pair = true; + } + return { + text: pair ? quote + quote : "", + selection: [1,1] + }; + } + } + }); + + this.add("string_dquotes", "deletion", function(state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + initContext(editor); + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == selected) { + range.end.column++; + return range; + } + } + }); + +}; + + +CstyleBehaviour.isSaneInsertion = function(editor, session) { + var cursor = editor.getCursorPosition(); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + + // Don't insert in the middle of a keyword/identifier/lexical + if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) { + // Look ahead in case we're at the end of a token + var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1); + if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) + return false; + } + + // Only insert in front of whitespace/comments + iterator.stepForward(); + return iterator.getCurrentTokenRow() !== cursor.row || + this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS); +}; + +CstyleBehaviour.$matchTokenType = function(token, types) { + return types.indexOf(token.type || token) > -1; +}; + +CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + // Reset previous state if text or context changed too much + if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0])) + context.autoInsertedBrackets = 0; + context.autoInsertedRow = cursor.row; + context.autoInsertedLineEnd = bracket + line.substr(cursor.column); + context.autoInsertedBrackets++; +}; + +CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + if (!this.isMaybeInsertedClosing(cursor, line)) + context.maybeInsertedBrackets = 0; + context.maybeInsertedRow = cursor.row; + context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket; + context.maybeInsertedLineEnd = line.substr(cursor.column); + context.maybeInsertedBrackets++; +}; + +CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) { + return context.autoInsertedBrackets > 0 && + cursor.row === context.autoInsertedRow && + bracket === context.autoInsertedLineEnd[0] && + line.substr(cursor.column) === context.autoInsertedLineEnd; +}; + +CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) { + return context.maybeInsertedBrackets > 0 && + cursor.row === context.maybeInsertedRow && + line.substr(cursor.column) === context.maybeInsertedLineEnd && + line.substr(0, cursor.column) == context.maybeInsertedLineStart; +}; + +CstyleBehaviour.popAutoInsertedClosing = function() { + context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1); + context.autoInsertedBrackets--; +}; + +CstyleBehaviour.clearMaybeInsertedClosing = function() { + if (context) { + context.maybeInsertedBrackets = 0; + context.maybeInsertedRow = -1; + } +}; + + + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); diff --git a/public/lib/ace/mode/behaviour/html.js b/public/lib/ace/mode/behaviour/html.js new file mode 100644 index 0000000..181655c --- /dev/null +++ b/public/lib/ace/mode/behaviour/html.js @@ -0,0 +1,46 @@ +/* ***** 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 oop = require("../../lib/oop"); +var XmlBehaviour = require("../behaviour/xml").XmlBehaviour; + +var HtmlBehaviour = function () { + + XmlBehaviour.call(this); + +}; + +oop.inherits(HtmlBehaviour, XmlBehaviour); + +exports.HtmlBehaviour = HtmlBehaviour; +}); diff --git a/public/lib/ace/mode/behaviour/xml.js b/public/lib/ace/mode/behaviour/xml.js new file mode 100644 index 0000000..549faa6 --- /dev/null +++ b/public/lib/ace/mode/behaviour/xml.js @@ -0,0 +1,208 @@ +/* ***** 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 oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; +var lang = require("../../lib/lang"); + +function is(token, type) { + return token.type.lastIndexOf(type + ".xml") > -1; +} + +var XmlBehaviour = function () { + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selected = session.doc.getTextRange(editor.getSelectionRange()); + if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) { + return { + text: quote + selected + quote, + selection: false + }; + } + + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + + if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) { + // Ignore input and move right one if we're typing over the closing quote. + return { + text: "", + selection: [1, 1] + }; + } + + if (!token) + token = iterator.stepBackward(); + + if (!token) + return; + + while (is(token, "tag-whitespace") || is(token, "whitespace")) { + token = iterator.stepBackward(); + } + var rightSpace = !rightChar || rightChar.match(/\s/); + if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) { + return { + text: quote + quote, + selection: [1, 1] + }; + } + } + }); + + this.add("string_dquotes", "deletion", function(state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == selected) { + range.end.column++; + return range; + } + } + }); + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getSelectionRange().start; + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken() || iterator.stepBackward(); + + // exit if we're not in a tag + if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value"))) + return; + + // exit if we're inside of a quoted attribute value + if (is(token, "reference.attribute-value")) + return; + if (is(token, "attribute-value")) { + var firstChar = token.value.charAt(0); + if (firstChar == '"' || firstChar == "'") { + var lastChar = token.value.charAt(token.value.length - 1); + var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length; + if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar) + return; + } + } + + // find tag name + while (!is(token, "tag-name")) { + token = iterator.stepBackward(); + if (token.value == "<") { + token = iterator.stepForward(); + break; + } + } + + var tokenRow = iterator.getCurrentTokenRow(); + var tokenColumn = iterator.getCurrentTokenColumn(); + + // exit if the tag is ending + if (is(iterator.stepBackward(), "end-tag-open")) + return; + + var element = token.value; + if (tokenRow == position.row) + element = element.substring(0, position.column - tokenColumn); + + if (this.voidElements.hasOwnProperty(element.toLowerCase())) + return; + + return { + text: ">" + "", + selection: [1, 1] + }; + } + }); + + this.add("autoindent", "insertion", function (state, action, editor, session, text) { + if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.getLine(cursor.row); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + + if (token && token.type.indexOf("tag-close") !== -1) { + if (token.value == "/>") + return; + //get tag name + while (token && token.type.indexOf("tag-name") === -1) { + token = iterator.stepBackward(); + } + + if (!token) { + return; + } + + var tag = token.value; + var row = iterator.getCurrentTokenRow(); + + //don't indent after closing tag + token = iterator.stepBackward(); + if (!token || token.type.indexOf("end-tag") !== -1) { + return; + } + + if (this.voidElements && !this.voidElements[tag]) { + var nextToken = session.getTokenAt(cursor.row, cursor.column+1); + var line = session.getLine(row); + var nextIndent = this.$getIndent(line); + var indent = nextIndent + session.getTabString(); + + if (nextToken && nextToken.value === "') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + var state = JSON.parse(state).pop(); + if ((token && token.value === '>') || state !== "StartTag") return; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + var previous = iterator.stepBackward(); + if (!token || !hasType(token, 'meta.tag') || (previous !== null && previous.value.match('/'))) { + return; + } + var tag = token.value.substring(1); + if (atCursor){ + var tag = tag.substring(0, position.column - token.start); + } + + return { + text: '>' + '', + selection: [1, 1] + }; + } + }); + + }; + oop.inherits(XQueryBehaviour, Behaviour); + + exports.XQueryBehaviour = XQueryBehaviour; +}); diff --git a/public/lib/ace/mode/bro.js b/public/lib/ace/mode/bro.js new file mode 100644 index 0000000..fd9ff82 --- /dev/null +++ b/public/lib/ace/mode/bro.js @@ -0,0 +1,58 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js +*/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var BroHighlightRules = require("./bro_highlight_rules").BroHighlightRules; +// TODO: pick appropriate fold mode +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = BroHighlightRules; + this.foldingRules = new FoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + // this.lineCommentStart = ""#""; + // this.blockComment = {start: ""/*"", end: ""*/""}; + // Extra logic goes here. + this.$id = "ace/mode/bro"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/bro_highlight_rules.js b/public/lib/ace/mode/bro_highlight_rules.js new file mode 100644 index 0000000..6c36a83 --- /dev/null +++ b/public/lib/ace/mode/bro_highlight_rules.js @@ -0,0 +1,204 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, 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 ***** */ + +/* This file was autogenerated from Bro.tmLanguage (uuid: ) */ +/**************************************************************************************** + * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * + * fileTypes * + ****************************************************************************************/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var BroHighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + start: [{ + token: "punctuation.definition.comment.bro", + regex: /#/, + push: [{ + token: "comment.line.number-sign.bro", + regex: /$/, + next: "pop" + }, { + defaultToken: "comment.line.number-sign.bro" + }] + }, { + token: "keyword.control.bro", + regex: /\b(?:break|case|continue|else|for|if|return|switch|next|when|timeout|schedule)\b/ + }, { + token: [ + "meta.function.bro", + "meta.function.bro", + "storage.type.bro", + "meta.function.bro", + "entity.name.function.bro", + "meta.function.bro" + ], + regex: /^(\s*)(?:function|hook|event)(\s*)(.*)(\s*\()(.*)(\).*$)/ + }, { + token: "storage.type.bro", + regex: /\b(?:bool|enum|double|int|count|port|addr|subnet|any|file|interval|time|string|table|vector|set|record|pattern|hook)\b/ + }, { + token: "storage.modifier.bro", + regex: /\b(?:global|const|redef|local|&(?:optional|rotate_interval|rotate_size|add_func|del_func|expire_func|expire_create|expire_read|expire_write|persistent|synchronized|encrypt|mergeable|priority|group|type_column|log|error_handler))\b/ + }, { + token: "keyword.operator.bro", + regex: /\s*(?:\||&&|(?:>|<|!)=?|==)\s*|\b!?in\b/ + }, { + token: "constant.language.bro", + regex: /\b(?:T|F)\b/ + }, { + token: "constant.numeric.bro", + regex: /\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:(?:e|E)(?:\+|-)?[0-9]+)?)(?:\/(?:tcp|udp|icmp)|\s*(?:u?sec|min|hr|day)s?)?\b/ + }, { + token: "punctuation.definition.string.begin.bro", + regex: /"/, + push: [{ + token: "punctuation.definition.string.end.bro", + regex: /"/, + next: "pop" + }, { + include: "#string_escaped_char" + }, { + include: "#string_placeholder" + }, { + defaultToken: "string.quoted.double.bro" + }] + }, { + token: "punctuation.definition.string.begin.bro", + regex: /\//, + push: [{ + token: "punctuation.definition.string.end.bro", + regex: /\//, + next: "pop" + }, { + include: "#string_escaped_char" + }, { + include: "#string_placeholder" + }, { + defaultToken: "string.quoted.regex.bro" + }] + }, { + token: [ + "meta.preprocessor.bro.load", + "keyword.other.special-method.bro" + ], + regex: /^(\s*)(\@load(?:-sigs)?)\b/, + push: [{ + token: [], + regex: /(?=\#)|$/, + next: "pop" + }, { + defaultToken: "meta.preprocessor.bro.load" + }] + }, { + token: [ + "meta.preprocessor.bro.if", + "keyword.other.special-method.bro", + "meta.preprocessor.bro.if" + ], + regex: /^(\s*)(\@endif|\@if(?:n?def)?)(.*$)/, + push: [{ + token: [], + regex: /$/, + next: "pop" + }, { + defaultToken: "meta.preprocessor.bro.if" + }] + }], + "#disabled": [{ + token: "text", + regex: /^\s*\@if(?:n?def)?\b.*$/, + push: [{ + token: "text", + regex: /^\s*\@endif\b.*$/, + next: "pop" + }, { + include: "#disabled" + }, { + include: "#pragma-mark" + }], + comment: "eat nested preprocessor ifdefs" + }], + "#preprocessor-rule-other": [{ + token: [ + "text", + "meta.preprocessor.bro", + "meta.preprocessor.bro", + "text" + ], + regex: /^(\s*)(@if)((?:n?def)?)\b(.*?)(?:(?=)|$)/, + push: [{ + token: ["text", "meta.preprocessor.bro", "text"], + regex: /^(\s*)(@endif)\b(.*$)/, + next: "pop" + }, { + include: "$base" + }] + }], + "#string_escaped_char": [{ + token: "constant.character.escape.bro", + regex: /\\(?:\\|[abefnprtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-fA-F0-9]{,2})/ + }, { + token: "invalid.illegal.unknown-escape.bro", + regex: /\\./ + }], + "#string_placeholder": [{ + token: "constant.other.placeholder.bro", + regex: /%(?:\d+\$)?[#0\- +']*[,;:_]?(?:-?\d+|\*(?:-?\d+\$)?)?(?:\.(?:-?\d+|\*(?:-?\d+\$)?)?)?(?:hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?[diouxXDOUeEfFgGaACcSspn%]/ + }, { + token: "invalid.illegal.placeholder.bro", + regex: /%/ + }] + }; + + this.normalizeRules(); +}; + +BroHighlightRules.metaData = { + fileTypes: ["bro"], + foldingStartMarker: "^(\\@if(n?def)?)", + foldingStopMarker: "^\\@endif", + keyEquivalent: "@B", + name: "Bro", + scopeName: "source.bro" +}; + + +oop.inherits(BroHighlightRules, TextHighlightRules); + +exports.BroHighlightRules = BroHighlightRules; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/c9search.js b/public/lib/ace/mode/c9search.js new file mode 100644 index 0000000..3286456 --- /dev/null +++ b/public/lib/ace/mode/c9search.js @@ -0,0 +1,67 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var C9SearchHighlightRules = require("./c9search_highlight_rules").C9SearchHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var C9StyleFoldMode = require("./folding/c9search").FoldMode; + +var Mode = function() { + this.HighlightRules = C9SearchHighlightRules; + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new C9StyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.$id = "ace/mode/c9search"; +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); diff --git a/public/lib/ace/mode/c9search_highlight_rules.js b/public/lib/ace/mode/c9search_highlight_rules.js new file mode 100644 index 0000000..96de823 --- /dev/null +++ b/public/lib/ace/mode/c9search_highlight_rules.js @@ -0,0 +1,193 @@ +/* ***** 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 oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +function safeCreateRegexp(source, flag) { + try { + return new RegExp(source, flag); + } catch(e) {} +} + +var C9SearchHighlightRules = function() { + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + this.$rules = { + "start" : [ + { + tokenNames : ["c9searchresults.constant.numeric", "c9searchresults.text", "c9searchresults.text", "c9searchresults.keyword"], + regex : /(^\s+[0-9]+)(:)(\d*\s?)([^\r\n]+)/, + onMatch : function(val, state, stack) { + var values = this.splitRegex.exec(val); + var types = this.tokenNames; + var tokens = [{ + type: types[0], + value: values[1] + }, { + type: types[1], + value: values[2] + }]; + + if (values[3]) { + if (values[3] == " ") + tokens[1] = { type: types[1], value: values[2] + " " }; + else + tokens.push({ type: types[1], value: values[3] }); + } + var regex = stack[1]; + var str = values[4]; + + var m; + var last = 0; + if (regex && regex.exec) { + regex.lastIndex = 0; + while (m = regex.exec(str)) { + var skipped = str.substring(last, m.index); + last = regex.lastIndex; + if (skipped) + tokens.push({type: types[2], value: skipped}); + if (m[0]) + tokens.push({type: types[3], value: m[0]}); + else if (!skipped) + break; + } + } + if (last < str.length) + tokens.push({type: types[2], value: str.substr(last)}); + return tokens; + } + }, + { + regex : "^Searching for [^\\r\\n]*$", + onMatch: function(val, state, stack) { + var parts = val.split("\x01"); + if (parts.length < 3) + return "text"; + + var options, search; + + var i = 0; + var tokens = [{ + value: parts[i++] + "'", + type: "text" + }, { + value: search = parts[i++], + type: "text" // "c9searchresults.keyword" + }, { + value: "'" + parts[i++], + type: "text" + }]; + + // replaced + if (parts[2] !== " in") { + tokens.push({ + value: "'" + parts[i++] + "'", + type: "text" + }, { + value: parts[i++], + type: "text" + }); + } + // path + tokens.push({ + value: " " + parts[i++] + " ", + type: "text" + }); + // options + if (parts[i+1]) { + options = parts[i+1]; + tokens.push({ + value: "(" + parts[i+1] + ")", + type: "text" + }); + i += 1; + } else { + i -= 1; + } + while (i++ < parts.length) { + parts[i] && tokens.push({ + value: parts[i], + type: "text" + }); + } + + if (search) { + if (!/regex/.test(options)) + search = lang.escapeRegExp(search); + if (/whole/.test(options)) + search = "\\b" + search + "\\b"; + } + + var regex = search && safeCreateRegexp( + "(" + search + ")", + / sensitive/.test(options) ? "g" : "ig" + ); + if (regex) { + stack[0] = state; + stack[1] = regex; + } + + return tokens; + } + }, + { + regex : "^(?=Found \\d+ matches)", + token : "text", + next : "numbers" + }, + { + token : "string", // single line + regex : "^\\S:?[^:]+", + next : "numbers" + } + ], + numbers:[{ + regex : "\\d+", + token : "constant.numeric" + }, { + regex : "$", + token : "text", + next : "start" + }] + }; + this.normalizeRules(); +}; + +oop.inherits(C9SearchHighlightRules, TextHighlightRules); + +exports.C9SearchHighlightRules = C9SearchHighlightRules; + +}); \ No newline at end of file diff --git a/public/lib/ace/mode/c_cpp.js b/public/lib/ace/mode/c_cpp.js new file mode 100644 index 0000000..a2dc133 --- /dev/null +++ b/public/lib/ace/mode/c_cpp.js @@ -0,0 +1,101 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = c_cppHighlightRules; + + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = "//"; + this.blockComment = {start: "/*", end: "*/"}; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.getTokenizer().getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.$id = "ace/mode/c_cpp"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/c_cpp_highlight_rules.js b/public/lib/ace/mode/c_cpp_highlight_rules.js new file mode 100644 index 0000000..20bbe5a --- /dev/null +++ b/public/lib/ace/mode/c_cpp_highlight_rules.js @@ -0,0 +1,199 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +// used by objective-c +var cFunctions = exports.cFunctions = "\\b(?:hypot(?:f|l)?|s(?:scanf|ystem|nprintf|ca(?:nf|lb(?:n(?:f|l)?|ln(?:f|l)?))|i(?:n(?:h(?:f|l)?|f|l)?|gn(?:al|bit))|tr(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(?:jmp|vbuf|locale|buf)|qrt(?:f|l)?|w(?:scanf|printf)|rand)|n(?:e(?:arbyint(?:f|l)?|xt(?:toward(?:f|l)?|after(?:f|l)?))|an(?:f|l)?)|c(?:s(?:in(?:h(?:f|l)?|f|l)?|qrt(?:f|l)?)|cos(?:h(?:f)?|f|l)?|imag(?:f|l)?|t(?:ime|an(?:h(?:f|l)?|f|l)?)|o(?:s(?:h(?:f|l)?|f|l)?|nj(?:f|l)?|pysign(?:f|l)?)|p(?:ow(?:f|l)?|roj(?:f|l)?)|e(?:il(?:f|l)?|xp(?:f|l)?)|l(?:o(?:ck|g(?:f|l)?)|earerr)|a(?:sin(?:h(?:f|l)?|f|l)?|cos(?:h(?:f|l)?|f|l)?|tan(?:h(?:f|l)?|f|l)?|lloc|rg(?:f|l)?|bs(?:f|l)?)|real(?:f|l)?|brt(?:f|l)?)|t(?:ime|o(?:upper|lower)|an(?:h(?:f|l)?|f|l)?|runc(?:f|l)?|gamma(?:f|l)?|mp(?:nam|file))|i(?:s(?:space|n(?:ormal|an)|cntrl|inf|digit|u(?:nordered|pper)|p(?:unct|rint)|finite|w(?:space|c(?:ntrl|type)|digit|upper|p(?:unct|rint)|lower|al(?:num|pha)|graph|xdigit|blank)|l(?:ower|ess(?:equal|greater)?)|al(?:num|pha)|gr(?:eater(?:equal)?|aph)|xdigit|blank)|logb(?:f|l)?|max(?:div|abs))|di(?:v|fftime)|_Exit|unget(?:c|wc)|p(?:ow(?:f|l)?|ut(?:s|c(?:har)?|wc(?:har)?)|error|rintf)|e(?:rf(?:c(?:f|l)?|f|l)?|x(?:it|p(?:2(?:f|l)?|f|l|m1(?:f|l)?)?))|v(?:s(?:scanf|nprintf|canf|printf|w(?:scanf|printf))|printf|f(?:scanf|printf|w(?:scanf|printf))|w(?:scanf|printf)|a_(?:start|copy|end|arg))|qsort|f(?:s(?:canf|e(?:tpos|ek))|close|tell|open|dim(?:f|l)?|p(?:classify|ut(?:s|c|w(?:s|c))|rintf)|e(?:holdexcept|set(?:e(?:nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(?:aiseexcept|ror)|get(?:e(?:nv|xceptflag)|round))|flush|w(?:scanf|ide|printf|rite)|loor(?:f|l)?|abs(?:f|l)?|get(?:s|c|pos|w(?:s|c))|re(?:open|e|ad|xp(?:f|l)?)|m(?:in(?:f|l)?|od(?:f|l)?|a(?:f|l|x(?:f|l)?)?))|l(?:d(?:iv|exp(?:f|l)?)|o(?:ngjmp|cal(?:time|econv)|g(?:1(?:p(?:f|l)?|0(?:f|l)?)|2(?:f|l)?|f|l|b(?:f|l)?)?)|abs|l(?:div|abs|r(?:int(?:f|l)?|ound(?:f|l)?))|r(?:int(?:f|l)?|ound(?:f|l)?)|gamma(?:f|l)?)|w(?:scanf|c(?:s(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?|mbs)|pbrk|ftime|len|r(?:chr|tombs)|xfrm)|to(?:b|mb)|rtomb)|printf|mem(?:set|c(?:hr|py|mp)|move))|a(?:s(?:sert|ctime|in(?:h(?:f|l)?|f|l)?)|cos(?:h(?:f|l)?|f|l)?|t(?:o(?:i|f|l(?:l)?)|exit|an(?:h(?:f|l)?|2(?:f|l)?|f|l)?)|b(?:s|ort))|g(?:et(?:s|c(?:har)?|env|wc(?:har)?)|mtime)|r(?:int(?:f|l)?|ound(?:f|l)?|e(?:name|alloc|wind|m(?:ove|quo(?:f|l)?|ainder(?:f|l)?))|a(?:nd|ise))|b(?:search|towc)|m(?:odf(?:f|l)?|em(?:set|c(?:hr|py|mp)|move)|ktime|alloc|b(?:s(?:init|towcs|rtowcs)|towc|len|r(?:towc|len))))\\b"; + +var c_cppHighlightRules = function() { + + var keywordControls = ( + "break|case|continue|default|do|else|for|goto|if|_Pragma|" + + "return|switch|while|catch|operator|try|throw|using" + ); + + var storageType = ( + "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" + + "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" + + "class|wchar_t|template|char16_t|char32_t" + ); + + var storageModifiers = ( + "const|extern|register|restrict|static|volatile|inline|private|" + + "protected|public|friend|explicit|virtual|export|mutable|typename|" + + "constexpr|new|delete|alignas|alignof|decltype|noexcept|thread_local" + ); + + var keywordOperators = ( + "and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq" + + "const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace" + ); + + var builtinConstants = ( + "NULL|true|false|TRUE|FALSE|nullptr" + ); + + var keywordMapper = this.$keywords = this.createKeywordMapper({ + "keyword.control" : keywordControls, + "storage.type" : storageType, + "storage.modifier" : storageModifiers, + "keyword.operator" : keywordOperators, + "variable.language": "this", + "constant.language": builtinConstants + }, "identifier"); + + var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b"; + var escapeRe = /\\(?:['"?\\abfnrtv]|[0-7]{1,3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}U[a-fA-F\d]{8}|.)/.source; + var formatRe = "%" + + /(\d+\$)?/.source // field (argument #) + + /[#0\- +']*/.source // flags + + /[,;:_]?/.source // separator character (AltiVec) + + /((-?\d+)|\*(-?\d+\$)?)?/.source // minimum field width + + /(\.((-?\d+)|\*(-?\d+\$)?)?)?/.source // precision + + /(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?/.source // length modifier + + /(\[[^"\]]+\]|[diouxXDOUeEfFgGaACcSspn%])/.source; // conversion type + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "//$", + next : "start" + }, { + token : "comment", + regex : "//", + next : "singleLineComment" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // character + regex : "'(?:" + escapeRe + "|.)?'" + }, { + token : "string.start", + regex : '"', + stateName: "qqstring", + next: [ + { token: "string", regex: /\\\s*$/, next: "qqstring" }, + { token: "constant.language.escape", regex: escapeRe }, + { token: "constant.language.escape", regex: formatRe }, + { token: "string.end", regex: '"|$', next: "start" }, + { defaultToken: "string"} + ] + }, { + token : "string.start", + regex : 'R"\\(', + stateName: "rawString", + next: [ + { token: "string.end", regex: '\\)"', next: "start" }, + { defaultToken: "string"} + ] + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b" + }, { + token : "keyword", // pre-compiler directives + regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b", + next : "directive" + }, { + token : "keyword", // special case pre-compiler directive + regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b" + }, { + token : "support.function.C99.c", + regex : cFunctions + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*" + }, { + token : "keyword.operator", + regex : /--|\+\+|<<=|>>=|>>>=|<>|&&|\|\||\?:|[*%\/+\-&\^|~!<>=]=?/ + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\." + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : "\\*\\/", + next : "start" + }, { + defaultToken : "comment" + } + ], + "singleLineComment" : [ + { + token : "comment", + regex : /\\$/, + next : "singleLineComment" + }, { + token : "comment", + regex : /$/, + next : "start" + }, { + defaultToken: "comment" + } + ], + "directive" : [ + { + token : "constant.other.multiline", + regex : /\\/ + }, + { + token : "constant.other.multiline", + regex : /.*\\/ + }, + { + token : "constant.other", + regex : "\\s*<.+?>", + next : "start" + }, + { + token : "constant.other", // single line + regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]', + next : "start" + }, + { + token : "constant.other", // single line + regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']", + next : "start" + }, + // "\" implies multiline, while "/" implies comment + { + token : "constant.other", + regex : /[^\\\/]+/, + next : "start" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); + this.normalizeRules(); +}; + +oop.inherits(c_cppHighlightRules, TextHighlightRules); + +exports.c_cppHighlightRules = c_cppHighlightRules; +}); diff --git a/public/lib/ace/mode/cirru.js b/public/lib/ace/mode/cirru.js new file mode 100644 index 0000000..75a4d0c --- /dev/null +++ b/public/lib/ace/mode/cirru.js @@ -0,0 +1,52 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2014, 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 oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CirruHighlightRules = require("./cirru_highlight_rules").CirruHighlightRules; +var CoffeeFoldMode = require("./folding/coffee").FoldMode; + +var Mode = function() { + this.HighlightRules = CirruHighlightRules; + this.foldingRules = new CoffeeFoldMode(); + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "--"; + this.$id = "ace/mode/cirru"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/cirru_highlight_rules.js b/public/lib/ace/mode/cirru_highlight_rules.js new file mode 100644 index 0000000..de28336 --- /dev/null +++ b/public/lib/ace/mode/cirru_highlight_rules.js @@ -0,0 +1,125 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2014, 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 oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +// see http://cirru.org for more about this language +var CirruHighlightRules = function() { + this.$rules = { + start: [{ + token: 'constant.numeric', + regex: /[\d\.]+/ + }, { + token: 'comment.line.double-dash', + regex: /--/, + next: 'comment' + }, { + token: 'storage.modifier', + regex: /\(/ + }, { + token: 'storage.modifier', + regex: /,/, + next: 'line' + }, { + token: 'support.function', + regex: /[^\(\)"\s]+/, + next: 'line' + }, { + token: 'string.quoted.double', + regex: /"/, + next: 'string' + }, { + token: 'storage.modifier', + regex: /\)/ + }], + comment: [{ + token: 'comment.line.double-dash', + regex: / +[^\n]+/, + next: 'start' + }], + string: [{ + token: 'string.quoted.double', + regex: /"/, + next: 'line' + }, { + token: 'constant.character.escape', + regex: /\\/, + next: 'escape' + }, { + token: 'string.quoted.double', + regex: /[^\\"]+/ + }], + escape: [{ + token: 'constant.character.escape', + regex: /./, + next: 'string' + }], + line: [{ + token: 'constant.numeric', + regex: /[\d\.]+/ + }, { + token: 'markup.raw', + regex: /^\s*/, + next: 'start' + }, { + token: 'storage.modifier', + regex: /\$/, + next: 'start' + }, { + token: 'variable.parameter', + regex: /[^\(\)"\s]+/ + }, { + token: 'storage.modifier', + regex: /\(/, + next: 'start' + }, { + token: 'storage.modifier', + regex: /\)/ + }, { + token: 'markup.raw', + regex: /^ */, + next: 'start' + }, { + token: 'string.quoted.double', + regex: /"/, + next: 'string' + }] + }; + +}; + +oop.inherits(CirruHighlightRules, TextHighlightRules); + +exports.CirruHighlightRules = CirruHighlightRules; +}); diff --git a/public/lib/ace/mode/clojure.js b/public/lib/ace/mode/clojure.js new file mode 100644 index 0000000..6bb9b0a --- /dev/null +++ b/public/lib/ace/mode/clojure.js @@ -0,0 +1,129 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var ClojureHighlightRules = require("./clojure_highlight_rules").ClojureHighlightRules; +var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent; + +var Mode = function() { + this.HighlightRules = ClojureHighlightRules; + this.$outdent = new MatchingParensOutdent(); + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = ";"; + this.minorIndentFunctions = ["defn", "defn-", "defmacro", "def", "deftest", "testing"]; + + this.$toIndent = function(str) { + return str.split('').map(function(ch) { + if (/\s/.exec(ch)) { + return ch; + } else { + return ' '; + } + }).join(''); + }; + + this.$calculateIndent = function(line, tab) { + var baseIndent = this.$getIndent(line); + var delta = 0; + var isParen, ch; + // Walk back from end of line, find matching braces + for (var i = line.length - 1; i >= 0; i--) { + ch = line[i]; + if (ch === '(') { + delta--; + isParen = true; + } else if (ch === '(' || ch === '[' || ch === '{') { + delta--; + isParen = false; + } else if (ch === ')' || ch === ']' || ch === '}') { + delta++; + } + if (delta < 0) { + break; + } + } + if (delta < 0 && isParen) { + // Were more brackets opened than closed and was a ( left open? + i += 1; + var iBefore = i; + var fn = ''; + while (true) { + ch = line[i]; + if (ch === ' ' || ch === '\t') { + if(this.minorIndentFunctions.indexOf(fn) !== -1) { + return this.$toIndent(line.substring(0, iBefore - 1) + tab); + } else { + return this.$toIndent(line.substring(0, i + 1)); + } + } else if (ch === undefined) { + return this.$toIndent(line.substring(0, iBefore - 1) + tab); + } + fn += line[i]; + i++; + } + } else if(delta < 0 && !isParen) { + // Were more brackets openend than closed and was it not a (? + return this.$toIndent(line.substring(0, i+1)); + } else if(delta > 0) { + // Mere more brackets closed than opened? Outdent. + baseIndent = baseIndent.substring(0, baseIndent.length - tab.length); + return baseIndent; + } else { + // Were they nicely matched? Just indent like line before. + return baseIndent; + } + }; + + this.getNextLineIndent = function(state, line, tab) { + return this.$calculateIndent(line, tab); + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.$id = "ace/mode/clojure"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/clojure_highlight_rules.js b/public/lib/ace/mode/clojure_highlight_rules.js new file mode 100644 index 0000000..008d02e --- /dev/null +++ b/public/lib/ace/mode/clojure_highlight_rules.js @@ -0,0 +1,200 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + + +var ClojureHighlightRules = function() { + + var builtinFunctions = ( + '* *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* ' + + '*command-line-args* *compile-files* *compile-path* *e *err* *file* ' + + '*flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* ' + + '*print-dup* *print-length* *print-level* *print-meta* *print-readably* ' + + '*read-eval* *source-path* *use-context-classloader* ' + + '*warn-on-reflection* + - -> ->> .. / < <= = ' + + '== > > >= >= accessor aclone ' + + 'add-classpath add-watch agent agent-errors aget alength alias all-ns ' + + 'alter alter-meta! alter-var-root amap ancestors and apply areduce ' + + 'array-map aset aset-boolean aset-byte aset-char aset-double aset-float ' + + 'aset-int aset-long aset-short assert assoc assoc! assoc-in associative? ' + + 'atom await await-for await1 bases bean bigdec bigint binding bit-and ' + + 'bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left ' + + 'bit-shift-right bit-test bit-xor boolean boolean-array booleans ' + + 'bound-fn bound-fn* butlast byte byte-array bytes cast char char-array ' + + 'char-escape-string char-name-string char? chars chunk chunk-append ' + + 'chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? ' + + 'class class? clear-agent-errors clojure-version coll? comment commute ' + + 'comp comparator compare compare-and-set! compile complement concat cond ' + + 'condp conj conj! cons constantly construct-proxy contains? count ' + + 'counted? create-ns create-struct cycle dec decimal? declare definline ' + + 'defmacro defmethod defmulti defn defn- defonce defstruct delay delay? ' + + 'deliver deref derive descendants destructure disj disj! dissoc dissoc! ' + + 'distinct distinct? doall doc dorun doseq dosync dotimes doto double ' + + 'double-array doubles drop drop-last drop-while empty empty? ensure ' + + 'enumeration-seq eval even? every? false? ffirst file-seq filter find ' + + 'find-doc find-ns find-var first float float-array float? floats flush ' + + 'fn fn? fnext for force format future future-call future-cancel ' + + 'future-cancelled? future-done? future? gen-class gen-interface gensym ' + + 'get get-in get-method get-proxy-class get-thread-bindings get-validator ' + + 'hash hash-map hash-set identical? identity if-let if-not ifn? import ' + + 'in-ns inc init-proxy instance? int int-array integer? interleave intern ' + + 'interpose into into-array ints io! isa? iterate iterator-seq juxt key ' + + 'keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list ' + + 'list* list? load load-file load-reader load-string loaded-libs locking ' + + 'long long-array longs loop macroexpand macroexpand-1 make-array ' + + 'make-hierarchy map map? mapcat max max-key memfn memoize merge ' + + 'merge-with meta method-sig methods min min-key mod name namespace neg? ' + + 'newline next nfirst nil? nnext not not-any? not-empty not-every? not= ' + + 'ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ' + + 'ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? ' + + 'or parents partial partition pcalls peek persistent! pmap pop pop! ' + + 'pop-thread-bindings pos? pr pr-str prefer-method prefers ' + + 'primitives-classnames print print-ctor print-doc print-dup print-method ' + + 'print-namespace-doc print-simple print-special-doc print-str printf ' + + 'println println-str prn prn-str promise proxy proxy-call-with-super ' + + 'proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot ' + + 'rand rand-int range ratio? rational? rationalize re-find re-groups ' + + 're-matcher re-matches re-pattern re-seq read read-line read-string ' + + 'reduce ref ref-history-count ref-max-history ref-min-history ref-set ' + + 'refer refer-clojure release-pending-sends rem remove remove-method ' + + 'remove-ns remove-watch repeat repeatedly replace replicate require ' + + 'reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq ' + + 'rsubseq second select-keys send send-off seq seq? seque sequence ' + + 'sequential? set set-validator! set? short short-array shorts ' + + 'shutdown-agents slurp some sort sort-by sorted-map sorted-map-by ' + + 'sorted-set sorted-set-by sorted? special-form-anchor special-symbol? ' + + 'split-at split-with str stream? string? struct struct-map subs subseq ' + + 'subvec supers swap! symbol symbol? sync syntax-symbol-anchor take ' + + 'take-last take-nth take-while test the-ns time to-array to-array-2d ' + + 'trampoline transient tree-seq true? type unchecked-add unchecked-dec ' + + 'unchecked-divide unchecked-inc unchecked-multiply unchecked-negate ' + + 'unchecked-remainder unchecked-subtract underive unquote ' + + 'unquote-splicing update-in update-proxy use val vals var-get var-set ' + + 'var? vary-meta vec vector vector? when when-first when-let when-not ' + + 'while with-bindings with-bindings* with-in-str with-loading-context ' + + 'with-local-vars with-meta with-open with-out-str with-precision xml-seq ' + + 'zero? zipmap' + ); + + var keywords = ('throw try var ' + + 'def do fn if let loop monitor-enter monitor-exit new quote recur set!' + ); + + var buildinConstants = ("true false nil"); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "constant.language": buildinConstants, + "support.function": builtinFunctions + }, "identifier", false, " "); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : ";.*$" + }, { + token : "keyword", //parens + regex : "[\\(|\\)]" + }, { + token : "keyword", //lists + regex : "[\\'\\(]" + }, { + token : "keyword", //vectors + regex : "[\\[|\\]]" + }, { + token : "keyword", //sets and maps + regex : "[\\{|\\}|\\#\\{|\\#\\}]" + }, { + token : "keyword", // ampersands + regex : '[\\&]' + }, { + token : "keyword", // metadata + regex : '[\\#\\^\\{]' + }, { + token : "keyword", // anonymous fn syntactic sugar + regex : '[\\%]' + }, { + token : "keyword", // deref reader macro + regex : '[@]' + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language", + regex : '[!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+||=|!=|<=|>=|<>|<|>|!|&&]' + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b" + }, { + token : "string", // single line + regex : '"', + next: "string" + }, { + token : "constant", // symbol + regex : /:[^()\[\]{}'"\^%`,;\s]+/ + }, { + token : "string.regexp", //Regular Expressions + regex : '/#"(?:\\.|(?:\\")|[^""\n])*"/g' + } + + ], + "string" : [ + { + token : "constant.language.escape", + regex : "\\\\.|\\\\$" + }, { + token : "string", + regex : '[^"\\\\]+' + }, { + token : "string", + regex : '"', + next : "start" + } + ] + }; +}; + +oop.inherits(ClojureHighlightRules, TextHighlightRules); + +exports.ClojureHighlightRules = ClojureHighlightRules; +}); diff --git a/public/lib/ace/mode/cobol.js b/public/lib/ace/mode/cobol.js new file mode 100644 index 0000000..3b32598 --- /dev/null +++ b/public/lib/ace/mode/cobol.js @@ -0,0 +1,53 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CobolHighlightRules = require("./cobol_highlight_rules").CobolHighlightRules; + +var Mode = function() { + this.HighlightRules = CobolHighlightRules; + this.$behaviour = this.$defaultBehaviour; +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = "*"; + + this.$id = "ace/mode/cobol"; +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); diff --git a/public/lib/ace/mode/cobol_highlight_rules.js b/public/lib/ace/mode/cobol_highlight_rules.js new file mode 100644 index 0000000..36335c9 --- /dev/null +++ b/public/lib/ace/mode/cobol_highlight_rules.js @@ -0,0 +1,100 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CobolHighlightRules = function() { +var keywords = "ACCEPT|MERGE|SUM|ADD||MESSAGE|TABLE|ADVANCING|MODE|TAPE|" + +"AFTER|MULTIPLY|TEST|ALL|NEGATIVE|TEXT|ALPHABET|NEXT|THAN|" + +"ALSO|NO|THEN|ALTERNATE|NOT|THROUGH|AND|NUMBER|THRU|ANY|OCCURS|" + +"TIME|ARE|OF|TO|AREA|OFF|TOP||ASCENDING|OMITTED|TRUE|ASSIGN|ON|TYPE|AT|OPEN|" + +"UNIT|AUTHOR|OR|UNTIL|BEFORE|OTHER|UP|BLANK|OUTPUT|USE|BLOCK|PAGE|USING|BOTTOM|" + +"PERFORM|VALUE|BY|PIC|VALUES|CALL|PICTURE|WHEN|CANCEL|PLUS|WITH|CD|POINTER|WRITE|" + +"CHARACTER|POSITION||ZERO|CLOSE|POSITIVE|ZEROS|COLUMN|PROCEDURE|ZEROES|COMMA|PROGRAM|" + +"COMMON|PROGRAM-ID|COMMUNICATION|QUOTE|COMP|RANDOM|COMPUTE|READ|CONTAINS|RECEIVE|CONFIGURATION|" + +"RECORD|CONTINUE|REDEFINES|CONTROL|REFERENCE|COPY|REMAINDER|COUNT|REPLACE|DATA|REPORT|DATE|RESERVE|" + +"DAY|RESET|DELETE|RETURN|DESTINATION|REWIND|DISABLE|REWRITE|DISPLAY|RIGHT|DIVIDE|RUN|DOWN|SAME|" + +"ELSE|SEARCH|ENABLE|SECTION|END|SELECT|ENVIRONMENT|SENTENCE|EQUAL|SET|ERROR|SIGN|EXIT|SEQUENTIAL|" + +"EXTERNAL|SIZE|FLASE|SORT|FILE|SOURCE|LENGTH|SPACE|LESS|STANDARD|LIMIT|START|LINE|STOP|LOCK|STRING|LOW-VALUE|SUBTRACT"; + + var builtinConstants = ( + "true|false|null" + ); + + var builtinFunctions = ( + "count|min|max|avg|sum|rank|now|coalesce|main" + ); + + var keywordMapper = this.createKeywordMapper({ + "support.function": builtinFunctions, + "keyword": keywords, + "constant.language": builtinConstants + }, "identifier", true); + + this.$rules = { + "start" : [ { + token : "comment", + regex : "\\*.*$" + }, { + token : "string", // " string + regex : '".*?"' + }, { + token : "string", // ' string + regex : "'.*?'" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=" + }, { + token : "paren.lparen", + regex : "[\\(]" + }, { + token : "paren.rparen", + regex : "[\\)]" + }, { + token : "text", + regex : "\\s+" + } ] + }; +}; + +oop.inherits(CobolHighlightRules, TextHighlightRules); + +exports.CobolHighlightRules = CobolHighlightRules; +}); \ No newline at end of file diff --git a/public/lib/ace/mode/coffee.js b/public/lib/ace/mode/coffee.js new file mode 100644 index 0000000..9782fc7 --- /dev/null +++ b/public/lib/ace/mode/coffee.js @@ -0,0 +1,116 @@ +/* ***** 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 Rules = require("./coffee_highlight_rules").CoffeeHighlightRules; +var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var FoldMode = require("./folding/coffee").FoldMode; +var Range = require("../range").Range; +var TextMode = require("./text").Mode; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var oop = require("../lib/oop"); + +function Mode() { + this.HighlightRules = Rules; + this.$outdent = new Outdent(); + this.foldingRules = new FoldMode(); +} + +oop.inherits(Mode, TextMode); + +(function() { + + /*: + [({[=:] # Opening parentheses or brackets + |[-=]> # OR single or double arrow + |\b(?: # OR one of these words: + else # else + |try # OR try + |(?:swi|ca)tch # OR catch, optionally followed by: + (?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)? # a variable + |finally # OR finally + ))\s*$ # all as the last thing on a line (allowing trailing space) + | # ---- OR ---- : + ^\s* # a line starting with optional space + (else\b\s*)? # followed by an optional "else" + (?: # followed by one of the following: + if # if + |for # OR for + |while # OR while + |loop # OR loop + )\b # (as a word) + (?!.*\bthen\b) # ... but NOT followed by "then" on the line + */ + var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|(?:swi|ca)tch(?:\s+[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$|^\s*(else\b\s*)?(?:if|for|while|loop)\b(?!.*\bthen\b)/; + + this.lineCommentStart = "#"; + this.blockComment = {start: "###", end: "###"}; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + var tokens = this.getTokenizer().getLineTokens(line, state).tokens; + + if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') && + state === 'start' && indenter.test(line)) + indent += tab; + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/coffee_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("annotate", function(e) { + session.setAnnotations(e.data); + }); + + worker.on("terminate", function() { + session.clearAnnotations(); + }); + + return worker; + }; + + this.$id = "ace/mode/coffee"; +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); diff --git a/public/lib/ace/mode/coffee/coffee.js b/public/lib/ace/mode/coffee/coffee.js new file mode 100644 index 0000000..f0b0fbc --- /dev/null +++ b/public/lib/ace/mode/coffee/coffee.js @@ -0,0 +1,15 @@ +define(function(require, exports, module) { +function define(f) { module.exports = f() }; define.amd = {}; +/** + * CoffeeScript Compiler v1.9.3 + * http://coffeescript.org + * + * Copyright 2011, Jeremy Ashkenas + * Released under the MIT License + */ +(function(root){var CoffeeScript=function(){function _dereq_(e){return _dereq_[e]}return _dereq_["./helpers"]=function(){var e={},t={exports:e};return function(){var t,n,i,r,s,o;e.starts=function(e,t,n){return t===e.substr(n,t.length)},e.ends=function(e,t,n){var i;return i=t.length,t===e.substr(e.length-i-(n||0),i)},e.repeat=s=function(e,t){var n;for(n="";t>0;)1&t&&(n+=e),t>>>=1,e+=e;return n},e.compact=function(e){var t,n,i,r;for(r=[],t=0,i=e.length;i>t;t++)n=e[t],n&&r.push(n);return r},e.count=function(e,t){var n,i;if(n=i=0,!t.length)return 1/0;for(;i=1+e.indexOf(t,i);)n++;return n},e.merge=function(e,t){return n(n({},e),t)},n=e.extend=function(e,t){var n,i;for(n in t)i=t[n],e[n]=i;return e},e.flatten=i=function(e){var t,n,r,s;for(n=[],r=0,s=e.length;s>r;r++)t=e[r],t instanceof Array?n=n.concat(i(t)):n.push(t);return n},e.del=function(e,t){var n;return n=e[t],delete e[t],n},e.some=null!=(r=Array.prototype.some)?r:function(e){var t,n,i;for(n=0,i=this.length;i>n;n++)if(t=this[n],e(t))return!0;return!1},e.invertLiterate=function(e){var t,n,i;return i=!0,n=function(){var n,r,s,o;for(s=e.split("\n"),o=[],n=0,r=s.length;r>n;n++)t=s[n],i&&/^([ ]{4}|[ ]{0,3}\t)/.test(t)?o.push(t):(i=/^\s*$/.test(t))?o.push(t):o.push("# "+t);return o}(),n.join("\n")},t=function(e,t){return t?{first_line:e.first_line,first_column:e.first_column,last_line:t.last_line,last_column:t.last_column}:e},e.addLocationDataFn=function(e,n){return function(i){return"object"==typeof i&&i.updateLocationDataIfMissing&&i.updateLocationDataIfMissing(t(e,n)),i}},e.locationDataToString=function(e){var t;return"2"in e&&"first_line"in e[2]?t=e[2]:"first_line"in e&&(t=e),t?t.first_line+1+":"+(t.first_column+1)+"-"+(t.last_line+1+":"+(t.last_column+1)):"No location data"},e.baseFileName=function(e,t,n){var i,r;return null==t&&(t=!1),null==n&&(n=!1),r=n?/\\|\//:/\//,i=e.split(r),e=i[i.length-1],t&&e.indexOf(".")>=0?(i=e.split("."),i.pop(),"coffee"===i[i.length-1]&&i.length>1&&i.pop(),i.join(".")):e},e.isCoffee=function(e){return/\.((lit)?coffee|coffee\.md)$/.test(e)},e.isLiterate=function(e){return/\.(litcoffee|coffee\.md)$/.test(e)},e.throwSyntaxError=function(e,t){var n;throw n=new SyntaxError(e),n.location=t,n.toString=o,n.stack=""+n,n},e.updateSyntaxError=function(e,t,n){return e.toString===o&&(e.code||(e.code=t),e.filename||(e.filename=n),e.stack=""+e),e},o=function(){var e,t,n,i,r,o,a,c,h,l,u,p,d,f,m;return this.code&&this.location?(u=this.location,a=u.first_line,o=u.first_column,h=u.last_line,c=u.last_column,null==h&&(h=a),null==c&&(c=o),r=this.filename||"[stdin]",e=this.code.split("\n")[a],m=o,i=a===h?c+1:e.length,l=e.slice(0,m).replace(/[^\s]/g," ")+s("^",i-m),"undefined"!=typeof process&&null!==process&&(n=(null!=(p=process.stdout)?p.isTTY:void 0)&&!(null!=(d=process.env)?d.NODE_DISABLE_COLORS:void 0)),(null!=(f=this.colorful)?f:n)&&(t=function(e){return""+e+""},e=e.slice(0,m)+t(e.slice(m,i))+e.slice(i),l=t(l)),r+":"+(a+1)+":"+(o+1)+": error: "+this.message+"\n"+e+"\n"+l):Error.prototype.toString.call(this)},e.nameWhitespaceCharacter=function(e){switch(e){case" ":return"space";case"\n":return"newline";case"\r":return"carriage return";case" ":return"tab";default:return e}}}.call(this),t.exports}(),_dereq_["./rewriter"]=function(){var e={},t={exports:e};return function(){var t,n,i,r,s,o,a,c,h,l,u,p,d,f,m,g,v,y,b,k=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1},w=[].slice;for(f=function(e,t,n){var i;return i=[e,t],i.generated=!0,n&&(i.origin=n),i},e.Rewriter=function(){function e(){}return e.prototype.rewrite=function(e){return this.tokens=e,this.removeLeadingNewlines(),this.closeOpenCalls(),this.closeOpenIndexes(),this.normalizeLines(),this.tagPostfixConditionals(),this.addImplicitBracesAndParens(),this.addLocationDataToGeneratedTokens(),this.tokens},e.prototype.scanTokens=function(e){var t,n,i;for(i=this.tokens,t=0;n=i[t];)t+=e.call(this,n,t,i);return!0},e.prototype.detectEnd=function(e,t,n){var i,o,a,c,h;for(h=this.tokens,i=0;c=h[e];){if(0===i&&t.call(this,c,e))return n.call(this,c,e);if(!c||0>i)return n.call(this,c,e-1);o=c[0],k.call(s,o)>=0?i+=1:(a=c[0],k.call(r,a)>=0&&(i-=1)),e+=1}return e-1},e.prototype.removeLeadingNewlines=function(){var e,t,n,i,r;for(i=this.tokens,e=t=0,n=i.length;n>t&&(r=i[e][0],"TERMINATOR"===r);e=++t);return e?this.tokens.splice(0,e):void 0},e.prototype.closeOpenCalls=function(){var e,t;return t=function(e,t){var n;return")"===(n=e[0])||"CALL_END"===n||"OUTDENT"===e[0]&&")"===this.tag(t-1)},e=function(e,t){return this.tokens["OUTDENT"===e[0]?t-1:t][0]="CALL_END"},this.scanTokens(function(n,i){return"CALL_START"===n[0]&&this.detectEnd(i+1,t,e),1})},e.prototype.closeOpenIndexes=function(){var e,t;return t=function(e){var t;return"]"===(t=e[0])||"INDEX_END"===t},e=function(e){return e[0]="INDEX_END"},this.scanTokens(function(n,i){return"INDEX_START"===n[0]&&this.detectEnd(i+1,t,e),1})},e.prototype.indexOfTag=function(){var e,t,n,i,r,s,o;for(t=arguments[0],r=arguments.length>=2?w.call(arguments,1):[],e=0,n=i=0,s=r.length;s>=0?s>i:i>s;n=s>=0?++i:--i){for(;"HERECOMMENT"===this.tag(t+n+e);)e+=2;if(null!=r[n]&&("string"==typeof r[n]&&(r[n]=[r[n]]),o=this.tag(t+n+e),0>k.call(r[n],o)))return-1}return t+n+e-1},e.prototype.looksObjectish=function(e){var t,n;return this.indexOfTag(e,"@",null,":")>-1||this.indexOfTag(e,null,":")>-1?!0:(n=this.indexOfTag(e,s),n>-1&&(t=null,this.detectEnd(n+1,function(e){var t;return t=e[0],k.call(r,t)>=0},function(e,n){return t=n}),":"===this.tag(t+1))?!0:!1)},e.prototype.findTagsBackwards=function(e,t){var n,i,o,a,c,h,l;for(n=[];e>=0&&(n.length||(a=this.tag(e),0>k.call(t,a)&&(c=this.tag(e),0>k.call(s,c)||this.tokens[e].generated)&&(h=this.tag(e),0>k.call(u,h))));)i=this.tag(e),k.call(r,i)>=0&&n.push(this.tag(e)),o=this.tag(e),k.call(s,o)>=0&&n.length&&n.pop(),e-=1;return l=this.tag(e),k.call(t,l)>=0},e.prototype.addImplicitBracesAndParens=function(){var e,t;return e=[],t=null,this.scanTokens(function(i,l,p){var d,m,g,v,y,b,w,T,C,E,F,N,L,x,S,D,R,A,I,_,O,$,j,M,B,V,P,U;if(U=i[0],F=(N=l>0?p[l-1]:[])[0],C=(p.length-1>l?p[l+1]:[])[0],j=function(){return e[e.length-1]},M=l,g=function(e){return l-M+e},v=function(){var e,t;return null!=(e=j())?null!=(t=e[2])?t.ours:void 0:void 0},y=function(){var e;return v()&&"("===(null!=(e=j())?e[0]:void 0)},w=function(){var e;return v()&&"{"===(null!=(e=j())?e[0]:void 0)},b=function(){var e;return v&&"CONTROL"===(null!=(e=j())?e[0]:void 0)},B=function(t){var n;return n=null!=t?t:l,e.push(["(",n,{ours:!0}]),p.splice(n,0,f("CALL_START","(")),null==t?l+=1:void 0},d=function(){return e.pop(),p.splice(l,0,f("CALL_END",")",["","end of input",i[2]])),l+=1},V=function(t,n){var r,s;return null==n&&(n=!0),r=null!=t?t:l,e.push(["{",r,{sameLine:!0,startsLine:n,ours:!0}]),s=new String("{"),s.generated=!0,p.splice(r,0,f("{",s,i)),null==t?l+=1:void 0},m=function(t){return t=null!=t?t:l,e.pop(),p.splice(t,0,f("}","}",i)),l+=1},y()&&("IF"===U||"TRY"===U||"FINALLY"===U||"CATCH"===U||"CLASS"===U||"SWITCH"===U))return e.push(["CONTROL",l,{ours:!0}]),g(1);if("INDENT"===U&&v()){if("=>"!==F&&"->"!==F&&"["!==F&&"("!==F&&","!==F&&"{"!==F&&"TRY"!==F&&"ELSE"!==F&&"="!==F)for(;y();)d();return b()&&e.pop(),e.push([U,l]),g(1)}if(k.call(s,U)>=0)return e.push([U,l]),g(1);if(k.call(r,U)>=0){for(;v();)y()?d():w()?m():e.pop();t=e.pop()}if((k.call(c,U)>=0&&i.spaced||"?"===U&&l>0&&!p[l-1].spaced)&&(k.call(o,C)>=0||k.call(h,C)>=0&&!(null!=(L=p[l+1])?L.spaced:void 0)&&!(null!=(x=p[l+1])?x.newLine:void 0)))return"?"===U&&(U=i[0]="FUNC_EXIST"),B(l+1),g(2);if(k.call(c,U)>=0&&this.indexOfTag(l+1,"INDENT")>-1&&this.looksObjectish(l+2)&&!this.findTagsBackwards(l,["CLASS","EXTENDS","IF","CATCH","SWITCH","LEADING_WHEN","FOR","WHILE","UNTIL"]))return B(l+1),e.push(["INDENT",l+2]),g(3);if(":"===U){for(I=function(){var e;switch(!1){case e=this.tag(l-1),0>k.call(r,e):return t[1];case"@"!==this.tag(l-2):return l-2;default:return l-1}}.call(this);"HERECOMMENT"===this.tag(I-2);)I-=2;return this.insideForDeclaration="FOR"===C,P=0===I||(S=this.tag(I-1),k.call(u,S)>=0)||p[I-1].newLine,j()&&(D=j(),$=D[0],O=D[1],("{"===$||"INDENT"===$&&"{"===this.tag(O-1))&&(P||","===this.tag(I-1)||"{"===this.tag(I-1)))?g(1):(V(I,!!P),g(2))}if(w()&&k.call(u,U)>=0&&(j()[2].sameLine=!1),T="OUTDENT"===F||N.newLine,k.call(a,U)>=0||k.call(n,U)>=0&&T)for(;v();)if(R=j(),$=R[0],O=R[1],A=R[2],_=A.sameLine,P=A.startsLine,y()&&","!==F)d();else if(w()&&!this.insideForDeclaration&&_&&"TERMINATOR"!==U&&":"!==F)m();else{if(!w()||"TERMINATOR"!==U||","===F||P&&this.looksObjectish(l+1))break;if("HERECOMMENT"===C)return g(1);m()}if(!(","!==U||this.looksObjectish(l+1)||!w()||this.insideForDeclaration||"TERMINATOR"===C&&this.looksObjectish(l+2)))for(E="OUTDENT"===C?1:0;w();)m(l+E);return g(1)})},e.prototype.addLocationDataToGeneratedTokens=function(){return this.scanTokens(function(e,t,n){var i,r,s,o,a,c;return e[2]?1:e.generated||e.explicit?("{"===e[0]&&(s=null!=(a=n[t+1])?a[2]:void 0)?(r=s.first_line,i=s.first_column):(o=null!=(c=n[t-1])?c[2]:void 0)?(r=o.last_line,i=o.last_column):r=i=0,e[2]={first_line:r,first_column:i,last_line:r,last_column:i},1):1})},e.prototype.normalizeLines=function(){var e,t,r,s,o;return o=r=s=null,t=function(e,t){var r,s,a,c;return";"!==e[1]&&(r=e[0],k.call(p,r)>=0)&&!("TERMINATOR"===e[0]&&(s=this.tag(t+1),k.call(i,s)>=0))&&!("ELSE"===e[0]&&"THEN"!==o)&&!!("CATCH"!==(a=e[0])&&"FINALLY"!==a||"->"!==o&&"=>"!==o)||(c=e[0],k.call(n,c)>=0&&this.tokens[t-1].newLine)},e=function(e,t){return this.tokens.splice(","===this.tag(t-1)?t-1:t,0,s)},this.scanTokens(function(n,a,c){var h,l,u,p,f,m;if(m=n[0],"TERMINATOR"===m){if("ELSE"===this.tag(a+1)&&"OUTDENT"!==this.tag(a-1))return c.splice.apply(c,[a,1].concat(w.call(this.indentation()))),1;if(u=this.tag(a+1),k.call(i,u)>=0)return c.splice(a,1),0}if("CATCH"===m)for(h=l=1;2>=l;h=++l)if("OUTDENT"===(p=this.tag(a+h))||"TERMINATOR"===p||"FINALLY"===p)return c.splice.apply(c,[a+h,0].concat(w.call(this.indentation()))),2+h;return k.call(d,m)>=0&&"INDENT"!==this.tag(a+1)&&("ELSE"!==m||"IF"!==this.tag(a+1))?(o=m,f=this.indentation(c[a]),r=f[0],s=f[1],"THEN"===o&&(r.fromThen=!0),c.splice(a+1,0,r),this.detectEnd(a+2,t,e),"THEN"===m&&c.splice(a,1),1):1})},e.prototype.tagPostfixConditionals=function(){var e,t,n;return n=null,t=function(e,t){var n,i;return i=e[0],n=this.tokens[t-1][0],"TERMINATOR"===i||"INDENT"===i&&0>k.call(d,n)},e=function(e){return"INDENT"!==e[0]||e.generated&&!e.fromThen?n[0]="POST_"+n[0]:void 0},this.scanTokens(function(i,r){return"IF"!==i[0]?1:(n=i,this.detectEnd(r+1,t,e),1)})},e.prototype.indentation=function(e){var t,n;return t=["INDENT",2],n=["OUTDENT",2],e?(t.generated=n.generated=!0,t.origin=n.origin=e):t.explicit=n.explicit=!0,[t,n]},e.prototype.generate=f,e.prototype.tag=function(e){var t;return null!=(t=this.tokens[e])?t[0]:void 0},e}(),t=[["(",")"],["[","]"],["{","}"],["INDENT","OUTDENT"],["CALL_START","CALL_END"],["PARAM_START","PARAM_END"],["INDEX_START","INDEX_END"],["STRING_START","STRING_END"],["REGEX_START","REGEX_END"]],e.INVERSES=l={},s=[],r=[],m=0,v=t.length;v>m;m++)y=t[m],g=y[0],b=y[1],s.push(l[b]=g),r.push(l[g]=b);i=["CATCH","THEN","ELSE","FINALLY"].concat(r),c=["IDENTIFIER","SUPER",")","CALL_END","]","INDEX_END","@","THIS"],o=["IDENTIFIER","NUMBER","STRING","STRING_START","JS","REGEX","REGEX_START","NEW","PARAM_START","CLASS","IF","TRY","SWITCH","THIS","BOOL","NULL","UNDEFINED","UNARY","YIELD","UNARY_MATH","SUPER","THROW","@","->","=>","[","(","{","--","++"],h=["+","-"],a=["POST_IF","FOR","WHILE","UNTIL","WHEN","BY","LOOP","TERMINATOR"],d=["ELSE","->","=>","TRY","FINALLY","THEN"],p=["TERMINATOR","CATCH","FINALLY","ELSE","OUTDENT","LEADING_WHEN"],u=["TERMINATOR","INDENT","OUTDENT"],n=[".","?.","::","?::"]}.call(this),t.exports}(),_dereq_["./lexer"]=function(){var e={},t={exports:e};return function(){var t,n,i,r,s,o,a,c,h,l,u,p,d,f,m,g,v,y,b,k,w,T,C,E,F,N,L,x,S,D,R,A,I,_,O,$,j,M,B,V,P,U,G,H,q,X,W,Y,K,z,J,Q,Z,et,tt,nt,it,rt,st,ot,at,ct,ht,lt,ut=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};ot=_dereq_("./rewriter"),P=ot.Rewriter,w=ot.INVERSES,at=_dereq_("./helpers"),nt=at.count,ht=at.starts,tt=at.compact,ct=at.repeat,it=at.invertLiterate,st=at.locationDataToString,lt=at.throwSyntaxError,e.Lexer=S=function(){function e(){}return e.prototype.tokenize=function(e,t){var n,i,r,s;for(null==t&&(t={}),this.literate=t.literate,this.indent=0,this.baseIndent=0,this.indebt=0,this.outdebt=0,this.indents=[],this.ends=[],this.tokens=[],this.chunkLine=t.line||0,this.chunkColumn=t.column||0,e=this.clean(e),r=0;this.chunk=e.slice(r);)if(n=this.identifierToken()||this.commentToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||this.numberToken()||this.regexToken()||this.jsToken()||this.literalToken(),s=this.getLineAndColumnFromChunk(n),this.chunkLine=s[0],this.chunkColumn=s[1],r+=n,t.untilBalanced&&0===this.ends.length)return{tokens:this.tokens,index:r};return this.closeIndentation(),(i=this.ends.pop())&&this.error("missing "+i.tag,i.origin[2]),t.rewrite===!1?this.tokens:(new P).rewrite(this.tokens)},e.prototype.clean=function(e){return e.charCodeAt(0)===t&&(e=e.slice(1)),e=e.replace(/\r/g,"").replace(z,""),et.test(e)&&(e="\n"+e,this.chunkLine--),this.literate&&(e=it(e)),e},e.prototype.identifierToken=function(){var e,t,n,i,r,c,h,l,u,p,d,f,m,g,y,b;return(l=v.exec(this.chunk))?(h=l[0],r=l[1],t=l[2],c=r.length,u=void 0,"own"===r&&"FOR"===this.tag()?(this.token("OWN",r),r.length):"from"===r&&"YIELD"===this.tag()?(this.token("FROM",r),r.length):(d=this.tokens,p=d[d.length-1],i=t||null!=p&&("."===(f=p[0])||"?."===f||"::"===f||"?::"===f||!p.spaced&&"@"===p[0]),y="IDENTIFIER",!i&&(ut.call(E,r)>=0||ut.call(a,r)>=0)&&(y=r.toUpperCase(),"WHEN"===y&&(m=this.tag(),ut.call(N,m)>=0)?y="LEADING_WHEN":"FOR"===y?this.seenFor=!0:"UNLESS"===y?y="IF":ut.call(J,y)>=0?y="UNARY":ut.call(B,y)>=0&&("INSTANCEOF"!==y&&this.seenFor?(y="FOR"+y,this.seenFor=!1):(y="RELATION","!"===this.value()&&(u=this.tokens.pop(),r="!"+r)))),ut.call(C,r)>=0&&(i?(y="IDENTIFIER",r=new String(r),r.reserved=!0):ut.call(V,r)>=0&&this.error("reserved word '"+r+"'",{length:r.length})),i||(ut.call(s,r)>=0&&(e=r,r=o[r]),y=function(){switch(r){case"!":return"UNARY";case"==":case"!=":return"COMPARE";case"&&":case"||":return"LOGIC";case"true":case"false":return"BOOL";case"break":case"continue":return"STATEMENT";default:return y}}()),b=this.token(y,r,0,c),e&&(b.origin=[y,e,b[2]]),b.variable=!i,u&&(g=[u[2].first_line,u[2].first_column],b[2].first_line=g[0],b[2].first_column=g[1]),t&&(n=h.lastIndexOf(":"),this.token(":",":",n,t.length)),h.length)):0},e.prototype.numberToken=function(){var e,t,n,i,r;return(n=I.exec(this.chunk))?(i=n[0],t=i.length,/^0[BOX]/.test(i)?this.error("radix prefix in '"+i+"' must be lowercase",{offset:1}):/E/.test(i)&&!/^0x/.test(i)?this.error("exponential notation in '"+i+"' must be indicated with a lowercase 'e'",{offset:i.indexOf("E")}):/^0\d*[89]/.test(i)?this.error("decimal literal '"+i+"' must not be prefixed with '0'",{length:t}):/^0\d+/.test(i)&&this.error("octal literal '"+i+"' must be prefixed with '0o'",{length:t}),(r=/^0o([0-7]+)/.exec(i))&&(i="0x"+parseInt(r[1],8).toString(16)),(e=/^0b([01]+)/.exec(i))&&(i="0x"+parseInt(e[1],2).toString(16)),this.token("NUMBER",i,0,t),t):0},e.prototype.stringToken=function(){var e,t,n,i,r,s,o,a,c,h,l,u,m,g,v,y;if(l=(Y.exec(this.chunk)||[])[0],!l)return 0;if(g=function(){switch(l){case"'":return W;case'"':return q;case"'''":return f;case'"""':return p}}(),s=3===l.length,u=this.matchWithInterpolations(g,l),y=u.tokens,r=u.index,e=y.length-1,n=l.charAt(0),s){for(a=null,i=function(){var e,t,n;for(n=[],o=e=0,t=y.length;t>e;o=++e)v=y[o],"NEOSTRING"===v[0]&&n.push(v[1]);return n}().join("#{}");h=d.exec(i);)t=h[1],(null===a||(m=t.length)>0&&a.length>m)&&(a=t);a&&(c=RegExp("^"+a,"gm")),this.mergeInterpolationTokens(y,{delimiter:n},function(t){return function(n,i){return n=t.formatString(n),0===i&&(n=n.replace(F,"")),i===e&&(n=n.replace(K,"")),c&&(n=n.replace(c,"")),n}}(this))}else this.mergeInterpolationTokens(y,{delimiter:n},function(t){return function(n,i){return n=t.formatString(n),n=n.replace(G,function(t,r){return 0===i&&0===r||i===e&&r+t.length===n.length?"":" "})}}(this));return r},e.prototype.commentToken=function(){var e,t,n;return(n=this.chunk.match(c))?(e=n[0],t=n[1],t&&((n=u.exec(e))&&this.error("block comments cannot contain "+n[0],{offset:n.index,length:n[0].length}),t.indexOf("\n")>=0&&(t=t.replace(RegExp("\\n"+ct(" ",this.indent),"g"),"\n")),this.token("HERECOMMENT",t,0,e.length)),e.length):0},e.prototype.jsToken=function(){var e,t;return"`"===this.chunk.charAt(0)&&(e=T.exec(this.chunk))?(this.token("JS",(t=e[0]).slice(1,-1),0,t.length),t.length):0},e.prototype.regexToken=function(){var e,t,n,r,s,o,a,c,h,l,u,p,d;switch(!1){case!(o=M.exec(this.chunk)):this.error("regular expressions cannot begin with "+o[2],{offset:o.index+o[1].length});break;case!(o=this.matchWithInterpolations(m,"///")):d=o.tokens,s=o.index;break;case!(o=$.exec(this.chunk)):if(p=o[0],e=o[1],t=o[2],this.validateEscapes(e,{isRegex:!0,offsetInChunk:1}),s=p.length,h=this.tokens,c=h[h.length-1],c)if(c.spaced&&(l=c[0],ut.call(i,l)>=0)){if(!t||O.test(p))return 0}else if(u=c[0],ut.call(A,u)>=0)return 0;t||this.error("missing / (unclosed regex)");break;default:return 0}switch(r=j.exec(this.chunk.slice(s))[0],n=s+r.length,a=this.makeToken("REGEX",null,0,n),!1){case!!Z.test(r):this.error("invalid regular expression flags "+r,{offset:s,length:r.length});break;case!(p||1===d.length):null==e&&(e=this.formatHeregex(d[0][1])),this.token("REGEX",""+this.makeDelimitedLiteral(e,{delimiter:"/"})+r,0,n,a);break;default:this.token("REGEX_START","(",0,0,a),this.token("IDENTIFIER","RegExp",0,0),this.token("CALL_START","(",0,0),this.mergeInterpolationTokens(d,{delimiter:'"',"double":!0},this.formatHeregex),r&&(this.token(",",",",s,0),this.token("STRING",'"'+r+'"',s,r.length)),this.token(")",")",n,0),this.token("REGEX_END",")",n,0)}return n},e.prototype.lineToken=function(){var e,t,n,i,r;if(!(n=R.exec(this.chunk)))return 0;if(t=n[0],this.seenFor=!1,r=t.length-1-t.lastIndexOf("\n"),i=this.unfinished(),r-this.indebt===this.indent)return i?this.suppressNewlines():this.newlineToken(0),t.length;if(r>this.indent){if(i)return this.indebt=r-this.indent,this.suppressNewlines(),t.length;if(!this.tokens.length)return this.baseIndent=this.indent=r,t.length;e=r-this.indent+this.outdebt,this.token("INDENT",e,t.length-r,r),this.indents.push(e),this.ends.push({tag:"OUTDENT"}),this.outdebt=this.indebt=0,this.indent=r}else this.baseIndent>r?this.error("missing indentation",{offset:t.length}):(this.indebt=0,this.outdentToken(this.indent-r,i,t.length));return t.length},e.prototype.outdentToken=function(e,t,n){var i,r,s,o;for(i=this.indent-e;e>0;)s=this.indents[this.indents.length-1],s?s===this.outdebt?(e-=this.outdebt,this.outdebt=0):this.outdebt>s?(this.outdebt-=s,e-=s):(r=this.indents.pop()+this.outdebt,n&&(o=this.chunk[n],ut.call(y,o)>=0)&&(i-=r-e,e=r),this.outdebt=0,this.pair("OUTDENT"),this.token("OUTDENT",e,0,n),e-=r):e=0;for(r&&(this.outdebt-=e);";"===this.value();)this.tokens.pop();return"TERMINATOR"===this.tag()||t||this.token("TERMINATOR","\n",n,0),this.indent=i,this},e.prototype.whitespaceToken=function(){var e,t,n,i;return(e=et.exec(this.chunk))||(t="\n"===this.chunk.charAt(0))?(i=this.tokens,n=i[i.length-1],n&&(n[e?"spaced":"newLine"]=!0),e?e[0].length:0):0},e.prototype.newlineToken=function(e){for(;";"===this.value();)this.tokens.pop();return"TERMINATOR"!==this.tag()&&this.token("TERMINATOR","\n",e,0),this},e.prototype.suppressNewlines=function(){return"\\"===this.value()&&this.tokens.pop(),this},e.prototype.literalToken=function(){var e,t,n,s,o,a,c,u,p,d;if((e=_.exec(this.chunk))?(d=e[0],r.test(d)&&this.tagParameters()):d=this.chunk.charAt(0),u=d,n=this.tokens,t=n[n.length-1],"="===d&&t&&(!t[1].reserved&&(s=t[1],ut.call(C,s)>=0)&&(t.origin&&(t=t.origin),this.error("reserved word '"+t[1]+"' can't be assigned",t[2])),"||"===(o=t[1])||"&&"===o))return t[0]="COMPOUND_ASSIGN",t[1]+="=",d.length;if(";"===d)this.seenFor=!1,u="TERMINATOR";else if(ut.call(D,d)>=0)u="MATH";else if(ut.call(h,d)>=0)u="COMPARE";else if(ut.call(l,d)>=0)u="COMPOUND_ASSIGN";else if(ut.call(J,d)>=0)u="UNARY";else if(ut.call(Q,d)>=0)u="UNARY_MATH";else if(ut.call(U,d)>=0)u="SHIFT";else if(ut.call(x,d)>=0||"?"===d&&(null!=t?t.spaced:void 0))u="LOGIC";else if(t&&!t.spaced)if("("===d&&(a=t[0],ut.call(i,a)>=0))"?"===t[0]&&(t[0]="FUNC_EXIST"),u="CALL_START";else if("["===d&&(c=t[0],ut.call(b,c)>=0))switch(u="INDEX_START",t[0]){case"?":t[0]="INDEX_SOAK"}switch(p=this.makeToken(u,d),d){case"(":case"{":case"[":this.ends.push({tag:w[d],origin:p});break;case")":case"}":case"]":this.pair(d)}return this.tokens.push(p),d.length},e.prototype.tagParameters=function(){var e,t,n,i;if(")"!==this.tag())return this;for(t=[],i=this.tokens,e=i.length,i[--e][0]="PARAM_END";n=i[--e];)switch(n[0]){case")":t.push(n);break;case"(":case"CALL_START":if(!t.length)return"("===n[0]?(n[0]="PARAM_START",this):this;t.pop()}return this},e.prototype.closeIndentation=function(){return this.outdentToken(this.indent)},e.prototype.matchWithInterpolations=function(t,n){var i,r,s,o,a,c,h,l,u,p,d,f,m,g,v;if(v=[],l=n.length,this.chunk.slice(0,l)!==n)return null;for(m=this.chunk.slice(l);;){if(g=t.exec(m)[0],this.validateEscapes(g,{isRegex:"/"===n.charAt(0),offsetInChunk:l}),v.push(this.makeToken("NEOSTRING",g,l)),m=m.slice(g.length),l+=g.length,"#{"!==m.slice(0,2))break;p=this.getLineAndColumnFromChunk(l+1),c=p[0],r=p[1],d=(new e).tokenize(m.slice(1),{line:c,column:r,untilBalanced:!0}),h=d.tokens,o=d.index,o+=1,u=h[0],i=h[h.length-1],u[0]=u[1]="(",i[0]=i[1]=")",i.origin=["","end of interpolation",i[2]],"TERMINATOR"===(null!=(f=h[1])?f[0]:void 0)&&h.splice(1,1),v.push(["TOKENS",h]),m=m.slice(o),l+=o}return m.slice(0,n.length)!==n&&this.error("missing "+n,{length:n.length}),s=v[0],a=v[v.length-1],s[2].first_column-=n.length,a[2].last_column+=n.length,0===a[1].length&&(a[2].last_column-=1),{tokens:v,index:l+n.length}},e.prototype.mergeInterpolationTokens=function(e,t,n){var i,r,s,o,a,c,h,l,u,p,d,f,m,g,v,y;for(e.length>1&&(u=this.token("STRING_START","(",0,0)),s=this.tokens.length,o=a=0,h=e.length;h>a;o=++a){switch(g=e[o],m=g[0],y=g[1],m){case"TOKENS":if(2===y.length)continue;l=y[0],v=y;break;case"NEOSTRING":if(i=n(g[1],o),0===i.length){if(0!==o)continue;r=this.tokens.length}2===o&&null!=r&&this.tokens.splice(r,2),g[0]="STRING",g[1]=this.makeDelimitedLiteral(i,t),l=g,v=[g]}this.tokens.length>s&&(p=this.token("+","+"),p[2]={first_line:l[2].first_line,first_column:l[2].first_column,last_line:l[2].first_line,last_column:l[2].first_column}),(d=this.tokens).push.apply(d,v)}return u?(c=e[e.length-1],u.origin=["STRING",null,{first_line:u[2].first_line,first_column:u[2].first_column,last_line:c[2].last_line,last_column:c[2].last_column}],f=this.token("STRING_END",")"),f[2]={first_line:c[2].last_line,first_column:c[2].last_column,last_line:c[2].last_line,last_column:c[2].last_column}):void 0},e.prototype.pair=function(e){var t,n,i,r,s;return i=this.ends,n=i[i.length-1],e!==(s=null!=n?n.tag:void 0)?("OUTDENT"!==s&&this.error("unmatched "+e),r=this.indents,t=r[r.length-1],this.outdentToken(t,!0),this.pair(e)):this.ends.pop()},e.prototype.getLineAndColumnFromChunk=function(e){var t,n,i,r,s;return 0===e?[this.chunkLine,this.chunkColumn]:(s=e>=this.chunk.length?this.chunk:this.chunk.slice(0,+(e-1)+1||9e9),i=nt(s,"\n"),t=this.chunkColumn,i>0?(r=s.split("\n"),n=r[r.length-1],t=n.length):t+=s.length,[this.chunkLine+i,t])},e.prototype.makeToken=function(e,t,n,i){var r,s,o,a,c;return null==n&&(n=0),null==i&&(i=t.length),s={},o=this.getLineAndColumnFromChunk(n),s.first_line=o[0],s.first_column=o[1],r=Math.max(0,i-1),a=this.getLineAndColumnFromChunk(n+r),s.last_line=a[0],s.last_column=a[1],c=[e,t,s]},e.prototype.token=function(e,t,n,i,r){var s;return s=this.makeToken(e,t,n,i),r&&(s.origin=r),this.tokens.push(s),s},e.prototype.tag=function(){var e,t;return e=this.tokens,t=e[e.length-1],null!=t?t[0]:void 0},e.prototype.value=function(){var e,t;return e=this.tokens,t=e[e.length-1],null!=t?t[1]:void 0},e.prototype.unfinished=function(){var e;return L.test(this.chunk)||"\\"===(e=this.tag())||"."===e||"?."===e||"?::"===e||"UNARY"===e||"MATH"===e||"UNARY_MATH"===e||"+"===e||"-"===e||"YIELD"===e||"**"===e||"SHIFT"===e||"RELATION"===e||"COMPARE"===e||"LOGIC"===e||"THROW"===e||"EXTENDS"===e},e.prototype.formatString=function(e){return e.replace(X,"$1")},e.prototype.formatHeregex=function(e){return e.replace(g,"$1$2")},e.prototype.validateEscapes=function(e,t){var n,i,r,s,o,a,c,h;return null==t&&(t={}),s=k.exec(e),!s||(s[0],n=s[1],a=s[2],i=s[3],h=s[4],t.isRegex&&a&&"0"!==a.charAt(0))?void 0:(o=a?"octal escape sequences are not allowed":"invalid escape sequence",r="\\"+(a||i||h),this.error(o+" "+r,{offset:(null!=(c=t.offsetInChunk)?c:0)+s.index+n.length,length:r.length}))},e.prototype.makeDelimitedLiteral=function(e,t){var n;return null==t&&(t={}),""===e&&"/"===t.delimiter&&(e="(?:)"),n=RegExp("(\\\\\\\\)|(\\\\0(?=[1-7]))|\\\\?("+t.delimiter+")|\\\\?(?:(\\n)|(\\r)|(\\u2028)|(\\u2029))|(\\\\.)","g"),e=e.replace(n,function(e,n,i,r,s,o,a,c,h){switch(!1){case!n:return t.double?n+n:n;case!i:return"\\x00";case!r:return"\\"+r;case!s:return"\\n";case!o:return"\\r";case!a:return"\\u2028";case!c:return"\\u2029";case!h:return t.double?"\\"+h:h}}),""+t.delimiter+e+t.delimiter},e.prototype.error=function(e,t){var n,i,r,s,o,a;return null==t&&(t={}),r="first_line"in t?t:(o=this.getLineAndColumnFromChunk(null!=(s=t.offset)?s:0),i=o[0],n=o[1],o,{first_line:i,first_column:n,last_column:n+(null!=(a=t.length)?a:1)-1}),lt(e,r)},e}(),E=["true","false","null","this","new","delete","typeof","in","instanceof","return","throw","break","continue","debugger","yield","if","else","switch","for","while","do","try","catch","finally","class","extends","super"],a=["undefined","then","unless","until","loop","of","by","when"],o={and:"&&",or:"||",is:"==",isnt:"!=",not:"!",yes:"true",no:"false",on:"true",off:"false"},s=function(){var e;e=[];for(rt in o)e.push(rt);return e}(),a=a.concat(s),V=["case","default","function","var","void","with","const","let","enum","export","import","native","implements","interface","package","private","protected","public","static"],H=["arguments","eval","yield*"],C=E.concat(V).concat(H),e.RESERVED=V.concat(E).concat(a).concat(H),e.STRICT_PROSCRIBED=H,t=65279,v=/^(?!\d)((?:(?!\s)[$\w\x7f-\uffff])+)([^\n\S]*:(?!:))?/,I=/^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i,_=/^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?(\.|::)|\.{2,3})/,et=/^[^\n\S]+/,c=/^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/,r=/^[-=]>/,R=/^(?:\n[^\n\S]*)+/,T=/^`[^\\`]*(?:\\.[^\\`]*)*`/,Y=/^(?:'''|"""|'|")/,W=/^(?:[^\\']|\\[\s\S])*/,q=/^(?:[^\\"#]|\\[\s\S]|\#(?!\{))*/,f=/^(?:[^\\']|\\[\s\S]|'(?!''))*/,p=/^(?:[^\\"#]|\\[\s\S]|"(?!"")|\#(?!\{))*/,X=/((?:\\\\)+)|\\[^\S\n]*\n\s*/g,G=/\s*\n\s*/g,d=/\n+([^\n\S]*)(?=\S)/g,$=/^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/,j=/^\w*/,Z=/^(?!.*(.).*\1)[imgy]*$/,m=/^(?:[^\\\/#]|\\[\s\S]|\/(?!\/\/)|\#(?!\{))*/,g=/((?:\\\\)+)|\\(\s)|\s+(?:#.*)?/g,M=/^(\/|\/{3}\s*)(\*)/,O=/^\/=?\s/,u=/\*\//,L=/^\s*(?:,|\??\.(?![.\d])|::)/,k=/((?:^|[^\\])(?:\\\\)*)\\(?:(0[0-7]|[1-7])|(x(?![\da-fA-F]{2}).{0,2})|(u(?![\da-fA-F]{4}).{0,4}))/,F=/^[^\n\S]*\n/,K=/\n[^\n\S]*$/,z=/\s+$/,l=["-=","+=","/=","*=","%=","||=","&&=","?=","<<=",">>=",">>>=","&=","^=","|=","**=","//=","%%="],J=["NEW","TYPEOF","DELETE","DO"],Q=["!","~"],x=["&&","||","&","|","^"],U=["<<",">>",">>>"],h=["==","!=","<",">","<=",">="],D=["*","/","%","//","%%"],B=["IN","OF","INSTANCEOF"],n=["TRUE","FALSE"],i=["IDENTIFIER",")","]","?","@","THIS","SUPER"],b=i.concat(["NUMBER","STRING","STRING_END","REGEX","REGEX_END","BOOL","NULL","UNDEFINED","}","::"]),A=b.concat(["++","--"]),N=["INDENT","OUTDENT","TERMINATOR"],y=[")","}","]"]}.call(this),t.exports}(),_dereq_["./parser"]=function(){var e={},t={exports:e},n=function(){function e(){this.yy={}}var t=function(e,t,n,i){for(n=n||{},i=e.length;i--;n[e[i]]=t);return n},n=[1,20],i=[1,75],r=[1,71],s=[1,76],o=[1,77],a=[1,73],c=[1,74],h=[1,50],l=[1,52],u=[1,53],p=[1,54],d=[1,55],f=[1,45],m=[1,46],g=[1,27],v=[1,60],y=[1,61],b=[1,70],k=[1,43],w=[1,26],T=[1,58],C=[1,59],E=[1,57],F=[1,38],N=[1,44],L=[1,56],x=[1,65],S=[1,66],D=[1,67],R=[1,68],A=[1,42],I=[1,64],_=[1,29],O=[1,30],$=[1,31],j=[1,32],M=[1,33],B=[1,34],V=[1,35],P=[1,78],U=[1,6,26,34,108],G=[1,88],H=[1,81],q=[1,80],X=[1,79],W=[1,82],Y=[1,83],K=[1,84],z=[1,85],J=[1,86],Q=[1,87],Z=[1,91],et=[1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,135,136,141,142,143,144,145,146,147],tt=[1,97],nt=[1,98],it=[1,99],rt=[1,100],st=[1,102],ot=[1,103],at=[1,96],ct=[2,112],ht=[1,6,25,26,34,55,60,63,72,73,74,75,77,79,80,84,90,91,92,97,99,108,110,111,112,116,117,132,135,136,141,142,143,144,145,146,147],lt=[2,79],ut=[1,108],pt=[2,58],dt=[1,112],ft=[1,117],mt=[1,118],gt=[1,120],vt=[1,6,25,26,34,46,55,60,63,72,73,74,75,77,79,80,84,90,91,92,97,99,108,110,111,112,116,117,132,135,136,141,142,143,144,145,146,147],yt=[2,76],bt=[1,6,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,135,136,141,142,143,144,145,146,147],kt=[1,155],wt=[1,157],Tt=[1,152],Ct=[1,6,25,26,34,46,55,60,63,72,73,74,75,77,79,80,84,86,90,91,92,97,99,108,110,111,112,116,117,132,135,136,139,140,141,142,143,144,145,146,147,148],Et=[2,95],Ft=[1,6,25,26,34,49,55,60,63,72,73,74,75,77,79,80,84,90,91,92,97,99,108,110,111,112,116,117,132,135,136,141,142,143,144,145,146,147],Nt=[1,6,25,26,34,46,49,55,60,63,72,73,74,75,77,79,80,84,86,90,91,92,97,99,108,110,111,112,116,117,123,124,132,135,136,139,140,141,142,143,144,145,146,147,148],Lt=[1,206],xt=[1,205],St=[1,6,25,26,34,38,55,60,63,72,73,74,75,77,79,80,84,90,91,92,97,99,108,110,111,112,116,117,132,135,136,141,142,143,144,145,146,147],Dt=[2,56],Rt=[1,216],At=[6,25,26,55,60],It=[6,25,26,46,55,60,63],_t=[1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,135,136,142,144,145,146,147],Ot=[1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132],$t=[72,73,74,75,77,80,90,91],jt=[1,235],Mt=[2,133],Bt=[1,6,25,26,34,46,55,60,63,72,73,74,75,77,79,80,84,90,91,92,97,99,108,110,111,112,116,117,123,124,132,135,136,141,142,143,144,145,146,147],Vt=[1,244],Pt=[6,25,26,60,92,97],Ut=[1,6,25,26,34,55,60,63,79,84,92,97,99,108,117,132],Gt=[1,6,25,26,34,55,60,63,79,84,92,97,99,108,111,117,132],Ht=[123,124],qt=[60,123,124],Xt=[1,255],Wt=[6,25,26,60,84],Yt=[6,25,26,49,60,84],Kt=[1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,135,136,144,145,146,147],zt=[11,28,30,32,33,36,37,40,41,42,43,44,51,52,53,57,58,79,82,85,89,94,95,96,102,106,107,110,112,114,116,125,131,133,134,135,136,137,139,140],Jt=[2,122],Qt=[6,25,26],Zt=[2,57],en=[1,268],tn=[1,269],nn=[1,6,25,26,34,55,60,63,79,84,92,97,99,104,105,108,110,111,112,116,117,127,129,132,135,136,141,142,143,144,145,146,147],rn=[26,127,129],sn=[1,6,26,34,55,60,63,79,84,92,97,99,108,111,117,132],on=[2,71],an=[1,291],cn=[1,292],hn=[1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,127,132,135,136,141,142,143,144,145,146,147],ln=[1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,112,116,117,132],un=[1,303],pn=[1,304],dn=[6,25,26,60],fn=[1,6,25,26,34,55,60,63,79,84,92,97,99,104,108,110,111,112,116,117,132,135,136,141,142,143,144,145,146,147],mn=[25,60],gn={trace:function(){},yy:{},symbols_:{error:2,Root:3,Body:4,Line:5,TERMINATOR:6,Expression:7,Statement:8,Return:9,Comment:10,STATEMENT:11,Value:12,Invocation:13,Code:14,Operation:15,Assign:16,If:17,Try:18,While:19,For:20,Switch:21,Class:22,Throw:23,Block:24,INDENT:25,OUTDENT:26,Identifier:27,IDENTIFIER:28,AlphaNumeric:29,NUMBER:30,String:31,STRING:32,STRING_START:33,STRING_END:34,Regex:35,REGEX:36,REGEX_START:37,REGEX_END:38,Literal:39,JS:40,DEBUGGER:41,UNDEFINED:42,NULL:43,BOOL:44,Assignable:45,"=":46,AssignObj:47,ObjAssignable:48,":":49,ThisProperty:50,RETURN:51,HERECOMMENT:52,PARAM_START:53,ParamList:54,PARAM_END:55,FuncGlyph:56,"->":57,"=>":58,OptComma:59,",":60,Param:61,ParamVar:62,"...":63,Array:64,Object:65,Splat:66,SimpleAssignable:67,Accessor:68,Parenthetical:69,Range:70,This:71,".":72,"?.":73,"::":74,"?::":75,Index:76,INDEX_START:77,IndexValue:78,INDEX_END:79,INDEX_SOAK:80,Slice:81,"{":82,AssignList:83,"}":84,CLASS:85,EXTENDS:86,OptFuncExist:87,Arguments:88,SUPER:89,FUNC_EXIST:90,CALL_START:91,CALL_END:92,ArgList:93,THIS:94,"@":95,"[":96,"]":97,RangeDots:98,"..":99,Arg:100,SimpleArgs:101,TRY:102,Catch:103,FINALLY:104,CATCH:105,THROW:106,"(":107,")":108,WhileSource:109,WHILE:110,WHEN:111,UNTIL:112,Loop:113,LOOP:114,ForBody:115,FOR:116,BY:117,ForStart:118,ForSource:119,ForVariables:120,OWN:121,ForValue:122,FORIN:123,FOROF:124,SWITCH:125,Whens:126,ELSE:127,When:128,LEADING_WHEN:129,IfBlock:130,IF:131,POST_IF:132,UNARY:133,UNARY_MATH:134,"-":135,"+":136,YIELD:137,FROM:138,"--":139,"++":140,"?":141,MATH:142,"**":143,SHIFT:144,COMPARE:145,LOGIC:146,RELATION:147,COMPOUND_ASSIGN:148,$accept:0,$end:1},terminals_:{2:"error",6:"TERMINATOR",11:"STATEMENT",25:"INDENT",26:"OUTDENT",28:"IDENTIFIER",30:"NUMBER",32:"STRING",33:"STRING_START",34:"STRING_END",36:"REGEX",37:"REGEX_START",38:"REGEX_END",40:"JS",41:"DEBUGGER",42:"UNDEFINED",43:"NULL",44:"BOOL",46:"=",49:":",51:"RETURN",52:"HERECOMMENT",53:"PARAM_START",55:"PARAM_END",57:"->",58:"=>",60:",",63:"...",72:".",73:"?.",74:"::",75:"?::",77:"INDEX_START",79:"INDEX_END",80:"INDEX_SOAK",82:"{",84:"}",85:"CLASS",86:"EXTENDS",89:"SUPER",90:"FUNC_EXIST",91:"CALL_START",92:"CALL_END",94:"THIS",95:"@",96:"[",97:"]",99:"..",102:"TRY",104:"FINALLY",105:"CATCH",106:"THROW",107:"(",108:")",110:"WHILE",111:"WHEN",112:"UNTIL",114:"LOOP",116:"FOR",117:"BY",121:"OWN",123:"FORIN",124:"FOROF",125:"SWITCH",127:"ELSE",129:"LEADING_WHEN",131:"IF",132:"POST_IF",133:"UNARY",134:"UNARY_MATH",135:"-",136:"+",137:"YIELD",138:"FROM",139:"--",140:"++",141:"?",142:"MATH",143:"**",144:"SHIFT",145:"COMPARE",146:"LOGIC",147:"RELATION",148:"COMPOUND_ASSIGN"},productions_:[0,[3,0],[3,1],[4,1],[4,3],[4,2],[5,1],[5,1],[8,1],[8,1],[8,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[24,2],[24,3],[27,1],[29,1],[29,1],[31,1],[31,3],[35,1],[35,3],[39,1],[39,1],[39,1],[39,1],[39,1],[39,1],[39,1],[16,3],[16,4],[16,5],[47,1],[47,3],[47,5],[47,1],[48,1],[48,1],[48,1],[9,2],[9,1],[10,1],[14,5],[14,2],[56,1],[56,1],[59,0],[59,1],[54,0],[54,1],[54,3],[54,4],[54,6],[61,1],[61,2],[61,3],[61,1],[62,1],[62,1],[62,1],[62,1],[66,2],[67,1],[67,2],[67,2],[67,1],[45,1],[45,1],[45,1],[12,1],[12,1],[12,1],[12,1],[12,1],[68,2],[68,2],[68,2],[68,2],[68,1],[68,1],[76,3],[76,2],[78,1],[78,1],[65,4],[83,0],[83,1],[83,3],[83,4],[83,6],[22,1],[22,2],[22,3],[22,4],[22,2],[22,3],[22,4],[22,5],[13,3],[13,3],[13,1],[13,2],[87,0],[87,1],[88,2],[88,4],[71,1],[71,1],[50,2],[64,2],[64,4],[98,1],[98,1],[70,5],[81,3],[81,2],[81,2],[81,1],[93,1],[93,3],[93,4],[93,4],[93,6],[100,1],[100,1],[100,1],[101,1],[101,3],[18,2],[18,3],[18,4],[18,5],[103,3],[103,3],[103,2],[23,2],[69,3],[69,5],[109,2],[109,4],[109,2],[109,4],[19,2],[19,2],[19,2],[19,1],[113,2],[113,2],[20,2],[20,2],[20,2],[115,2],[115,4],[115,2],[118,2],[118,3],[122,1],[122,1],[122,1],[122,1],[120,1],[120,3],[119,2],[119,2],[119,4],[119,4],[119,4],[119,6],[119,6],[21,5],[21,7],[21,4],[21,6],[126,1],[126,2],[128,3],[128,4],[130,3],[130,5],[17,1],[17,3],[17,3],[17,3],[15,2],[15,2],[15,2],[15,2],[15,2],[15,2],[15,3],[15,2],[15,2],[15,2],[15,2],[15,2],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,5],[15,4],[15,3]],performAction:function(e,t,n,i,r,s,o){var a=s.length-1; +switch(r){case 1:return this.$=i.addLocationDataFn(o[a],o[a])(new i.Block);case 2:return this.$=s[a];case 3:this.$=i.addLocationDataFn(o[a],o[a])(i.Block.wrap([s[a]]));break;case 4:this.$=i.addLocationDataFn(o[a-2],o[a])(s[a-2].push(s[a]));break;case 5:this.$=s[a-1];break;case 6:case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 27:case 32:case 34:case 45:case 46:case 47:case 48:case 56:case 57:case 67:case 68:case 69:case 70:case 75:case 76:case 79:case 83:case 89:case 133:case 134:case 136:case 166:case 167:case 183:case 189:this.$=s[a];break;case 10:case 25:case 26:case 28:case 30:case 33:case 35:this.$=i.addLocationDataFn(o[a],o[a])(new i.Literal(s[a]));break;case 23:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Block);break;case 24:case 31:case 90:this.$=i.addLocationDataFn(o[a-2],o[a])(s[a-1]);break;case 29:case 146:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Parens(s[a-1]));break;case 36:this.$=i.addLocationDataFn(o[a],o[a])(new i.Undefined);break;case 37:this.$=i.addLocationDataFn(o[a],o[a])(new i.Null);break;case 38:this.$=i.addLocationDataFn(o[a],o[a])(new i.Bool(s[a]));break;case 39:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Assign(s[a-2],s[a]));break;case 40:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Assign(s[a-3],s[a]));break;case 41:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Assign(s[a-4],s[a-1]));break;case 42:case 72:case 77:case 78:case 80:case 81:case 82:case 168:case 169:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(s[a]));break;case 43:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Assign(i.addLocationDataFn(o[a-2])(new i.Value(s[a-2])),s[a],"object"));break;case 44:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Assign(i.addLocationDataFn(o[a-4])(new i.Value(s[a-4])),s[a-1],"object"));break;case 49:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Return(s[a]));break;case 50:this.$=i.addLocationDataFn(o[a],o[a])(new i.Return);break;case 51:this.$=i.addLocationDataFn(o[a],o[a])(new i.Comment(s[a]));break;case 52:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Code(s[a-3],s[a],s[a-1]));break;case 53:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Code([],s[a],s[a-1]));break;case 54:this.$=i.addLocationDataFn(o[a],o[a])("func");break;case 55:this.$=i.addLocationDataFn(o[a],o[a])("boundfunc");break;case 58:case 95:this.$=i.addLocationDataFn(o[a],o[a])([]);break;case 59:case 96:case 128:case 170:this.$=i.addLocationDataFn(o[a],o[a])([s[a]]);break;case 60:case 97:case 129:this.$=i.addLocationDataFn(o[a-2],o[a])(s[a-2].concat(s[a]));break;case 61:case 98:case 130:this.$=i.addLocationDataFn(o[a-3],o[a])(s[a-3].concat(s[a]));break;case 62:case 99:case 132:this.$=i.addLocationDataFn(o[a-5],o[a])(s[a-5].concat(s[a-2]));break;case 63:this.$=i.addLocationDataFn(o[a],o[a])(new i.Param(s[a]));break;case 64:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Param(s[a-1],null,!0));break;case 65:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Param(s[a-2],s[a]));break;case 66:case 135:this.$=i.addLocationDataFn(o[a],o[a])(new i.Expansion);break;case 71:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Splat(s[a-1]));break;case 73:this.$=i.addLocationDataFn(o[a-1],o[a])(s[a-1].add(s[a]));break;case 74:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Value(s[a-1],[].concat(s[a])));break;case 84:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Access(s[a]));break;case 85:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Access(s[a],"soak"));break;case 86:this.$=i.addLocationDataFn(o[a-1],o[a])([i.addLocationDataFn(o[a-1])(new i.Access(new i.Literal("prototype"))),i.addLocationDataFn(o[a])(new i.Access(s[a]))]);break;case 87:this.$=i.addLocationDataFn(o[a-1],o[a])([i.addLocationDataFn(o[a-1])(new i.Access(new i.Literal("prototype"),"soak")),i.addLocationDataFn(o[a])(new i.Access(s[a]))]);break;case 88:this.$=i.addLocationDataFn(o[a],o[a])(new i.Access(new i.Literal("prototype")));break;case 91:this.$=i.addLocationDataFn(o[a-1],o[a])(i.extend(s[a],{soak:!0}));break;case 92:this.$=i.addLocationDataFn(o[a],o[a])(new i.Index(s[a]));break;case 93:this.$=i.addLocationDataFn(o[a],o[a])(new i.Slice(s[a]));break;case 94:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Obj(s[a-2],s[a-3].generated));break;case 100:this.$=i.addLocationDataFn(o[a],o[a])(new i.Class);break;case 101:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Class(null,null,s[a]));break;case 102:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Class(null,s[a]));break;case 103:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Class(null,s[a-1],s[a]));break;case 104:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Class(s[a]));break;case 105:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Class(s[a-1],null,s[a]));break;case 106:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Class(s[a-2],s[a]));break;case 107:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Class(s[a-3],s[a-1],s[a]));break;case 108:case 109:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Call(s[a-2],s[a],s[a-1]));break;case 110:this.$=i.addLocationDataFn(o[a],o[a])(new i.Call("super",[new i.Splat(new i.Literal("arguments"))]));break;case 111:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Call("super",s[a]));break;case 112:this.$=i.addLocationDataFn(o[a],o[a])(!1);break;case 113:this.$=i.addLocationDataFn(o[a],o[a])(!0);break;case 114:this.$=i.addLocationDataFn(o[a-1],o[a])([]);break;case 115:case 131:this.$=i.addLocationDataFn(o[a-3],o[a])(s[a-2]);break;case 116:case 117:this.$=i.addLocationDataFn(o[a],o[a])(new i.Value(new i.Literal("this")));break;case 118:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Value(i.addLocationDataFn(o[a-1])(new i.Literal("this")),[i.addLocationDataFn(o[a])(new i.Access(s[a]))],"this"));break;case 119:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Arr([]));break;case 120:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Arr(s[a-2]));break;case 121:this.$=i.addLocationDataFn(o[a],o[a])("inclusive");break;case 122:this.$=i.addLocationDataFn(o[a],o[a])("exclusive");break;case 123:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Range(s[a-3],s[a-1],s[a-2]));break;case 124:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Range(s[a-2],s[a],s[a-1]));break;case 125:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Range(s[a-1],null,s[a]));break;case 126:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Range(null,s[a],s[a-1]));break;case 127:this.$=i.addLocationDataFn(o[a],o[a])(new i.Range(null,null,s[a]));break;case 137:this.$=i.addLocationDataFn(o[a-2],o[a])([].concat(s[a-2],s[a]));break;case 138:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Try(s[a]));break;case 139:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Try(s[a-1],s[a][0],s[a][1]));break;case 140:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Try(s[a-2],null,null,s[a]));break;case 141:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Try(s[a-3],s[a-2][0],s[a-2][1],s[a]));break;case 142:this.$=i.addLocationDataFn(o[a-2],o[a])([s[a-1],s[a]]);break;case 143:this.$=i.addLocationDataFn(o[a-2],o[a])([i.addLocationDataFn(o[a-1])(new i.Value(s[a-1])),s[a]]);break;case 144:this.$=i.addLocationDataFn(o[a-1],o[a])([null,s[a]]);break;case 145:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Throw(s[a]));break;case 147:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Parens(s[a-2]));break;case 148:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.While(s[a]));break;case 149:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.While(s[a-2],{guard:s[a]}));break;case 150:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.While(s[a],{invert:!0}));break;case 151:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.While(s[a-2],{invert:!0,guard:s[a]}));break;case 152:this.$=i.addLocationDataFn(o[a-1],o[a])(s[a-1].addBody(s[a]));break;case 153:case 154:this.$=i.addLocationDataFn(o[a-1],o[a])(s[a].addBody(i.addLocationDataFn(o[a-1])(i.Block.wrap([s[a-1]]))));break;case 155:this.$=i.addLocationDataFn(o[a],o[a])(s[a]);break;case 156:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.While(i.addLocationDataFn(o[a-1])(new i.Literal("true"))).addBody(s[a]));break;case 157:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.While(i.addLocationDataFn(o[a-1])(new i.Literal("true"))).addBody(i.addLocationDataFn(o[a])(i.Block.wrap([s[a]]))));break;case 158:case 159:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.For(s[a-1],s[a]));break;case 160:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.For(s[a],s[a-1]));break;case 161:this.$=i.addLocationDataFn(o[a-1],o[a])({source:i.addLocationDataFn(o[a])(new i.Value(s[a]))});break;case 162:this.$=i.addLocationDataFn(o[a-3],o[a])({source:i.addLocationDataFn(o[a-2])(new i.Value(s[a-2])),step:s[a]});break;case 163:this.$=i.addLocationDataFn(o[a-1],o[a])(function(){return s[a].own=s[a-1].own,s[a].name=s[a-1][0],s[a].index=s[a-1][1],s[a]}());break;case 164:this.$=i.addLocationDataFn(o[a-1],o[a])(s[a]);break;case 165:this.$=i.addLocationDataFn(o[a-2],o[a])(function(){return s[a].own=!0,s[a]}());break;case 171:this.$=i.addLocationDataFn(o[a-2],o[a])([s[a-2],s[a]]);break;case 172:this.$=i.addLocationDataFn(o[a-1],o[a])({source:s[a]});break;case 173:this.$=i.addLocationDataFn(o[a-1],o[a])({source:s[a],object:!0});break;case 174:this.$=i.addLocationDataFn(o[a-3],o[a])({source:s[a-2],guard:s[a]});break;case 175:this.$=i.addLocationDataFn(o[a-3],o[a])({source:s[a-2],guard:s[a],object:!0});break;case 176:this.$=i.addLocationDataFn(o[a-3],o[a])({source:s[a-2],step:s[a]});break;case 177:this.$=i.addLocationDataFn(o[a-5],o[a])({source:s[a-4],guard:s[a-2],step:s[a]});break;case 178:this.$=i.addLocationDataFn(o[a-5],o[a])({source:s[a-4],step:s[a-2],guard:s[a]});break;case 179:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Switch(s[a-3],s[a-1]));break;case 180:this.$=i.addLocationDataFn(o[a-6],o[a])(new i.Switch(s[a-5],s[a-3],s[a-1]));break;case 181:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Switch(null,s[a-1]));break;case 182:this.$=i.addLocationDataFn(o[a-5],o[a])(new i.Switch(null,s[a-3],s[a-1]));break;case 184:this.$=i.addLocationDataFn(o[a-1],o[a])(s[a-1].concat(s[a]));break;case 185:this.$=i.addLocationDataFn(o[a-2],o[a])([[s[a-1],s[a]]]);break;case 186:this.$=i.addLocationDataFn(o[a-3],o[a])([[s[a-2],s[a-1]]]);break;case 187:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.If(s[a-1],s[a],{type:s[a-2]}));break;case 188:this.$=i.addLocationDataFn(o[a-4],o[a])(s[a-4].addElse(i.addLocationDataFn(o[a-2],o[a])(new i.If(s[a-1],s[a],{type:s[a-2]}))));break;case 190:this.$=i.addLocationDataFn(o[a-2],o[a])(s[a-2].addElse(s[a]));break;case 191:case 192:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.If(s[a],i.addLocationDataFn(o[a-2])(i.Block.wrap([s[a-2]])),{type:s[a-1],statement:!0}));break;case 193:case 194:case 197:case 198:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op(s[a-1],s[a]));break;case 195:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("-",s[a]));break;case 196:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("+",s[a]));break;case 199:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op(s[a-2].concat(s[a-1]),s[a]));break;case 200:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("--",s[a]));break;case 201:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("++",s[a]));break;case 202:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("--",s[a-1],null,!0));break;case 203:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Op("++",s[a-1],null,!0));break;case 204:this.$=i.addLocationDataFn(o[a-1],o[a])(new i.Existence(s[a-1]));break;case 205:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op("+",s[a-2],s[a]));break;case 206:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op("-",s[a-2],s[a]));break;case 207:case 208:case 209:case 210:case 211:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Op(s[a-1],s[a-2],s[a]));break;case 212:this.$=i.addLocationDataFn(o[a-2],o[a])(function(){return"!"===s[a-1].charAt(0)?new i.Op(s[a-1].slice(1),s[a-2],s[a]).invert():new i.Op(s[a-1],s[a-2],s[a])}());break;case 213:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Assign(s[a-2],s[a],s[a-1]));break;case 214:this.$=i.addLocationDataFn(o[a-4],o[a])(new i.Assign(s[a-4],s[a-1],s[a-3]));break;case 215:this.$=i.addLocationDataFn(o[a-3],o[a])(new i.Assign(s[a-3],s[a],s[a-2]));break;case 216:this.$=i.addLocationDataFn(o[a-2],o[a])(new i.Extends(s[a-2],s[a]))}},table:[{1:[2,1],3:1,4:2,5:3,7:4,8:5,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{1:[3]},{1:[2,2],6:P},t(U,[2,3]),t(U,[2,6],{118:69,109:89,115:90,110:x,112:S,116:R,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(U,[2,7],{118:69,109:92,115:93,110:x,112:S,116:R,132:Z}),t(et,[2,11],{87:94,68:95,76:101,72:tt,73:nt,74:it,75:rt,77:st,80:ot,90:at,91:ct}),t(et,[2,12],{76:101,87:104,68:105,72:tt,73:nt,74:it,75:rt,77:st,80:ot,90:at,91:ct}),t(et,[2,13]),t(et,[2,14]),t(et,[2,15]),t(et,[2,16]),t(et,[2,17]),t(et,[2,18]),t(et,[2,19]),t(et,[2,20]),t(et,[2,21]),t(et,[2,22]),t(et,[2,8]),t(et,[2,9]),t(et,[2,10]),t(ht,lt,{46:[1,106]}),t(ht,[2,80]),t(ht,[2,81]),t(ht,[2,82]),t(ht,[2,83]),t([1,6,25,26,34,38,55,60,63,72,73,74,75,77,79,80,84,90,92,97,99,108,110,111,112,116,117,132,135,136,141,142,143,144,145,146,147],[2,110],{88:107,91:ut}),t([6,25,55,60],pt,{54:109,61:110,62:111,27:113,50:114,64:115,65:116,28:i,63:dt,82:b,95:ft,96:mt}),{24:119,25:gt},{7:121,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:123,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:124,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:125,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:127,8:126,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,138:[1,128],139:B,140:V},{12:130,13:131,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:132,50:63,64:47,65:48,67:129,69:23,70:24,71:25,82:b,89:w,94:T,95:C,96:E,107:L},{12:130,13:131,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:132,50:63,64:47,65:48,67:133,69:23,70:24,71:25,82:b,89:w,94:T,95:C,96:E,107:L},t(vt,yt,{86:[1,137],139:[1,134],140:[1,135],148:[1,136]}),t(et,[2,189],{127:[1,138]}),{24:139,25:gt},{24:140,25:gt},t(et,[2,155]),{24:141,25:gt},{7:142,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(bt,[2,100],{39:22,69:23,70:24,71:25,64:47,65:48,29:49,35:51,27:62,50:63,31:72,12:130,13:131,45:132,24:144,67:146,25:gt,28:i,30:r,32:s,33:o,36:a,37:c,40:h,41:l,42:u,43:p,44:d,82:b,86:[1,145],89:w,94:T,95:C,96:E,107:L}),{7:147,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t([1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,141,142,143,144,145,146,147],[2,50],{12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,9:18,10:19,45:21,39:22,69:23,70:24,71:25,56:28,67:36,130:37,109:39,113:40,115:41,64:47,65:48,29:49,35:51,27:62,50:63,118:69,31:72,8:122,7:148,11:n,28:i,30:r,32:s,33:o,36:a,37:c,40:h,41:l,42:u,43:p,44:d,51:f,52:m,53:g,57:v,58:y,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,114:D,125:A,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V}),t(et,[2,51]),t(vt,[2,77]),t(vt,[2,78]),t(ht,[2,32]),t(ht,[2,33]),t(ht,[2,34]),t(ht,[2,35]),t(ht,[2,36]),t(ht,[2,37]),t(ht,[2,38]),{4:149,5:3,7:4,8:5,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,150],27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:151,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:kt,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,63:wt,64:47,65:48,66:156,67:36,69:23,70:24,71:25,82:b,85:k,89:w,93:153,94:T,95:C,96:E,97:Tt,100:154,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(ht,[2,116]),t(ht,[2,117],{27:158,28:i}),{25:[2,54]},{25:[2,55]},t(Ct,[2,72]),t(Ct,[2,75]),{7:159,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:160,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:161,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:163,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,24:162,25:gt,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{27:168,28:i,50:169,64:170,65:171,70:164,82:b,95:ft,96:E,120:165,121:[1,166],122:167},{119:172,123:[1,173],124:[1,174]},t([6,25,60,84],Et,{31:72,83:175,47:176,48:177,10:178,27:179,29:180,50:181,28:i,30:r,32:s,33:o,52:m,95:ft}),t(Ft,[2,26]),t(Ft,[2,27]),t(ht,[2,30]),{12:130,13:182,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:132,50:63,64:47,65:48,67:183,69:23,70:24,71:25,82:b,89:w,94:T,95:C,96:E,107:L},t(Nt,[2,25]),t(Ft,[2,28]),{4:184,5:3,7:4,8:5,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(U,[2,5],{7:4,8:5,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,9:18,10:19,45:21,39:22,69:23,70:24,71:25,56:28,67:36,130:37,109:39,113:40,115:41,64:47,65:48,29:49,35:51,27:62,50:63,118:69,31:72,5:185,11:n,28:i,30:r,32:s,33:o,36:a,37:c,40:h,41:l,42:u,43:p,44:d,51:f,52:m,53:g,57:v,58:y,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,110:x,112:S,114:D,116:R,125:A,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V}),t(et,[2,204]),{7:186,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:187,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:188,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:189,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:190,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:191,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:192,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:193,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:194,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(et,[2,154]),t(et,[2,159]),{7:195,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(et,[2,153]),t(et,[2,158]),{88:196,91:ut},t(Ct,[2,73]),{91:[2,113]},{27:197,28:i},{27:198,28:i},t(Ct,[2,88],{27:199,28:i}),{27:200,28:i},t(Ct,[2,89]),{7:202,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,63:Lt,64:47,65:48,67:36,69:23,70:24,71:25,78:201,81:203,82:b,85:k,89:w,94:T,95:C,96:E,98:204,99:xt,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{76:207,77:st,80:ot},{88:208,91:ut},t(Ct,[2,74]),{6:[1,210],7:209,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,211],27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(St,[2,111]),{7:214,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:kt,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,63:wt,64:47,65:48,66:156,67:36,69:23,70:24,71:25,82:b,85:k,89:w,92:[1,212],93:213,94:T,95:C,96:E,100:154,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t([6,25],Dt,{59:217,55:[1,215],60:Rt}),t(At,[2,59]),t(At,[2,63],{46:[1,219],63:[1,218]}),t(At,[2,66]),t(It,[2,67]),t(It,[2,68]),t(It,[2,69]),t(It,[2,70]),{27:158,28:i},{7:214,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:kt,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,63:wt,64:47,65:48,66:156,67:36,69:23,70:24,71:25,82:b,85:k,89:w,93:153,94:T,95:C,96:E,97:Tt,100:154,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(et,[2,53]),{4:221,5:3,7:4,8:5,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,26:[1,220],27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t([1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,135,136,142,143,144,145,146,147],[2,193],{118:69,109:89,115:90,141:X}),{109:92,110:x,112:S,115:93,116:R,118:69,132:Z},t(_t,[2,194],{118:69,109:89,115:90,141:X,143:Y}),t(_t,[2,195],{118:69,109:89,115:90,141:X,143:Y}),t(_t,[2,196],{118:69,109:89,115:90,141:X,143:Y}),t(et,[2,197],{118:69,109:92,115:93}),t(Ot,[2,198],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{7:222,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(et,[2,200],{72:yt,73:yt,74:yt,75:yt,77:yt,80:yt,90:yt,91:yt}),{68:95,72:tt,73:nt,74:it,75:rt,76:101,77:st,80:ot,87:94,90:at,91:ct},{68:105,72:tt,73:nt,74:it,75:rt,76:101,77:st,80:ot,87:104,90:at,91:ct},t($t,lt),t(et,[2,201],{72:yt,73:yt,74:yt,75:yt,77:yt,80:yt,90:yt,91:yt}),t(et,[2,202]),t(et,[2,203]),{6:[1,225],7:223,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,224],27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:226,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{24:227,25:gt,131:[1,228]},t(et,[2,138],{103:229,104:[1,230],105:[1,231]}),t(et,[2,152]),t(et,[2,160]),{25:[1,232],109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},{126:233,128:234,129:jt},t(et,[2,101]),{7:236,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(bt,[2,104],{24:237,25:gt,72:yt,73:yt,74:yt,75:yt,77:yt,80:yt,90:yt,91:yt,86:[1,238]}),t(Ot,[2,145],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Ot,[2,49],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{6:P,108:[1,239]},{4:240,5:3,7:4,8:5,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t([6,25,60,97],Mt,{118:69,109:89,115:90,98:241,63:[1,242],99:xt,110:x,112:S,116:R,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Bt,[2,119]),t([6,25,97],Dt,{59:243,60:Vt}),t(Pt,[2,128]),{7:214,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:kt,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,63:wt,64:47,65:48,66:156,67:36,69:23,70:24,71:25,82:b,85:k,89:w,93:245,94:T,95:C,96:E,100:154,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(Pt,[2,134]),t(Pt,[2,135]),t(Nt,[2,118]),{24:246,25:gt,109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},t(Ut,[2,148],{118:69,109:89,115:90,110:x,111:[1,247],112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Ut,[2,150],{118:69,109:89,115:90,110:x,111:[1,248],112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(et,[2,156]),t(Gt,[2,157],{118:69,109:89,115:90,110:x,112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t([1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,132,135,136,141,142,143,144,145,146,147],[2,161],{117:[1,249]}),t(Ht,[2,164]),{27:168,28:i,50:169,64:170,65:171,82:b,95:ft,96:mt,120:250,122:167},t(Ht,[2,170],{60:[1,251]}),t(qt,[2,166]),t(qt,[2,167]),t(qt,[2,168]),t(qt,[2,169]),t(et,[2,163]),{7:252,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:253,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t([6,25,84],Dt,{59:254,60:Xt}),t(Wt,[2,96]),t(Wt,[2,42],{49:[1,256]}),t(Wt,[2,45]),t(Yt,[2,46]),t(Yt,[2,47]),t(Yt,[2,48]),{38:[1,257],68:105,72:tt,73:nt,74:it,75:rt,76:101,77:st,80:ot,87:104,90:at,91:ct},t($t,yt),{6:P,34:[1,258]},t(U,[2,4]),t(Kt,[2,205],{118:69,109:89,115:90,141:X,142:W,143:Y}),t(Kt,[2,206],{118:69,109:89,115:90,141:X,142:W,143:Y}),t(_t,[2,207],{118:69,109:89,115:90,141:X,143:Y}),t(_t,[2,208],{118:69,109:89,115:90,141:X,143:Y}),t([1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,144,145,146,147],[2,209],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y}),t([1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,145,146],[2,210],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,147:Q}),t([1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,146],[2,211],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,147:Q}),t([1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,117,132,145,146,147],[2,212],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K}),t(Gt,[2,192],{118:69,109:89,115:90,110:x,112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Gt,[2,191],{118:69,109:89,115:90,110:x,112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(St,[2,108]),t(Ct,[2,84]),t(Ct,[2,85]),t(Ct,[2,86]),t(Ct,[2,87]),{79:[1,259]},{63:Lt,79:[2,92],98:260,99:xt,109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},{79:[2,93]},{7:261,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,79:[2,127],82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(zt,[2,121]),t(zt,Jt),t(Ct,[2,91]),t(St,[2,109]),t(Ot,[2,39],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{7:262,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:263,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(St,[2,114]),t([6,25,92],Dt,{59:264,60:Vt}),t(Pt,Mt,{118:69,109:89,115:90,63:[1,265],110:x,112:S,116:R,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{56:266,57:v,58:y},t(Qt,Zt,{62:111,27:113,50:114,64:115,65:116,61:267,28:i,63:dt,82:b,95:ft,96:mt}),{6:en,25:tn},t(At,[2,64]),{7:270,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(nn,[2,23]),{6:P,26:[1,271]},t(Ot,[2,199],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Ot,[2,213],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{7:272,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:273,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(Ot,[2,216],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(et,[2,190]),{7:274,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(et,[2,139],{104:[1,275]}),{24:276,25:gt},{24:279,25:gt,27:277,28:i,65:278,82:b},{126:280,128:234,129:jt},{26:[1,281],127:[1,282],128:283,129:jt},t(rn,[2,183]),{7:285,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,101:284,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(sn,[2,102],{118:69,109:89,115:90,24:286,25:gt,110:x,112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(et,[2,105]),{7:287,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(ht,[2,146]),{6:P,26:[1,288]},{7:289,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t([11,28,30,32,33,36,37,40,41,42,43,44,51,52,53,57,58,82,85,89,94,95,96,102,106,107,110,112,114,116,125,131,133,134,135,136,137,139,140],Jt,{6:on,25:on,60:on,97:on}),{6:an,25:cn,97:[1,290]},t([6,25,26,92,97],Zt,{12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,9:18,10:19,45:21,39:22,69:23,70:24,71:25,56:28,67:36,130:37,109:39,113:40,115:41,64:47,65:48,29:49,35:51,27:62,50:63,118:69,31:72,8:122,66:156,7:214,100:293,11:n,28:i,30:r,32:s,33:o,36:a,37:c,40:h,41:l,42:u,43:p,44:d,51:f,52:m,53:g,57:v,58:y,63:wt,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,110:x,112:S,114:D,116:R,125:A,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V}),t(Qt,Dt,{59:294,60:Vt}),t(hn,[2,187]),{7:295,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:296,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:297,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(Ht,[2,165]),{27:168,28:i,50:169,64:170,65:171,82:b,95:ft,96:mt,122:298},t([1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,112,116,132],[2,172],{118:69,109:89,115:90,111:[1,299],117:[1,300],135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(ln,[2,173],{118:69,109:89,115:90,111:[1,301],135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{6:un,25:pn,84:[1,302]},t([6,25,26,84],Zt,{31:72,48:177,10:178,27:179,29:180,50:181,47:305,28:i,30:r,32:s,33:o,52:m,95:ft}),{7:306,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,307],27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(ht,[2,31]),t(Ft,[2,29]),t(Ct,[2,90]),{7:308,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,79:[2,125],82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{79:[2,126],109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},t(Ot,[2,40],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{26:[1,309],109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},{6:an,25:cn,92:[1,310]},t(Pt,on),{24:311,25:gt},t(At,[2,60]),{27:113,28:i,50:114,61:312,62:111,63:dt,64:115,65:116,82:b,95:ft,96:mt},t(dn,pt,{61:110,62:111,27:113,50:114,64:115,65:116,54:313,28:i,63:dt,82:b,95:ft,96:mt}),t(At,[2,65],{118:69,109:89,115:90,110:x,112:S,116:R,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(nn,[2,24]),{26:[1,314],109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},t(Ot,[2,215],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{24:315,25:gt,109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},{24:316,25:gt},t(et,[2,140]),{24:317,25:gt},{24:318,25:gt},t(fn,[2,144]),{26:[1,319],127:[1,320],128:283,129:jt},t(et,[2,181]),{24:321,25:gt},t(rn,[2,184]),{24:322,25:gt,60:[1,323]},t(mn,[2,136],{118:69,109:89,115:90,110:x,112:S,116:R,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(et,[2,103]),t(sn,[2,106],{118:69,109:89,115:90,24:324,25:gt,110:x,112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{108:[1,325]},{97:[1,326],109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},t(Bt,[2,120]),{7:214,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,63:wt,64:47,65:48,66:156,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,100:327,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:214,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:kt,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,63:wt,64:47,65:48,66:156,67:36,69:23,70:24,71:25,82:b,85:k,89:w,93:328,94:T,95:C,96:E,100:154,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(Pt,[2,129]),{6:an,25:cn,26:[1,329]},t(Gt,[2,149],{118:69,109:89,115:90,110:x,112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Gt,[2,151],{118:69,109:89,115:90,110:x,112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Gt,[2,162],{118:69,109:89,115:90,110:x,112:S,116:R,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Ht,[2,171]),{7:330,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:331,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:332,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(Bt,[2,94]),{10:178,27:179,28:i,29:180,30:r,31:72,32:s,33:o,47:333,48:177,50:181,52:m,95:ft},t(dn,Et,{31:72,47:176,48:177,10:178,27:179,29:180,50:181,83:334,28:i,30:r,32:s,33:o,52:m,95:ft}),t(Wt,[2,97]),t(Wt,[2,43],{118:69,109:89,115:90,110:x,112:S,116:R,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{7:335,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{79:[2,124],109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},t(et,[2,41]),t(St,[2,115]),t(et,[2,52]),t(At,[2,61]),t(Qt,Dt,{59:336,60:Rt}),t(et,[2,214]),t(hn,[2,188]),t(et,[2,141]),t(fn,[2,142]),t(fn,[2,143]),t(et,[2,179]),{24:337,25:gt},{26:[1,338]},t(rn,[2,185],{6:[1,339]}),{7:340,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},t(et,[2,107]),t(ht,[2,147]),t(ht,[2,123]),t(Pt,[2,130]),t(Qt,Dt,{59:341,60:Vt}),t(Pt,[2,131]),t([1,6,25,26,34,55,60,63,79,84,92,97,99,108,110,111,112,116,132],[2,174],{118:69,109:89,115:90,117:[1,342],135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(ln,[2,176],{118:69,109:89,115:90,111:[1,343],135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Ot,[2,175],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Wt,[2,98]),t(Qt,Dt,{59:344,60:Xt}),{26:[1,345],109:89,110:x,112:S,115:90,116:R,118:69,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q},{6:en,25:tn,26:[1,346]},{26:[1,347]},t(et,[2,182]),t(rn,[2,186]),t(mn,[2,137],{118:69,109:89,115:90,110:x,112:S,116:R,132:G,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),{6:an,25:cn,26:[1,348]},{7:349,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{7:350,8:122,9:18,10:19,11:n,12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:62,28:i,29:49,30:r,31:72,32:s,33:o,35:51,36:a,37:c,39:22,40:h,41:l,42:u,43:p,44:d,45:21,50:63,51:f,52:m,53:g,56:28,57:v,58:y,64:47,65:48,67:36,69:23,70:24,71:25,82:b,85:k,89:w,94:T,95:C,96:E,102:F,106:N,107:L,109:39,110:x,112:S,113:40,114:D,115:41,116:R,118:69,125:A,130:37,131:I,133:_,134:O,135:$,136:j,137:M,139:B,140:V},{6:un,25:pn,26:[1,351]},t(Wt,[2,44]),t(At,[2,62]),t(et,[2,180]),t(Pt,[2,132]),t(Ot,[2,177],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Ot,[2,178],{118:69,109:89,115:90,135:H,136:q,141:X,142:W,143:Y,144:K,145:z,146:J,147:Q}),t(Wt,[2,99])],defaultActions:{60:[2,54],61:[2,55],96:[2,113],203:[2,93]},parseError:function(e,t){if(!t.recoverable)throw Error(e); +this.trace(e)},parse:function(e){function t(){var e;return e=f.lex()||p,"number"!=typeof e&&(e=n.symbols_[e]||e),e}var n=this,i=[0],r=[null],s=[],o=this.table,a="",c=0,h=0,l=0,u=2,p=1,d=s.slice.call(arguments,1),f=Object.create(this.lexer),m={yy:{}};for(var g in this.yy)Object.prototype.hasOwnProperty.call(this.yy,g)&&(m.yy[g]=this.yy[g]);f.setInput(e,m.yy),m.yy.lexer=f,m.yy.parser=this,f.yylloc===void 0&&(f.yylloc={});var v=f.yylloc;s.push(v);var y=f.options&&f.options.ranges;this.parseError="function"==typeof m.yy.parseError?m.yy.parseError:Object.getPrototypeOf(this).parseError;for(var b,k,w,T,C,E,F,N,L,x={};;){if(w=i[i.length-1],this.defaultActions[w]?T=this.defaultActions[w]:((null===b||b===void 0)&&(b=t()),T=o[w]&&o[w][b]),T===void 0||!T.length||!T[0]){var S="";L=[];for(E in o[w])this.terminals_[E]&&E>u&&L.push("'"+this.terminals_[E]+"'");S=f.showPosition?"Parse error on line "+(c+1)+":\n"+f.showPosition()+"\nExpecting "+L.join(", ")+", got '"+(this.terminals_[b]||b)+"'":"Parse error on line "+(c+1)+": Unexpected "+(b==p?"end of input":"'"+(this.terminals_[b]||b)+"'"),this.parseError(S,{text:f.match,token:this.terminals_[b]||b,line:f.yylineno,loc:v,expected:L})}if(T[0]instanceof Array&&T.length>1)throw Error("Parse Error: multiple actions possible at state: "+w+", token: "+b);switch(T[0]){case 1:i.push(b),r.push(f.yytext),s.push(f.yylloc),i.push(T[1]),b=null,k?(b=k,k=null):(h=f.yyleng,a=f.yytext,c=f.yylineno,v=f.yylloc,l>0&&l--);break;case 2:if(F=this.productions_[T[1]][1],x.$=r[r.length-F],x._$={first_line:s[s.length-(F||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(F||1)].first_column,last_column:s[s.length-1].last_column},y&&(x._$.range=[s[s.length-(F||1)].range[0],s[s.length-1].range[1]]),C=this.performAction.apply(x,[a,h,c,m.yy,T[1],r,s].concat(d)),C!==void 0)return C;F&&(i=i.slice(0,2*-1*F),r=r.slice(0,-1*F),s=s.slice(0,-1*F)),i.push(this.productions_[T[1]][0]),r.push(x.$),s.push(x._$),N=o[i[i.length-2]][i[i.length-1]],i.push(N);break;case 3:return!0}}return!0}};return e.prototype=gn,gn.Parser=e,new e}();return _dereq_!==void 0&&e!==void 0&&(e.parser=n,e.Parser=n.Parser,e.parse=function(){return n.parse.apply(n,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var n=_dereq_("fs").readFileSync(_dereq_("path").normalize(t[1]),"utf8");return e.parser.parse(n)},t!==void 0&&_dereq_.main===t&&e.main(process.argv.slice(1))),t.exports}(),_dereq_["./scope"]=function(){var e={},t={exports:e};return function(){var t,n=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};e.Scope=t=function(){function e(e,t,n,i){var r,s;this.parent=e,this.expressions=t,this.method=n,this.referencedVars=i,this.variables=[{name:"arguments",type:"arguments"}],this.positions={},this.parent||(this.utilities={}),this.root=null!=(r=null!=(s=this.parent)?s.root:void 0)?r:this}return e.prototype.add=function(e,t,n){return this.shared&&!n?this.parent.add(e,t,n):Object.prototype.hasOwnProperty.call(this.positions,e)?this.variables[this.positions[e]].type=t:this.positions[e]=this.variables.push({name:e,type:t})-1},e.prototype.namedMethod=function(){var e;return(null!=(e=this.method)?e.name:void 0)||!this.parent?this.method:this.parent.namedMethod()},e.prototype.find=function(e){return this.check(e)?!0:(this.add(e,"var"),!1)},e.prototype.parameter=function(e){return this.shared&&this.parent.check(e,!0)?void 0:this.add(e,"param")},e.prototype.check=function(e){var t;return!!(this.type(e)||(null!=(t=this.parent)?t.check(e):void 0))},e.prototype.temporary=function(e,t,n){return null==n&&(n=!1),n?(t+parseInt(e,36)).toString(36).replace(/\d/g,"a"):e+(t||"")},e.prototype.type=function(e){var t,n,i,r;for(i=this.variables,t=0,n=i.length;n>t;t++)if(r=i[t],r.name===e)return r.type;return null},e.prototype.freeVariable=function(e,t){var i,r,s;for(null==t&&(t={}),i=0;;){if(s=this.temporary(e,i,t.single),!(this.check(s)||n.call(this.root.referencedVars,s)>=0))break;i++}return(null!=(r=t.reserve)?r:!0)&&this.add(s,"var",!0),s},e.prototype.assign=function(e,t){return this.add(e,{value:t,assigned:!0},!0),this.hasAssignments=!0},e.prototype.hasDeclarations=function(){return!!this.declaredVariables().length},e.prototype.declaredVariables=function(){var e;return function(){var t,n,i,r;for(i=this.variables,r=[],t=0,n=i.length;n>t;t++)e=i[t],"var"===e.type&&r.push(e.name);return r}.call(this).sort()},e.prototype.assignedVariables=function(){var e,t,n,i,r;for(n=this.variables,i=[],e=0,t=n.length;t>e;e++)r=n[e],r.type.assigned&&i.push(r.name+" = "+r.type.value);return i},e}()}.call(this),t.exports}(),_dereq_["./nodes"]=function(){var e={},t={exports:e};return function(){var t,n,i,r,s,o,a,c,h,l,u,p,d,f,m,g,v,y,b,k,w,T,C,E,F,N,L,x,S,D,R,A,I,_,O,$,j,M,B,V,P,U,G,H,q,X,W,Y,K,z,J,Q,Z,et,tt,nt,it,rt,st,ot,at,ct,ht,lt,ut,pt,dt,ft,mt,gt,vt,yt,bt,kt=function(e,t){function n(){this.constructor=e}for(var i in t)wt.call(t,i)&&(e[i]=t[i]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e},wt={}.hasOwnProperty,Tt=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1},Ct=[].slice;Error.stackTraceLimit=1/0,P=_dereq_("./scope").Scope,dt=_dereq_("./lexer"),$=dt.RESERVED,V=dt.STRICT_PROSCRIBED,ft=_dereq_("./helpers"),et=ft.compact,rt=ft.flatten,it=ft.extend,lt=ft.merge,tt=ft.del,gt=ft.starts,nt=ft.ends,mt=ft.some,Z=ft.addLocationDataFn,ht=ft.locationDataToString,vt=ft.throwSyntaxError,e.extend=it,e.addLocationDataFn=Z,Q=function(){return!0},D=function(){return!1},X=function(){return this},S=function(){return this.negated=!this.negated,this},e.CodeFragment=h=function(){function e(e,t){var n;this.code=""+t,this.locationData=null!=e?e.locationData:void 0,this.type=(null!=e?null!=(n=e.constructor)?n.name:void 0:void 0)||"unknown"}return e.prototype.toString=function(){return""+this.code+(this.locationData?": "+ht(this.locationData):"")},e}(),st=function(e){var t;return function(){var n,i,r;for(r=[],n=0,i=e.length;i>n;n++)t=e[n],r.push(t.code);return r}().join("")},e.Base=r=function(){function e(){}return e.prototype.compile=function(e,t){return st(this.compileToFragments(e,t))},e.prototype.compileToFragments=function(e,t){var n;return e=it({},e),t&&(e.level=t),n=this.unfoldSoak(e)||this,n.tab=e.indent,e.level!==L&&n.isStatement(e)?n.compileClosure(e):n.compileNode(e)},e.prototype.compileClosure=function(e){var n,i,r,a,h,l,u;return(a=this.jumps())&&a.error("cannot use a pure statement in an expression"),e.sharedScope=!0,r=new c([],s.wrap([this])),n=[],((i=this.contains(at))||this.contains(ct))&&(n=[new x("this")],i?(h="apply",n.push(new x("arguments"))):h="call",r=new z(r,[new t(new x(h))])),l=new o(r,n).compileNode(e),(r.isGenerator||(null!=(u=r.base)?u.isGenerator:void 0))&&(l.unshift(this.makeCode("(yield* ")),l.push(this.makeCode(")"))),l},e.prototype.cache=function(e,t,n){var r,s,o;return r=null!=n?n(this):this.isComplex(),r?(s=new x(e.scope.freeVariable("ref")),o=new i(s,this),t?[o.compileToFragments(e,t),[this.makeCode(s.value)]]:[o,s]):(s=t?this.compileToFragments(e,t):this,[s,s])},e.prototype.cacheToCodeFragments=function(e){return[st(e[0]),st(e[1])]},e.prototype.makeReturn=function(e){var t;return t=this.unwrapAll(),e?new o(new x(e+".push"),[t]):new M(t)},e.prototype.contains=function(e){var t;return t=void 0,this.traverseChildren(!1,function(n){return e(n)?(t=n,!1):void 0}),t},e.prototype.lastNonComment=function(e){var t;for(t=e.length;t--;)if(!(e[t]instanceof l))return e[t];return null},e.prototype.toString=function(e,t){var n;return null==e&&(e=""),null==t&&(t=this.constructor.name),n="\n"+e+t,this.soak&&(n+="?"),this.eachChild(function(t){return n+=t.toString(e+q)}),n},e.prototype.eachChild=function(e){var t,n,i,r,s,o,a,c;if(!this.children)return this;for(a=this.children,i=0,s=a.length;s>i;i++)if(t=a[i],this[t])for(c=rt([this[t]]),r=0,o=c.length;o>r;r++)if(n=c[r],e(n)===!1)return this;return this},e.prototype.traverseChildren=function(e,t){return this.eachChild(function(n){var i;return i=t(n),i!==!1?n.traverseChildren(e,t):void 0})},e.prototype.invert=function(){return new I("!",this)},e.prototype.unwrapAll=function(){var e;for(e=this;e!==(e=e.unwrap()););return e},e.prototype.children=[],e.prototype.isStatement=D,e.prototype.jumps=D,e.prototype.isComplex=Q,e.prototype.isChainable=D,e.prototype.isAssignable=D,e.prototype.unwrap=X,e.prototype.unfoldSoak=D,e.prototype.assigns=D,e.prototype.updateLocationDataIfMissing=function(e){return this.locationData?this:(this.locationData=e,this.eachChild(function(t){return t.updateLocationDataIfMissing(e)}))},e.prototype.error=function(e){return vt(e,this.locationData)},e.prototype.makeCode=function(e){return new h(this,e)},e.prototype.wrapInBraces=function(e){return[].concat(this.makeCode("("),e,this.makeCode(")"))},e.prototype.joinFragmentArrays=function(e,t){var n,i,r,s,o;for(n=[],r=s=0,o=e.length;o>s;r=++s)i=e[r],r&&n.push(this.makeCode(t)),n=n.concat(i);return n},e}(),e.Block=s=function(e){function t(e){this.expressions=et(rt(e||[]))}return kt(t,e),t.prototype.children=["expressions"],t.prototype.push=function(e){return this.expressions.push(e),this},t.prototype.pop=function(){return this.expressions.pop()},t.prototype.unshift=function(e){return this.expressions.unshift(e),this},t.prototype.unwrap=function(){return 1===this.expressions.length?this.expressions[0]:this},t.prototype.isEmpty=function(){return!this.expressions.length},t.prototype.isStatement=function(e){var t,n,i,r;for(r=this.expressions,n=0,i=r.length;i>n;n++)if(t=r[n],t.isStatement(e))return!0;return!1},t.prototype.jumps=function(e){var t,n,i,r,s;for(s=this.expressions,n=0,r=s.length;r>n;n++)if(t=s[n],i=t.jumps(e))return i},t.prototype.makeReturn=function(e){var t,n;for(n=this.expressions.length;n--;)if(t=this.expressions[n],!(t instanceof l)){this.expressions[n]=t.makeReturn(e),t instanceof M&&!t.expression&&this.expressions.splice(n,1);break}return this},t.prototype.compileToFragments=function(e,n){return null==e&&(e={}),e.scope?t.__super__.compileToFragments.call(this,e,n):this.compileRoot(e)},t.prototype.compileNode=function(e){var n,i,r,s,o,a,c,h,l;for(this.tab=e.indent,l=e.level===L,i=[],h=this.expressions,s=o=0,a=h.length;a>o;s=++o)c=h[s],c=c.unwrapAll(),c=c.unfoldSoak(e)||c,c instanceof t?i.push(c.compileNode(e)):l?(c.front=!0,r=c.compileToFragments(e),c.isStatement(e)||(r.unshift(this.makeCode(""+this.tab)),r.push(this.makeCode(";"))),i.push(r)):i.push(c.compileToFragments(e,E));return l?this.spaced?[].concat(this.joinFragmentArrays(i,"\n\n"),this.makeCode("\n")):this.joinFragmentArrays(i,"\n"):(n=i.length?this.joinFragmentArrays(i,", "):[this.makeCode("void 0")],i.length>1&&e.level>=E?this.wrapInBraces(n):n)},t.prototype.compileRoot=function(e){var t,n,i,r,s,o,a,c,h,u,p;for(e.indent=e.bare?"":q,e.level=L,this.spaced=!0,e.scope=new P(null,this,null,null!=(h=e.referencedVars)?h:[]),u=e.locals||[],r=0,s=u.length;s>r;r++)o=u[r],e.scope.parameter(o);return a=[],e.bare||(c=function(){var e,n,r,s;for(r=this.expressions,s=[],i=e=0,n=r.length;n>e&&(t=r[i],t.unwrap()instanceof l);i=++e)s.push(t);return s}.call(this),p=this.expressions.slice(c.length),this.expressions=c,c.length&&(a=this.compileNode(lt(e,{indent:""})),a.push(this.makeCode("\n"))),this.expressions=p),n=this.compileWithDeclarations(e),e.bare?n:[].concat(a,this.makeCode("(function() {\n"),n,this.makeCode("\n}).call(this);\n"))},t.prototype.compileWithDeclarations=function(e){var t,n,i,r,s,o,a,c,h,u,p,d,f,m;for(r=[],c=[],h=this.expressions,s=o=0,a=h.length;a>o&&(i=h[s],i=i.unwrap(),i instanceof l||i instanceof x);s=++o);return e=lt(e,{level:L}),s&&(d=this.expressions.splice(s,9e9),u=[this.spaced,!1],m=u[0],this.spaced=u[1],p=[this.compileNode(e),m],r=p[0],this.spaced=p[1],this.expressions=d),c=this.compileNode(e),f=e.scope,f.expressions===this&&(n=e.scope.hasDeclarations(),t=f.hasAssignments,n||t?(s&&r.push(this.makeCode("\n")),r.push(this.makeCode(this.tab+"var ")),n&&r.push(this.makeCode(f.declaredVariables().join(", "))),t&&(n&&r.push(this.makeCode(",\n"+(this.tab+q))),r.push(this.makeCode(f.assignedVariables().join(",\n"+(this.tab+q))))),r.push(this.makeCode(";\n"+(this.spaced?"\n":"")))):r.length&&c.length&&r.push(this.makeCode("\n"))),r.concat(c)},t.wrap=function(e){return 1===e.length&&e[0]instanceof t?e[0]:new t(e)},t}(r),e.Literal=x=function(e){function t(e){this.value=e}return kt(t,e),t.prototype.makeReturn=function(){return this.isStatement()?this:t.__super__.makeReturn.apply(this,arguments)},t.prototype.isAssignable=function(){return g.test(this.value)},t.prototype.isStatement=function(){var e;return"break"===(e=this.value)||"continue"===e||"debugger"===e},t.prototype.isComplex=D,t.prototype.assigns=function(e){return e===this.value},t.prototype.jumps=function(e){return"break"!==this.value||(null!=e?e.loop:void 0)||(null!=e?e.block:void 0)?"continue"!==this.value||(null!=e?e.loop:void 0)?void 0:this:this},t.prototype.compileNode=function(e){var t,n,i;return n="this"===this.value?(null!=(i=e.scope.method)?i.bound:void 0)?e.scope.method.context:this.value:this.value.reserved?'"'+this.value+'"':this.value,t=this.isStatement()?""+this.tab+n+";":n,[this.makeCode(t)]},t.prototype.toString=function(){return' "'+this.value+'"'},t}(r),e.Undefined=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return kt(t,e),t.prototype.isAssignable=D,t.prototype.isComplex=D,t.prototype.compileNode=function(e){return[this.makeCode(e.level>=T?"(void 0)":"void 0")]},t}(r),e.Null=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return kt(t,e),t.prototype.isAssignable=D,t.prototype.isComplex=D,t.prototype.compileNode=function(){return[this.makeCode("null")]},t}(r),e.Bool=function(e){function t(e){this.val=e}return kt(t,e),t.prototype.isAssignable=D,t.prototype.isComplex=D,t.prototype.compileNode=function(){return[this.makeCode(this.val)]},t}(r),e.Return=M=function(e){function t(e){this.expression=e}return kt(t,e),t.prototype.children=["expression"],t.prototype.isStatement=Q,t.prototype.makeReturn=X,t.prototype.jumps=X,t.prototype.compileToFragments=function(e,n){var i,r;return i=null!=(r=this.expression)?r.makeReturn():void 0,!i||i instanceof t?t.__super__.compileToFragments.call(this,e,n):i.compileToFragments(e,n)},t.prototype.compileNode=function(e){var t,n,i;return t=[],n=null!=(i=this.expression)?"function"==typeof i.isYieldReturn?i.isYieldReturn():void 0:void 0,n||t.push(this.makeCode(this.tab+("return"+(this.expression?" ":"")))),this.expression&&(t=t.concat(this.expression.compileToFragments(e,N))),n||t.push(this.makeCode(";")),t},t}(r),e.Value=z=function(e){function t(e,n,i){return!n&&e instanceof t?e:(this.base=e,this.properties=n||[],i&&(this[i]=!0),this)}return kt(t,e),t.prototype.children=["base","properties"],t.prototype.add=function(e){return this.properties=this.properties.concat(e),this},t.prototype.hasProperties=function(){return!!this.properties.length},t.prototype.bareLiteral=function(e){return!this.properties.length&&this.base instanceof e},t.prototype.isArray=function(){return this.bareLiteral(n)},t.prototype.isRange=function(){return this.bareLiteral(j)},t.prototype.isComplex=function(){return this.hasProperties()||this.base.isComplex()},t.prototype.isAssignable=function(){return this.hasProperties()||this.base.isAssignable()},t.prototype.isSimpleNumber=function(){return this.bareLiteral(x)&&B.test(this.base.value)},t.prototype.isString=function(){return this.bareLiteral(x)&&y.test(this.base.value)},t.prototype.isRegex=function(){return this.bareLiteral(x)&&v.test(this.base.value)},t.prototype.isAtomic=function(){var e,t,n,i;for(i=this.properties.concat(this.base),e=0,t=i.length;t>e;e++)if(n=i[e],n.soak||n instanceof o)return!1;return!0},t.prototype.isNotCallable=function(){return this.isSimpleNumber()||this.isString()||this.isRegex()||this.isArray()||this.isRange()||this.isSplice()||this.isObject()},t.prototype.isStatement=function(e){return!this.properties.length&&this.base.isStatement(e)},t.prototype.assigns=function(e){return!this.properties.length&&this.base.assigns(e)},t.prototype.jumps=function(e){return!this.properties.length&&this.base.jumps(e)},t.prototype.isObject=function(e){return this.properties.length?!1:this.base instanceof A&&(!e||this.base.generated)},t.prototype.isSplice=function(){var e,t;return t=this.properties,e=t[t.length-1],e instanceof U},t.prototype.looksStatic=function(e){var t;return this.base.value===e&&1===this.properties.length&&"prototype"!==(null!=(t=this.properties[0].name)?t.value:void 0)},t.prototype.unwrap=function(){return this.properties.length?this:this.base},t.prototype.cacheReference=function(e){var n,r,s,o,a;return a=this.properties,s=a[a.length-1],2>this.properties.length&&!this.base.isComplex()&&!(null!=s?s.isComplex():void 0)?[this,this]:(n=new t(this.base,this.properties.slice(0,-1)),n.isComplex()&&(r=new x(e.scope.freeVariable("base")),n=new t(new O(new i(r,n)))),s?(s.isComplex()&&(o=new x(e.scope.freeVariable("name")),s=new w(new i(o,s.index)),o=new w(o)),[n.add(s),new t(r||n.base,[o||s])]):[n,r])},t.prototype.compileNode=function(e){var t,n,i,r,s;for(this.base.front=this.front,s=this.properties,t=this.base.compileToFragments(e,s.length?T:null),(this.base instanceof O||s.length)&&B.test(st(t))&&t.push(this.makeCode(".")),n=0,i=s.length;i>n;n++)r=s[n],t.push.apply(t,r.compileToFragments(e));return t},t.prototype.unfoldSoak=function(e){return null!=this.unfoldedSoak?this.unfoldedSoak:this.unfoldedSoak=function(n){return function(){var r,s,o,a,c,h,l,p,d,f;if(o=n.base.unfoldSoak(e))return(p=o.body.properties).push.apply(p,n.properties),o;for(d=n.properties,s=a=0,c=d.length;c>a;s=++a)if(h=d[s],h.soak)return h.soak=!1,r=new t(n.base,n.properties.slice(0,s)),f=new t(n.base,n.properties.slice(s)),r.isComplex()&&(l=new x(e.scope.freeVariable("ref")),r=new O(new i(l,r)),f.base=l),new b(new u(r),f,{soak:!0});return!1}}(this)()},t}(r),e.Comment=l=function(e){function t(e){this.comment=e}return kt(t,e),t.prototype.isStatement=Q,t.prototype.makeReturn=X,t.prototype.compileNode=function(e,t){var n,i;return i=this.comment.replace(/^(\s*)#(?=\s)/gm,"$1 *"),n="/*"+ut(i,this.tab)+(Tt.call(i,"\n")>=0?"\n"+this.tab:"")+" */",(t||e.level)===L&&(n=e.indent+n),[this.makeCode("\n"),this.makeCode(n)]},t}(r),e.Call=o=function(e){function n(e,t,n){this.args=null!=t?t:[],this.soak=n,this.isNew=!1,this.isSuper="super"===e,this.variable=this.isSuper?null:e,e instanceof z&&e.isNotCallable()&&e.error("literal is not a function")}return kt(n,e),n.prototype.children=["variable","args"],n.prototype.newInstance=function(){var e,t;return e=(null!=(t=this.variable)?t.base:void 0)||this.variable,e instanceof n&&!e.isNew?e.newInstance():this.isNew=!0,this},n.prototype.superReference=function(e){var n,r,s,o,a,c,h,l;return a=e.scope.namedMethod(),(null!=a?a.klass:void 0)?(o=a.klass,c=a.name,l=a.variable,o.isComplex()&&(s=new x(e.scope.parent.freeVariable("base")),r=new z(new O(new i(s,o))),l.base=r,l.properties.splice(0,o.properties.length)),(c.isComplex()||c instanceof w&&c.index.isAssignable())&&(h=new x(e.scope.parent.freeVariable("name")),c=new w(new i(h,c.index)),l.properties.pop(),l.properties.push(c)),n=[new t(new x("__super__"))],a["static"]&&n.push(new t(new x("constructor"))),n.push(null!=h?new w(h):c),new z(null!=s?s:o,n).compile(e)):(null!=a?a.ctor:void 0)?a.name+".__super__.constructor":this.error("cannot call super outside of an instance method.")},n.prototype.superThis=function(e){var t;return t=e.scope.method,t&&!t.klass&&t.context||"this"},n.prototype.unfoldSoak=function(e){var t,i,r,s,o,a,c,h,l;if(this.soak){if(this.variable){if(i=yt(e,this,"variable"))return i;c=new z(this.variable).cacheReference(e),s=c[0],l=c[1]}else s=new x(this.superReference(e)),l=new z(s);return l=new n(l,this.args),l.isNew=this.isNew,s=new x("typeof "+s.compile(e)+' === "function"'),new b(s,new z(l),{soak:!0})}for(t=this,a=[];;)if(t.variable instanceof n)a.push(t),t=t.variable;else{if(!(t.variable instanceof z))break;if(a.push(t),!((t=t.variable.base)instanceof n))break}for(h=a.reverse(),r=0,o=h.length;o>r;r++)t=h[r],i&&(t.variable instanceof n?t.variable=i:t.variable.base=i),i=yt(e,t,"variable");return i},n.prototype.compileNode=function(e){var t,n,i,r,s,o,a,c,h,l;if(null!=(h=this.variable)&&(h.front=this.front),r=G.compileSplattedArray(e,this.args,!0),r.length)return this.compileSplat(e,r);for(i=[],l=this.args,n=o=0,a=l.length;a>o;n=++o)t=l[n],n&&i.push(this.makeCode(", ")),i.push.apply(i,t.compileToFragments(e,E));return s=[],this.isSuper?(c=this.superReference(e)+(".call("+this.superThis(e)),i.length&&(c+=", "),s.push(this.makeCode(c))):(this.isNew&&s.push(this.makeCode("new ")),s.push.apply(s,this.variable.compileToFragments(e,T)),s.push(this.makeCode("("))),s.push.apply(s,i),s.push(this.makeCode(")")),s},n.prototype.compileSplat=function(e,t){var n,i,r,s,o,a;return this.isSuper?[].concat(this.makeCode(this.superReference(e)+".apply("+this.superThis(e)+", "),t,this.makeCode(")")):this.isNew?(s=this.tab+q,[].concat(this.makeCode("(function(func, args, ctor) {\n"+s+"ctor.prototype = func.prototype;\n"+s+"var child = new ctor, result = func.apply(child, args);\n"+s+"return Object(result) === result ? result : child;\n"+this.tab+"})("),this.variable.compileToFragments(e,E),this.makeCode(", "),t,this.makeCode(", function(){})"))):(n=[],i=new z(this.variable),(o=i.properties.pop())&&i.isComplex()?(a=e.scope.freeVariable("ref"),n=n.concat(this.makeCode("("+a+" = "),i.compileToFragments(e,E),this.makeCode(")"),o.compileToFragments(e))):(r=i.compileToFragments(e,T),B.test(st(r))&&(r=this.wrapInBraces(r)),o?(a=st(r),r.push.apply(r,o.compileToFragments(e))):a="null",n=n.concat(r)),n=n.concat(this.makeCode(".apply("+a+", "),t,this.makeCode(")")))},n}(r),e.Extends=d=function(e){function t(e,t){this.child=e,this.parent=t}return kt(t,e),t.prototype.children=["child","parent"],t.prototype.compileToFragments=function(e){return new o(new z(new x(bt("extend",e))),[this.child,this.parent]).compileToFragments(e)},t}(r),e.Access=t=function(e){function t(e,t){this.name=e,this.name.asKey=!0,this.soak="soak"===t}return kt(t,e),t.prototype.children=["name"],t.prototype.compileToFragments=function(e){var t;return t=this.name.compileToFragments(e),g.test(st(t))?t.unshift(this.makeCode(".")):(t.unshift(this.makeCode("[")),t.push(this.makeCode("]"))),t},t.prototype.isComplex=D,t}(r),e.Index=w=function(e){function t(e){this.index=e}return kt(t,e),t.prototype.children=["index"],t.prototype.compileToFragments=function(e){return[].concat(this.makeCode("["),this.index.compileToFragments(e,N),this.makeCode("]"))},t.prototype.isComplex=function(){return this.index.isComplex()},t}(r),e.Range=j=function(e){function t(e,t,n){this.from=e,this.to=t,this.exclusive="exclusive"===n,this.equals=this.exclusive?"":"="}return kt(t,e),t.prototype.children=["from","to"],t.prototype.compileVariables=function(e){var t,n,i,r,s,o;return e=lt(e,{top:!0}),t=tt(e,"isComplex"),n=this.cacheToCodeFragments(this.from.cache(e,E,t)),this.fromC=n[0],this.fromVar=n[1],i=this.cacheToCodeFragments(this.to.cache(e,E,t)),this.toC=i[0],this.toVar=i[1],(o=tt(e,"step"))&&(r=this.cacheToCodeFragments(o.cache(e,E,t)),this.step=r[0],this.stepVar=r[1]),s=[this.fromVar.match(R),this.toVar.match(R)],this.fromNum=s[0],this.toNum=s[1],this.stepVar?this.stepNum=this.stepVar.match(R):void 0},t.prototype.compileNode=function(e){var t,n,i,r,s,o,a,c,h,l,u,p,d,f;return this.fromVar||this.compileVariables(e),e.index?(a=this.fromNum&&this.toNum,s=tt(e,"index"),o=tt(e,"name"),h=o&&o!==s,f=s+" = "+this.fromC,this.toC!==this.toVar&&(f+=", "+this.toC),this.step!==this.stepVar&&(f+=", "+this.step),l=[s+" <"+this.equals,s+" >"+this.equals],c=l[0],r=l[1],n=this.stepNum?pt(this.stepNum[0])>0?c+" "+this.toVar:r+" "+this.toVar:a?(u=[pt(this.fromNum[0]),pt(this.toNum[0])],i=u[0],d=u[1],u,d>=i?c+" "+d:r+" "+d):(t=this.stepVar?this.stepVar+" > 0":this.fromVar+" <= "+this.toVar,t+" ? "+c+" "+this.toVar+" : "+r+" "+this.toVar),p=this.stepVar?s+" += "+this.stepVar:a?h?d>=i?"++"+s:"--"+s:d>=i?s+"++":s+"--":h?t+" ? ++"+s+" : --"+s:t+" ? "+s+"++ : "+s+"--",h&&(f=o+" = "+f),h&&(p=o+" = "+p),[this.makeCode(f+"; "+n+"; "+p)]):this.compileArray(e)},t.prototype.compileArray=function(e){var t,n,i,r,s,o,a,c,h,l,u,p,d;return this.fromNum&&this.toNum&&20>=Math.abs(this.fromNum-this.toNum)?(h=function(){p=[];for(var e=l=+this.fromNum,t=+this.toNum;t>=l?t>=e:e>=t;t>=l?e++:e--)p.push(e);return p}.apply(this),this.exclusive&&h.pop(),[this.makeCode("["+h.join(", ")+"]")]):(o=this.tab+q,s=e.scope.freeVariable("i",{single:!0}),u=e.scope.freeVariable("results"),c="\n"+o+u+" = [];",this.fromNum&&this.toNum?(e.index=s,n=st(this.compileNode(e))):(d=s+" = "+this.fromC+(this.toC!==this.toVar?", "+this.toC:""),i=this.fromVar+" <= "+this.toVar,n="var "+d+"; "+i+" ? "+s+" <"+this.equals+" "+this.toVar+" : "+s+" >"+this.equals+" "+this.toVar+"; "+i+" ? "+s+"++ : "+s+"--"),a="{ "+u+".push("+s+"); }\n"+o+"return "+u+";\n"+e.indent,r=function(e){return null!=e?e.contains(at):void 0},(r(this.from)||r(this.to))&&(t=", arguments"),[this.makeCode("(function() {"+c+"\n"+o+"for ("+n+")"+a+"}).apply(this"+(null!=t?t:"")+")")])},t}(r),e.Slice=U=function(e){function t(e){this.range=e,t.__super__.constructor.call(this)}return kt(t,e),t.prototype.children=["range"],t.prototype.compileNode=function(e){var t,n,i,r,s,o,a;return s=this.range,o=s.to,i=s.from,r=i&&i.compileToFragments(e,N)||[this.makeCode("0")],o&&(t=o.compileToFragments(e,N),n=st(t),(this.range.exclusive||-1!==+n)&&(a=", "+(this.range.exclusive?n:B.test(n)?""+(+n+1):(t=o.compileToFragments(e,T),"+"+st(t)+" + 1 || 9e9")))),[this.makeCode(".slice("+st(r)+(a||"")+")")]},t}(r),e.Obj=A=function(e){function n(e,t){this.generated=null!=t?t:!1,this.objects=this.properties=e||[]}return kt(n,e),n.prototype.children=["properties"],n.prototype.compileNode=function(e){var n,r,s,o,a,c,h,u,p,d,f,m,g,v,y,b,k,w,T,C,E;if(T=this.properties,this.generated)for(h=0,g=T.length;g>h;h++)b=T[h],b instanceof z&&b.error("cannot have an implicit value in an implicit object");for(r=p=0,v=T.length;v>p&&(w=T[r],!((w.variable||w).base instanceof O));r=++p);for(s=T.length>r,a=e.indent+=q,m=this.lastNonComment(this.properties),n=[],s&&(k=e.scope.freeVariable("obj"),n.push(this.makeCode("(\n"+a+k+" = "))),n.push(this.makeCode("{"+(0===T.length||0===r?"}":"\n"))),o=f=0,y=T.length;y>f;o=++f)w=T[o],o===r&&(0!==o&&n.push(this.makeCode("\n"+a+"}")),n.push(this.makeCode(",\n"))),u=o===T.length-1||o===r-1?"":w===m||w instanceof l?"\n":",\n",c=w instanceof l?"":a,s&&r>o&&(c+=q),w instanceof i&&w.variable instanceof z&&w.variable.hasProperties()&&w.variable.error("invalid object key"),w instanceof z&&w["this"]&&(w=new i(w.properties[0].name,w,"object")),w instanceof l||(r>o?(w instanceof i||(w=new i(w,w,"object")),(w.variable.base||w.variable).asKey=!0):(w instanceof i?(d=w.variable,E=w.value):(C=w.base.cache(e),d=C[0],E=C[1]),w=new i(new z(new x(k),[new t(d)]),E))),c&&n.push(this.makeCode(c)),n.push.apply(n,w.compileToFragments(e,L)),u&&n.push(this.makeCode(u));return s?n.push(this.makeCode(",\n"+a+k+"\n"+this.tab+")")):0!==T.length&&n.push(this.makeCode("\n"+this.tab+"}")),this.front&&!s?this.wrapInBraces(n):n},n.prototype.assigns=function(e){var t,n,i,r;for(r=this.properties,t=0,n=r.length;n>t;t++)if(i=r[t],i.assigns(e))return!0;return!1},n}(r),e.Arr=n=function(e){function t(e){this.objects=e||[]}return kt(t,e),t.prototype.children=["objects"],t.prototype.compileNode=function(e){var t,n,i,r,s,o,a;if(!this.objects.length)return[this.makeCode("[]")];if(e.indent+=q,t=G.compileSplattedArray(e,this.objects),t.length)return t;for(t=[],n=function(){var t,n,i,r;for(i=this.objects,r=[],t=0,n=i.length;n>t;t++)a=i[t],r.push(a.compileToFragments(e,E));return r}.call(this),r=s=0,o=n.length;o>s;r=++s)i=n[r],r&&t.push(this.makeCode(", ")),t.push.apply(t,i);return st(t).indexOf("\n")>=0?(t.unshift(this.makeCode("[\n"+e.indent)),t.push(this.makeCode("\n"+this.tab+"]"))):(t.unshift(this.makeCode("[")),t.push(this.makeCode("]"))),t},t.prototype.assigns=function(e){var t,n,i,r;for(r=this.objects,t=0,n=r.length;n>t;t++)if(i=r[t],i.assigns(e))return!0;return!1},t}(r),e.Class=a=function(e){function n(e,t,n){this.variable=e,this.parent=t,this.body=null!=n?n:new s,this.boundFuncs=[],this.body.classBody=!0}return kt(n,e),n.prototype.children=["variable","parent","body"],n.prototype.determineName=function(){var e,n,i;return this.variable?(n=this.variable.properties,i=n[n.length-1],e=i?i instanceof t&&i.name.value:this.variable.base.value,Tt.call(V,e)>=0&&this.variable.error("class variable name may not be "+e),e&&(e=g.test(e)&&e)):null},n.prototype.setContext=function(e){return this.body.traverseChildren(!1,function(t){return t.classBody?!1:t instanceof x&&"this"===t.value?t.value=e:t instanceof c&&t.bound?t.context=e:void 0})},n.prototype.addBoundFunctions=function(e){var n,i,r,s,o;for(o=this.boundFuncs,i=0,r=o.length;r>i;i++)n=o[i],s=new z(new x("this"),[new t(n)]).compile(e),this.ctor.body.unshift(new x(s+" = "+bt("bind",e)+"("+s+", this)"))},n.prototype.addProperties=function(e,n,r){var s,o,a,h,l,u;return u=e.base.properties.slice(0),h=function(){var e;for(e=[];o=u.shift();)o instanceof i&&(a=o.variable.base,delete o.context,l=o.value,"constructor"===a.value?(this.ctor&&o.error("cannot define more than one constructor in a class"),l.bound&&o.error("cannot define a constructor as a bound function"),l instanceof c?o=this.ctor=l:(this.externalCtor=r.classScope.freeVariable("class"),o=new i(new x(this.externalCtor),l))):o.variable["this"]?l["static"]=!0:(s=a.isComplex()?new w(a):new t(a),o.variable=new z(new x(n),[new t(new x("prototype")),s]),l instanceof c&&l.bound&&(this.boundFuncs.push(a),l.bound=!1))),e.push(o);return e}.call(this),et(h)},n.prototype.walkBody=function(e,t){return this.traverseChildren(!1,function(r){return function(o){var a,c,h,l,u,p,d;if(a=!0,o instanceof n)return!1;if(o instanceof s){for(d=c=o.expressions,h=l=0,u=d.length;u>l;h=++l)p=d[h],p instanceof i&&p.variable.looksStatic(e)?p.value["static"]=!0:p instanceof z&&p.isObject(!0)&&(a=!1,c[h]=r.addProperties(p,e,t));o.expressions=c=rt(c)}return a&&!(o instanceof n)}}(this))},n.prototype.hoistDirectivePrologue=function(){var e,t,n;for(t=0,e=this.body.expressions;(n=e[t])&&n instanceof l||n instanceof z&&n.isString();)++t;return this.directives=e.splice(0,t)},n.prototype.ensureConstructor=function(e){return this.ctor||(this.ctor=new c,this.externalCtor?this.ctor.body.push(new x(this.externalCtor+".apply(this, arguments)")):this.parent&&this.ctor.body.push(new x(e+".__super__.constructor.apply(this, arguments)")),this.ctor.body.makeReturn(),this.body.expressions.unshift(this.ctor)),this.ctor.ctor=this.ctor.name=e,this.ctor.klass=null,this.ctor.noReturn=!0},n.prototype.compileNode=function(e){var t,n,r,a,h,l,u,p,f;return(a=this.body.jumps())&&a.error("Class bodies cannot contain pure statements"),(n=this.body.contains(at))&&n.error("Class bodies shouldn't reference arguments"),u=this.determineName()||"_Class",u.reserved&&(u="_"+u),l=new x(u),r=new c([],s.wrap([this.body])),t=[],e.classScope=r.makeScope(e.scope),this.hoistDirectivePrologue(),this.setContext(u),this.walkBody(u,e),this.ensureConstructor(u),this.addBoundFunctions(e),this.body.spaced=!0,this.body.expressions.push(l),this.parent&&(f=new x(e.classScope.freeVariable("superClass",{reserve:!1})),this.body.expressions.unshift(new d(l,f)),r.params.push(new _(f)),t.push(this.parent)),(p=this.body.expressions).unshift.apply(p,this.directives),h=new O(new o(r,t)),this.variable&&(h=new i(this.variable,h)),h.compileToFragments(e)},n}(r),e.Assign=i=function(e){function n(e,t,n,i){var r,s,o;this.variable=e,this.value=t,this.context=n,this.param=i&&i.param,this.subpattern=i&&i.subpattern,o=s=this.variable.unwrapAll().value,r=Tt.call(V,o)>=0,r&&"object"!==this.context&&this.variable.error('variable name may not be "'+s+'"')}return kt(n,e),n.prototype.children=["variable","value"],n.prototype.isStatement=function(e){return(null!=e?e.level:void 0)===L&&null!=this.context&&Tt.call(this.context,"?")>=0 +},n.prototype.assigns=function(e){return this["object"===this.context?"value":"variable"].assigns(e)},n.prototype.unfoldSoak=function(e){return yt(e,this,"variable")},n.prototype.compileNode=function(e){var t,n,i,r,s,o,a,h,l,u,p,d,f,m;if(i=this.variable instanceof z){if(this.variable.isArray()||this.variable.isObject())return this.compilePatternMatch(e);if(this.variable.isSplice())return this.compileSplice(e);if("||="===(h=this.context)||"&&="===h||"?="===h)return this.compileConditional(e);if("**="===(l=this.context)||"//="===l||"%%="===l)return this.compileSpecialMath(e)}return this.value instanceof c&&(this.value["static"]?(this.value.klass=this.variable.base,this.value.name=this.variable.properties[0],this.value.variable=this.variable):(null!=(u=this.variable.properties)?u.length:void 0)>=2&&(p=this.variable.properties,o=p.length>=3?Ct.call(p,0,r=p.length-2):(r=0,[]),a=p[r++],s=p[r++],"prototype"===(null!=(d=a.name)?d.value:void 0)&&(this.value.klass=new z(this.variable.base,o),this.value.name=s,this.value.variable=this.variable))),this.context||(m=this.variable.unwrapAll(),m.isAssignable()||this.variable.error('"'+this.variable.compile(e)+'" cannot be assigned'),("function"==typeof m.hasProperties?m.hasProperties():void 0)||(this.param?e.scope.add(m.value,"var"):e.scope.find(m.value))),f=this.value.compileToFragments(e,E),n=this.variable.compileToFragments(e,E),"object"===this.context?n.concat(this.makeCode(": "),f):(t=n.concat(this.makeCode(" "+(this.context||"=")+" "),f),E>=e.level?t:this.wrapInBraces(t))},n.prototype.compilePatternMatch=function(e){var i,r,s,o,a,c,h,l,u,d,f,m,v,y,b,k,T,C,N,S,D,R,A,I,_,j,M,B;if(I=e.level===L,j=this.value,y=this.variable.base.objects,!(b=y.length))return s=j.compileToFragments(e),e.level>=F?this.wrapInBraces(s):s;if(l=this.variable.isObject(),I&&1===b&&!((v=y[0])instanceof G))return v instanceof n?(T=v,C=T.variable,h=C.base,v=T.value):h=l?v["this"]?v.properties[0].name:v:new x(0),i=g.test(h.unwrap().value||0),j=new z(j),j.properties.push(new(i?t:w)(h)),N=v.unwrap().value,Tt.call($,N)>=0&&v.error("assignment to a reserved word: "+v.compile(e)),new n(v,j,null,{param:this.param}).compileToFragments(e,L);for(M=j.compileToFragments(e,E),B=st(M),r=[],o=!1,(!g.test(B)||this.variable.assigns(B))&&(r.push([this.makeCode((k=e.scope.freeVariable("ref"))+" = ")].concat(Ct.call(M))),M=[this.makeCode(k)],B=k),c=d=0,f=y.length;f>d;c=++d){if(v=y[c],h=c,l&&(v instanceof n?(S=v,D=S.variable,h=D.base,v=S.value):v.base instanceof O?(R=new z(v.unwrapAll()).cacheReference(e),v=R[0],h=R[1]):h=v["this"]?v.properties[0].name:v),!o&&v instanceof G)m=v.name.unwrap().value,v=v.unwrap(),_=b+" <= "+B+".length ? "+bt("slice",e)+".call("+B+", "+c,(A=b-c-1)?(u=e.scope.freeVariable("i",{single:!0}),_+=", "+u+" = "+B+".length - "+A+") : ("+u+" = "+c+", [])"):_+=") : []",_=new x(_),o=u+"++";else{if(!o&&v instanceof p){(A=b-c-1)&&(1===A?o=B+".length - 1":(u=e.scope.freeVariable("i",{single:!0}),_=new x(u+" = "+B+".length - "+A),o=u+"++",r.push(_.compileToFragments(e,E))));continue}m=v.unwrap().value,(v instanceof G||v instanceof p)&&v.error("multiple splats/expansions are disallowed in an assignment"),"number"==typeof h?(h=new x(o||h),i=!1):i=l&&g.test(h.unwrap().value||0),_=new z(new x(B),[new(i?t:w)(h)])}null!=m&&Tt.call($,m)>=0&&v.error("assignment to a reserved word: "+v.compile(e)),r.push(new n(v,_,null,{param:this.param,subpattern:!0}).compileToFragments(e,E))}return I||this.subpattern||r.push(M),a=this.joinFragmentArrays(r,", "),E>e.level?a:this.wrapInBraces(a)},n.prototype.compileConditional=function(e){var t,i,r,s;return r=this.variable.cacheReference(e),i=r[0],s=r[1],!i.properties.length&&i.base instanceof x&&"this"!==i.base.value&&!e.scope.check(i.base.value)&&this.variable.error('the variable "'+i.base.value+"\" can't be assigned with "+this.context+" because it has not been declared before"),Tt.call(this.context,"?")>=0?(e.isExistentialEquals=!0,new b(new u(i),s,{type:"if"}).addElse(new n(s,this.value,"=")).compileToFragments(e)):(t=new I(this.context.slice(0,-1),i,new n(s,this.value,"=")).compileToFragments(e),E>=e.level?t:this.wrapInBraces(t))},n.prototype.compileSpecialMath=function(e){var t,i,r;return i=this.variable.cacheReference(e),t=i[0],r=i[1],new n(t,new I(this.context.slice(0,-1),r,this.value)).compileToFragments(e)},n.prototype.compileSplice=function(e){var t,n,i,r,s,o,a,c,h,l,u,p;return a=this.variable.properties.pop().range,i=a.from,l=a.to,n=a.exclusive,o=this.variable.compile(e),i?(c=this.cacheToCodeFragments(i.cache(e,F)),r=c[0],s=c[1]):r=s="0",l?i instanceof z&&i.isSimpleNumber()&&l instanceof z&&l.isSimpleNumber()?(l=l.compile(e)-s,n||(l+=1)):(l=l.compile(e,T)+" - "+s,n||(l+=" + 1")):l="9e9",h=this.value.cache(e,E),u=h[0],p=h[1],t=[].concat(this.makeCode("[].splice.apply("+o+", ["+r+", "+l+"].concat("),u,this.makeCode(")), "),p),e.level>L?this.wrapInBraces(t):t},n}(r),e.Code=c=function(e){function t(e,t,n){this.params=e||[],this.body=t||new s,this.bound="boundfunc"===n,this.isGenerator=!!this.body.contains(function(e){var t;return e instanceof I&&("yield"===(t=e.operator)||"yield*"===t)})}return kt(t,e),t.prototype.children=["params","body"],t.prototype.isStatement=function(){return!!this.ctor},t.prototype.jumps=D,t.prototype.makeScope=function(e){return new P(e,this.body,this)},t.prototype.compileNode=function(e){var r,a,c,h,l,u,d,f,m,g,v,y,k,w,C,E,F,N,L,S,D,R,A,O,$,j,M,B,V,P,U,G,H;if(this.bound&&(null!=(A=e.scope.method)?A.bound:void 0)&&(this.context=e.scope.method.context),this.bound&&!this.context)return this.context="_this",H=new t([new _(new x(this.context))],new s([this])),a=new o(H,[new x("this")]),a.updateLocationDataIfMissing(this.locationData),a.compileNode(e);for(e.scope=tt(e,"classScope")||this.makeScope(e.scope),e.scope.shared=tt(e,"sharedScope"),e.indent+=q,delete e.bare,delete e.isExistentialEquals,L=[],h=[],O=this.params,u=0,m=O.length;m>u;u++)N=O[u],N instanceof p||e.scope.parameter(N.asReference(e));for($=this.params,d=0,g=$.length;g>d;d++)if(N=$[d],N.splat||N instanceof p){for(j=this.params,f=0,v=j.length;v>f;f++)F=j[f],F instanceof p||!F.name.value||e.scope.add(F.name.value,"var",!0);V=new i(new z(new n(function(){var t,n,i,r;for(i=this.params,r=[],n=0,t=i.length;t>n;n++)F=i[n],r.push(F.asReference(e));return r}.call(this))),new z(new x("arguments")));break}for(M=this.params,E=0,y=M.length;y>E;E++)N=M[E],N.isComplex()?(U=R=N.asReference(e),N.value&&(U=new I("?",R,N.value)),h.push(new i(new z(N.name),U,"=",{param:!0}))):(R=N,N.value&&(C=new x(R.name.value+" == null"),U=new i(new z(N.name),N.value,"="),h.push(new b(C,U)))),V||L.push(R);for(G=this.body.isEmpty(),V&&h.unshift(V),h.length&&(B=this.body.expressions).unshift.apply(B,h),l=S=0,k=L.length;k>S;l=++S)F=L[l],L[l]=F.compileToFragments(e),e.scope.parameter(st(L[l]));for(P=[],this.eachParamName(function(e,t){return Tt.call(P,e)>=0&&t.error("multiple parameters named "+e),P.push(e)}),G||this.noReturn||this.body.makeReturn(),c="function",this.isGenerator&&(c+="*"),this.ctor&&(c+=" "+this.name),c+="(",r=[this.makeCode(c)],l=D=0,w=L.length;w>D;l=++D)F=L[l],l&&r.push(this.makeCode(", ")),r.push.apply(r,F);return r.push(this.makeCode(") {")),this.body.isEmpty()||(r=r.concat(this.makeCode("\n"),this.body.compileWithDeclarations(e),this.makeCode("\n"+this.tab))),r.push(this.makeCode("}")),this.ctor?[this.makeCode(this.tab)].concat(Ct.call(r)):this.front||e.level>=T?this.wrapInBraces(r):r},t.prototype.eachParamName=function(e){var t,n,i,r,s;for(r=this.params,s=[],t=0,n=r.length;n>t;t++)i=r[t],s.push(i.eachName(e));return s},t.prototype.traverseChildren=function(e,n){return e?t.__super__.traverseChildren.call(this,e,n):void 0},t}(r),e.Param=_=function(e){function t(e,t,n){var i,r;this.name=e,this.value=t,this.splat=n,r=i=this.name.unwrapAll().value,Tt.call(V,r)>=0&&this.name.error('parameter name "'+i+'" is not allowed')}return kt(t,e),t.prototype.children=["name","value"],t.prototype.compileToFragments=function(e){return this.name.compileToFragments(e,E)},t.prototype.asReference=function(e){var t,n;return this.reference?this.reference:(n=this.name,n["this"]?(t=n.properties[0].name.value,t.reserved&&(t="_"+t),n=new x(e.scope.freeVariable(t))):n.isComplex()&&(n=new x(e.scope.freeVariable("arg"))),n=new z(n),this.splat&&(n=new G(n)),n.updateLocationDataIfMissing(this.locationData),this.reference=n)},t.prototype.isComplex=function(){return this.name.isComplex()},t.prototype.eachName=function(e,t){var n,r,s,o,a,c;if(null==t&&(t=this.name),n=function(t){return e("@"+t.properties[0].name.value,t)},t instanceof x)return e(t.value,t);if(t instanceof z)return n(t);for(c=t.objects,r=0,s=c.length;s>r;r++)a=c[r],a instanceof i?this.eachName(e,a.value.unwrap()):a instanceof G?(o=a.name.unwrap(),e(o.value,o)):a instanceof z?a.isArray()||a.isObject()?this.eachName(e,a.base):a["this"]?n(a):e(a.base.value,a.base):a instanceof p||a.error("illegal parameter "+a.compile())},t}(r),e.Splat=G=function(e){function t(e){this.name=e.compile?e:new x(e)}return kt(t,e),t.prototype.children=["name"],t.prototype.isAssignable=Q,t.prototype.assigns=function(e){return this.name.assigns(e)},t.prototype.compileToFragments=function(e){return this.name.compileToFragments(e)},t.prototype.unwrap=function(){return this.name},t.compileSplattedArray=function(e,n,i){var r,s,o,a,c,h,l,u,p,d,f;for(l=-1;(f=n[++l])&&!(f instanceof t););if(l>=n.length)return[];if(1===n.length)return f=n[0],c=f.compileToFragments(e,E),i?c:[].concat(f.makeCode(bt("slice",e)+".call("),c,f.makeCode(")"));for(r=n.slice(l),h=u=0,d=r.length;d>u;h=++u)f=r[h],o=f.compileToFragments(e,E),r[h]=f instanceof t?[].concat(f.makeCode(bt("slice",e)+".call("),o,f.makeCode(")")):[].concat(f.makeCode("["),o,f.makeCode("]"));return 0===l?(f=n[0],a=f.joinFragmentArrays(r.slice(1),", "),r[0].concat(f.makeCode(".concat("),a,f.makeCode(")"))):(s=function(){var t,i,r,s;for(r=n.slice(0,l),s=[],t=0,i=r.length;i>t;t++)f=r[t],s.push(f.compileToFragments(e,E));return s}(),s=n[0].joinFragmentArrays(s,", "),a=n[l].joinFragmentArrays(r,", "),p=n[n.length-1],[].concat(n[0].makeCode("["),s,n[l].makeCode("].concat("),a,p.makeCode(")")))},t}(r),e.Expansion=p=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return kt(t,e),t.prototype.isComplex=D,t.prototype.compileNode=function(){return this.error("Expansion must be used inside a destructuring assignment or parameter list")},t.prototype.asReference=function(){return this},t.prototype.eachName=function(){},t}(r),e.While=J=function(e){function t(e,t){this.condition=(null!=t?t.invert:void 0)?e.invert():e,this.guard=null!=t?t.guard:void 0}return kt(t,e),t.prototype.children=["condition","guard","body"],t.prototype.isStatement=Q,t.prototype.makeReturn=function(e){return e?t.__super__.makeReturn.apply(this,arguments):(this.returns=!this.jumps({loop:!0}),this)},t.prototype.addBody=function(e){return this.body=e,this},t.prototype.jumps=function(){var e,t,n,i,r;if(e=this.body.expressions,!e.length)return!1;for(t=0,i=e.length;i>t;t++)if(r=e[t],n=r.jumps({loop:!0}))return n;return!1},t.prototype.compileNode=function(e){var t,n,i,r;return e.indent+=q,r="",n=this.body,n.isEmpty()?n=this.makeCode(""):(this.returns&&(n.makeReturn(i=e.scope.freeVariable("results")),r=""+this.tab+i+" = [];\n"),this.guard&&(n.expressions.length>1?n.expressions.unshift(new b(new O(this.guard).invert(),new x("continue"))):this.guard&&(n=s.wrap([new b(this.guard,n)]))),n=[].concat(this.makeCode("\n"),n.compileToFragments(e,L),this.makeCode("\n"+this.tab))),t=[].concat(this.makeCode(r+this.tab+"while ("),this.condition.compileToFragments(e,N),this.makeCode(") {"),n,this.makeCode("}")),this.returns&&t.push(this.makeCode("\n"+this.tab+"return "+i+";")),t},t}(r),e.Op=I=function(e){function n(e,t,n,i){if("in"===e)return new k(t,n);if("do"===e)return this.generateDo(t);if("new"===e){if(t instanceof o&&!t["do"]&&!t.isNew)return t.newInstance();(t instanceof c&&t.bound||t["do"])&&(t=new O(t))}return this.operator=r[e]||e,this.first=t,this.second=n,this.flip=!!i,this}var r,s;return kt(n,e),r={"==":"===","!=":"!==",of:"in",yieldfrom:"yield*"},s={"!==":"===","===":"!=="},n.prototype.children=["first","second"],n.prototype.isSimpleNumber=D,n.prototype.isYield=function(){var e;return"yield"===(e=this.operator)||"yield*"===e},n.prototype.isYieldReturn=function(){return this.isYield()&&this.first instanceof M},n.prototype.isUnary=function(){return!this.second},n.prototype.isComplex=function(){var e;return!(this.isUnary()&&("+"===(e=this.operator)||"-"===e)&&this.first instanceof z&&this.first.isSimpleNumber())},n.prototype.isChainable=function(){var e;return"<"===(e=this.operator)||">"===e||">="===e||"<="===e||"==="===e||"!=="===e},n.prototype.invert=function(){var e,t,i,r,o;if(this.isChainable()&&this.first.isChainable()){for(e=!0,t=this;t&&t.operator;)e&&(e=t.operator in s),t=t.first;if(!e)return new O(this).invert();for(t=this;t&&t.operator;)t.invert=!t.invert,t.operator=s[t.operator],t=t.first;return this}return(r=s[this.operator])?(this.operator=r,this.first.unwrap()instanceof n&&this.first.invert(),this):this.second?new O(this).invert():"!"===this.operator&&(i=this.first.unwrap())instanceof n&&("!"===(o=i.operator)||"in"===o||"instanceof"===o)?i:new n("!",this)},n.prototype.unfoldSoak=function(e){var t;return("++"===(t=this.operator)||"--"===t||"delete"===t)&&yt(e,this,"first")},n.prototype.generateDo=function(e){var t,n,r,s,a,h,l,u;for(h=[],n=e instanceof i&&(l=e.value.unwrap())instanceof c?l:e,u=n.params||[],r=0,s=u.length;s>r;r++)a=u[r],a.value?(h.push(a.value),delete a.value):h.push(a);return t=new o(e,h),t["do"]=!0,t},n.prototype.compileNode=function(e){var t,n,i,r,s,o;if(n=this.isChainable()&&this.first.isChainable(),n||(this.first.front=this.front),"delete"===this.operator&&e.scope.check(this.first.unwrapAll().value)&&this.error("delete operand may not be argument or var"),("--"===(r=this.operator)||"++"===r)&&(s=this.first.unwrapAll().value,Tt.call(V,s)>=0)&&this.error('cannot increment/decrement "'+this.first.unwrapAll().value+'"'),this.isYield())return this.compileYield(e);if(this.isUnary())return this.compileUnary(e);if(n)return this.compileChain(e);switch(this.operator){case"?":return this.compileExistence(e);case"**":return this.compilePower(e);case"//":return this.compileFloorDivision(e);case"%%":return this.compileModulo(e);default:return i=this.first.compileToFragments(e,F),o=this.second.compileToFragments(e,F),t=[].concat(i,this.makeCode(" "+this.operator+" "),o),F>=e.level?t:this.wrapInBraces(t)}},n.prototype.compileChain=function(e){var t,n,i,r;return i=this.first.second.cache(e),this.first.second=i[0],r=i[1],n=this.first.compileToFragments(e,F),t=n.concat(this.makeCode(" "+(this.invert?"&&":"||")+" "),r.compileToFragments(e),this.makeCode(" "+this.operator+" "),this.second.compileToFragments(e,F)),this.wrapInBraces(t)},n.prototype.compileExistence=function(e){var t,n;return this.first.isComplex()?(n=new x(e.scope.freeVariable("ref")),t=new O(new i(n,this.first))):(t=this.first,n=t),new b(new u(t),n,{type:"if"}).addElse(this.second).compileToFragments(e)},n.prototype.compileUnary=function(e){var t,i,r;return i=[],t=this.operator,i.push([this.makeCode(t)]),"!"===t&&this.first instanceof u?(this.first.negated=!this.first.negated,this.first.compileToFragments(e)):e.level>=T?new O(this).compileToFragments(e):(r="+"===t||"-"===t,("new"===t||"typeof"===t||"delete"===t||r&&this.first instanceof n&&this.first.operator===t)&&i.push([this.makeCode(" ")]),(r&&this.first instanceof n||"new"===t&&this.first.isStatement(e))&&(this.first=new O(this.first)),i.push(this.first.compileToFragments(e,F)),this.flip&&i.reverse(),this.joinFragmentArrays(i,""))},n.prototype.compileYield=function(e){var t,n;return n=[],t=this.operator,null==e.scope.parent&&this.error("yield statements must occur within a function generator."),Tt.call(Object.keys(this.first),"expression")>=0&&!(this.first instanceof W)?this.isYieldReturn()?n.push(this.first.compileToFragments(e,L)):null!=this.first.expression&&n.push(this.first.expression.compileToFragments(e,F)):(n.push([this.makeCode("("+t+" ")]),n.push(this.first.compileToFragments(e,F)),n.push([this.makeCode(")")])),this.joinFragmentArrays(n,"")},n.prototype.compilePower=function(e){var n;return n=new z(new x("Math"),[new t(new x("pow"))]),new o(n,[this.first,this.second]).compileToFragments(e)},n.prototype.compileFloorDivision=function(e){var i,r;return r=new z(new x("Math"),[new t(new x("floor"))]),i=new n("/",this.first,this.second),new o(r,[i]).compileToFragments(e)},n.prototype.compileModulo=function(e){var t;return t=new z(new x(bt("modulo",e))),new o(t,[this.first,this.second]).compileToFragments(e)},n.prototype.toString=function(e){return n.__super__.toString.call(this,e,this.constructor.name+" "+this.operator)},n}(r),e.In=k=function(e){function t(e,t){this.object=e,this.array=t}return kt(t,e),t.prototype.children=["object","array"],t.prototype.invert=S,t.prototype.compileNode=function(e){var t,n,i,r,s;if(this.array instanceof z&&this.array.isArray()&&this.array.base.objects.length){for(s=this.array.base.objects,n=0,i=s.length;i>n;n++)if(r=s[n],r instanceof G){t=!0;break}if(!t)return this.compileOrTest(e)}return this.compileLoopTest(e)},t.prototype.compileOrTest=function(e){var t,n,i,r,s,o,a,c,h,l,u,p;for(c=this.object.cache(e,F),u=c[0],a=c[1],h=this.negated?[" !== "," && "]:[" === "," || "],t=h[0],n=h[1],p=[],l=this.array.base.objects,i=s=0,o=l.length;o>s;i=++s)r=l[i],i&&p.push(this.makeCode(n)),p=p.concat(i?a:u,this.makeCode(t),r.compileToFragments(e,T));return F>e.level?p:this.wrapInBraces(p)},t.prototype.compileLoopTest=function(e){var t,n,i,r;return i=this.object.cache(e,E),r=i[0],n=i[1],t=[].concat(this.makeCode(bt("indexOf",e)+".call("),this.array.compileToFragments(e,E),this.makeCode(", "),n,this.makeCode(") "+(this.negated?"< 0":">= 0"))),st(r)===st(n)?t:(t=r.concat(this.makeCode(", "),t),E>e.level?t:this.wrapInBraces(t))},t.prototype.toString=function(e){return t.__super__.toString.call(this,e,this.constructor.name+(this.negated?"!":""))},t}(r),e.Try=Y=function(e){function t(e,t,n,i){this.attempt=e,this.errorVariable=t,this.recovery=n,this.ensure=i}return kt(t,e),t.prototype.children=["attempt","recovery","ensure"],t.prototype.isStatement=Q,t.prototype.jumps=function(e){var t;return this.attempt.jumps(e)||(null!=(t=this.recovery)?t.jumps(e):void 0)},t.prototype.makeReturn=function(e){return this.attempt&&(this.attempt=this.attempt.makeReturn(e)),this.recovery&&(this.recovery=this.recovery.makeReturn(e)),this},t.prototype.compileNode=function(e){var t,n,r,s;return e.indent+=q,s=this.attempt.compileToFragments(e,L),t=this.recovery?(r=new x("_error"),this.errorVariable?this.recovery.unshift(new i(this.errorVariable,r)):void 0,[].concat(this.makeCode(" catch ("),r.compileToFragments(e),this.makeCode(") {\n"),this.recovery.compileToFragments(e,L),this.makeCode("\n"+this.tab+"}"))):this.ensure||this.recovery?[]:[this.makeCode(" catch (_error) {}")],n=this.ensure?[].concat(this.makeCode(" finally {\n"),this.ensure.compileToFragments(e,L),this.makeCode("\n"+this.tab+"}")):[],[].concat(this.makeCode(this.tab+"try {\n"),s,this.makeCode("\n"+this.tab+"}"),t,n)},t}(r),e.Throw=W=function(e){function t(e){this.expression=e}return kt(t,e),t.prototype.children=["expression"],t.prototype.isStatement=Q,t.prototype.jumps=D,t.prototype.makeReturn=X,t.prototype.compileNode=function(e){return[].concat(this.makeCode(this.tab+"throw "),this.expression.compileToFragments(e),this.makeCode(";"))},t}(r),e.Existence=u=function(e){function t(e){this.expression=e}return kt(t,e),t.prototype.children=["expression"],t.prototype.invert=S,t.prototype.compileNode=function(e){var t,n,i,r;return this.expression.front=this.front,i=this.expression.compile(e,F),g.test(i)&&!e.scope.check(i)?(r=this.negated?["===","||"]:["!==","&&"],t=r[0],n=r[1],i="typeof "+i+" "+t+' "undefined" '+n+" "+i+" "+t+" null"):i=i+" "+(this.negated?"==":"!=")+" null",[this.makeCode(C>=e.level?i:"("+i+")")]},t}(r),e.Parens=O=function(e){function t(e){this.body=e}return kt(t,e),t.prototype.children=["body"],t.prototype.unwrap=function(){return this.body},t.prototype.isComplex=function(){return this.body.isComplex()},t.prototype.compileNode=function(e){var t,n,i;return n=this.body.unwrap(),n instanceof z&&n.isAtomic()?(n.front=this.front,n.compileToFragments(e)):(i=n.compileToFragments(e,N),t=F>e.level&&(n instanceof I||n instanceof o||n instanceof f&&n.returns),t?i:this.wrapInBraces(i))},t}(r),e.For=f=function(e){function t(e,t){var n;this.source=t.source,this.guard=t.guard,this.step=t.step,this.name=t.name,this.index=t.index,this.body=s.wrap([e]),this.own=!!t.own,this.object=!!t.object,this.object&&(n=[this.index,this.name],this.name=n[0],this.index=n[1]),this.index instanceof z&&this.index.error("index cannot be a pattern matching expression"),this.range=this.source instanceof z&&this.source.base instanceof j&&!this.source.properties.length,this.pattern=this.name instanceof z,this.range&&this.index&&this.index.error("indexes do not apply to range loops"),this.range&&this.pattern&&this.name.error("cannot pattern match over range loops"),this.own&&!this.object&&this.name.error("cannot use own with for-in"),this.returns=!1}return kt(t,e),t.prototype.children=["body","source","guard","step"],t.prototype.compileNode=function(e){var t,n,r,o,a,c,h,l,u,p,d,f,m,v,y,k,w,T,C,F,N,S,D,A,I,_,$,j,B,V,P,U,G,H;return t=s.wrap([this.body]),D=t.expressions,T=D[D.length-1],(null!=T?T.jumps():void 0)instanceof M&&(this.returns=!1),B=this.range?this.source.base:this.source,j=e.scope,this.pattern||(F=this.name&&this.name.compile(e,E)),v=this.index&&this.index.compile(e,E),F&&!this.pattern&&j.find(F),v&&j.find(v),this.returns&&($=j.freeVariable("results")),y=this.object&&v||j.freeVariable("i",{single:!0}),k=this.range&&F||v||y,w=k!==y?k+" = ":"",this.step&&!this.range&&(A=this.cacheToCodeFragments(this.step.cache(e,E,ot)),V=A[0],U=A[1],P=U.match(R)),this.pattern&&(F=y),H="",d="",h="",f=this.tab+q,this.range?p=B.compileToFragments(lt(e,{index:y,name:F,step:this.step,isComplex:ot})):(G=this.source.compile(e,E),!F&&!this.own||g.test(G)||(h+=""+this.tab+(S=j.freeVariable("ref"))+" = "+G+";\n",G=S),F&&!this.pattern&&(N=F+" = "+G+"["+k+"]"),this.object||(V!==U&&(h+=""+this.tab+V+";\n"),this.step&&P&&(u=0>pt(P[0]))||(C=j.freeVariable("len")),a=""+w+y+" = 0, "+C+" = "+G+".length",c=""+w+y+" = "+G+".length - 1",r=y+" < "+C,o=y+" >= 0",this.step?(P?u&&(r=o,a=c):(r=U+" > 0 ? "+r+" : "+o,a="("+U+" > 0 ? ("+a+") : "+c+")"),m=y+" += "+U):m=""+(k!==y?"++"+y:y+"++"),p=[this.makeCode(a+"; "+r+"; "+w+m)])),this.returns&&(I=""+this.tab+$+" = [];\n",_="\n"+this.tab+"return "+$+";",t.makeReturn($)),this.guard&&(t.expressions.length>1?t.expressions.unshift(new b(new O(this.guard).invert(),new x("continue"))):this.guard&&(t=s.wrap([new b(this.guard,t)]))),this.pattern&&t.expressions.unshift(new i(this.name,new x(G+"["+k+"]"))),l=[].concat(this.makeCode(h),this.pluckDirectCall(e,t)),N&&(H="\n"+f+N+";"),this.object&&(p=[this.makeCode(k+" in "+G)],this.own&&(d="\n"+f+"if (!"+bt("hasProp",e)+".call("+G+", "+k+")) continue;")),n=t.compileToFragments(lt(e,{indent:f}),L),n&&n.length>0&&(n=[].concat(this.makeCode("\n"),n,this.makeCode("\n"))),[].concat(l,this.makeCode(""+(I||"")+this.tab+"for ("),p,this.makeCode(") {"+d+H),n,this.makeCode(this.tab+"}"+(_||"")))},t.prototype.pluckDirectCall=function(e,t){var n,r,s,a,h,l,u,p,d,f,m,g,v,y,b,k;for(r=[],d=t.expressions,h=l=0,u=d.length;u>l;h=++l)s=d[h],s=s.unwrapAll(),s instanceof o&&(k=null!=(f=s.variable)?f.unwrapAll():void 0,(k instanceof c||k instanceof z&&(null!=(m=k.base)?m.unwrapAll():void 0)instanceof c&&1===k.properties.length&&("call"===(g=null!=(v=k.properties[0].name)?v.value:void 0)||"apply"===g))&&(a=(null!=(y=k.base)?y.unwrapAll():void 0)||k,p=new x(e.scope.freeVariable("fn")),n=new z(p),k.base&&(b=[n,k],k.base=b[0],n=b[1]),t.expressions[h]=new o(n,s.args),r=r.concat(this.makeCode(this.tab),new i(p,a).compileToFragments(e,L),this.makeCode(";\n"))));return r},t}(J),e.Switch=H=function(e){function t(e,t,n){this.subject=e,this.cases=t,this.otherwise=n}return kt(t,e),t.prototype.children=["subject","cases","otherwise"],t.prototype.isStatement=Q,t.prototype.jumps=function(e){var t,n,i,r,s,o,a,c;for(null==e&&(e={block:!0}),o=this.cases,i=0,s=o.length;s>i;i++)if(a=o[i],n=a[0],t=a[1],r=t.jumps(e))return r;return null!=(c=this.otherwise)?c.jumps(e):void 0},t.prototype.makeReturn=function(e){var t,n,i,r,o;for(r=this.cases,t=0,n=r.length;n>t;t++)i=r[t],i[1].makeReturn(e);return e&&(this.otherwise||(this.otherwise=new s([new x("void 0")]))),null!=(o=this.otherwise)&&o.makeReturn(e),this},t.prototype.compileNode=function(e){var t,n,i,r,s,o,a,c,h,l,u,p,d,f,m,g;for(c=e.indent+q,h=e.indent=c+q,o=[].concat(this.makeCode(this.tab+"switch ("),this.subject?this.subject.compileToFragments(e,N):this.makeCode("false"),this.makeCode(") {\n")),f=this.cases,a=l=0,p=f.length;p>l;a=++l){for(m=f[a],r=m[0],t=m[1],g=rt([r]),u=0,d=g.length;d>u;u++)i=g[u],this.subject||(i=i.invert()),o=o.concat(this.makeCode(c+"case "),i.compileToFragments(e,N),this.makeCode(":\n"));if((n=t.compileToFragments(e,L)).length>0&&(o=o.concat(n,this.makeCode("\n"))),a===this.cases.length-1&&!this.otherwise)break;s=this.lastNonComment(t.expressions),s instanceof M||s instanceof x&&s.jumps()&&"debugger"!==s.value||o.push(i.makeCode(h+"break;\n"))}return this.otherwise&&this.otherwise.expressions.length&&o.push.apply(o,[this.makeCode(c+"default:\n")].concat(Ct.call(this.otherwise.compileToFragments(e,L)),[this.makeCode("\n")])),o.push(this.makeCode(this.tab+"}")),o},t}(r),e.If=b=function(e){function t(e,t,n){this.body=t,null==n&&(n={}),this.condition="unless"===n.type?e.invert():e,this.elseBody=null,this.isChain=!1,this.soak=n.soak}return kt(t,e),t.prototype.children=["condition","body","elseBody"],t.prototype.bodyNode=function(){var e;return null!=(e=this.body)?e.unwrap():void 0},t.prototype.elseBodyNode=function(){var e;return null!=(e=this.elseBody)?e.unwrap():void 0},t.prototype.addElse=function(e){return this.isChain?this.elseBodyNode().addElse(e):(this.isChain=e instanceof t,this.elseBody=this.ensureBlock(e),this.elseBody.updateLocationDataIfMissing(e.locationData)),this},t.prototype.isStatement=function(e){var t;return(null!=e?e.level:void 0)===L||this.bodyNode().isStatement(e)||(null!=(t=this.elseBodyNode())?t.isStatement(e):void 0)},t.prototype.jumps=function(e){var t;return this.body.jumps(e)||(null!=(t=this.elseBody)?t.jumps(e):void 0)},t.prototype.compileNode=function(e){return this.isStatement(e)?this.compileStatement(e):this.compileExpression(e)},t.prototype.makeReturn=function(e){return e&&(this.elseBody||(this.elseBody=new s([new x("void 0")]))),this.body&&(this.body=new s([this.body.makeReturn(e)])),this.elseBody&&(this.elseBody=new s([this.elseBody.makeReturn(e)])),this},t.prototype.ensureBlock=function(e){return e instanceof s?e:new s([e])},t.prototype.compileStatement=function(e){var n,i,r,s,o,a,c;return r=tt(e,"chainChild"),(o=tt(e,"isExistentialEquals"))?new t(this.condition.invert(),this.elseBodyNode(),{type:"if"}).compileToFragments(e):(c=e.indent+q,s=this.condition.compileToFragments(e,N),i=this.ensureBlock(this.body).compileToFragments(lt(e,{indent:c})),a=[].concat(this.makeCode("if ("),s,this.makeCode(") {\n"),i,this.makeCode("\n"+this.tab+"}")),r||a.unshift(this.makeCode(this.tab)),this.elseBody?(n=a.concat(this.makeCode(" else ")),this.isChain?(e.chainChild=!0,n=n.concat(this.elseBody.unwrap().compileToFragments(e,L))):n=n.concat(this.makeCode("{\n"),this.elseBody.compileToFragments(lt(e,{indent:c}),L),this.makeCode("\n"+this.tab+"}")),n):a)},t.prototype.compileExpression=function(e){var t,n,i,r;return i=this.condition.compileToFragments(e,C),n=this.bodyNode().compileToFragments(e,E),t=this.elseBodyNode()?this.elseBodyNode().compileToFragments(e,E):[this.makeCode("void 0")],r=i.concat(this.makeCode(" ? "),n,this.makeCode(" : "),t),e.level>=C?this.wrapInBraces(r):r},t.prototype.unfoldSoak=function(){return this.soak&&this},t}(r),K={extend:function(e){return"function(child, parent) { for (var key in parent) { if ("+bt("hasProp",e)+".call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }"},bind:function(){return"function(fn, me){ return function(){ return fn.apply(me, arguments); }; }"},indexOf:function(){return"[].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }"},modulo:function(){return"function(a, b) { return (+a % (b = +b) + b) % b; }"},hasProp:function(){return"{}.hasOwnProperty"},slice:function(){return"[].slice"}},L=1,N=2,E=3,C=4,F=5,T=6,q=" ",g=/^(?!\d)[$\w\x7f-\uffff]+$/,B=/^[+-]?\d+$/,m=/^[+-]?0x[\da-f]+/i,R=/^[+-]?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)$/i,y=/^['"]/,v=/^\//,bt=function(e,t){var n,i;return i=t.scope.root,e in i.utilities?i.utilities[e]:(n=i.freeVariable(e),i.assign(n,K[e](t)),i.utilities[e]=n)},ut=function(e,t){return e=e.replace(/\n/g,"$&"+t),e.replace(/\s+$/,"")},pt=function(e){return null==e?0:e.match(m)?parseInt(e,16):parseFloat(e)},at=function(e){return e instanceof x&&"arguments"===e.value&&!e.asKey},ct=function(e){return e instanceof x&&"this"===e.value&&!e.asKey||e instanceof c&&e.bound||e instanceof o&&e.isSuper},ot=function(e){return e.isComplex()||("function"==typeof e.isAssignable?e.isAssignable():void 0)},yt=function(e,t,n){var i;if(i=t[n].unfoldSoak(e))return t[n]=i.body,i.body=new z(t),i}}.call(this),t.exports}(),_dereq_["./sourcemap"]=function(){var e={},t={exports:e};return function(){var e,n;e=function(){function e(e){this.line=e,this.columns=[]}return e.prototype.add=function(e,t,n){var i,r;return r=t[0],i=t[1],null==n&&(n={}),this.columns[e]&&n.noReplace?void 0:this.columns[e]={line:this.line,column:e,sourceLine:r,sourceColumn:i}},e.prototype.sourceLocation=function(e){for(var t;!((t=this.columns[e])||0>=e);)e--;return t&&[t.sourceLine,t.sourceColumn]},e}(),n=function(){function t(){this.lines=[]}var n,i,r,s;return t.prototype.add=function(t,n,i){var r,s,o,a;return null==i&&(i={}),o=n[0],s=n[1],a=(r=this.lines)[o]||(r[o]=new e(o)),a.add(s,t,i)},t.prototype.sourceLocation=function(e){var t,n,i;for(n=e[0],t=e[1];!((i=this.lines[n])||0>=n);)n--;return i&&i.sourceLocation(t)},t.prototype.generate=function(e,t){var n,i,r,s,o,a,c,h,l,u,p,d,f,m,g,v;for(null==e&&(e={}),null==t&&(t=null),v=0,s=0,a=0,o=0,d=!1,n="",f=this.lines,u=i=0,c=f.length;c>i;u=++i)if(l=f[u])for(m=l.columns,r=0,h=m.length;h>r;r++)if(p=m[r]){for(;p.line>v;)s=0,d=!1,n+=";",v++;d&&(n+=",",d=!1),n+=this.encodeVlq(p.column-s),s=p.column,n+=this.encodeVlq(0),n+=this.encodeVlq(p.sourceLine-a),a=p.sourceLine,n+=this.encodeVlq(p.sourceColumn-o),o=p.sourceColumn,d=!0}return g={version:3,file:e.generatedFile||"",sourceRoot:e.sourceRoot||"",sources:e.sourceFiles||[""],names:[],mappings:n},e.inline&&(g.sourcesContent=[t]),JSON.stringify(g,null,2)},r=5,i=1<e?1:0,a=(Math.abs(e)<<1)+o;a||!t;)n=a&s,a>>=r,a&&(n|=i),t+=this.encodeBase64(n);return t},n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t.prototype.encodeBase64=function(e){return n[e]||function(){throw Error("Cannot Base64 encode value: "+e)}()},t}(),t.exports=n}.call(this),t.exports}(),_dereq_["./coffee-script"]=function(){var e={},t={exports:e};return function(){var t,n,i,r,s,o,a,c,h,l,u,p,d,f,m,g,v,y,b={}.hasOwnProperty,k=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};if(a=_dereq_("fs"),v=_dereq_("vm"),f=_dereq_("path"),t=_dereq_("./lexer").Lexer,d=_dereq_("./parser").parser,h=_dereq_("./helpers"),n=_dereq_("./sourcemap"),e.VERSION="1.9.3",e.FILE_EXTENSIONS=[".coffee",".litcoffee",".coffee.md"],e.helpers=h,y=function(e){return function(t,n){var i;null==n&&(n={});try{return e.call(this,t,n) +}catch(r){if(i=r,"string"!=typeof t)throw i;throw h.updateSyntaxError(i,t,n.filename)}}},e.compile=r=y(function(e,t){var i,r,s,o,a,c,l,u,f,m,g,v,y,b,k;for(v=h.merge,o=h.extend,t=o({},t),t.sourceMap&&(g=new n),k=p.tokenize(e,t),t.referencedVars=function(){var e,t,n;for(n=[],e=0,t=k.length;t>e;e++)b=k[e],b.variable&&n.push(b[1]);return n}(),c=d.parse(k).compileToFragments(t),s=0,t.header&&(s+=1),t.shiftLine&&(s+=1),r=0,f="",u=0,m=c.length;m>u;u++)a=c[u],t.sourceMap&&(a.locationData&&!/^[;\s]*$/.test(a.code)&&g.add([a.locationData.first_line,a.locationData.first_column],[s,r],{noReplace:!0}),y=h.count(a.code,"\n"),s+=y,y?r=a.code.length-(a.code.lastIndexOf("\n")+1):r+=a.code.length),f+=a.code;return t.header&&(l="Generated by CoffeeScript "+this.VERSION,f="// "+l+"\n"+f),t.sourceMap?(i={js:f},i.sourceMap=g,i.v3SourceMap=g.generate(t,e),i):f}),e.tokens=y(function(e,t){return p.tokenize(e,t)}),e.nodes=y(function(e,t){return"string"==typeof e?d.parse(p.tokenize(e,t)):d.parse(e)}),e.run=function(e,t){var n,i,s,o;return null==t&&(t={}),s=_dereq_.main,s.filename=process.argv[1]=t.filename?a.realpathSync(t.filename):".",s.moduleCache&&(s.moduleCache={}),i=t.filename?f.dirname(a.realpathSync(t.filename)):a.realpathSync("."),s.paths=_dereq_("module")._nodeModulePaths(i),(!h.isCoffee(s.filename)||_dereq_.extensions)&&(n=r(e,t),e=null!=(o=n.js)?o:n),s._compile(e,s.filename)},e.eval=function(e,t){var n,i,s,o,a,c,h,l,u,p,d,m,g,y,k,w,T;if(null==t&&(t={}),e=e.trim()){if(o=null!=(m=v.Script.createContext)?m:v.createContext,c=null!=(g=v.isContext)?g:function(){return t.sandbox instanceof o().constructor},o){if(null!=t.sandbox){if(c(t.sandbox))w=t.sandbox;else{w=o(),y=t.sandbox;for(l in y)b.call(y,l)&&(T=y[l],w[l]=T)}w.global=w.root=w.GLOBAL=w}else w=global;if(w.__filename=t.filename||"eval",w.__dirname=f.dirname(w.__filename),w===global&&!w.module&&!w.require){for(n=_dereq_("module"),w.module=i=new n(t.modulename||"eval"),w.require=s=function(e){return n._load(e,i,!0)},i.filename=w.__filename,k=Object.getOwnPropertyNames(_dereq_),a=0,u=k.length;u>a;a++)d=k[a],"paths"!==d&&(s[d]=_dereq_[d]);s.paths=i.paths=n._nodeModulePaths(process.cwd()),s.resolve=function(e){return n._resolveFilename(e,i)}}}p={};for(l in t)b.call(t,l)&&(T=t[l],p[l]=T);return p.bare=!0,h=r(e,p),w===global?v.runInThisContext(h):v.runInContext(h,w)}},e.register=function(){return _dereq_("./register")},_dereq_.extensions)for(m=this.FILE_EXTENSIONS,l=0,u=m.length;u>l;l++)s=m[l],null==(i=_dereq_.extensions)[s]&&(i[s]=function(){throw Error("Use CoffeeScript.register() or require the coffee-script/register module to require "+s+" files.")});e._compileFile=function(e,t){var n,i,s,o;null==t&&(t=!1),s=a.readFileSync(e,"utf8"),o=65279===s.charCodeAt(0)?s.substring(1):s;try{n=r(o,{filename:e,sourceMap:t,literate:h.isLiterate(e)})}catch(c){throw i=c,h.updateSyntaxError(i,o,e)}return n},p=new t,d.lexer={lex:function(){var e,t;return t=d.tokens[this.pos++],t?(e=t[0],this.yytext=t[1],this.yylloc=t[2],d.errorToken=t.origin||t,this.yylineno=this.yylloc.first_line):e="",e},setInput:function(e){return d.tokens=e,this.pos=0},upcomingInput:function(){return""}},d.yy=_dereq_("./nodes"),d.yy.parseError=function(e,t){var n,i,r,s,o,a;return o=t.token,s=d.errorToken,a=d.tokens,i=s[0],r=s[1],n=s[2],r=function(){switch(!1){case s!==a[a.length-1]:return"end of input";case"INDENT"!==i&&"OUTDENT"!==i:return"indentation";case"IDENTIFIER"!==i&&"NUMBER"!==i&&"STRING"!==i&&"STRING_START"!==i&&"REGEX"!==i&&"REGEX_START"!==i:return i.replace(/_START$/,"").toLowerCase();default:return h.nameWhitespaceCharacter(r)}}(),h.throwSyntaxError("unexpected "+r,n)},o=function(e,t){var n,i,r,s,o,a,c,h,l,u,p,d;return s=void 0,r="",e.isNative()?r="native":(e.isEval()?(s=e.getScriptNameOrSourceURL(),s||(r=e.getEvalOrigin()+", ")):s=e.getFileName(),s||(s=""),h=e.getLineNumber(),i=e.getColumnNumber(),u=t(s,h,i),r=u?s+":"+u[0]+":"+u[1]:s+":"+h+":"+i),o=e.getFunctionName(),a=e.isConstructor(),c=!(e.isToplevel()||a),c?(l=e.getMethodName(),d=e.getTypeName(),o?(p=n="",d&&o.indexOf(d)&&(p=d+"."),l&&o.indexOf("."+l)!==o.length-l.length-1&&(n=" [as "+l+"]"),""+p+o+n+" ("+r+")"):d+"."+(l||"")+" ("+r+")"):a?"new "+(o||"")+" ("+r+")":o?o+" ("+r+")":r},g={},c=function(t){var n,i;if(g[t])return g[t];if(i=null!=f?f.extname(t):void 0,!(0>k.call(e.FILE_EXTENSIONS,i)))return n=e._compileFile(t,!0),g[t]=n.sourceMap},Error.prepareStackTrace=function(t,n){var i,r,s;return s=function(e,t,n){var i,r;return r=c(e),r&&(i=r.sourceLocation([t-1,n-1])),i?[i[0]+1,i[1]+1]:null},r=function(){var t,r,a;for(a=[],t=0,r=n.length;r>t&&(i=n[t],i.getFunction()!==e.run);t++)a.push(" at "+o(i,s));return a}(),""+t+"\n"+r.join("\n")+"\n"}}.call(this),t.exports}(),_dereq_["./browser"]=function(){var exports={},module={exports:exports};return function(){var CoffeeScript,compile,runScripts,indexOf=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};CoffeeScript=_dereq_("./coffee-script"),CoffeeScript.require=_dereq_,compile=CoffeeScript.compile,CoffeeScript.eval=function(code,options){return null==options&&(options={}),null==options.bare&&(options.bare=!0),eval(compile(code,options))},CoffeeScript.run=function(e,t){return null==t&&(t={}),t.bare=!0,t.shiftLine=!0,Function(compile(e,t))()},"undefined"!=typeof window&&null!==window&&("undefined"!=typeof btoa&&null!==btoa&&"undefined"!=typeof JSON&&null!==JSON&&"undefined"!=typeof unescape&&null!==unescape&&"undefined"!=typeof encodeURIComponent&&null!==encodeURIComponent&&(compile=function(e,t){var n,i,r;return null==t&&(t={}),t.sourceMap=!0,t.inline=!0,i=CoffeeScript.compile(e,t),n=i.js,r=i.v3SourceMap,n+"\n//# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(r)))+"\n//# sourceURL=coffeescript"}),CoffeeScript.load=function(e,t,n,i){var r;return null==n&&(n={}),null==i&&(i=!1),n.sourceFiles=[e],r=window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):new window.XMLHttpRequest,r.open("GET",e,!0),"overrideMimeType"in r&&r.overrideMimeType("text/plain"),r.onreadystatechange=function(){var s,o;if(4===r.readyState){if(0!==(o=r.status)&&200!==o)throw Error("Could not load "+e);if(s=[r.responseText,n],i||CoffeeScript.run.apply(CoffeeScript,s),t)return t(s)}},r.send(null)},runScripts=function(){var e,t,n,i,r,s,o,a,c,h,l;for(l=window.document.getElementsByTagName("script"),t=["text/coffeescript","text/literate-coffeescript"],e=function(){var e,n,i,r;for(r=[],e=0,n=l.length;n>e;e++)c=l[e],i=c.type,indexOf.call(t,i)>=0&&r.push(c);return r}(),s=0,n=function(){var t;return t=e[s],t instanceof Array?(CoffeeScript.run.apply(CoffeeScript,t),s++,n()):void 0},i=function(i,r){var s,o;return s={literate:i.type===t[1]},o=i.src||i.getAttribute("data-src"),o?CoffeeScript.load(o,function(t){return e[r]=t,n()},s,!0):(s.sourceFiles=["embedded"],e[r]=[i.innerHTML,s])},r=o=0,a=e.length;a>o;r=++o)h=e[r],i(h,r);return n()},window.addEventListener?window.addEventListener("DOMContentLoaded",runScripts,!1):window.attachEvent("onload",runScripts))}.call(this),module.exports}(),_dereq_["./coffee-script"]}();"function"==typeof define&&define.amd?define(function(){return CoffeeScript}):root.CoffeeScript=CoffeeScript})(this); +}); \ No newline at end of file diff --git a/public/lib/ace/mode/coffee/parser_test.js b/public/lib/ace/mode/coffee/parser_test.js new file mode 100644 index 0000000..ccaae5b --- /dev/null +++ b/public/lib/ace/mode/coffee/parser_test.js @@ -0,0 +1,89 @@ +/* ***** 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 ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { +"use strict"; + +var assert = require("../../test/assertions"); +var coffee = require("./coffee"); + +function assertLocation(e, sl, sc, el, ec) { + var l = e.location; + assert.equal( + l.first_line + ":" + l.first_column + "->" + l.last_line + ":" + l.last_column, + sl + ":" + sc + "->" + el + ":" + ec + ); +} + +function parse(str) { + try { + coffee.compile(str); + } catch (e) { + return e; + } +} + +module.exports = { + "test parse valid coffee script": function() { + coffee.compile("square = (x) -> x * x"); + }, + + "test parse invalid coffee script": function() { + var e = parse("a = 12 f"); + assert.equal(e.message, "unexpected identifier"); + assertLocation(e, 0, 7, 0, 7); + }, + + "test parse missing bracket": function() { + var e = parse("a = 12 f {\n\n"); + assert.equal(e.message, "missing }"); + assertLocation(e, 0, 9, 0, 9); + }, + "test unexpected indent": function() { + var e = parse("a\n a\n"); + assert.equal(e.message, "unexpected indentation"); + assertLocation(e, 1, 0, 1, 1); + }, + "test invalid destructuring": function() { + var e = parse("\n{b: 5} = {}"); + assert.equal(e.message, '"5" cannot be assigned'); + assertLocation(e, 1, 4, 1, 4); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/mode/coffee_highlight_rules.js b/public/lib/ace/mode/coffee_highlight_rules.js new file mode 100644 index 0000000..08630b0 --- /dev/null +++ b/public/lib/ace/mode/coffee_highlight_rules.js @@ -0,0 +1,232 @@ +/* ***** 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 oop = require("../lib/oop"); + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + oop.inherits(CoffeeHighlightRules, TextHighlightRules); + + function CoffeeHighlightRules() { + var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*"; + + var keywords = ( + "this|throw|then|try|typeof|super|switch|return|break|by|continue|" + + "catch|class|in|instanceof|is|isnt|if|else|extends|for|own|" + + "finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" + + "or|on|unless|until|and|yes" + ); + + var langConstant = ( + "true|false|null|undefined|NaN|Infinity" + ); + + var illegal = ( + "case|const|default|function|var|void|with|enum|export|implements|" + + "interface|let|package|private|protected|public|static|yield" + ); + + var supportClass = ( + "Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|String|" + + "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + + "SyntaxError|TypeError|URIError|" + + "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" + + "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray" + ); + + var supportFunction = ( + "Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|" + + "encodeURIComponent|decodeURI|decodeURIComponent|String|" + ); + + var variableLanguage = ( + "window|arguments|prototype|document" + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "constant.language": langConstant, + "invalid.illegal": illegal, + "language.support.class": supportClass, + "language.support.function": supportFunction, + "variable.language": variableLanguage + }, "identifier"); + + var functionRule = { + token: ["paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"], + regex: /(?:(\()((?:"[^")]*?"|'[^')]*?'|\/[^\/)]*?\/|[^()"'\/])*?)(\))(\s*))?([\-=]>)/.source + }; + + var stringEscape = /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)/; + + this.$rules = { + start : [ + { + token : "constant.numeric", + regex : "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)" + }, { + stateName: "qdoc", + token : "string", regex : "'''", next : [ + {token : "string", regex : "'''", next : "start"}, + {token : "constant.language.escape", regex : stringEscape}, + {defaultToken: "string"} + ] + }, { + stateName: "qqdoc", + token : "string", + regex : '"""', + next : [ + {token : "string", regex : '"""', next : "start"}, + {token : "paren.string", regex : '#{', push : "start"}, + {token : "constant.language.escape", regex : stringEscape}, + {defaultToken: "string"} + ] + }, { + stateName: "qstring", + token : "string", regex : "'", next : [ + {token : "string", regex : "'", next : "start"}, + {token : "constant.language.escape", regex : stringEscape}, + {defaultToken: "string"} + ] + }, { + stateName: "qqstring", + token : "string.start", regex : '"', next : [ + {token : "string.end", regex : '"', next : "start"}, + {token : "paren.string", regex : '#{', push : "start"}, + {token : "constant.language.escape", regex : stringEscape}, + {defaultToken: "string"} + ] + }, { + stateName: "js", + token : "string", regex : "`", next : [ + {token : "string", regex : "`", next : "start"}, + {token : "constant.language.escape", regex : stringEscape}, + {defaultToken: "string"} + ] + }, { + regex: "[{}]", onMatch: function(val, state, stack) { + this.next = ""; + if (val == "{" && stack.length) { + stack.unshift("start", state); + return "paren"; + } + if (val == "}" && stack.length) { + stack.shift(); + this.next = stack.shift() || ""; + if (this.next.indexOf("string") != -1) + return "paren.string"; + } + return "paren"; + } + }, { + token : "string.regex", + regex : "///", + next : "heregex" + }, { + token : "string.regex", + regex : /(?:\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)(?:[imgy]{0,4})(?!\w)/ + }, { + token : "comment", + regex : "###(?!#)", + next : "comment" + }, { + token : "comment", + regex : "#.*" + }, { + token : ["punctuation.operator", "text", "identifier"], + regex : "(\\.)(\\s*)(" + illegal + ")" + }, { + token : "punctuation.operator", + regex : "\\.{1,3}" + }, { + //class A extends B + token : ["keyword", "text", "language.support.class", + "text", "keyword", "text", "language.support.class"], + regex : "(class)(\\s+)(" + identifier + ")(?:(\\s+)(extends)(\\s+)(" + identifier + "))?" + }, { + //play = (...) -> + token : ["entity.name.function", "text", "keyword.operator", "text"].concat(functionRule.token), + regex : "(" + identifier + ")(\\s*)([=:])(\\s*)" + functionRule.regex + }, + functionRule, + { + token : "variable", + regex : "@(?:" + identifier + ")?" + }, { + token: keywordMapper, + regex : identifier + }, { + token : "punctuation.operator", + regex : "\\,|\\." + }, { + token : "storage.type", + regex : "[\\-=]>" + }, { + token : "keyword.operator", + regex : "(?:[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|[!*+-=><])" + }, { + token : "paren.lparen", + regex : "[({[]" + }, { + token : "paren.rparen", + regex : "[\\]})]" + }, { + token : "text", + regex : "\\s+" + }], + + + heregex : [{ + token : "string.regex", + regex : '.*?///[imgy]{0,4}', + next : "start" + }, { + token : "comment.regex", + regex : "\\s+(?:#.*)?" + }, { + token : "string.regex", + regex : "\\S+" + }], + + comment : [{ + token : "comment", + regex : '###', + next : "start" + }, { + defaultToken : "comment" + }] + }; + this.normalizeRules(); + } + + exports.CoffeeHighlightRules = CoffeeHighlightRules; +}); diff --git a/public/lib/ace/mode/coffee_worker.js b/public/lib/ace/mode/coffee_worker.js new file mode 100644 index 0000000..ff2f441 --- /dev/null +++ b/public/lib/ace/mode/coffee_worker.js @@ -0,0 +1,73 @@ +/* ***** 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 oop = require("../lib/oop"); +var Mirror = require("../worker/mirror").Mirror; +var coffee = require("../mode/coffee/coffee"); + +window.addEventListener = function() {}; + + +var Worker = exports.Worker = function(sender) { + Mirror.call(this, sender); + this.setTimeout(250); +}; + +oop.inherits(Worker, Mirror); + +(function() { + + this.onUpdate = function() { + var value = this.doc.getValue(); + var errors = []; + try { + coffee.compile(value); + } catch(e) { + var loc = e.location; + if (loc) { + errors.push({ + row: loc.first_line, + column: loc.first_column, + endRow: loc.last_line, + endColumn: loc.last_column, + text: e.message, + type: "error" + }); + } + } + this.sender.emit("annotate", errors); + }; + +}).call(Worker.prototype); + +}); diff --git a/public/lib/ace/mode/coldfusion.js b/public/lib/ace/mode/coldfusion.js new file mode 100644 index 0000000..0b4ea44 --- /dev/null +++ b/public/lib/ace/mode/coldfusion.js @@ -0,0 +1,61 @@ +/* ***** 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 oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var HtmlMode = require("./html").Mode; +var ColdfusionHighlightRules = require("./coldfusion_highlight_rules").ColdfusionHighlightRules; + +var voidElements = "cfabort|cfapplication|cfargument|cfassociate|cfbreak|cfcache|cfcollection|cfcookie|cfdbinfo|cfdirectory|cfdump|cfelse|cfelseif|cferror|cfexchangecalendar|cfexchangeconnection|cfexchangecontact|cfexchangefilter|cfexchangetask|cfexit|cffeed|cffile|cfflush|cfftp|cfheader|cfhtmlhead|cfhttpparam|cfimage|cfimport|cfinclude|cfindex|cfinsert|cfinvokeargument|cflocation|cflog|cfmailparam|cfNTauthenticate|cfobject|cfobjectcache|cfparam|cfpdfformparam|cfprint|cfprocparam|cfprocresult|cfproperty|cfqueryparam|cfregistry|cfreportparam|cfrethrow|cfreturn|cfschedule|cfsearch|cfset|cfsetting|cfthrow|cfzipparam)".split("|"); + +var Mode = function() { + HtmlMode.call(this); + + this.HighlightRules = ColdfusionHighlightRules; +}; +oop.inherits(Mode, HtmlMode); + +(function() { + + // mix with html void elements + this.voidElements = oop.mixin(lang.arrayToMap(voidElements), this.voidElements); + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + + this.$id = "ace/mode/coldfusion"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/coldfusion_highlight_rules.js b/public/lib/ace/mode/coldfusion_highlight_rules.js new file mode 100644 index 0000000..469de29 --- /dev/null +++ b/public/lib/ace/mode/coldfusion_highlight_rules.js @@ -0,0 +1,86 @@ +/* ***** 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 oop = require("../lib/oop"); +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; + +var ColdfusionHighlightRules = function() { + HtmlHighlightRules.call(this); + this.$rules.tag[2].token = function (start, tag) { + var group = tag.slice(0,2) == "cf" ? "keyword" : "meta.tag"; + return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml", + group + ".tag-name.xml"]; + }; + + var jsAndCss = Object.keys(this.$rules).filter(function(x) { + return /^(js|css)-/.test(x); + }); + this.embedRules({ + cfmlComment: [ + { regex: "", token: "comment.end", next: "pop"}, + { defaultToken: "comment"} + ] + }, "", [ + { regex: "", " ", "fg"].join("\n"), session.toString()); + }, + + "test: next line indent should be the same as the current line indent" : function() { + assert.equal(" ", this.mode.getNextLineIndent("start", " abc")); + assert.equal("", this.mode.getNextLineIndent("start", "abc")); + assert.equal("\t", this.mode.getNextLineIndent("start", "\tabc")); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/public/lib/ace/mode/csharp.js b/public/lib/ace/mode/csharp.js new file mode 100644 index 0000000..a3b2964 --- /dev/null +++ b/public/lib/ace/mode/csharp.js @@ -0,0 +1,61 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/csharp").FoldMode; + +var Mode = function() { + this.HighlightRules = CSharpHighlightRules; + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = "//"; + this.blockComment = {start: "/*", end: "*/"}; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.getTokenizer().getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + + this.createWorker = function(session) { + return null; + }; + + this.$id = "ace/mode/csharp"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/csharp_highlight_rules.js b/public/lib/ace/mode/csharp_highlight_rules.js new file mode 100644 index 0000000..aeea2f7 --- /dev/null +++ b/public/lib/ace/mode/csharp_highlight_rules.js @@ -0,0 +1,98 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CSharpHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": "abstract|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|partial|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic", + "constant.language": "null|true|false" + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // character + regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))?'/ + }, { + token : "string", start : '"', end : '"|$', next: [ + {token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/}, + {token: "invalid", regex: /\\./} + ] + }, { + token : "string", start : '@"', end : '"', next:[ + {token: "constant.language.escape", regex: '""'} + ] + }, { + token : "string", start : /\$"/, end : '"|$', next: [ + {token: "constant.language.escape", regex: /\\(:?$)|{{/}, + {token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/}, + {token: "invalid", regex: /\\./} + ] + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "keyword", + regex : "^\\s*#(if|else|elif|endif|define|undef|warning|error|line|region|endregion|pragma)" + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\." + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : "\\*\\/", + next : "start" + }, { + defaultToken : "comment" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); + this.normalizeRules(); +}; + +oop.inherits(CSharpHighlightRules, TextHighlightRules); + +exports.CSharpHighlightRules = CSharpHighlightRules; +}); diff --git a/public/lib/ace/mode/csound_document.js b/public/lib/ace/mode/csound_document.js new file mode 100644 index 0000000..a10d7d5 --- /dev/null +++ b/public/lib/ace/mode/csound_document.js @@ -0,0 +1,14 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CsoundDocumentHighlightRules = require("./csound_document_highlight_rules").CsoundDocumentHighlightRules; + +var Mode = function() { + this.HighlightRules = CsoundDocumentHighlightRules; +}; +oop.inherits(Mode, TextMode); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/csound_document_highlight_rules.js b/public/lib/ace/mode/csound_document_highlight_rules.js new file mode 100644 index 0000000..c8023df --- /dev/null +++ b/public/lib/ace/mode/csound_document_highlight_rules.js @@ -0,0 +1,66 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); + +var CsoundOrchestraHighlightRules = require("./csound_orchestra_highlight_rules").CsoundOrchestraHighlightRules; +var CsoundScoreHighlightRules = require("./csound_score_highlight_rules").CsoundScoreHighlightRules; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CsoundDocumentHighlightRules = function() { + + this.$rules = { + "start": [ + { + token : ["meta.tag.punctuation.tag-open.csound-document", "entity.name.tag.begin.csound-document", "meta.tag.punctuation.tag-close.csound-document"], + regex : /(<)(CsoundSynthesi[sz]er)(>)/, + next : "synthesizer" + }, + {defaultToken : "text.csound-document"} + ], + + "synthesizer": [ + { + token : ["meta.tag.punctuation.end-tag-open.csound-document", "entity.name.tag.begin.csound-document", "meta.tag.punctuation.tag-close.csound-document"], + regex : "()", + next : "start" + }, { + token : ["meta.tag.punctuation.tag-open.csound-document", "entity.name.tag.begin.csound-document", "meta.tag.punctuation.tag-close.csound-document"], + regex : "(<)(CsInstruments)(>)", + next : "csound-start" + }, { + token : ["meta.tag.punctuation.tag-open.csound-document", "entity.name.tag.begin.csound-document", "meta.tag.punctuation.tag-close.csound-document"], + regex : "(<)(CsScore)(>)", + next : "csound-score-start" + }, { + token : ["meta.tag.punctuation.tag-open.csound-document", "entity.name.tag.begin.csound-document", "meta.tag.punctuation.tag-close.csound-document"], + regex : "(<)([Hh][Tt][Mm][Ll])(>)", + next : "html-start" + } + ] + }; + + this.embedRules(CsoundOrchestraHighlightRules, "csound-", [{ + token : ["meta.tag.punctuation.end-tag-open.csound-document", "entity.name.tag.begin.csound-document", "meta.tag.punctuation.tag-close.csound-document"], + regex : "()", + next : "synthesizer" + }]); + this.embedRules(CsoundScoreHighlightRules, "csound-score-", [{ + token : ["meta.tag.punctuation.end-tag-open.csound-document", "entity.name.tag.begin.csound-document", "meta.tag.punctuation.tag-close.csound-document"], + regex : "()", + next : "synthesizer" + }]); + this.embedRules(HtmlHighlightRules, "html-", [{ + token : ["meta.tag.punctuation.end-tag-open.csound-document", "entity.name.tag.begin.csound-document", "meta.tag.punctuation.tag-close.csound-document"], + regex : "()", + next : "synthesizer" + }]); + + this.normalizeRules(); +}; + +oop.inherits(CsoundDocumentHighlightRules, TextHighlightRules); + +exports.CsoundDocumentHighlightRules = CsoundDocumentHighlightRules; +}); diff --git a/public/lib/ace/mode/csound_orchestra.js b/public/lib/ace/mode/csound_orchestra.js new file mode 100644 index 0000000..4f71291 --- /dev/null +++ b/public/lib/ace/mode/csound_orchestra.js @@ -0,0 +1,21 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CsoundOrchestraHighlightRules = require("./csound_orchestra_highlight_rules").CsoundOrchestraHighlightRules; + +var Mode = function() { + this.HighlightRules = CsoundOrchestraHighlightRules; +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = ";"; + this.blockComment = {start: "/*", end: "*/"}; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/csound_orchestra_highlight_rules.js b/public/lib/ace/mode/csound_orchestra_highlight_rules.js new file mode 100644 index 0000000..ac2f265 --- /dev/null +++ b/public/lib/ace/mode/csound_orchestra_highlight_rules.js @@ -0,0 +1,1920 @@ +define(function(require, exports, module) { +"use strict"; + +var lang = require("../lib/lang"); +var oop = require("../lib/oop"); + +var CsoundPreprocessorHighlightRules = require("./csound_preprocessor_highlight_rules").CsoundPreprocessorHighlightRules; +var CsoundScoreHighlightRules = require("./csound_score_highlight_rules").CsoundScoreHighlightRules; +var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules; +var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules; + +var CsoundOrchestraHighlightRules = function() { + + CsoundPreprocessorHighlightRules.call(this); + + // To update the opcodes and deprecatedOpcodes arrays, run + /* + curl --remote-name https://bitbucket.org/nwhetsell/pygments-main/raw/tip/pygments/lexers/_csound_builtins.py + python -c "import json; from _csound_builtins import OPCODES, DEPRECATED_OPCODES; print 'var opcodes = {};'.format(json.dumps(sorted(list(OPCODES)), indent=4)); print 'var deprecatedOpcodes = {};'.format(json.dumps(sorted(list(DEPRECATED_OPCODES)), indent=4))" + */ + // and then paste the output. + var opcodes = [ + "ATSadd", + "ATSaddnz", + "ATSbufread", + "ATScross", + "ATSinfo", + "ATSinterpread", + "ATSpartialtap", + "ATSread", + "ATSreadnz", + "ATSsinnoi", + "FLbox", + "FLbutBank", + "FLbutton", + "FLcloseButton", + "FLcolor", + "FLcolor2", + "FLcount", + "FLexecButton", + "FLgetsnap", + "FLgroup", + "FLgroupEnd", + "FLgroup_end", + "FLhide", + "FLhvsBox", + "FLhvsBoxSetValue", + "FLjoy", + "FLkeyIn", + "FLknob", + "FLlabel", + "FLloadsnap", + "FLmouse", + "FLpack", + "FLpackEnd", + "FLpack_end", + "FLpanel", + "FLpanelEnd", + "FLpanel_end", + "FLprintk", + "FLprintk2", + "FLroller", + "FLrun", + "FLsavesnap", + "FLscroll", + "FLscrollEnd", + "FLscroll_end", + "FLsetAlign", + "FLsetBox", + "FLsetColor", + "FLsetColor2", + "FLsetFont", + "FLsetPosition", + "FLsetSize", + "FLsetSnapGroup", + "FLsetText", + "FLsetTextColor", + "FLsetTextSize", + "FLsetTextType", + "FLsetVal", + "FLsetVal_i", + "FLsetVali", + "FLsetsnap", + "FLshow", + "FLslidBnk", + "FLslidBnk2", + "FLslidBnk2Set", + "FLslidBnk2Setk", + "FLslidBnkGetHandle", + "FLslidBnkSet", + "FLslidBnkSetk", + "FLslider", + "FLtabs", + "FLtabsEnd", + "FLtabs_end", + "FLtext", + "FLupdate", + "FLvalue", + "FLvkeybd", + "FLvslidBnk", + "FLvslidBnk2", + "FLxyin", + "JackoAudioIn", + "JackoAudioInConnect", + "JackoAudioOut", + "JackoAudioOutConnect", + "JackoFreewheel", + "JackoInfo", + "JackoInit", + "JackoMidiInConnect", + "JackoMidiOut", + "JackoMidiOutConnect", + "JackoNoteOut", + "JackoOn", + "JackoTransport", + "K35_hpf", + "K35_lpf", + "MixerClear", + "MixerGetLevel", + "MixerReceive", + "MixerSend", + "MixerSetLevel", + "MixerSetLevel_i", + "OSCinit", + "OSCinitM", + "OSClisten", + "OSCraw", + "OSCsend", + "OSCsendA", + "OSCsend_lo", + "S", + "STKBandedWG", + "STKBeeThree", + "STKBlowBotl", + "STKBlowHole", + "STKBowed", + "STKBrass", + "STKClarinet", + "STKDrummer", + "STKFMVoices", + "STKFlute", + "STKHevyMetl", + "STKMandolin", + "STKModalBar", + "STKMoog", + "STKPercFlut", + "STKPlucked", + "STKResonate", + "STKRhodey", + "STKSaxofony", + "STKShakers", + "STKSimple", + "STKSitar", + "STKStifKarp", + "STKTubeBell", + "STKVoicForm", + "STKWhistle", + "STKWurley", + "a", + "abs", + "active", + "adsr", + "adsyn", + "adsynt", + "adsynt2", + "aftouch", + "alpass", + "alwayson", + "ampdb", + "ampdbfs", + "ampmidi", + "ampmidid", + "areson", + "aresonk", + "atone", + "atonek", + "atonex", + "babo", + "balance", + "bamboo", + "barmodel", + "bbcutm", + "bbcuts", + "betarand", + "bexprnd", + "bformdec1", + "bformenc1", + "binit", + "biquad", + "biquada", + "birnd", + "bpf", + "bqrez", + "buchla", + "butbp", + "butbr", + "buthp", + "butlp", + "butterbp", + "butterbr", + "butterhp", + "butterlp", + "button", + "buzz", + "c2r", + "cabasa", + "cauchy", + "cauchyi", + "cbrt", + "ceil", + "cell", + "cent", + "centroid", + "ceps", + "cepsinv", + "chanctrl", + "changed", + "changed2", + "chani", + "chano", + "chebyshevpoly", + "checkbox", + "chn_S", + "chn_a", + "chn_k", + "chnclear", + "chnexport", + "chnget", + "chnmix", + "chnparams", + "chnset", + "chuap", + "clear", + "clfilt", + "clip", + "clockoff", + "clockon", + "cmp", + "cmplxprod", + "comb", + "combinv", + "compilecsd", + "compileorc", + "compilestr", + "compress", + "compress2", + "connect", + "control", + "convle", + "convolve", + "copya2ftab", + "copyf2array", + "cos", + "cosh", + "cosinv", + "cosseg", + "cossegb", + "cossegr", + "cps2pch", + "cpsmidi", + "cpsmidib", + "cpsmidinn", + "cpsoct", + "cpspch", + "cpstmid", + "cpstun", + "cpstuni", + "cpsxpch", + "cpumeter", + "cpuprc", + "cross2", + "crossfm", + "crossfmi", + "crossfmpm", + "crossfmpmi", + "crosspm", + "crosspmi", + "crunch", + "ctlchn", + "ctrl14", + "ctrl21", + "ctrl7", + "ctrlinit", + "cuserrnd", + "dam", + "date", + "dates", + "db", + "dbamp", + "dbfsamp", + "dcblock", + "dcblock2", + "dconv", + "dct", + "dctinv", + "delay", + "delay1", + "delayk", + "delayr", + "delayw", + "deltap", + "deltap3", + "deltapi", + "deltapn", + "deltapx", + "deltapxw", + "denorm", + "diff", + "diode_ladder", + "directory", + "diskgrain", + "diskin", + "diskin2", + "dispfft", + "display", + "distort", + "distort1", + "divz", + "doppler", + "dot", + "downsamp", + "dripwater", + "dssiactivate", + "dssiaudio", + "dssictls", + "dssiinit", + "dssilist", + "dumpk", + "dumpk2", + "dumpk3", + "dumpk4", + "duserrnd", + "dust", + "dust2", + "envlpx", + "envlpxr", + "ephasor", + "eqfil", + "evalstr", + "event", + "event_i", + "exciter", + "exitnow", + "exp", + "expcurve", + "expon", + "exprand", + "exprandi", + "expseg", + "expsega", + "expsegb", + "expsegba", + "expsegr", + "fareylen", + "fareyleni", + "faustaudio", + "faustcompile", + "faustctl", + "faustgen", + "fft", + "fftinv", + "ficlose", + "filebit", + "filelen", + "filenchnls", + "filepeak", + "filescal", + "filesr", + "filevalid", + "fillarray", + "filter2", + "fin", + "fini", + "fink", + "fiopen", + "flanger", + "flashtxt", + "flooper", + "flooper2", + "floor", + "fluidAllOut", + "fluidCCi", + "fluidCCk", + "fluidControl", + "fluidEngine", + "fluidLoad", + "fluidNote", + "fluidOut", + "fluidProgramSelect", + "fluidSetInterpMethod", + "fmanal", + "fmax", + "fmb3", + "fmbell", + "fmin", + "fmmetal", + "fmod", + "fmpercfl", + "fmrhode", + "fmvoice", + "fmwurlie", + "fof", + "fof2", + "fofilter", + "fog", + "fold", + "follow", + "follow2", + "foscil", + "foscili", + "fout", + "fouti", + "foutir", + "foutk", + "fprintks", + "fprints", + "frac", + "fractalnoise", + "framebuffer", + "freeverb", + "ftchnls", + "ftconv", + "ftcps", + "ftfree", + "ftgen", + "ftgenonce", + "ftgentmp", + "ftlen", + "ftload", + "ftloadk", + "ftlptim", + "ftmorf", + "ftom", + "ftresize", + "ftresizei", + "ftsamplebank", + "ftsave", + "ftsavek", + "ftsr", + "gain", + "gainslider", + "gauss", + "gaussi", + "gausstrig", + "gbuzz", + "genarray", + "genarray_i", + "gendy", + "gendyc", + "gendyx", + "getcfg", + "getcol", + "getftargs", + "getrow", + "getseed", + "gogobel", + "grain", + "grain2", + "grain3", + "granule", + "guiro", + "harmon", + "harmon2", + "harmon3", + "harmon4", + "hdf5read", + "hdf5write", + "hilbert", + "hilbert2", + "hrtfearly", + "hrtfmove", + "hrtfmove2", + "hrtfreverb", + "hrtfstat", + "hsboscil", + "hvs1", + "hvs2", + "hvs3", + "hypot", + "i", + "ihold", + "imagecreate", + "imagefree", + "imagegetpixel", + "imageload", + "imagesave", + "imagesetpixel", + "imagesize", + "in", + "in32", + "inch", + "inh", + "init", + "initc14", + "initc21", + "initc7", + "inleta", + "inletf", + "inletk", + "inletkid", + "inletv", + "ino", + "inq", + "inrg", + "ins", + "insglobal", + "insremot", + "int", + "integ", + "interp", + "invalue", + "inx", + "inz", + "jacktransport", + "jitter", + "jitter2", + "joystick", + "jspline", + "k", + "la_i_add_mc", + "la_i_add_mr", + "la_i_add_vc", + "la_i_add_vr", + "la_i_assign_mc", + "la_i_assign_mr", + "la_i_assign_t", + "la_i_assign_vc", + "la_i_assign_vr", + "la_i_conjugate_mc", + "la_i_conjugate_mr", + "la_i_conjugate_vc", + "la_i_conjugate_vr", + "la_i_distance_vc", + "la_i_distance_vr", + "la_i_divide_mc", + "la_i_divide_mr", + "la_i_divide_vc", + "la_i_divide_vr", + "la_i_dot_mc", + "la_i_dot_mc_vc", + "la_i_dot_mr", + "la_i_dot_mr_vr", + "la_i_dot_vc", + "la_i_dot_vr", + "la_i_get_mc", + "la_i_get_mr", + "la_i_get_vc", + "la_i_get_vr", + "la_i_invert_mc", + "la_i_invert_mr", + "la_i_lower_solve_mc", + "la_i_lower_solve_mr", + "la_i_lu_det_mc", + "la_i_lu_det_mr", + "la_i_lu_factor_mc", + "la_i_lu_factor_mr", + "la_i_lu_solve_mc", + "la_i_lu_solve_mr", + "la_i_mc_create", + "la_i_mc_set", + "la_i_mr_create", + "la_i_mr_set", + "la_i_multiply_mc", + "la_i_multiply_mr", + "la_i_multiply_vc", + "la_i_multiply_vr", + "la_i_norm1_mc", + "la_i_norm1_mr", + "la_i_norm1_vc", + "la_i_norm1_vr", + "la_i_norm_euclid_mc", + "la_i_norm_euclid_mr", + "la_i_norm_euclid_vc", + "la_i_norm_euclid_vr", + "la_i_norm_inf_mc", + "la_i_norm_inf_mr", + "la_i_norm_inf_vc", + "la_i_norm_inf_vr", + "la_i_norm_max_mc", + "la_i_norm_max_mr", + "la_i_print_mc", + "la_i_print_mr", + "la_i_print_vc", + "la_i_print_vr", + "la_i_qr_eigen_mc", + "la_i_qr_eigen_mr", + "la_i_qr_factor_mc", + "la_i_qr_factor_mr", + "la_i_qr_sym_eigen_mc", + "la_i_qr_sym_eigen_mr", + "la_i_random_mc", + "la_i_random_mr", + "la_i_random_vc", + "la_i_random_vr", + "la_i_size_mc", + "la_i_size_mr", + "la_i_size_vc", + "la_i_size_vr", + "la_i_subtract_mc", + "la_i_subtract_mr", + "la_i_subtract_vc", + "la_i_subtract_vr", + "la_i_t_assign", + "la_i_trace_mc", + "la_i_trace_mr", + "la_i_transpose_mc", + "la_i_transpose_mr", + "la_i_upper_solve_mc", + "la_i_upper_solve_mr", + "la_i_vc_create", + "la_i_vc_set", + "la_i_vr_create", + "la_i_vr_set", + "la_k_a_assign", + "la_k_add_mc", + "la_k_add_mr", + "la_k_add_vc", + "la_k_add_vr", + "la_k_assign_a", + "la_k_assign_f", + "la_k_assign_mc", + "la_k_assign_mr", + "la_k_assign_t", + "la_k_assign_vc", + "la_k_assign_vr", + "la_k_conjugate_mc", + "la_k_conjugate_mr", + "la_k_conjugate_vc", + "la_k_conjugate_vr", + "la_k_current_f", + "la_k_current_vr", + "la_k_distance_vc", + "la_k_distance_vr", + "la_k_divide_mc", + "la_k_divide_mr", + "la_k_divide_vc", + "la_k_divide_vr", + "la_k_dot_mc", + "la_k_dot_mc_vc", + "la_k_dot_mr", + "la_k_dot_mr_vr", + "la_k_dot_vc", + "la_k_dot_vr", + "la_k_f_assign", + "la_k_get_mc", + "la_k_get_mr", + "la_k_get_vc", + "la_k_get_vr", + "la_k_invert_mc", + "la_k_invert_mr", + "la_k_lower_solve_mc", + "la_k_lower_solve_mr", + "la_k_lu_det_mc", + "la_k_lu_det_mr", + "la_k_lu_factor_mc", + "la_k_lu_factor_mr", + "la_k_lu_solve_mc", + "la_k_lu_solve_mr", + "la_k_mc_set", + "la_k_mr_set", + "la_k_multiply_mc", + "la_k_multiply_mr", + "la_k_multiply_vc", + "la_k_multiply_vr", + "la_k_norm1_mc", + "la_k_norm1_mr", + "la_k_norm1_vc", + "la_k_norm1_vr", + "la_k_norm_euclid_mc", + "la_k_norm_euclid_mr", + "la_k_norm_euclid_vc", + "la_k_norm_euclid_vr", + "la_k_norm_inf_mc", + "la_k_norm_inf_mr", + "la_k_norm_inf_vc", + "la_k_norm_inf_vr", + "la_k_norm_max_mc", + "la_k_norm_max_mr", + "la_k_qr_eigen_mc", + "la_k_qr_eigen_mr", + "la_k_qr_factor_mc", + "la_k_qr_factor_mr", + "la_k_qr_sym_eigen_mc", + "la_k_qr_sym_eigen_mr", + "la_k_random_mc", + "la_k_random_mr", + "la_k_random_vc", + "la_k_random_vr", + "la_k_subtract_mc", + "la_k_subtract_mr", + "la_k_subtract_vc", + "la_k_subtract_vr", + "la_k_t_assign", + "la_k_trace_mc", + "la_k_trace_mr", + "la_k_upper_solve_mc", + "la_k_upper_solve_mr", + "la_k_vc_set", + "la_k_vr_set", + "lenarray", + "lfo", + "limit", + "limit1", + "line", + "linen", + "linenr", + "lineto", + "link_beat_force", + "link_beat_get", + "link_beat_request", + "link_create", + "link_enable", + "link_is_enabled", + "link_metro", + "link_peers", + "link_tempo_get", + "link_tempo_set", + "linlin", + "linrand", + "linseg", + "linsegb", + "linsegr", + "liveconv", + "locsend", + "locsig", + "log", + "log10", + "log2", + "logbtwo", + "logcurve", + "loopseg", + "loopsegp", + "looptseg", + "loopxseg", + "lorenz", + "loscil", + "loscil3", + "loscilx", + "lowpass2", + "lowres", + "lowresx", + "lpf18", + "lpform", + "lpfreson", + "lphasor", + "lpinterp", + "lposcil", + "lposcil3", + "lposcila", + "lposcilsa", + "lposcilsa2", + "lpread", + "lpreson", + "lpshold", + "lpsholdp", + "lpslot", + "lua_exec", + "lua_iaopcall", + "lua_iaopcall_off", + "lua_ikopcall", + "lua_ikopcall_off", + "lua_iopcall", + "lua_iopcall_off", + "lua_opdef", + "mac", + "maca", + "madsr", + "mags", + "mandel", + "mandol", + "maparray", + "maparray_i", + "marimba", + "massign", + "max", + "max_k", + "maxabs", + "maxabsaccum", + "maxaccum", + "maxalloc", + "maxarray", + "mclock", + "mdelay", + "median", + "mediank", + "metro", + "mfb", + "midglobal", + "midiarp", + "midic14", + "midic21", + "midic7", + "midichannelaftertouch", + "midichn", + "midicontrolchange", + "midictrl", + "mididefault", + "midifilestatus", + "midiin", + "midinoteoff", + "midinoteoncps", + "midinoteonkey", + "midinoteonoct", + "midinoteonpch", + "midion", + "midion2", + "midiout", + "midipgm", + "midipitchbend", + "midipolyaftertouch", + "midiprogramchange", + "miditempo", + "midremot", + "min", + "minabs", + "minabsaccum", + "minaccum", + "minarray", + "mincer", + "mirror", + "mode", + "modmatrix", + "monitor", + "moog", + "moogladder", + "moogladder2", + "moogvcf", + "moogvcf2", + "moscil", + "mp3bitrate", + "mp3in", + "mp3len", + "mp3nchnls", + "mp3scal", + "mp3scal_check", + "mp3scal_load", + "mp3scal_load2", + "mp3scal_play", + "mp3scal_play2", + "mp3sr", + "mpulse", + "mrtmsg", + "mtof", + "mton", + "multitap", + "mute", + "mvchpf", + "mvclpf1", + "mvclpf2", + "mvclpf3", + "mvclpf4", + "mxadsr", + "nchnls_hw", + "nestedap", + "nlalp", + "nlfilt", + "nlfilt2", + "noise", + "noteoff", + "noteon", + "noteondur", + "noteondur2", + "notnum", + "nreverb", + "nrpn", + "nsamp", + "nstance", + "nstrnum", + "ntom", + "ntrpol", + "nxtpow2", + "octave", + "octcps", + "octmidi", + "octmidib", + "octmidinn", + "octpch", + "olabuffer", + "oscbnk", + "oscil", + "oscil1", + "oscil1i", + "oscil3", + "oscili", + "oscilikt", + "osciliktp", + "oscilikts", + "osciln", + "oscils", + "oscilx", + "out", + "out32", + "outc", + "outch", + "outh", + "outiat", + "outic", + "outic14", + "outipat", + "outipb", + "outipc", + "outkat", + "outkc", + "outkc14", + "outkpat", + "outkpb", + "outkpc", + "outleta", + "outletf", + "outletk", + "outletkid", + "outletv", + "outo", + "outq", + "outq1", + "outq2", + "outq3", + "outq4", + "outrg", + "outs", + "outs1", + "outs2", + "outvalue", + "outx", + "outz", + "p", + "p5gconnect", + "p5gdata", + "pan", + "pan2", + "pareq", + "part2txt", + "partials", + "partikkel", + "partikkelget", + "partikkelset", + "partikkelsync", + "passign", + "paulstretch", + "pcauchy", + "pchbend", + "pchmidi", + "pchmidib", + "pchmidinn", + "pchoct", + "pchtom", + "pconvolve", + "pcount", + "pdclip", + "pdhalf", + "pdhalfy", + "peak", + "pgmassign", + "pgmchn", + "phaser1", + "phaser2", + "phasor", + "phasorbnk", + "phs", + "pindex", + "pinker", + "pinkish", + "pitch", + "pitchac", + "pitchamdf", + "planet", + "platerev", + "plltrack", + "pluck", + "poisson", + "pol2rect", + "polyaft", + "polynomial", + "port", + "portk", + "poscil", + "poscil3", + "pow", + "powershape", + "powoftwo", + "pows", + "prealloc", + "prepiano", + "print", + "print_type", + "printf", + "printf_i", + "printk", + "printk2", + "printks", + "printks2", + "prints", + "product", + "pset", + "ptable", + "ptable3", + "ptablei", + "ptableiw", + "ptablew", + "ptrack", + "puts", + "pvadd", + "pvbufread", + "pvcross", + "pvinterp", + "pvoc", + "pvread", + "pvs2array", + "pvs2tab", + "pvsadsyn", + "pvsanal", + "pvsarp", + "pvsbandp", + "pvsbandr", + "pvsbin", + "pvsblur", + "pvsbuffer", + "pvsbufread", + "pvsbufread2", + "pvscale", + "pvscent", + "pvsceps", + "pvscross", + "pvsdemix", + "pvsdiskin", + "pvsdisp", + "pvsenvftw", + "pvsfilter", + "pvsfread", + "pvsfreeze", + "pvsfromarray", + "pvsftr", + "pvsftw", + "pvsfwrite", + "pvsgain", + "pvsgendy", + "pvshift", + "pvsifd", + "pvsin", + "pvsinfo", + "pvsinit", + "pvslock", + "pvsmaska", + "pvsmix", + "pvsmooth", + "pvsmorph", + "pvsosc", + "pvsout", + "pvspitch", + "pvstanal", + "pvstencil", + "pvstrace", + "pvsvoc", + "pvswarp", + "pvsynth", + "pwd", + "pyassign", + "pyassigni", + "pyassignt", + "pycall", + "pycall1", + "pycall1i", + "pycall1t", + "pycall2", + "pycall2i", + "pycall2t", + "pycall3", + "pycall3i", + "pycall3t", + "pycall4", + "pycall4i", + "pycall4t", + "pycall5", + "pycall5i", + "pycall5t", + "pycall6", + "pycall6i", + "pycall6t", + "pycall7", + "pycall7i", + "pycall7t", + "pycall8", + "pycall8i", + "pycall8t", + "pycalli", + "pycalln", + "pycallni", + "pycallt", + "pyeval", + "pyevali", + "pyevalt", + "pyexec", + "pyexeci", + "pyexect", + "pyinit", + "pylassign", + "pylassigni", + "pylassignt", + "pylcall", + "pylcall1", + "pylcall1i", + "pylcall1t", + "pylcall2", + "pylcall2i", + "pylcall2t", + "pylcall3", + "pylcall3i", + "pylcall3t", + "pylcall4", + "pylcall4i", + "pylcall4t", + "pylcall5", + "pylcall5i", + "pylcall5t", + "pylcall6", + "pylcall6i", + "pylcall6t", + "pylcall7", + "pylcall7i", + "pylcall7t", + "pylcall8", + "pylcall8i", + "pylcall8t", + "pylcalli", + "pylcalln", + "pylcallni", + "pylcallt", + "pyleval", + "pylevali", + "pylevalt", + "pylexec", + "pylexeci", + "pylexect", + "pylrun", + "pylruni", + "pylrunt", + "pyrun", + "pyruni", + "pyrunt", + "qinf", + "qnan", + "r2c", + "rand", + "randh", + "randi", + "random", + "randomh", + "randomi", + "rbjeq", + "readclock", + "readf", + "readfi", + "readk", + "readk2", + "readk3", + "readk4", + "readks", + "readscore", + "readscratch", + "rect2pol", + "release", + "remoteport", + "remove", + "repluck", + "reson", + "resonk", + "resonr", + "resonx", + "resonxk", + "resony", + "resonz", + "resyn", + "reverb", + "reverb2", + "reverbsc", + "rewindscore", + "rezzy", + "rfft", + "rifft", + "rms", + "rnd", + "rnd31", + "round", + "rspline", + "rtclock", + "s16b14", + "s32b14", + "samphold", + "sandpaper", + "sc_lag", + "sc_lagud", + "sc_phasor", + "sc_trig", + "scale", + "scalearray", + "scanhammer", + "scans", + "scantable", + "scanu", + "schedkwhen", + "schedkwhennamed", + "schedule", + "schedwhen", + "scoreline", + "scoreline_i", + "seed", + "sekere", + "select", + "semitone", + "sense", + "sensekey", + "seqtime", + "seqtime2", + "serialBegin", + "serialEnd", + "serialFlush", + "serialPrint", + "serialRead", + "serialWrite", + "serialWrite_i", + "setcol", + "setctrl", + "setksmps", + "setrow", + "setscorepos", + "sfilist", + "sfinstr", + "sfinstr3", + "sfinstr3m", + "sfinstrm", + "sfload", + "sflooper", + "sfpassign", + "sfplay", + "sfplay3", + "sfplay3m", + "sfplaym", + "sfplist", + "sfpreset", + "shaker", + "shiftin", + "shiftout", + "signalflowgraph", + "signum", + "sin", + "sinh", + "sininv", + "sinsyn", + "sleighbells", + "slicearray", + "slider16", + "slider16f", + "slider16table", + "slider16tablef", + "slider32", + "slider32f", + "slider32table", + "slider32tablef", + "slider64", + "slider64f", + "slider64table", + "slider64tablef", + "slider8", + "slider8f", + "slider8table", + "slider8tablef", + "sliderKawai", + "sndloop", + "sndwarp", + "sndwarpst", + "sockrecv", + "sockrecvs", + "socksend", + "socksend_k", + "socksends", + "sorta", + "sortd", + "soundin", + "space", + "spat3d", + "spat3di", + "spat3dt", + "spdist", + "splitrig", + "sprintf", + "sprintfk", + "spsend", + "sqrt", + "statevar", + "stix", + "strcat", + "strcatk", + "strchar", + "strchark", + "strcmp", + "strcmpk", + "strcpy", + "strcpyk", + "strecv", + "streson", + "strfromurl", + "strget", + "strindex", + "strindexk", + "strlen", + "strlenk", + "strlower", + "strlowerk", + "strrindex", + "strrindexk", + "strset", + "strsub", + "strsubk", + "strtod", + "strtodk", + "strtol", + "strtolk", + "strupper", + "strupperk", + "stsend", + "subinstr", + "subinstrinit", + "sum", + "sumarray", + "svfilter", + "syncgrain", + "syncloop", + "syncphasor", + "system", + "system_i", + "tab", + "tab2pvs", + "tab_i", + "tabifd", + "table", + "table3", + "table3kt", + "tablecopy", + "tablefilter", + "tablefilteri", + "tablegpw", + "tablei", + "tableicopy", + "tableigpw", + "tableikt", + "tableimix", + "tableiw", + "tablekt", + "tablemix", + "tableng", + "tablera", + "tableseg", + "tableshuffle", + "tableshufflei", + "tablew", + "tablewa", + "tablewkt", + "tablexkt", + "tablexseg", + "tabmorph", + "tabmorpha", + "tabmorphak", + "tabmorphi", + "tabplay", + "tabrec", + "tabsum", + "tabw", + "tabw_i", + "tambourine", + "tan", + "tanh", + "taninv", + "taninv2", + "tb0", + "tb0_init", + "tb1", + "tb10", + "tb10_init", + "tb11", + "tb11_init", + "tb12", + "tb12_init", + "tb13", + "tb13_init", + "tb14", + "tb14_init", + "tb15", + "tb15_init", + "tb1_init", + "tb2", + "tb2_init", + "tb3", + "tb3_init", + "tb4", + "tb4_init", + "tb5", + "tb5_init", + "tb6", + "tb6_init", + "tb7", + "tb7_init", + "tb8", + "tb8_init", + "tb9", + "tb9_init", + "tbvcf", + "tempest", + "tempo", + "temposcal", + "tempoval", + "timedseq", + "timeinstk", + "timeinsts", + "timek", + "times", + "tival", + "tlineto", + "tone", + "tonek", + "tonex", + "tradsyn", + "trandom", + "transeg", + "transegb", + "transegr", + "trcross", + "trfilter", + "trhighest", + "trigger", + "trigseq", + "trirand", + "trlowest", + "trmix", + "trscale", + "trshift", + "trsplit", + "turnoff", + "turnoff2", + "turnon", + "tvconv", + "unirand", + "unwrap", + "upsamp", + "urandom", + "urd", + "vactrol", + "vadd", + "vadd_i", + "vaddv", + "vaddv_i", + "vaget", + "valpass", + "vaset", + "vbap", + "vbapg", + "vbapgmove", + "vbaplsinit", + "vbapmove", + "vbapz", + "vbapzmove", + "vcella", + "vco", + "vco2", + "vco2ft", + "vco2ift", + "vco2init", + "vcomb", + "vcopy", + "vcopy_i", + "vdel_k", + "vdelay", + "vdelay3", + "vdelayk", + "vdelayx", + "vdelayxq", + "vdelayxs", + "vdelayxw", + "vdelayxwq", + "vdelayxws", + "vdivv", + "vdivv_i", + "vecdelay", + "veloc", + "vexp", + "vexp_i", + "vexpseg", + "vexpv", + "vexpv_i", + "vibes", + "vibr", + "vibrato", + "vincr", + "vlimit", + "vlinseg", + "vlowres", + "vmap", + "vmirror", + "vmult", + "vmult_i", + "vmultv", + "vmultv_i", + "voice", + "vosim", + "vphaseseg", + "vport", + "vpow", + "vpow_i", + "vpowv", + "vpowv_i", + "vpvoc", + "vrandh", + "vrandi", + "vsubv", + "vsubv_i", + "vtaba", + "vtabi", + "vtabk", + "vtable1k", + "vtablea", + "vtablei", + "vtablek", + "vtablewa", + "vtablewi", + "vtablewk", + "vtabwa", + "vtabwi", + "vtabwk", + "vwrap", + "waveset", + "websocket", + "weibull", + "wgbow", + "wgbowedbar", + "wgbrass", + "wgclar", + "wgflute", + "wgpluck", + "wgpluck2", + "wguide1", + "wguide2", + "wiiconnect", + "wiidata", + "wiirange", + "wiisend", + "window", + "wrap", + "writescratch", + "wterrain", + "xadsr", + "xin", + "xout", + "xscanmap", + "xscans", + "xscansmap", + "xscanu", + "xtratim", + "xyscale", + "zacl", + "zakinit", + "zamod", + "zar", + "zarg", + "zaw", + "zawm", + "zdf_1pole", + "zdf_1pole_mode", + "zdf_2pole", + "zdf_2pole_mode", + "zdf_ladder", + "zfilter2", + "zir", + "ziw", + "ziwm", + "zkcl", + "zkmod", + "zkr", + "zkw", + "zkwm" + ]; + var deprecatedOpcodes = [ + "array", + "bformdec", + "bformenc", + "copy2ftab", + "copy2ttab", + "hrtfer", + "ktableseg", + "lentab", + "maxtab", + "mintab", + "pop", + "pop_f", + "push", + "push_f", + "scalet", + "sndload", + "soundout", + "soundouts", + "specaddm", + "specdiff", + "specdisp", + "specfilt", + "spechist", + "specptrk", + "specscal", + "specsum", + "spectrum", + "stack", + "sumtab", + "tabgen", + "tabmap", + "tabmap_i", + "tabslice", + "vbap16", + "vbap4", + "vbap4move", + "vbap8", + "vbap8move", + "xyin" + ]; + + opcodes = lang.arrayToMap(opcodes); + deprecatedOpcodes = lang.arrayToMap(deprecatedOpcodes); + + this.lineContinuations = [ + { + token : "constant.character.escape.line-continuation.csound", + regex : /\\$/ + }, this.pushRule({ + token : "constant.character.escape.line-continuation.csound", + regex : /\\/, + next : "line continuation" + }) + ]; + + this.comments.push(this.lineContinuations); + + this.quotedStringContents.push( + this.lineContinuations, + { + token : "invalid.illegal", + regex : /[^"\\]*$/ + } + ); + + var start = this.$rules.start; + start.splice(1, 0, { + token : ["text.csound", "entity.name.label.csound", "entity.punctuation.label.csound", "text.csound"], + regex : /^([ \t]*)(\w+)(:)([ \t]+|$)/ + }); + start.push( + this.pushRule({ + token : "keyword.function.csound", + regex : /\binstr\b/, + next : "instrument numbers and identifiers" + }), this.pushRule({ + token : "keyword.function.csound", + regex : /\bopcode\b/, + next : "after opcode keyword" + }), { + token : "keyword.other.csound", + regex : /\bend(?:in|op)\b/ + }, + + { + token : "variable.language.csound", + regex : /\b(?:0dbfs|A4|k(?:r|smps)|nchnls(?:_i)?|sr)\b/ + }, + + this.numbers, + + { + token : "keyword.operator.csound", + regex : "\\+=|-=|\\*=|/=|<<|>>|<=|>=|==|!=|&&|\\|\\||[~¬]|[=!+\\-*/^%&|<>#?:]" + }, + + this.pushRule({ + token : "punctuation.definition.string.begin.csound", + regex : /"/, + next : "quoted string" + }), this.pushRule({ + token : "punctuation.definition.string.begin.csound", + regex : /{{/, + next : "braced string" + }), + + { + token : "keyword.control.csound", + regex : /\b(?:do|else(?:if)?|end(?:if|until)|fi|i(?:f|then)|kthen|od|r(?:ir)?eturn|then|until|while)\b/ + }, + + this.pushRule({ + token : "keyword.control.csound", + regex : /\b[ik]?goto\b/, + next : "goto before label" + }), this.pushRule({ + token : "keyword.control.csound", + regex : /\b(?:r(?:einit|igoto)|tigoto)\b/, + next : "goto before label" + }), this.pushRule({ + token : "keyword.control.csound", + regex : /\bc(?:g|in?|k|nk?)goto\b/, + next : ["goto before label", "goto before argument"] + }), this.pushRule({ + token : "keyword.control.csound", + regex : /\btimout\b/, + next : ["goto before label", "goto before argument", "goto before argument"] + }), this.pushRule({ + token : "keyword.control.csound", + regex : /\bloop_[gl][et]\b/, + next : ["goto before label", "goto before argument", "goto before argument", "goto before argument"] + }), + + this.pushRule({ + token : "support.function.csound", + regex : /\b(?:readscore|scoreline(?:_i)?)\b/, + next : "Csound score opcode" + }), this.pushRule({ + token : "support.function.csound", + regex : /\bpyl?run[it]?\b(?!$)/, + next : "Python opcode" + }), this.pushRule({ + token : "support.function.csound", + regex : /\blua_(?:exec|opdef)\b(?!$)/, + next : "Lua opcode" + }), + + { + token : "support.variable.csound", + regex : /\bp\d+\b/ + }, { + regex : /\b([A-Z_a-z]\w*)(?:(:)([A-Za-z]))?\b/, onMatch: function(value, currentState, stack, line) { + var tokens = value.split(this.splitRegex); + var name = tokens[1]; + var type; + if (opcodes.hasOwnProperty(name)) + type = "support.function.csound"; + else if (deprecatedOpcodes.hasOwnProperty(name)) + type = "invalid.deprecated.csound"; + if (type) { + if (tokens[2]) { + return [ + {type: type, value: name}, + {type: "punctuation.type-annotation.csound", value: tokens[2]}, + {type: "type-annotation.storage.type.csound", value: tokens[3]} + ]; + } + return type; + } + return "text.csound"; + } + } + ); + + this.$rules["macro parameter value list"].splice(2, 0, { + token : "punctuation.definition.string.begin.csound", + regex : /{{/, + next : "macro parameter value braced string" + }); + + this.addRules({ + "macro parameter value braced string": [ + { + token : "constant.character.escape.csound", + regex : /\\[#'()]/ + }, { + token : "invalid.illegal.csound.csound", + regex : /[#'()]/ + }, { + token : "punctuation.definition.string.end.csound", + regex : /}}/, + next : "macro parameter value list" + }, { + defaultToken: "string.braced.csound" + } + ], + + "instrument numbers and identifiers": [ + this.comments, + { + token : "entity.name.function.csound", + regex : /\d+|[A-Z_a-z]\w*/ + }, this.popRule({ + token : "empty", + regex : /$/ + }) + ], + + "after opcode keyword": [ + this.comments, + this.popRule({ + token : "empty", + regex : /$/ + }), this.popRule({ + token : "entity.name.function.opcode.csound", + regex : /[A-Z_a-z]\w*/, + next : "opcode type signatures" + }) + ], + "opcode type signatures": [ + this.comments, + this.popRule({ + token : "empty", + regex : /$/ + }), { + token : "storage.type.csound", + // https://github.com/csound/csound/search?q=XIDENT+path%3AEngine+filename%3Acsound_orc.lex + regex : /\b(?:0|[afijkKoOpPStV\[\]]+)/ + } + ], + + "quoted string": [ + this.popRule({ + token : "punctuation.definition.string.end.csound", + regex : /"/ + }), + this.quotedStringContents, + { + defaultToken: "string.quoted.csound" + } + ], + "braced string": [ + this.popRule({ + token : "punctuation.definition.string.end.csound", + regex : /}}/ + }), + this.bracedStringContents, + { + defaultToken: "string.braced.csound" + } + ], + + "goto before argument": [ + this.popRule({ + token : "text.csound", + regex : /,/ + }), + start + ], + "goto before label": [ + { + token : "text.csound", + regex : /\s+/ + }, + this.comments, + this.popRule({ + token : "entity.name.label.csound", + regex : /\w+/ + }), this.popRule({ + token : "empty", + regex : /(?!\w)/ + }) + ], + + "Csound score opcode": [ + this.comments, + { + token : "punctuation.definition.string.begin.csound", + regex : /{{/, + next : "csound-score-start" + }, this.popRule({ + token : "empty", + regex : /$/ + }) + ], + + "Python opcode": [ + this.comments, + { + token : "punctuation.definition.string.begin.csound", + regex : /{{/, + next : "python-start" + }, this.popRule({ + token : "empty", + regex : /$/ + }) + ], + + "Lua opcode": [ + this.comments, + { + token : "punctuation.definition.string.begin.csound", + regex : /{{/, + next : "lua-start" + }, this.popRule({ + token : "empty", + regex : /$/ + }) + ], + + "line continuation": [ + this.popRule({ + token : "empty", + regex : /$/ + }), + this.semicolonComments, + { + token : "invalid.illegal.csound", + regex : /\S.*/ + } + ] + }); + + var rules = [ + this.popRule({ + token : "punctuation.definition.string.end.csound", + regex : /}}/ + }) + ]; + this.embedRules(CsoundScoreHighlightRules, "csound-score-", rules); + this.embedRules(PythonHighlightRules, "python-", rules); + this.embedRules(LuaHighlightRules, "lua-", rules); + + this.normalizeRules(); +}; + +oop.inherits(CsoundOrchestraHighlightRules, CsoundPreprocessorHighlightRules); + +exports.CsoundOrchestraHighlightRules = CsoundOrchestraHighlightRules; +}); diff --git a/public/lib/ace/mode/csound_preprocessor_highlight_rules.js b/public/lib/ace/mode/csound_preprocessor_highlight_rules.js new file mode 100644 index 0000000..ddab597 --- /dev/null +++ b/public/lib/ace/mode/csound_preprocessor_highlight_rules.js @@ -0,0 +1,295 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); + +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CsoundPreprocessorHighlightRules = function() { + + this.semicolonComments = { + token : "comment.line.semicolon.csound", + regex : ";.*$" + }; + + this.comments = [ + { + token : "punctuation.definition.comment.begin.csound", + regex : "/\\*", + push : [ + { + token : "punctuation.definition.comment.end.csound", + regex : "\\*/", + next : "pop" + }, { + defaultToken: "comment.block.csound" + } + ] + }, { + token : "comment.line.double-slash.csound", + regex : "//.*$" + }, + this.semicolonComments + ]; + + this.macroUses = [ + { + token : ["entity.name.function.preprocessor.csound", "punctuation.definition.macro-parameter-value-list.begin.csound"], + regex : /(\$[A-Z_a-z]\w*\.?)(\()/, + next : "macro parameter value list" + }, { + token : "entity.name.function.preprocessor.csound", + regex : /\$[A-Z_a-z]\w*(?:\.|\b)/ + } + ]; + + this.numbers = [ + { + token : "constant.numeric.float.csound", + regex : /(?:\d+[Ee][+-]?\d+)|(?:\d+\.\d*|\d*\.\d+)(?:[Ee][+-]?\d+)?/ + }, { + token : ["storage.type.number.csound", "constant.numeric.integer.hexadecimal.csound"], + regex : /(0[Xx])([0-9A-Fa-f]+)/ + }, { + token : "constant.numeric.integer.decimal.csound", + regex : /\d+/ + } + ]; + + this.bracedStringContents = [ + { + token : "constant.character.escape.csound", + // https://github.com/csound/csound/search?q=unquote_string+path%3AEngine+filename%3Acsound_orc_compile.c + regex : /\\(?:[\\abnrt"]|[0-7]{1,3})/ + }, + // Format specifiers are included in quoted and braced strings. This + // means that format specifiers are highlighted in all strings, even + // though only + // fprintks https://csound.github.io/docs/manual/fprintks.html + // fprints https://csound.github.io/docs/manual/fprints.html + // printf/printf_i https://csound.github.io/docs/manual/printf.html + // printks https://csound.github.io/docs/manual/printks.html + // prints https://csound.github.io/docs/manual/prints.html + // sprintf https://csound.github.io/docs/manual/sprintf.html + // sprintfk https://csound.github.io/docs/manual/sprintfk.html + // work with strings that contain format specifiers. In addition, these + // opcodes’ handling of format specifiers is inconsistent: + // - fprintks, fprints, printks, and prints do accept %a and %A + // specifiers, but can’t accept %s specifiers. + // - printf, printf_i, sprintf, and sprintfk don’t accept %a and %A + // specifiers, but do accept %s specifiers. + // See https://github.com/csound/csound/issues/747 for more information. + { + token : "constant.character.placeholder.csound", + regex : /%[#0\- +]*\d*(?:\.\d+)?[diuoxXfFeEgGaAcs]/ + }, { + token : "constant.character.escape.csound", + regex : /%%/ + } + ]; + + this.quotedStringContents = [ + this.macroUses, + this.bracedStringContents + ]; + + var start = [ + this.comments, + + { + token : "keyword.preprocessor.csound", + regex : /#(?:e(?:nd(?:if)?|lse)\b|##)|@@?[ \t]*\d+/ + }, { + token : "keyword.preprocessor.csound", + regex : /#include/, + push : [ + this.comments, + { + token : "string.csound", + regex : /([^ \t])(?:.*?\1)/, + next : "pop" + } + ] + }, { + token : "keyword.preprocessor.csound", + regex : /#[ \t]*define/, + next : "define directive" + }, { + token : "keyword.preprocessor.csound", + regex : /#(?:ifn?def|undef)\b/, + next : "macro directive" + }, + + this.macroUses + ]; + + this.$rules = { + "start": start, + + "define directive": [ + this.comments, + { + token : "entity.name.function.preprocessor.csound", + regex : /[A-Z_a-z]\w*/ + }, { + token : "punctuation.definition.macro-parameter-name-list.begin.csound", + regex : /\(/, + next : "macro parameter name list" + }, { + token : "punctuation.definition.macro.begin.csound", + regex : /#/, + next : "macro body" + } + ], + "macro parameter name list": [ + { + token : "variable.parameter.preprocessor.csound", + regex : /[A-Z_a-z]\w*/ + }, { + token : "punctuation.definition.macro-parameter-name-list.end.csound", + regex : /\)/, + next : "define directive" + } + ], + "macro body": [ + { + token : "constant.character.escape.csound", + regex : /\\#/ + }, { + token : "punctuation.definition.macro.end.csound", + regex : /#/, + next : "start" + }, + start + ], + + "macro directive": [ + this.comments, + { + token : "entity.name.function.preprocessor.csound", + regex : /[A-Z_a-z]\w*/, + next : "start" + } + ], + + "macro parameter value list": [ + { + token : "punctuation.definition.macro-parameter-value-list.end.csound", + regex : /\)/, + next : "start" + }, { + token : "punctuation.definition.string.begin.csound", + regex : /"/, + next : "macro parameter value quoted string" + }, this.pushRule({ + token : "punctuation.macro-parameter-value-parenthetical.begin.csound", + regex : /\(/, + next : "macro parameter value parenthetical" + }), { + token : "punctuation.macro-parameter-value-separator.csound", + regex : "[#']" + } + ], + "macro parameter value quoted string": [ + { + token : "constant.character.escape.csound", + regex : /\\[#'()]/ + }, { + token : "invalid.illegal.csound", + regex : /[#'()]/ + }, { + token : "punctuation.definition.string.end.csound", + regex : /"/, + next : "macro parameter value list" + }, + this.quotedStringContents, + { + defaultToken: "string.quoted.csound" + } + ], + "macro parameter value parenthetical": [ + { + token : "constant.character.escape.csound", + regex : /\\\)/ + }, this.popRule({ + token : "punctuation.macro-parameter-value-parenthetical.end.csound", + regex : /\)/ + }), this.pushRule({ + token : "punctuation.macro-parameter-value-parenthetical.begin.csound", + regex : /\(/, + next : "macro parameter value parenthetical" + }), + start + ] + }; +}; + +oop.inherits(CsoundPreprocessorHighlightRules, TextHighlightRules); + +(function() { + + this.pushRule = function(params) { + return { + regex : params.regex, onMatch: function(value, currentState, stack, line) { + if (stack.length === 0) + stack.push(currentState); + if (Array.isArray(params.next)) { + for (var i = 0; i < params.next.length; i++) { + stack.push(params.next[i]); + } + } else { + stack.push(params.next); + } + this.next = stack[stack.length - 1]; + return params.token; + }, + + // TODO + get next() { return Array.isArray(params.next) ? params.next[params.next.length - 1] : params.next; }, + set next(next) { + if (Array.isArray(params.next)) { + var oldNext = params.next[params.next.length - 1]; + var oldNextIndex = oldNext.length - 1; + var newNextIndex = next.length - 1; + if (newNextIndex > oldNextIndex) { + while (oldNextIndex >= 0 && newNextIndex >= 0) { + if (oldNext.charAt(oldNextIndex) !== next.charAt(newNextIndex)) { + var prefix = next.substr(0, newNextIndex); + for (var i = 0; i < params.next.length; i++) { + params.next[i] = prefix + params.next[i]; + } + break; + } + oldNextIndex--; + newNextIndex--; + } + } + } else { + params.next = next; + } + }, + + // TODO: normalizeRules + get token() { return params.token; } + }; + }; + + this.popRule = function(params) { + return { + regex : params.regex, onMatch: function(value, currentState, stack, line) { + stack.pop(); + if (params.next) { + stack.push(params.next); + this.next = stack[stack.length - 1]; + } else { + this.next = stack.length > 1 ? stack[stack.length - 1] : stack.pop(); + } + return params.token; + } + }; + }; + +}).call(CsoundPreprocessorHighlightRules.prototype); + +exports.CsoundPreprocessorHighlightRules = CsoundPreprocessorHighlightRules; +}); diff --git a/public/lib/ace/mode/csound_score.js b/public/lib/ace/mode/csound_score.js new file mode 100644 index 0000000..2abb00c --- /dev/null +++ b/public/lib/ace/mode/csound_score.js @@ -0,0 +1,21 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CsoundScoreHighlightRules = require("./csound_score_highlight_rules").CsoundScoreHighlightRules; + +var Mode = function() { + this.HighlightRules = CsoundScoreHighlightRules; +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.lineCommentStart = ";"; + this.blockComment = {start: "/*", end: "*/"}; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/public/lib/ace/mode/csound_score_highlight_rules.js b/public/lib/ace/mode/csound_score_highlight_rules.js new file mode 100644 index 0000000..b007155 --- /dev/null +++ b/public/lib/ace/mode/csound_score_highlight_rules.js @@ -0,0 +1,156 @@ +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); + +var CsoundPreprocessorHighlightRules = require("./csound_preprocessor_highlight_rules").CsoundPreprocessorHighlightRules; + +var CsoundScoreHighlightRules = function() { + + CsoundPreprocessorHighlightRules.call(this); + + this.quotedStringContents.push({ + token : "invalid.illegal.csound-score", + regex : /[^"]*$/ + }); + + var start = this.$rules.start; + start.push( + { + token : "keyword.control.csound-score", + regex : /[abCdefiqstvxy]/ + }, { + // w statements are generated internally and should not be used; see + // https://github.com/csound/csound/issues/750. + token : "invalid.illegal.csound-score", + regex : /w/ + }, { + // z is not a statement, but rather a constant equal to + // 800,000,000,000. 800 billion seconds is about 25,367.8 years. See + // also https://csound.github.io/docs/manual/ScoreTop.html and + // https://github.com/csound/csound/search?q=stof+path%3AEngine+filename%3Asread.c. + token : "constant.numeric.language.csound-score", + regex : /z/ + }, { + token : ["keyword.control.csound-score", "constant.numeric.integer.decimal.csound-score"], + regex : /([nNpP][pP])(\d+)/ + }, { + token : "keyword.other.csound-score", + regex : /[mn]/, + push : [ + { + token : "empty", + regex : /$/, + next : "pop" + }, + this.comments, + { + token : "entity.name.label.csound-score", + regex : /[A-Z_a-z]\w*/ + } + ] + }, { + token : "keyword.preprocessor.csound-score", + regex : /r\b/, + next : "repeat section" + }, + + this.numbers, + + { + token : "keyword.operator.csound-score", + regex : "[!+\\-*/^%&|<>#~.]" + }, + + this.pushRule({ + token : "punctuation.definition.string.begin.csound-score", + regex : /"/, + next : "quoted string" + }), + + this.pushRule({ + token : "punctuation.braced-loop.begin.csound-score", + regex : /{/, + next : "loop after left brace" + }) + ); + + this.addRules({ + "repeat section": [ + { + token : "empty", + regex : /$/, + next : "start" + }, + this.comments, + { + token : "constant.numeric.integer.decimal.csound-score", + regex : /\d+/, + next : "repeat section before label" + } + ], + "repeat section before label": [ + { + token : "empty", + regex : /$/, + next : "start" + }, + this.comments, + { + token : "entity.name.label.csound-score", + regex : /[A-Z_a-z]\w*/, + next : "start" + } + ], + + "quoted string": [ + this.popRule({ + token : "punctuation.definition.string.end.csound-score", + regex : /"/ + }), + this.quotedStringContents, + { + defaultToken: "string.quoted.csound-score" + } + ], + + "loop after left brace": [ + this.popRule({ + token : "constant.numeric.integer.decimal.csound-score", + regex : /\d+/, + next : "loop after repeat count" + }), + this.comments, + { + token : "invalid.illegal.csound", + regex : /\S.*/ + } + ], + "loop after repeat count": [ + this.popRule({ + token : "entity.name.function.preprocessor.csound-score", + regex : /[A-Z_a-z]\w*\b/, + next : "loop after macro name" + }), + this.comments, + { + token : "invalid.illegal.csound", + regex : /\S.*/ + } + ], + "loop after macro name": [ + start, + this.popRule({ + token : "punctuation.braced-loop.end.csound-score", + regex : /}/ + }) + ] + }); + + this.normalizeRules(); +}; + +oop.inherits(CsoundScoreHighlightRules, CsoundPreprocessorHighlightRules); + +exports.CsoundScoreHighlightRules = CsoundScoreHighlightRules; +}); diff --git a/public/lib/ace/mode/css.js b/public/lib/ace/mode/css.js new file mode 100644 index 0000000..cafa502 --- /dev/null +++ b/public/lib/ace/mode/css.js @@ -0,0 +1,106 @@ +/* ***** 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 oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CssCompletions = require("./css_completions").CssCompletions; +var CssBehaviour = require("./behaviour/css").CssBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = CssHighlightRules; + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CssBehaviour(); + this.$completer = new CssCompletions(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.foldingRules = "cStyle"; + this.blockComment = {start: "/*", end: "*/"}; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + // ignore braces in comments + var tokens = this.getTokenizer().getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.getCompletions = function(state, session, pos, prefix) { + return this.$completer.getCompletions(state, session, pos, prefix); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("annotate", function(e) { + session.setAnnotations(e.data); + }); + + worker.on("terminate", function() { + session.clearAnnotations(); + }); + + return worker; + }; + + this.$id = "ace/mode/css"; +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); diff --git a/public/lib/ace/mode/css/csslint.js b/public/lib/ace/mode/css/csslint.js new file mode 100644 index 0000000..5c88843 --- /dev/null +++ b/public/lib/ace/mode/css/csslint.js @@ -0,0 +1,9629 @@ +define(function(require, exports, module) { +/*! +CSSLint +Copyright (c) 2014 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the 'Software'), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ +/* Build: v0.10.0 22-July-2014 01:17:52 */ +/*! +Parser-Lib +Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ +/* Version v0.2.5, Build time: 7-May-2014 03:37:38 */ +var parserlib = {}; +(function(){ + +/** + * A generic base to inherit from for any object + * that needs event handling. + * @class EventTarget + * @constructor + */ +function EventTarget(){ + + /** + * The array of listeners for various events. + * @type Object + * @property _listeners + * @private + */ + this._listeners = {}; +} + +EventTarget.prototype = { + + //restore constructor + constructor: EventTarget, + + /** + * Adds a listener for a given event type. + * @param {String} type The type of event to add a listener for. + * @param {Function} listener The function to call when the event occurs. + * @return {void} + * @method addListener + */ + addListener: function(type, listener){ + if (!this._listeners[type]){ + this._listeners[type] = []; + } + + this._listeners[type].push(listener); + }, + + /** + * Fires an event based on the passed-in object. + * @param {Object|String} event An object with at least a 'type' attribute + * or a string indicating the event name. + * @return {void} + * @method fire + */ + fire: function(event){ + if (typeof event == "string"){ + event = { type: event }; + } + if (typeof event.target != "undefined"){ + event.target = this; + } + + if (typeof event.type == "undefined"){ + throw new Error("Event object missing 'type' property."); + } + + if (this._listeners[event.type]){ + + //create a copy of the array and use that so listeners can't chane + var listeners = this._listeners[event.type].concat(); + for (var i=0, len=listeners.length; i < len; i++){ + listeners[i].call(this, event); + } + } + }, + + /** + * Removes a listener for a given event type. + * @param {String} type The type of event to remove a listener from. + * @param {Function} listener The function to remove from the event. + * @return {void} + * @method removeListener + */ + removeListener: function(type, listener){ + if (this._listeners[type]){ + var listeners = this._listeners[type]; + for (var i=0, len=listeners.length; i < len; i++){ + if (listeners[i] === listener){ + listeners.splice(i, 1); + break; + } + } + + + } + } +}; +/** + * Convenient way to read through strings. + * @namespace parserlib.util + * @class StringReader + * @constructor + * @param {String} text The text to read. + */ +function StringReader(text){ + + /** + * The input text with line endings normalized. + * @property _input + * @type String + * @private + */ + this._input = text.replace(/\n\r?/g, "\n"); + + + /** + * The row for the character to be read next. + * @property _line + * @type int + * @private + */ + this._line = 1; + + + /** + * The column for the character to be read next. + * @property _col + * @type int + * @private + */ + this._col = 1; + + /** + * The index of the character in the input to be read next. + * @property _cursor + * @type int + * @private + */ + this._cursor = 0; +} + +StringReader.prototype = { + + //restore constructor + constructor: StringReader, + + //------------------------------------------------------------------------- + // Position info + //------------------------------------------------------------------------- + + /** + * Returns the column of the character to be read next. + * @return {int} The column of the character to be read next. + * @method getCol + */ + getCol: function(){ + return this._col; + }, + + /** + * Returns the row of the character to be read next. + * @return {int} The row of the character to be read next. + * @method getLine + */ + getLine: function(){ + return this._line ; + }, + + /** + * Determines if you're at the end of the input. + * @return {Boolean} True if there's no more input, false otherwise. + * @method eof + */ + eof: function(){ + return (this._cursor == this._input.length); + }, + + //------------------------------------------------------------------------- + // Basic reading + //------------------------------------------------------------------------- + + /** + * Reads the next character without advancing the cursor. + * @param {int} count How many characters to look ahead (default is 1). + * @return {String} The next character or null if there is no next character. + * @method peek + */ + peek: function(count){ + var c = null; + count = (typeof count == "undefined" ? 1 : count); + + //if we're not at the end of the input... + if (this._cursor < this._input.length){ + + //get character and increment cursor and column + c = this._input.charAt(this._cursor + count - 1); + } + + return c; + }, + + /** + * Reads the next character from the input and adjusts the row and column + * accordingly. + * @return {String} The next character or null if there is no next character. + * @method read + */ + read: function(){ + var c = null; + + //if we're not at the end of the input... + if (this._cursor < this._input.length){ + + //if the last character was a newline, increment row count + //and reset column count + if (this._input.charAt(this._cursor) == "\n"){ + this._line++; + this._col=1; + } else { + this._col++; + } + + //get character and increment cursor and column + c = this._input.charAt(this._cursor++); + } + + return c; + }, + + //------------------------------------------------------------------------- + // Misc + //------------------------------------------------------------------------- + + /** + * Saves the current location so it can be returned to later. + * @method mark + * @return {void} + */ + mark: function(){ + this._bookmark = { + cursor: this._cursor, + line: this._line, + col: this._col + }; + }, + + reset: function(){ + if (this._bookmark){ + this._cursor = this._bookmark.cursor; + this._line = this._bookmark.line; + this._col = this._bookmark.col; + delete this._bookmark; + } + }, + + //------------------------------------------------------------------------- + // Advanced reading + //------------------------------------------------------------------------- + + /** + * Reads up to and including the given string. Throws an error if that + * string is not found. + * @param {String} pattern The string to read. + * @return {String} The string when it is found. + * @throws Error when the string pattern is not found. + * @method readTo + */ + readTo: function(pattern){ + + var buffer = "", + c; + + /* + * First, buffer must be the same length as the pattern. + * Then, buffer must end with the pattern or else reach the + * end of the input. + */ + while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) != buffer.length - pattern.length){ + c = this.read(); + if (c){ + buffer += c; + } else { + throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + "."); + } + } + + return buffer; + + }, + + /** + * Reads characters while each character causes the given + * filter function to return true. The function is passed + * in each character and either returns true to continue + * reading or false to stop. + * @param {Function} filter The function to read on each character. + * @return {String} The string made up of all characters that passed the + * filter check. + * @method readWhile + */ + readWhile: function(filter){ + + var buffer = "", + c = this.read(); + + while(c !== null && filter(c)){ + buffer += c; + c = this.read(); + } + + return buffer; + + }, + + /** + * Reads characters that match either text or a regular expression and + * returns those characters. If a match is found, the row and column + * are adjusted; if no match is found, the reader's state is unchanged. + * reading or false to stop. + * @param {String|RegExp} matcher If a string, then the literal string + * value is searched for. If a regular expression, then any string + * matching the pattern is search for. + * @return {String} The string made up of all characters that matched or + * null if there was no match. + * @method readMatch + */ + readMatch: function(matcher){ + + var source = this._input.substring(this._cursor), + value = null; + + //if it's a string, just do a straight match + if (typeof matcher == "string"){ + if (source.indexOf(matcher) === 0){ + value = this.readCount(matcher.length); + } + } else if (matcher instanceof RegExp){ + if (matcher.test(source)){ + value = this.readCount(RegExp.lastMatch.length); + } + } + + return value; + }, + + + /** + * Reads a given number of characters. If the end of the input is reached, + * it reads only the remaining characters and does not throw an error. + * @param {int} count The number of characters to read. + * @return {String} The string made up the read characters. + * @method readCount + */ + readCount: function(count){ + var buffer = ""; + + while(count--){ + buffer += this.read(); + } + + return buffer; + } + +}; +/** + * Type to use when a syntax error occurs. + * @class SyntaxError + * @namespace parserlib.util + * @constructor + * @param {String} message The error message. + * @param {int} line The line at which the error occurred. + * @param {int} col The column at which the error occurred. + */ +function SyntaxError(message, line, col){ + + /** + * The column at which the error occurred. + * @type int + * @property col + */ + this.col = col; + + /** + * The line at which the error occurred. + * @type int + * @property line + */ + this.line = line; + + /** + * The text representation of the unit. + * @type String + * @property text + */ + this.message = message; + +} + +//inherit from Error +SyntaxError.prototype = new Error(); +/** + * Base type to represent a single syntactic unit. + * @class SyntaxUnit + * @namespace parserlib.util + * @constructor + * @param {String} text The text of the unit. + * @param {int} line The line of text on which the unit resides. + * @param {int} col The column of text on which the unit resides. + */ +function SyntaxUnit(text, line, col, type){ + + + /** + * The column of text on which the unit resides. + * @type int + * @property col + */ + this.col = col; + + /** + * The line of text on which the unit resides. + * @type int + * @property line + */ + this.line = line; + + /** + * The text representation of the unit. + * @type String + * @property text + */ + this.text = text; + + /** + * The type of syntax unit. + * @type int + * @property type + */ + this.type = type; +} + +/** + * Create a new syntax unit based solely on the given token. + * Convenience method for creating a new syntax unit when + * it represents a single token instead of multiple. + * @param {Object} token The token object to represent. + * @return {parserlib.util.SyntaxUnit} The object representing the token. + * @static + * @method fromToken + */ +SyntaxUnit.fromToken = function(token){ + return new SyntaxUnit(token.value, token.startLine, token.startCol); +}; + +SyntaxUnit.prototype = { + + //restore constructor + constructor: SyntaxUnit, + + /** + * Returns the text representation of the unit. + * @return {String} The text representation of the unit. + * @method valueOf + */ + valueOf: function(){ + return this.text; + }, + + /** + * Returns the text representation of the unit. + * @return {String} The text representation of the unit. + * @method toString + */ + toString: function(){ + return this.text; + } + +}; +/*global StringReader, SyntaxError*/ + +/** + * Generic TokenStream providing base functionality. + * @class TokenStreamBase + * @namespace parserlib.util + * @constructor + * @param {String|StringReader} input The text to tokenize or a reader from + * which to read the input. + */ +function TokenStreamBase(input, tokenData){ + + /** + * The string reader for easy access to the text. + * @type StringReader + * @property _reader + * @private + */ + this._reader = input ? new StringReader(input.toString()) : null; + + /** + * Token object for the last consumed token. + * @type Token + * @property _token + * @private + */ + this._token = null; + + /** + * The array of token information. + * @type Array + * @property _tokenData + * @private + */ + this._tokenData = tokenData; + + /** + * Lookahead token buffer. + * @type Array + * @property _lt + * @private + */ + this._lt = []; + + /** + * Lookahead token buffer index. + * @type int + * @property _ltIndex + * @private + */ + this._ltIndex = 0; + + this._ltIndexCache = []; +} + +/** + * Accepts an array of token information and outputs + * an array of token data containing key-value mappings + * and matching functions that the TokenStream needs. + * @param {Array} tokens An array of token descriptors. + * @return {Array} An array of processed token data. + * @method createTokenData + * @static + */ +TokenStreamBase.createTokenData = function(tokens){ + + var nameMap = [], + typeMap = {}, + tokenData = tokens.concat([]), + i = 0, + len = tokenData.length+1; + + tokenData.UNKNOWN = -1; + tokenData.unshift({name:"EOF"}); + + for (; i < len; i++){ + nameMap.push(tokenData[i].name); + tokenData[tokenData[i].name] = i; + if (tokenData[i].text){ + typeMap[tokenData[i].text] = i; + } + } + + tokenData.name = function(tt){ + return nameMap[tt]; + }; + + tokenData.type = function(c){ + return typeMap[c]; + }; + + return tokenData; +}; + +TokenStreamBase.prototype = { + + //restore constructor + constructor: TokenStreamBase, + + //------------------------------------------------------------------------- + // Matching methods + //------------------------------------------------------------------------- + + /** + * Determines if the next token matches the given token type. + * If so, that token is consumed; if not, the token is placed + * back onto the token stream. You can pass in any number of + * token types and this will return true if any of the token + * types is found. + * @param {int|int[]} tokenTypes Either a single token type or an array of + * token types that the next token might be. If an array is passed, + * it's assumed that the token can be any of these. + * @param {variant} channel (Optional) The channel to read from. If not + * provided, reads from the default (unnamed) channel. + * @return {Boolean} True if the token type matches, false if not. + * @method match + */ + match: function(tokenTypes, channel){ + + //always convert to an array, makes things easier + if (!(tokenTypes instanceof Array)){ + tokenTypes = [tokenTypes]; + } + + var tt = this.get(channel), + i = 0, + len = tokenTypes.length; + + while(i < len){ + if (tt == tokenTypes[i++]){ + return true; + } + } + + //no match found, put the token back + this.unget(); + return false; + }, + + /** + * Determines if the next token matches the given token type. + * If so, that token is consumed; if not, an error is thrown. + * @param {int|int[]} tokenTypes Either a single token type or an array of + * token types that the next token should be. If an array is passed, + * it's assumed that the token must be one of these. + * @param {variant} channel (Optional) The channel to read from. If not + * provided, reads from the default (unnamed) channel. + * @return {void} + * @method mustMatch + */ + mustMatch: function(tokenTypes, channel){ + + var token; + + //always convert to an array, makes things easier + if (!(tokenTypes instanceof Array)){ + tokenTypes = [tokenTypes]; + } + + if (!this.match.apply(this, arguments)){ + token = this.LT(1); + throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name + + " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); + } + }, + + //------------------------------------------------------------------------- + // Consuming methods + //------------------------------------------------------------------------- + + /** + * Keeps reading from the token stream until either one of the specified + * token types is found or until the end of the input is reached. + * @param {int|int[]} tokenTypes Either a single token type or an array of + * token types that the next token should be. If an array is passed, + * it's assumed that the token must be one of these. + * @param {variant} channel (Optional) The channel to read from. If not + * provided, reads from the default (unnamed) channel. + * @return {void} + * @method advance + */ + advance: function(tokenTypes, channel){ + + while(this.LA(0) !== 0 && !this.match(tokenTypes, channel)){ + this.get(); + } + + return this.LA(0); + }, + + /** + * Consumes the next token from the token stream. + * @return {int} The token type of the token that was just consumed. + * @method get + */ + get: function(channel){ + + var tokenInfo = this._tokenData, + reader = this._reader, + value, + i =0, + len = tokenInfo.length, + found = false, + token, + info; + + //check the lookahead buffer first + if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length){ + + i++; + this._token = this._lt[this._ltIndex++]; + info = tokenInfo[this._token.type]; + + //obey channels logic + while((info.channel !== undefined && channel !== info.channel) && + this._ltIndex < this._lt.length){ + this._token = this._lt[this._ltIndex++]; + info = tokenInfo[this._token.type]; + i++; + } + + //here be dragons + if ((info.channel === undefined || channel === info.channel) && + this._ltIndex <= this._lt.length){ + this._ltIndexCache.push(i); + return this._token.type; + } + } + + //call token retriever method + token = this._getToken(); + + //if it should be hidden, don't save a token + if (token.type > -1 && !tokenInfo[token.type].hide){ + + //apply token channel + token.channel = tokenInfo[token.type].channel; + + //save for later + this._token = token; + this._lt.push(token); + + //save space that will be moved (must be done before array is truncated) + this._ltIndexCache.push(this._lt.length - this._ltIndex + i); + + //keep the buffer under 5 items + if (this._lt.length > 5){ + this._lt.shift(); + } + + //also keep the shift buffer under 5 items + if (this._ltIndexCache.length > 5){ + this._ltIndexCache.shift(); + } + + //update lookahead index + this._ltIndex = this._lt.length; + } + + /* + * Skip to the next token if: + * 1. The token type is marked as hidden. + * 2. The token type has a channel specified and it isn't the current channel. + */ + info = tokenInfo[token.type]; + if (info && + (info.hide || + (info.channel !== undefined && channel !== info.channel))){ + return this.get(channel); + } else { + //return just the type + return token.type; + } + }, + + /** + * Looks ahead a certain number of tokens and returns the token type at + * that position. This will throw an error if you lookahead past the + * end of input, past the size of the lookahead buffer, or back past + * the first token in the lookahead buffer. + * @param {int} The index of the token type to retrieve. 0 for the + * current token, 1 for the next, -1 for the previous, etc. + * @return {int} The token type of the token in the given position. + * @method LA + */ + LA: function(index){ + var total = index, + tt; + if (index > 0){ + //TODO: Store 5 somewhere + if (index > 5){ + throw new Error("Too much lookahead."); + } + + //get all those tokens + while(total){ + tt = this.get(); + total--; + } + + //unget all those tokens + while(total < index){ + this.unget(); + total++; + } + } else if (index < 0){ + + if(this._lt[this._ltIndex+index]){ + tt = this._lt[this._ltIndex+index].type; + } else { + throw new Error("Too much lookbehind."); + } + + } else { + tt = this._token.type; + } + + return tt; + + }, + + /** + * Looks ahead a certain number of tokens and returns the token at + * that position. This will throw an error if you lookahead past the + * end of input, past the size of the lookahead buffer, or back past + * the first token in the lookahead buffer. + * @param {int} The index of the token type to retrieve. 0 for the + * current token, 1 for the next, -1 for the previous, etc. + * @return {Object} The token of the token in the given position. + * @method LA + */ + LT: function(index){ + + //lookahead first to prime the token buffer + this.LA(index); + + //now find the token, subtract one because _ltIndex is already at the next index + return this._lt[this._ltIndex+index-1]; + }, + + /** + * Returns the token type for the next token in the stream without + * consuming it. + * @return {int} The token type of the next token in the stream. + * @method peek + */ + peek: function(){ + return this.LA(1); + }, + + /** + * Returns the actual token object for the last consumed token. + * @return {Token} The token object for the last consumed token. + * @method token + */ + token: function(){ + return this._token; + }, + + /** + * Returns the name of the token for the given token type. + * @param {int} tokenType The type of token to get the name of. + * @return {String} The name of the token or "UNKNOWN_TOKEN" for any + * invalid token type. + * @method tokenName + */ + tokenName: function(tokenType){ + if (tokenType < 0 || tokenType > this._tokenData.length){ + return "UNKNOWN_TOKEN"; + } else { + return this._tokenData[tokenType].name; + } + }, + + /** + * Returns the token type value for the given token name. + * @param {String} tokenName The name of the token whose value should be returned. + * @return {int} The token type value for the given token name or -1 + * for an unknown token. + * @method tokenName + */ + tokenType: function(tokenName){ + return this._tokenData[tokenName] || -1; + }, + + /** + * Returns the last consumed token to the token stream. + * @method unget + */ + unget: function(){ + //if (this._ltIndex > -1){ + if (this._ltIndexCache.length){ + this._ltIndex -= this._ltIndexCache.pop();//--; + this._token = this._lt[this._ltIndex - 1]; + } else { + throw new Error("Too much lookahead."); + } + } + +}; + + +parserlib.util = { +StringReader: StringReader, +SyntaxError : SyntaxError, +SyntaxUnit : SyntaxUnit, +EventTarget : EventTarget, +TokenStreamBase : TokenStreamBase +}; +})(); +/* +Parser-Lib +Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ +/* Version v0.2.5, Build time: 7-May-2014 03:37:38 */ +(function(){ +var EventTarget = parserlib.util.EventTarget, +TokenStreamBase = parserlib.util.TokenStreamBase, +StringReader = parserlib.util.StringReader, +SyntaxError = parserlib.util.SyntaxError, +SyntaxUnit = parserlib.util.SyntaxUnit; + +var Colors = { + aliceblue :"#f0f8ff", + antiquewhite :"#faebd7", + aqua :"#00ffff", + aquamarine :"#7fffd4", + azure :"#f0ffff", + beige :"#f5f5dc", + bisque :"#ffe4c4", + black :"#000000", + blanchedalmond :"#ffebcd", + blue :"#0000ff", + blueviolet :"#8a2be2", + brown :"#a52a2a", + burlywood :"#deb887", + cadetblue :"#5f9ea0", + chartreuse :"#7fff00", + chocolate :"#d2691e", + coral :"#ff7f50", + cornflowerblue :"#6495ed", + cornsilk :"#fff8dc", + crimson :"#dc143c", + cyan :"#00ffff", + darkblue :"#00008b", + darkcyan :"#008b8b", + darkgoldenrod :"#b8860b", + darkgray :"#a9a9a9", + darkgrey :"#a9a9a9", + darkgreen :"#006400", + darkkhaki :"#bdb76b", + darkmagenta :"#8b008b", + darkolivegreen :"#556b2f", + darkorange :"#ff8c00", + darkorchid :"#9932cc", + darkred :"#8b0000", + darksalmon :"#e9967a", + darkseagreen :"#8fbc8f", + darkslateblue :"#483d8b", + darkslategray :"#2f4f4f", + darkslategrey :"#2f4f4f", + darkturquoise :"#00ced1", + darkviolet :"#9400d3", + deeppink :"#ff1493", + deepskyblue :"#00bfff", + dimgray :"#696969", + dimgrey :"#696969", + dodgerblue :"#1e90ff", + firebrick :"#b22222", + floralwhite :"#fffaf0", + forestgreen :"#228b22", + fuchsia :"#ff00ff", + gainsboro :"#dcdcdc", + ghostwhite :"#f8f8ff", + gold :"#ffd700", + goldenrod :"#daa520", + gray :"#808080", + grey :"#808080", + green :"#008000", + greenyellow :"#adff2f", + honeydew :"#f0fff0", + hotpink :"#ff69b4", + indianred :"#cd5c5c", + indigo :"#4b0082", + ivory :"#fffff0", + khaki :"#f0e68c", + lavender :"#e6e6fa", + lavenderblush :"#fff0f5", + lawngreen :"#7cfc00", + lemonchiffon :"#fffacd", + lightblue :"#add8e6", + lightcoral :"#f08080", + lightcyan :"#e0ffff", + lightgoldenrodyellow :"#fafad2", + lightgray :"#d3d3d3", + lightgrey :"#d3d3d3", + lightgreen :"#90ee90", + lightpink :"#ffb6c1", + lightsalmon :"#ffa07a", + lightseagreen :"#20b2aa", + lightskyblue :"#87cefa", + lightslategray :"#778899", + lightslategrey :"#778899", + lightsteelblue :"#b0c4de", + lightyellow :"#ffffe0", + lime :"#00ff00", + limegreen :"#32cd32", + linen :"#faf0e6", + magenta :"#ff00ff", + maroon :"#800000", + mediumaquamarine:"#66cdaa", + mediumblue :"#0000cd", + mediumorchid :"#ba55d3", + mediumpurple :"#9370d8", + mediumseagreen :"#3cb371", + mediumslateblue :"#7b68ee", + mediumspringgreen :"#00fa9a", + mediumturquoise :"#48d1cc", + mediumvioletred :"#c71585", + midnightblue :"#191970", + mintcream :"#f5fffa", + mistyrose :"#ffe4e1", + moccasin :"#ffe4b5", + navajowhite :"#ffdead", + navy :"#000080", + oldlace :"#fdf5e6", + olive :"#808000", + olivedrab :"#6b8e23", + orange :"#ffa500", + orangered :"#ff4500", + orchid :"#da70d6", + palegoldenrod :"#eee8aa", + palegreen :"#98fb98", + paleturquoise :"#afeeee", + palevioletred :"#d87093", + papayawhip :"#ffefd5", + peachpuff :"#ffdab9", + peru :"#cd853f", + pink :"#ffc0cb", + plum :"#dda0dd", + powderblue :"#b0e0e6", + purple :"#800080", + red :"#ff0000", + rosybrown :"#bc8f8f", + royalblue :"#4169e1", + saddlebrown :"#8b4513", + salmon :"#fa8072", + sandybrown :"#f4a460", + seagreen :"#2e8b57", + seashell :"#fff5ee", + sienna :"#a0522d", + silver :"#c0c0c0", + skyblue :"#87ceeb", + slateblue :"#6a5acd", + slategray :"#708090", + slategrey :"#708090", + snow :"#fffafa", + springgreen :"#00ff7f", + steelblue :"#4682b4", + tan :"#d2b48c", + teal :"#008080", + thistle :"#d8bfd8", + tomato :"#ff6347", + turquoise :"#40e0d0", + violet :"#ee82ee", + wheat :"#f5deb3", + white :"#ffffff", + whitesmoke :"#f5f5f5", + yellow :"#ffff00", + yellowgreen :"#9acd32", + //CSS2 system colors http://www.w3.org/TR/css3-color/#css2-system + activeBorder :"Active window border.", + activecaption :"Active window caption.", + appworkspace :"Background color of multiple document interface.", + background :"Desktop background.", + buttonface :"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.", + buttonhighlight :"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.", + buttonshadow :"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.", + buttontext :"Text on push buttons.", + captiontext :"Text in caption, size box, and scrollbar arrow box.", + graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.", + greytext :"Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.", + highlight :"Item(s) selected in a control.", + highlighttext :"Text of item(s) selected in a control.", + inactiveborder :"Inactive window border.", + inactivecaption :"Inactive window caption.", + inactivecaptiontext :"Color of text in an inactive caption.", + infobackground :"Background color for tooltip controls.", + infotext :"Text color for tooltip controls.", + menu :"Menu background.", + menutext :"Text in menus.", + scrollbar :"Scroll bar gray area.", + threeddarkshadow :"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + threedface :"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + threedhighlight :"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + threedlightshadow :"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + threedshadow :"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + window :"Window background.", + windowframe :"Window frame.", + windowtext :"Text in windows." +}; +/*global SyntaxUnit, Parser*/ +/** + * Represents a selector combinator (whitespace, +, >). + * @namespace parserlib.css + * @class Combinator + * @extends parserlib.util.SyntaxUnit + * @constructor + * @param {String} text The text representation of the unit. + * @param {int} line The line of text on which the unit resides. + * @param {int} col The column of text on which the unit resides. + */ +function Combinator(text, line, col){ + + SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE); + + /** + * The type of modifier. + * @type String + * @property type + */ + this.type = "unknown"; + + //pretty simple + if (/^\s+$/.test(text)){ + this.type = "descendant"; + } else if (text == ">"){ + this.type = "child"; + } else if (text == "+"){ + this.type = "adjacent-sibling"; + } else if (text == "~"){ + this.type = "sibling"; + } + +} + +Combinator.prototype = new SyntaxUnit(); +Combinator.prototype.constructor = Combinator; + +/*global SyntaxUnit, Parser*/ +/** + * Represents a media feature, such as max-width:500. + * @namespace parserlib.css + * @class MediaFeature + * @extends parserlib.util.SyntaxUnit + * @constructor + * @param {SyntaxUnit} name The name of the feature. + * @param {SyntaxUnit} value The value of the feature or null if none. + */ +function MediaFeature(name, value){ + + SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE); + + /** + * The name of the media feature + * @type String + * @property name + */ + this.name = name; + + /** + * The value for the feature or null if there is none. + * @type SyntaxUnit + * @property value + */ + this.value = value; +} + +MediaFeature.prototype = new SyntaxUnit(); +MediaFeature.prototype.constructor = MediaFeature; + +/*global SyntaxUnit, Parser*/ +/** + * Represents an individual media query. + * @namespace parserlib.css + * @class MediaQuery + * @extends parserlib.util.SyntaxUnit + * @constructor + * @param {String} modifier The modifier "not" or "only" (or null). + * @param {String} mediaType The type of media (i.e., "print"). + * @param {Array} parts Array of selectors parts making up this selector. + * @param {int} line The line of text on which the unit resides. + * @param {int} col The column of text on which the unit resides. + */ +function MediaQuery(modifier, mediaType, features, line, col){ + + SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE); + + /** + * The media modifier ("not" or "only") + * @type String + * @property modifier + */ + this.modifier = modifier; + + /** + * The mediaType (i.e., "print") + * @type String + * @property mediaType + */ + this.mediaType = mediaType; + + /** + * The parts that make up the selector. + * @type Array + * @property features + */ + this.features = features; + +} + +MediaQuery.prototype = new SyntaxUnit(); +MediaQuery.prototype.constructor = MediaQuery; + +/*global Tokens, TokenStream, SyntaxError, Properties, Validation, ValidationError, SyntaxUnit, + PropertyValue, PropertyValuePart, SelectorPart, SelectorSubPart, Selector, + PropertyName, Combinator, MediaFeature, MediaQuery, EventTarget */ + +/** + * A CSS3 parser. + * @namespace parserlib.css + * @class Parser + * @constructor + * @param {Object} options (Optional) Various options for the parser: + * starHack (true|false) to allow IE6 star hack as valid, + * underscoreHack (true|false) to interpret leading underscores + * as IE6-7 targeting for known properties, ieFilters (true|false) + * to indicate that IE < 8 filters should be accepted and not throw + * syntax errors. + */ +function Parser(options){ + + //inherit event functionality + EventTarget.call(this); + + + this.options = options || {}; + + this._tokenStream = null; +} + +//Static constants +Parser.DEFAULT_TYPE = 0; +Parser.COMBINATOR_TYPE = 1; +Parser.MEDIA_FEATURE_TYPE = 2; +Parser.MEDIA_QUERY_TYPE = 3; +Parser.PROPERTY_NAME_TYPE = 4; +Parser.PROPERTY_VALUE_TYPE = 5; +Parser.PROPERTY_VALUE_PART_TYPE = 6; +Parser.SELECTOR_TYPE = 7; +Parser.SELECTOR_PART_TYPE = 8; +Parser.SELECTOR_SUB_PART_TYPE = 9; + +Parser.prototype = function(){ + + var proto = new EventTarget(), //new prototype + prop, + additions = { + + //restore constructor + constructor: Parser, + + //instance constants - yuck + DEFAULT_TYPE : 0, + COMBINATOR_TYPE : 1, + MEDIA_FEATURE_TYPE : 2, + MEDIA_QUERY_TYPE : 3, + PROPERTY_NAME_TYPE : 4, + PROPERTY_VALUE_TYPE : 5, + PROPERTY_VALUE_PART_TYPE : 6, + SELECTOR_TYPE : 7, + SELECTOR_PART_TYPE : 8, + SELECTOR_SUB_PART_TYPE : 9, + + //----------------------------------------------------------------- + // Grammar + //----------------------------------------------------------------- + + _stylesheet: function(){ + + /* + * stylesheet + * : [ CHARSET_SYM S* STRING S* ';' ]? + * [S|CDO|CDC]* [ import [S|CDO|CDC]* ]* + * [ namespace [S|CDO|CDC]* ]* + * [ [ ruleset | media | page | font_face | keyframes ] [S|CDO|CDC]* ]* + * ; + */ + + var tokenStream = this._tokenStream, + charset = null, + count, + token, + tt; + + this.fire("startstylesheet"); + + //try to read character set + this._charset(); + + this._skipCruft(); + + //try to read imports - may be more than one + while (tokenStream.peek() == Tokens.IMPORT_SYM){ + this._import(); + this._skipCruft(); + } + + //try to read namespaces - may be more than one + while (tokenStream.peek() == Tokens.NAMESPACE_SYM){ + this._namespace(); + this._skipCruft(); + } + + //get the next token + tt = tokenStream.peek(); + + //try to read the rest + while(tt > Tokens.EOF){ + + try { + + switch(tt){ + case Tokens.MEDIA_SYM: + this._media(); + this._skipCruft(); + break; + case Tokens.PAGE_SYM: + this._page(); + this._skipCruft(); + break; + case Tokens.FONT_FACE_SYM: + this._font_face(); + this._skipCruft(); + break; + case Tokens.KEYFRAMES_SYM: + this._keyframes(); + this._skipCruft(); + break; + case Tokens.VIEWPORT_SYM: + this._viewport(); + this._skipCruft(); + break; + case Tokens.UNKNOWN_SYM: //unknown @ rule + tokenStream.get(); + if (!this.options.strict){ + + //fire error event + this.fire({ + type: "error", + error: null, + message: "Unknown @ rule: " + tokenStream.LT(0).value + ".", + line: tokenStream.LT(0).startLine, + col: tokenStream.LT(0).startCol + }); + + //skip braces + count=0; + while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) == Tokens.LBRACE){ + count++; //keep track of nesting depth + } + + while(count){ + tokenStream.advance([Tokens.RBRACE]); + count--; + } + + } else { + //not a syntax error, rethrow it + throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol); + } + break; + case Tokens.S: + this._readWhitespace(); + break; + default: + if(!this._ruleset()){ + + //error handling for known issues + switch(tt){ + case Tokens.CHARSET_SYM: + token = tokenStream.LT(1); + this._charset(false); + throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol); + case Tokens.IMPORT_SYM: + token = tokenStream.LT(1); + this._import(false); + throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol); + case Tokens.NAMESPACE_SYM: + token = tokenStream.LT(1); + this._namespace(false); + throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol); + default: + tokenStream.get(); //get the last token + this._unexpectedToken(tokenStream.token()); + } + + } + } + } catch(ex) { + if (ex instanceof SyntaxError && !this.options.strict){ + this.fire({ + type: "error", + error: ex, + message: ex.message, + line: ex.line, + col: ex.col + }); + } else { + throw ex; + } + } + + tt = tokenStream.peek(); + } + + if (tt != Tokens.EOF){ + this._unexpectedToken(tokenStream.token()); + } + + this.fire("endstylesheet"); + }, + + _charset: function(emit){ + var tokenStream = this._tokenStream, + charset, + token, + line, + col; + + if (tokenStream.match(Tokens.CHARSET_SYM)){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.STRING); + + token = tokenStream.token(); + charset = token.value; + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.SEMICOLON); + + if (emit !== false){ + this.fire({ + type: "charset", + charset:charset, + line: line, + col: col + }); + } + } + }, + + _import: function(emit){ + /* + * import + * : IMPORT_SYM S* + * [STRING|URI] S* media_query_list? ';' S* + */ + + var tokenStream = this._tokenStream, + tt, + uri, + importToken, + mediaList = []; + + //read import symbol + tokenStream.mustMatch(Tokens.IMPORT_SYM); + importToken = tokenStream.token(); + this._readWhitespace(); + + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); + + //grab the URI value + uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1"); + + this._readWhitespace(); + + mediaList = this._media_query_list(); + + //must end with a semicolon + tokenStream.mustMatch(Tokens.SEMICOLON); + this._readWhitespace(); + + if (emit !== false){ + this.fire({ + type: "import", + uri: uri, + media: mediaList, + line: importToken.startLine, + col: importToken.startCol + }); + } + + }, + + _namespace: function(emit){ + /* + * namespace + * : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S* + */ + + var tokenStream = this._tokenStream, + line, + col, + prefix, + uri; + + //read import symbol + tokenStream.mustMatch(Tokens.NAMESPACE_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + this._readWhitespace(); + + //it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT + if (tokenStream.match(Tokens.IDENT)){ + prefix = tokenStream.token().value; + this._readWhitespace(); + } + + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); + /*if (!tokenStream.match(Tokens.STRING)){ + tokenStream.mustMatch(Tokens.URI); + }*/ + + //grab the URI value + uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + + this._readWhitespace(); + + //must end with a semicolon + tokenStream.mustMatch(Tokens.SEMICOLON); + this._readWhitespace(); + + if (emit !== false){ + this.fire({ + type: "namespace", + prefix: prefix, + uri: uri, + line: line, + col: col + }); + } + + }, + + _media: function(){ + /* + * media + * : MEDIA_SYM S* media_query_list S* '{' S* ruleset* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col, + mediaList;// = []; + + //look for @media + tokenStream.mustMatch(Tokens.MEDIA_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + mediaList = this._media_query_list(); + + tokenStream.mustMatch(Tokens.LBRACE); + this._readWhitespace(); + + this.fire({ + type: "startmedia", + media: mediaList, + line: line, + col: col + }); + + while(true) { + if (tokenStream.peek() == Tokens.PAGE_SYM){ + this._page(); + } else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){ + this._font_face(); + } else if (tokenStream.peek() == Tokens.VIEWPORT_SYM){ + this._viewport(); + } else if (!this._ruleset()){ + break; + } + } + + tokenStream.mustMatch(Tokens.RBRACE); + this._readWhitespace(); + + this.fire({ + type: "endmedia", + media: mediaList, + line: line, + col: col + }); + }, + + + //CSS3 Media Queries + _media_query_list: function(){ + /* + * media_query_list + * : S* [media_query [ ',' S* media_query ]* ]? + * ; + */ + var tokenStream = this._tokenStream, + mediaList = []; + + + this._readWhitespace(); + + if (tokenStream.peek() == Tokens.IDENT || tokenStream.peek() == Tokens.LPAREN){ + mediaList.push(this._media_query()); + } + + while(tokenStream.match(Tokens.COMMA)){ + this._readWhitespace(); + mediaList.push(this._media_query()); + } + + return mediaList; + }, + + /* + * Note: "expression" in the grammar maps to the _media_expression + * method. + + */ + _media_query: function(){ + /* + * media_query + * : [ONLY | NOT]? S* media_type S* [ AND S* expression ]* + * | expression [ AND S* expression ]* + * ; + */ + var tokenStream = this._tokenStream, + type = null, + ident = null, + token = null, + expressions = []; + + if (tokenStream.match(Tokens.IDENT)){ + ident = tokenStream.token().value.toLowerCase(); + + //since there's no custom tokens for these, need to manually check + if (ident != "only" && ident != "not"){ + tokenStream.unget(); + ident = null; + } else { + token = tokenStream.token(); + } + } + + this._readWhitespace(); + + if (tokenStream.peek() == Tokens.IDENT){ + type = this._media_type(); + if (token === null){ + token = tokenStream.token(); + } + } else if (tokenStream.peek() == Tokens.LPAREN){ + if (token === null){ + token = tokenStream.LT(1); + } + expressions.push(this._media_expression()); + } + + if (type === null && expressions.length === 0){ + return null; + } else { + this._readWhitespace(); + while (tokenStream.match(Tokens.IDENT)){ + if (tokenStream.token().value.toLowerCase() != "and"){ + this._unexpectedToken(tokenStream.token()); + } + + this._readWhitespace(); + expressions.push(this._media_expression()); + } + } + + return new MediaQuery(ident, type, expressions, token.startLine, token.startCol); + }, + + //CSS3 Media Queries + _media_type: function(){ + /* + * media_type + * : IDENT + * ; + */ + return this._media_feature(); + }, + + /** + * Note: in CSS3 Media Queries, this is called "expression". + * Renamed here to avoid conflict with CSS3 Selectors + * definition of "expression". Also note that "expr" in the + * grammar now maps to "expression" from CSS3 selectors. + * @method _media_expression + * @private + */ + _media_expression: function(){ + /* + * expression + * : '(' S* media_feature S* [ ':' S* expr ]? ')' S* + * ; + */ + var tokenStream = this._tokenStream, + feature = null, + token, + expression = null; + + tokenStream.mustMatch(Tokens.LPAREN); + this._readWhitespace(); + + feature = this._media_feature(); + this._readWhitespace(); + + if (tokenStream.match(Tokens.COLON)){ + this._readWhitespace(); + token = tokenStream.LT(1); + expression = this._expression(); + } + + tokenStream.mustMatch(Tokens.RPAREN); + this._readWhitespace(); + + return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null)); + }, + + //CSS3 Media Queries + _media_feature: function(){ + /* + * media_feature + * : IDENT + * ; + */ + var tokenStream = this._tokenStream; + + tokenStream.mustMatch(Tokens.IDENT); + + return SyntaxUnit.fromToken(tokenStream.token()); + }, + + //CSS3 Paged Media + _page: function(){ + /* + * page: + * PAGE_SYM S* IDENT? pseudo_page? S* + * '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col, + identifier = null, + pseudoPage = null; + + //look for @page + tokenStream.mustMatch(Tokens.PAGE_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + if (tokenStream.match(Tokens.IDENT)){ + identifier = tokenStream.token().value; + + //The value 'auto' may not be used as a page name and MUST be treated as a syntax error. + if (identifier.toLowerCase() === "auto"){ + this._unexpectedToken(tokenStream.token()); + } + } + + //see if there's a colon upcoming + if (tokenStream.peek() == Tokens.COLON){ + pseudoPage = this._pseudo_page(); + } + + this._readWhitespace(); + + this.fire({ + type: "startpage", + id: identifier, + pseudo: pseudoPage, + line: line, + col: col + }); + + this._readDeclarations(true, true); + + this.fire({ + type: "endpage", + id: identifier, + pseudo: pseudoPage, + line: line, + col: col + }); + + }, + + //CSS3 Paged Media + _margin: function(){ + /* + * margin : + * margin_sym S* '{' declaration [ ';' S* declaration? ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col, + marginSym = this._margin_sym(); + + if (marginSym){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this.fire({ + type: "startpagemargin", + margin: marginSym, + line: line, + col: col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endpagemargin", + margin: marginSym, + line: line, + col: col + }); + return true; + } else { + return false; + } + }, + + //CSS3 Paged Media + _margin_sym: function(){ + + /* + * margin_sym : + * TOPLEFTCORNER_SYM | + * TOPLEFT_SYM | + * TOPCENTER_SYM | + * TOPRIGHT_SYM | + * TOPRIGHTCORNER_SYM | + * BOTTOMLEFTCORNER_SYM | + * BOTTOMLEFT_SYM | + * BOTTOMCENTER_SYM | + * BOTTOMRIGHT_SYM | + * BOTTOMRIGHTCORNER_SYM | + * LEFTTOP_SYM | + * LEFTMIDDLE_SYM | + * LEFTBOTTOM_SYM | + * RIGHTTOP_SYM | + * RIGHTMIDDLE_SYM | + * RIGHTBOTTOM_SYM + * ; + */ + + var tokenStream = this._tokenStream; + + if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM, + Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM, + Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, + Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM, + Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, + Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM, + Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) + { + return SyntaxUnit.fromToken(tokenStream.token()); + } else { + return null; + } + + }, + + _pseudo_page: function(){ + /* + * pseudo_page + * : ':' IDENT + * ; + */ + + var tokenStream = this._tokenStream; + + tokenStream.mustMatch(Tokens.COLON); + tokenStream.mustMatch(Tokens.IDENT); + + //TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed + + return tokenStream.token().value; + }, + + _font_face: function(){ + /* + * font_face + * : FONT_FACE_SYM S* + * '{' S* declaration [ ';' S* declaration ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col; + + //look for @page + tokenStream.mustMatch(Tokens.FONT_FACE_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + this.fire({ + type: "startfontface", + line: line, + col: col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endfontface", + line: line, + col: col + }); + }, + + _viewport: function(){ + /* + * viewport + * : VIEWPORT_SYM S* + * '{' S* declaration? [ ';' S* declaration? ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col; + + tokenStream.mustMatch(Tokens.VIEWPORT_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + this.fire({ + type: "startviewport", + line: line, + col: col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endviewport", + line: line, + col: col + }); + + }, + + _operator: function(inFunction){ + + /* + * operator (outside function) + * : '/' S* | ',' S* | /( empty )/ + * operator (inside function) + * : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/ + * ; + */ + + var tokenStream = this._tokenStream, + token = null; + + if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) || + (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){ + token = tokenStream.token(); + this._readWhitespace(); + } + return token ? PropertyValuePart.fromToken(token) : null; + + }, + + _combinator: function(){ + + /* + * combinator + * : PLUS S* | GREATER S* | TILDE S* | S+ + * ; + */ + + var tokenStream = this._tokenStream, + value = null, + token; + + if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){ + token = tokenStream.token(); + value = new Combinator(token.value, token.startLine, token.startCol); + this._readWhitespace(); + } + + return value; + }, + + _unary_operator: function(){ + + /* + * unary_operator + * : '-' | '+' + * ; + */ + + var tokenStream = this._tokenStream; + + if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){ + return tokenStream.token().value; + } else { + return null; + } + }, + + _property: function(){ + + /* + * property + * : IDENT S* + * ; + */ + + var tokenStream = this._tokenStream, + value = null, + hack = null, + tokenValue, + token, + line, + col; + + //check for star hack - throws error if not allowed + if (tokenStream.peek() == Tokens.STAR && this.options.starHack){ + tokenStream.get(); + token = tokenStream.token(); + hack = token.value; + line = token.startLine; + col = token.startCol; + } + + if(tokenStream.match(Tokens.IDENT)){ + token = tokenStream.token(); + tokenValue = token.value; + + //check for underscore hack - no error if not allowed because it's valid CSS syntax + if (tokenValue.charAt(0) == "_" && this.options.underscoreHack){ + hack = "_"; + tokenValue = tokenValue.substring(1); + } + + value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol)); + this._readWhitespace(); + } + + return value; + }, + + //Augmented with CSS3 Selectors + _ruleset: function(){ + /* + * ruleset + * : selectors_group + * '{' S* declaration? [ ';' S* declaration? ]* '}' S* + * ; + */ + + var tokenStream = this._tokenStream, + tt, + selectors; + + + /* + * Error Recovery: If even a single selector fails to parse, + * then the entire ruleset should be thrown away. + */ + try { + selectors = this._selectors_group(); + } catch (ex){ + if (ex instanceof SyntaxError && !this.options.strict){ + + //fire error event + this.fire({ + type: "error", + error: ex, + message: ex.message, + line: ex.line, + col: ex.col + }); + + //skip over everything until closing brace + tt = tokenStream.advance([Tokens.RBRACE]); + if (tt == Tokens.RBRACE){ + //if there's a right brace, the rule is finished so don't do anything + } else { + //otherwise, rethrow the error because it wasn't handled properly + throw ex; + } + + } else { + //not a syntax error, rethrow it + throw ex; + } + + //trigger parser to continue + return true; + } + + //if it got here, all selectors parsed + if (selectors){ + + this.fire({ + type: "startrule", + selectors: selectors, + line: selectors[0].line, + col: selectors[0].col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endrule", + selectors: selectors, + line: selectors[0].line, + col: selectors[0].col + }); + + } + + return selectors; + + }, + + //CSS3 Selectors + _selectors_group: function(){ + + /* + * selectors_group + * : selector [ COMMA S* selector ]* + * ; + */ + var tokenStream = this._tokenStream, + selectors = [], + selector; + + selector = this._selector(); + if (selector !== null){ + + selectors.push(selector); + while(tokenStream.match(Tokens.COMMA)){ + this._readWhitespace(); + selector = this._selector(); + if (selector !== null){ + selectors.push(selector); + } else { + this._unexpectedToken(tokenStream.LT(1)); + } + } + } + + return selectors.length ? selectors : null; + }, + + //CSS3 Selectors + _selector: function(){ + /* + * selector + * : simple_selector_sequence [ combinator simple_selector_sequence ]* + * ; + */ + + var tokenStream = this._tokenStream, + selector = [], + nextSelector = null, + combinator = null, + ws = null; + + //if there's no simple selector, then there's no selector + nextSelector = this._simple_selector_sequence(); + if (nextSelector === null){ + return null; + } + + selector.push(nextSelector); + + do { + + //look for a combinator + combinator = this._combinator(); + + if (combinator !== null){ + selector.push(combinator); + nextSelector = this._simple_selector_sequence(); + + //there must be a next selector + if (nextSelector === null){ + this._unexpectedToken(tokenStream.LT(1)); + } else { + + //nextSelector is an instance of SelectorPart + selector.push(nextSelector); + } + } else { + + //if there's not whitespace, we're done + if (this._readWhitespace()){ + + //add whitespace separator + ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol); + + //combinator is not required + combinator = this._combinator(); + + //selector is required if there's a combinator + nextSelector = this._simple_selector_sequence(); + if (nextSelector === null){ + if (combinator !== null){ + this._unexpectedToken(tokenStream.LT(1)); + } + } else { + + if (combinator !== null){ + selector.push(combinator); + } else { + selector.push(ws); + } + + selector.push(nextSelector); + } + } else { + break; + } + + } + } while(true); + + return new Selector(selector, selector[0].line, selector[0].col); + }, + + //CSS3 Selectors + _simple_selector_sequence: function(){ + /* + * simple_selector_sequence + * : [ type_selector | universal ] + * [ HASH | class | attrib | pseudo | negation ]* + * | [ HASH | class | attrib | pseudo | negation ]+ + * ; + */ + + var tokenStream = this._tokenStream, + + //parts of a simple selector + elementName = null, + modifiers = [], + + //complete selector text + selectorText= "", + + //the different parts after the element name to search for + components = [ + //HASH + function(){ + return tokenStream.match(Tokens.HASH) ? + new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : + null; + }, + this._class, + this._attrib, + this._pseudo, + this._negation + ], + i = 0, + len = components.length, + component = null, + found = false, + line, + col; + + + //get starting line and column for the selector + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol; + + elementName = this._type_selector(); + if (!elementName){ + elementName = this._universal(); + } + + if (elementName !== null){ + selectorText += elementName; + } + + while(true){ + + //whitespace means we're done + if (tokenStream.peek() === Tokens.S){ + break; + } + + //check for each component + while(i < len && component === null){ + component = components[i++].call(this); + } + + if (component === null){ + + //we don't have a selector + if (selectorText === ""){ + return null; + } else { + break; + } + } else { + i = 0; + modifiers.push(component); + selectorText += component.toString(); + component = null; + } + } + + + return selectorText !== "" ? + new SelectorPart(elementName, modifiers, selectorText, line, col) : + null; + }, + + //CSS3 Selectors + _type_selector: function(){ + /* + * type_selector + * : [ namespace_prefix ]? element_name + * ; + */ + + var tokenStream = this._tokenStream, + ns = this._namespace_prefix(), + elementName = this._element_name(); + + if (!elementName){ + /* + * Need to back out the namespace that was read due to both + * type_selector and universal reading namespace_prefix + * first. Kind of hacky, but only way I can figure out + * right now how to not change the grammar. + */ + if (ns){ + tokenStream.unget(); + if (ns.length > 1){ + tokenStream.unget(); + } + } + + return null; + } else { + if (ns){ + elementName.text = ns + elementName.text; + elementName.col -= ns.length; + } + return elementName; + } + }, + + //CSS3 Selectors + _class: function(){ + /* + * class + * : '.' IDENT + * ; + */ + + var tokenStream = this._tokenStream, + token; + + if (tokenStream.match(Tokens.DOT)){ + tokenStream.mustMatch(Tokens.IDENT); + token = tokenStream.token(); + return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1); + } else { + return null; + } + + }, + + //CSS3 Selectors + _element_name: function(){ + /* + * element_name + * : IDENT + * ; + */ + + var tokenStream = this._tokenStream, + token; + + if (tokenStream.match(Tokens.IDENT)){ + token = tokenStream.token(); + return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol); + + } else { + return null; + } + }, + + //CSS3 Selectors + _namespace_prefix: function(){ + /* + * namespace_prefix + * : [ IDENT | '*' ]? '|' + * ; + */ + var tokenStream = this._tokenStream, + value = ""; + + //verify that this is a namespace prefix + if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){ + + if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){ + value += tokenStream.token().value; + } + + tokenStream.mustMatch(Tokens.PIPE); + value += "|"; + + } + + return value.length ? value : null; + }, + + //CSS3 Selectors + _universal: function(){ + /* + * universal + * : [ namespace_prefix ]? '*' + * ; + */ + var tokenStream = this._tokenStream, + value = "", + ns; + + ns = this._namespace_prefix(); + if(ns){ + value += ns; + } + + if(tokenStream.match(Tokens.STAR)){ + value += "*"; + } + + return value.length ? value : null; + + }, + + //CSS3 Selectors + _attrib: function(){ + /* + * attrib + * : '[' S* [ namespace_prefix ]? IDENT S* + * [ [ PREFIXMATCH | + * SUFFIXMATCH | + * SUBSTRINGMATCH | + * '=' | + * INCLUDES | + * DASHMATCH ] S* [ IDENT | STRING ] S* + * ]? ']' + * ; + */ + + var tokenStream = this._tokenStream, + value = null, + ns, + token; + + if (tokenStream.match(Tokens.LBRACKET)){ + token = tokenStream.token(); + value = token.value; + value += this._readWhitespace(); + + ns = this._namespace_prefix(); + + if (ns){ + value += ns; + } + + tokenStream.mustMatch(Tokens.IDENT); + value += tokenStream.token().value; + value += this._readWhitespace(); + + if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH, + Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){ + + value += tokenStream.token().value; + value += this._readWhitespace(); + + tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); + value += tokenStream.token().value; + value += this._readWhitespace(); + } + + tokenStream.mustMatch(Tokens.RBRACKET); + + return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol); + } else { + return null; + } + }, + + //CSS3 Selectors + _pseudo: function(){ + + /* + * pseudo + * : ':' ':'? [ IDENT | functional_pseudo ] + * ; + */ + + var tokenStream = this._tokenStream, + pseudo = null, + colons = ":", + line, + col; + + if (tokenStream.match(Tokens.COLON)){ + + if (tokenStream.match(Tokens.COLON)){ + colons += ":"; + } + + if (tokenStream.match(Tokens.IDENT)){ + pseudo = tokenStream.token().value; + line = tokenStream.token().startLine; + col = tokenStream.token().startCol - colons.length; + } else if (tokenStream.peek() == Tokens.FUNCTION){ + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol - colons.length; + pseudo = this._functional_pseudo(); + } + + if (pseudo){ + pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col); + } + } + + return pseudo; + }, + + //CSS3 Selectors + _functional_pseudo: function(){ + /* + * functional_pseudo + * : FUNCTION S* expression ')' + * ; + */ + + var tokenStream = this._tokenStream, + value = null; + + if(tokenStream.match(Tokens.FUNCTION)){ + value = tokenStream.token().value; + value += this._readWhitespace(); + value += this._expression(); + tokenStream.mustMatch(Tokens.RPAREN); + value += ")"; + } + + return value; + }, + + //CSS3 Selectors + _expression: function(){ + /* + * expression + * : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+ + * ; + */ + + var tokenStream = this._tokenStream, + value = ""; + + while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION, + Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH, + Tokens.FREQ, Tokens.ANGLE, Tokens.TIME, + Tokens.RESOLUTION, Tokens.SLASH])){ + + value += tokenStream.token().value; + value += this._readWhitespace(); + } + + return value.length ? value : null; + + }, + + //CSS3 Selectors + _negation: function(){ + /* + * negation + * : NOT S* negation_arg S* ')' + * ; + */ + + var tokenStream = this._tokenStream, + line, + col, + value = "", + arg, + subpart = null; + + if (tokenStream.match(Tokens.NOT)){ + value = tokenStream.token().value; + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + value += this._readWhitespace(); + arg = this._negation_arg(); + value += arg; + value += this._readWhitespace(); + tokenStream.match(Tokens.RPAREN); + value += tokenStream.token().value; + + subpart = new SelectorSubPart(value, "not", line, col); + subpart.args.push(arg); + } + + return subpart; + }, + + //CSS3 Selectors + _negation_arg: function(){ + /* + * negation_arg + * : type_selector | universal | HASH | class | attrib | pseudo + * ; + */ + + var tokenStream = this._tokenStream, + args = [ + this._type_selector, + this._universal, + function(){ + return tokenStream.match(Tokens.HASH) ? + new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : + null; + }, + this._class, + this._attrib, + this._pseudo + ], + arg = null, + i = 0, + len = args.length, + elementName, + line, + col, + part; + + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol; + + while(i < len && arg === null){ + + arg = args[i].call(this); + i++; + } + + //must be a negation arg + if (arg === null){ + this._unexpectedToken(tokenStream.LT(1)); + } + + //it's an element name + if (arg.type == "elementName"){ + part = new SelectorPart(arg, [], arg.toString(), line, col); + } else { + part = new SelectorPart(null, [arg], arg.toString(), line, col); + } + + return part; + }, + + _declaration: function(){ + + /* + * declaration + * : property ':' S* expr prio? + * | /( empty )/ + * ; + */ + + var tokenStream = this._tokenStream, + property = null, + expr = null, + prio = null, + error = null, + invalid = null, + propertyName= ""; + + property = this._property(); + if (property !== null){ + + tokenStream.mustMatch(Tokens.COLON); + this._readWhitespace(); + + expr = this._expr(); + + //if there's no parts for the value, it's an error + if (!expr || expr.length === 0){ + this._unexpectedToken(tokenStream.LT(1)); + } + + prio = this._prio(); + + /* + * If hacks should be allowed, then only check the root + * property. If hacks should not be allowed, treat + * _property or *property as invalid properties. + */ + propertyName = property.toString(); + if (this.options.starHack && property.hack == "*" || + this.options.underscoreHack && property.hack == "_") { + + propertyName = property.text; + } + + try { + this._validateProperty(propertyName, expr); + } catch (ex) { + invalid = ex; + } + + this.fire({ + type: "property", + property: property, + value: expr, + important: prio, + line: property.line, + col: property.col, + invalid: invalid + }); + + return true; + } else { + return false; + } + }, + + _prio: function(){ + /* + * prio + * : IMPORTANT_SYM S* + * ; + */ + + var tokenStream = this._tokenStream, + result = tokenStream.match(Tokens.IMPORTANT_SYM); + + this._readWhitespace(); + return result; + }, + + _expr: function(inFunction){ + /* + * expr + * : term [ operator term ]* + * ; + */ + + var tokenStream = this._tokenStream, + values = [], + //valueParts = [], + value = null, + operator = null; + + value = this._term(inFunction); + if (value !== null){ + + values.push(value); + + do { + operator = this._operator(inFunction); + + //if there's an operator, keep building up the value parts + if (operator){ + values.push(operator); + } /*else { + //if there's not an operator, you have a full value + values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); + valueParts = []; + }*/ + + value = this._term(inFunction); + + if (value === null){ + break; + } else { + values.push(value); + } + } while(true); + } + + //cleanup + /*if (valueParts.length){ + values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); + }*/ + + return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null; + }, + + _term: function(inFunction){ + + /* + * term + * : unary_operator? + * [ NUMBER S* | PERCENTAGE S* | LENGTH S* | ANGLE S* | + * TIME S* | FREQ S* | function | ie_function ] + * | STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor + * ; + */ + + var tokenStream = this._tokenStream, + unary = null, + value = null, + endChar = null, + token, + line, + col; + + //returns the operator or null + unary = this._unary_operator(); + if (unary !== null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + + //exception for IE filters + if (tokenStream.peek() == Tokens.IE_FUNCTION && this.options.ieFilters){ + + value = this._ie_function(); + if (unary === null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + + //see if it's a simple block + } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])){ + + token = tokenStream.token(); + endChar = token.endChar; + value = token.value + this._expr(inFunction).text; + if (unary === null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + tokenStream.mustMatch(Tokens.type(endChar)); + value += endChar; + this._readWhitespace(); + + //see if there's a simple match + } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH, + Tokens.ANGLE, Tokens.TIME, + Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){ + + value = tokenStream.token().value; + if (unary === null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + this._readWhitespace(); + } else { + + //see if it's a color + token = this._hexcolor(); + if (token === null){ + + //if there's no unary, get the start of the next token for line/col info + if (unary === null){ + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol; + } + + //has to be a function + if (value === null){ + + /* + * This checks for alpha(opacity=0) style of IE + * functions. IE_FUNCTION only presents progid: style. + */ + if (tokenStream.LA(3) == Tokens.EQUALS && this.options.ieFilters){ + value = this._ie_function(); + } else { + value = this._function(); + } + } + + /*if (value === null){ + return null; + //throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + "."); + }*/ + + } else { + value = token.value; + if (unary === null){ + line = token.startLine; + col = token.startCol; + } + } + + } + + return value !== null ? + new PropertyValuePart(unary !== null ? unary + value : value, line, col) : + null; + + }, + + _function: function(){ + + /* + * function + * : FUNCTION S* expr ')' S* + * ; + */ + + var tokenStream = this._tokenStream, + functionText = null, + expr = null, + lt; + + if (tokenStream.match(Tokens.FUNCTION)){ + functionText = tokenStream.token().value; + this._readWhitespace(); + expr = this._expr(true); + functionText += expr; + + //START: Horrible hack in case it's an IE filter + if (this.options.ieFilters && tokenStream.peek() == Tokens.EQUALS){ + do { + + if (this._readWhitespace()){ + functionText += tokenStream.token().value; + } + + //might be second time in the loop + if (tokenStream.LA(0) == Tokens.COMMA){ + functionText += tokenStream.token().value; + } + + tokenStream.match(Tokens.IDENT); + functionText += tokenStream.token().value; + + tokenStream.match(Tokens.EQUALS); + functionText += tokenStream.token().value; + + //functionText += this._term(); + lt = tokenStream.peek(); + while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ + tokenStream.get(); + functionText += tokenStream.token().value; + lt = tokenStream.peek(); + } + } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + } + + //END: Horrible Hack + + tokenStream.match(Tokens.RPAREN); + functionText += ")"; + this._readWhitespace(); + } + + return functionText; + }, + + _ie_function: function(){ + + /* (My own extension) + * ie_function + * : IE_FUNCTION S* IDENT '=' term [S* ','? IDENT '=' term]+ ')' S* + * ; + */ + + var tokenStream = this._tokenStream, + functionText = null, + expr = null, + lt; + + //IE function can begin like a regular function, too + if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){ + functionText = tokenStream.token().value; + + do { + + if (this._readWhitespace()){ + functionText += tokenStream.token().value; + } + + //might be second time in the loop + if (tokenStream.LA(0) == Tokens.COMMA){ + functionText += tokenStream.token().value; + } + + tokenStream.match(Tokens.IDENT); + functionText += tokenStream.token().value; + + tokenStream.match(Tokens.EQUALS); + functionText += tokenStream.token().value; + + //functionText += this._term(); + lt = tokenStream.peek(); + while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ + tokenStream.get(); + functionText += tokenStream.token().value; + lt = tokenStream.peek(); + } + } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + + tokenStream.match(Tokens.RPAREN); + functionText += ")"; + this._readWhitespace(); + } + + return functionText; + }, + + _hexcolor: function(){ + /* + * There is a constraint on the color that it must + * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F]) + * after the "#"; e.g., "#000" is OK, but "#abcd" is not. + * + * hexcolor + * : HASH S* + * ; + */ + + var tokenStream = this._tokenStream, + token = null, + color; + + if(tokenStream.match(Tokens.HASH)){ + + //need to do some validation here + + token = tokenStream.token(); + color = token.value; + if (!/#[a-f0-9]{3,6}/i.test(color)){ + throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); + } + this._readWhitespace(); + } + + return token; + }, + + //----------------------------------------------------------------- + // Animations methods + //----------------------------------------------------------------- + + _keyframes: function(){ + + /* + * keyframes: + * : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' { + * ; + */ + var tokenStream = this._tokenStream, + token, + tt, + name, + prefix = ""; + + tokenStream.mustMatch(Tokens.KEYFRAMES_SYM); + token = tokenStream.token(); + if (/^@\-([^\-]+)\-/.test(token.value)) { + prefix = RegExp.$1; + } + + this._readWhitespace(); + name = this._keyframe_name(); + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.LBRACE); + + this.fire({ + type: "startkeyframes", + name: name, + prefix: prefix, + line: token.startLine, + col: token.startCol + }); + + this._readWhitespace(); + tt = tokenStream.peek(); + + //check for key + while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) { + this._keyframe_rule(); + this._readWhitespace(); + tt = tokenStream.peek(); + } + + this.fire({ + type: "endkeyframes", + name: name, + prefix: prefix, + line: token.startLine, + col: token.startCol + }); + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.RBRACE); + + }, + + _keyframe_name: function(){ + + /* + * keyframe_name: + * : IDENT + * | STRING + * ; + */ + var tokenStream = this._tokenStream, + token; + + tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); + return SyntaxUnit.fromToken(tokenStream.token()); + }, + + _keyframe_rule: function(){ + + /* + * keyframe_rule: + * : key_list S* + * '{' S* declaration [ ';' S* declaration ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + token, + keyList = this._key_list(); + + this.fire({ + type: "startkeyframerule", + keys: keyList, + line: keyList[0].line, + col: keyList[0].col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endkeyframerule", + keys: keyList, + line: keyList[0].line, + col: keyList[0].col + }); + + }, + + _key_list: function(){ + + /* + * key_list: + * : key [ S* ',' S* key]* + * ; + */ + var tokenStream = this._tokenStream, + token, + key, + keyList = []; + + //must be least one key + keyList.push(this._key()); + + this._readWhitespace(); + + while(tokenStream.match(Tokens.COMMA)){ + this._readWhitespace(); + keyList.push(this._key()); + this._readWhitespace(); + } + + return keyList; + }, + + _key: function(){ + /* + * There is a restriction that IDENT can be only "from" or "to". + * + * key + * : PERCENTAGE + * | IDENT + * ; + */ + + var tokenStream = this._tokenStream, + token; + + if (tokenStream.match(Tokens.PERCENTAGE)){ + return SyntaxUnit.fromToken(tokenStream.token()); + } else if (tokenStream.match(Tokens.IDENT)){ + token = tokenStream.token(); + + if (/from|to/i.test(token.value)){ + return SyntaxUnit.fromToken(token); + } + + tokenStream.unget(); + } + + //if it gets here, there wasn't a valid token, so time to explode + this._unexpectedToken(tokenStream.LT(1)); + }, + + //----------------------------------------------------------------- + // Helper methods + //----------------------------------------------------------------- + + /** + * Not part of CSS grammar, but useful for skipping over + * combination of white space and HTML-style comments. + * @return {void} + * @method _skipCruft + * @private + */ + _skipCruft: function(){ + while(this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])){ + //noop + } + }, + + /** + * Not part of CSS grammar, but this pattern occurs frequently + * in the official CSS grammar. Split out here to eliminate + * duplicate code. + * @param {Boolean} checkStart Indicates if the rule should check + * for the left brace at the beginning. + * @param {Boolean} readMargins Indicates if the rule should check + * for margin patterns. + * @return {void} + * @method _readDeclarations + * @private + */ + _readDeclarations: function(checkStart, readMargins){ + /* + * Reads the pattern + * S* '{' S* declaration [ ';' S* declaration ]* '}' S* + * or + * S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* + * Note that this is how it is described in CSS3 Paged Media, but is actually incorrect. + * A semicolon is only necessary following a declaration is there's another declaration + * or margin afterwards. + */ + var tokenStream = this._tokenStream, + tt; + + + this._readWhitespace(); + + if (checkStart){ + tokenStream.mustMatch(Tokens.LBRACE); + } + + this._readWhitespace(); + + try { + + while(true){ + + if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){ + //noop + } else if (this._declaration()){ + if (!tokenStream.match(Tokens.SEMICOLON)){ + break; + } + } else { + break; + } + + //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){ + // break; + //} + this._readWhitespace(); + } + + tokenStream.mustMatch(Tokens.RBRACE); + this._readWhitespace(); + + } catch (ex) { + if (ex instanceof SyntaxError && !this.options.strict){ + + //fire error event + this.fire({ + type: "error", + error: ex, + message: ex.message, + line: ex.line, + col: ex.col + }); + + //see if there's another declaration + tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]); + if (tt == Tokens.SEMICOLON){ + //if there's a semicolon, then there might be another declaration + this._readDeclarations(false, readMargins); + } else if (tt != Tokens.RBRACE){ + //if there's a right brace, the rule is finished so don't do anything + //otherwise, rethrow the error because it wasn't handled properly + throw ex; + } + + } else { + //not a syntax error, rethrow it + throw ex; + } + } + + }, + + /** + * In some cases, you can end up with two white space tokens in a + * row. Instead of making a change in every function that looks for + * white space, this function is used to match as much white space + * as necessary. + * @method _readWhitespace + * @return {String} The white space if found, empty string if not. + * @private + */ + _readWhitespace: function(){ + + var tokenStream = this._tokenStream, + ws = ""; + + while(tokenStream.match(Tokens.S)){ + ws += tokenStream.token().value; + } + + return ws; + }, + + + /** + * Throws an error when an unexpected token is found. + * @param {Object} token The token that was found. + * @method _unexpectedToken + * @return {void} + * @private + */ + _unexpectedToken: function(token){ + throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); + }, + + /** + * Helper method used for parsing subparts of a style sheet. + * @return {void} + * @method _verifyEnd + * @private + */ + _verifyEnd: function(){ + if (this._tokenStream.LA(1) != Tokens.EOF){ + this._unexpectedToken(this._tokenStream.LT(1)); + } + }, + + //----------------------------------------------------------------- + // Validation methods + //----------------------------------------------------------------- + _validateProperty: function(property, value){ + Validation.validate(property, value); + }, + + //----------------------------------------------------------------- + // Parsing methods + //----------------------------------------------------------------- + + parse: function(input){ + this._tokenStream = new TokenStream(input, Tokens); + this._stylesheet(); + }, + + parseStyleSheet: function(input){ + //just passthrough + return this.parse(input); + }, + + parseMediaQuery: function(input){ + this._tokenStream = new TokenStream(input, Tokens); + var result = this._media_query(); + + //if there's anything more, then it's an invalid selector + this._verifyEnd(); + + //otherwise return result + return result; + }, + + /** + * Parses a property value (everything after the semicolon). + * @return {parserlib.css.PropertyValue} The property value. + * @throws parserlib.util.SyntaxError If an unexpected token is found. + * @method parserPropertyValue + */ + parsePropertyValue: function(input){ + + this._tokenStream = new TokenStream(input, Tokens); + this._readWhitespace(); + + var result = this._expr(); + + //okay to have a trailing white space + this._readWhitespace(); + + //if there's anything more, then it's an invalid selector + this._verifyEnd(); + + //otherwise return result + return result; + }, + + /** + * Parses a complete CSS rule, including selectors and + * properties. + * @param {String} input The text to parser. + * @return {Boolean} True if the parse completed successfully, false if not. + * @method parseRule + */ + parseRule: function(input){ + this._tokenStream = new TokenStream(input, Tokens); + + //skip any leading white space + this._readWhitespace(); + + var result = this._ruleset(); + + //skip any trailing white space + this._readWhitespace(); + + //if there's anything more, then it's an invalid selector + this._verifyEnd(); + + //otherwise return result + return result; + }, + + /** + * Parses a single CSS selector (no comma) + * @param {String} input The text to parse as a CSS selector. + * @return {Selector} An object representing the selector. + * @throws parserlib.util.SyntaxError If an unexpected token is found. + * @method parseSelector + */ + parseSelector: function(input){ + + this._tokenStream = new TokenStream(input, Tokens); + + //skip any leading white space + this._readWhitespace(); + + var result = this._selector(); + + //skip any trailing white space + this._readWhitespace(); + + //if there's anything more, then it's an invalid selector + this._verifyEnd(); + + //otherwise return result + return result; + }, + + /** + * Parses an HTML style attribute: a set of CSS declarations + * separated by semicolons. + * @param {String} input The text to parse as a style attribute + * @return {void} + * @method parseStyleAttribute + */ + parseStyleAttribute: function(input){ + input += "}"; // for error recovery in _readDeclarations() + this._tokenStream = new TokenStream(input, Tokens); + this._readDeclarations(); + } + }; + + //copy over onto prototype + for (prop in additions){ + if (additions.hasOwnProperty(prop)){ + proto[prop] = additions[prop]; + } + } + + return proto; +}(); + + +/* +nth + : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? | + ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S* + ; +*/ +/*global Validation, ValidationTypes, ValidationError*/ +var Properties = { + + //A + "align-items" : "flex-start | flex-end | center | baseline | stretch", + "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch", + "align-self" : "auto | flex-start | flex-end | center | baseline | stretch", + "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch", + "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch", + "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch", + "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | | ", + "alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical", + "animation" : 1, + "animation-delay" : { multi: "