-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,20 +37,21 @@ const ( | |
keypad_mod = 0x20000000 | ||
) | ||
|
||
// keeping track of frontend state | ||
type frontend struct { | ||
status_message string | ||
lock sync.Mutex | ||
windows map[*backend.Window]*window | ||
Console *view | ||
qmlDispatch chan qmlDispatch | ||
|
||
promptWaitGroup sync.WaitGroup | ||
promptResult string | ||
} | ||
type ( | ||
// keeping track of frontend state | ||
frontend struct { | ||
lock sync.Mutex | ||
windows map[*backend.Window]*window | ||
Console *view | ||
qmlDispatch chan qmlDispatch | ||
|
||
promptWaitGroup sync.WaitGroup | ||
promptResult string | ||
} | ||
|
||
// Used for batching qml.Changed calls | ||
type qmlDispatch struct{ value, field interface{} } | ||
// Used for batching qml.Changed calls | ||
qmlDispatch struct{ value, field interface{} } | ||
) | ||
|
||
var fe *frontend | ||
|
||
|
@@ -62,7 +63,7 @@ func initFrontend() { | |
qml.Run(fe.loop) | ||
} | ||
|
||
func (f *frontend) Window(w *backend.Window) *window { | ||
func (f *frontend) window(w *backend.Window) *window { | ||
return f.windows[w] | ||
} | ||
|
||
|
@@ -76,9 +77,12 @@ func (f *frontend) VisibleRegion(bv *backend.View) Region { | |
} | ||
|
||
func (f *frontend) StatusMessage(msg string) { | ||
f.lock.Lock() | ||
defer f.lock.Unlock() | ||
f.status_message = msg | ||
w := f.windows[backend.GetEditor().ActiveWindow()] | ||
w.qw.Call("setFrontendStatus", msg) | ||
go func() { | ||
time.Sleep(5 * time.Second) | ||
w.qw.Call("setFrontendStatus", "") | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
zoli
Author
Member
|
||
}() | ||
} | ||
|
||
const ( | ||
|
@@ -153,7 +157,7 @@ func (f *frontend) Prompt(title, folder string, flags int) []string { | |
files[i] = file[7:] | ||
} | ||
} | ||
log.Debug("Selected %s files", files) | ||
log.Fine("Selected %s files", files) | ||
return files | ||
} | ||
|
||
|
@@ -207,13 +211,13 @@ func (f *frontend) qmlChanged(value, field interface{}) { | |
} | ||
|
||
func (f *frontend) DefaultBg() color.RGBA { | ||
c := f.ColorScheme().Spice(&render.ViewRegions{}) | ||
c := f.colorScheme().Spice(&render.ViewRegions{}) | ||
c.Background.A = 0xff | ||
return color.RGBA(c.Background) | ||
} | ||
|
||
func (f *frontend) DefaultFg() color.RGBA { | ||
c := f.ColorScheme().Spice(&render.ViewRegions{}) | ||
c := f.colorScheme().Spice(&render.ViewRegions{}) | ||
c.Foreground.A = 0xff | ||
return color.RGBA(c.Foreground) | ||
} | ||
|
@@ -334,7 +338,7 @@ func (f *frontend) HandleInput(text string, keycode int, modifiers int) bool { | |
return false | ||
} | ||
|
||
func (f *frontend) ColorScheme() backend.ColorScheme { | ||
func (f *frontend) colorScheme() backend.ColorScheme { | ||
ed := backend.GetEditor() | ||
return ed.GetColorScheme(ed.Settings().String("color_scheme", "")) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,23 +15,35 @@ ApplicationWindow { | |
property string themeFolder: "../../packages/Soda/Soda Dark" | ||
|
||
function view() { | ||
return mainView.view(); | ||
return mainView.view(); | ||
} | ||
|
||
function addTab(tabId, view) { | ||
return mainView.addTab(tabId, view); | ||
return mainView.addTab(tabId, view); | ||
} | ||
|
||
function activateTab(tabId) { | ||
return mainView.activateTab(tabId); | ||
return mainView.activateTab(tabId); | ||
} | ||
|
||
function removeTab(tabId) { | ||
return mainView.removeTab(tabId); | ||
return mainView.removeTab(tabId); | ||
} | ||
|
||
function setTabTitle(tabId, title) { | ||
return mainView.setTabTitle(tabId, title); | ||
return mainView.setTabTitle(tabId, title); | ||
} | ||
|
||
function setFrontendStatus(text) { | ||
frontendStatus.text = text | ||
} | ||
|
||
function setIndentStatus(text) { | ||
indentStatus.text = text | ||
} | ||
|
||
function setSyntaxStatus(text) { | ||
syntaxStatus.text = text | ||
} | ||
|
||
menuBar: MenuBar { | ||
|
@@ -79,8 +91,8 @@ ApplicationWindow { | |
MenuSeparator{} | ||
MenuItem { | ||
text: qsTr("Quit") | ||
// TODO: frontend.runCommand("quit"); | ||
onTriggered: Qt.quit(); | ||
// TODO: frontend.runCommand("quit"); | ||
onTriggered: Qt.quit(); | ||
} | ||
} | ||
Menu { | ||
|
@@ -134,10 +146,10 @@ ApplicationWindow { | |
MenuItem { | ||
text: qsTr("Show/Hide Minimap") | ||
onTriggered: { | ||
var tab = tabs.getTab(tabs.currentIndex); | ||
var tab = tabs.getTab(tabs.currentIndex); | ||
|
||
if (tab.item) | ||
tab.item.minimapVisible = !tab.item.minimapVisible; | ||
if (tab.item) | ||
tab.item.minimapVisible = !tab.item.minimapVisible; | ||
} | ||
} | ||
MenuItem { | ||
|
@@ -148,105 +160,85 @@ ApplicationWindow { | |
} | ||
|
||
property Tab currentTab: mainView.currentTab() | ||
property var statusBarMap: (currentTab == null || currentTab.item == null) ? null : currentTab.item.statusBar | ||
property var statusBarSorted: [] | ||
onStatusBarMapChanged: { | ||
if (statusBarMap == null) { | ||
statusBarSorted = [["a", "git branch: master"], ["b", "INSERT MODE"], ["c", "Line xx, Column yy"]]; | ||
return; | ||
} | ||
|
||
console.log("status bar map:", statusBarMap); | ||
var keys = Object.keys(statusBarMap); | ||
keys.sort(); | ||
console.log("status bar keys:", keys); | ||
var sorted = []; | ||
for (var i = 0; i < keys.length; i++) | ||
sorted.push([keys[i], statusBarMap[keys[i]]]); | ||
|
||
statusBarSorted = sorted; | ||
This comment has been minimized.
Sorry, something went wrong.
ricochet1k
Member
|
||
Component { | ||
id: tabTemplate | ||
View {} | ||
} | ||
|
||
Item { | ||
anchors.fill: parent | ||
Keys.onPressed: { | ||
var v = view(); if (v === undefined) return; | ||
v.ctrl = (event.key == Qt.Key_Control) ? true : false; | ||
event.accepted = frontend.handleInput(event.text, event.key, event.modifiers) | ||
event.accepted = true; | ||
} | ||
Keys.onReleased: { | ||
var v = view(); if (v === undefined) return; | ||
v.ctrl = (event.key == Qt.Key_Control) ? false : view().ctrl; | ||
} | ||
focus: true // Focus required for Keys.onPressed | ||
SplitView { | ||
anchors.fill: parent | ||
orientation: Qt.Vertical | ||
MainView { | ||
id: mainView | ||
} | ||
View { | ||
id: consoleView | ||
myView: frontend.console | ||
visible: false | ||
minimapVisible: false | ||
height: 100 | ||
} | ||
} | ||
} | ||
|
||
statusBar: StatusBar { | ||
id: statusBar | ||
property color textColor: "#969696" | ||
|
||
style: StatusBarStyle { | ||
background: Image { | ||
source: themeFolder + "/status-bar-background.png" | ||
source: themeFolder + "/status-bar-background.png" | ||
} | ||
} | ||
|
||
property color textColor: "#969696" | ||
|
||
RowLayout { | ||
anchors.fill: parent | ||
id: statusBarRowLayout | ||
spacing: 15 | ||
|
||
RowLayout { | ||
anchors.fill: parent | ||
spacing: 3 | ||
Repeater { | ||
model: statusBarSorted | ||
delegate: | ||
model: statusBarSorted | ||
delegate: | ||
Label { | ||
text: modelData[1] | ||
color: statusBar.textColor | ||
} | ||
} | ||
Label { | ||
id: frontendStatus | ||
color: statusBar.textColor | ||
} | ||
} | ||
|
||
Label { | ||
id: statusBarIndent | ||
text: "Tab Size/Spaces: 4" | ||
id: indentStatus | ||
color: statusBar.textColor | ||
Layout.alignment: Qt.AlignRight | ||
} | ||
|
||
Label { | ||
id: statusBarLanguage | ||
text: "Go" | ||
id: syntaxStatus | ||
color: statusBar.textColor | ||
Layout.alignment: Qt.AlignRight | ||
} | ||
} | ||
} | ||
|
||
Component { | ||
id: tabTemplate | ||
|
||
View {} | ||
} | ||
|
||
Item { | ||
anchors.fill: parent | ||
Keys.onPressed: { | ||
var v = view(); if (v === undefined) return; | ||
v.ctrl = (event.key == Qt.Key_Control) ? true : false; | ||
event.accepted = frontend.handleInput(event.text, event.key, event.modifiers) | ||
// if (event.key == Qt.Key_Alt) | ||
event.accepted = true; | ||
} | ||
Keys.onReleased: { | ||
var v = view(); if (v === undefined) return; | ||
v.ctrl = (event.key == Qt.Key_Control) ? false : view().ctrl; | ||
} | ||
focus: true // Focus required for Keys.onPressed | ||
SplitView { | ||
anchors.fill: parent | ||
orientation: Qt.Vertical | ||
MainView { | ||
id: mainView | ||
} | ||
View { | ||
id: consoleView | ||
myView: frontend.console | ||
visible: false | ||
minimapVisible: false | ||
height: 100 | ||
} | ||
} | ||
} | ||
MessageDialog { | ||
objectName: "messageDialog" | ||
onAccepted: frontend.promptClosed("accepted") | ||
|
@@ -258,6 +250,7 @@ ApplicationWindow { | |
onReset: frontend.promptClosed("reset") | ||
onYes: frontend.promptClosed("yes") | ||
} | ||
|
||
FileDialog { | ||
objectName: "fileDialog" | ||
onAccepted: frontend.promptClosed("accepted") | ||
|
Where is it documented that the status_message only shows for 5 seconds? Also, what happens if a status message is set, and then 4 seconds later a second message is set? This goroutine is not a good solution.