(m *TuiModel)
| 142 | } |
| 143 | |
| 144 | func GetFormattedTextBuffer(m *TuiModel) []string { |
| 145 | v := m.Data().EditTextBuffer |
| 146 | |
| 147 | lines := SplitLines(v) |
| 148 | FormatModeOffset = len(strconv.Itoa(len(lines))) + 1 // number of characters in the numeric string |
| 149 | |
| 150 | var ret []string |
| 151 | m.Format.RunningOffsets = []int{} |
| 152 | |
| 153 | total := 0 |
| 154 | strlen := 0 |
| 155 | for i, v := range lines { |
| 156 | xOffset := len(strconv.Itoa(i)) |
| 157 | totalOffset := Max(FormatModeOffset-xOffset, 0) |
| 158 | //wrap := wordwrap.String(v, m.Viewport.Width-totalOffset) |
| 159 | |
| 160 | right := tuiutil.Indent( |
| 161 | v, |
| 162 | fmt.Sprintf("%d%s", i, strings.Repeat(" ", totalOffset)), |
| 163 | false) |
| 164 | ret = append(ret, right) |
| 165 | m.Format.RunningOffsets = append(m.Format.RunningOffsets, total) |
| 166 | |
| 167 | strlen = len(v) |
| 168 | |
| 169 | total += strlen + 1 |
| 170 | } |
| 171 | |
| 172 | lineLength := len(ret) |
| 173 | // need to add this so that the last line can be edited |
| 174 | m.Format.RunningOffsets = append(m.Format.RunningOffsets, |
| 175 | m.Format.RunningOffsets[lineLength-1]+ |
| 176 | len(ret[len(ret)-1][FormatModeOffset:])) |
| 177 | |
| 178 | for i := len(ret); i < m.Viewport.Height; i++ { |
| 179 | ret = append(ret, "") |
| 180 | } |
| 181 | |
| 182 | return ret |
| 183 | } |
| 184 | |
| 185 | func DisplayFormatText(m *TuiModel) string { |
| 186 | cpy := make([]string, len(m.Format.EditSlices)) |
no test coverage detected