An object of the DirectoryViewer class is passed to a ListViewer at the time of its construction so that the list viewer implements a directory viewing command interface. More...
#include <directoryviewer.h>
Public Types | |
typedef FileName::sorted_names_t | file_name_list |
Storage type for lists of file names. | |
typedef std::vector< FileName > | file_name_vector |
typedef std::vector< FileStatus > | file_status_vector |
Vector of operating system file information objects. | |
typedef CursorWindow::input_event | input_event |
user input events | |
typedef std::set< FileName > | marked_files_set |
Set of file names marked by the user. | |
enum | sortCode { onName = 0, onSize = 1, onTime = 2 } |
sortCode's are symbolic names for ways in which the directory can be sorted. More... | |
typedef std::vector< std::string > | string_vector |
Public Member Functions | |
std::string const & | application_name () const |
Return the name of the application to use when describing this viewer in the ViewerManager::appChooser or in the ViewerManager::ViewerSelector. | |
int | change_mode (size_t index, ViewerManager *vm) |
Prompt the user for file permissions changes. | |
int | copy_file (size_t index, ViewerManager *vm, FileName target_filename="") |
Handle user interaction needed for copying a single file. | |
int | copy_files (ViewerManager *vm) |
Handle user interaction needed for copying all marked files. | |
int | cpptags_all (ViewerManager *vm) |
Prompt the user for a symbol name and list all file locations that match it. | |
int | cpptags_first (ViewerManager *vm) |
Prompt the user for the name of a symbol and bring up an edit session on that file using the cpptags database, TAGPP.tagpp. | |
int | cpptagviewer (ViewerManager *vm) |
Discover the CppTagDB for the current directory and show it. | |
int | delete_file (size_t index, ViewerManager *vm, bool verify=true) |
Handle user interaction needed for deleting the file under the cursor. Returns 0 if everything went ok. Return 1 if the file really didn't get deleted. | |
int | delete_files (ViewerManager *vm) |
Delete all the marked files. | |
std::string | description () const |
A description of the active session. Might be the name of the directory or file being viewed -- might be something else. | |
DirectoryViewer (std::string const &fullname, bool show_user_names=false, bool show_ids=false) | |
Construct a DirectoryViewer's command handler -- and read the corresponding directory. | |
void | display_symbolic_link_file_target (size_t index, ViewerManager *vm) |
Produce a popup message containing the name of the the link file target for the specified line index. If the line is not a symbolic link file, then you get an empty string. | |
int | etags_all (ViewerManager *vm) |
Prompt the user for a symbol name and list all symbols that match it. | |
int | etags_first (ViewerManager *vm) |
Prompt the user for the name of a symbol and bring up an edit session on that file using the standard etags database. | |
virtual bool | fetchAllLines (std::list< std::string > &output) |
void | generate_row_text (size_t index) |
update strings_[index] with the correct text for its row | |
void | generate_row_text () |
generate a string_ for each name_ in the directory | |
int | handle_event (CursorWindow::input_event const *e, size_t index, ViewerManager *vm) |
Handle user events -- and turn them into commands to be executed. | |
void | handle_resize (CursorWindow::row_col const &vp_size) |
Respond to resize commands. Note that you may receive extraneous resize commands, so save vp_size and ignore duplicate size settings. | |
virtual std::auto_ptr < std::list< std::string > > | help_text () |
return true if this item should be displayed bold | |
bool | is_marked (size_t index) |
Is this item marked? | |
bool | is_special (size_t index) |
returns true on directories | |
int | mark_files_by_pattern (ViewerManager *vm) |
prompt the user for a file name pattern and mark files whose names match that pattern. | |
void | read_directory () |
This is the function that really reads the directory. It eliminates in extant directory info, and rereads it all. Directory elements are sorted based on the most recent change to the class member sortCode_ whose default value is onName. | |
void | remove_item (size_t index) |
delete the file whose name appears at location "index" | |
int | rename_file (size_t index, ViewerManager *vm, FileName target_filename="") |
Handle user interaction needed for renaming a single file. | |
int | rename_files (ViewerManager *vm) |
Handle user interaction needed for renaming all marked files. | |
void | view_dir (size_t index, ViewerManager *vm) |
Ensure that there is a viewer containing the directory whose name is in under the cursor. | |
void | view_file_or_dir (std::string const &dir, ViewerManager *vm, bool is_dir) |
Ensure that there is a viewer containing the specified directory or file search criteria. | |
Static Public Member Functions | |
static Viewer * | app (ViewerManager *vm, std::string &fullname) |
Application "hook" function for the DirectoryViewer class. Use it as a parameter to add_app, like this: | |
Public Attributes | |
FileName | fullname_ |
size_t | marked_line_ |
marked_files_set | marks_ |
file_name_vector | names_ |
bool | show_ids_ |
do not put any id info | |
sortCode | sortCode_ |
Sort specification for read_directory. | |
file_status_vector | status_ |
status_.size() == names_.size() == strings_.size() | |
std::vector< std::string > | strings_ |
items to display in the ListViewer | |
std::string | title_ |
title of list display viewer | |
bool | user_names_ |
show user id as a name (group too) | |
int | vp_width_ |
Static Public Attributes | |
static std::string | app_name |
The name to prompt the user with in the ViewerManager::appChooser menu. |
An object of the DirectoryViewer class is passed to a ListViewer at the time of its construction so that the list viewer implements a directory viewing command interface.
DirectoryViewer derives from ListViewer::policies and specializes the event handler function. It uses the strings_ member of policies_ to hold the displayable version of text describing files and their status. It keeps other another vector of strings, names_, which contains the raw data of file names. The strings_ array contains other text beside the file names.
To use add this class to the list of valid applications for a a ViewerManager object, do this:
ViewerManger vm; ... vm.add_app(DirectoryViewer::app, DirectoryViewer::app_name);
This makes the directory viewer avaiable in the application chooser menu brought up when you split the screen or replace the current viewer. The default key bindings for these activities are
^X 2 -- split vertically ^X 3 -- split horizontally ^X ^N -- replace the current viewer
There is of course, no reason to have a DirectoryViewer object unless you are also creating a ListViewer object because a DirectoryViewer is nothing more than a set of policies for controlling a ListViewer's behavior. There is really no reason to have either unless you have a ViewerManager because it declares global variables used by ListViewer.
Here's how to manually create a DirectoryViewer and pop it up in the viewer manager:
ViewerManger vm; ... vm.add_app(DirectoryViewer::app, DirectoryViewer::app_name); ... FileName curdir="*"; curdir.convert_to_absolute_path(); vm.add(new ListViewer(new DirectoryViewer(curdir), &vm), curdir);
This example both adds the DirectoryViewer class as a valid application type _and_ it creates a directory viewer for the current directory and pops it up in the viewer manager.
The directory viewer prefers absolute pathnames on directories.
Here are the command keys available as part of the directory viewer itself. The scrolling and system control key bindings are handled by the viewport manager.
'q' - quit showing this directory, close the vieweport Enter - show the object under the cursor '^' - show the parent directory 'm' - mark the item under the cursor 'M' - mark files by filename pattern 'd' - delete the file under the cursor 'D' - delete marked files 'c' - copy the file under the cursor 'C' - copy the marked files 'r' - rename the file under the cursor 'R' - rename marked files 'a' - lets the user change the attributes of the file under the cursor 'l' - re-read the directory and redisplay it 'L' - same as 'l', but sort on size
Definition at line 21 of file directoryviewer.h.
Storage type for lists of file names.
Definition at line 106 of file directoryviewer.h.
typedef std::vector<FileName> file_name_vector |
Definition at line 107 of file directoryviewer.h.
typedef std::vector<FileStatus> file_status_vector |
Vector of operating system file information objects.
Definition at line 109 of file directoryviewer.h.
typedef CursorWindow::input_event input_event |
user input events
Definition at line 111 of file directoryviewer.h.
typedef std::set<FileName> marked_files_set |
Set of file names marked by the user.
Definition at line 110 of file directoryviewer.h.
typedef std::vector<std::string> string_vector |
Definition at line 108 of file directoryviewer.h.
enum sortCode |
sortCode's are symbolic names for ways in which the directory can be sorted.
onName |
sort by the file's name |
onSize |
sort by the file's size in descending order |
onTime |
Definition at line 128 of file directoryviewer.h.
DirectoryViewer | ( | std::string const & | fullname, | |
bool | show_user_names = false , |
|||
bool | show_ids = false | |||
) |
Construct a DirectoryViewer's command handler -- and read the corresponding directory.
Definition at line 403 of file directoryviewer.cxx.
Viewer * app | ( | ViewerManager * | vm, | |
std::string & | fullname | |||
) | [static] |
Application "hook" function for the DirectoryViewer class. Use it as a parameter to add_app, like this:
vm.add_app(DirectoryViewer::app, "DirectoryViewer");
Definition at line 1780 of file directoryviewer.cxx.
std::string const& application_name | ( | ) | const [virtual] |
Return the name of the application to use when describing this viewer in the ViewerManager::appChooser or in the ViewerManager::ViewerSelector.
Implements policies.
Definition at line 266 of file directoryviewer.h.
int change_mode | ( | size_t | index, | |
ViewerManager * | vm | |||
) |
Prompt the user for file permissions changes.
Definition at line 1502 of file directoryviewer.cxx.
int copy_file | ( | size_t | index, | |
ViewerManager * | vm, | |||
FileName | target_filename = "" | |||
) |
Handle user interaction needed for copying a single file.
Definition at line 762 of file directoryviewer.cxx.
int copy_files | ( | ViewerManager * | vm | ) |
Handle user interaction needed for copying all marked files.
Definition at line 1338 of file directoryviewer.cxx.
int cpptags_all | ( | ViewerManager * | vm | ) |
Prompt the user for a symbol name and list all file locations that match it.
Definition at line 1157 of file directoryviewer.cxx.
int cpptags_first | ( | ViewerManager * | vm | ) |
Prompt the user for the name of a symbol and bring up an edit session on that file using the cpptags database, TAGPP.tagpp.
Definition at line 935 of file directoryviewer.cxx.
int cpptagviewer | ( | ViewerManager * | vm | ) |
Discover the CppTagDB for the current directory and show it.
Definition at line 1287 of file directoryviewer.cxx.
int delete_file | ( | size_t | index, | |
ViewerManager * | vm, | |||
bool | verify = true | |||
) |
Handle user interaction needed for deleting the file under the cursor. Returns 0 if everything went ok. Return 1 if the file really didn't get deleted.
Definition at line 1441 of file directoryviewer.cxx.
int delete_files | ( | ViewerManager * | vm | ) |
Delete all the marked files.
Definition at line 1728 of file directoryviewer.cxx.
std::string description | ( | ) | const [virtual] |
A description of the active session. Might be the name of the directory or file being viewed -- might be something else.
Implements policies.
Definition at line 272 of file directoryviewer.h.
void display_symbolic_link_file_target | ( | size_t | index, | |
ViewerManager * | vm | |||
) |
Produce a popup message containing the name of the the link file target for the specified line index. If the line is not a symbolic link file, then you get an empty string.
Definition at line 318 of file directoryviewer.cxx.
int etags_all | ( | ViewerManager * | vm | ) |
Prompt the user for a symbol name and list all symbols that match it.
Definition at line 1035 of file directoryviewer.cxx.
int etags_first | ( | ViewerManager * | vm | ) |
Prompt the user for the name of a symbol and bring up an edit session on that file using the standard etags database.
Definition at line 859 of file directoryviewer.cxx.
bool fetchAllLines | ( | std::list< std::string > & | output | ) | [virtual] |
Reimplemented from policies.
Definition at line 2070 of file directoryviewer.cxx.
void generate_row_text | ( | size_t | index | ) |
update strings_[index] with the correct text for its row
Definition at line 687 of file directoryviewer.cxx.
void generate_row_text | ( | ) |
generate a string_ for each name_ in the directory
generate a string_ for each name_
Definition at line 669 of file directoryviewer.cxx.
int handle_event | ( | CursorWindow::input_event const * | e, | |
size_t | index, | |||
ViewerManager * | vm | |||
) | [virtual] |
Handle user events -- and turn them into commands to be executed.
Implements policies.
Definition at line 44 of file directoryviewer.cxx.
void handle_resize | ( | CursorWindow::row_col const & | vp_size | ) | [virtual] |
Respond to resize commands. Note that you may receive extraneous resize commands, so save vp_size and ignore duplicate size settings.
Reimplemented from policies.
Definition at line 747 of file directoryviewer.cxx.
std::auto_ptr< std::list< std::string > > help_text | ( | ) | [virtual] |
return true if this item should be displayed bold
This function returns the help text specific to this application. The ListViewer help method will first present the user with the return values from this function then it will present ListViewer specific help, then it will present ViewerManager specific help.
Implements policies.
Definition at line 2015 of file directoryviewer.cxx.
bool is_marked | ( | size_t | index | ) | [virtual] |
bool is_special | ( | size_t | index | ) | [virtual] |
returns true on directories
Reimplemented from policies.
Definition at line 30 of file directoryviewer.cxx.
int mark_files_by_pattern | ( | ViewerManager * | vm | ) |
prompt the user for a file name pattern and mark files whose names match that pattern.
Definition at line 1671 of file directoryviewer.cxx.
void read_directory | ( | ) |
This is the function that really reads the directory. It eliminates in extant directory info, and rereads it all. Directory elements are sorted based on the most recent change to the class member sortCode_ whose default value is onName.
Definition at line 437 of file directoryviewer.cxx.
void remove_item | ( | size_t | index | ) |
delete the file whose name appears at location "index"
Definition at line 381 of file directoryviewer.cxx.
int rename_file | ( | size_t | index, | |
ViewerManager * | vm, | |||
FileName | target_filename = "" | |||
) |
Handle user interaction needed for renaming a single file.
Definition at line 1820 of file directoryviewer.cxx.
int rename_files | ( | ViewerManager * | vm | ) |
Handle user interaction needed for renaming all marked files.
Definition at line 1924 of file directoryviewer.cxx.
void view_dir | ( | size_t | index, | |
ViewerManager * | vm | |||
) |
Ensure that there is a viewer containing the directory whose name is in under the cursor.
Definition at line 1643 of file directoryviewer.cxx.
void view_file_or_dir | ( | std::string const & | dir, | |
ViewerManager * | vm, | |||
bool | is_dir | |||
) |
Ensure that there is a viewer containing the specified directory or file search criteria.
popup a new browser
dir should end in /* or some other file name search pattern
Definition at line 1607 of file directoryviewer.cxx.
std::string app_name [static] |
The name to prompt the user with in the ViewerManager::appChooser menu.
Definition at line 261 of file directoryviewer.h.
Definition at line 115 of file directoryviewer.h.
size_t marked_line_ |
Definition at line 114 of file directoryviewer.h.
Definition at line 118 of file directoryviewer.h.
Definition at line 117 of file directoryviewer.h.
bool show_ids_ |
do not put any id info
Definition at line 123 of file directoryviewer.h.
Sort specification for read_directory.
Definition at line 138 of file directoryviewer.h.
status_.size() == names_.size() == strings_.size()
Definition at line 116 of file directoryviewer.h.
std::vector<std::string> strings_ [inherited] |
items to display in the ListViewer
std::string title_ [inherited] |
bool user_names_ |
show user id as a name (group too)
Definition at line 122 of file directoryviewer.h.
int vp_width_ |
Definition at line 120 of file directoryviewer.h.