# File: text.coffee

Defined in: | node_modules/grunt-codo/node_modules/codo/node_modules/haml-coffee/src/util

## Variables Summary

module.exports =

      {

        /*
        Whitespace helper function.

        @param [Number] n the number if indents
        @return [String] the indention string
         */
        whitespace: function(n) {
          var a;
          n = n * 2;
          a = [];
          while (a.length < n) {
            a.push(' ');
          }
          return a.join('');
        },

        /*
        Escape quotation in a text.

        @param [String] text the text containing quotes
        @return [String] the escaped text
         */
        escapeQuotes: function(text) {
          if (!text) {
            return '';
          }
          return text.replace(/"/g, '\\"').replace(/\\\\\"/g, '\\"');
        },

        /*
        Unescape quotation in a text.

        @param [String] text the text containing escaped quotes
        @return [String] the text without escaped quotes
         */
        unescapeQuotes: function(text) {
          if (!text) {
            return '';
          }
          return text.replace(/\\"/g, '"');
        },

        /*
        HTML Escape a text.

        @param [String] text the text
        @return [String] the HTML escaped text
         */
        escapeHTML: function(text) {
          if (!text) {
            return '';
          }
          return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;');
        },

        /*
        Preserve newlines within the preserve tags,

        @param [String] code the code to preserve
        @return [String] the preserved code
         */
        preserve: function(code) {
          if (code) {
            code.replace(/\r/g, '');
            return code.replace(/<(pre|textarea)>(.*?)<\/\1>/g, function(text) {
              return text.replace('\\n', '\&\#x000A;');
            });
          }
        },

        /*
        Indent the given text.

        @param [String] text the text to indent
        @param [Integer] the amount of spaced to insert
        @return [String] the indented text
         */
        indent: function(text, spaces) {
          return text.replace(/^(.*)$/mg, module.exports.whitespace(spaces) + '$1');
        }
      }

  Global text helpers

Quickly fuzzy find classes, mixins, methods, file:

- T Open fuzzy finder dialog

Control the navigation frame:

- L Toggle list view
- C Show class list
- I Show mixin list
- F Show file list
- M Show method list
- E Show extras list

You can focus and blur the search input:

- S Focus search input
- Esc Blur search input