Skip to content

Commit

Permalink
fixes #1: build5.sh fails with cursor.js and cpp.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpoelen committed Jun 12, 2016
1 parent 20f9c9d commit 96da60c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 67 deletions.
30 changes: 30 additions & 0 deletions 4to5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

[ $# -ne 1 ] && echo $0 command-file >&2 && exit 1

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

actions="$(sed -E '/^function action/,/^}/!d;
/^function/d;/^}/d;
/^\{/d;
/return \{|icon: ""/d;
s/if \(["'\''](.*)["'\''].*/{ "function": "\1",/g;
s/category: ""/"category": "Editing"/g;
s/category: /"category": /g;
s/interactive: /"interactive": /g;
s/text: i18n\("(.*)"\)/"name": "\1"/g;
s/text: i18n\('\''(.*)'\''\)/"name": "\1"/g;
s/shortcut: /"shortcut": /g;
s/};/},/g' "$@")"

echo 'var katescript = {
"author": "Jonathan Poelen <jonathan.poelen+katescript@gmail.com>",
"license": "LGPL",
"revision": '$(sed '/revision/{!d;s/ *\* *revision: //;q};d' "$@")',
"kate-version": "5.1",
"functions": ["'${functions//,/\", \"}'"]'
[ ! -z "$actions" ] && echo " ,\"actions\": [${actions:0:-1}]"
echo '};'

sed '1,/\*\//{d;q};/^function action/,/^}/d;' "$@"
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,33 @@ Install

## KDE 5:

/!\ _ATTENTION_: headers files are incompatible. Use `build5.sh` or see `help:/katepart/dev-scripting.html#dev-scripting-command-line`.

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
```sh
scriptdir="${XDG_DATA_HOME=~/.local/share}/katepart5/script/"
tmpdir="${TMPDIR=/tmp}/katepart-script-$$"
mkdir -p "$tmpdir/commands" "$scriptdir/commands" &&
cp -ri libraries/ "$scriptdir" &&
for f in commands/* ; do ./4to5.sh "$f" > "$tmpdir/$f" ; done &&
mv -i "$tmpdir/commands"/* "$scriptdir/commands"
```

Or merge commands into one file with `build5.sh`:
Or merge commands into one file:

```sh
cd commands
../build5.sh *.js > "$XDG_DATA_HOME"/katepart5/script/commands/katepartscript.kfs5.js
jsfile="${TMPDIR=/tmp}"/katepartscript.kfs4.js
../build.sh *.js > "$jsfile" && \
../4to5.sh "$jsfile" > "${XDG_DATA_HOME=~/.local/share}"/katepart5/script/commands/katepartscript.kfs5.js
```

## KDE 4:

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

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

```sh
cd commands
../build.sh *.js > "$KDEHOME"/.kde/share/app/katepart/script/commands/katepartscript.kfs4.js
../build.sh *.js > "${KDEHOME=~}"/.kde/share/app/katepart/script/commands/katepartscript.kfs4.js
```
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ p=`dirname $0`

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

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

if [ ! -z "$libs" ] ; then
cd "$p"/libraries
Expand Down Expand Up @@ -36,7 +36,7 @@ if [ ! -z "$libs" ] ; then
grep -vh '^require' $libs ;
cd - > /dev/null ;
fi
sed '/^\/\*/d;/^ \*/d;/^require/d;/^function action/,/^}/d;/^function help/,/^}/d' "$@" ;
sed -s '1,/\*\//d;/^require/d;/^function action/,/^}/d;/^function help/,/^}/d' "$@" ;
echo 'function help(cmd){' ;
sed '/^function help/,/^}/!d;/^function/d;/^}/d;/^{/d' "$@" ;
echo '}
Expand Down
56 changes: 0 additions & 56 deletions build5.sh

This file was deleted.

1 change: 0 additions & 1 deletion commands/cpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

require("cursor.js")

///*
/*var inserted = [
['ñ', 'noexcept', 'noexcept '],
['ë', 'const_ref', 'const & '],
Expand Down
1 change: 0 additions & 1 deletion commands/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function action(cmd)
if ("cursor" === cmd)
return {
category: "Navigation",
interactive: false,
text: i18n("Move cursor or create selection"),
shortcut: "Ctrl+Alt+M",
interactive: true
Expand Down

0 comments on commit 96da60c

Please sign in to comment.