implements new JS cursor API (see #221)