/Ft_select2

In-shell interactive menu for selecting files.

Primary LanguageC

Ft_select2 42

Codacy Badge Build Status

An implementation of an in-shell file dialog using termcaps [a 42 project].

This project aims to learn the very basics of using termcap library in C programming language. Ft_select2 is an argument viewer in the terminal that returns the user selection on the standard output.

Description

Ft_select2 is the newer version of Ft_select. It displays a list of arguments in the running terminal. Pressing arrow keys on the keyboard will move the cursor through the list of arguments passed to ft_select.

Ft_select2 has 3 different modes:

1. Selection mode (default mode)

2. Command mode by pressing <:> from selection mode

3. Search mode by pressing <\/> from selection mode

Pressing <ESC> in Command or Search mode will put the user back to Selection mode.

Authorized functions:

isatty, ttyname, ttyslot, ioctl, getenv, tcsetattr, tcgetattr, tgetent, tgetflag
tgetnum, tgetstr, tgoto, tputs, open, close, write, malloc, free, read, exit, signal

Selection mode

  • 'Arrow keys' will move the cursor through the circular list. The cursor underlines the file - appears as an underline font.

  • 'space' key will select/un-select one or more choices in the displayed list. A selection positions the cursor on the next element in the list if it exists. A selected file appears overlined.

  • 'return' key validates the selection. It displays the selection to the standard output. Other programs can take the output.

  • 'delete' and 'backspace' keys removes an element from the list.

  • 'ESC' key exists the program.

Command mode

The command mode is used to change the list sort.

  • 'Arrow keys' left or right will change the sort mode.

  • 'ESC' or 'ENTER' key to go back to Selection mode.

Search mode

The search mode helps user to find a file among the many that have been selected.

To find an argument, just type its name and press <ENTER>.

The program will select the found argument of display an error message.

  • 'ESC' to cancel search and go back to Selection mode.

  • 'ENTER' to confirm search and go back to Selection mode.

Requirements

  • Termcap library:
sudo apt-get -y install libncurses-dev

Usage

  • Clone the github repository
git clone --recurse-submodules https://github.com/Ant0wan/Ft_select2.git && cd Ft_select2/ && make -j
  • Build
cd Ft_select2 && make -j
  • Run, format ./ft_select + arguments
./ft_select ARG|...

For instance:

./ft_select Makefile README.md author ft_select ft_select.en.pdf libft src

Demo

demo