{"action":"created","comment":{"url":"https://api.github.com/repos/keyme/visual-diff/pulls/comments/94251556","pull_request_review_id":14782807,"id":94251556,"diff_hunk":"@@ -0,0 +1,124 @@\n+#!/usr/bin/python3\n+\n+import functools\n+import tkinter as tk\n+\n+from zoom_map import ZoomMap\n+\n+\n+class _Context(tk.Text):\n+    CONTEXT_COUNT = 3  # Lines to display before/after the current one\n+    # TODO: What about files with over 99,999 lines?\n+    LINE_NUMBER_WIDTH = 5  # Number of characters to allocate for line numbers\n+    PRELUDE_WIDTH = LINE_NUMBER_WIDTH + 2  # Line number, colon, space\n+    # TODO: What about files with very long lines? They currently wrap around to\n+    # the next line and push later context out of the widget. Should we truncate\n+    # them instead? and if so, should we change which part gets cut based on the\n+    # location of the token within the line?\n+    TEXT_WIDTH = 80\n+\n+    def __init__(self, tk_parent, data, axis, zoom_map):\n+        height = 1 + 2 * self.CONTEXT_COUNT","path":"gui.py","position":21,"original_position":21,"commit_id":"8e3f784407c9dd01eb9e9ee971f79e8a430813ff","original_commit_id":"8e3f784407c9dd01eb9e9ee971f79e8a430813ff","user":{"login":"penguinland","id":2861124,"avatar_url":"https://avatars.githubusercontent.com/u/2861124?v=3","gravatar_id":"","url":"https://api.github.com/users/penguinland","html_url":"https://github.com/penguinland","followers_url":"https://api.github.com/users/penguinland/followers","following_url":"https://api.github.com/users/penguinland/following{/other_user}","gists_url":"https://api.github.com/users/penguinland/gists{/gist_id}","starred_url":"https://api.github.com/users/penguinland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/penguinland/subscriptions","organizations_url":"https://api.github.com/users/penguinland/orgs","repos_url":"https://api.github.com/users/penguinland/repos","events_url":"https://api.github.com/users/penguinland/events{/privacy}","received_events_url":"https://api.github.com/users/penguinland/received_events","type":"User","site_admin":false},"body":"Would it help if I put the \"+ 1\" at the end instead? Parens seem like overkill.","created_at":"2016-12-30T19:17:59Z","updated_at":"2016-12-30T19:17:59Z","html_url":"https://github.com/keyme/visual-diff/pull/2#discussion_r94251556","pull_request_url":"https://api.github.com/repos/keyme/visual-diff/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/keyme/visual-diff/pulls/comments/94251556"},"html":{"href":"https://github.com/keyme/visual-diff/pull/2#discussion_r94251556"},"pull_request":{"href":"https://api.github.com/repos/keyme/visual-diff/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/keyme/visual-diff/pulls/2","id":99772728,"html_url":"https://github.com/keyme/visual-diff/pull/2","diff_url":"https://github.com/keyme/visual-diff/pull/2.diff","patch_url":"https://github.com/keyme/visual-diff/pull/2.patch","issue_url":"https://api.github.com/repos/keyme/visual-diff/issues/2","number":2,"state":"open","locked":false,"title":"First stab at a GUI","user":{"login":"penguinland","id":2861124,"avatar_url":"https://avatars.githubusercontent.com/u/2861124?v=3","gravatar_id":"","url":"https://api.github.com/users/penguinland","html_url":"https://github.com/penguinland","followers_url":"https://api.github.com/users/penguinland/followers","following_url":"https://api.github.com/users/penguinland/following{/other_user}","gists_url":"https://api.github.com/users/penguinland/gists{/gist_id}","starred_url":"https://api.github.com/users/penguinland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/penguinland/subscriptions","organizations_url":"https://api.github.com/users/penguinland/orgs","repos_url":"https://api.github.com/users/penguinland/repos","events_url":"https://api.github.com/users/penguinland/events{/privacy}","received_events_url":"https://api.github.com/users/penguinland/received_events","type":"User","site_admin":false},"body":"@Jeff-Ciesielski convinced me to send out a PR for this even though it only half-works right now. This desperately needs squashing, but that can come at the end of the code review.\r\n\r\nTo get this to run, I had to `sudo apt-get install python3-pil.imagetk`. I might have had to do other things, too; LMK what you have to install for this.\r\n\r\nThings that work:\r\n- Use the `--gui` option to open up the GUI. Don't use this on very large source files; it doesn't yet have a way to limit the size of the image displayed to the screen!\r\n- You can quit with control-w or control-q.\r\n- Mouse over the image part to see the relevant source code in the text boxes below. \r\n- Zoom out and back in with the scroll wheel (Linux only; I think there's different bindings on Windows/Mac).\r\n- In the text box, the token represented by the pixel under the mouse is highlighted. If you zoom out, multiple tokens are represented by a single pixel, and all of them will be highlighted.\r\n- Click and drag to print stuff about clicking and dragging, but you can't actually pan around the image yet.\r\n\r\nThings that don't work:\r\n- Click-and-drag to pan around the image. I imagine the interface will eventually be similar to Google Maps, but I'm not there yet.\r\n- Restricting the on-screen part of the image to a maximum size, so large ones don't overwhelm your system\r\n- We only have 5 levels of zoom. This should be replaced with a variable number of levels depending on how many tokens we're dealing with.\r\n- Line numbers are allocated 5 characters. Things might go poorly if you run this on a file with more than 99,999 lines (highlighting tokens will be off, for instance). Similarly, horizontal space is wasted if you run this on a file with less than 10,000 lines.\r\n- Zooming with the scroll wheel on Windows/Mac?\r\n- The TK widget for the image appears 1 pixel larger (both taller and wider) than the image itself. I wonder if I have off-by-one errors.\r\n- There are a bunch of TODO statements in the code. Some of them might get taken out eventually. <_<\r\n\r\nSuggested order for reading: \r\n- visual_diff.py, since it's the main program. \r\n- zoom_map.py, since it's self-contained and obvious\r\n- gui.py, since it's the only one left.","created_at":"2016-12-30T18:19:25Z","updated_at":"2016-12-30T19:17:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ba7c37c247f056d322c455e92900c0ca67256271","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/keyme/visual-diff/pulls/2/commits","review_comments_url":"https://api.github.com/repos/keyme/visual-diff/pulls/2/comments","review_comment_url":"https://api.github.com/repos/keyme/visual-diff/pulls/comments{/number}","comments_url":"https://api.github.com/repos/keyme/visual-diff/issues/2/comments","statuses_url":"https://api.github.com/repos/keyme/visual-diff/statuses/8e3f784407c9dd01eb9e9ee971f79e8a430813ff","head":{"label":"penguinland:learn_tkinter","ref":"learn_tkinter","sha":"8e3f784407c9dd01eb9e9ee971f79e8a430813ff","user":{"login":"penguinland","id":2861124,"avatar_url":"https://avatars.githubusercontent.com/u/2861124?v=3","gravatar_id":"","url":"https://api.github.com/users/penguinland","html_url":"https://github.com/penguinland","followers_url":"https://api.github.com/users/penguinland/followers","following_url":"https://api.github.com/users/penguinland/following{/other_user}","gists_url":"https://api.github.com/users/penguinland/gists{/gist_id}","starred_url":"https://api.github.com/users/penguinland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/penguinland/subscriptions","organizations_url":"https://api.github.com/users/penguinland/orgs","repos_url":"https://api.github.com/users/penguinland/repos","events_url":"https://api.github.com/users/penguinland/events{/privacy}","received_events_url":"https://api.github.com/users/penguinland/received_events","type":"User","site_admin":false},"repo":{"id":76898843,"name":"visual-diff","full_name":"penguinland/visual-diff","owner":{"login":"penguinland","id":2861124,"avatar_url":"https://avatars.githubusercontent.com/u/2861124?v=3","gravatar_id":"","url":"https://api.github.com/users/penguinland","html_url":"https://github.com/penguinland","followers_url":"https://api.github.com/users/penguinland/followers","following_url":"https://api.github.com/users/penguinland/following{/other_user}","gists_url":"https://api.github.com/users/penguinland/gists{/gist_id}","starred_url":"https://api.github.com/users/penguinland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/penguinland/subscriptions","organizations_url":"https://api.github.com/users/penguinland/orgs","repos_url":"https://api.github.com/users/penguinland/repos","events_url":"https://api.github.com/users/penguinland/events{/privacy}","received_events_url":"https://api.github.com/users/penguinland/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/penguinland/visual-diff","description":"A tool for generating a visual comparison of two source code files.","fork":true,"url":"https://api.github.com/repos/penguinland/visual-diff","forks_url":"https://api.github.com/repos/penguinland/visual-diff/forks","keys_url":"https://api.github.com/repos/penguinland/visual-diff/keys{/key_id}","collaborators_url":"https://api.github.com/repos/penguinland/visual-diff/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/penguinland/visual-diff/teams","hooks_url":"https://api.github.com/repos/penguinland/visual-diff/hooks","issue_events_url":"https://api.github.com/repos/penguinland/visual-diff/issues/events{/number}","events_url":"https://api.github.com/repos/penguinland/visual-diff/events","assignees_url":"https://api.github.com/repos/penguinland/visual-diff/assignees{/user}","branches_url":"https://api.github.com/repos/penguinland/visual-diff/branches{/branch}","tags_url":"https://api.github.com/repos/penguinland/visual-diff/tags","blobs_url":"https://api.github.com/repos/penguinland/visual-diff/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/penguinland/visual-diff/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/penguinland/visual-diff/git/refs{/sha}","trees_url":"https://api.github.com/repos/penguinland/visual-diff/git/trees{/sha}","statuses_url":"https://api.github.com/repos/penguinland/visual-diff/statuses/{sha}","languages_url":"https://api.github.com/repos/penguinland/visual-diff/languages","stargazers_url":"https://api.github.com/repos/penguinland/visual-diff/stargazers","contributors_url":"https://api.github.com/repos/penguinland/visual-diff/contributors","subscribers_url":"https://api.github.com/repos/penguinland/visual-diff/subscribers","subscription_url":"https://api.github.com/repos/penguinland/visual-diff/subscription","commits_url":"https://api.github.com/repos/penguinland/visual-diff/commits{/sha}","git_commits_url":"https://api.github.com/repos/penguinland/visual-diff/git/commits{/sha}","comments_url":"https://api.github.com/repos/penguinland/visual-diff/comments{/number}","issue_comment_url":"https://api.github.com/repos/penguinland/visual-diff/issues/comments{/number}","contents_url":"https://api.github.com/repos/penguinland/visual-diff/contents/{+path}","compare_url":"https://api.github.com/repos/penguinland/visual-diff/compare/{base}...{head}","merges_url":"https://api.github.com/repos/penguinland/visual-diff/merges","archive_url":"https://api.github.com/repos/penguinland/visual-diff/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/penguinland/visual-diff/downloads","issues_url":"https://api.github.com/repos/penguinland/visual-diff/issues{/number}","pulls_url":"https://api.github.com/repos/penguinland/visual-diff/pulls{/number}","milestones_url":"https://api.github.com/repos/penguinland/visual-diff/milestones{/number}","notifications_url":"https://api.github.com/repos/penguinland/visual-diff/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/penguinland/visual-diff/labels{/name}","releases_url":"https://api.github.com/repos/penguinland/visual-diff/releases{/id}","deployments_url":"https://api.github.com/repos/penguinland/visual-diff/deployments","created_at":"2016-12-19T21:30:58Z","updated_at":"2016-12-19T21:47:20Z","pushed_at":"2016-12-30T18:10:08Z","git_url":"git://github.com/penguinland/visual-diff.git","ssh_url":"git@github.com:penguinland/visual-diff.git","clone_url":"https://github.com/penguinland/visual-diff.git","svn_url":"https://github.com/penguinland/visual-diff","homepage":null,"size":24,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"keyme:master","ref":"master","sha":"8683d0b09d8a7dfe8dde4aac73558f8c0700330a","user":{"login":"keyme","id":3791919,"avatar_url":"https://avatars.githubusercontent.com/u/3791919?v=3","gravatar_id":"","url":"https://api.github.com/users/keyme","html_url":"https://github.com/keyme","followers_url":"https://api.github.com/users/keyme/followers","following_url":"https://api.github.com/users/keyme/following{/other_user}","gists_url":"https://api.github.com/users/keyme/gists{/gist_id}","starred_url":"https://api.github.com/users/keyme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keyme/subscriptions","organizations_url":"https://api.github.com/users/keyme/orgs","repos_url":"https://api.github.com/users/keyme/repos","events_url":"https://api.github.com/users/keyme/events{/privacy}","received_events_url":"https://api.github.com/users/keyme/received_events","type":"Organization","site_admin":false},"repo":{"id":76898416,"name":"visual-diff","full_name":"keyme/visual-diff","owner":{"login":"keyme","id":3791919,"avatar_url":"https://avatars.githubusercontent.com/u/3791919?v=3","gravatar_id":"","url":"https://api.github.com/users/keyme","html_url":"https://github.com/keyme","followers_url":"https://api.github.com/users/keyme/followers","following_url":"https://api.github.com/users/keyme/following{/other_user}","gists_url":"https://api.github.com/users/keyme/gists{/gist_id}","starred_url":"https://api.github.com/users/keyme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keyme/subscriptions","organizations_url":"https://api.github.com/users/keyme/orgs","repos_url":"https://api.github.com/users/keyme/repos","events_url":"https://api.github.com/users/keyme/events{/privacy}","received_events_url":"https://api.github.com/users/keyme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keyme/visual-diff","description":"A tool for generating a visual comparison of two source code files.","fork":false,"url":"https://api.github.com/repos/keyme/visual-diff","forks_url":"https://api.github.com/repos/keyme/visual-diff/forks","keys_url":"https://api.github.com/repos/keyme/visual-diff/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keyme/visual-diff/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keyme/visual-diff/teams","hooks_url":"https://api.github.com/repos/keyme/visual-diff/hooks","issue_events_url":"https://api.github.com/repos/keyme/visual-diff/issues/events{/number}","events_url":"https://api.github.com/repos/keyme/visual-diff/events","assignees_url":"https://api.github.com/repos/keyme/visual-diff/assignees{/user}","branches_url":"https://api.github.com/repos/keyme/visual-diff/branches{/branch}","tags_url":"https://api.github.com/repos/keyme/visual-diff/tags","blobs_url":"https://api.github.com/repos/keyme/visual-diff/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keyme/visual-diff/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keyme/visual-diff/git/refs{/sha}","trees_url":"https://api.github.com/repos/keyme/visual-diff/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keyme/visual-diff/statuses/{sha}","languages_url":"https://api.github.com/repos/keyme/visual-diff/languages","stargazers_url":"https://api.github.com/repos/keyme/visual-diff/stargazers","contributors_url":"https://api.github.com/repos/keyme/visual-diff/contributors","subscribers_url":"https://api.github.com/repos/keyme/visual-diff/subscribers","subscription_url":"https://api.github.com/repos/keyme/visual-diff/subscription","commits_url":"https://api.github.com/repos/keyme/visual-diff/commits{/sha}","git_commits_url":"https://api.github.com/repos/keyme/visual-diff/git/commits{/sha}","comments_url":"https://api.github.com/repos/keyme/visual-diff/comments{/number}","issue_comment_url":"https://api.github.com/repos/keyme/visual-diff/issues/comments{/number}","contents_url":"https://api.github.com/repos/keyme/visual-diff/contents/{+path}","compare_url":"https://api.github.com/repos/keyme/visual-diff/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keyme/visual-diff/merges","archive_url":"https://api.github.com/repos/keyme/visual-diff/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keyme/visual-diff/downloads","issues_url":"https://api.github.com/repos/keyme/visual-diff/issues{/number}","pulls_url":"https://api.github.com/repos/keyme/visual-diff/pulls{/number}","milestones_url":"https://api.github.com/repos/keyme/visual-diff/milestones{/number}","notifications_url":"https://api.github.com/repos/keyme/visual-diff/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keyme/visual-diff/labels{/name}","releases_url":"https://api.github.com/repos/keyme/visual-diff/releases{/id}","deployments_url":"https://api.github.com/repos/keyme/visual-diff/deployments","created_at":"2016-12-19T21:24:24Z","updated_at":"2016-12-19T21:46:53Z","pushed_at":"2016-12-30T18:19:25Z","git_url":"git://github.com/keyme/visual-diff.git","ssh_url":"git@github.com:keyme/visual-diff.git","clone_url":"https://github.com/keyme/visual-diff.git","svn_url":"https://github.com/keyme/visual-diff","homepage":null,"size":13,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/keyme/visual-diff/pulls/2"},"html":{"href":"https://github.com/keyme/visual-diff/pull/2"},"issue":{"href":"https://api.github.com/repos/keyme/visual-diff/issues/2"},"comments":{"href":"https://api.github.com/repos/keyme/visual-diff/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/keyme/visual-diff/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/keyme/visual-diff/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/keyme/visual-diff/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/keyme/visual-diff/statuses/8e3f784407c9dd01eb9e9ee971f79e8a430813ff"}}}}
{"actor":{"display_login":"penguinland"}}