Skip to content

Conversation

@wingeng
Copy link

@wingeng wingeng commented May 2, 2014

Just adding something I use all the time on cli.

First time with pull request, hope this works.

thanks
wing

wing added 2 commits May 2, 2014 06:16
words are series of alpha-numeric character.  Use !isalnum() to find
the separators.
linenoise.c Outdated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor issue I noticed is that trying to move to the beginning of a line starting with whitespace (or any other separators) stops after the first character (e.g. ..^a moves to .^.a, where ^ is the cursor). Adding an exemption here if the cursor position is 0 should fix this:

if (isWordSep(l->buf[l->pos]) && l->pos != 0) l->pos++;

Other than that, I can't find any problems. 👍

lethosor found issue when there are separator chars at beginning of
line.  The code didn't allow the cursor at position 0.

Fixed the while loop to break out when pos is at the first char of
word. No need to fixing the position afterwards like the original
loop.  So the cursor can now go to pos 0 even when it contains a
separator character.
@wingeng
Copy link
Author

wingeng commented May 27, 2014

Fixed the problem of the edge case by modifying the loop that moves the cursor over a word. It stops at the first char of the word boundary. It does this by looking at the char to the left of the current line position, breaking out of the loop if that char is not a word separator.

Added bonus, decrease line count by 2 :)

wing and others added 5 commits March 4, 2015 04:56
Handle the delete-next word key sequence of
  Alt-d

Map Alt-h, Alt-BACKSPACE to delete previous word.
Start implementation of help ('?' handling)

Add command handler to example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants