partly implement setCaret