From 688f1e9e753cbe64040338a19773009dc88fa6e9 Mon Sep 17 00:00:00 2001 From: Nate Stemen Date: Fri, 11 Aug 2017 09:23:36 +0100 Subject: [PATCH] merged staticManager with snippetManager --- .../auto-complete/AutoCompleteManager.coffee | 6 +- .../auto-complete/SnippetManager.coffee | 85 ++++++++++++++++++- .../StaticSuggestionManager.coffee | 81 ------------------ 3 files changed, 84 insertions(+), 88 deletions(-) delete mode 100644 services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/StaticSuggestionManager.coffee diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee index fc164176a3..5b02c6b6bb 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee @@ -1,10 +1,9 @@ define [ "ide/editor/directives/aceEditor/auto-complete/SuggestionManager" "ide/editor/directives/aceEditor/auto-complete/SnippetManager" - "ide/editor/directives/aceEditor/auto-complete/StaticSuggestionManager" "ace/ace" "ace/ext-language_tools" -], (SuggestionManager, SnippetManager, StaticSuggestionManager) -> +], (SuggestionManager, SnippetManager) -> Range = ace.require("ace/range").Range aceSnippetManager = ace.require('ace/snippets').snippetManager @@ -45,8 +44,6 @@ define [ SnippetCompleter = new SnippetManager() - StaticCommandCompleter = new StaticSuggestionManager() - labelsManager = @labelsManager LabelsCompleter = getCompletions: (editor, session, pos, prefix, callback) -> @@ -117,7 +114,6 @@ define [ @editor.completers = [@suggestionManager, SnippetCompleter, - StaticCommandCompleter, ReferencesCompleter, LabelsCompleter] diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SnippetManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SnippetManager.coffee index 7b7593565d..7927a2cd6f 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SnippetManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SnippetManager.coffee @@ -1,4 +1,73 @@ define () -> + noArgumentCommands = [ + 'item', 'hline', 'lipsum', 'centering', 'noindent', 'textwidth', 'draw', + 'maketitle', 'newpage', 'verb', 'bibliography', 'fi', 'hfill', 'par', + 'in', 'sum', 'cdot', 'alpha', 'ldots', 'else', 'linewidth', 'left', + 'right', 'today', 'clearpage', 'newline', 'endinput', 'mu', + 'tableofcontents', 'vfill', 'bigskip', 'fill', 'cleardoublepage', + ] + singleArgumentCommands = [ + 'chapter', 'usepackage', 'section', 'label', 'textbf', 'subsection', + 'vspace', 'cite', 'textit', 'documentclass', 'includegraphics', 'input', + 'emph','caption', 'ref', 'title', 'author', 'texttt', 'include', + 'hspace', 'bibitem', 'url', 'large', 'subsubsection', 'textsc', 'date', + 'footnote', 'small', 'thanks', 'underline', 'graphicspath', 'pageref', + 'section*', 'subsection*', 'subsubsection*', 'sqrt', 'text', + 'normalsize', 'Large', 'paragraph', 'pagestyle', 'thispagestyle', + 'bibliographystyle', + ] + doubleArgumentCommands = [ + 'newcommand', 'frac', 'renewcommand', 'setlength', 'href', 'newtheorem', + ] + tripleArgumentCommands = [ + 'addcontentsline', 'newacronym', 'multicolumn' + ] + special = ['LaTeX', 'TeX'] + + noArgumentCommands = for com in noArgumentCommands + { + caption: "\\#{com}" + snippet: "\\#{com}" + meta: "cmd" + } + singleArgumentCommands = for com in singleArgumentCommands + { + caption: "\\#{com}{}" + snippet: "\\#{com}{$1}" + meta: "cmd" + } + doubleArgumentCommands = for com in doubleArgumentCommands + { + caption: "\\#{com}{}{}" + snippet: "\\#{com}{$1}{$2}" + meta: "cmd" + } + tripleArgumentCommands = for com in tripleArgumentCommands + { + caption: "\\#{com}{}{}{}" + snippet: "\\#{com}{$1}{$2}{$3}" + meta: "cmd" + } + special = for cmd in special + if cmd == 'TeX' + { + caption: "\\TeX{}" + snippet: "\\TeX{}" + meta: "cmd" + } + else if com == 'LaTeX' + { + caption: "\\LaTeX{}" + snippet: "\\LaTeX{}" + meta: "cmd" + } + + staticCommands = [].concat(noArgumentCommands, + singleArgumentCommands, + doubleArgumentCommands, + tripleArgumentCommands, + special) + environments = [ "abstract", "align", "align*", @@ -6,7 +75,9 @@ define () -> "gather", "gather*", "multline", "multline*", "split", - "verbatim" + "verbatim", + "quote", + "center" ] staticSnippets = for env in environments @@ -95,7 +166,17 @@ define () -> \\end{frame} """ meta: "env" - }] + }, { + caption: "\\begin{thebibliography}..." + snippet: """ + \\begin{thebibliography}{$1} + \\bibitem{$2} + $3 + \\end{thebibliography} + """ + }] + + staticSnippets = staticSnippets.concat staticCommands parseCustomEnvironments = (text) -> diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/StaticSuggestionManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/StaticSuggestionManager.coffee deleted file mode 100644 index df5153a833..0000000000 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/StaticSuggestionManager.coffee +++ /dev/null @@ -1,81 +0,0 @@ -define () -> - noArgumentCommands = [ - 'item', 'hline', 'lipsum', 'centering', 'noindent', 'textwidth', 'draw', - 'maketitle', 'newpage', 'verb', 'bibliography', 'fi', 'hfill', 'par', - 'in', 'sum', 'cdot', 'alpha', 'ldots', 'else', 'linewidth', 'left', - 'right', 'today', 'clearpage', 'newline', 'endinput', 'mu', - 'tableofcontents', 'vfill', 'bigskip', 'fill', 'cleardoublepage', - ] - singleArgumentCommands = [ - 'chapter', 'usepackage', 'section', 'label', 'textbf', 'subsection', - 'vspace', 'cite', 'textit', 'documentclass', 'includegraphics', 'input', - 'emph','caption', 'ref', 'title', 'author', 'texttt', 'include', - 'hspace', 'bibitem', 'url', 'large', 'subsubsection', 'textsc', 'date', - 'footnote', 'small', 'thanks', 'underline', 'graphicspath', 'pageref', - 'section*', 'subsection*', 'subsubsection*', 'sqrt', 'text', - 'normalsize', 'Large', 'paragraph', 'pagestyle', 'thispagestyle', - 'bibliographystyle', - ] - doubleArgumentCommands = [ - 'newcommand', 'frac', 'renewcommand', 'setlength', 'href', 'newtheorem', - ] - tripleArgumentCommands = [ - 'addcontentsline', 'newacronym', 'multicolumn' - ] - special = ['def', 'let', 'LaTeX'] - - noArgumentCommands = for com in noArgumentCommands - { - caption: "\\#{com}" - snippet: "\\#{com}" - meta: "cmd" - } - singleArgumentCommands = for com in singleArgumentCommands - { - caption: "\\#{com}{}" - snippet: "\\#{com}{$1}" - meta: "cmd" - } - doubleArgumentCommands = for com in doubleArgumentCommands - { - caption: "\\#{com}{}{}" - snippet: "\\#{com}{$1}{$2}" - meta: "cmd" - } - tripleArgumentCommands = for com in tripleArgumentCommands - { - caption: "\\#{com}{}{}{}" - snippet: "\\#{com}{$1}{$2}{$3}" - meta: "cmd" - } - special = for com in special - if com == 'def' - { #should be improved - caption: "\\def{}" - snippet: "\\def$1{$2}" - meta: "cmd" - } - else if com == 'let' - { #should be improved - caption: "\\let" - snippet: "\\let" - meta: "cmd" - } - else if com == 'LaTeX' - { - caption: "\\LaTeX{}" - snippet: "\\LaTeX{}" - meta: "cmd" - } - - staticCommands = [].concat(noArgumentCommands, - singleArgumentCommands, - doubleArgumentCommands, - tripleArgumentCommands, - special) - - class StaticSuggestionManager - getCompletions: (editor, session, pos, prefix, callback) -> - callback null, staticCommands - - return StaticSuggestionManager