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
110
Issues
110
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
8789dea2
Commit
8789dea2
authored
Mar 20, 2012
by
Sebastian Ramacher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add completion for :write (Closes: #138)
parent
41bcad37
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
11 deletions
+38
-11
completion.c
completion.c
+26
-9
completion.h
completion.h
+10
-0
config.c
config.c
+2
-2
No files found.
completion.c
View file @
8789dea2
...
@@ -28,7 +28,8 @@ compare_case_insensitive(const char* str1, const char* str2)
...
@@ -28,7 +28,8 @@ compare_case_insensitive(const char* str1, const char* str2)
}
}
static
girara_list_t
*
static
girara_list_t
*
list_files
(
zathura_t
*
zathura
,
const
char
*
current_path
,
const
char
*
current_file
,
int
current_file_length
,
bool
is_dir
)
list_files
(
zathura_t
*
zathura
,
const
char
*
current_path
,
const
char
*
current_file
,
int
current_file_length
,
bool
is_dir
,
bool
check_file_ext
)
{
{
if
(
zathura
==
NULL
||
zathura
->
ui
.
session
==
NULL
||
current_path
==
NULL
)
{
if
(
zathura
==
NULL
||
zathura
->
ui
.
session
==
NULL
||
current_path
==
NULL
)
{
return
NULL
;
return
NULL
;
...
@@ -85,7 +86,7 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
...
@@ -85,7 +86,7 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
full_path
=
g_strdup_printf
(
"%s/"
,
full_path
);
full_path
=
g_strdup_printf
(
"%s/"
,
full_path
);
g_free
(
tmp_path
);
g_free
(
tmp_path
);
girara_list_append
(
res
,
full_path
);
girara_list_append
(
res
,
full_path
);
}
else
if
(
file_valid_extension
(
zathura
,
full_path
)
==
true
)
{
}
else
if
(
file_valid_extension
(
zathura
,
full_path
)
==
true
||
check_file_ext
==
false
)
{
girara_list_append
(
res
,
full_path
);
girara_list_append
(
res
,
full_path
);
}
else
{
}
else
{
g_free
(
full_path
);
g_free
(
full_path
);
...
@@ -102,14 +103,10 @@ error_free:
...
@@ -102,14 +103,10 @@ error_free:
}
}
girara_completion_t
*
girara_completion_t
*
cc_open
(
girara_session_t
*
session
,
const
char
*
inpu
t
)
list_files_for_cc
(
zathura_t
*
zathura
,
const
char
*
input
,
bool
check_file_ex
t
)
{
{
g_return_val_if_fail
(
session
!=
NULL
,
NULL
);
g_return_val_if_fail
(
session
->
global
.
data
!=
NULL
,
NULL
);
zathura_t
*
zathura
=
session
->
global
.
data
;
girara_completion_t
*
completion
=
girara_completion_init
();
girara_completion_t
*
completion
=
girara_completion_init
();
girara_completion_group_t
*
group
=
girara_completion_group_create
(
session
,
NULL
);
girara_completion_group_t
*
group
=
girara_completion_group_create
(
zathura
->
ui
.
session
,
NULL
);
gchar
*
path
=
NULL
;
gchar
*
path
=
NULL
;
gchar
*
current_path
=
NULL
;
gchar
*
current_path
=
NULL
;
...
@@ -166,7 +163,7 @@ cc_open(girara_session_t* session, const char* input)
...
@@ -166,7 +163,7 @@ cc_open(girara_session_t* session, const char* input)
/* read directory */
/* read directory */
if
(
g_file_test
(
current_path
,
G_FILE_TEST_IS_DIR
)
==
TRUE
)
{
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
);
girara_list_t
*
names
=
list_files
(
zathura
,
current_path
,
current_file
,
current_file_length
,
is_dir
,
check_file_ext
);
if
(
!
names
)
{
if
(
!
names
)
{
goto
error_free
;
goto
error_free
;
}
}
...
@@ -199,6 +196,26 @@ error_free:
...
@@ -199,6 +196,26 @@ error_free:
return
NULL
;
return
NULL
;
}
}
girara_completion_t
*
cc_open
(
girara_session_t
*
session
,
const
char
*
input
)
{
g_return_val_if_fail
(
session
!=
NULL
,
NULL
);
g_return_val_if_fail
(
session
->
global
.
data
!=
NULL
,
NULL
);
zathura_t
*
zathura
=
session
->
global
.
data
;
return
list_files_for_cc
(
zathura
,
input
,
true
);
}
girara_completion_t
*
cc_write
(
girara_session_t
*
session
,
const
char
*
input
)
{
g_return_val_if_fail
(
session
!=
NULL
,
NULL
);
g_return_val_if_fail
(
session
->
global
.
data
!=
NULL
,
NULL
);
zathura_t
*
zathura
=
session
->
global
.
data
;
return
list_files_for_cc
(
zathura
,
input
,
false
);
}
girara_completion_t
*
girara_completion_t
*
cc_bookmarks
(
girara_session_t
*
session
,
const
char
*
input
)
cc_bookmarks
(
girara_session_t
*
session
,
const
char
*
input
)
{
{
...
...
completion.h
View file @
8789dea2
...
@@ -15,6 +15,16 @@
...
@@ -15,6 +15,16 @@
*/
*/
girara_completion_t
*
cc_open
(
girara_session_t
*
session
,
const
char
*
input
);
girara_completion_t
*
cc_open
(
girara_session_t
*
session
,
const
char
*
input
);
/**
* Completion for the write command - Creates a list of accesible directories or
* files
*
* @param session The used girara session
* @param input The current input
* @return The completion object or NULL if an error occured
*/
girara_completion_t
*
cc_write
(
girara_session_t
*
session
,
const
char
*
input
);
/**
/**
* Completion for the bmarks command - Creates a list of bookmarks
* Completion for the bmarks command - Creates a list of bookmarks
*
*
...
...
config.c
View file @
8789dea2
...
@@ -245,8 +245,8 @@ config_load_default(zathura_t* zathura)
...
@@ -245,8 +245,8 @@ config_load_default(zathura_t* zathura)
girara_inputbar_command_add
(
gsession
,
"help"
,
NULL
,
cmd_help
,
NULL
,
_
(
"Show help"
));
girara_inputbar_command_add
(
gsession
,
"help"
,
NULL
,
cmd_help
,
NULL
,
_
(
"Show help"
));
girara_inputbar_command_add
(
gsession
,
"open"
,
"o"
,
cmd_open
,
cc_open
,
_
(
"Open document"
));
girara_inputbar_command_add
(
gsession
,
"open"
,
"o"
,
cmd_open
,
cc_open
,
_
(
"Open document"
));
girara_inputbar_command_add
(
gsession
,
"print"
,
NULL
,
cmd_print
,
NULL
,
_
(
"Print document"
));
girara_inputbar_command_add
(
gsession
,
"print"
,
NULL
,
cmd_print
,
NULL
,
_
(
"Print document"
));
girara_inputbar_command_add
(
gsession
,
"write"
,
NULL
,
cmd_save
,
NULL
,
_
(
"Save document"
));
girara_inputbar_command_add
(
gsession
,
"write"
,
NULL
,
cmd_save
,
cc_write
,
_
(
"Save document"
));
girara_inputbar_command_add
(
gsession
,
"write!"
,
NULL
,
cmd_savef
,
NULL
,
_
(
"Save document (and force overwriting)"
));
girara_inputbar_command_add
(
gsession
,
"write!"
,
NULL
,
cmd_savef
,
cc_write
,
_
(
"Save document (and force overwriting)"
));
girara_inputbar_command_add
(
gsession
,
"export"
,
NULL
,
cmd_export
,
cc_export
,
_
(
"Save attachments"
));
girara_inputbar_command_add
(
gsession
,
"export"
,
NULL
,
cmd_export
,
cc_export
,
_
(
"Save attachments"
));
girara_special_command_add
(
gsession
,
'/'
,
cmd_search
,
true
,
FORWARD
,
NULL
);
girara_special_command_add
(
gsession
,
'/'
,
cmd_search
,
true
,
FORWARD
,
NULL
);
...
...
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