Fixed issue #1928: Hotkeys in "Show log" dialog for navigating back / forward

This work are based on previous @csware's work. Thank @csware.
 * cherry pick @csware's commit e8f858b
 * test it
 * fix some bug
 * extend it
 * rebase it onto master

My work is split to many commits,
so that you can drop any one you don't like.
Then, spuash the left commits.
(drop all? oh~ a little sad, but I will be fine. :) )

I also write some examples to help people understand the logic, please see 75dcdbe.

any review, advice and help will be appreciated. 

Thank you. ^_^
Small improvement: lastselected.size() is used several times. Store it to a variable so that the size doesn't need to be recalculated again and again.