Skip to content

Commit

Permalink
show view status map in status bar #3
Browse files Browse the repository at this point in the history
  • Loading branch information
zoli committed Dec 21, 2017
1 parent de261c0 commit ded5141
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
11 changes: 2 additions & 9 deletions main/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ func initFrontend() {
fe = &frontend{
windows: make(map[*backend.Window]*window),
}
go func() {
time.Sleep(3 * time.Second)
fe.StatusMessage("Hiiiiiiiiiiiiii")
}()
go fe.qmlBatchLoop()
qml.Run(fe.loop)
}
Expand Down Expand Up @@ -286,10 +282,8 @@ func (f *frontend) onStatusChanged(bv *backend.View) {
log.Error("Couldn't find status changed view")
return
}
if v.qv == nil {
return
}
v.qv.Call("onStatusChanged")
v.updateStatus()
f.qmlChanged(v, &v.Status)
}

// Launches the provided command in a new goroutine
Expand Down Expand Up @@ -534,7 +528,6 @@ func (f *frontend) loop() (err error) {
for _, bv := range w.Back().Views() {
f.onNew(bv)
f.onLoad(bv)

}
}
}
Expand Down
1 change: 0 additions & 1 deletion main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var rotateLog = flag.Bool("rotateLog", false, "Rotate debug log")

func main() {
flag.Parse()

// Need to lock the OS thread as OSX GUI requires GUI stuff to run in the main thread
runtime.LockOSThread()

Expand Down
10 changes: 0 additions & 10 deletions main/qml/View.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ Item {
property var cursor: Qt.IBeamCursor
property bool ctrl: false
property bool minimapVisible: true

property var statusBar: {}


property var linesModel: myView.formattedLines

function setTitle(title) {
Expand Down Expand Up @@ -55,12 +51,6 @@ Item {
editorView.onSelectionModified();
}

function onStatusChanged() {
if (myView == undefined) return;
var bv = myView.back();
statusBar = bv.status();
}

RowLayout {
anchors.fill: parent
Buffer {
Expand Down
10 changes: 7 additions & 3 deletions main/qml/Window.qml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ ApplicationWindow {
RowLayout {
anchors.verticalCenter: parent.verticalCenter
Label {
text: myWindow.status
text: currentView && currentView.myView ? currentView.myView.status : ""
color: statusBar.textColor
}
Label {
text: myWindow ? myWindow.status : ""
color: statusBar.textColor
}
}
Expand All @@ -200,11 +204,11 @@ ApplicationWindow {
spacing: 42
Label {
color: statusBar.textColor
text: "Tab Size: "+(currentView.myView ? currentView.myView.tabSize : "0")
text: "Tab Size: "+(currentView && currentView.myView ? currentView.myView.tabSize : "")
}
Label {
color: statusBar.textColor
text: currentView.myView ? currentView.myView.syntaxName : "Plain Text"
text: currentView && currentView.myView ? currentView.myView.syntaxName : ""
}
}
}
Expand Down
22 changes: 19 additions & 3 deletions main/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main

import (
"fmt"
"sort"
"sync"

"github.com/limetext/backend"
Expand All @@ -25,15 +26,15 @@ type view struct {
FormattedLines *linesList
linesLock sync.Mutex
Title string
Status string

watchedSettings map[string]watchedSetting

// these setting: tags are merely for ease of reading, they aren't actually used
TabSize int `setting:"tab_size"`
SyntaxName string `setting:"syntax"`

FontSize int `setting:"font_size"`
FontFace string `setting:"font_face"`
FontSize int `setting:"font_size"`
FontFace string `setting:"font_face"`
}

func newView(bv *backend.View) *view {
Expand Down Expand Up @@ -268,3 +269,18 @@ func (v *view) formatLine(linenum int, line *lineStruct) {
fe.qmlChanged(line, line)
}
}

func (v *view) updateStatus() {
statusMap := v.Back().Status()
ks := make([]string, 0, len(statusMap))
for k := range statusMap {
ks = append(ks, k)
}
sort.Strings(ks)

status := ""
for _, k := range ks {
status += statusMap[k] + ", "
}
v.Status = status
}

0 comments on commit ded5141

Please sign in to comment.