Backport PR #5803: unify visual line handling

Extra change on top of @ivanov pr #5768 to have more consistent handling of visual lines.

In a  long wrapped line End/Cmd-Right will go to the end of the visual line which seem more logical.
Cmd-Left beginning of line. I did note rebind Ctrl-Left because there is already custom logic in code mirror for "smart" beginning of line.
Backport PR #6005: Changed right arrow key movement function to mirror left arrow key

Seems to solve Issue #5926 on this machine, and passing the test file locally.  Changed from `cursor.movePosition` to `self._control.moveCursor`, the latter is what the left-arrow key uses.  Also removed line 1373 which seems unnecessary and which prevents the cursor from moving at all.

I'm not certain how to further test this to make sure nothing was broken.
Backport PR #6029: add pickleutil.PICKLE_PROTOCOL

instead of hardcoding `-1`.

default to DEFAULT_PROTOCOL if defined (Python 3.4), and HIGHEST_PROTOCOL
otherwise.

...
Backport PR #6061: make CORS configurable

allows setting CORS headers.

- allow_origin sets Access-Control-Allow-Origin directly
- allow_origin_pat allows setting Access-Control-Allow-Origin via regular expression, since the header spec itself doesn’t support nontrivial rules.
- allow_credentials sets Access-Control-Allow-Credentials: true
...
Backport PR #6077: allow unicode keys in dicts in json_clean

non-ascii keys would raise UnicodeEncodeError in json_clean on Python 2
Backport PR #6081: don’t modify dict keys while iterating through them

in `jsonutil.rekey`, which could prevent some keys from being modified during the iteration.

closes #5901

Fixes 'unorderable types' failure on Python 3 in test_client:
...