#!/bin/bash
pdf_full=$1
pdf_dir=$(dirname $pdf_full)
pdf_slice=$(basename $pdf_full)
pdf_base=${pdf_slice#_whizzy_}
pdf_file=$pdf_dir/$pdf_base
pdf_tex=$(basename $pdf_base .wpdf).tex
page=$(($2 + 1)) # The page number star at zero in llpp
x=$3
y=$4
context=$5

# for vim
# synctex edit -o "$page:$x:$y:$pdf_file" \
#        -x "gvim --servername synctex --remote-wait-silent +%{line} '%{input}'"

# for testing/debugging
case "$5" in
    "") ;;
    *) synctex edit -o "$page:$x:$y:$pdf_file" -x "echo #line %{line}:%{column}+%{offset}:${context} '<<<<'$context>><<>>>>' '%{input}'"
esac 

# for emacs
# synctex edit -o "$page:$x:$y:$pdf_file" -x "emacsclient +%{line} '%{input}' -n"
synctex edit -o "$page:$x:$y:$pdf_file" -x "echo #line %{line}:%{column}+%{offset}:${context} '<<<<'$context>><<>>>>' '%{input}'"


