Permalink
Browse files

Improved gls column handling

  • Loading branch information...
1 parent f37c8b8 commit 533acd400d3f25dc5a690585dd64f97b6a3feb5c @mitotic committed Sep 21, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 graphterm/bin/gls
View
@@ -152,7 +152,15 @@ elif options.time:
else:
File_list.sort(key=lambda x:x[1])
-ncols = 4
+try:
+ lines = int(os.getenv("LINES"))
+ columns = int(os.getenv("COLUMNS"))
+except Exception:
+ lines = 24
+ columns = 80
+
+max_width = max([len(fileinfo[1]) for fileinfo in File_list])
+ncols = max(1, columns // (max_width+1))
Table_list = ['<table frame=none border=0>',
'<colgroup colspan=%d width=1*>' % (ncols,),

0 comments on commit 533acd4

Please sign in to comment.