Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zathura
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
108
Issues
108
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pwmt
zathura
Commits
4e5ae52b
Commit
4e5ae52b
authored
Jul 24, 2015
by
Sebastian Ramacher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display recent files in completion (fixes #490)
Signed-off-by:
Sebastian Ramacher
<
sebastian+dev@ramacher.at
>
parent
83fe96e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
8 deletions
+60
-8
doc/man/zathurarc.5.rst
doc/man/zathurarc.5.rst
+22
-0
zathura/completion.c
zathura/completion.c
+36
-8
zathura/config.c
zathura/config.c
+2
-0
No files found.
doc/man/zathurarc.5.rst
View file @
4e5ae52b
...
...
@@ -820,6 +820,28 @@ Defines if the last/first page should be wrapped
* Value type: Boolean
* Default value: false
show-directories
^^^^^^^^^^^^^^^^
Defines if the directories should be displayed in completion.
* Value type: Boolean
* Default value: true
show-hidden
^^^^^^^^^^^
Defines if hidden files and directories should be displayed in completion.
* Value type: Boolean
* Default value: false
show-recent
^^^^^^^^^^^
Defines if recent files should be displayed in completion.
* Value type: Boolean
* Default value: true
scroll-page-aware
^^^^^^^^^^^^^^^^^
Defines if scrolling by half or full pages stops at page boundaries.
...
...
zathura/completion.c
View file @
4e5ae52b
...
...
@@ -12,6 +12,7 @@
#include "completion.h"
#include "utils.h"
#include "page.h"
#include "database.h"
#include <girara/session.h>
#include <girara/settings.h>
...
...
@@ -32,7 +33,7 @@ compare_case_insensitive(const char* str1, const char* str2)
static
girara_list_t
*
list_files
(
zathura_t
*
zathura
,
const
char
*
current_path
,
const
char
*
current_file
,
unsigned
in
t
current_file_length
,
bool
is_dir
,
bool
check_file_ext
)
size_
t
current_file_length
,
bool
is_dir
,
bool
check_file_ext
)
{
if
(
zathura
==
NULL
||
zathura
->
ui
.
session
==
NULL
||
current_path
==
NULL
)
{
return
NULL
;
...
...
@@ -113,15 +114,20 @@ error_free:
}
static
girara_completion_t
*
list_files_for_cc
(
zathura_t
*
zathura
,
const
char
*
input
,
bool
check_file_ext
)
list_files_for_cc
(
zathura_t
*
zathura
,
const
char
*
input
,
bool
check_file_ext
,
bool
include_history
)
{
girara_completion_t
*
completion
=
girara_completion_init
();
girara_completion_group_t
*
group
=
girara_completion_group_create
(
zathura
->
ui
.
session
,
NULL
);
girara_completion_group_t
*
group
=
girara_completion_group_create
(
zathura
->
ui
.
session
,
"files"
);
girara_completion_group_t
*
history_group
=
NULL
;
gchar
*
path
=
NULL
;
gchar
*
current_path
=
NULL
;
if
(
completion
==
NULL
||
group
==
NULL
)
{
if
(
include_history
==
true
)
{
history_group
=
girara_completion_group_create
(
zathura
->
ui
.
session
,
"recent files"
);
}
if
(
completion
==
NULL
||
group
==
NULL
||
(
include_history
==
true
&&
history_group
==
NULL
))
{
goto
error_free
;
}
...
...
@@ -169,12 +175,12 @@ list_files_for_cc(zathura_t* zathura, const char* input, bool check_file_ext)
/* get current file */
gchar
*
current_file
=
is_dir
?
""
:
basename
(
path
);
in
t
current_file_length
=
strlen
(
current_file
);
const
size_
t
current_file_length
=
strlen
(
current_file
);
/* read directory */
if
(
g_file_test
(
current_path
,
G_FILE_TEST_IS_DIR
)
==
TRUE
)
{
girara_list_t
*
names
=
list_files
(
zathura
,
current_path
,
current_file
,
current_file_length
,
is_dir
,
check_file_ext
);
if
(
!
names
)
{
if
(
names
==
NULL
)
{
goto
error_free
;
}
...
...
@@ -184,10 +190,26 @@ list_files_for_cc(zathura_t* zathura, const char* input, bool check_file_ext)
girara_list_free
(
names
);
}
if
(
include_history
==
true
)
{
girara_list_t
*
recent_files
=
zathura_db_get_recent_files
(
zathura
->
database
);
if
(
recent_files
==
NULL
)
{
goto
error_free
;
}
const
size_t
path_len
=
strlen
(
path
);
GIRARA_LIST_FOREACH
(
recent_files
,
const
char
*
,
iter
,
file
)
if
(
strncmp
(
path
,
file
,
path_len
)
==
0
)
{
girara_completion_group_add_element
(
history_group
,
file
,
NULL
);
}
GIRARA_LIST_FOREACH_END
(
recent_files
,
const
char
*
,
iter
,
file
);
girara_list_free
(
recent_files
);
}
g_free
(
path
);
g_free
(
current_path
);
girara_completion_add_group
(
completion
,
group
);
girara_completion_add_group
(
completion
,
history_group
);
return
completion
;
...
...
@@ -196,6 +218,9 @@ error_free:
if
(
completion
)
{
girara_completion_free
(
completion
);
}
if
(
history_group
)
{
girara_completion_group_free
(
history_group
);
}
if
(
group
)
{
girara_completion_group_free
(
group
);
}
...
...
@@ -213,7 +238,10 @@ cc_open(girara_session_t* session, const char* input)
g_return_val_if_fail
(
session
->
global
.
data
!=
NULL
,
NULL
);
zathura_t
*
zathura
=
session
->
global
.
data
;
return
list_files_for_cc
(
zathura
,
input
,
true
);
bool
show_recent
=
true
;
girara_setting_get
(
zathura
->
ui
.
session
,
"show-recent"
,
&
show_recent
);
return
list_files_for_cc
(
zathura
,
input
,
true
,
show_recent
);
}
girara_completion_t
*
...
...
@@ -223,7 +251,7 @@ cc_write(girara_session_t* session, const char* input)
g_return_val_if_fail
(
session
->
global
.
data
!=
NULL
,
NULL
);
zathura_t
*
zathura
=
session
->
global
.
data
;
return
list_files_for_cc
(
zathura
,
input
,
false
);
return
list_files_for_cc
(
zathura
,
input
,
false
,
false
);
}
girara_completion_t
*
...
...
zathura/config.c
View file @
4e5ae52b
...
...
@@ -212,6 +212,8 @@ config_load_default(zathura_t* zathura)
girara_setting_add
(
gsession
,
"show-hidden"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Show hidden files and directories"
),
NULL
,
NULL
);
bool_value
=
true
;
girara_setting_add
(
gsession
,
"show-directories"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Show directories"
),
NULL
,
NULL
);
bool_value
=
true
;
girara_setting_add
(
gsession
,
"show-recent"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Show recent files"
),
NULL
,
NULL
);
bool_value
=
false
;
girara_setting_add
(
gsession
,
"open-first-page"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Always open on first page"
),
NULL
,
NULL
);
bool_value
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment