asuender / cliex-cpp

A simple terminal-based file explorer written in C++ using the ncurses lib.
GNU General Public License v3.0
3 stars 0 forks source link

Files with long name continue to next line #15

Open mfederczuk opened 4 years ago

mfederczuk commented 4 years ago

Files with a very long name wrap and continue in the next line.
After selecting a different file, the wrapped part still stays since the window doesn't get cleared.

image image

asuender commented 4 years ago

This bug appears because file_info_win() only gets cleared at specific lines (where the information are shown) and not the whole window. Easy fix.

mfederczuk commented 4 years ago

Yeah, but we should actually look for a proper way to fix this.
Just letting the file name automatically wrap doesn't look very good.

Maybe check the width of the terminal and check if the file name fits, if not, split the name manually and let it continue under where the name began

| Name: very-long-fi
|       le-name-that
|       wraps-severa
|       l-times
asuender commented 4 years ago

We can use the positions of any _ - . or spaces to split the file names up, e.g.: Name: my-long-filename.txt

| Split it up in:
|                     my-
|                     long-
|                     filename.txt
mfederczuk commented 4 years ago

Could write a function to help with that:

std::vector<std::string> split_file_name(
    const std::string &file_name,
    unsigned int max_length,
    const std::string &wrap_chars = "_-.");

Of course we also gotta move the rest of the file infos down accordingly.