: cmd: prefix, suffix, prefix-line, suffix-line
(text,chars,cmd)
| 285 | |
| 286 | |
| 287 | def add_prefix_suffix(text,chars,cmd): |
| 288 | ''' |
| 289 | : cmd: prefix, suffix, prefix-line, suffix-line |
| 290 | |
| 291 | ''' |
| 292 | lines, text = text.split('\n'), '' |
| 293 | |
| 294 | def concat(lines,chars,text): |
| 295 | chars = chars.split('\n') |
| 296 | if len(chars) != len(lines): |
| 297 | sublime.message_dialog('[waring] The number of text lines is not same') |
| 298 | return None |
| 299 | |
| 300 | for x,line in enumerate(lines): |
| 301 | line = (chars[x] + line) if cmd == 'prefix-line' else (line+chars[x]) |
| 302 | text = text + line + '\n' |
| 303 | |
| 304 | return text |
| 305 | |
| 306 | if 'line' in cmd: |
| 307 | return concat(lines,chars,text) |
| 308 | |
| 309 | for line in lines: |
| 310 | line = (chars+line) if cmd == 'prefix' else (line+chars) |
| 311 | text = text + line + '\n' |
| 312 | |
| 313 | return text |
| 314 | |
| 315 | |
| 316 | ''' |