This commit is contained in:
Liang Ding 2014-12-01 14:49:16 +08:00
parent 80185b71e7
commit d6b8cc4360
10 changed files with 27 additions and 7 deletions

View File

@ -68,6 +68,7 @@ type Editor struct {
FontSize string
LineHeight string
Theme string
TabSize string
}
// Configuration.
@ -330,6 +331,10 @@ func upgrade() {
if "" == user.Editor.Theme {
user.Editor.Theme = "wide" // since 1.1.0
}
if "" == user.Editor.TabSize {
user.Editor.TabSize = "4" // since 1.1.0
}
}
Save()

View File

@ -137,5 +137,6 @@
"export": "Export",
"refresh": "Refresh",
"import": "Import",
"theme": "Theme"
"theme": "Theme",
"tab_size": "Tab Size"
}

View File

@ -137,5 +137,6 @@
"export": "輸出",
"refresh": "リフレッシュ",
"import": "インポート",
"theme": "テーマ"
"theme": "テーマ",
"tab_size": "Tab·サイズ"
}

View File

@ -137,5 +137,6 @@
"export": "导出",
"refresh": "刷新",
"import": "导入",
"theme": "主题"
"theme": "主题",
"tab_size": "Tab 大小"
}

View File

@ -137,5 +137,6 @@
"export": "導出",
"refresh": "刷新",
"import": "導入",
"theme": "主題"
"theme": "主題",
"tab_size": "Tab 大小"
}

View File

@ -95,6 +95,7 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
EditorFontSize string
EditorLineHeight string
EditorTheme string
EditorTabSize string
}{}
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
@ -115,6 +116,7 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
user.Editor.FontSize = args.EditorFontSize
user.Editor.LineHeight = args.EditorLineHeight
user.Editor.Theme = args.EditorTheme
user.Editor.TabSize = args.EditorTabSize
conf.UpdateCustomizedConf(username)

View File

@ -565,7 +565,7 @@ var editors = {
menu.undisabled(['save-all', 'close-all', 'build', 'run', 'go-test', 'go-get', 'go-install']);
var textArea = document.getElementById("editor" + id);
textArea.value = data.content;
textArea.value = data.content;
var editor = CodeMirror.fromTextArea(textArea, {
lineNumbers: true,
@ -576,6 +576,7 @@ var editors = {
rulers: [{color: "#ccc", column: 120, lineStyle: "dashed"}],
styleActiveLine: true,
theme: config.editorTheme,
tabSize: config.editorTabSize,
indentUnit: 4,
foldGutter: true,
cursorHeight: 1,

View File

@ -370,6 +370,7 @@ var menu = {
$editorFontSize = $dialogPreference.find("input[name=editorFontSize]"),
$editorLineHeight = $dialogPreference.find("input[name=editorLineHeight]"),
$editorTheme = $dialogPreference.find("input[name=editorTheme]");
$editorTabSize = $dialogPreference.find("input[name=editorTabSize]");
$.extend(request, {
"fontFamily": $fontFamily.val(),
@ -382,7 +383,8 @@ var menu = {
"editorFontFamily": $editorFontFamily.val(),
"editorFontSize": $editorFontSize.val(),
"editorLineHeight": $editorLineHeight.val(),
"editorTheme": $editorTheme.val()
"editorTheme": $editorTheme.val(),
"editorTabSize": $editorTabSize.val()
});
$.ajax({
@ -405,6 +407,7 @@ var menu = {
$editorFontSize.data("value", $editorFontSize.val());
$editorLineHeight.data("value", $editorLineHeight.val());
$editorTheme.data("value", $editorTheme.val());
$editorTabSize.data("value", $editorTabSize.val());
var $okBtn = $("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");
$okBtn.prop("disabled", true);

View File

@ -317,7 +317,8 @@
"session": '{{.conf.SessionChannel}}'
},
"wideSessionId": '{{.session.Id}}',
"editorTheme": '{{.user.Editor.Theme}}'
"editorTheme": '{{.user.Editor.Theme}}',
"editorTabSize": '{{.user.Editor.TabSize}}'
};
// 发往 Wide 的所有 AJAX 请求需要使用该函数创建请求参数.
function newWideRequest() {

View File

@ -48,6 +48,10 @@
{{.i18n.line_height}}{{.i18n.colon}}
<input data-value="{{.user.Editor.LineHeight}}" value="{{.user.Editor.LineHeight}}" name="editorLineHeight"/>
</label>
<label>
{{.i18n.tab_size}}{{.i18n.colon}}
<input data-value="{{.user.Editor.TabSize}}" value="{{.user.Editor.TabSize}}" name="editorTabSize"/>
</label>
<label>
{{.i18n.theme}}{{.i18n.colon}}
<br/>