-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix misligned lines in output of aqFile
- Loading branch information
1 parent
8be96b8
commit e346af5
Showing
2 changed files
with
13 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import strutils, re, aq | ||
from strutils import split | ||
from aq import aq | ||
proc aqFile*(file: string): string = | ||
for line in file.lines: | ||
if line.aq != 0: | ||
result.add line.strip&" = " & $line.aq&"\n" | ||
let words = line.split(re"\s") | ||
let lineaq = line.aq | ||
if lineaq != 0: | ||
let words = line.split | ||
var tline,nline:string | ||
for word in words: | ||
if word != "": | ||
if word.len == 1: tline.add word&" " | ||
else: tline.add word&" " | ||
let sum = word.aq | ||
let slen = ($sum).len | ||
var offset = word.len - slen | ||
if offset < 0: offset = 0 | ||
result.add $sum&" " | ||
for i in 0..<offset: result.add " " | ||
result.add "\n" | ||
nline.add $sum&" " | ||
for i in 0..<offset: nline.add " " | ||
tline.add "= " & $lineaq | ||
result.add tline&"\n"&nline&"\n" | ||
else: result.add "\n" |