func (dl *DirectoryListing) ChangeDirectory(dir string) error { cwd, err := backend.CreateDirEntry(dir) if err != nil { return err } dl.current_dir = cwd dl.current_coloredstrings = make(map[*backend.FileEntry]backend.ColoredScrollingString) dl.pl = PrintableListing{ column_width: LS_COL_WIDTH, startx: dl.pl.startx, starty: dl.pl.starty, width: dl.pl.width, height: dl.pl.height, } dl.pl.ElementToFilterValue = dl_elementtofiltervalue_func() dl.pl.ElementPrintValue = dl_elementprintvalue_func(dl) return nil }
func NewListing(startx, starty int, width, height int, update_chan chan int) *DirectoryListing { directoryName, err := os.Getwd() panic_perhaps(err) cwd, err := backend.CreateDirEntry(directoryName) panic_perhaps(err) dl := &DirectoryListing{ current_dir: cwd, current_coloredstrings: make(map[*backend.FileEntry]backend.ColoredScrollingString), pl: PrintableListing{ column_width: LS_COL_WIDTH, startx: startx, starty: starty, width: width, height: height - 1, }, } dl.pl.ElementToFilterValue = dl_elementtofiltervalue_func() dl.pl.ElementPrintValue = dl_elementprintvalue_func(dl) dl.FinalizeCallback = func(_ string) error { dl.CdHighlighted() dl.CL.Clear() return nil } dl.CL.X = startx dl.CL.Y = starty + height - 1 dl.CL.Length = width dl.CL.FG = termbox.ColorWhite dl.CL.BG = termbox.ColorBlack dl.CL.Cmd = make([]rune, 0, 8) dl.CL.FillRune = ' ' dl.CL.Prefix = "> " dl.pl.UpdateFilter(&dl.current_dir.Contents, string(dl.CL.Cmd)) return dl }