summaryrefslogtreecommitdiff
path: root/notepadpp/debian/bin/notepadpp-common
blob: 7c1c2f88ea968ffd749ca37992755bf6d1e85c69 (plain)
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
#!/bin/sh
# File: notepadpp-common
# Locations: /usr/bin
# Author: bgstack15@gmail.com
# Startdate: 2019-12-27
# Title: Common Elements for Wrapper script for passing files to notepadpp
# Purpose: Converts file paths to a wine format
# History:
# Usage:
#    called from notepadpp (which is symlink to notepadpp32 or notepadpp64)
#    Do not use this by itself.
# Reference:
#    irfanview-common
# Improve:

if ! test "${NPP_VALID_CALL:-nothing}" = "do_not_set_this_manually" ;
then
   printf "%s\n" "Do not call this script by itself! Use \"notepadpp\". Aborted."
   false
else

NPP_VERSION="2019-12-27a"

# Define functions
expandword() {
   # call: expandword "${word}"
   # if file, add it
   # if directory, expand it
   # if tarball, extract it and operate on the directory like normal
   local _word="$( echo "${@}" | sed -e 'sF\/\/F\/Fg;' )"
   if test -d "${_word}";
   then
      # loop through all files in the directory
      for _newword in "${_word}"/*;
      do
         expandword "${_newword}";
      done
   elif test -f "${_word}";
   then
      # file exists so check if tarball
      case "${_word}" in
         *)
            # assume it is readable and add it to list of files to open
            echo "File ${_word}"
            thisfile="$( getwinepath "${_word}" )"
            wineappfiles="${wineappfiles} ${thisfile}"
            ;;
      esac
   fi
}

getwinepath() {
   # call: getwinepath "$foo"
   wine winepath.exe -w "${@}"
}

# Define variables
alltempdirs=""

# prepare files
wineappargs=
wineappfiles=

for word in "${@}";
do
   expandword "${word}"
done
wineappfiles="${wineappfiles## }"

# run wine
cd $WINEPREFIX
printf wine "${NPP_EXEC_PATH}" ${wineappargs} ${wineappfiles}
wine "${NPP_EXEC_PATH}" ${wineappargs} ${wineappfiles} &

wait %1
for thistempdir in ${alltempdirs};
do
   rm -rf "${thistempdir}"
done

fi
bgstack15