aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax8
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/syntax_rules/md.syntax34
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/syntax_rules/php.syntax49
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/tests/test.php224
4 files changed, 302 insertions, 13 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax
index b9543221..bb179be4 100644
--- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax
+++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax
@@ -1,6 +1,6 @@
# Syntax support file for the Lumina Text Editor
# ===================================
-# JSON language support rules
+# Javascript language support rules
# Written by Ken Moore <ken@ixsystems.com>
# Released under the 2-clause BSD license
# ===================================
@@ -25,6 +25,12 @@
"foreground": "colors/comment"
},
{
+ "name": "multi-line comment",
+ "regex_start": "/\\*",
+ "regex_end": "\\*/",
+ "foreground": "colors/comment"
+ },
+ {
"name": "numbers",
"regex": "\\b([0-9]+[\\.]?[0-9]?)+\\b",
"foreground": "colors/altkeyword"
diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/md.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/md.syntax
index 89146c62..2ba4bca7 100644
--- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/md.syntax
+++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/md.syntax
@@ -21,44 +21,44 @@
"foreground": "colors/keyword"
},
{
+ "name": "bold and italic",
+ "regex" : "[\\*]{3}(?!\\s)[^\\*\\_]+(?!\\s)[\\*]{3}",
+ "foreground": "colors/altkeyword",
+ "font_weight" : "bold",
+ "font_style" : "italic"
+ },
+ {
"name": "bold",
- "regex" : "[\\*]{2}[^\\*\\_\\s]+[\\*]{2}",
+ "regex" : "[\\*]{2}(?!\\s)[^\\*\\_]+(?!\\s)[\\*]{2}",
"foreground": "colors/altkeyword",
"font_weight" : "bold"
},
{
"name": "italic",
- "regex" : "[\\*]{1}[^\\*\\_\\s]+[\\*]{1}",
+ "regex" : "[\\*](?!\\s){1}[^\\*\\_]+(?!\\s)[\\*]{1}",
"foreground": "colors/altkeyword",
"font_style" : "italic"
},
{
"name": "bold and italic",
- "regex" : "[\\*]{3}[^\\s]*[^\\*\\_]+[^\\s]*[\\*]{3}",
+ "regex" : "[_]{3}(?!\\s)[^\\*\\_]+(?!\\s)[_]{3}",
"foreground": "colors/altkeyword",
"font_weight" : "bold",
"font_style" : "italic"
},
{
"name": "bold",
- "regex" : "[_]{2}[^\\*\\_\\s]+[_]{2}",
+ "regex" : "[_]{2}(?!\\s)[^\\*\\_]+(?!\\s)[_]{2}",
"foreground": "colors/altkeyword",
"font_weight" : "bold"
},
{
"name": "italic",
- "regex" : "[_]{1}[^\\*\\_\\s]+[_]{1}",
+ "regex" : "[_]{1}(?!\\s)[^\\*\\_]+(?!\\s)[_]{1}",
"foreground": "colors/altkeyword",
"font_style" : "italic"
},
{
- "name": "bold and italic",
- "regex" : "[_]{3}[^\\s]*[^\\*\\_]+[^\\s]*[_]{3}",
- "foreground": "colors/altkeyword",
- "font_weight" : "bold",
- "font_style" : "italic"
- },
- {
"name" : "markup",
"regex": "<[a-z].*><\\/[a-z]>",
"foreground" : "colors/class"
@@ -88,6 +88,16 @@
"name" : "block quote",
"regex" : "^(\\> )+",
"foreground" : "colors/keyword"
+ },
+ {
+ "name" : "lists",
+ "regex" : "^\\s*([0-9].|[\\*\\+\\-]{1})\\s+",
+ "foreground" : "colors/function"
+ },
+ {
+ "name" : "text",
+ "regex": "\"[^\"\\\\]*(\\\\(.|\\n)[^\"\\\\]*)*\"|'[^'\\\\]*(\\\\(.|\\n)[^'\\\\]*)*'",
+ "foreground" : "colors/text"
}
]
}
diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/php.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/php.syntax
new file mode 100644
index 00000000..1aa906d4
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/php.syntax
@@ -0,0 +1,49 @@
+# Syntax support file for the Lumina Text Editor
+# ===================================
+# PHP language support rules
+# Written by Zackary Welch <zwelch@ixsystems.com>
+# Released under the 2-clause BSD license
+# ===================================
+
+{
+ "meta": {
+ "name": "PHP",
+ "file_suffix": ["php"]
+ },
+ "format": {
+ "line_wrap": false,
+ "highlight_whitespace_eol" : false
+ },
+ "rules": [{
+ "name": "keywords",
+ "words": ["private", "public", "class", "function", "const", "return", "if", "else", "bool", "abstract", "and", "as", "break", "case", "catch", "const", "do", "echo", "elseif", "default", "endif", "endfor", "final", "for", "foreach", "extends", "global", "include", "interface", "new", "or", "protected", "require", "static", "switch", "throw", "try", "use", "var", "while", "xor"],
+ "foreground": "colors/keyword"
+ },
+ {
+ "name": "single-line comment",
+ "regex": "[//#][^\n]*",
+ "foreground": "colors/comment"
+ },
+ {
+ "name": "multi-line comment",
+ "regex_start": "/\\*",
+ "regex_end": "\\*/",
+ "foreground": "colors/comment"
+ },
+ {
+ "name": "numbers",
+ "regex": "\\b([0-9]+[\\.]?[0-9]?)+\\b",
+ "foreground": "colors/altkeyword"
+ },
+ {
+ "name": "function names",
+ "regex": "\\b[A-Za-z0-9_]+(?=\\()",
+ "foreground": "colors/class"
+ },
+ {
+ "name" : "text",
+ "regex": "\"[^\"\\\\]*(\\\\(.|\\n)[^\"\\\\]*)*\"|'[^'\\\\]*(\\\\(.|\\n)[^'\\\\]*)*'",
+ "foreground" : "colors/text"
+ }
+ ]
+}
diff --git a/src-qt5/desktop-utils/lumina-textedit/tests/test.php b/src-qt5/desktop-utils/lumina-textedit/tests/test.php
new file mode 100644
index 00000000..d297c16b
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-textedit/tests/test.php
@@ -0,0 +1,224 @@
+<?php
+
+class Mail
+{
+ private $from = ['name' => '', 'email' => ''];
+ private $to = [];
+ private $subject = '';
+ private $message = '';
+ private $files = [];
+ private $multipart = false;
+ private $boundary = '';
+ private $uniqId = '';
+ private $replyTo = [];
+ private $timestamp = null;
+
+ const CRLF = "\r\n";
+
+
+ public function __construct()
+ {
+ $this->uniqId = '<php-mail-' . md5(microtime()) . mt_rand() . '@git.php.net>';
+ }
+
+ /**
+ * Return unique id of mail
+ * @return string unique Id of message in format: '<php-mail-...@git.php.net';
+ */
+ public function getId()
+ {
+ return $this->uniqId;
+ }
+
+ /**
+ * Add parent mail for this mail
+ * @param string $uniqId unique Id of message in format: '<php-mail-...@git.php.net';
+ */
+ public function addReplyTo($uniqId)
+ {
+ $this->replyTo[] = $uniqId;
+ }
+
+ /**
+ * Add attached text file to mail
+ * @param string $name unique file name
+ * @param string $data file content
+ */
+ public function addTextFile($name , $data)
+ {
+ $this->files[trim($name)] = chunk_split(base64_encode($data), 76, self::CRLF);
+ }
+
+ /**
+ * Return length of attached file
+ * @param string $name unique file name
+ * @return int file length
+ */
+ public function getFileLength($name)
+ {
+ $name = trim($name);
+ return isset($this->files[$name]) ? strlen($this->files[$name]) : 0;
+ }
+
+ /**
+ * Delete attached file
+ * @param string $name unique file name
+ */
+ public function dropFile($name)
+ {
+ $name = trim($name);
+ unset($this->files[$name]);
+ }
+
+ /**
+ * Set "From" address
+ * @param string $email email author address
+ * @param string $name author name
+ */
+ public function setFrom($email, $name = '')
+ {
+ $this->from = ['email' => trim($email), 'name' => trim($name)];
+ }
+
+ /**
+ * Add recipient address
+ * @param string $email recipient address
+ * @param string $name recipient name
+ */
+ public function addTo($email, $name = '')
+ {
+ $this->to[] = ['email' => trim($email), 'name' => trim($name)];
+ }
+
+ /**
+ * Set mail subject
+ * @param string $subject subject
+ */
+ public function setSubject($subject)
+ {
+ $this->subject = trim($subject);
+ }
+
+ /**
+ * Set timestamp
+ * @param string $timestamp timestamp
+ */
+ public function setTimestamp($timestamp)
+ {
+ $this->timestamp = trim($timestamp);
+ }
+
+ /**
+ * Set mail body text
+ * @param string $message body text
+ */
+ public function setMessage($message)
+ {
+ $this->message = $message;
+ }
+
+
+ /**
+ * Format header string
+ * @param string $name header name
+ * @param string $value header value
+ * @return string header string
+ */
+ private function makeHeader($name, $value)
+ {
+ return $name . ': ' . $value;
+ }
+
+ /**
+ * Format address string
+ * @param array $address array with email adress and name
+ * @return string address string
+ */
+ private function makeAddress(array $address)
+ {
+ return $address['name'] ? $this->utf8SafeEncode($address['name'], 100) . ' <'. $address['email'] . '>' : $address['email'];
+ }
+
+ /**
+ * Cut end encode string by mb_encode_mimeheader
+ * @param string $value utf8 string
+ * @param int $maxLenght max length
+ * @return string encoded string
+ */
+ private function utf8SafeEncode($value, $maxLenght = null)
+ {
+ if ($maxLenght) $value = mb_substr($value, 0, $maxLenght);
+ return mb_encode_mimeheader($value, 'UTF-8', 'Q');
+ }
+
+ /**
+ * Prepare heade part of mail
+ * @return string header part of mail
+ */
+ private function makeHeaders()
+ {
+ $headers = [];
+ $headers[] = $this->makeHeader('From', $this->makeAddress($this->from));
+ $headers[] = $this->makeHeader('Message-ID', $this->uniqId);
+ if (count($this->replyTo)) {
+ $replyTo = implode(' ', $this->replyTo);
+ $headers[] = $this->makeHeader('References', $replyTo);
+ $headers[] = $this->makeHeader('In-Reply-To', $replyTo);
+ }
+ $headers[] = $this->makeHeader('MIME-Version', '1.0');
+ $headers[] = $this->makeHeader('Date', date(DATE_RFC2822, $this->timestamp ?: time()));
+ if ($this->multipart) {
+ $this->boundary = sha1($this->uniqId);
+ $headers[] = $this->makeHeader('Content-Type', 'multipart/mixed; boundary="' . $this->boundary . '"');
+ } else {
+ $headers[] = $this->makeHeader('Content-Type', 'text/plain; charset="utf-8"');
+ // we use base64 for avoiding some problems sush string length limit, safety encoding etc.
+ $headers[] = $this->makeHeader('Content-Transfer-Encoding', 'quoted-printable');
+ }
+ return implode(self::CRLF , $headers);
+ }
+
+ /**
+ * Prepare body part of mail
+ * @return string mail body
+ */
+ private function makeBody()
+ {
+ $body = '';
+ if ($this->multipart) {
+ $body .= '--' . $this->boundary . self::CRLF;
+ $body .= $this->makeHeader('Content-Type', 'text/plain; charset="utf-8"') . self::CRLF;
+ $body .= $this->makeHeader('Content-Transfer-Encoding', 'quoted-printable') . self::CRLF;
+ $body .= self::CRLF;
+ $body .= quoted_printable_encode($this->message);
+ foreach ($this->files as $name => $data) {
+ $body .= self::CRLF . '--' . $this->boundary . self::CRLF;
+ $body .= $this->makeHeader('Content-Type', 'text/plain; charset="utf-8"') . self::CRLF;
+ $body .= $this->makeHeader('Content-Transfer-Encoding', 'base64') . self::CRLF;
+ $body .= $this->makeHeader('Content-Disposition', 'attachment; filename="' . $name . '"') . self::CRLF;
+ $body .= self::CRLF;
+ $body .= $data;
+ }
+ $body .= self::CRLF . '--' . $this->boundary . '--';
+ } else {
+ $body = quoted_printable_encode($this->message);
+ }
+ return $body;
+ }
+
+ /**
+ * Send current mail
+ * @return bool
+ */
+ public function send()
+ {
+ $this->multipart = (bool) count($this->files);
+
+ $receivers = implode(', ', array_map([$this, 'makeAddress'], $this->to));
+ $subject = $this->utf8SafeEncode($this->subject, 450);
+ $headers = $this->makeHeaders();
+ $body = $this->makeBody();
+
+ return mail($receivers, $subject, $body, $headers, "-f noreply@php.net");
+ }
+}
bgstack15