1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
From ead43f353675d4c8952facf57920ce79533955a6 Mon Sep 17 00:00:00 2001
From: Chris Taylor <chris@code-monkeys.org>
Date: Fri, 05 Mar 2010 06:24:05 +0000
Subject: Code refactoring.
-Split browser creation code off into its own object. update_browser.
-If exiting from opening creation use update_browser() to repaint browser.
Signed-off-by: Chris Taylor <chris@code-monkeys.org>
---
diff --git a/browse.c b/browse.c
index c736e64..232d374 100644
--- a/browse.c
+++ b/browse.c
@@ -50,7 +50,7 @@ void add_file(gboolean dir);
void remove_win( void );
void display_error(gchar *message, gchar *name, gboolean type);
void open_directory( void );
-
+void update_browser(void);
void file_browser(gint height)
{
@@ -63,28 +63,15 @@ void file_browser(gint height)
cont.length = 1;
cont.first=0;
cont.pos_height=0;
- clear();
+ clear();
refresh();
-
+
browser.location = newwin(1, 0, 0, 0);
browser.title = newwin(1, 0, 1, 0);
browser.list = newwin(cont.height, 0, 3, 0);
-
- wcolor_set(browser.location, 1, NULL);
- wcolor_set(browser.title, 1, NULL);
- wcolor_set(browser.list, 1, NULL);
-
- mvwtitledhline(browser.title, 0, "File Browser");
- wnoutrefresh(browser.title);
- wnoutrefresh(browser.list);
-
- doupdate();
-
-
- get_contents();
- browser_paint(&cont);
-
+ update_browser();
+
while((c=getch()))
{
switch(c)
@@ -399,7 +386,10 @@ void open_directory( void )
get_contents();
return;
case ENTER:
- if(strlen(buffer)==0) return;
+ if(strlen(buffer)==0) {
+ update_browser();
+ return;
+ }
else {
cont.location=g_strdup(buffer);
g_chdir(buffer);
@@ -429,4 +419,18 @@ void open_directory( void )
doupdate();
}
return;
+}
+
+void update_browser(void)
+{
+ wcolor_set(browser.location, 1, NULL);
+ wcolor_set(browser.title, 1, NULL);
+ wcolor_set(browser.list, 1, NULL);
+ mvwtitledhline(browser.title, 0, "File Browser");
+ wnoutrefresh(browser.title);
+ wnoutrefresh(browser.list);
+ doupdate();
+ get_contents();
+ browser_paint(&cont);
+ return;
}
\ No newline at end of file
--
cgit v0.8.3.4-115-g1759
|