Skip to content

Commit 96da60c

Browse files
fixes #1: build5.sh fails with cursor.js and cpp.js
1 parent 20f9c9d commit 96da60c

6 files changed

Lines changed: 48 additions & 67 deletions

File tree

4to5.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
[ $# -ne 1 ] && echo $0 command-file >&2 && exit 1
4+
5+
functions=`sed -E '/^ \* functions:/!d;s/^ \* functions:(.*)/\1/' "$@" | sed ':a;N;s/\n/,/;ta;'`
6+
functions="${functions// /}"
7+
8+
actions="$(sed -E '/^function action/,/^}/!d;
9+
/^function/d;/^}/d;
10+
/^\{/d;
11+
/return \{|icon: ""/d;
12+
s/if \(["'\''](.*)["'\''].*/{ "function": "\1",/g;
13+
s/category: ""/"category": "Editing"/g;
14+
s/category: /"category": /g;
15+
s/interactive: /"interactive": /g;
16+
s/text: i18n\("(.*)"\)/"name": "\1"/g;
17+
s/text: i18n\('\''(.*)'\''\)/"name": "\1"/g;
18+
s/shortcut: /"shortcut": /g;
19+
s/};/},/g' "$@")"
20+
21+
echo 'var katescript = {
22+
"author": "Jonathan Poelen <jonathan.poelen+katescript@gmail.com>",
23+
"license": "LGPL",
24+
"revision": '$(sed '/revision/{!d;s/ *\* *revision: //;q};d' "$@")',
25+
"kate-version": "5.1",
26+
"functions": ["'${functions//,/\", \"}'"]'
27+
[ ! -z "$actions" ] && echo " ,\"actions\": [${actions:0:-1}]"
28+
echo '};'
29+
30+
sed '1,/\*\//{d;q};/^function action/,/^}/d;' "$@"

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,33 @@ Install
1717

1818
## KDE 5:
1919

20-
/!\ _ATTENTION_: headers files are incompatible. Use `build5.sh` or see `help:/katepart/dev-scripting.html#dev-scripting-command-line`.
21-
22-
Copy `libraries/` and `commands/` in the local home folder $XDG_DATA_HOME/katepart5/script/. Therein, the environment variable XDG_DATA_HOME typically expands to either ~/.local or ~/.local/share
20+
```sh
21+
scriptdir="${XDG_DATA_HOME=~/.local/share}/katepart5/script/"
22+
tmpdir="${TMPDIR=/tmp}/katepart-script-$$"
23+
mkdir -p "$tmpdir/commands" "$scriptdir/commands" &&
24+
cp -ri libraries/ "$scriptdir" &&
25+
for f in commands/* ; do ./4to5.sh "$f" > "$tmpdir/$f" ; done &&
26+
mv -i "$tmpdir/commands"/* "$scriptdir/commands"
27+
```
2328

24-
Or merge commands into one file with `build5.sh`:
29+
Or merge commands into one file:
2530

2631
```sh
2732
cd commands
28-
../build5.sh *.js > "$XDG_DATA_HOME"/katepart5/script/commands/katepartscript.kfs5.js
33+
jsfile="${TMPDIR=/tmp}"/katepartscript.kfs4.js
34+
../build.sh *.js > "$jsfile" && \
35+
../4to5.sh "$jsfile" > "${XDG_DATA_HOME=~/.local/share}"/katepart5/script/commands/katepartscript.kfs5.js
2936
```
3037

3138
## KDE 4:
3239

33-
Copy the files inside `libraries/` in `$KDEHOME/.kde/share/apps/katepart/script/libraries` and `commands/` in `$KDEHOME/.kde/share/apps/katepart/script/commands`
40+
```sh
41+
cp -ri libraries/ commands/ "${KDEHOME=~}"/.kde/share/apps/katepart/script/
42+
```
3443

3544
Or merge commands into one file with `build.sh`:
3645

3746
```sh
3847
cd commands
39-
../build.sh *.js > "$KDEHOME"/.kde/share/app/katepart/script/commands/katepartscript.kfs4.js
48+
../build.sh *.js > "${KDEHOME=~}"/.kde/share/app/katepart/script/commands/katepartscript.kfs4.js
4049
```

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ p=`dirname $0`
66

77
libs=`sed -E '/^require/!d;/"range.js"|"cursor.js"/d;s/^require\("(.*)"\);?/\1/' "$@" | sort -u`
88

9-
functions=`sed -E '/^ \* functions:/!d;s/^ \* functions:(.*)/\1/' "$@" | sed :a';/$/N;s/\n/, /;ta'`
9+
functions=`sed -E '/^ \* functions:/!d;s/^ \* functions:(.*)/\1/' "$@" | sed ':a;N;s/\n/, /;ta'`
1010

1111
if [ ! -z "$libs" ] ; then
1212
cd "$p"/libraries
@@ -36,7 +36,7 @@ if [ ! -z "$libs" ] ; then
3636
grep -vh '^require' $libs ;
3737
cd - > /dev/null ;
3838
fi
39-
sed '/^\/\*/d;/^ \*/d;/^require/d;/^function action/,/^}/d;/^function help/,/^}/d' "$@" ;
39+
sed -s '1,/\*\//d;/^require/d;/^function action/,/^}/d;/^function help/,/^}/d' "$@" ;
4040
echo 'function help(cmd){' ;
4141
sed '/^function help/,/^}/!d;/^function/d;/^}/d;/^{/d' "$@" ;
4242
echo '}

build5.sh

Lines changed: 0 additions & 56 deletions
This file was deleted.

commands/cpp.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
require("cursor.js")
1111

12-
///*
1312
/*var inserted = [
1413
['ñ', 'noexcept', 'noexcept '],
1514
['ë', 'const_ref', 'const & '],

commands/cursor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ function action(cmd)
1414
if ("cursor" === cmd)
1515
return {
1616
category: "Navigation",
17-
interactive: false,
1817
text: i18n("Move cursor or create selection"),
1918
shortcut: "Ctrl+Alt+M",
2019
interactive: true

0 commit comments

Comments
 (0)