Skip to content

Commit

Permalink
Merge branch 'jarun:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUtopian committed Apr 12, 2024
2 parents be03c21 + ad04944 commit 2d7c826
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ O_GITSTATUS := 0 # add git status to detail view
O_NAMEFIRST := 0 # print file name first, add uid and guid to detail view
O_RESTOREPREVIEW := 0 # add preview pipe to close and restore preview pane

T_ICONS := 0 # test if multiple icons options are set and fail

# convert targets to flags for backwards compatibility
ifneq ($(filter debug,$(MAKECMDGOALS)),)
O_DEBUG := 1
Expand Down Expand Up @@ -97,16 +99,28 @@ endif
ifeq ($(strip $(O_ICONS)),1)
ICONS_INCLUDE = icons-generated-icons-in-term.h
CPPFLAGS += -DICONS_IN_TERM -DICONS_INCLUDE=\"$(ICONS_INCLUDE)\"
ifeq ($(strip $(T_ICONS)),1)
$(error Choose only one system for icons (O_ICONS, O_NERD or O_EMOJI))
endif
T_ICONS := 1
endif

ifeq ($(strip $(O_NERD)),1)
ICONS_INCLUDE = icons-generated-nerd.h
CPPFLAGS += -DNERD -DICONS_INCLUDE=\"$(ICONS_INCLUDE)\"
ifeq ($(strip $(T_ICONS)),1)
$(error Choose only one system for icons (O_ICONS, O_NERD or O_EMOJI))
endif
T_ICONS := 1
endif

ifeq ($(strip $(O_EMOJI)),1)
ICONS_INCLUDE = icons-generated-emoji.h
CPPFLAGS += -DEMOJI -DICONS_INCLUDE=\"$(ICONS_INCLUDE)\"
ifeq ($(strip $(T_ICONS)),1)
$(error Choose only one system for icons (O_ICONS, O_NERD or O_EMOJI))
endif
T_ICONS := 1
endif

ifeq ($(strip $(O_QSORT)),1)
Expand Down
9 changes: 7 additions & 2 deletions plugins/preview-tui
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
# - optional: pistol file viewer (https://github.com/doronbehar/pistol).
# 1. install pistol
# 2. set/export $NNN_PISTOL as 1
# - optional: librsvg for rsvg-convert
#
# Usage:
# You need to set a NNN_FIFO path and a key for the plugin with NNN_PLUG,
Expand Down Expand Up @@ -94,7 +95,7 @@
# 'no_focus [title="preview-tui"]' to your i3 config file.
#
# Shell: Bash (for environment manipulation through arrays)
# Authors: Todd Yamakawa, Léo Villeveygoux, @Recidiviste, Mario Ortiz Manero, Luuk van Baal, @WanderLanz
# Authors: Todd Yamakawa, Léo Villeveygoux, @Recidiviste, Mario Ortiz Manero, Luuk van Baal, @WanderLanz, @flipflop133

# Configurable environment variables:
NNN_SPLIT=${NNN_SPLIT:-} # permanent split direction
Expand Down Expand Up @@ -416,7 +417,9 @@ generate_preview() {
else
image_preview "$1" "$2" "$3" && return
fi ;;
image) if exists convert; then
image) if exists rsvg-convert && [[ "${3##*.}" == "svg" ]]; then
rsvg-convert -a -w "$NNN_PREVIEWWIDTH" -h "$NNN_PREVIEWHEIGHT" -f png -o "$NNN_PREVIEWDIR/$3.png" "$3"
elif exists convert; then
convert "$3" -flatten -resize "$NNN_PREVIEWWIDTH"x"$NNN_PREVIEWHEIGHT"\> "$NNN_PREVIEWDIR/$3.jpg"
else
image_preview "$1" "$2" "$3" && return
Expand All @@ -431,6 +434,8 @@ generate_preview() {
fi
if [ -f "$NNN_PREVIEWDIR/$3.jpg" ]; then
image_preview "$1" "$2" "$NNN_PREVIEWDIR/$3.jpg"
elif [[ "${3##*.}" == "svg" ]] && [ -f "$NNN_PREVIEWDIR/$3.png" ]; then
image_preview "$1" "$2" "$NNN_PREVIEWDIR/$3.png"
else
fifo_pager print_bin_info "$3"
fi
Expand Down
2 changes: 1 addition & 1 deletion src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4732,7 +4732,7 @@ static bool xmktree(char *path, bool dir)
return FALSE;
}
} else {
int fd = open(path, O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); /* Forced create mode for files */
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); /* Forced create mode for files */

if (fd == -1 && errno != EEXIST) {
DPRINTF_S("open!");
Expand Down

0 comments on commit 2d7c826

Please sign in to comment.