()
| 17 | ) |
| 18 | |
| 19 | func init() { |
| 20 | // GLOBAL COMMANDS |
| 21 | GlobalCommands["t"] = func(m *TuiModel) tea.Cmd { |
| 22 | tuiutil.SelectedTheme = (tuiutil.SelectedTheme + 1) % len(tuiutil.ValidThemes) |
| 23 | SetStyles() |
| 24 | themeName := tuiutil.ValidThemes[tuiutil.SelectedTheme] |
| 25 | m.WriteMessage(fmt.Sprintf("Changed themes to %s", themeName)) |
| 26 | return nil |
| 27 | } |
| 28 | GlobalCommands["pgdown"] = func(m *TuiModel) tea.Cmd { |
| 29 | for i := 0; i < m.Viewport.Height; i++ { |
| 30 | ScrollDown(m) |
| 31 | } |
| 32 | |
| 33 | return nil |
| 34 | } |
| 35 | GlobalCommands["pgup"] = func(m *TuiModel) tea.Cmd { |
| 36 | for i := 0; i < m.Viewport.Height; i++ { |
| 37 | ScrollUp(m) |
| 38 | } |
| 39 | |
| 40 | return nil |
| 41 | } |
| 42 | GlobalCommands["r"] = func(m *TuiModel) tea.Cmd { |
| 43 | if len(m.RedoStack) > 0 && m.QueryResult == nil && m.QueryData == nil { // do this after you get undo working, basically just the same thing reversed |
| 44 | // handle undo |
| 45 | deepCopy := m.CopyMap() |
| 46 | // THE GLOBALIST TAKEOVER |
| 47 | deepState := TableState{ |
| 48 | Database: &database.SQLite{ |
| 49 | FileName: m.Table().Database.GetFileName(), |
| 50 | Database: nil, |
| 51 | }, // placeholder for now while testing database copy |
| 52 | Data: deepCopy, |
| 53 | } |
| 54 | m.UndoStack = append(m.UndoStack, deepState) |
| 55 | // handle redo |
| 56 | from := m.RedoStack[len(m.RedoStack)-1] |
| 57 | to := m.Table() |
| 58 | m.SwapTableValues(&from, to) |
| 59 | m.Table().Database.CloseDatabaseReference() |
| 60 | m.Table().Database.SetDatabaseReference(from.Database.GetFileName()) |
| 61 | |
| 62 | m.RedoStack = m.RedoStack[0 : len(m.RedoStack)-1] // pop |
| 63 | } |
| 64 | |
| 65 | return nil |
| 66 | } |
| 67 | GlobalCommands["u"] = func(m *TuiModel) tea.Cmd { |
| 68 | if len(m.UndoStack) > 0 && m.QueryResult == nil && m.QueryData == nil { |
| 69 | // handle redo |
| 70 | deepCopy := m.CopyMap() |
| 71 | t := m.Table() |
| 72 | // THE GLOBALIST TAKEOVER |
| 73 | deepState := TableState{ |
| 74 | Database: &database.SQLite{ |
| 75 | FileName: t.Database.GetFileName(), |
| 76 | Database: nil, |
nothing calls this directly
no test coverage detected