{"action":"created","comment":{"url":"https://api.github.com/repos/manifoldco/promptui/pulls/comments/244652898","pull_request_review_id":188573346,"id":244652898,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDY1Mjg5OA==","diff_hunk":"@@ -0,0 +1,166 @@\n+package promptui\n+\n+import \"fmt\"\n+\n+type Pointer func(to []rune) []rune\n+\n+func defaultCursor(ignored []rune) []rune {\n+\treturn []rune(\"\\u2588\")\n+}\n+func blockCursor(input []rune) []rune {\n+\treturn []rune(fmt.Sprintf(\"\\\\e[7m%s\\\\e[0m\", string(input)))\n+}\n+\n+func pipeCursor(input []rune) []rune {\n+\tmarker := []rune(\"|\")\n+\tout := []rune{}\n+\tout = append(out, marker...)\n+\tout = append(out, input...)\n+\treturn out\n+}\n+\n+var (\n+\tDefaultCursor Pointer = defaultCursor\n+\tBlockCursor   Pointer = blockCursor\n+\tPipeCursor    Pointer = pipeCursor\n+)\n+\n+// tracks the state associated with the movable cursor\n+// The strategy is to keep the prompt, input pristine except for requested\n+// modifications. The insertion of the cursor happens during a `format` call\n+// and we read in new input via an `Update` call\n+type Cursor struct {\n+\t// shows where the user inserts/updates text\n+\tCursor Pointer\n+\t// what the user entered, and what we will echo back to them, after\n+\t// insertion of the cursor and prefixing with the prompt\n+\tInput []rune\n+\t// Put the cursor before this slice\n+\tPosition int\n+}\n+\n+// create a new cursor, with the DefaultCurso, the specified input, and position\n+// at the end of the specified starting input.\n+func NewCursor(startingInput string, pointer Pointer) Cursor {\n+\tif pointer == nil {\n+\t\tpointer = defaultCursor\n+\t}\n+\treturn Cursor{Cursor: pointer, Position: len(startingInput), Input: []rune(startingInput)}\n+}\n+\n+func (c *Cursor) String() string {\n+\treturn fmt.Sprintf(\n+\t\t\"Cursor: %s, Input %s, Position %d\",\n+\t\tstring(c.Cursor([]rune(\"\"))), string(c.Input), c.Position)\n+}\n+\n+// convenience for c.Place(len(c.Input)) so you don't have to know how I\n+// indexed.\n+func (c *Cursor) End() {\n+\tc.Place(len(c.Input))\n+}\n+\n+// convenience for c.Place(0) so you don't have to know how I","path":"cursor.go","position":63,"original_position":63,"commit_id":"8913f2854c4a0173221b3592a051de3aa680f6ff","original_commit_id":"8913f2854c4a0173221b3592a051de3aa680f6ff","user":{"login":"fixmie[bot]","id":44270338,"node_id":"MDM6Qm90NDQyNzAzMzg=","avatar_url":"https://avatars0.githubusercontent.com/in/19360?v=4","gravatar_id":"","url":"https://api.github.com/users/fixmie%5Bbot%5D","html_url":"https://github.com/apps/fixmie","followers_url":"https://api.github.com/users/fixmie%5Bbot%5D/followers","following_url":"https://api.github.com/users/fixmie%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/fixmie%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/fixmie%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fixmie%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/fixmie%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/fixmie%5Bbot%5D/repos","events_url":"https://api.github.com/users/fixmie%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/fixmie%5Bbot%5D/received_events","type":"Bot","site_admin":false},"body":"existing comment doesn't match identifier \"Start\"\n```suggestion\n// Start for c.Place(0) so you don't have to know how I\n```","created_at":"2019-01-02T00:53:40Z","updated_at":"2019-01-02T00:53:40Z","html_url":"https://github.com/manifoldco/promptui/pull/86#discussion_r244652898","pull_request_url":"https://api.github.com/repos/manifoldco/promptui/pulls/86","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/manifoldco/promptui/pulls/comments/244652898"},"html":{"href":"https://github.com/manifoldco/promptui/pull/86#discussion_r244652898"},"pull_request":{"href":"https://api.github.com/repos/manifoldco/promptui/pulls/86"}}},"pull_request":{"url":"https://api.github.com/repos/manifoldco/promptui/pulls/86","id":241659092,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQxNjU5MDky","html_url":"https://github.com/manifoldco/promptui/pull/86","diff_url":"https://github.com/manifoldco/promptui/pull/86.diff","patch_url":"https://github.com/manifoldco/promptui/pull/86.patch","issue_url":"https://api.github.com/repos/manifoldco/promptui/issues/86","number":86,"state":"open","locked":false,"title":"Add support for ← and → in editable fields","user":{"login":"AWinterman","id":524923,"node_id":"MDQ6VXNlcjUyNDkyMw==","avatar_url":"https://avatars3.githubusercontent.com/u/524923?v=4","gravatar_id":"","url":"https://api.github.com/users/AWinterman","html_url":"https://github.com/AWinterman","followers_url":"https://api.github.com/users/AWinterman/followers","following_url":"https://api.github.com/users/AWinterman/following{/other_user}","gists_url":"https://api.github.com/users/AWinterman/gists{/gist_id}","starred_url":"https://api.github.com/users/AWinterman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AWinterman/subscriptions","organizations_url":"https://api.github.com/users/AWinterman/orgs","repos_url":"https://api.github.com/users/AWinterman/repos","events_url":"https://api.github.com/users/AWinterman/events{/privacy}","received_events_url":"https://api.github.com/users/AWinterman/received_events","type":"User","site_admin":false},"body":"This commit adds support for left/right arrow in Searches and Prompts (and, by\r\nextension SelectWithAdd Adds).\r\n\r\nIt does so to support use cases were user input can be computed except for a\r\nsubset of characters, which is not always on the right hand side of the default\r\ninput. E.g. my app, an exercised journal, has a field for how far I swam.\r\nYesterday I input that I swam 1600 meters. Today, I shouldn't have press delete\r\nthree times, and then re-write two zeros, in order to modify the 6 to a 7.\r\n\r\nTo support this use case I added:\r\n    1. support for specifying your cursor, since the default one obscures the\r\n       rune under it\r\n    2. support for moving cursor over existing text\r\n    3. support for editing input from wherever the cursor happens to be\r\n\r\nThe cursor positioning math is limited to the Cursor struct, in\r\npromptui/cursor.go. It is documented and tested.\r\n\r\nIt has consequences on both prompt.go and select.go, which as far as I can tell\r\ndid not have tests covering the logic I modified. I verified their functioning\r\nby running the app mentioned above.\r\n\r\nNote: I made a design choice that could be wrongheaded-- I moved the cursor to\r\nthe front of `\"AllowEdit: false\"` default text, and made it so that if the user\r\nattempts to →  into the default text, we allow them to edit it. I did so because\r\nto my mind moving into the text is a clear indication that the user would like\r\nto change it, and it is better to support the user than enforce arbitrary\r\nrules. I could be convinced otherwise.","created_at":"2019-01-02T00:53:29Z","updated_at":"2019-01-02T00:53:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"75fd34941c40cda83d7ad8407f76d50a1a2bac18","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/manifoldco/promptui/pulls/86/commits","review_comments_url":"https://api.github.com/repos/manifoldco/promptui/pulls/86/comments","review_comment_url":"https://api.github.com/repos/manifoldco/promptui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/manifoldco/promptui/issues/86/comments","statuses_url":"https://api.github.com/repos/manifoldco/promptui/statuses/8913f2854c4a0173221b3592a051de3aa680f6ff","head":{"label":"AWinterman:left-and-right-arrows","ref":"left-and-right-arrows","sha":"8913f2854c4a0173221b3592a051de3aa680f6ff","user":{"login":"AWinterman","id":524923,"node_id":"MDQ6VXNlcjUyNDkyMw==","avatar_url":"https://avatars3.githubusercontent.com/u/524923?v=4","gravatar_id":"","url":"https://api.github.com/users/AWinterman","html_url":"https://github.com/AWinterman","followers_url":"https://api.github.com/users/AWinterman/followers","following_url":"https://api.github.com/users/AWinterman/following{/other_user}","gists_url":"https://api.github.com/users/AWinterman/gists{/gist_id}","starred_url":"https://api.github.com/users/AWinterman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AWinterman/subscriptions","organizations_url":"https://api.github.com/users/AWinterman/orgs","repos_url":"https://api.github.com/users/AWinterman/repos","events_url":"https://api.github.com/users/AWinterman/events{/privacy}","received_events_url":"https://api.github.com/users/AWinterman/received_events","type":"User","site_admin":false},"repo":{"id":163777013,"node_id":"MDEwOlJlcG9zaXRvcnkxNjM3NzcwMTM=","name":"promptui","full_name":"AWinterman/promptui","private":false,"owner":{"login":"AWinterman","id":524923,"node_id":"MDQ6VXNlcjUyNDkyMw==","avatar_url":"https://avatars3.githubusercontent.com/u/524923?v=4","gravatar_id":"","url":"https://api.github.com/users/AWinterman","html_url":"https://github.com/AWinterman","followers_url":"https://api.github.com/users/AWinterman/followers","following_url":"https://api.github.com/users/AWinterman/following{/other_user}","gists_url":"https://api.github.com/users/AWinterman/gists{/gist_id}","starred_url":"https://api.github.com/users/AWinterman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AWinterman/subscriptions","organizations_url":"https://api.github.com/users/AWinterman/orgs","repos_url":"https://api.github.com/users/AWinterman/repos","events_url":"https://api.github.com/users/AWinterman/events{/privacy}","received_events_url":"https://api.github.com/users/AWinterman/received_events","type":"User","site_admin":false},"html_url":"https://github.com/AWinterman/promptui","description":"Interactive prompt for command-line applications","fork":true,"url":"https://api.github.com/repos/AWinterman/promptui","forks_url":"https://api.github.com/repos/AWinterman/promptui/forks","keys_url":"https://api.github.com/repos/AWinterman/promptui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AWinterman/promptui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AWinterman/promptui/teams","hooks_url":"https://api.github.com/repos/AWinterman/promptui/hooks","issue_events_url":"https://api.github.com/repos/AWinterman/promptui/issues/events{/number}","events_url":"https://api.github.com/repos/AWinterman/promptui/events","assignees_url":"https://api.github.com/repos/AWinterman/promptui/assignees{/user}","branches_url":"https://api.github.com/repos/AWinterman/promptui/branches{/branch}","tags_url":"https://api.github.com/repos/AWinterman/promptui/tags","blobs_url":"https://api.github.com/repos/AWinterman/promptui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AWinterman/promptui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AWinterman/promptui/git/refs{/sha}","trees_url":"https://api.github.com/repos/AWinterman/promptui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AWinterman/promptui/statuses/{sha}","languages_url":"https://api.github.com/repos/AWinterman/promptui/languages","stargazers_url":"https://api.github.com/repos/AWinterman/promptui/stargazers","contributors_url":"https://api.github.com/repos/AWinterman/promptui/contributors","subscribers_url":"https://api.github.com/repos/AWinterman/promptui/subscribers","subscription_url":"https://api.github.com/repos/AWinterman/promptui/subscription","commits_url":"https://api.github.com/repos/AWinterman/promptui/commits{/sha}","git_commits_url":"https://api.github.com/repos/AWinterman/promptui/git/commits{/sha}","comments_url":"https://api.github.com/repos/AWinterman/promptui/comments{/number}","issue_comment_url":"https://api.github.com/repos/AWinterman/promptui/issues/comments{/number}","contents_url":"https://api.github.com/repos/AWinterman/promptui/contents/{+path}","compare_url":"https://api.github.com/repos/AWinterman/promptui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AWinterman/promptui/merges","archive_url":"https://api.github.com/repos/AWinterman/promptui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AWinterman/promptui/downloads","issues_url":"https://api.github.com/repos/AWinterman/promptui/issues{/number}","pulls_url":"https://api.github.com/repos/AWinterman/promptui/pulls{/number}","milestones_url":"https://api.github.com/repos/AWinterman/promptui/milestones{/number}","notifications_url":"https://api.github.com/repos/AWinterman/promptui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AWinterman/promptui/labels{/name}","releases_url":"https://api.github.com/repos/AWinterman/promptui/releases{/id}","deployments_url":"https://api.github.com/repos/AWinterman/promptui/deployments","created_at":"2019-01-02T00:35:51Z","updated_at":"2019-01-02T00:35:53Z","pushed_at":"2019-01-02T00:51:06Z","git_url":"git://github.com/AWinterman/promptui.git","ssh_url":"git@github.com:AWinterman/promptui.git","clone_url":"https://github.com/AWinterman/promptui.git","svn_url":"https://github.com/AWinterman/promptui","homepage":"https://www.manifold.co","size":97,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"manifoldco:master","ref":"master","sha":"20f2a94120aa14a334121a6de66616a7fa89a5cd","user":{"login":"manifoldco","id":16501525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NTAxNTI1","avatar_url":"https://avatars2.githubusercontent.com/u/16501525?v=4","gravatar_id":"","url":"https://api.github.com/users/manifoldco","html_url":"https://github.com/manifoldco","followers_url":"https://api.github.com/users/manifoldco/followers","following_url":"https://api.github.com/users/manifoldco/following{/other_user}","gists_url":"https://api.github.com/users/manifoldco/gists{/gist_id}","starred_url":"https://api.github.com/users/manifoldco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manifoldco/subscriptions","organizations_url":"https://api.github.com/users/manifoldco/orgs","repos_url":"https://api.github.com/users/manifoldco/repos","events_url":"https://api.github.com/users/manifoldco/events{/privacy}","received_events_url":"https://api.github.com/users/manifoldco/received_events","type":"Organization","site_admin":false},"repo":{"id":107154646,"node_id":"MDEwOlJlcG9zaXRvcnkxMDcxNTQ2NDY=","name":"promptui","full_name":"manifoldco/promptui","private":false,"owner":{"login":"manifoldco","id":16501525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2NTAxNTI1","avatar_url":"https://avatars2.githubusercontent.com/u/16501525?v=4","gravatar_id":"","url":"https://api.github.com/users/manifoldco","html_url":"https://github.com/manifoldco","followers_url":"https://api.github.com/users/manifoldco/followers","following_url":"https://api.github.com/users/manifoldco/following{/other_user}","gists_url":"https://api.github.com/users/manifoldco/gists{/gist_id}","starred_url":"https://api.github.com/users/manifoldco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manifoldco/subscriptions","organizations_url":"https://api.github.com/users/manifoldco/orgs","repos_url":"https://api.github.com/users/manifoldco/repos","events_url":"https://api.github.com/users/manifoldco/events{/privacy}","received_events_url":"https://api.github.com/users/manifoldco/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/manifoldco/promptui","description":"Interactive prompt for command-line applications","fork":false,"url":"https://api.github.com/repos/manifoldco/promptui","forks_url":"https://api.github.com/repos/manifoldco/promptui/forks","keys_url":"https://api.github.com/repos/manifoldco/promptui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/manifoldco/promptui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/manifoldco/promptui/teams","hooks_url":"https://api.github.com/repos/manifoldco/promptui/hooks","issue_events_url":"https://api.github.com/repos/manifoldco/promptui/issues/events{/number}","events_url":"https://api.github.com/repos/manifoldco/promptui/events","assignees_url":"https://api.github.com/repos/manifoldco/promptui/assignees{/user}","branches_url":"https://api.github.com/repos/manifoldco/promptui/branches{/branch}","tags_url":"https://api.github.com/repos/manifoldco/promptui/tags","blobs_url":"https://api.github.com/repos/manifoldco/promptui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/manifoldco/promptui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/manifoldco/promptui/git/refs{/sha}","trees_url":"https://api.github.com/repos/manifoldco/promptui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/manifoldco/promptui/statuses/{sha}","languages_url":"https://api.github.com/repos/manifoldco/promptui/languages","stargazers_url":"https://api.github.com/repos/manifoldco/promptui/stargazers","contributors_url":"https://api.github.com/repos/manifoldco/promptui/contributors","subscribers_url":"https://api.github.com/repos/manifoldco/promptui/subscribers","subscription_url":"https://api.github.com/repos/manifoldco/promptui/subscription","commits_url":"https://api.github.com/repos/manifoldco/promptui/commits{/sha}","git_commits_url":"https://api.github.com/repos/manifoldco/promptui/git/commits{/sha}","comments_url":"https://api.github.com/repos/manifoldco/promptui/comments{/number}","issue_comment_url":"https://api.github.com/repos/manifoldco/promptui/issues/comments{/number}","contents_url":"https://api.github.com/repos/manifoldco/promptui/contents/{+path}","compare_url":"https://api.github.com/repos/manifoldco/promptui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/manifoldco/promptui/merges","archive_url":"https://api.github.com/repos/manifoldco/promptui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/manifoldco/promptui/downloads","issues_url":"https://api.github.com/repos/manifoldco/promptui/issues{/number}","pulls_url":"https://api.github.com/repos/manifoldco/promptui/pulls{/number}","milestones_url":"https://api.github.com/repos/manifoldco/promptui/milestones{/number}","notifications_url":"https://api.github.com/repos/manifoldco/promptui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/manifoldco/promptui/labels{/name}","releases_url":"https://api.github.com/repos/manifoldco/promptui/releases{/id}","deployments_url":"https://api.github.com/repos/manifoldco/promptui/deployments","created_at":"2017-10-16T16:35:21Z","updated_at":"2019-01-01T07:04:23Z","pushed_at":"2019-01-02T00:53:30Z","git_url":"git://github.com/manifoldco/promptui.git","ssh_url":"git@github.com:manifoldco/promptui.git","clone_url":"https://github.com/manifoldco/promptui.git","svn_url":"https://github.com/manifoldco/promptui","homepage":"https://www.manifold.co","size":97,"stargazers_count":2572,"watchers_count":2572,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":67,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":67,"open_issues":18,"watchers":2572,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/manifoldco/promptui/pulls/86"},"html":{"href":"https://github.com/manifoldco/promptui/pull/86"},"issue":{"href":"https://api.github.com/repos/manifoldco/promptui/issues/86"},"comments":{"href":"https://api.github.com/repos/manifoldco/promptui/issues/86/comments"},"review_comments":{"href":"https://api.github.com/repos/manifoldco/promptui/pulls/86/comments"},"review_comment":{"href":"https://api.github.com/repos/manifoldco/promptui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/manifoldco/promptui/pulls/86/commits"},"statuses":{"href":"https://api.github.com/repos/manifoldco/promptui/statuses/8913f2854c4a0173221b3592a051de3aa680f6ff"}},"author_association":"NONE"}}
{"actor":{"display_login":"fixmie"}}