diff --git a/src/main.cpp b/src/main.cpp
index efbd03edc..576993bfa 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
QApplication::setOrganizationDomain("redisdesktop.com");
QApplication::setOrganizationName("redisdesktop");
- QFontDatabase::addApplicationFont("://fonts/OpenSans-Regular.ttf");
+ QFontDatabase::addApplicationFont("://fonts/OpenSans.ttc");
QFont defaultFont("OpenSans", 10);
QApplication::setFont(defaultFont);
diff --git a/src/rdm.pro b/src/rdm.pro
index 9f5739daf..4f16c170b 100644
--- a/src/rdm.pro
+++ b/src/rdm.pro
@@ -60,6 +60,10 @@ win32 {
CONFIG += c++11
RC_FILE += $$PWD/resources/rdm.rc
+ win32-msvc* {
+ QMAKE_LFLAGS += /LARGEADDRESSAWARE
+ }
+
release: DESTDIR = ./../bin/windows/release
debug: DESTDIR = ./../bin/windows/debug
}
diff --git a/src/resources/fonts.qrc b/src/resources/fonts.qrc
index adc7f985e..228d40af0 100644
--- a/src/resources/fonts.qrc
+++ b/src/resources/fonts.qrc
@@ -1,5 +1,6 @@
- fonts/OpenSans-Regular.ttf
+ fonts/OpenSans.ttc
+ fonts/Inconsolata-Regular.ttf
diff --git a/src/resources/fonts/Inconsolata-Regular.ttf b/src/resources/fonts/Inconsolata-Regular.ttf
new file mode 100644
index 000000000..bbc964755
Binary files /dev/null and b/src/resources/fonts/Inconsolata-Regular.ttf differ
diff --git a/src/resources/fonts/OpenSans-Bold.ttf b/src/resources/fonts/OpenSans-Bold.ttf
deleted file mode 100644
index fd79d43be..000000000
Binary files a/src/resources/fonts/OpenSans-Bold.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans-BoldItalic.ttf b/src/resources/fonts/OpenSans-BoldItalic.ttf
deleted file mode 100644
index 9bc800958..000000000
Binary files a/src/resources/fonts/OpenSans-BoldItalic.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans-ExtraBold.ttf b/src/resources/fonts/OpenSans-ExtraBold.ttf
deleted file mode 100644
index 21f6f84a0..000000000
Binary files a/src/resources/fonts/OpenSans-ExtraBold.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans-ExtraBoldItalic.ttf b/src/resources/fonts/OpenSans-ExtraBoldItalic.ttf
deleted file mode 100644
index 31cb68834..000000000
Binary files a/src/resources/fonts/OpenSans-ExtraBoldItalic.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans-Italic.ttf b/src/resources/fonts/OpenSans-Italic.ttf
deleted file mode 100644
index c90da48ff..000000000
Binary files a/src/resources/fonts/OpenSans-Italic.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans-Light.ttf b/src/resources/fonts/OpenSans-Light.ttf
deleted file mode 100644
index 0d381897d..000000000
Binary files a/src/resources/fonts/OpenSans-Light.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans-LightItalic.ttf b/src/resources/fonts/OpenSans-LightItalic.ttf
deleted file mode 100644
index 68299c4bc..000000000
Binary files a/src/resources/fonts/OpenSans-LightItalic.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans-Regular.ttf b/src/resources/fonts/OpenSans-Regular.ttf
deleted file mode 100644
index db433349b..000000000
Binary files a/src/resources/fonts/OpenSans-Regular.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans-Semibold.ttf b/src/resources/fonts/OpenSans-Semibold.ttf
deleted file mode 100644
index 1a7679e39..000000000
Binary files a/src/resources/fonts/OpenSans-Semibold.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans-SemiboldItalic.ttf b/src/resources/fonts/OpenSans-SemiboldItalic.ttf
deleted file mode 100644
index 59b6d16b0..000000000
Binary files a/src/resources/fonts/OpenSans-SemiboldItalic.ttf and /dev/null differ
diff --git a/src/resources/fonts/OpenSans.ttc b/src/resources/fonts/OpenSans.ttc
new file mode 100644
index 000000000..e9d99737a
Binary files /dev/null and b/src/resources/fonts/OpenSans.ttc differ
diff --git a/src/resources/qml/editors/MultilineEditor.qml b/src/resources/qml/editors/MultilineEditor.qml
index e23922037..5ec91a718 100644
--- a/src/resources/qml/editors/MultilineEditor.qml
+++ b/src/resources/qml/editors/MultilineEditor.qml
@@ -1,5 +1,6 @@
import QtQuick 2.0
import QtQuick.Controls 1.2
+import QtQuick.Controls.Styles 1.2
import QtQuick.Layouts 1.1
import "./formatters/formatters.js" as Formatters
@@ -83,25 +84,26 @@ ColumnLayout
console.log("Text editor was disabled")
}
- text: {
- if (!formatter) return ''
- var val
- if (formatter.binary === true)
- val = formatter.getFormatted(binaryUtils.valueToBinary(value))
- else
- val = formatter.getFormatted(binaryUtils.toUtf(value))
-
- if (val === undefined) {
- formatterSelector.currentIndex = 0
- binaryFlag.visible = false
- }
+ text: {
+ if (!formatter || !value)
+ return ''
- return (val === undefined) ? '' : val
+ if (formatter.binary === true) {
+ return formatter.getFormatted(binaryUtils.valueToBinary(value)) || ''
+ } else {
+ return formatter.getFormatted(binaryUtils.toUtf(value)) || ''
+ }
}
property var formatter: {
var index = formatterSelector.currentIndex ? formatterSelector.currentIndex : Formatters.defaultFormatterIndex
return Formatters.enabledFormatters[index]
}
+
+ style: TextAreaStyle {
+ renderType: Text.QtRendering
+ }
+ font { family: monospacedFont.name }
+ wrapMode: TextEdit.WrapAnywhere
}
}
diff --git a/src/resources/qml/editors/formatters/formatters.js b/src/resources/qml/editors/formatters/formatters.js
index cf2802b37..cfc4b24d4 100644
--- a/src/resources/qml/editors/formatters/formatters.js
+++ b/src/resources/qml/editors/formatters/formatters.js
@@ -1,6 +1,7 @@
.import "./msgpack.js" as MsgPack
.import "./hexy.js" as Hexy
.import "./php-unserialize.js" as PHPUnserialize
+.import "./json-tools.js" as JSONFormatter
/**
Plain formatter
@@ -74,11 +75,8 @@ var json = {
htmlOutput: false,
getFormatted: function (raw) {
-
- try {
- var parsed = JSON.parse(raw)
- return JSON.stringify(parsed, undefined, 4)
-
+ try {
+ return JSONFormatter.prettyPrint(raw)
} catch (e) {
return "Error: Invalid JSON"
}
@@ -95,9 +93,7 @@ var json = {
getRaw: function (formatted) {
try {
- var parsed = JSON.parse(formatted)
- return JSON.stringify(parsed)
-
+ return JSONFormatter.minify(formatted)
} catch (e) {
return formatted
}
@@ -180,6 +176,11 @@ var enabledFormatters = [plain, json, msgpack, hex, hexTable, phpserialized]
function guessFormatter(isBinary, value)
{
+ // NOTE(u_glide): Use hex or plain formatter if value is large
+ if (binaryUtils.binaryStringLength(value) > 100000) {
+ return isBinary? 3 : 0
+ }
+
var tryFormatters = isBinary? [2, 5, 3, 4] : [1, 5, 2]
for (var index in tryFormatters) {
diff --git a/src/resources/qml/editors/formatters/json-tools.js b/src/resources/qml/editors/formatters/json-tools.js
new file mode 100644
index 000000000..226420d7c
--- /dev/null
+++ b/src/resources/qml/editors/formatters/json-tools.js
@@ -0,0 +1,88 @@
+/*
+ Based on:
+ json-format v.1.1
+ http://github.com/phoboslab/json-format
+ Released under MIT license:
+ http://www.opensource.org/licenses/mit-license.php
+*/
+
+var prettyPrint = function( json ) {
+ var p = []
+ var out = ""
+ var indent = 0;
+
+ var push = function( m ) { return '\\' + p.push( m ) + '\\'; }
+ var pop = function( m, i ) { return p[i-1] }
+ var tabs = function( count ) { return new Array( count + 1 ).join( ' ' ); }
+
+ // Extract backslashes and strings
+ json = json
+ .replace( /\\./g, push )
+ .replace( /(".*?"|'.*?')/g, push )
+ .replace( /\s+/, '' );
+
+ // Indent and insert newlines
+ for( var i = 0; i < json.length; i++ ) {
+ var c = json.charAt(i);
+
+ switch(c) {
+ case '{':
+ case '[':
+ out += c + "\n" + tabs(++indent);
+ break;
+ case '}':
+ case ']':
+ out += "\n" + tabs(--indent) + c;
+ break;
+ case ',':
+ out += ",\n" + tabs(indent);
+ break;
+ case ':':
+ out += ": ";
+ break;
+ default:
+ out += c;
+ break;
+ }
+ }
+
+ // Strip whitespace from numeric arrays and put backslashes
+ // and strings back in
+ out = out
+ .replace( /\[[\d,\s]+?\]/g, function(m){ return m.replace(/\s/g,''); } )
+ .replace( /\\(\d+)\\/g, pop ) // strings
+ .replace( /\\(\d+)\\/g, pop ); // backslashes in strings
+
+ return out;
+};
+
+
+/*!
+ Based on:
+
+ * pretty-data - nodejs plugin to pretty-print or minify data in XML, JSON and CSS formats.
+ *
+ * Version - 0.40.0
+ * Copyright (c) 2012 Vadim Kiryukhin
+ * vkiryukhin @ gmail.com
+ * http://www.eslinstructor.net/pretty-data/
+ * Dual licensed under the MIT and GPL licenses
+*/
+var minify = function(json) {
+
+ return json.replace(/\s{0,}\{\s{0,}/g,"{")
+ .replace(/\s{0,}\[$/g,"[")
+ .replace(/\[\s{0,}/g,"[")
+ .replace(/:\s{0,}\[/g,':[')
+ .replace(/\s{0,}\}\s{0,}/g,"}")
+ .replace(/\s{0,}\]\s{0,}/g,"]")
+ .replace(/\"\s{0,}\,/g,'",')
+ .replace(/\,\s{0,}\"/g,',"')
+ .replace(/\"\s{0,}:/g,'":')
+ .replace(/:\s{0,}\"/g,':"')
+ .replace(/:\s{0,}\[/g,':[')
+ .replace(/\,\s{0,}\[/g,',[')
+ .replace(/\,\s{2,}/g,', ')
+ .replace(/\]\s{0,},\s{0,}\[/g,'],[');
+};
+
diff --git a/src/resources/qml/value-editor.qml b/src/resources/qml/value-editor.qml
index 32b401d4a..944012f55 100644
--- a/src/resources/qml/value-editor.qml
+++ b/src/resources/qml/value-editor.qml
@@ -13,6 +13,14 @@ Rectangle {
color: "transparent"
property var currentValueFormatter
+ FontLoader {
+ id: monospacedFont
+ Component.onCompleted: {
+ source = "qrc:/fonts/Inconsolata-Regular.ttf"
+ }
+ }
+
+
TabView {
id: tabs
objectName: "rdm_qml_tabs"
diff --git a/src/resources/rdm.qrc b/src/resources/rdm.qrc
index 304447d5c..0f66f5d52 100644
--- a/src/resources/rdm.qrc
+++ b/src/resources/rdm.qrc
@@ -49,5 +49,6 @@
qml/parts/RichTextWithLinks.qml
qml/3rdparty/php-unserialize-js/phpUnserialize.js
qml/bulk-operations/BulkOperationsDialog.qml
+ qml/editors/formatters/json-tools.js