docs
[mirrors/Programs.git] / bash / bbs / utils / fm / fm-1.0 / fm.h
CommitLineData
21c4e167
H
1/* Copyright (C) 2008 Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef FM_H
18#define FM_H
19
20#define _XOPEN_SOURCE 500
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <unistd.h>
25#include <string.h>
26#include <sys/types.h>
27#include <sys/stat.h>
28#include <sys/wait.h>
29#include <dirent.h>
30#include <signal.h>
31#include <ctype.h>
32#include <time.h>
33#include <pwd.h>
34#include <grp.h>
35#include <errno.h>
36#include <locale.h>
37#include <glib.h>
38#include <ncurses.h>
39
40#undef FILE
41#define FILE(node) ((File *) (node)->data)
42#define NODE(element) ((GNode *) (element)->data)
43#define PRINT_ERRNO_AND_EXIT() print_errno_and_exit(errno, __FILE__, __LINE__)
44#define PRINT_ERRNO_INFO() print_error_info(errno, __FILE__, __LINE__, NULL)
45#define PRINT_ERROR_INFO(message) print_error_info(0, __FILE__, __LINE__, message)
46#define PRINT_LAST_INFO() print_info(NULL, -1)
47
48#define DEFAULT_EDITOR "vim"
49#define DEFAULT_PAGER "less"
50#define DEFAULT_SHELL "bash"
51#define DEFAULT_PS_VIEWER "gv"
52#define DEFAULT_PDF_VIEWER "xpdf"
53#define DEFAULT_IMAGE_VIEWER "display"
54
55typedef struct File File;
56struct File {
57 char *name, *link_path;
58 enum Type {file_type, directory_type} type;
59 struct stat info;
60 gboolean read, open, show_dotfiles, link, no_info;
61 GList *line, *dotfiles;
62};
63
64extern char *program_name;
65extern GNode *tree_root;
66extern WINDOW *tree_window, *info_window;
67extern GList *lines, *selected_line, *first_line, *last_line;
68
69/* cmd.c */
70void get_key(void);
71void run_program(GNode *current_directory, char *program_name_variable,
72 char *default_program_name, char *arg, gboolean wait_proccess);
73void run_shell(GNode *directory);
74void read_file(GNode *file);
75void edit_file(GNode *file);
76
77/* fm.c */
78void print_errno_and_exit(int last_errno, char *file, int line);
79void handle_sigsegv(int signal_number);
80void handle_sigint(int signal_number);
81void set_sighandlers(void);
82void unset_sighandlers(void);
83
84/* fs.c */
85void init_tree(char *name);
86File *create_new_file(char *name, char *path, gboolean exit_on_error);
87gboolean read_directory(GNode *directory);
88void free_element_data(gpointer element_data, gpointer data);
89void destroy_dotfiles(GList *dotfiles);
90gboolean free_node_data(GNode *node, gpointer data);
91void destroy_directory_content(GNode *directory);
92void add_dotfiles(GNode *directory);
93void remove_dotfiles(GNode *directory);
94int file_cmp(File *file1, File *file2);
95int file_cmp_list(gconstpointer file1, gconstpointer file2);
96void insert_sorted_in_dotfiles(GNode *directory, File *file);
97void insert_sorted_in_tree(GNode *directory, File *file);
98char *get_path(GNode *file);
99GNode *get_next_file__real(GNode *file, gboolean go_deeper);
100GNode *get_previous_file(GNode *file);
101GNode *get_next_file(GNode *file);
102GNode *get_next_file_not_deepper(GNode *file);
103char *get_file_info(GNode *file);
104
105/* ino.c */
106void init_directory_paths(void);
107void init_inotify(char *root_path);
108GNode *get_file_by_path(char *path);
109void insert_file_in_directory(GNode *directory, GNode *file);
110void remove_file_from_directory(GNode *file);
111
112/* ui.c */
113void init_lines(void);
114void init_curses(void);
115void init_ui(char *name);
116void refresh_screen(void);
117void handle_sigwinch(int signal_number);
118void print_lines(GList *start_line, GList *end_line, gboolean clear_bottom_lines);
119void print_parents_lines(GList *line);
120void print_line(GList *line);
121void clear_info(void);
122void print_info(char *message, gboolean bold);
123void print_error_info(int last_errno, char *file, int line, char *message);
124void update_last_line(void);
125void add_directory_content(GNode *directory);
126void open_directory(GNode *directory);
127void close_directory(GNode *directory);
128void update_directory(GNode *directory);
129void show_dotfiles(GNode *directory);
130void hide_dotfiles(GNode *directory);
131void select_line(GList *line);
132void select_file(GNode *file);
133void select_nth_line(int n_lines);
134void scroll_tree(int n_lines);
135void select_line_inside_window(void);
136void select_next_line_by_first_letter(char letter);
137void select_previous_line_by_first_letter(char letter);
138
139#endif
This page took 0.289301 seconds and 4 git commands to generate.