Added some small boring scripts and programs writen in few last years
[mirrors/Programs.git] / bash / bbs / utils / fm / fm-1.0 / fm.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
55 typedef struct File File;
56 struct 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
64 extern char *program_name;
65 extern GNode *tree_root;
66 extern WINDOW *tree_window, *info_window;
67 extern GList *lines, *selected_line, *first_line, *last_line;
68
69 /* cmd.c */
70 void get_key(void);
71 void run_program(GNode *current_directory, char *program_name_variable,
72 char *default_program_name, char *arg, gboolean wait_proccess);
73 void run_shell(GNode *directory);
74 void read_file(GNode *file);
75 void edit_file(GNode *file);
76
77 /* fm.c */
78 void print_errno_and_exit(int last_errno, char *file, int line);
79 void handle_sigsegv(int signal_number);
80 void handle_sigint(int signal_number);
81 void set_sighandlers(void);
82 void unset_sighandlers(void);
83
84 /* fs.c */
85 void init_tree(char *name);
86 File *create_new_file(char *name, char *path, gboolean exit_on_error);
87 gboolean read_directory(GNode *directory);
88 void free_element_data(gpointer element_data, gpointer data);
89 void destroy_dotfiles(GList *dotfiles);
90 gboolean free_node_data(GNode *node, gpointer data);
91 void destroy_directory_content(GNode *directory);
92 void add_dotfiles(GNode *directory);
93 void remove_dotfiles(GNode *directory);
94 int file_cmp(File *file1, File *file2);
95 int file_cmp_list(gconstpointer file1, gconstpointer file2);
96 void insert_sorted_in_dotfiles(GNode *directory, File *file);
97 void insert_sorted_in_tree(GNode *directory, File *file);
98 char *get_path(GNode *file);
99 GNode *get_next_file__real(GNode *file, gboolean go_deeper);
100 GNode *get_previous_file(GNode *file);
101 GNode *get_next_file(GNode *file);
102 GNode *get_next_file_not_deepper(GNode *file);
103 char *get_file_info(GNode *file);
104
105 /* ino.c */
106 void init_directory_paths(void);
107 void init_inotify(char *root_path);
108 GNode *get_file_by_path(char *path);
109 void insert_file_in_directory(GNode *directory, GNode *file);
110 void remove_file_from_directory(GNode *file);
111
112 /* ui.c */
113 void init_lines(void);
114 void init_curses(void);
115 void init_ui(char *name);
116 void refresh_screen(void);
117 void handle_sigwinch(int signal_number);
118 void print_lines(GList *start_line, GList *end_line, gboolean clear_bottom_lines);
119 void print_parents_lines(GList *line);
120 void print_line(GList *line);
121 void clear_info(void);
122 void print_info(char *message, gboolean bold);
123 void print_error_info(int last_errno, char *file, int line, char *message);
124 void update_last_line(void);
125 void add_directory_content(GNode *directory);
126 void open_directory(GNode *directory);
127 void close_directory(GNode *directory);
128 void update_directory(GNode *directory);
129 void show_dotfiles(GNode *directory);
130 void hide_dotfiles(GNode *directory);
131 void select_line(GList *line);
132 void select_file(GNode *file);
133 void select_nth_line(int n_lines);
134 void scroll_tree(int n_lines);
135 void select_line_inside_window(void);
136 void select_next_line_by_first_letter(char letter);
137 void select_previous_line_by_first_letter(char letter);
138
139 #endif
This page took 0.305811 seconds and 4 git commands to generate.