use const instead of magic strings
This commit is contained in:
parent
8e8434bb18
commit
3f317d58df
|
@ -28,12 +28,18 @@ const (
|
||||||
hoffset int = 6
|
hoffset int = 6
|
||||||
poffset int = 2
|
poffset int = 2
|
||||||
|
|
||||||
|
filenameColumn string = "filename"
|
||||||
|
pathColumn string = "path"
|
||||||
|
modifiedColumn string = "modified"
|
||||||
|
trashedColumn string = "trashed"
|
||||||
|
sizeColumn string = "size"
|
||||||
|
|
||||||
// TODO: figure these out dynamically based on longest of each
|
// TODO: figure these out dynamically based on longest of each
|
||||||
filenameColumn float64 = 0.46
|
filenameColumnW float64 = 0.46
|
||||||
pathColumn float64 = 0.25
|
pathColumnW float64 = 0.25
|
||||||
dateColumn float64 = 0.15
|
dateColumnW float64 = 0.15
|
||||||
sizeColumn float64 = 0.12
|
sizeColumnW float64 = 0.12
|
||||||
checkColumn float64 = 0.02
|
checkColumnW float64 = 0.02
|
||||||
|
|
||||||
// TODO: make these configurable or something
|
// TODO: make these configurable or something
|
||||||
borderbg string = "5"
|
borderbg string = "5"
|
||||||
|
@ -75,11 +81,11 @@ type model struct {
|
||||||
|
|
||||||
func newModel(fls []files.File, width, height int, readonly, once bool, workdir string, mode modes.Mode) model {
|
func newModel(fls []files.File, width, height int, readonly, once bool, workdir string, mode modes.Mode) model {
|
||||||
var (
|
var (
|
||||||
fwidth = int(math.Round(float64(width-woffset) * filenameColumn))
|
fwidth = int(math.Round(float64(width-woffset) * filenameColumnW))
|
||||||
owidth = int(math.Round(float64(width-woffset) * pathColumn))
|
owidth = int(math.Round(float64(width-woffset) * pathColumnW))
|
||||||
dwidth = int(math.Round(float64(width-woffset) * dateColumn))
|
dwidth = int(math.Round(float64(width-woffset) * dateColumnW))
|
||||||
swidth = int(math.Round(float64(width-woffset) * sizeColumn))
|
swidth = int(math.Round(float64(width-woffset) * sizeColumnW))
|
||||||
cwidth = int(math.Round(float64(width-woffset) * checkColumn))
|
cwidth = int(math.Round(float64(width-woffset) * checkColumnW))
|
||||||
theight = min(height-hoffset, len(fls))
|
theight = min(height-hoffset, len(fls))
|
||||||
|
|
||||||
mdl = model{
|
mdl = model{
|
||||||
|
@ -104,16 +110,16 @@ func newModel(fls []files.File, width, height int, readonly, once bool, workdir
|
||||||
var datecolumn string
|
var datecolumn string
|
||||||
switch mdl.mode {
|
switch mdl.mode {
|
||||||
case modes.Trashing:
|
case modes.Trashing:
|
||||||
datecolumn = "modified"
|
datecolumn = modifiedColumn
|
||||||
default:
|
default:
|
||||||
datecolumn = "trashed"
|
datecolumn = trashedColumn
|
||||||
}
|
}
|
||||||
|
|
||||||
columns := []table.Column{
|
columns := []table.Column{
|
||||||
{Title: "filename", Width: fwidth},
|
{Title: filenameColumn, Width: fwidth},
|
||||||
{Title: "path", Width: owidth},
|
{Title: pathColumn, Width: owidth},
|
||||||
{Title: datecolumn, Width: dwidth},
|
{Title: datecolumn, Width: dwidth},
|
||||||
{Title: "size", Width: swidth},
|
{Title: sizeColumn, Width: swidth},
|
||||||
}
|
}
|
||||||
if !mdl.readonly {
|
if !mdl.readonly {
|
||||||
columns = append(columns, table.Column{Title: uncheck, Width: cwidth})
|
columns = append(columns, table.Column{Title: uncheck, Width: cwidth})
|
||||||
|
|
Loading…
Reference in a new issue