{"action":"created","comment":{"url":"https://api.github.com/repos/flutter/flutter/pulls/comments/59085391","id":59085391,"diff_hunk":"@@ -430,3 +463,153 @@ class _EditableLineWidget extends LeafRenderObjectWidget {\n     return new TextSpan(style: style, text: text);\n   }\n }\n+\n+enum _TextSelectionHandleSide { left, right }\n+\n+class _TextSelectionHandleOverlay extends StatefulWidget {\n+  _TextSelectionHandleOverlay({\n+    Key key,\n+    this.onSelectionHandleChanged,\n+    this.selection,\n+    this.renderObject\n+  }) : super(key: key);\n+\n+  final TextSelection selection;\n+  final ValueChanged<TextSelection> onSelectionHandleChanged;\n+  // TODO(mpcomplete): what if the renderObject is removed or replaced, or\n+  // moves? Not sure what cases I need to handle, or how to handle them.\n+  final RenderEditableLine renderObject;\n+\n+  @override\n+  _TextSelectionHandleOverlayState createState() => new _TextSelectionHandleOverlayState();\n+}\n+\n+/// The state for an overlay that displays 2 selection handles. This is intended\n+/// to be used only when there is text selected (e.g. the TextSelection is not\n+/// collapsed).\n+class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay> {\n+  TextSelection selection;\n+  List<Point> endpoints;\n+\n+  @override\n+  void initState() {\n+    super.initState();\n+    selection = config.selection;\n+    endpoints = config.renderObject.getEndpointsForSelection(selection);\n+  }\n+\n+  @override\n+  void didUpdateConfig(_TextSelectionHandleOverlay oldConfig) {\n+    setState(() {\n+      selection = config.selection;\n+      endpoints = config.renderObject.getEndpointsForSelection(selection);\n+    });\n+  }\n+\n+  Point _dragPosition;\n+  void _dragStart(Point position, _TextSelectionHandleSide side) {\n+    _dragPosition = position;\n+  }\n+\n+  void _dragUpdate(double delta, _TextSelectionHandleSide side) {\n+    _dragPosition = _dragPosition + new Offset(delta, 0.0);\n+    TextPosition position = config.renderObject.getPositionForPoint(_dragPosition);\n+\n+    TextSelection newSelection;\n+    if (side == _TextSelectionHandleSide.left) {\n+      newSelection = new TextSelection(\n+        baseOffset: position.offset,\n+        extentOffset: selection.extentOffset\n+      );\n+    } else {\n+      newSelection = new TextSelection(\n+        baseOffset: selection.baseOffset,\n+        extentOffset: position.offset\n+      );\n+    }\n+\n+    if (newSelection.baseOffset >= newSelection.extentOffset)\n+      return;\n+\n+    setState(() {\n+      selection = newSelection;\n+      endpoints = config.renderObject.getEndpointsForSelection(selection);\n+      config.onSelectionHandleChanged(selection);\n+    });\n+  }\n+\n+  @override\n+  Widget build(BuildContext context) {\n+    return new Stack(\n+      children: <Widget>[\n+        new GestureDetector(\n+          onHorizontalDragStart: (Point p) { _dragStart(p, _TextSelectionHandleSide.left); },\n+          onHorizontalDragUpdate: (double d) { _dragUpdate(d, _TextSelectionHandleSide.left); },\n+          child: new CustomPaint(\n+            foregroundPainter: new _TextSelectionHandlePainter(","path":"packages/flutter/lib/src/widgets/editable.dart","position":175,"original_position":175,"commit_id":"138063394fa762d7894339366158396c8021d955","original_commit_id":"138063394fa762d7894339366158396c8021d955","user":{"login":"abarth","id":112007,"avatar_url":"https://avatars.githubusercontent.com/u/112007?v=3","gravatar_id":"","url":"https://api.github.com/users/abarth","html_url":"https://github.com/abarth","followers_url":"https://api.github.com/users/abarth/followers","following_url":"https://api.github.com/users/abarth/following{/other_user}","gists_url":"https://api.github.com/users/abarth/gists{/gist_id}","starred_url":"https://api.github.com/users/abarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abarth/subscriptions","organizations_url":"https://api.github.com/users/abarth/orgs","repos_url":"https://api.github.com/users/abarth/repos","events_url":"https://api.github.com/users/abarth/events{/privacy}","received_events_url":"https://api.github.com/users/abarth/received_events","type":"User","site_admin":false},"body":"Why a foreground painter and not just a regular painter?  This widget doesn't have any children.\r\n\r\nAlso, what determines the size of the CustomPaint widget?","created_at":"2016-04-08T20:34:18Z","updated_at":"2016-04-08T20:34:18Z","html_url":"https://github.com/flutter/flutter/pull/3223#discussion_r59085391","pull_request_url":"https://api.github.com/repos/flutter/flutter/pulls/3223","_links":{"self":{"href":"https://api.github.com/repos/flutter/flutter/pulls/comments/59085391"},"html":{"href":"https://github.com/flutter/flutter/pull/3223#discussion_r59085391"},"pull_request":{"href":"https://api.github.com/repos/flutter/flutter/pulls/3223"}}},"pull_request":{"url":"https://api.github.com/repos/flutter/flutter/pulls/3223","id":65840328,"html_url":"https://github.com/flutter/flutter/pull/3223","diff_url":"https://github.com/flutter/flutter/pull/3223.diff","patch_url":"https://github.com/flutter/flutter/pull/3223.patch","issue_url":"https://api.github.com/repos/flutter/flutter/issues/3223","number":3223,"state":"open","locked":false,"title":"Add basic text selection to editable text.","user":{"login":"mpcomplete","id":1071986,"avatar_url":"https://avatars.githubusercontent.com/u/1071986?v=3","gravatar_id":"","url":"https://api.github.com/users/mpcomplete","html_url":"https://github.com/mpcomplete","followers_url":"https://api.github.com/users/mpcomplete/followers","following_url":"https://api.github.com/users/mpcomplete/following{/other_user}","gists_url":"https://api.github.com/users/mpcomplete/gists{/gist_id}","starred_url":"https://api.github.com/users/mpcomplete/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpcomplete/subscriptions","organizations_url":"https://api.github.com/users/mpcomplete/orgs","repos_url":"https://api.github.com/users/mpcomplete/repos","events_url":"https://api.github.com/users/mpcomplete/events{/privacy}","received_events_url":"https://api.github.com/users/mpcomplete/received_events","type":"User","site_admin":false},"body":"Only partially works. Editing the selected text doesn't work, which\r\nprobably will require engine changes. Currently only draws the selected\r\ntext and allows you to manipulate the selection with draggable selection\r\nhandles.","created_at":"2016-04-08T20:07:50Z","updated_at":"2016-04-08T20:34:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c61ab56f6d65b6704b346c7fe3e0ce00f50c82b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/flutter/flutter/pulls/3223/commits","review_comments_url":"https://api.github.com/repos/flutter/flutter/pulls/3223/comments","review_comment_url":"https://api.github.com/repos/flutter/flutter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/flutter/flutter/issues/3223/comments","statuses_url":"https://api.github.com/repos/flutter/flutter/statuses/138063394fa762d7894339366158396c8021d955","head":{"label":"mpcomplete:selection","ref":"selection","sha":"138063394fa762d7894339366158396c8021d955","user":{"login":"mpcomplete","id":1071986,"avatar_url":"https://avatars.githubusercontent.com/u/1071986?v=3","gravatar_id":"","url":"https://api.github.com/users/mpcomplete","html_url":"https://github.com/mpcomplete","followers_url":"https://api.github.com/users/mpcomplete/followers","following_url":"https://api.github.com/users/mpcomplete/following{/other_user}","gists_url":"https://api.github.com/users/mpcomplete/gists{/gist_id}","starred_url":"https://api.github.com/users/mpcomplete/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpcomplete/subscriptions","organizations_url":"https://api.github.com/users/mpcomplete/orgs","repos_url":"https://api.github.com/users/mpcomplete/repos","events_url":"https://api.github.com/users/mpcomplete/events{/privacy}","received_events_url":"https://api.github.com/users/mpcomplete/received_events","type":"User","site_admin":false},"repo":{"id":45862350,"name":"flutter","full_name":"mpcomplete/flutter","owner":{"login":"mpcomplete","id":1071986,"avatar_url":"https://avatars.githubusercontent.com/u/1071986?v=3","gravatar_id":"","url":"https://api.github.com/users/mpcomplete","html_url":"https://github.com/mpcomplete","followers_url":"https://api.github.com/users/mpcomplete/followers","following_url":"https://api.github.com/users/mpcomplete/following{/other_user}","gists_url":"https://api.github.com/users/mpcomplete/gists{/gist_id}","starred_url":"https://api.github.com/users/mpcomplete/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpcomplete/subscriptions","organizations_url":"https://api.github.com/users/mpcomplete/orgs","repos_url":"https://api.github.com/users/mpcomplete/repos","events_url":"https://api.github.com/users/mpcomplete/events{/privacy}","received_events_url":"https://api.github.com/users/mpcomplete/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mpcomplete/flutter","description":"The Flutter framework","fork":true,"url":"https://api.github.com/repos/mpcomplete/flutter","forks_url":"https://api.github.com/repos/mpcomplete/flutter/forks","keys_url":"https://api.github.com/repos/mpcomplete/flutter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mpcomplete/flutter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mpcomplete/flutter/teams","hooks_url":"https://api.github.com/repos/mpcomplete/flutter/hooks","issue_events_url":"https://api.github.com/repos/mpcomplete/flutter/issues/events{/number}","events_url":"https://api.github.com/repos/mpcomplete/flutter/events","assignees_url":"https://api.github.com/repos/mpcomplete/flutter/assignees{/user}","branches_url":"https://api.github.com/repos/mpcomplete/flutter/branches{/branch}","tags_url":"https://api.github.com/repos/mpcomplete/flutter/tags","blobs_url":"https://api.github.com/repos/mpcomplete/flutter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mpcomplete/flutter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mpcomplete/flutter/git/refs{/sha}","trees_url":"https://api.github.com/repos/mpcomplete/flutter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mpcomplete/flutter/statuses/{sha}","languages_url":"https://api.github.com/repos/mpcomplete/flutter/languages","stargazers_url":"https://api.github.com/repos/mpcomplete/flutter/stargazers","contributors_url":"https://api.github.com/repos/mpcomplete/flutter/contributors","subscribers_url":"https://api.github.com/repos/mpcomplete/flutter/subscribers","subscription_url":"https://api.github.com/repos/mpcomplete/flutter/subscription","commits_url":"https://api.github.com/repos/mpcomplete/flutter/commits{/sha}","git_commits_url":"https://api.github.com/repos/mpcomplete/flutter/git/commits{/sha}","comments_url":"https://api.github.com/repos/mpcomplete/flutter/comments{/number}","issue_comment_url":"https://api.github.com/repos/mpcomplete/flutter/issues/comments{/number}","contents_url":"https://api.github.com/repos/mpcomplete/flutter/contents/{+path}","compare_url":"https://api.github.com/repos/mpcomplete/flutter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mpcomplete/flutter/merges","archive_url":"https://api.github.com/repos/mpcomplete/flutter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mpcomplete/flutter/downloads","issues_url":"https://api.github.com/repos/mpcomplete/flutter/issues{/number}","pulls_url":"https://api.github.com/repos/mpcomplete/flutter/pulls{/number}","milestones_url":"https://api.github.com/repos/mpcomplete/flutter/milestones{/number}","notifications_url":"https://api.github.com/repos/mpcomplete/flutter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mpcomplete/flutter/labels{/name}","releases_url":"https://api.github.com/repos/mpcomplete/flutter/releases{/id}","deployments_url":"https://api.github.com/repos/mpcomplete/flutter/deployments","created_at":"2015-11-09T19:43:57Z","updated_at":"2015-11-09T19:43:59Z","pushed_at":"2016-04-08T20:07:23Z","git_url":"git://github.com/mpcomplete/flutter.git","ssh_url":"git@github.com:mpcomplete/flutter.git","clone_url":"https://github.com/mpcomplete/flutter.git","svn_url":"https://github.com/mpcomplete/flutter","homepage":"http://flutter.io","size":15469,"stargazers_count":0,"watchers_count":0,"language":"Dart","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"flutter:master","ref":"master","sha":"295d3749bd175340ee0d292c0d9dd8e85a65788e","user":{"login":"flutter","id":14101776,"avatar_url":"https://avatars.githubusercontent.com/u/14101776?v=3","gravatar_id":"","url":"https://api.github.com/users/flutter","html_url":"https://github.com/flutter","followers_url":"https://api.github.com/users/flutter/followers","following_url":"https://api.github.com/users/flutter/following{/other_user}","gists_url":"https://api.github.com/users/flutter/gists{/gist_id}","starred_url":"https://api.github.com/users/flutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flutter/subscriptions","organizations_url":"https://api.github.com/users/flutter/orgs","repos_url":"https://api.github.com/users/flutter/repos","events_url":"https://api.github.com/users/flutter/events{/privacy}","received_events_url":"https://api.github.com/users/flutter/received_events","type":"Organization","site_admin":false},"repo":{"id":31792824,"name":"flutter","full_name":"flutter/flutter","owner":{"login":"flutter","id":14101776,"avatar_url":"https://avatars.githubusercontent.com/u/14101776?v=3","gravatar_id":"","url":"https://api.github.com/users/flutter","html_url":"https://github.com/flutter","followers_url":"https://api.github.com/users/flutter/followers","following_url":"https://api.github.com/users/flutter/following{/other_user}","gists_url":"https://api.github.com/users/flutter/gists{/gist_id}","starred_url":"https://api.github.com/users/flutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flutter/subscriptions","organizations_url":"https://api.github.com/users/flutter/orgs","repos_url":"https://api.github.com/users/flutter/repos","events_url":"https://api.github.com/users/flutter/events{/privacy}","received_events_url":"https://api.github.com/users/flutter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flutter/flutter","description":"Framework for building high-performance, high-fidelity iOS and Android apps","fork":false,"url":"https://api.github.com/repos/flutter/flutter","forks_url":"https://api.github.com/repos/flutter/flutter/forks","keys_url":"https://api.github.com/repos/flutter/flutter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flutter/flutter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flutter/flutter/teams","hooks_url":"https://api.github.com/repos/flutter/flutter/hooks","issue_events_url":"https://api.github.com/repos/flutter/flutter/issues/events{/number}","events_url":"https://api.github.com/repos/flutter/flutter/events","assignees_url":"https://api.github.com/repos/flutter/flutter/assignees{/user}","branches_url":"https://api.github.com/repos/flutter/flutter/branches{/branch}","tags_url":"https://api.github.com/repos/flutter/flutter/tags","blobs_url":"https://api.github.com/repos/flutter/flutter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flutter/flutter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flutter/flutter/git/refs{/sha}","trees_url":"https://api.github.com/repos/flutter/flutter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flutter/flutter/statuses/{sha}","languages_url":"https://api.github.com/repos/flutter/flutter/languages","stargazers_url":"https://api.github.com/repos/flutter/flutter/stargazers","contributors_url":"https://api.github.com/repos/flutter/flutter/contributors","subscribers_url":"https://api.github.com/repos/flutter/flutter/subscribers","subscription_url":"https://api.github.com/repos/flutter/flutter/subscription","commits_url":"https://api.github.com/repos/flutter/flutter/commits{/sha}","git_commits_url":"https://api.github.com/repos/flutter/flutter/git/commits{/sha}","comments_url":"https://api.github.com/repos/flutter/flutter/comments{/number}","issue_comment_url":"https://api.github.com/repos/flutter/flutter/issues/comments{/number}","contents_url":"https://api.github.com/repos/flutter/flutter/contents/{+path}","compare_url":"https://api.github.com/repos/flutter/flutter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flutter/flutter/merges","archive_url":"https://api.github.com/repos/flutter/flutter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flutter/flutter/downloads","issues_url":"https://api.github.com/repos/flutter/flutter/issues{/number}","pulls_url":"https://api.github.com/repos/flutter/flutter/pulls{/number}","milestones_url":"https://api.github.com/repos/flutter/flutter/milestones{/number}","notifications_url":"https://api.github.com/repos/flutter/flutter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flutter/flutter/labels{/name}","releases_url":"https://api.github.com/repos/flutter/flutter/releases{/id}","deployments_url":"https://api.github.com/repos/flutter/flutter/deployments","created_at":"2015-03-06T22:54:58Z","updated_at":"2016-04-08T10:41:54Z","pushed_at":"2016-04-08T20:19:25Z","git_url":"git://github.com/flutter/flutter.git","ssh_url":"git@github.com:flutter/flutter.git","clone_url":"https://github.com/flutter/flutter.git","svn_url":"https://github.com/flutter/flutter","homepage":"http://flutter.io","size":109115,"stargazers_count":2741,"watchers_count":2741,"language":"Dart","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":275,"mirror_url":null,"open_issues_count":777,"forks":275,"open_issues":777,"watchers":2741,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flutter/flutter/pulls/3223"},"html":{"href":"https://github.com/flutter/flutter/pull/3223"},"issue":{"href":"https://api.github.com/repos/flutter/flutter/issues/3223"},"comments":{"href":"https://api.github.com/repos/flutter/flutter/issues/3223/comments"},"review_comments":{"href":"https://api.github.com/repos/flutter/flutter/pulls/3223/comments"},"review_comment":{"href":"https://api.github.com/repos/flutter/flutter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/flutter/flutter/pulls/3223/commits"},"statuses":{"href":"https://api.github.com/repos/flutter/flutter/statuses/138063394fa762d7894339366158396c8021d955"}}}}