Change-Id: I217cb2e11b815d7286c478b1f1a841791c9fec27
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3838
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
Reviewed-by: Vinay Kulkarni <kulkarniv@vmware.com>
... | ... |
@@ -95,29 +95,30 @@ class TextPane(Action): |
95 | 95 |
def read_file(self, text_file_path, line_width): |
96 | 96 |
with open(text_file_path, "r") as f: |
97 | 97 |
for line in f: |
98 |
- # remove the trailing white space. |
|
99 |
- line = line.rstrip() |
|
100 | 98 |
# expand tab to 8 spaces. |
101 | 99 |
line = line.expandtabs() |
100 |
+ indent = len(line) - len(line.lstrip()) |
|
101 |
+ actual_line_width = line_width - indent |
|
102 |
+ line = line.strip() |
|
102 | 103 |
# Adjust the words on the lines |
103 |
- while len(line) > line_width: |
|
104 |
- sep_index = line_width |
|
104 |
+ while len(line) > actual_line_width: |
|
105 |
+ sep_index = actual_line_width |
|
105 | 106 |
|
106 | 107 |
while sep_index > 0 and line[sep_index-1] != ' ' and line[sep_index] != ' ': |
107 | 108 |
sep_index = sep_index - 1 |
108 | 109 |
|
109 | 110 |
current_line_width=sep_index |
110 | 111 |
if sep_index == 0: |
111 |
- current_line_width = line_width |
|
112 |
+ current_line_width = actual_line_width |
|
112 | 113 |
currLine = line[:current_line_width] |
113 | 114 |
line = line[current_line_width:] |
114 | 115 |
line = line.strip() |
115 | 116 |
|
116 | 117 |
# Lengthen the line with spaces |
117 |
- self.lines.append(currLine + ' ' * (line_width - len(currLine))) |
|
118 |
+ self.lines.append(' ' * indent + currLine + ' ' *(actual_line_width - len(currLine))) |
|
118 | 119 |
|
119 | 120 |
# lengthen the line with spaces |
120 |
- self.lines.append(line + ' ' * (line_width - len(line))) |
|
121 |
+ self.lines.append(' ' * indent + line + ' ' *(actual_line_width - len(line))) |
|
121 | 122 |
|
122 | 123 |
def navigate(self, n): |
123 | 124 |
if self.show_scroll: |