rhtml.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * rhtml.js
  3. *
  4. * Copyright (C) 2009-11 by RStudio, Inc.
  5. *
  6. * The Initial Developer of the Original Code is
  7. * Ajax.org B.V.
  8. * Portions created by the Initial Developer are Copyright (C) 2010
  9. * the Initial Developer. All Rights Reserved.
  10. *
  11. * Distributed under the BSD license:
  12. *
  13. * Copyright (c) 2010, Ajax.org B.V.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions are met:
  18. * * Redistributions of source code must retain the above copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. * * Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * * Neither the name of Ajax.org B.V. nor the
  24. * names of its contributors may be used to endorse or promote products
  25. * derived from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  28. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  29. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  31. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  32. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  33. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  34. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  36. */
  37. define(function(require, exports, module) {
  38. "use strict";
  39. var oop = require("../lib/oop");
  40. var HtmlMode = require("./html").Mode;
  41. var RHtmlHighlightRules = require("./rhtml_highlight_rules").RHtmlHighlightRules;
  42. /* Make life easier, don't do these right now
  43. var SweaveBackgroundHighlighter = require("mode/sweave_background_highlighter").SweaveBackgroundHighlighter;
  44. var RCodeModel = require("mode/r_code_model").RCodeModel;
  45. */
  46. var Mode = function(doc, session) {
  47. HtmlMode.call(this);
  48. this.$session = session;
  49. this.HighlightRules = RHtmlHighlightRules;
  50. /* Or these.
  51. this.codeModel = new RCodeModel(doc, this.$tokenizer, /^r-/,
  52. /^<!--\s*begin.rcode\s*(.*)/);
  53. this.foldingRules = this.codeModel;
  54. this.$sweaveBackgroundHighlighter = new SweaveBackgroundHighlighter(
  55. session,
  56. /^<!--\s*begin.rcode\s*(?:.*)/,
  57. /^\s*end.rcode\s*-->/,
  58. true); */
  59. };
  60. oop.inherits(Mode, HtmlMode);
  61. (function() {
  62. this.insertChunkInfo = {
  63. value: "<!--begin.rcode\n\nend.rcode-->\n",
  64. position: {row: 0, column: 15}
  65. };
  66. this.getLanguageMode = function(position)
  67. {
  68. return this.$session.getState(position.row).match(/^r-/) ? 'R' : 'HTML';
  69. };
  70. /* this.getNextLineIndent = function(state, line, tab, tabSize, row)
  71. {
  72. return this.codeModel.getNextLineIndent(row, line, state, tab, tabSize);
  73. }; */
  74. this.$id = "ace/mode/rhtml";
  75. }).call(Mode.prototype);
  76. exports.Mode = Mode;
  77. });