{"action":"created","issue":{"url":"https://api.github.com/repos/Zing22/simple_ls/issues/1","labels_url":"https://api.github.com/repos/Zing22/simple_ls/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/Zing22/simple_ls/issues/1/comments","events_url":"https://api.github.com/repos/Zing22/simple_ls/issues/1/events","html_url":"https://github.com/Zing22/simple_ls/issues/1","id":56485409,"number":1,"title":"短输出分栏对齐","user":{"login":"richardtsai","id":1297550,"avatar_url":"https://avatars.githubusercontent.com/u/1297550?v=3","gravatar_id":"","url":"https://api.github.com/users/richardtsai","html_url":"https://github.com/richardtsai","followers_url":"https://api.github.com/users/richardtsai/followers","following_url":"https://api.github.com/users/richardtsai/following{/other_user}","gists_url":"https://api.github.com/users/richardtsai/gists{/gist_id}","starred_url":"https://api.github.com/users/richardtsai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardtsai/subscriptions","organizations_url":"https://api.github.com/users/richardtsai/orgs","repos_url":"https://api.github.com/users/richardtsai/repos","events_url":"https://api.github.com/users/richardtsai/events{/privacy}","received_events_url":"https://api.github.com/users/richardtsai/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-04T06:21:21Z","updated_at":"2015-02-06T02:14:45Z","closed_at":null,"body":"短输出是要分栏的，而且要**对齐**，并按**列优先**输出。如下图：\r\n![2015-02-04 14 12 12](https://cloud.githubusercontent.com/assets/1297550/6035977/585c4366-ac78-11e4-911a-4870f2ef23d0.png)\r\n\r\n而且，应该分多少栏，这个应该根据**终端窗口的宽度**确定。比如上图中的文件夹，如果我加宽了窗口，输出会变成下图：\r\n![2015-02-04 14 12 58](https://cloud.githubusercontent.com/assets/1297550/6036005/d47865a6-ac78-11e4-8f30-c6b9847673aa.png)\r\n\r\n实现对齐的时候，你会遇到一个问题，就是如果某些文件名中如果有非ASCII字符，如中文，对齐会乱掉。这个先忽略，以后再教你处理。"},"comment":{"url":"https://api.github.com/repos/Zing22/simple_ls/issues/comments/73171022","html_url":"https://github.com/Zing22/simple_ls/issues/1#issuecomment-73171022","issue_url":"https://api.github.com/repos/Zing22/simple_ls/issues/1","id":73171022,"user":{"login":"Zing22","id":8966971,"avatar_url":"https://avatars.githubusercontent.com/u/8966971?v=3","gravatar_id":"","url":"https://api.github.com/users/Zing22","html_url":"https://github.com/Zing22","followers_url":"https://api.github.com/users/Zing22/followers","following_url":"https://api.github.com/users/Zing22/following{/other_user}","gists_url":"https://api.github.com/users/Zing22/gists{/gist_id}","starred_url":"https://api.github.com/users/Zing22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zing22/subscriptions","organizations_url":"https://api.github.com/users/Zing22/orgs","repos_url":"https://api.github.com/users/Zing22/repos","events_url":"https://api.github.com/users/Zing22/events{/privacy}","received_events_url":"https://api.github.com/users/Zing22/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T02:14:45Z","updated_at":"2015-02-06T02:14:45Z","body":"假设有`n`个文件，分为`col`栏，那么总共有`row`行，`row = (n+col-1)/col`。\r\n第`r`行第`c`列是第`r+(c-1)*row`个文件。\r\n关于计算`col`的数量，我想到的是=终端宽度/（最长文件名+空格数），但似乎和我系统（Ubuntu）的输出不一样，我系统的ls似乎会根据每一栏的最长文件名来确定该栏的宽度，这样似乎会导致每一栏的宽度不一样，我先试试上面那种算法好了。"}}