{"action":"created","issue":{"url":"https://api.github.com/repos/pexpect/pexpect/issues/186","labels_url":"https://api.github.com/repos/pexpect/pexpect/issues/186/labels{/name}","comments_url":"https://api.github.com/repos/pexpect/pexpect/issues/186/comments","events_url":"https://api.github.com/repos/pexpect/pexpect/issues/186/events","html_url":"https://github.com/pexpect/pexpect/issues/186","id":61791287,"number":186,"title":"ANSI seems to wrap when a line fits exactly","user":{"login":"detly","id":311239,"avatar_url":"https://avatars.githubusercontent.com/u/311239?v=3","gravatar_id":"","url":"https://api.github.com/users/detly","html_url":"https://github.com/detly","followers_url":"https://api.github.com/users/detly/followers","following_url":"https://api.github.com/users/detly/following{/other_user}","gists_url":"https://api.github.com/users/detly/gists{/gist_id}","starred_url":"https://api.github.com/users/detly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/detly/subscriptions","organizations_url":"https://api.github.com/users/detly/orgs","repos_url":"https://api.github.com/users/detly/repos","events_url":"https://api.github.com/users/detly/events{/privacy}","received_events_url":"https://api.github.com/users/detly/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-15T10:43:19Z","updated_at":"2015-03-17T09:38:11Z","closed_at":null,"body":"Quick example:\r\n\r\n    import pexpect.ANSI\r\n    test_str = b'\\n01234567890123456789\\r\\n01234567890123456789\\r\\n'\r\n    ansi_term = pexpect.ANSI.ANSI(r=24, c=20)\r\n    ansi_term.write(test_str)\r\n    print(ansi_term)\r\n\r\nOutput:\r\n                    \r\n    01234567890123456789\r\n                     \r\n    01234567890123456789\r\n\r\nI would not expect the extra line there, since the characters fit exactly.\r\n\r\nThis is based on trying to print the captured output of `top`, and encountering blank lines when there should be none. `top`'s output fits perfectly in a console of a certain width, but redrawing it with `pexpect.ANSI` adds these blank lines.\r\n\r\nUnder Python 2.7 on Ubuntu 14.04.1 using `pexpect` 3.3 in a virtualenv."},"comment":{"url":"https://api.github.com/repos/pexpect/pexpect/issues/comments/82244820","html_url":"https://github.com/pexpect/pexpect/issues/186#issuecomment-82244820","issue_url":"https://api.github.com/repos/pexpect/pexpect/issues/186","id":82244820,"user":{"login":"detly","id":311239,"avatar_url":"https://avatars.githubusercontent.com/u/311239?v=3","gravatar_id":"","url":"https://api.github.com/users/detly","html_url":"https://github.com/detly","followers_url":"https://api.github.com/users/detly/followers","following_url":"https://api.github.com/users/detly/following{/other_user}","gists_url":"https://api.github.com/users/detly/gists{/gist_id}","starred_url":"https://api.github.com/users/detly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/detly/subscriptions","organizations_url":"https://api.github.com/users/detly/orgs","repos_url":"https://api.github.com/users/detly/repos","events_url":"https://api.github.com/users/detly/events{/privacy}","received_events_url":"https://api.github.com/users/detly/received_events","type":"User","site_admin":false},"created_at":"2015-03-17T09:38:11Z","updated_at":"2015-03-17T09:38:11Z","body":"The problem is that after writing the second `9`, at `ANSI.py:329` there's a call to `self.cursor_forward()` followed by some checks that wrap the cursor if it's been constrained. This then means that by the time `\\r` is received, it's too late; the cursor stays where it is, and the next `\\n` just terminates an empty line.\r\n\r\nIt's not immediately obvious to me how to fix it though, so I'll just leave this observation here for now. (PyTE works fine for me too, and I don't really mind which one I use, but I thought I'd at least write it down in case anyone else can see the solution.)"}}