/*
  How Properties of Mime Types are used by SQL Mode
  =================================================

  keywords:
    A list of keywords you want to be highlighted.
  builtin:
    A list of builtin types you want to be highlighted (if you want types to be of class "builtin" instead of "keyword").
  operatorChars:
    All characters that must be handled as operators.
  client:
    Commands parsed and executed by the client (not the server).
  support:
    A list of supported syntaxes which are not common, but are supported by more than 1 DBMS.
    * ODBCdotTable: .tableName
    * zerolessFloat: .1
    * doubleQuote
    * nCharCast: N'string'
    * charsetCast: _utf8'string'
    * commentHash: use # char for comments
    * commentSlashSlash: use // for comments
    * commentSpaceRequired: require a space after -- for comments
  atoms:
    Keywords that must be highlighted as atoms,. Some DBMS's support more atoms than others:
    UNKNOWN, INFINITY, UNDERFLOW, NaN...
  dateSQL:
    Used for date/time SQL standard syntax, because not all DBMS's support same temporal types.
*/

/* eat */

/* global define */

/* package java.lang */

/* scala */

/*!
  Copyright (c) 2018 Jed Watson.
  Licensed under the MIT License (MIT), see
  http://jedwatson.github.io/classnames
*/

/**
 * Author: Gautam Mehta
 * Branched from CodeMirror's Scheme mode
 */

/**
 * Link to the project's GitHub page:
 * https://github.com/pickhardt/coffeescript-codemirror-mode
 */

/** @license React v16.14.0
 * react.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

/*, mode, …*/

/*, values...*/

/*keywords*/

//

//                                                          12   3tail

//      PERL blocks

//      PERL functions

//      PERL operators

//      PERL predefined variables (I know, what this is a paranoid idea, but may be needed for people, who learn PERL, and for me as well, ...and may be for you?;)

//     Pos(0, 1, ...)

//     before   after

//   ! ~ \ and unary + and -

//   1 - keyword

//   2 - def

//   3 - atom

//   4 - operator

//   5 - variable-2 (predefined)

//   [x,y] - x=1,2,3; y=must be defined if x{...}

//   etc. ???

//   list operators (rightward)

//   named unary operators

//   null - magic touch

// "Complex" syntax

// "add"/null, "subtract", or "prev". When aggressive is false

// "group" (to the start of next group of word or

// "gutter", "class", "widget"

// "identifier"

// "line", "div" (display.lineDiv), "local"./null (editor), "window",

// "page" or "line". The resulting position will have a hitSide=true

// #3261: make sure, that we're not starting a second selection

// % (ET):  European Number Terminator

// '%' operator

// 'Project' the visible viewport to cover the area that is being

// 'other' property containing the position of the secondary cursor

// 'simulates' scrolling that position into view in a cheap way, so

// 'string', with char specified in quote escaped by '\'

// 'wrap f in an operation, performed on its `this` parameter'.

// (Adjust for extended bound, if necessary.)

// (Less wasteful than consing up a hundred closures on every call.)

// (and non-touching) ranges, sorted, and an integer that indicates

// (backwards compatibility) while at the same time support features

// (comments) in between. Fallback is to only notice when we hit the

// (ctrl-click), rectangle drag (alt-drag), or xwin

// (left-to-right), or an array of sections ({from, to, level}

// (markTextShared will call out to this again, once per

// (not linked ones).

// (returning false) when there is nothing to be done and forced is

// (typically set to true for forced single-line indents), empty

// (when the bar is hidden). If it is still visible, we keep

// + (ES):  European Number Separator

// , (CS):  Common Number Separator

// - Compile pattern

// - SysV IPC message control operations

// - SysV semaphore control operations

// - SysV semaphore operations

// - SysV shared memory operations

// - abandon this program to run another

// - absolute value function

// - accept an incoming socket connect

// - add or remove elements anywhere in an array

// - append one or more elements to an array

// - apply a change to a list to get back a new list with the changes

// - arctangent of Y/X in the range -PI to PI

// - backquote quote a string

// - be done using group file

// - be done using hosts file

// - be done using networks file

// - be done using passwd file

// - be done using protocols file

// - be done using services file

// - bind a variable to an object class

// - binds an address to a socket

// - block for some number of seconds

// - break a tie binding to a variable

// - break out of a "given" block

// - breaks binding on a tied dbm file

// - catch exceptions or compile and run code

// - change a filename

// - change the ownership on a list of files

// - change your current working directory

// - changes the permissions on a list of files

// - clear all variables of a given name

// - close directory handle

// - close down just half of a socket connection

// - close file (or pipe or socket) handle

// - connect to a remote socket

// - convert UNIX time into record or string using Greenwich time

// - convert UNIX time into record or string using local time

// - convert a list into a binary representation

// - convert a string to a hexadecimal number

// - convert a string to an octal number

// - convert binary structure into normal perl variables

// - cosine function

// - create a directory

// - create a hard link in the filesystem

// - create a new process just like this one

// - create a pair of sockets

// - create a socket

// - create a symbolic link to a file

// - create a temporary value for a global variable (dynamic scoping)

// - create an immediate core dump

// - create an object

// - create binding on a tied dbm file

// - create spaghetti code

// - declare a picture format with use by the write() function

// - declare a separate global namespace

// - declare a subroutine, possibly anonymously

// - declare and assign a local variable (lexical scoping)

// - declare and assign a package variable (lexical scoping)

// - declare and assign a state variable (persistent lexical scoping)

// - deletes a value from a hash

// - determine where a symbolic link is pointing

// - doubly quote a string

// - execute a system command and collect standard output

// - execute an arbitrary system call

// - exit a block prematurely

// - expand filenames using wildcards

// - fetch a record from a file

// - file control system call

// - find a character's numeric representation

// - find a substring within a string

// - find or set the offset for the last/next m//g search

// - find out the type of thing being referenced

// - find the other end of a socket connection

// - fixed-length buffered input from a filehandle

// - fixed-length unbuffered input from a filehandle

// - fixed-length unbuffered output to a filehandle

// - flip a string or a list

// - force a scalar context

// - formatted print into a string

// - get SysV IPC message queue

// - get SysV shared memory segment identifier

// - get a directory from a directory handle

// - get a file's status information

// - get a reference to the object underlying a tied variable

// - get a thread lock on a variable, subroutine, or method

// - get character this number represents

// - get context of the current subroutine call

// - get current nice value

// - get current seekpointer on a directory handle

// - get current seekpointer on a filehandle

// - get group record given group name

// - get group record given group user ID

// - get host record given its address

// - get host record given name

// - get network record given its address

// - get networks record given name

// - get next group record

// - get next hosts record

// - get next networks record

// - get next passwd record

// - get next protocols record

// - get next services record

// - get or alter a portion of a string

// - get out of a function early

// - get parent process ID

// - get passwd record given user ID

// - get passwd record given user login name

// - get process group

// - get protocol record given name

// - get protocol record numeric protocol

// - get services record given its name

// - get services record given numeric port

// - get set of SysV semaphores

// - get socket options on a given socket

// - get the integer portion of a number

// - get the next character from the filehandle

// - get the prototype (if any) of a subroutine

// - get void vs scalar vs list context of current subroutine call

// - internal function used for formats

// - iterate a block prematurely

// - join a list into a string using a separator

// - load in a module at compile time

// - load in external functions from a library at runtime

// - locate elements in a list test true against a given criterion

// - lock an entire file with an advisory lock

// - make directory new root for path lookups

// - match a string with a regular expression pattern

// - one-way passwd-style encryption

// - open a directory

// - open a file, pipe, or descriptor

// - open a pair of connected filehandles

// - optimize input data for repeated searches

// - optional trailing block in a while or foreach

// - output a formatted list to a filehandle

// - output a list to a filehandle

// - patch a module's namespace into your own

// - position I/O pointer on handle used with sysread and syswrite

// - prepare binary files for I/O

// - prepare group file for use

// - prepare hosts file for use

// - prepare networks file for use

// - prepare passwd file for use

// - prepare protocols file for use

// - prepare services file for use

// - prepend more elements to the beginning of a list

// - print a picture record

// - print debugging info

// - print with newline

// - quote a list of words

// - quote regular expression magic characters

// - raise I to a power

// - raise an exception or bail out

// - read SysV shared memory

// - receive a SysV IPC message from a message queue

// - receive a message over a Socket

// - regexp $1, $2...

// - register your socket as a server

// - remove a directory

// - remove a trailing record separator from a string

// - remove a variable or function definition

// - remove one link to a file

// - remove the first element of an array, and return it

// - remove the last character from a string

// - remove the last element from an array and return it

// - replace a pattern with a string

// - reposition directory pointer

// - reposition file pointer for random-access I/O

// - reset default output or do I/O multiplexing

// - reset directory handle

// - retrieve list of indices from a hash

// - retrieve the natural logarithm for a number

// - retrieve the next key/value pair from a hash

// - retrieve the next pseudorandom number

// - retrieve the sockaddr for a given socket

// - return a list of the values in a hash

// - return a string with just the next letter in lower case

// - return a string with just the next letter in upper case

// - return elapsed time for self and child processes

// - return file descriptor from filehandle

// - return lower-case version of a string

// - return number of seconds since 1970

// - return the number of bytes in a string

// - return the sine of a number

// - return upper-case version of a string

// - return who logged in at this tty

// - right-to-left substring search

// - run a separate program

// - schedule a SIGALRM

// - seed the random number generator

// - send a SysV IPC message to a message queue

// - send a message over a socket

// - send a signal to a process or process group

// - set a file's last access and modify times

// - set a process's nice value

// - set file creation mode mask

// - set some socket options

// - set the process group of a process

// - shorten a file

// - singly quote a string

// - sort a list of values

// - split up a string using a regexp delimiter

// - square root function

// - start this loop iteration over again

// - stat a symbolic link

// - system-dependent device control system call

// - terminate this program

// - test a filehandle for its end

// - test or set particular bits in a string

// - test whether a hash key is present

// - test whether a value, variable, or function is defined

// - transliterate a string

// - turn a BLOCK into a TERM

// - unimport some module symbols or semantics at compile time

// - wait for a particular child process to die

// - wait for any child process to die

// - write SysV shared memory

// -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the

// -- for invalidation -- followed by pairs of end positions and

// .1 for 0.1

// .table_name (ODBC)

// // ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html

// 1 (EN):  European Number

// 1-line comment

// 1-line comments

// :+ :- :/ :* :| :& :! are valid symbols

// :> :>> :< :<< are valid symbols

// <delim> can be a string up to 16 characters long.

// @@prefix.varName @varName

// A CodeMirror instance represents an editor. This is the object

// A Pos instance represents a position within the text.

// A binary search to find the first character whose bounding box

// A bug in IE8 can cause this value to be negative, so guard it.

// A cursor Pos(line, char, "after") is on the same visual line as `char`

// A cursor Pos(line, char, "before") is on the same visual line as `char - 1`

// A generic SQL Mode. It's not a standard, it just try to support what is generally supported

// A lineView may contain multiple logical lines (when merged by

// A mouse down can be a single click, double click, triple click,

// A new event is started when the previous origin does not match

// A shared marker spans multiple linked documents. It is

// A styles array always starts with a number identifying the

// A visibility: hidden element used to find the size of things.

// A visual line is a line as drawn on the screen. Folding, for

// AB     B|A     B|A

// AL is found, change the type of the European number to Arabic

// AMD

// Ab     |Ab     A|b

// Abort measurement, if in progress

// Abort mouse wheel delta measurement, when scrolling explicitly

// Accumulated changes, for firing change events

// Actual scrollable element.

// Add a span to a line.

// Add new sub-event

// Add on and off methods to a constructor's prototype, to make

// Adds "Select all" to context menu in FF

// Adjust a position to refer to the post-change position of the

// Adjust the line structure

// After finding a start of a string ('|") this function attempts to find the end;

// After the variable name there may appear array or object operator.

// All nodes have parent links. The tree is used both to go from

// Allow "beforeChange" event handlers to influence a change

// Alphabetic keys

// Already drawn

// An optional function that takes a {string} token and returns true if it

// Apache uses a slightly different Media Type for Shell scripts

// Apply a change to a document, and add it to the document's

// Are we in a definition (class, node, define)?

// Are we in an 'include' statement?

// Arrays of change events and selections. Doing something adds an

// At any point we are certain `to` satisfies `pred`, don't know

// Attach a document to an editor.

// Attach the necessary event handlers when initializing the editor

// Automatic semicolon insertion

// BIDI HELPERS

// Bail out if the visible area is already rendered and nothing changed.

// Because Android doesn't allow us to actually detect backspace

// Become the parent node

// Behavior of elts with overflow: auto and padding is

// Bidi parts are sorted left-to-right, and in a non-line-wrapping

// BidiSpan objects otherwise.

// Bidirectional ordering algorithm

// Binary

// Block keywords start new blocks, except 'else if', which only starts

// Bottom overlap

// Briefly turn off draggability, to allow widgets to do

// Build a line's DOM representation from scratch

// Build up a reverse change object to add to the opposite history

// Build up a set of ranges to kill first, merging overlapping

// Build up the DOM representation for a single token, and add it to

// By default, updates that start and end at the beginning of a line

// C type is defined as those that are reserved by the compiler (basicTypes),

// C#-style strings where "" escapes a quote.

// C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where

// CONTENTEDITABLE INPUT STYLE

// CONTEXT MENU HANDLING

// Calculate a new scroll position needed to scroll the given

// Call f for all linked documents.

// Called when the window resizes

// Called whenever the selection changes, sets the new selection as

// Calls delayed callbacks and cursorActivity handlers until no

// Can not be merged, start a new event.

// Cancel the current text selection if any (#5821)

// Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines,

// Case 2: We move within an rtl part or in an rtl editor on the same visual line

// Case 3: Could not move within this bidi part in this visual line, so leave

// Case 3a: Look for other bidi parts on the same visual line

// Case 3b: Look for other bidi parts on the next visual line

// Case 4: Nowhere to move

// Ceylon Strings need to deal with interpolation

// Change after

// Change before

// Change some spaces to NBSP to prevent the browser from collapsing

// Change the content (text, markers) of a line. Automatically

// Character types for codepoints 0 to 0xff

// Character types for codepoints 0x600 to 0x6f9

// Characters

// Check that lines don't extend past the right of the current

// Class expressions may have an optional name.

// Class variables and instance variables

// Clear the marker.

// Clear the view.

// Clip forced viewport to actual scrollable area.

// Clip the change to the size of this doc

// Clip the part to the wrapped line.

// Closing tag spotted

// CodeMirror 1 mode.

// CodeMirror, copyright (c) by Marijn Haverbeke and others

// CodeMirror.prototype, for backwards compatibility and

// CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08)

// Collapsed markers have unique ids, in order to be able to order

// Combinator utils

// Combinators

// Commands are parameter-less actions that can be performed on an

// Comments

// CommonJS

// Communicate our context to the combinators.

// Compare two positions, return 0 if they are the same, a negative

// Compute a style array (an array starting with a mode generation

// Compute a suitable new viewport (from & to)

// Compute the base array of styles

// Compute the character length of a line, taking into account

// Compute the character position closest to the given coordinates.

// Compute the default character width.

// Compute the default text height.

// Compute the lines that are visible in a given viewport (defaults

// Compute the position of the end of a change (its 'to' property

// Compute the relative visual position of the head compared to the

// Compute whether a line is hidden. Lines count as hidden when they

// Computes display.scroller.scrollLeft + display.gutters.offsetWidth,

// Connect or disconnect spans from a line.

// Constants and types

// Context management

// Context may be "window", "page", "div", or "local"./null.

// Continuing lines, if any

// Convert a style as returned by a mode (either null, or a string

// Converts a {top, bottom, left, right} box from line-local

// Count the number of lines in the view whose DOM representation is

// Counts the column offset in a string, taking tabs into account.

// Covers bottom of gutter when coverGutterNextToScrollbar is on

// Covers bottom-right square when both scrollbars are present.

// Coverts a box from "div" coords to another coordinate system.

// Create a history change event from an updateDoc-style change

// Create a marker, wire it up to the right lines, and

// Create a range of LineView objects for the given lines.

// Created to support specific hive keywords

// Created with markText and setBookmark methods. A TextMarker is a

// Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,

// Current rendered range (may be bigger than the view window).

// Cursor-blinking

// DISPLAY DRAWING

// DOCUMENT DATA STRUCTURE

// DOM structure.

// Decimal

// Decimal literals may be "imaginary"

// Dedent relative to current context.

// Default to positioning above (if specified and possible); otherwise default to positioning below

// Detach a line from the document tree and its markers.

// Detect drag-and-drop

// Determine effective options based on given values and defaults.

// Determine if we should prevent the cursor being placed to the left/right of an atomic marker

// Determines whether an event happened in the gutter, and fires the

// Distinguish coordinates nearer to the left or right side of the box

// Distributed under an MIT license: https://codemirror.net/5/LICENSE

// Distributed under an MIT license: https://codemirror.net/LICENSE

// Do a bulk-read of the DOM positions and sizes needed to draw the

// Do we have Puppet specific words?

// Do we just have a function on our hands?

// Does the actual updating of the line display. Bails out

// Doesn't consider line feeds a character.

// Doesn't do anything on an empty line.

// Doesn't do anything with non-empty selections.

// Doesn't scan more than one line above to find a character.

// Don't connect empty markers unless clearWhenEmpty is false

// Don't do a replace if the drop happened inside of the selected text.

// Don't leave long text in the textarea, since it makes further polling slow

// Don't match the @interface keyword.

// Draws a cursor for the given range

// Draws the given range as a highlighted selection

// Due to the fact that we still support jurassic IE versions, some

// EDITOR CONSTRUCTOR

// EVENT HANDLING

// EXTENSIONS

// Elements are added to these to represent selection and cursors.

// Empty space (in pixels) above the view

// Ensure a given position is not inside an atomic range.

// Ensure at least a single node is present, for measuring.

// Ensure is a {from: {line, ch}, to: {line, ch}} object, and

// Ensure previous input has been read, so that the handler sees a

// Ensure that, if the cursor was in the whitespace at the start

// Ensure the editor is re-focused

// Ensure the lineView.wrapping.heights array is populated. This is

// Ensure there's a token end at the current position, and that i points at it

// Ensure we are in an operation.

// Escape characters that have special regex meanings.

// Escapes

// Esper

// Every position after the last character on a line is considered to stick

// Examples (upper-case letters are RTL, lower-case are LTR):

// Extend all selections (pos is an array of selections with length

// Extend the primary selection range, discard the rest.

// Extending unicode characters. A series of a non-extending char +

// Extra arguments are stored as the mode's dependencies, which is

// FIXME

// FIXME function decls are also not block scoped

// FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems

// Fails unpredictably on IE[67] when mouse is dragged around quickly.

// Fall back to "prev" when the mode doesn't have an indentation

// Fall through means this is global

// Feature-detect IE's crummy client rect reporting for bidi text

// Fed to the mode parsers, provides helper functions to make

// Fetch the parser token for a given character. Useful for hacks

// Fill gap with whole-line-spans

// Fill in a browser-detected starting value on browsers where we

// Find a line map (mapping character offsets to text nodes) and a

// Find a line view that corresponds to the given line number.

// Find out whether a line ends or starts in a collapsed span. If

// Find the height above the given line.

// Find the line at the given vertical position, using the height

// Find the line object corresponding to the given line number.

// Find the longest line in the document.

// Find the part of the input that is actually new

// Find the part that overlaps with the start of this text

// Find the position of the marker in the document. Returns a {from,

// Find the top change event in the history. Pop off selection

// Find the view element corresponding to a given line. Return null

// Find the word at the given position (as returned by coordsChar).

// Finds the line to start with when starting a parse. Tries to

// Finish an operation, updating the display and signalling delayed events

// Fire change events, and delayed event handlers

// Fire events for markers that are hidden/unidden by editing or

// First move into "page" coordinate system

// First, search the line map for the text node corresponding to,

// Fix up .from in last (or move them into first in case of sameLine)

// Fix up .to properties of first

// Flag that indicates that lines might need to be redrawn

// Flag that indicates whether we expect input to appear real soon

// Float literals may be "imaginary"

// Floats

// For C and C++ (and ObjC): identifiers starting with __

// For PostgreSQL - https://www.postgresql.org/docs/11/sql-keywords-appendix.html

// For big changes, we hide the enclosing element during the

// For pl/pgsql lang - https://github.com/postgres/postgres/blob/REL_11_2/src/pl/plpgsql/src/pl_scanner.c

// For relative vertical movement. Dir may be -1 or 1. Unit can be

// Force a relayout, or Opera won't use our image for some obscure reason

// Force the view to cover a given range, adding empty view element

// From here, the methods are part of the public interface. Most

// Full overlap

// Function keys

// Functions to run when options are changed.

// Gap in the middle

// Get a {top, bottom, left, right} box (in line-local coordinates)

// Get the bidi ordering for the given line (and cache it). Returns

// Get the line number of the start of the next visual line after

// Get the line number of the start of the visual line that the

// Get the lines between from and to, as array of strings.

// Get the part of a document between two positions, as an array of

// Get the spans that 'stick out' on both sides

// Give beforeSelectionChange handlers a change to influence a

// Given a MIME type, a {name, ...options} config object, or a name

// Given a change object, compute the new set of marker spans that

// Given a line object, find its line number by walking up through

// Given a mode and a state (for that mode), find the inner mode and

// Given a mode spec (anything that resolveMode accepts), find and

// Given a mouse event, find the corresponding position. If liberal

// Given a prepared measurement object, measures the position of an

// Go through the main process

// Google's SQL-like query language, GQL

// Greenplum

// HIGHLIGHT WORKER

// Handle Comments

// Handle Number Literals

// Handle Strings

// Handle a key from the keydown event.

// Handle a key from the keypress event

// Handle decorators

// Handle docco title comment (single line)

// Handle indentation for {x -> \n ... }

// Handle multi line comments

// Handle non-detected items

// Handle number literals

// Handle operators and delimiters

// Handle regex literals

// Handle scope changes

// Handle scope changes.

// Handle strings

// Handle the interaction of a change to a document with the editor

// Have we found a string?

// Have we found a variable?

// Have we matched the prior attribute regex?

// Have we matched the prior resource regex?

// Have we matched the prior special_resource regex?

// Helper for deleting text near the selection(s), used to implement

// Helper for phpString

// Helper used to collapse a small branch into a single leaf.

// Helpers used when computing which overlapping collapsed span

// Here Docs

// Here we depart from the documented algorithm, in order to avoid

// Hex

// Historically this was determined using the inclusiveLeft/Right option, but the new way to control it

// Holds info about a single rendered line when it was rendered

// IANA registered media type

// IE < 10 will throw when accessed while the page is loading or in an iframe.

// IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.

// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.

// IE does strange things with escape.

// IE doesn't fire input events, so we schedule a read for the pasted content in this way

// IE's approach to draggable

// IE8 will throw if the textarea is display: none or not in DOM

// If a box around the coordinates was found, use that

// If a variable is encountered along the way, we display it differently when it

// If an editor sits on the top or bottom of the window, partially

// If border: 0; -- iOS fails to open keyboard (issue #1287)

// If e is null or undefined we interpret this as someone trying

// If it is a text node, use a range to retrieve the coordinates.

// If it is a widget, simply get the box for the whole widget.

// If nothing changed, bail.

// If pos == Pos(_, 0, "before"), pos and end are unchanged

// If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch

// If shift is held or the extend flag is set, extends a range to

// If so, go through the loop again

// If so, return def (i.e. for 'class myclass {' ; 'myclass' would be matched)

// If the histories were shared, split them again

// If the line isn't plain left-to-right text, first figure out

// If the max line changed since it was last measured, measure it,

// If the result is smaller than 25 lines, ensure that it is a

// If this isn't the first part, the part's start is also after

// If we need to scroll a specific position into view, do so.

// Ignore this hook.

// In 'ensure_resource("myclass")', 'ensure_resource' is matched

// In Ceylon all identifiers that start with an uppercase are types

// In a wrapped line, rtl text on wrapping boundaries can do things

// Indent multi-line strings (e.g. css).

// Indent the given line. The how parameter can be "smart",

// Indent the starts of attribute names.

// Information about the rendered lines.

// Input must be lineSpace-local ("div" coordinate system).

// Insert the given array of lines at offset 'at', count them as

// Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.

// Integer literals may be "long"

// Integers

// Interface

// Intermediate scroll position, not pushed to DOM yet

// Is there a match on a reference?

// It also indexes by height, and is used to convert between height

// Iterate over the document. Supports two forms -- with only one

// Iterate over the logical lines that make up this visual line.

// KEYMAP DISPATCH

// Keep advancing through all the rest

// Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.

// Kludge to prevent 'maybelse' from blocking lexical scope pops

// Kludge to work around strange IE behavior where it'll sometimes

// Kludges for bugs and behavior differences that can't be feature

// Known modes, by name and by MIME

// L (L):   Left-to-Right

// LINE DATA STRUCTURE

// LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's

// Label for screenreaders, accessibility

// Let the drag handler handle this.

// Lightweight event framework. on/off also work on DOM nodes,

// Lightweight form of highlight -- proceed over this line and

// Line objects. These hold state related to a line, including

// Line widgets are block elements displayed above or below a line.

// Lines with gutter elements, widgets or a background class need to

// Listen to wheel events in order to try and update the viewport on time.

// Look up the name of a key as indicated by an event object.

// Loop over the elements in the view, syncing cur (the DOM nodes

// Macro variables

// Macros

// Main function

// Make sure that at the end of the operation the current cursor is

// Make sure we didn't create any zero-length spans

// Match all the brackets

// Match all the comments. All of them.

// Match all the numbers

// Match and return the included class

// Match array operator

// Match characters that we are going to assume

// Match object operator

// Match the '=' and '=>' operators

// Match the full reference

// Match the rest it the next time around

// Matches attributes (i.e. ensure => present ; 'ensure' would be matched)

// Matches one whole word

// Measure a bunch of lines, for browsers that compute

// Measurement can be split in two steps, the set-up work that

// Merge this change into the last event

// Might be a file drop, in which case we simply extract the text

// Might be a text scaling operation, clear size caches.

// Minimal default mode.

// Modifier key presses don't count as 'real' key presses for the

// More lower-level change function, handling only a single document

// Most of the external API clips given positions to make sure they

// Move cursor behind the two swapped characters afterwards.

// Move the hidden textarea near the cursor to prevent scrolling artifacts

// Move y into line-local coordinate space

// Moved around its parent to cover visible view.

// Multiple lines

// Must be '('

// MySQL/MariaDB identifiers

// N (ON):  Other Neutrals

// N1. A sequence of neutrals takes the direction of the

// N2. Any remaining neutrals take the embedding direction.

// NOTE: "m", "s", "y" and "tr" need to correct real modifiers for each regexp type

// NOTE: ' or " or <<'SOMETHING'\n...\nSOMETHING\n or <<"SOMETHING"\n...\nSOMETHING\n

// NOTE: <<SOMETHING\n...\nSOMETHING\n

// NOTE: \n=item...\n=cut\n

// NOTE: chain.length > 2 is not working now (it's for s[...][...]geos;)

// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).

// Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)

// Negate the next()

// Negates the initial next()

// Neutral.

// Next, remove those actual ranges.

// Non-public interface for adding and removing lines.

// Normal behavior is to insert the new text into every selection

// Normal drop

// Normal selection, as opposed to text dragging.

// Normal string

// Not drawn yet

// Note that the save and find-related commands aren't defined by

// Note that, despite the name, this function is also used to check

// Now get accurate coordinates for this place, in order to get a

// Number keys

// Number of logical lines in this visual line

// Number of pixels added to scroller and sizer to hide scrollbar

// Numbers

// Octal

// Often, we want to signal events at a point where we are in the

// Old-fashioned briefly-focus-a-textarea hack

// Older IE's will not fire a second mousedown for a double click

// On Android Chrome (version 56, at least), backspacing into an

// On Chrome 102, viewport updates somehow stop wheel-based

// On some browsers, horizontal scrolling will cause redraws to

// One-char codes used for character types:

// Only one ? ! = is allowed and only as the last character

// Only prevent default scrolling if vertical scrolling is

// Opening tag spotted

// Opera has no cut event... we try to at least catch the key combo

// Opera is difficult.

// Operations are used to wrap a series of changes to the editor

// Operators

// Optimize some code when these features are not used.

// Optimized case for simple insertion -- don't want to add

// Optionally wire in some hacks into the token-rendering

// Otherwise return an invalid variable

// Otherwise, simply returns the range between the given positions.

// Our model of the DOM might be outdated, in which case the range we try to set can be impossible

// Outputs a number of spans to make up a line, taking highlighting

// Override magic textarea content restore that IE sometimes does

// POSITION MEASUREMENT

// Parens and braces

// Parser

// Pass the `paste` event to the textarea so it's handled by its event listener.

// Passed to option handlers when there is no old value.

// Perform a change on the document data structure.

// Plain browser env

// Poll for input changes, using the normal rate of polling. This

// Pop all selection events off the end of a history array. Stop at

// Pos objects returned contain a line object, rather than a line

// Position the mover div to align with the current scroll position

// Positions returned by coordsChar contain some extra information.

// Possibly split or suppress the update based on the presence

// Prepare DOM reads needed to update the scrollbars. Done in one

// Prevent clicks in the scrollbars from killing focus

// Prevent normal selection in the editor (we handle our own)

// Prevent selection and cursors from interfering with the scroll

// Prevent this from being ran twice

// Prevent wrapper from ever scrolling

// Propagate the scroll position to the actual DOM scroller

// Propagate to the linked documents

// Public alias.

// Quit if there's nothing to scroll here

// R (R):   Right-to-Left

// Raw strings.

// Re-align line numbers and gutter marks to compensate for

// Re-set this, in case some other handler touched the

// Re-synchronize the fake scrollbars with the actual size of the

// Read and store the height of line widgets associated with the

// Read input from the textarea, and update the document to match.

// Read the actual heights of the rendered lines, and update their

// Rebasing/resetting history to deal with externally-sourced changes

// Rebuild the gutter elements, ensure the margin to the left of the

// Redraw the line's text. Interacts with the background and text

// Redraw the selection and/or cursor

// Regexps

// Register a change in the history. Merges changes that are within

// Register a change to a single line. Type must be one of "text",

// Remember that these lines changed, for updating the display

// Remove a span from an array, returning undefined if no spans are

// Remove spans that are empty and don't have a clearWhenEmpty

// Remove the n lines at offset 'at'.

// Render a line into the hidden node display.externalMeasured. Used

// Render the DOM representation of the text of a line. Also builds

// Reset the current text selection only if the click is done outside of the selection

// Reset the input to correspond to the selection (or to be empty,

// Reset the selection to a single range.

// Resume indentation from parent context.

// Retrieve and filter the old marked spans stored in a change event.

// Retry a maximum of 4 times when nonsense rectangles are returned

// Return a selection that does not partially select any atomic

// Return true when the given mouse event happened in a widget

// Return variables for tokenizers

// Returned or thrown by various protocols to signal 'I'm not

// Returns a box for a given cursor position, which may have an

// Returns a function that estimates the height of a line, to use as

// Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.

// Returns a number indicating which of two overlapping collapsed

// Returns an array of logical lines that continue the visual line

// Returns null if characters are ordered as they appear

// Returns the value from the range [`from`; `to`] that satisfies

// Returns true if identifier is a "C" type.

// Returns true if identifier is a "Objective C" type.

// Returns true if the given side of a box is after the given

// Revert a change stored in a document's history.

// Run a handler that was bound to a key.

// Run overlays, adjust style array.

// Run the given function in an operation

// Run the given mode's parser over a line, calling f for each token.

// SCROLLBARS

// SCROLLING THINGS INTO VIEW

// SHARED TEXTMARKERS

// SQLite is weakly typed, ref: http://sqlite.org/datatype3.html. This is just a list of some common types.

// STRING STREAM

// SVG-specific

// Safari returns null in some cases (#2780)

// Scroll a given position into view (immediately), verifying that

// Scroll a given set of coordinates into view (immediately).

// Search an array of spans for a span matching the given marker.

// Secondary cursor, shown when on a 'jump' in bi-directional text

// See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html

// See http://unicode.org/reports/tr9/tr9-13.html for the algorithm

// See if "".split is the broken IE version, if so, provide an

// See input.poll and input.reset

// See issue #2901

// Select-all will be greyed out if there's nothing to select, so

// Selection objects are immutable. A new one is created every time

// Self-resetting timeout for the poller

// Send an event to consumers responding to changes in gutter width.

// Set a new selection.

// Set autofocus to true if this textarea is focused, or if it has

// Set of handlers to fire cursorActivity on

// Set pos and end to the cursor positions around the character pos sticks to

// Set to the height of the document, allowing scrolling.

// Set to true when a non-horizontal-scrolling line widget is

// Set up methods on CodeMirror's prototype to redirect to the editor's document.

// Set when the widest line needs to be determined anew

// Shared markers (across linked documents) are handled separately

// Should we still be looking for the end of a string?

// Showing up as a widget implies collapsed (widget replaces text)

// Signals that the marker's widget changed, and surrounding layout

// Simple syntax

// Since the delta values reported on mouse wheel events are

// Since this is called a *lot*, try to bail out as cheaply as

// Single line

// Single line comment

// Some browsers fire contextmenu *after* opening the menu, at

// Some browsers fire keypress events for backspace

// Some browsers use the wrong event properties to signal cmd/ctrl on OS X

// Spark SQL

// Standard SQL /SQLite identifiers

// Start a new operation.

// Start a text drag. When it ends, see if any dragging actually

// Start it all

// Store a relative adjustment to the scroll position in the current

// Store some values that we'll need later (but don't want to force a relayout for)

// Store the map and a cache object for the current logical line

// Store the type (single or double)

// Stores the words from the define method

// Strings

// Strings or regexps or macro variables or '%' operator

// Strip the spaces, but regex will account for them eitherway

// Sub-views need their line numbers shifted when text is added

// Such overlap is not allowed.

// Suppress optimizelegibility in Webkit, since it breaks text

// Swap the two chars left and right of each selection's head.

// Swift mode created by Michael Kaminsky https://github.com/mkaminsky11

// Symbols can't start by a digit

// Symbols or ':' operator

// Sync editor state

// Sync scroller and scrollbar, ensure the gutter elements are

// Sync scrolling between fake scrollbars and real scrollable

// Sync the actual display DOM structure with display.view, removing

// Sync the scrollable area and scrollbars, ensure the viewport

// TEXTAREA INPUT STYLE

// TEXTMARKER SPANS

// TEXTMARKERS

// TODO - Can you have imaginary longs?

// Take an unsorted, potentially overlapping set of ranges, and

// Taken, mostly, from the Puppet official variable standards regex

// Takes a string of words separated by spaces and adds them as

// Takes commonly known puppet types/words and classifies them to a style

// Test whether there exists a collapsed span that partially

// The 'scroll' parameter given to many of these indicated whether

// The DOM events that CodeMirror handles can be overridden by

// The DOM updates done when an operation finishes are batched so

// The awkward -1 offsets are needed because findFirst (called

// The default configuration options.

// The display handles the DOM integration, both for input reading

// The document is represented as a BTree consisting of leaves, with

// The element in which the editor lives.

// The inverse of countColumn -- find the offset that corresponds to

// The padding-right forces the element to have a 'border', which

// The preferred way to escape Identifiers is using double quotes, ref: http://sqlite.org/lang_keywords.html

// The publicly visible API. Note that methodOp(f) means

// The reason we want to know the amount a wheel event will scroll

// The returned object contains the DOM node, this map, and

// The semihidden textarea that is focused when the editor is

// The spans will have null for their from/to properties when the

// The starting line

// The textarea is kept positioned near the cursor to prevent the

// There is *some* kind of drag-and-drop support in IE6-8, but I

// There might have been a widget with a focused element that got

// These must be handled carefully, because naively registering a

// These objects are used to represent the visible (currently drawn)

// These should all be Unicode extended, as per the Haskell 2010 report

// These two are, on init, called from the constructor because they

// This attribute is respected by automatic translation systems such as Google Translate,

// This can be used to attach properties to mode objects from

// This hack (see related code in patchDisplay) makes sure the

// This is CodeMirror (https://codemirror.net/5), a code editor

// This is a crude lookahead trick to try and notice that we're

// This is a kludge to keep keymaps mostly working as raw objects

// This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl (mail@sabaca.com)

// This is a whole-line replace. Treated specially to make

// This is not the complete set of editor methods. Most of the

// This test prevents this from firing when a context

// This will be set to a {lineWise: bool, text: [string]} object, so

// Thus, in rtl, we are looking for the first (content-order) character

// To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.

// To determine which side to associate with, get the box to the

// To find out whether the scrollbar is still visible, we

// To make the context menu work, we need to briefly unhide the

// Tokenizers

// Top overlap

// Tracks the maximum line length so that the horizontal scrollbar

// Tracks which cursorActivity handlers have been called already

// Tries to rebase an array of history events given a change in the

// True when shift is held down.

// Try to move start of change to start of selection if ambiguous

// Try to skip TypeScript return type declarations after the arguments

// Turn mouse into crosshair when Alt is held on Mac.

// UPDATING

// Unfinished key sequence

// Unicode strings/chars.

// Unique ID

// Update current marker set

// Update the height of a line, propagating the height change

// Updated line heights might result in the drawn area not

// Updates a single range in the selection.

// Updates the display.view data structure for a given change to the

// Used as scratch variables to communicate multiple values without

// Used both to provide a JSON-safe object in .getHistory, and, when

// Used by replaceSelections to allow moving the selection to the

// Used by the isClean() method

// Used for cursor motion and such.

// Used for horizontal relative motion. Dir is -1 or 1 (left or

// Used for measuring wheel scrolling granularity

// Used for the algorithm that adjusts markers for a change in the

// Used for un/re-doing changes from the history. Combines the

// Used mostly to find indentation.

// Used to 'clip' out readOnly ranges when making a change.

// Used to add methods to editor and doc instances, wrapping them in

// Used to catch context-menu undo

// Used to cheaply estimate the coordinates for a position. Used for

// Used to detect need to update scrollbar

// Used to ensure that the line number gutter is still the right

// Used to ensure timeout re-tries don't fire when another extend

// Used to force a redraw

// Used to get the editor into a consistent state again when options change.

// Used to iterate over a part of the tree.

// Used to only resize the line number gutter when necessary (when

// Used to scroll to a specific position

// Used to store marked span information in the history.

// Used to suppress mouse event handling when a touch happens

// Used to track when changes can be merged into a single undo

// Used to track whether anything happened since the context menu

// Used to work around IE issue with selection being forgotten when focus moves away from textarea

// Used when mouse-selecting to adjust the anchor to the proper side

// Utility for applying a change to a line by handle or number,

// Utility for getTokenAt and getLineTokens

// Variables and keywords

// Verify that the selection does not partially select any atomic

// Very basic readline/emacs-style bindings, which are standard on Mac.

// Visible

// W1. Examine each non-spacing mark (NSM) in the level run, and

// W2. Search backwards from each instance of a European number

// W3. Change all ALs to R.

// W4. A single European separator between two European numbers

// W5. A sequence of European terminators adjacent to European

// W6. Otherwise, separators and terminators change to Other

// W7. Search backwards from each instance of a European number

// We want to process these words differently

// Webkit browsers on OS X abort momentum scrolls when the target

// Webkit seems to refuse to render text nodes longer than 57444

// When a node has grown, check whether it should be split.

// When an 'electric' character is inserted, immediately trigger a reindent

// When an aspect of a line changes, a string is added to

// When an event has just come in that is likely to add or change

// When an operation has its scrollToPos property set, and another

// When directly calling `measureCharPrepared`, we have to adjust

// When lines outside of the viewport are measured, they are drawn in this.

// When pasting N lines into N selections, insert one line per selection

// When something is selected, it is present in the textarea, and

// When the window loses focus, we want to show the editor as blurred

// When un/re-doing restores text containing marked spans, those

// Whether the selection needs to be redrawn

// Whether this reset should be careful to leave existing text (for compositing)

// Whether to reset the input textarea

// Will contain the actual code, positioned to cover the viewport.

// Will contain the gutters, if any.

// With a wrapped rtl chunk (possibly spanning multiple bidi parts),

// Work around Chrome issue (#2712)

// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)

// Work around fat-arrow-detection complication for detecting typescript typed arrow params

// Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206

// Work around nonsense dimensions being reported for stretches of

// Work around nonsensical selection resetting in IE9/10, and

// Work around problem with bounding client rects on ranges being

// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)

// Works around a throw-scroll bug in OS X Webkit

// Wrapper around buildLineContent which will reuse the structure

// Wraps a function in an operation. Returns the wrapped function.

// Wraps and hides input textarea

// Wraps everything that needs to exist inside the vertically-padded coordinate system

// You can find some technical background for some of the code below

// Zero by itself with no other piece of number.

// \N means NULL

// \g, etc

// `identifier`

// `pred` and is closest to `from`. Assumes that at least `to`

// a change event.

// a particular column.

// a single operation, or are close together with an origin that

// aB     a|B     aB|

// ab     a|b     a|b

// above or below them in the parent document.

// actual character (or fetches it from the cache).

// actual scrolling happens, reducing flickering.

// actually covering the viewport. Keep looping until it does.

// actually exist within the document.

// actually hit the arrow token. It only works if the arrow is on

// actually possible. Otherwise, it causes vertical scroll

// added. As an optimization, line widget aligning is skipped when

// additional methods and properties).

// advance stream by at least one character so we don't get stuck.

// algorithm, to deal with browser quirks.

// aligned.

// all, so a binary search doesn't work, and we want to return a

// allows merging (starting with "+") into a single event.

// alternative way to split lines.

// an array of bottom offsets for the lines that make up a drawn

// anchor (<0 is to the left, >0 to the right)

// and 'resetSelectionOnContextMenu' option is true.

// and after `char - 1` in writing order of `char - 1`

// and also looks for line-wide styles.

// and before `char` in writing order of `char`

// and content drawing. It holds references to DOM nodes and

// and end-of-level-run (eor) are used at level run boundaries.

// and ensure the document's width matches it.

// and h scrollbar is present.

// and insert it.

// and line object, and to find the total height of the document.

// and marked text into account.

// and may also be respected by tools used by human translators.

// and preventDefault-ing the event in that handler.

// and returns null if it was. forRect is used by rectangular

// and simulates a backspace press in this case.

// and then, because it's not editable, hide the virtual keyboard.

// and those that end in _t (Reserved by POSIX for types)

// and, from that, detects the way it can convert deltas to pixel

// any number of extending chars is treated as a single unit as far

// applies to the whole line, and the measurement of the actual

// are also available from CodeMirror (editor) instances.

// are left alone.

// are part of a visual line that starts with another line, or when

// are simply ignored.

// are treated specially, in order to make the association of line

// are trying to be regex

// area, ensure viewport is updated when scrolling.

// aren't currently visible.

// argument, it calls that for each line in the document. With

// arrays with one element for each line in (after) the change.

// arrow, and not declare the arguments as locals for the arrow

// as editing and measuring is concerned. This is not fully correct,

// as the last (content-order) character).

// at http://marijnhaverbeke.nl/blog/#cm-internals .

// autofocus and no other element is focused.

// b (BN):  Boundary Neutral

// backspace, delete, and similar functionality.

// base X position

// be wrapped, and have the extra elements added to the wrapper div

// before the event, the event's positions are updated. Uses a

// being wrong would just be a slight flicker on the first wheel

// better than glitching out.

// bind-parameters ref:http://sqlite.org/lang_expr.html#varparam

// bitstring

// body.

// brackets

// build a selection out of it. 'Consumes' ranges array (modifying

// building up an actual levels array. Since there are only three

// bumped when mode/overlay changes, used to invalidate highlighting info

// but using getBoundingClientRect to get a sub-pixel-accurate

// call hooks from the mime type

// can be kept static when scrolling.

// change is on 3

// change the type of the NSM to the type of the previous

// changed.

// changes to a European number. A single common separator between

// character position, returning an array of remaining chunks (or

// character. Functions like coordsChar, that need to do a lot of

// character. If the NSM is at the start of the level run, it will

// characters in the part's range

// characters, and returns inaccurate measurements in nodes

// charset casting: _utf8'str', N'str', n'str'

// check whether the element under the pixel in the bottom

// chunk of lines in them, and branches, with up to ten leaves or

// classes because the mode may output tokens that influence these

// classes.

// code matches their width.

// collapsed ranges (see markText) that might hide parts, and join

// collapsed spans). The widgets for all of them need to be drawn.

// combined and executed at once.

// commands of the official SQLite client, ref: https://www.sqlite.org/cli.html#dotcmd

// comment

// comparing ids when the spans cover exactly the same range.

// compatibility wrappers are needed.

// consing up tons of objects.

// consistent view of the document

// contain multiple lines when collapsed ranges are present.)

// containing one or more styles) to a CSS style. This is cached,

// content.

// convenience.

// coordinates

// coordinates beyond the right of the text.

// coordinates into another coordinate system. Context may be one of

// coordinates, in top-to-bottom, left-to-right order.

// coordinates.

// coordsCharInner is safe. As such, we first find the extent of the

// copy-on-write scheme for the positions, to avoid having to

// couldn't get it to work yet.

// counts as the larger one.

// cover the line in which the change took place. Removes spans

// covers the visible area.

// cursor and display (which would be awkward, slow, and

// date.

// dates (standard SQL syntax)

// dates (weird ODBC syntax)

// default parsing mode

// default. User code or addons can define them. Unknown commands

// detaching a document, to split the history in two

// detected are enabled based on userAgent etc sniffing.

// different (in number of selected ranges, emptiness, or time).

// different reference viewports and invalidate our calculations.

// direction. European and Arabic numbers act as if they were R in

// display-related state.

// do to the importance they have in Puppet

// document).

// document. From and to are in pre-change coordinates. Lendiff is

// document. If the change touches the same lines as the event, the

// document. Line objects hold arrays (markedSpans) containing

// document. These functions cut an array of spans at a given

// doesn't cross line boundaries), "word" (across next word), or

// eating and vomiting a part of stream from current position

// editor width

// editor, mostly used for keybindings.

// element is kept around.

// entirely within the change, reconnects spans belonging to the

// equal the number of selections)

// error-prone). Instead, display updates are batched and then all

// escape constant: E'str', e'str'

// estimated pixels/delta value, we just handle horizontal

// event

// event to done and clears undo. Undoing moves events from done

// event, and everything 'behind' it, is discarded. If the change is

// events that are in the way.

// example, can cause multiple logical lines to appear on the same

// existed in the history (so that deleting around a span and then

// explicit embedding into account, we can build up the order on

// fact that it'll be scrolled into view on input from scrolling

// false for lines that are fully left-to-right, and an array of

// false.

// find a line with a stateAfter, so that it can start with a

// first approximation until the line becomes visible (and is thus

// focused, and receives input.

// for a given character.

// for bound mouse clicks.

// for measurement, while not in view.

// for the widgets at this line.

// forces those lines into the viewport (if possible).

// found, then change the type of the European number to L.

// fractional heights.

// garbage collected.

// generally horribly unpredictable, this code starts by measuring

// get the type of sor.

// given line is part of (usually that is the line itself).

// given line number is part of.

// given line.

// handle that can be used to clear or find a marked position in the

// handled in onMouseDown for these browsers.

// handler for each editor will cause the editors to never be

// handlers for the corresponding event.

// handling this'.

// happen before the gutter has been realigned, causing it to

// happen, and treat as a click if it didn't.

// happened in the meantime (clearTimeout isn't reliable -- at

// have to be initialized before the editor can start at all.

// having the given height.

// height, and ensure (see op.scrollToPos) properties.

// height.

// help recognize paste/cut edits in input.poll

// hex

// hidden or updated, if so re-focus it.

// highlighting info (the styles array).

// highlighting overlays, as added by addOverlay

// highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting

// history, and propagating it to all linked documents.

// hitSide=true property if it reached the end of the document.

// horizontal scrolling.

// http://perldoc.perl.org

// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types

// http://www.espertech.com/esper/release-5.5.0/esper-reference/html/appendix_keywords.html

// http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html

// https://github.com/codemirror/CodeMirror/pull/5673

// https://www.iana.org/assignments/media-types/

// https://www.postgresql.org/docs/11/datatype.html

// iOS exposes the clipboard API, but seems to discard content inserted into it

// if the clear happens after their scheduled firing time).

// ignore {{ in f-str

// implemented as a meta-marker-object controlling multiple normal

// implemented in JavaScript on top of the browser's DOM.

// in display.externalMeasured when possible.

// in display.lineDiv) with the view as we go.

// in the rtl chunk that is on the last line (that is, the same line

// in which case reading its value would be expensive.

// include a given position (and optionally a second position).

// inconsistent across browsers. This is used to ensure the

// indicating that such a marker is present on that line. Multiple

// inexplicable appearance of private area unicode characters on

// information about line-wide styles that were set by the mode.

// information in the document tree.

// initialize an actual mode object.

// intermediate scroll updates.

// invalidates cached information and tries to re-estimate the

// is called Cassandra to avoid confusion with Contextual Query Language

// is encapsulated in a double-quoted string.

// is false, it checks whether a gutter or scrollbar was clicked,

// is large (issue #3579)

// is needed on Webkit to be able to get line-level bounding

// is needed.

// is that it gives us a chance to update the display before the

// is true, that means the coordinates lie outside the line's

// is with selectLeft/Right

// it actually became visible (as line heights are accurately

// it could be that the last bidi part is not on the last visual line,

// it enabled, if it's hidden, we disable pointer events.

// it got selected.

// it's like "peek", but need for look-ahead or look-behind if index < 0

// it).

// iter aborts when callback returns a truthy value

// iter aborts when callback returns truthy value

// its parent links.

// itself (when the bar is still visible) or its filler child

// jitter on OSX trackpads when deltaX is small and deltaY

// keys with the value of the first argument 'style'

// know one. These don't have to be accurate -- the result of them

// leading sign

// least on Chrome, the timeouts still happen even when cleared,

// left (we don't store arrays for lines without spans).

// left of the character and compare it's vertical position to the

// letting go of the mouse button.

// levels (0, 1, 2) in an implementation that doesn't take

// like normalization and multi-stroke key bindings. It compiles a

// line numbers to line objects, and to go from objects to numbers.

// line's height.

// line.

// line. When lineWrapping is on, there might be more than one

// lineIsHidden depends on the presence of the spans, so needs a second pass

// lineView.changes. This updates the relevant part of the line's

// lines are divided into visual lines. regLineChange (below)

// lines are not indented, and places where the mode returns Pass

// lines may point to the same marker when it spans across lines.

// links back to the lines they currently touch.

// load a mode. (Preferred mechanism is the require/define calls.)

// logical lines, if those are connected by collapsed ranges.

// long list of standard functions from lua manual

// m (NSM): Non-Spacing Mark

// marked ranges.

// marker continues beyond the start/end of the line. Markers have

// markers.

// measured, the position of something may 'drift' during drawing).

// measurement cache for the given line number. (A line view might

// measurements in a row, can thus ensure that the set-up work is

// measuring on line wrapping boundaries.

// menu is closed (since the input reset would kill the

// merged when similar and close together in time.

// method.

// methods defined on the Doc type are also injected into

// middle of some work, but don't want the handler to start calling

// middle-click-paste. Or it might be a click on something we should

// mode/overlays that it is based on (for easy invalidation).

// modifying the selection.

// multi-line comments

// multi-line string parsing mode

// n (AN):  Arabic Number

// new changesets for every character typed

// new normalized keymap, and then updates the old object to reflect

// new ones appear

// newlines are handled in tokenizer

// node, and is the document object itself (meaning it has

// nodes for lines that are no longer in view, and creating the ones

// non-word-non-whitespace chars). The visually param controls

// normal dragging things.

// not interfere with, such as a scrollbar or widget.

// not reset the textarea when typing, because that breaks IME).

// nothing interesting happens.

// now (after some event like 'keypress' or 'input') and are

// number (used to prevent looking up the same line twice).

// number when a is less, and a positive number otherwise.

// number.

// numbers

// numbers changes to all European numbers.

// object.

// objects) in the order in which they occur visually.

// of a bidi jump depending on the visual position of the head.

// of code points as a group.

// of read-only spans in its range.

// of the current position. The resulting position will have a

// of the line, it is moved to the end of that space.

// of the scroll event is removed from the scrollable element.

// offsets afterwards.

// on a bidi boundary.

// on our hidden textarea on reload

// on these below) will treat its first bound as inclusive,

// one new block for the 'if', no block for the 'else'.

// only done once.

// operation (to be applied when the operation finishes).

// operation is active, when a timeout fires.

// operations.

// operators

// option of false.

// or "page".

// or _ followed by a capital letter are reserved for the compiler.

// or attributes

// or clipping off existing ones as needed.

// or closest to, the target character.

// ordering. This finds the first part whose end is after the given

// other branch nodes below them. The top node is always a branch

// other lines onto it.

// other methods on the editor, which might be in an inconsistent

// our fake cursor out of view. On webkit, when wrap=off, paste is

// out of date (or nonexistent).

// outside the actual mode definition.

// overlaps (covers the start or end, but not both) of a new span.

// parse correctly.

// parsers more succinct.

// parsing the argument patterns for a fat-arrow function before we

// part of the document. A LineView may correspond to multiple

// part that only spans one line so that the binary search in

// placeholders

// polling intensively.

// possible when it is clear that nothing happened. hasSelection

// presses in a sane way, this code checks for when that happens

// prevent from getting extra . on 1..

// prevent highlight of division

// properly measurable).

// property if it reached the end of the document.

// provided by the phpLiteAdmin project - phpliteadmin.org

// punctuation

// purpose of keymap fallthrough.

// r (AL):  Right-to-Left Arabic

// ranges.

// re-fire a series of drag-related events right after the drop (#1551)

// reallocate them all on every rebase, but also avoid problems with

// rectangle into view. Returns an object with scrollTop and

// rectangles for it (in measureChar).

// ref: http://dev.mysql.com/doc/refman/5.5/en/bit-field-literals.html

// ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html

// ref: http://dev.mysql.com/doc/refman/5.5/en/hexadecimal-literals.html

// ref: http://dev.mysql.com/doc/refman/5.5/en/mysql-commands.html

// ref: http://dev.mysql.com/doc/refman/5.5/en/null-values.html

// ref: http://dev.mysql.com/doc/refman/5.5/en/number-literals.html

// ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html

// ref: http://dev.mysql.com/doc/refman/5.5/en/user-variables.html

// ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html

// ref: http://sqlite.org/lang_expr.html#binaryops

// ref: http://sqlite.org/lang_keywords.html

// ref: http://sqlite.org/syntax/literal-value.html

// ref: http://web.archive.org/web/20160813185132/http://savage.net.au/SQL/sql-99.bnf.html#delimited%20identifier

// ref: https://kb.askmonty.org/en/comment-syntax/

// ref: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE

// refers to the pre-change end).

// register as 'classnames', consistent with npm package name

// registering a (non-DOM) handler on the editor for the event name,

// registering events on such objects more convenient.

// registering native DOM handlers.

// registers single-line changes.

// rest of the line is a comment

// result of computing the existing spans with the set of spans that

// result.

// return a part of prefix of current stream from current position

// return a part of suffix of current stream from current position

// returned incorrectly when zoomed on IE10 and below.

// returning the number and optionally registering the line as

// right corner of the scrollbar box is the scrollbar box

// right), unit can be "codepoint", "char", "column" (like char, but

// right-click take effect on it.

// right-to-left text.

// rs move the stream

// runs as long as the editor is focused.

// s (B):   Paragraph Separator

// same marker that appear on both sides of the change, and cuts off

// same text, or the end of the change if the change covers it.

// satisfies `pred`. Supports `from` being greater than `to`.

// scroll (if it is large enough).

// scroll action is applied before the end of the operation, this

// scrollLeft properties. When these are undefined, the

// scrollable area is big enough.

// scrolled into view (if we know enough to estimate it).

// scrolled out of view, this ensures that the cursor is visible.

// scrolling entirely here. It'll be slightly off from native, but

// scrolling. Turning off pointer events during the scroll seems

// second as exclusive, but we want to actually address the

// seen text (can be empty), which is stored in prevInput (we must

// select-all detection hack)

// selected (unless it is huge, in which case a placeholder is

// selection in the meantime.

// selection into the 'done' array when it was significantly

// selection update.

// selections, and tries to estimate a character position even for

// shared position objects being unsafely updated.

// short client keyword token

// shot to minimize update/measure roundtrips.

// should be recomputed.

// should be treated as a builtin.

// should require at least 1

// shown.

// signalLater looks whether there are any handlers, and schedules

// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator

// since some scripts/fonts/browsers also treat other configurations

// since visual lines contain content order-consecutive chunks.

// single leaf node.

// single } in f-string is an error

// situation, we can take this ordering to correspond to the visual

// size for the current document size. Returns true when an update

// skip spaces

// smallest indentation, which tends to need the least context to

// so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)

// so, return the marker for that span.

// some key combos in Mac (#2689).

// something in the input textarea, we poll faster, to ensure that

// spans is larger (and thus includes the other). Falls back to

// spans partially within the change. Returns an array of span

// spans that aren't on the line.

// specific stretches of text, and is used by the measuring code.

// stack (redo when undoing, and vice versa).

// start of selection drag, start of text drag, new cursor

// start or around the replaced test. Hint may be "start" or "around".

// started by the argument, or undefined if there are no such lines.

// starting around 5000 chars.

// starting with * are always merged, those starting with + are

// starts after the coordinates. If we run across any whose box wrap

// state at the position that the state refers to.

// state in such a way that each change won't have to update the

// state on line 1 looked ahead 2 -- so saw 3

// state or simply not expect any other events to happen.

// stored heights to match.

// stores highlight worker timeout

// stores maps added by addKeyMap

// string, return a mode config object.

// strings

// strings.

// style strings), which is used to highlight the tokens on the

// support for the old title property

// sure line objects move the way they are supposed to.

// surrounding strong text if the text on both sides has the same

// switch to nested mode

// t (S):   Segment Separator

// terms of their influence on neutrals. Start-of-level-run (sor)

// test 1 + 2 < 3 should cover this

// text was made out of.

// textarea (making it as unobtrusive as possible) to let the

// that are not there yet, and updating the ones that are out of

// that don't correspond to the ordering in our `order` array at

// that have been explicitly cleared should not be restored.

// that start, move one part back.

// that the effect of intermediate scroll commands is not ignored.

// that the minimum number of relayouts are required.

// that this (partially) implements.

// that this document is part of.

// that user code is usually dealing with.

// that want to inspect the mode state (say, for completion).

// that, when pasting, we know what kind of selections the copied

// the amount of lines added or subtracted by the change. This is

// the amount of lines crosses a boundary that makes its width change)

// the change appears on the screen quickly.

// the coordinates, and the coordinates aren't on the same line as

// the coordinates, store that.

// the current bidi part

// the current, or the origins don't allow matching. Origins

// the fly, without following the level-based algorithm.

// the given line.

// the line map. Takes care to render special characters separately.

// the new cursor position should be scrolled into view after

// the next index in the string, or towards the character to the right

// the pending selection in the history, and pushes the old pending

// the query language used by Apache Cassandra is called CQL, but this mime type

// the right of the character position, for example). When outside

// the same line as the arguments and there's no strange noise

// the scroll effect that the first few mouse wheel events have,

// the second being non-inclusive).

// the selection changes. A selection is one or more non-overlapping

// the the current scroll position). viewport may contain top,

// them to be executed when the last operation ends, or, if no

// them, which is needed for uniquely determining an outer marker

// there is also support for backticks, ref: http://sqlite.org/lang_keywords.html

// these keywords are used by all SQL dialects (however, a mode can still overwrite it)

// they are entirely covered by collapsed, non-widget span.

// this adds a zero-width space so that we can later check whether

// this is based on Peter Raganitsch's 'plsql' mode

// this is false.

// this.

// three, it iterates over the range given by the first two (with

// to avoid the issue.

// to explicitly cancel the selection rather than the user

// to the found position (so xRel > 0 means the coordinates are to

// to the last character on the line.

// to undone, redoing moves them in the other direction.

// tokenizers

// to} object by default. Side can be passed to get a specific side

// trailing spaces at the end of a line when rendering text (issue #1362).

// turn a space-separated list into an array

// two numbers of the same type changes to that type.

// undefined if nothing remains).

// undoing

// undoing brings back the span).

// uneditable block element will put the cursor in that element,

// unstandardized between browsers and even browser versions, and

// until the first strong type (R, L, AL, or sor) is found. If an

// until the first strong type (R, L, or sor) is found. If an L is

// up a 'line map', which points at the DOM nodes that represent

// update indentation, but only if indentStack is empty

// update state, but don't save a style array. Used for lines that

// update, since that speeds up the operations on most browsers.

// updateDisplay_W2 will use these properties to do the actual resizing

// upwards to parent nodes.

// used by (legacy) mechanisms like loadmode.js to automatically

// used for changes that span multiple lines, or change the way

// used to disable editing during key handlers when in readOnly mode

// used). When nothing is selected, the cursor sits after previously

// valid state. If that fails, it returns the line with the

// varName can be quoted with ` or ' or "

// variable token

// variables

// vertical range.

// vertical/horizontal position does not need to be adjusted.

// very slow. So make the area wide instead.

// view, so that we don't interleave reading and writing to the DOM.

// view, that getCursor returns, etc).

// visual line. This finds the start of the visual line that the

// w (WS):  Whitespace

// was opened.

// when measurement is needed for a line that's not in the viewport.

// when not typing and nothing is selected)

// when the line isn't visible.

// when they overlap (they may nest, but not partially overlap).

// whether `from` does.

// whether, in right-to-left text, direction 1 means to move towards

// which bidi section the coordinates fall into.

// which causes page_Offset and bounding client rects to use

// which one is the primary selection (the one that's scrolled into

// which point we can't mess with it anymore. Context menu is

// widgets and marker elements with the text behave more intuitive.

// width and height.

// will be the case when there is a lot of text in the textarea,

// wrapped line, and then do a flat search in which we discard any

// wrapper for elt, which removes the elt from the accessibility tree

// wriggle around in a most unseemly way. When we have an

// xRel is the relative x position of the input coordinates compared

// {from, to, marker} object pointing to such marker objects, and

//https://github.com/greenplum-db/gpdb/blob/master/src/include/parser/kwlist.h

//ref: http://sqlite.org/lang_keywords.html

//var regexp = /^\/(?!\s)(?:\/\/)?(?:\\.|[^\/])+\//
