Add more syntax to lexer and parser, and make improvements to tview
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
engine "git.pablu.de/pablu/sqv-engine"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
// "github.com/uaraven/logview"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -24,6 +25,8 @@ func main() {
|
||||
tableView.Clear()
|
||||
})
|
||||
|
||||
// logView := logview.NewLogView().SetTitle("Logs")
|
||||
|
||||
verticalFlex := tview.NewFlex().
|
||||
AddItem(menuView, 0, 1, true).
|
||||
AddItem(tableView, 0, 3, false)
|
||||
@@ -32,12 +35,16 @@ func main() {
|
||||
SetDirection(tview.FlexRow).
|
||||
AddItem(verticalFlex, 0, 4, true).
|
||||
AddItem(sqlEditor, 0, 1, false)
|
||||
// AddItem(logView, 0, 0, false)
|
||||
|
||||
m, err := engine.NewManager("db.sqlite")
|
||||
if err != nil {
|
||||
log.Fatalf("Ran into an error on opening Manager, err: %v\n", err)
|
||||
}
|
||||
m.Start()
|
||||
err = m.Start()
|
||||
if err != nil {
|
||||
log.Fatalf("Ran into an error on starting Manager, err: %v\n", err)
|
||||
}
|
||||
|
||||
tables := m.GetTables()
|
||||
|
||||
@@ -60,14 +67,15 @@ func main() {
|
||||
|
||||
err = m.LoadTable(&t)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatalf("Error while loading Table, err: %v\n", err)
|
||||
}
|
||||
|
||||
for ri, r := range t.Rows {
|
||||
for rc, c := range r.Values {
|
||||
tableView.SetCell(ri+1, rc, tview.NewTableCell(c).SetTextColor(tcell.ColorWhite).SetAlign(tview.AlignCenter))
|
||||
tableView.SetCell(ri+1, rc, tview.NewTableCell(c).SetTextColor(tcell.ColorWhite).SetAlign(tview.AlignLeft).SetMaxWidth(30))
|
||||
}
|
||||
}
|
||||
tableView.ScrollToBeginning()
|
||||
})
|
||||
|
||||
// Idk this shouldnt be needed imo but with only 0 it doesnt work, and with 1, well we are on Table 1 not zero, WHICH WE CANT ALWAYS SAY THERE IS
|
||||
@@ -131,6 +139,8 @@ func main() {
|
||||
|
||||
menuHidden := false
|
||||
editorHidden := false
|
||||
// logHidden := true
|
||||
|
||||
horizontalFlex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch event.Key() {
|
||||
case tcell.KeyCtrlH:
|
||||
@@ -151,6 +161,13 @@ func main() {
|
||||
app.SetFocus(sqlEditor)
|
||||
}
|
||||
editorHidden = !editorHidden
|
||||
// case tcell.KeyCtrlD:
|
||||
// if !logHidden {
|
||||
// horizontalFlex.ResizeItem(logView, 0, 0)
|
||||
// } else {
|
||||
// horizontalFlex.ResizeItem(logView, 0, 1)
|
||||
// }
|
||||
// logHidden = !logHidden
|
||||
}
|
||||
|
||||
return event
|
||||
|
||||
Reference in New Issue
Block a user