Commit a319240b1513cd7a57db29b56bc7fb7c1da85afa
1 parent
6c609219
Exists in
master
and in
5 other branches
Incluindo justificação no script exemplo do clipboard
Showing
1 changed file
with
34 additions
and
3 deletions
Show diff stats
src/plugins/rx3270/sample/clipboard.rex
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | cursor = host~GetCursorAddr() |
| 30 | 30 | next = cursor |
| 31 | 31 | |
| 32 | - while text <> "" | |
| 33 | - do | |
| 32 | + do while text <> "" | |
| 34 | 33 | addr = host~GetFieldStart(next) |
| 35 | 34 | next = host~GetNextUnprotected(addr) |
| 36 | 35 | |
| ... | ... | @@ -51,7 +50,7 @@ |
| 51 | 50 | |
| 52 | 51 | when length(text) < field_len then |
| 53 | 52 | do |
| 54 | - s = strip(text) | |
| 53 | + s = justify(strip(text),field_len) | |
| 55 | 54 | text = "" |
| 56 | 55 | end |
| 57 | 56 | |
| ... | ... | @@ -80,6 +79,38 @@ |
| 80 | 79 | |
| 81 | 80 | return 0 |
| 82 | 81 | |
| 82 | +justify: procedure | |
| 83 | + | |
| 84 | + use arg text, len | |
| 85 | + | |
| 86 | + wlen = words(text) | |
| 87 | + if wlen < 3 | |
| 88 | + then return text | |
| 89 | + | |
| 90 | + ln = .array~new() | |
| 91 | + sz = 0 | |
| 92 | + | |
| 93 | + do f = 1 to wlen | |
| 94 | + ln[f] = word(text,f)||" " | |
| 95 | + sz = sz + length(ln[f]) | |
| 96 | + end | |
| 97 | + | |
| 98 | + do while sz < len | |
| 99 | + do f = wlen-1 to 1 by -1 | |
| 100 | + ln[f] = ln[f]||"." | |
| 101 | + sz = sz+1 | |
| 102 | + if sz >= len | |
| 103 | + then leave | |
| 104 | + end | |
| 105 | + end | |
| 106 | + | |
| 107 | + str = "" | |
| 108 | + do f = 1 to wlen | |
| 109 | + str = str||ln[f] | |
| 110 | + end | |
| 111 | + | |
| 112 | +return strip(str) | |
| 113 | + | |
| 83 | 114 | ::requires "rx3270.cls" |
| 84 | 115 | |
| 85 | 116 | ... | ... |