Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [<JavaScript>]
- let indent (right: bool) (cm: CodeMirror) =
- let startCursor = cm.GetCursor(true)
- let endCursor = cm.GetCursor(false)
- let startLine = cm.GetCursor(true).Line
- let endLine = cm.GetCursor(false).Line
- if startLine = endLine then
- let ch = startCursor.Ch
- if right then
- cm.ReplaceSelection(String.replicate (4 - ch % 4) " ")
- else
- let line = cm.GetLine(startLine)
- let notSpace i = i < 0 || line.[i] <> ' '
- let removeCh =
- if notSpace (ch - 1) then 0
- elif notSpace (ch - 2) then 1
- elif notSpace (ch - 3) then 2
- elif notSpace (ch - 4) then 3
- else 4
- if removeCh > 0 then
- cm.ReplaceRange("", CharCoords(startLine, ch - removeCh), startCursor)
- else
- for i = startLine to endLine do
- cm.IndentLine(i, if right then 4 else -4)
- [<JavaScript>]
- let CodeMirrorOptions () =
- CodeMirror.Options(
- IndentUnit = 4,
- TabSize = 4,
- IndentWithTabs = false,
- ExtraKeys = New [
- "Tab" => indent true
- "Shift-Tab" => indent false
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement