Compare commits
16 Commits
Author | SHA1 | Date |
---|---|---|
Brian Buller | fcc13603da | |
Brian Buller | 305329c943 | |
zhaojizhuang | 54338be381 | |
Brian Buller | b0aec79fcd | |
Brian Buller | 1f901154b9 | |
Brian Buller | 7a5543df99 | |
Brian Buller | dc87af7195 | |
James Hewitt | e1b2bfab4e | |
James Hewitt | 8a508a45ee | |
James Hewitt | ab21f99955 | |
Brian Buller | 184b3ef7cb | |
Brian Buller | 4d4716e825 | |
Brian Buller | ebb9186bbe | |
Brian Buller | ab62644960 | |
Brian Buller | 7f10a81cec | |
Brian Buller | 7718e0f038 |
|
@ -22,10 +22,16 @@ _cgo_export.*
|
|||
|
||||
_testmain.go
|
||||
|
||||
# Build Directory
|
||||
build
|
||||
|
||||
# Binaries
|
||||
*.exe
|
||||
boltbrowser
|
||||
boltbrowser.*
|
||||
|
||||
# Test Database
|
||||
test.db
|
||||
*.db
|
||||
|
||||
|
||||
|
|
12
README.md
12
README.md
|
@ -3,9 +3,9 @@ boltbrowser
|
|||
|
||||
A CLI Browser for BoltDB Files
|
||||
|
||||
![Image of About Screen](http://bullercodeworks.com/boltbrowser/ss2.png)
|
||||
![Image of About Screen](https://git.bullercodeworks.com/brian/boltbrowser/raw/branch/master/build/aboutscreen.png)
|
||||
|
||||
![Image of Main Browser](http://bullercodeworks.com/boltbrowser/ss1.png)
|
||||
![Image of Main Browser](https://git.bullercodeworks.com/brian/boltbrowser/raw/branch/master/build/mainscreen.png)
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
@ -20,13 +20,7 @@ Then you'll have `boltbrowser` in your path.
|
|||
|
||||
Pre-built Binaries
|
||||
------------------
|
||||
Here are pre-built binaries:
|
||||
* [Linux 64-bit](https://git.bullercodeworks.com/brian/boltbrowser/releases/download/2.0/boltbrowser.linux64.zip)
|
||||
* [Linux 32-bit](https://git.bullercodeworks.com/brian/boltbrowser/releases/download/2.0/boltbrowser.linux386.zip)
|
||||
* [Linux Arm](https://git.bullercodeworks.com/brian/boltbrowser/releases/download/2.0/boltbrowser.linuxarm.zip)
|
||||
* [Windows 64-bit](https://git.bullercodeworks.com/brian/boltbrowser/releases/download/2.0/boltbrowser.win64.exe.zip)
|
||||
* [Windows 32-bit](https://git.bullercodeworks.com/brian/boltbrowser/releases/download/2.0/boltbrowser.win386.exe.zip)
|
||||
* [Mac OS](https://git.bullercodeworks.com/brian/boltbrowser/releases/download/2.0/boltbrowser.darwin64.zip)
|
||||
Pre-build binaries are available on the [Releases Page](https://github.com/br0xen/boltbrowser/releases).
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -268,8 +268,8 @@ func (bd *BoltDB) syncOpenBuckets(shadow *BoltDB) {
|
|||
func (bd *BoltDB) refreshDatabase() *BoltDB {
|
||||
// Reload the database into memBolt
|
||||
memBolt = new(BoltDB)
|
||||
db.View(func(tx *bolt.Tx) error {
|
||||
err := tx.ForEach(func(nm []byte, b *bolt.Bucket) error {
|
||||
db.View(func(tx *bbolt.Tx) error {
|
||||
err := tx.ForEach(func(nm []byte, b *bbolt.Bucket) error {
|
||||
bb, err := readBucket(b)
|
||||
if err == nil {
|
||||
bb.name = string(nm)
|
||||
|
@ -280,6 +280,7 @@ func (bd *BoltDB) refreshDatabase() *BoltDB {
|
|||
return err
|
||||
})
|
||||
if err != nil {
|
||||
memBolt = new(BoltDB)
|
||||
// Check if there are key/values directly in the root
|
||||
bb, err := readBucket(tx.Cursor().Bucket())
|
||||
if err == nil {
|
||||
|
@ -405,7 +406,7 @@ func deleteKey(path []string) error {
|
|||
if AppArgs.ReadOnly {
|
||||
return errors.New("DB is in Read-Only Mode")
|
||||
}
|
||||
err := db.Update(func(tx *bolt.Tx) error {
|
||||
err := db.Update(func(tx *bbolt.Tx) error {
|
||||
// len(b.path)-1 is the key we need to delete,
|
||||
// the rest are buckets leading to that key
|
||||
if len(path) == 1 {
|
||||
|
@ -441,7 +442,7 @@ func deleteKey(path []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func readBucket(b *bolt.Bucket) (*BoltBucket, error) {
|
||||
func readBucket(b *bbolt.Bucket) (*BoltBucket, error) {
|
||||
bb := new(BoltBucket)
|
||||
if b == nil {
|
||||
return nil, errors.New("No bucket passed")
|
||||
|
@ -470,7 +471,7 @@ func renameBucket(path []string, name string) error {
|
|||
return nil
|
||||
}
|
||||
var bb *BoltBucket // For caching the current bucket
|
||||
err := db.View(func(tx *bolt.Tx) error {
|
||||
err := db.View(func(tx *bbolt.Tx) error {
|
||||
// len(b.path)-1 is the key we need to delete,
|
||||
// the rest are buckets leading to that key
|
||||
b := tx.Bucket([]byte(path[0]))
|
||||
|
@ -524,7 +525,7 @@ func updatePairKey(path []string, k string) error {
|
|||
if AppArgs.ReadOnly {
|
||||
return errors.New("DB is in Read-Only Mode")
|
||||
}
|
||||
err := db.Update(func(tx *bolt.Tx) error {
|
||||
err := db.Update(func(tx *bbolt.Tx) error {
|
||||
// len(b.path)-1 is the key for the pair we're updating,
|
||||
// the rest are buckets leading to that key
|
||||
b := tx.Bucket([]byte(path[0]))
|
||||
|
@ -560,7 +561,7 @@ func updatePairValue(path []string, v string) error {
|
|||
if AppArgs.ReadOnly {
|
||||
return errors.New("DB is in Read-Only Mode")
|
||||
}
|
||||
err := db.Update(func(tx *bolt.Tx) error {
|
||||
err := db.Update(func(tx *bbolt.Tx) error {
|
||||
// len(b.GetPath())-1 is the key for the pair we're updating,
|
||||
// the rest are buckets leading to that key
|
||||
b := tx.Bucket([]byte(path[0]))
|
||||
|
@ -591,7 +592,7 @@ func insertBucket(path []string, n string) error {
|
|||
return errors.New("DB is in Read-Only Mode")
|
||||
}
|
||||
// Inserts a new bucket named 'n' at 'path'
|
||||
err := db.Update(func(tx *bolt.Tx) error {
|
||||
err := db.Update(func(tx *bbolt.Tx) error {
|
||||
if len(path) == 0 || path[0] == "" {
|
||||
// insert at root
|
||||
_, err := tx.CreateBucket([]byte(n))
|
||||
|
@ -631,7 +632,7 @@ func insertPair(path []string, k string, v string) error {
|
|||
return errors.New("DB is in Read-Only Mode")
|
||||
}
|
||||
// Insert a new pair k => v at path
|
||||
err := db.Update(func(tx *bolt.Tx) error {
|
||||
err := db.Update(func(tx *bbolt.Tx) error {
|
||||
if len(path) == 0 {
|
||||
// We cannot insert a pair at root
|
||||
return errors.New("insertPair: Cannot insert pair at root")
|
||||
|
@ -662,7 +663,7 @@ func insertPair(path []string, k string, v string) error {
|
|||
}
|
||||
|
||||
func exportValue(path []string, fName string) error {
|
||||
return db.View(func(tx *bolt.Tx) error {
|
||||
return db.View(func(tx *bbolt.Tx) error {
|
||||
// len(b.path)-1 is the key whose value we want to export
|
||||
// the rest are buckets leading to that key
|
||||
b := tx.Bucket([]byte(path[0]))
|
||||
|
@ -681,14 +682,14 @@ func exportValue(path []string, fName string) error {
|
|||
}
|
||||
bk := []byte(path[len(path)-1])
|
||||
v := b.Get(bk)
|
||||
return writeToFile(fName, string(v)+"\n", os.O_CREATE|os.O_WRONLY|os.O_TRUNC)
|
||||
return writeToFile(fName, string(v), os.O_CREATE|os.O_WRONLY|os.O_TRUNC)
|
||||
}
|
||||
return errors.New("exportValue: Invalid Bucket")
|
||||
})
|
||||
}
|
||||
|
||||
func exportJSON(path []string, fName string) error {
|
||||
return db.View(func(tx *bolt.Tx) error {
|
||||
return db.View(func(tx *bbolt.Tx) error {
|
||||
// len(b.path)-1 is the key whose value we want to export
|
||||
// the rest are buckets leading to that key
|
||||
b := tx.Bucket([]byte(path[0]))
|
||||
|
@ -718,7 +719,7 @@ func exportJSON(path []string, fName string) error {
|
|||
})
|
||||
}
|
||||
|
||||
func genJSONString(b *bolt.Bucket) string {
|
||||
func genJSONString(b *bbolt.Bucket) string {
|
||||
ret := "{"
|
||||
b.ForEach(func(k, v []byte) error {
|
||||
ret = fmt.Sprintf("%s\"%s\":", ret, string(k))
|
||||
|
@ -755,3 +756,36 @@ func writeToFile(fn, s string, mode int) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func importValue(path []string, fName string) error {
|
||||
if AppArgs.ReadOnly {
|
||||
return errors.New("DB is in Read-Only Mode")
|
||||
}
|
||||
return db.Update(func(tx *bbolt.Tx) error {
|
||||
// len(b.GetPath())-1 is the key for the pair we're updating,
|
||||
// the rest are buckets leading to that key
|
||||
b := tx.Bucket([]byte(path[0]))
|
||||
if b == nil {
|
||||
// Invalid path, try for the root bucket
|
||||
b = tx.Cursor().Bucket()
|
||||
}
|
||||
if b != nil {
|
||||
if len(path) > 0 {
|
||||
for i := range path[1 : len(path)-1] {
|
||||
b = b.Bucket([]byte(path[i+1]))
|
||||
if b == nil {
|
||||
return errors.New("updatePairValue: Invalid Path")
|
||||
}
|
||||
}
|
||||
}
|
||||
// Now update the last key in the path
|
||||
bk := []byte(path[len(path)-1])
|
||||
v, err := os.ReadFile(fName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return b.Put(bk, v)
|
||||
}
|
||||
return errors.New("importValue: Invalid Bucket")
|
||||
})
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
13
go.mod
13
go.mod
|
@ -1,11 +1,14 @@
|
|||
module github.com/br0xen/boltbrowser
|
||||
|
||||
require (
|
||||
github.com/boltdb/bolt v1.3.1
|
||||
github.com/br0xen/termbox-util v0.0.0-20170904143325-de1d4c83380e
|
||||
github.com/mattn/go-runewidth v0.0.4 // indirect
|
||||
github.com/nsf/termbox-go v0.0.0-20180819125858-b66b20ab708e
|
||||
golang.org/x/sys v0.0.0-20191002091554-b397fe3ad8ed // indirect
|
||||
github.com/nsf/termbox-go v1.1.1
|
||||
go.etcd.io/bbolt v1.3.7
|
||||
)
|
||||
|
||||
go 1.13
|
||||
require (
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
)
|
||||
|
||||
go 1.20
|
||||
|
|
20
go.sum
20
go.sum
|
@ -1,10 +1,14 @@
|
|||
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
|
||||
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
|
||||
github.com/br0xen/termbox-util v0.0.0-20170904143325-de1d4c83380e h1:PF4gYXcZfTbAoAk5DPZcvjmq8gyg4gpcmWdT8W+0X1c=
|
||||
github.com/br0xen/termbox-util v0.0.0-20170904143325-de1d4c83380e/go.mod h1:x9wJlgOj74OFTOBwXOuO8pBguW37EgYNx51Dbjkfzo4=
|
||||
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/nsf/termbox-go v0.0.0-20180819125858-b66b20ab708e h1:fvw0uluMptljaRKSU8459cJ4bmi3qUYyMs5kzpic2fY=
|
||||
github.com/nsf/termbox-go v0.0.0-20180819125858-b66b20ab708e/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
|
||||
golang.org/x/sys v0.0.0-20191002091554-b397fe3ad8ed h1:5TJcLJn2a55mJjzYk0yOoqN8X1OdvBDUnaZaKKyQtkY=
|
||||
golang.org/x/sys v0.0.0-20191002091554-b397fe3ad8ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/nsf/termbox-go v1.1.1 h1:nksUPLCb73Q++DwbYUBEglYBRPZyoXJdrj5L+TkjyZY=
|
||||
github.com/nsf/termbox-go v1.1.1/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
|
||||
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
|
||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
|
8
main.go
8
main.go
|
@ -7,15 +7,15 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/nsf/termbox-go"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
var ProgramName = "boltbrowser"
|
||||
var VersionNum = 2.0
|
||||
|
||||
var databaseFiles []string
|
||||
var db *bolt.DB
|
||||
var db *bbolt.DB
|
||||
var memBolt *BoltDB
|
||||
|
||||
var currentFilename string
|
||||
|
@ -114,8 +114,8 @@ func main() {
|
|||
|
||||
for _, databaseFile := range databaseFiles {
|
||||
currentFilename = databaseFile
|
||||
db, err = bolt.Open(databaseFile, 0600, &bolt.Options{Timeout: AppArgs.DBOpenTimeout})
|
||||
if err == bolt.ErrTimeout {
|
||||
db, err = bbolt.Open(databaseFile, 0600, &bbolt.Options{Timeout: AppArgs.DBOpenTimeout})
|
||||
if err == bbolt.ErrTimeout {
|
||||
termbox.Close()
|
||||
fmt.Printf("File %s is locked. Make sure it's not used by another app and try again\n", databaseFile)
|
||||
os.Exit(1)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package main
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// +build windows
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
// Windows doesn't support process backgrounding like *nix.
|
||||
|
|
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/br0xen/termbox-util"
|
||||
termboxUtil "github.com/br0xen/termbox-util"
|
||||
"github.com/nsf/termbox-go"
|
||||
)
|
||||
|
||||
|
@ -111,9 +111,9 @@ func (screen *AboutScreen) drawScreen(style Style) {
|
|||
{"e", "edit value of pair"},
|
||||
{"r", "rename pair/bucket"},
|
||||
{"", ""},
|
||||
{"", ""},
|
||||
{"D", "delete item"},
|
||||
{"x,X", "export as string/json to file"},
|
||||
{"i", "import file to value of pair"},
|
||||
{"", ""},
|
||||
{"?", "this screen"},
|
||||
{"q", "quit program"},
|
||||
|
|
|
@ -61,9 +61,10 @@ const (
|
|||
modeInsertPairVal = 70 // 0000 0100 0110
|
||||
modeDelete = 256 // 0001 0000 0000
|
||||
modeModToParent = 8 // 0000 0000 1000
|
||||
modeExport = 512 // 0010 0000 0000
|
||||
modeExportValue = 513 // 0010 0000 0001
|
||||
modeExportJSON = 514 // 0010 0000 0010
|
||||
modeIO = 512 // 0010 0000 0000
|
||||
modeIOExportValue = 513 // 0010 0000 0001
|
||||
modeIOExportJSON = 514 // 0010 0000 0010
|
||||
modeIOImportValue = 516 // 0010 0000 0100
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -88,8 +89,8 @@ func (screen *BrowserScreen) handleKeyEvent(event termbox.Event) int {
|
|||
return screen.handleInsertKeyEvent(event)
|
||||
} else if screen.mode == modeDelete {
|
||||
return screen.handleDeleteKeyEvent(event)
|
||||
} else if screen.mode&modeExport == modeExport {
|
||||
return screen.handleExportKeyEvent(event)
|
||||
} else if screen.mode&modeIO == modeIO {
|
||||
return screen.handleIOKeyEvent(event)
|
||||
}
|
||||
return BrowserScreenIndex
|
||||
}
|
||||
|
@ -204,11 +205,14 @@ func (screen *BrowserScreen) handleBrowseKeyEvent(event termbox.Event) int {
|
|||
} else if event.Ch == 'D' {
|
||||
screen.startDeleteItem()
|
||||
} else if event.Ch == 'x' {
|
||||
// Export Value
|
||||
// Export Value to a file
|
||||
screen.startExportValue()
|
||||
} else if event.Ch == 'X' {
|
||||
// Export Key/Value (or Bucket) as JSON
|
||||
screen.startExportJSON()
|
||||
} else if event.Ch == 'i' {
|
||||
// Import value from a file
|
||||
screen.startImportValue()
|
||||
}
|
||||
return BrowserScreenIndex
|
||||
}
|
||||
|
@ -374,7 +378,7 @@ func (screen *BrowserScreen) handleInsertKeyEvent(event termbox.Event) int {
|
|||
return BrowserScreenIndex
|
||||
}
|
||||
|
||||
func (screen *BrowserScreen) handleExportKeyEvent(event termbox.Event) int {
|
||||
func (screen *BrowserScreen) handleIOKeyEvent(event termbox.Event) int {
|
||||
if event.Key == termbox.KeyEsc {
|
||||
screen.mode = modeBrowse
|
||||
screen.inputModal.Clear()
|
||||
|
@ -383,24 +387,33 @@ func (screen *BrowserScreen) handleExportKeyEvent(event termbox.Event) int {
|
|||
if screen.inputModal.IsDone() {
|
||||
b, p, _ := screen.db.getGenericFromPath(screen.currentPath)
|
||||
fileName := screen.inputModal.GetValue()
|
||||
if screen.mode&modeExportValue == modeExportValue {
|
||||
if screen.mode&modeIOExportValue == modeIOExportValue {
|
||||
// Exporting the value
|
||||
if p != nil {
|
||||
if err := exportValue(screen.currentPath, fileName); err != nil {
|
||||
//screen.setMessage("Error Exporting to file " + fileName + ".")
|
||||
//screen.setMessage("Error exporting to file " + fileName + ".")
|
||||
screen.setMessage(err.Error())
|
||||
} else {
|
||||
screen.setMessage("Value exported to file: " + fileName)
|
||||
}
|
||||
}
|
||||
} else if screen.mode&modeExportJSON == modeExportJSON {
|
||||
} else if screen.mode&modeIOExportJSON == modeIOExportJSON {
|
||||
if b != nil || p != nil {
|
||||
if exportJSON(screen.currentPath, fileName) != nil {
|
||||
screen.setMessage("Error Exporting to file " + fileName + ".")
|
||||
screen.setMessage("Error exporting to file " + fileName + ".")
|
||||
} else {
|
||||
screen.setMessage("Value exported to file: " + fileName)
|
||||
}
|
||||
}
|
||||
} else if screen.mode&modeIOImportValue == modeIOImportValue {
|
||||
if p != nil {
|
||||
if err := importValue(screen.currentPath, fileName); err != nil {
|
||||
screen.setMessage(err.Error())
|
||||
} else {
|
||||
screen.setMessage("Value imported from file: " + fileName)
|
||||
screen.refreshDatabase()
|
||||
}
|
||||
}
|
||||
}
|
||||
screen.mode = modeBrowse
|
||||
screen.inputModal.Clear()
|
||||
|
@ -907,7 +920,7 @@ func (screen *BrowserScreen) startExportValue() bool {
|
|||
mod.SetValue("")
|
||||
mod.Show()
|
||||
screen.inputModal = mod
|
||||
screen.mode = modeExportValue
|
||||
screen.mode = modeIOExportValue
|
||||
return true
|
||||
}
|
||||
screen.setMessage("Couldn't do string export on " + screen.currentPath[len(screen.currentPath)-1] + "(did you mean 'X'?)")
|
||||
|
@ -930,12 +943,30 @@ func (screen *BrowserScreen) startExportJSON() bool {
|
|||
}
|
||||
mod.Show()
|
||||
screen.inputModal = mod
|
||||
screen.mode = modeExportJSON
|
||||
screen.mode = modeIOExportJSON
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (screen *BrowserScreen) startImportValue() bool {
|
||||
_, p, e := screen.db.getGenericFromPath(screen.currentPath)
|
||||
if e == nil && p != nil {
|
||||
w, h := termbox.Size()
|
||||
inpW, inpH := (w / 2), 6
|
||||
inpX, inpY := ((w / 2) - (inpW / 2)), ((h / 2) - inpH)
|
||||
mod := termboxUtil.CreateInputModal("", inpX, inpY, inpW, inpH, termbox.ColorWhite, termbox.ColorBlack)
|
||||
mod.SetTitle(termboxUtil.AlignText(fmt.Sprintf("Import value of '%s' from:", p.key), inpW, termboxUtil.AlignCenter))
|
||||
mod.SetValue("")
|
||||
mod.Show()
|
||||
screen.inputModal = mod
|
||||
screen.mode = modeIOImportValue
|
||||
return true
|
||||
}
|
||||
screen.setMessage("Couldn't do import on " + screen.currentPath[len(screen.currentPath)-1] + ", must be a pair.")
|
||||
return false
|
||||
}
|
||||
|
||||
func (screen *BrowserScreen) setMessage(msg string) {
|
||||
screen.message = msg
|
||||
screen.messageTime = time.Now()
|
||||
|
|
Loading…
Reference in New Issue