mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
codemirror updated to 5.47.0
This commit is contained in:
68
libraries/codemirror/mode/swift/index.html
vendored
68
libraries/codemirror/mode/swift/index.html
vendored
@@ -28,50 +28,32 @@
|
||||
<article>
|
||||
<h2>Swift mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
//
|
||||
// TipCalculatorModel.swift
|
||||
// TipCalculator
|
||||
//
|
||||
// Created by Main Account on 12/18/14.
|
||||
// Copyright (c) 2014 Razeware LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class TipCalculatorModel {
|
||||
|
||||
var total: Double
|
||||
var taxPct: Double
|
||||
var subtotal: Double {
|
||||
get {
|
||||
return total / (taxPct + 1)
|
||||
}
|
||||
}
|
||||
|
||||
init(total: Double, taxPct: Double) {
|
||||
self.total = total
|
||||
self.taxPct = taxPct
|
||||
}
|
||||
|
||||
func calcTipWithTipPct(tipPct: Double) -> Double {
|
||||
return subtotal * tipPct
|
||||
}
|
||||
|
||||
func returnPossibleTips() -> [Int: Double] {
|
||||
|
||||
let possibleTipsInferred = [0.15, 0.18, 0.20]
|
||||
let possibleTipsExplicit:[Double] = [0.15, 0.18, 0.20]
|
||||
|
||||
var retval = [Int: Double]()
|
||||
for possibleTip in possibleTipsInferred {
|
||||
let intPct = Int(possibleTip*100)
|
||||
retval[intPct] = calcTipWithTipPct(possibleTip)
|
||||
}
|
||||
return retval
|
||||
|
||||
}
|
||||
|
||||
protocol HeaderViewProtocol {
|
||||
func setTitle(_ string: String)
|
||||
}
|
||||
|
||||
struct AnyHeaderView {
|
||||
let view: UIView
|
||||
let headerView: HeaderViewProtocol
|
||||
init<T: UIView>(view: T) where T: HeaderViewProtocol {
|
||||
self.view = view
|
||||
self.headerView = view
|
||||
}
|
||||
}
|
||||
|
||||
let header = AnyHeaderView(view: myView)
|
||||
header.headerView.setTitle("hi")
|
||||
|
||||
struct HeaderView {
|
||||
let view: UIView
|
||||
let setTitle: (String) -> ()
|
||||
}
|
||||
|
||||
var label = UILabel()
|
||||
let header = HeaderView(view: label) { str in
|
||||
label.text = str
|
||||
}
|
||||
header.setTitle("hello")
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
|
||||
42
libraries/codemirror/mode/swift/swift.js
vendored
42
libraries/codemirror/mode/swift/swift.js
vendored
@@ -73,9 +73,9 @@
|
||||
stream.match("..")
|
||||
return "punctuation"
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
stream.next()
|
||||
var tokenize = tokenString(ch)
|
||||
var stringMatch
|
||||
if (stringMatch = stream.match(/("""|"|')/)) {
|
||||
var tokenize = tokenString.bind(null, stringMatch[0])
|
||||
state.tokenize.push(tokenize)
|
||||
return tokenize(stream, state)
|
||||
}
|
||||
@@ -116,25 +116,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var ch, escaped = false
|
||||
while (ch = stream.next()) {
|
||||
if (escaped) {
|
||||
if (ch == "(") {
|
||||
state.tokenize.push(tokenUntilClosingParen())
|
||||
return "string"
|
||||
}
|
||||
escaped = false
|
||||
} else if (ch == quote) {
|
||||
break
|
||||
} else {
|
||||
escaped = ch == "\\"
|
||||
function tokenString(openQuote, stream, state) {
|
||||
var singleLine = openQuote.length == 1
|
||||
var ch, escaped = false
|
||||
while (ch = stream.peek()) {
|
||||
if (escaped) {
|
||||
stream.next()
|
||||
if (ch == "(") {
|
||||
state.tokenize.push(tokenUntilClosingParen())
|
||||
return "string"
|
||||
}
|
||||
escaped = false
|
||||
} else if (stream.match(openQuote)) {
|
||||
state.tokenize.pop()
|
||||
return "string"
|
||||
} else {
|
||||
stream.next()
|
||||
escaped = ch == "\\"
|
||||
}
|
||||
state.tokenize.pop()
|
||||
return "string"
|
||||
}
|
||||
if (singleLine) {
|
||||
state.tokenize.pop()
|
||||
}
|
||||
return "string"
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
|
||||
8
libraries/codemirror/mode/swift/test.js
vendored
8
libraries/codemirror/mode/swift/test.js
vendored
@@ -35,7 +35,13 @@
|
||||
// Strings and string interpolation.
|
||||
MT("strings",
|
||||
"[keyword var] [def a][punctuation :] [variable-2 String] [operator =] [string \"test\"]",
|
||||
"[keyword var] [def b][punctuation :] [variable-2 String] [operator =] [string \"\\(][variable a][string )\"]");
|
||||
"[keyword var] [def b][punctuation :] [variable-2 String] [operator =] [string \"\\(][variable a][string )\"]",
|
||||
"[keyword var] [def c] [operator =] [string \"\"\"]",
|
||||
"[string multi]",
|
||||
"[string line]",
|
||||
"[string \"test\"]",
|
||||
"[string \"\"\"]",
|
||||
"[variable print][punctuation (][string \"\"][punctuation )]");
|
||||
|
||||
// Comments.
|
||||
MT("comments",
|
||||
|
||||
Reference in New Issue
Block a user