fto 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Fri, 04 Dec 2009 01:20:04 -0500
1
+ Mon, 07 Dec 2009 21:52:39 -0500
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Fri Dec 04 01:20:01 -0500 2009</td>
59
+ <td>Mon Dec 07 21:52:36 -0500 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -20,19 +20,20 @@
20
20
  <div id="index">
21
21
  <h1 class="section-bar">Methods</h1>
22
22
  <div id="index-entries">
23
- <a href="classes/FormatText/FTO.html#M000004">destroyEffector (FormatText::FTO)</a><br />
24
- <a href="classes/FormatText/Effector.html#M000010">disable (FormatText::Effector)</a><br />
25
- <a href="classes/FormatText/FTO.html#M000005">disableEffector (FormatText::FTO)</a><br />
26
- <a href="classes/FormatText/Effector.html#M000011">disabled? (FormatText::Effector)</a><br />
27
- <a href="classes/FormatText/Effector.html#M000012">enable (FormatText::Effector)</a><br />
28
- <a href="classes/FormatText/FTO.html#M000003">enableEffector (FormatText::FTO)</a><br />
29
- <a href="classes/FormatText/Effector.html#M000013">enabled? (FormatText::Effector)</a><br />
30
- <a href="classes/FormatText/FTO.html#M000006">findEffectors (FormatText::FTO)</a><br />
31
- <a href="classes/FormatText/FTO.html#M000007">format (FormatText::FTO)</a><br />
32
- <a href="classes/FormatText/Effector.html#M000009">new (FormatText::Effector)</a><br />
33
- <a href="classes/FormatText/Context.html#M000008">new (FormatText::Context)</a><br />
23
+ <a href="classes/FormatText/FTO.html#M000002">clearEffectorList (FormatText::FTO)</a><br />
24
+ <a href="classes/FormatText/FTO.html#M000005">destroyEffector (FormatText::FTO)</a><br />
25
+ <a href="classes/FormatText/Effector.html#M000011">disable (FormatText::Effector)</a><br />
26
+ <a href="classes/FormatText/FTO.html#M000006">disableEffector (FormatText::FTO)</a><br />
27
+ <a href="classes/FormatText/Effector.html#M000012">disabled? (FormatText::Effector)</a><br />
28
+ <a href="classes/FormatText/Effector.html#M000013">enable (FormatText::Effector)</a><br />
29
+ <a href="classes/FormatText/FTO.html#M000004">enableEffector (FormatText::FTO)</a><br />
30
+ <a href="classes/FormatText/Effector.html#M000014">enabled? (FormatText::Effector)</a><br />
31
+ <a href="classes/FormatText/FTO.html#M000007">findEffectors (FormatText::FTO)</a><br />
32
+ <a href="classes/FormatText/FTO.html#M000008">format (FormatText::FTO)</a><br />
33
+ <a href="classes/FormatText/Effector.html#M000010">new (FormatText::Effector)</a><br />
34
+ <a href="classes/FormatText/Context.html#M000009">new (FormatText::Context)</a><br />
34
35
  <a href="classes/FormatText/FTO.html#M000001">new (FormatText::FTO)</a><br />
35
- <a href="classes/FormatText/FTO.html#M000002">registerEffector (FormatText::FTO)</a><br />
36
+ <a href="classes/FormatText/FTO.html#M000003">registerEffector (FormatText::FTO)</a><br />
36
37
  </div>
37
38
  </div>
38
39
  </body>
data/lib/fto.rb CHANGED
@@ -84,14 +84,6 @@
84
84
  # Stuff from SYS$FAO that isn't yet implemented (and may not be
85
85
  # reasonable outside of OpenVMS).
86
86
  #
87
- # @TODO: !%T Inserts the system time. It takes one parameter: the
88
- # address of a quadword time value to be converted to
89
- # ASCII. If you specify 0, the current system time is
90
- # inserted.
91
- # @TODO: !%D Inserts the system date and time. It takes one
92
- # parameter: the address of a quadword time value to be
93
- # converted to ASCII. If you specify 0, the current system
94
- # date and time is inserted.
95
87
  # @TODO: !n%C Inserts a character string when the most recently
96
88
  # evaluated argument has the value n. (Recommended for use
97
89
  # with multilingual products.)
@@ -158,12 +150,18 @@ module FormatText
158
150
  # to build the final string. The _argList_ attribute should be
159
151
  # modified in conjunction with _usedArgs_ to maintain continuity.
160
152
  # By default, after the effector function returns, the caller (the
161
- # <i>FTO#format</i> method) will take the element from the front
153
+ # <i>FTO#format()</i> method) will take the element from the front
162
154
  # of the _argList_ array and push it onto the end of the
163
155
  # _usedArgs_ array.
164
156
  #
165
157
  attr_accessor :argList
166
158
 
159
+ #
160
+ # _Any_. The <i>FTO#format()</i> sets this to the last argument
161
+ # that was actually used.
162
+ #
163
+ attr_accessor :lastArgUsed
164
+
167
165
  #
168
166
  # _Boolean_. The effector function sets this to +true+ to inhibit
169
167
  # the <i>FTO#format()</i> method from modifying the argument list
@@ -243,6 +241,14 @@ module FormatText
243
241
  #
244
242
  @@EffectorKeys = [] unless (defined?(@@EffectorKeys))
245
243
 
244
+ #
245
+ # Not yet implemented
246
+ # Controls whether the final string is built safely and
247
+ # conservatively, or if the output of each effector can alter the
248
+ # input to subsequent ones.
249
+ #
250
+ attr_accessor :safe
251
+
246
252
  # :stopdoc:
247
253
  #
248
254
  # We do this in order to call super on String, but since our
@@ -286,9 +292,23 @@ module FormatText
286
292
  #
287
293
  def initialize(text=nil, *args)
288
294
  String_initialize(text)
295
+ @safe = true
289
296
  @args = args
290
297
  end # def initialize
291
298
 
299
+ #
300
+ # Clear all effectors from the list (as a prelude to using a different
301
+ # syntax, for instance).
302
+ #
303
+ # :call-seq:
304
+ # FTO.clearEffectorList<i>()</i> => <i>nil</i>
305
+ #
306
+ def self.clearEffectorList()
307
+ @@RegisteredEffectors.delete_if { |id,e| true }
308
+ self.rebuildEffectorList()
309
+ nil
310
+ end # def self.clearEffectorList()
311
+
292
312
  #
293
313
  # Add an effector description to the list of those which will be
294
314
  # processed by the <i>FTO#format()</i> method.
@@ -298,7 +318,7 @@ module FormatText
298
318
  # FTO.registerEffector<i>({ :symattr => value [, ...] })</i> => <i>nil</i>
299
319
  #
300
320
  def self.registerEffector(*args)
301
- if ((args.length == 1) && (args[0].class.name.match(/Effector$/))
321
+ if ((args.length == 1) && (args[0].class.name.match(/Effector$/)))
302
322
  newE = args[0]
303
323
  else
304
324
  newE = Effector.new('placeholder')
@@ -310,9 +330,9 @@ module FormatText
310
330
  newE = Effector.new(args)
311
331
  end
312
332
  end
313
- @@RegisteredEffectors[newE.id] = newE
314
333
  key = sprintf('%06d-%s', newE.priority, newE.name)
315
334
  newE.sortKey = key
335
+ @@RegisteredEffectors[newE.id] = newE
316
336
  self.rebuildEffectorList()
317
337
  nil
318
338
  end # def self.registerEffector()
@@ -326,10 +346,14 @@ module FormatText
326
346
  #
327
347
  def self.rebuildEffectorList()
328
348
  enabled = @@RegisteredEffectors.select { |id,e| e.enabled? }
349
+ @@EffectorKeys = []
329
350
  @@EffectorKeys = enabled.collect { |k,e| e.sortKey }.sort
351
+ @@EffectorKeys.freeze
330
352
  @@EnabledEffectors = {}
331
353
  enabled.each { |k,e| @@EnabledEffectors[e.sortKey] = e }
354
+ @@EnabledEffectors.freeze
332
355
  @@regex = Regexp.new("(#{@@EffectorKeys.collect {|k| @@EnabledEffectors[k].reMatch}.join(')|(')})")
356
+ @@regex.freeze
333
357
  nil
334
358
  end # def self.rebuildEffectorList()
335
359
  # :startdoc:
@@ -352,7 +376,7 @@ module FormatText
352
376
 
353
377
  #
354
378
  # Completely removes the effector with the specified ID from the
355
- # FTO system. <strong>THIS IS NOT REVERSIBLE!</strong>
379
+ # FTO system. <b>THIS IS NOT REVERSIBLE!</b>
356
380
  #
357
381
  # :call-seq:
358
382
  # FTO.destroyEffector<i>(Fixnum)</i> => <i>nil</i>
@@ -395,7 +419,7 @@ module FormatText
395
419
  #
396
420
  # Process the formatting string, optionally with a runtime
397
421
  # argument list. The argument list can either be a list of
398
- # values, an array of values, or an <i>FormatText::Context</i>
422
+ # values, an array of values, or a <i>FormatText::Context</i>
399
423
  # object. (The latter is intended only for internal use with
400
424
  # recursion.)
401
425
  #
@@ -426,9 +450,10 @@ module FormatText
426
450
  :argList => argList
427
451
  })
428
452
  end
429
- result = self.to_s
453
+ input = self.to_s
454
+ output = input.clone
430
455
  effector = sMatched = nil
431
- while (m = result.match(@@regex))
456
+ while (m = input.match(@@regex))
432
457
  #
433
458
  # Find out which effector was matched. The index in .captures
434
459
  # will be the same as the index in @effectors.
@@ -444,14 +469,21 @@ module FormatText
444
469
  # Call the workhorse for this descriptor
445
470
  #
446
471
  replacement = effector.code.call(eContext)
447
- result.sub!(sMatched, replacement)
472
+ output.sub!(sMatched, replacement)
473
+ input.sub!(sMatched, '')
448
474
  #
449
475
  # Mark the item at the front of the argument list as having
450
- # been used, if the effector agrees.
476
+ # been used, if the effector agrees. Assume that an argument
477
+ # was actually used if we're moving it, and that the 'last
478
+ # argument used' hasn't changed if the effector has set
479
+ # _reuseArg_.
451
480
  #
452
- usedArgs.push(argList.shift) unless (eContext.reuseArg)
481
+ unless (eContext.reuseArg)
482
+ usedArgs.push(argList.shift)
483
+ eContext.lastArgUsed = usedArgs.last
484
+ end
453
485
  end
454
- result
486
+ output
455
487
  end # def format()
456
488
 
457
489
  end # class FTO
@@ -488,6 +520,17 @@ module FormatText
488
520
  #
489
521
  attr_accessor :name
490
522
 
523
+ #
524
+ # _String_. Phrase for grouping with related effectors in
525
+ # documentation (like 'String Insertion' or 'Numeric Conversion').
526
+ #
527
+ attr_accessor :category
528
+
529
+ #
530
+ # _String_. Human-readable syntax (HTML okey).
531
+ #
532
+ attr_accessor :syntax
533
+
491
534
  #
492
535
  # _String_. Human-readable brief description.
493
536
  #
@@ -533,8 +576,18 @@ module FormatText
533
576
  attr_accessor :signbit
534
577
 
535
578
  #
536
- # _Fixnum_. Default width for the effector result (used when
537
- # filling).
579
+ # _Various_. Default width for the effector result (used for
580
+ # documentation and when filling). Possible values:
581
+ #
582
+ # [_Integer_] Specified number of columns.
583
+ # [_String_] The string is used in the documentation <i>verbatim</i>.
584
+ # [<tt>:NA</tt>] Default width not applicable to this effector.
585
+ # [<tt>:asNeeded</tt>] As many columns as are needed to represent the value.
586
+ # [<tt>:asSpecified</tt>] As specified in the effector.
587
+ #
588
+ # This should be set to an integer value if needed by the effector
589
+ # function. All of the other possible values shown above are used
590
+ # in generating documentation.
538
591
  #
539
592
  attr_accessor :dWidth
540
593
 
@@ -813,8 +866,11 @@ module FormatText
813
866
  end
814
867
  replacement.gsub!(/[^[:print:]]/, '.') if (eObj.data.include?(:printable))
815
868
  eObj = eContext.effectorObj
816
- width = eContext.sMatched.match(Regexp.new(eObj.reExtra)).captures[0]
817
- FillAndJustify.call(eObj, replacement, width, '*')
869
+ c = eContext.sMatched.match(Regexp.new(eObj.reExtra)).captures
870
+ if (c.empty? || c[0].empty?)
871
+ return replacement
872
+ end
873
+ FillAndJustify.call(eObj, replacement, c[0].to_i, '*')
818
874
  }
819
875
 
820
876
  #
@@ -868,8 +924,12 @@ module FormatText
868
924
  #
869
925
  FTO.registerEffector({
870
926
  :name => 'TAB',
871
- :description => _('Insert a TAB character'),
927
+ :category => _('Special-character insertion'),
928
+ :syntax => '!_',
929
+ :priority => 1010,
930
+ :description => _('Insert a TAB character.'),
872
931
  :reMatch => '!_',
932
+ :dWidth => :NA,
873
933
  :code => lambda {
874
934
  | eContext |
875
935
  eContext.reuseArg = true
@@ -878,9 +938,13 @@ module FormatText
878
938
  })
879
939
  FTO.registerEffector({
880
940
  :name => 'Bang',
941
+ :category => _('Special-character insertion'),
942
+ :syntax => '!!',
943
+ :priority => 1030,
881
944
  :description => _('Insert an exclamation mark ' +
882
- '(!) character'),
945
+ '(!) character.'),
883
946
  :reMatch => '!!',
947
+ :dWidth => :NA,
884
948
  :code => lambda {
885
949
  | eContext |
886
950
  eContext.reuseArg = true
@@ -889,9 +953,13 @@ module FormatText
889
953
  })
890
954
  FTO.registerEffector({
891
955
  :name => 'Formfeed',
956
+ :category => _('Special-character insertion'),
957
+ :syntax => '!^',
958
+ :priority => 1020,
892
959
  :description => _('Insert a form-feed control ' +
893
- 'character'),
960
+ 'character.'),
894
961
  :reMatch => '!\^',
962
+ :dWidth => :NA,
895
963
  :code => lambda {
896
964
  | eContext |
897
965
  eContext.reuseArg = true
@@ -900,9 +968,13 @@ module FormatText
900
968
  })
901
969
  FTO.registerEffector({
902
970
  :name => 'CR',
971
+ :category => _('Special-character insertion'),
972
+ :syntax => '!=',
973
+ :priority => 1040,
903
974
  :description => _('Insert a carriage-return ' +
904
- 'character'),
975
+ 'character.'),
905
976
  :reMatch => '!=',
977
+ :dWidth => :NA,
906
978
  :code => lambda {
907
979
  | eContext |
908
980
  eContext.reuseArg = true
@@ -911,9 +983,13 @@ module FormatText
911
983
  })
912
984
  FTO.registerEffector({
913
985
  :name => 'LF',
986
+ :category => _('Special-character insertion'),
987
+ :syntax => '!,',
988
+ :priority => 1050,
914
989
  :description => _('Insert a line-feed control ' +
915
- 'character'),
990
+ 'character.'),
916
991
  :reMatch => '!,',
992
+ :dWidth => :NA,
917
993
  :code => lambda {
918
994
  | eContext |
919
995
  eContext.reuseArg = true
@@ -922,9 +998,13 @@ module FormatText
922
998
  })
923
999
  FTO.registerEffector({
924
1000
  :name => 'CRLF',
1001
+ :category => _('Special-character insertion'),
1002
+ :syntax => '!/',
1003
+ :priority => 1060,
925
1004
  :description => _('Insert a carriage-return and ' +
926
- 'a line-feed'),
1005
+ 'a line-feed.'),
927
1006
  :reMatch => '!/',
1007
+ :dWidth => :NA,
928
1008
  :code => lambda {
929
1009
  | eContext |
930
1010
  eContext.reuseArg = true
@@ -937,9 +1017,14 @@ module FormatText
937
1017
  #
938
1018
  FTO.registerEffector({
939
1019
  :name => 'Reuse',
1020
+ :category => _('Argument list modification'),
1021
+ :syntax => '!-',
1022
+ :priority => 2010,
940
1023
  :description => _('Back the argument list up ' +
941
- 'so the last argument gets re-used'),
1024
+ 'so the most recently used ' +
1025
+ ' argument gets re-used.'),
942
1026
  :reMatch => '!-',
1027
+ :dWidth => :NA,
943
1028
  :code => lambda {
944
1029
  | eContext |
945
1030
  eContext.reuseArg = true
@@ -949,165 +1034,270 @@ module FormatText
949
1034
  })
950
1035
  FTO.registerEffector({
951
1036
  :name => 'Skip',
1037
+ :category => _('Argument list modification'),
1038
+ :syntax => '!+',
1039
+ :priority => 2020,
952
1040
  :description => _('Skip over the next item in ' +
953
- 'the argument list'),
1041
+ 'the argument list.'),
954
1042
  :reMatch => '!\+',
1043
+ :dWidth => :NA,
955
1044
  :code => lambda {
956
1045
  | eContext |
957
1046
  eContext.usedArgs.push(eContext.argList.unshift) unless (eContext.argList.empty?)
958
1047
  return ''
959
1048
  }
960
1049
  })
961
- FTO.registerEffector({
962
- :name => 'ArgWidth',
963
- :description => _('Specify a field width using ' +
964
- 'an argument rather than a ' +
965
- 'hard-coded value'),
966
- :reMatch => '!#',
967
- :code => lambda {
968
- | eContext |
969
- n = GetArgument.call(eContext)
970
- return "!#{n.to_i.to_s}"
971
- }
972
- })
973
- FTO.registerEffector({
974
- :name => 'RepeatingChar',
975
- :description => _('Insert n occurrences of ' +
976
- 'a character'),
977
- :reMatch => '!\d+\*.',
978
- :reExtra => '!(\d+)\*(.)',
979
- :code => ConvertRepeatChar,
980
- })
1050
+
1051
+ #
1052
+ # Pluralisation
1053
+ #
981
1054
  FTO.registerEffector({
982
1055
  :name => 'Pluralise-English',
1056
+ :category => _('Pluralisation'),
1057
+ :syntax => '!%S',
1058
+ :priority => 3010,
983
1059
  :description => _('Add an "s" or "es" suffix if ' +
984
- 'the last argument used was not 1'),
1060
+ 'the last argument used was not 1.'),
985
1061
  :reMatch => '.?!%S',
986
1062
  :reExtra => '(.)?!%S',
1063
+ :dWidth => _('1 or 2 columns'),
987
1064
  :code => ConvertPlural,
988
1065
  })
989
1066
  FTO.registerEffector({
990
1067
  :name => 'is/are-English',
1068
+ :category => _('Pluralisation'),
1069
+ :syntax => '!%is',
1070
+ :priority => 3020,
991
1071
  :description => _('Insert "is" or "are" depending ' +
992
1072
  'on whether the last argument ' +
993
- 'used was 1'),
1073
+ 'used was 1.'),
994
1074
  :reMatch => '!%is',
1075
+ :dWidth => _('2 or 3 columns'),
995
1076
  :code => ConvertIsAre,
996
1077
  })
997
1078
  FTO.registerEffector({
998
1079
  :name => 'IS/ARE-English',
999
- :description => _('Insert n occurrences of a ' +
1000
- 'character'),
1080
+ :category => _('Pluralisation'),
1081
+ :syntax => '!%IS',
1082
+ :priority => 3030,
1083
+ :description => _('Insert "IS" or "ARE" depending ' +
1084
+ 'on whether the last argument ' +
1085
+ 'used was 1.'),
1001
1086
  :reMatch => '!%IS',
1087
+ :dWidth => _('2 or 3 columns'),
1002
1088
  :code => ConvertIsAre,
1003
1089
  })
1004
1090
 
1091
+ #
1092
+ # Special effects :-)
1093
+ #
1094
+ FTO.registerEffector({
1095
+ :name => 'ArgWidth',
1096
+ :category => _('Field-width control'),
1097
+ :syntax => '!#<i>effector</i>',
1098
+ :priority => 4010,
1099
+ :description => _('Specify a field width using ' +
1100
+ 'an argument rather than a ' +
1101
+ 'hard-coded value.'),
1102
+ :reMatch => '!#',
1103
+ :dWidth => :NA,
1104
+ :code => lambda {
1105
+ | eContext |
1106
+ n = GetArgument.call(eContext)
1107
+ return "!#{n.to_i.to_s}"
1108
+ }
1109
+ })
1005
1110
  FTO.registerEffector({
1006
1111
  :name => 'Fixed Window',
1112
+ :category => _('Field-width control'),
1113
+ :syntax => '!<i>w</i>&lt; ... !&gt;',
1114
+ :priority => 4020,
1007
1115
  :description => _('Force a right-justified field ' +
1008
1116
  'width on the contents between ' +
1009
- 'the effector delimiters'),
1010
- :priority => 10,
1117
+ 'the effector delimiters.'),
1011
1118
  :reMatch => '!\d+<.*!>',
1012
1119
  :reExtra => '!(\d+<)(.*)(!>)',
1013
1120
  :fill => ' ',
1014
1121
  :truncate => :right,
1015
1122
  :justify => :right,
1123
+ :dWidth => :NA,
1016
1124
  :code => ConvertFixedWindow,
1017
1125
  })
1126
+ FTO.registerEffector({
1127
+ :name => 'RepeatingChar',
1128
+ :category => _('Miscellaneous'),
1129
+ :syntax => '!<i>n</i>*<i>c</i>',
1130
+ :priority => 4030,
1131
+ :description => _('Insert <i>n</i> occurrences of ' +
1132
+ 'a character.'),
1133
+ :reMatch => '!\d+\*.',
1134
+ :reExtra => '!(\d+)\*(.)',
1135
+ :dWidth => :NA,
1136
+ :code => ConvertRepeatChar,
1137
+ })
1138
+ FTO.registerEffector({
1139
+ :name => 'Date/Time',
1140
+ :category => _('Date/time insertions'),
1141
+ :syntax => '![<i>w</i>]%T( ... !)',
1142
+ :priority => 4040,
1143
+ :description => _('Format a date/time value ' +
1144
+ 'using strftime(3) rules and ' +
1145
+ 'insert the result.'),
1146
+ :reMatch => '!\d*%T\([^)]*!\)',
1147
+ :reExtra => '!(\d*)%T\(([^)]*)!\)',
1148
+ :fill => ' ',
1149
+ :dWidth => _('Depends on the time formatting ' +
1150
+ 'string'),
1151
+ :code => lambda {
1152
+ | eContext |
1153
+ t = GetArgument.call(eContext)
1154
+ t = Time.now if (t.eql?(0))
1155
+ eObj = eContext.effectorObj
1156
+ sMatched = eContext.sMatched
1157
+ parcels = sMatched.match(Regexp.new(eObj.reExtra))
1158
+ result = t.strftime(parcels.captures[1])
1159
+ unless (parcels.captures[0].eql?(''))
1160
+ rWidth = parcels.captures[0].to_i
1161
+ if ((diff = rWidth - result.length) < 0)
1162
+ result = result[0,rWidth]
1163
+ else
1164
+ result += eObj.fill * diff
1165
+ end
1166
+ end
1167
+ return result
1168
+ }
1169
+ })
1170
+
1018
1171
  #
1019
1172
  # Strings
1020
1173
  #
1021
1174
  FTO.registerEffector({
1022
1175
  :name => 'String AS',
1023
- :description => _('Insert a simple string'),
1176
+ :category => _('String insertion'),
1177
+ :syntax => '![<i>w</i>]AS',
1178
+ :priority => 5010,
1179
+ :description => _('Insert a simple string.'),
1024
1180
  :reMatch => '!\d*AS',
1025
1181
  :reExtra => '!(\d*)AS',
1026
1182
  :fill => ' ',
1027
1183
  :truncate => :right,
1028
1184
  :data => [:AS],
1185
+ :dWidth => :asNeeded,
1029
1186
  :code => ConvertString,
1030
1187
  })
1031
1188
  FTO.registerEffector({
1032
1189
  :name => 'String AN',
1190
+ :category => _('String insertion'),
1191
+ :syntax => '![<i>w</i>]AN',
1192
+ :priority => 5020,
1033
1193
  :description => _('Insert a simple string, ' +
1034
1194
  'replacing non-printing ' +
1035
- 'characters with "."'),
1195
+ 'characters with ".".'),
1036
1196
  :reMatch => '!\d*AN',
1037
1197
  :reExtra => '!(\d*)AN',
1038
1198
  :fill => ' ',
1039
1199
  :truncate => :right,
1040
1200
  :data => [:AS, :printable],
1201
+ :dWidth => :asSpecified,
1041
1202
  :code => ConvertString,
1042
1203
  })
1043
1204
  FTO.registerEffector({
1044
1205
  :name => 'String AD',
1045
- :description => _('Insert the first n characters ' +
1046
- 'of a string, drawing n from the ' +
1047
- 'argument list'),
1206
+ :category => _('String insertion'),
1207
+ :syntax => '![<i>w</i>]AD',
1208
+ :priority => 5030,
1209
+ :description => _('Insert the first <i>n</i> ' +
1210
+ 'characters of a string, ' +
1211
+ 'drawing <i>n</i> from the ' +
1212
+ 'argument list.'),
1048
1213
  :reMatch => '!\d*AD',
1049
1214
  :reExtra => '!(\d*)AD',
1050
1215
  :fill => ' ',
1051
1216
  :truncate => :right,
1052
1217
  :data => [:lengthAsArg],
1218
+ :dWidth => :asSpecified,
1053
1219
  :code => ConvertString,
1054
1220
  })
1055
1221
  FTO.registerEffector({
1056
1222
  :name => 'String AF',
1057
- :description => _('Insert the first n characters ' +
1058
- 'of a string, drawing n from the ' +
1223
+ :category => _('String insertion'),
1224
+ :syntax => '![<i>w</i>]AF',
1225
+ :priority => 5040,
1226
+ :description => _('Insert the first <i>n</i> ' +
1227
+ 'characters of a string, ' +
1228
+ 'drawing <i>n</i> from the ' +
1059
1229
  'argument list and replacing ' +
1060
- 'non-printing characters with "."'),
1230
+ 'non-printing characters with ".".'),
1061
1231
  :reMatch => '!\d*AF',
1062
1232
  :reExtra => '!(\d*)AF',
1063
1233
  :fill => ' ',
1064
1234
  :truncate => :right,
1065
1235
  :data => [:lengthAsArg, :printable],
1236
+ :dWidth => :asSpecified,
1066
1237
  :code => ConvertString,
1067
1238
  })
1239
+
1240
+ #
1241
+ # Numeric conversions
1242
+ #
1068
1243
  FTO.registerEffector({
1069
1244
  :name => 'Byte: unsigned',
1245
+ :category => _('Numeric insertion'),
1246
+ :syntax => '![<i>w</i>]UB',
1247
+ :priority => 6010,
1070
1248
  :description => _('Insert the decimal ' +
1071
1249
  'representation of an unsigned ' +
1072
1250
  '8-bit value, left space-filled ' +
1073
- 'to the field width'),
1251
+ 'to the field width.'),
1074
1252
  :reMatch => '!\d*UB',
1075
1253
  :reExtra => '!(\d*)UB',
1076
1254
  :mask => 0xFF,
1255
+ :dWidth => :asNeeded,
1256
+ :code => ConvertNumeric,
1257
+ })
1258
+ FTO.registerEffector({
1259
+ :name => 'Byte: signed',
1260
+ :category => _('Numeric insertion'),
1261
+ :syntax => '![<i>w</i>]SB',
1262
+ :priority => 6020,
1263
+ :description => _('Insert the decimal ' +
1264
+ 'representation of a signed ' +
1265
+ '8-bit value, left space-filled ' +
1266
+ 'to the field width.'),
1267
+ :reMatch => '!\d*SB',
1268
+ :reExtra => '!(\d*)SB',
1269
+ :mask => 0xFF,
1270
+ :signbit => 0x80,
1271
+ :dWidth => :asNeeded,
1077
1272
  :code => ConvertNumeric,
1078
1273
  })
1079
1274
  FTO.registerEffector({
1080
1275
  :name => 'Byte: unsigned, zero-filled',
1276
+ :category => _('Numeric insertion'),
1277
+ :syntax => '![<i>w</i>]ZB',
1278
+ :priority => 6030,
1081
1279
  :description => _('Insert the decimal ' +
1082
1280
  'representation of an unsigned ' +
1083
1281
  '8-bit value, left zero-filled ' +
1084
- 'to the field width'),
1282
+ 'to the field width.'),
1085
1283
  :reMatch => '!\d*ZB',
1086
1284
  :reExtra => '!(\d*)ZB',
1087
1285
  :mask => 0xFF,
1088
1286
  :fill => '0',
1089
1287
  :justify => :right,
1090
- :code => ConvertNumeric,
1091
- })
1092
- FTO.registerEffector({
1093
- :name => 'Byte: signed',
1094
- :description => _('Insert the decimal ' +
1095
- 'representation of a signed ' +
1096
- '8-bit value, left space-filled ' +
1097
- 'to the field width'),
1098
- :reMatch => '!\d*SB',
1099
- :reExtra => '!(\d*)SB',
1100
- :mask => 0xFF,
1101
- :signbit => 0x80,
1288
+ :dWidth => :asNeeded,
1102
1289
  :code => ConvertNumeric,
1103
1290
  })
1104
1291
  FTO.registerEffector({
1105
1292
  :name => 'Byte: octal',
1293
+ :category => _('Numeric insertion'),
1294
+ :syntax => '![<i>w</i>]OB',
1295
+ :priority => 6040,
1106
1296
  :description => _('Insert the octal ' +
1107
1297
  'representation of an unsigned ' +
1108
1298
  '8-bit value, left zero-filled ' +
1109
1299
  'to the field width (default ' +
1110
- '3)'),
1300
+ '3).'),
1111
1301
  :reMatch => '!\d*OB',
1112
1302
  :reExtra => '!(\d*)OB',
1113
1303
  :mask => 0xFF,
@@ -1120,11 +1310,14 @@ module FormatText
1120
1310
  })
1121
1311
  FTO.registerEffector({
1122
1312
  :name => 'Byte: hex',
1313
+ :category => _('Numeric insertion'),
1314
+ :syntax => '![<i>w</i>]XB',
1315
+ :priority => 6050,
1123
1316
  :description => _('Insert the hexadecimal ' +
1124
1317
  'representation of an unsigned ' +
1125
1318
  '8-bit value, left zero-filled ' +
1126
1319
  'to the field width (default ' +
1127
- '2)'),
1320
+ '2).'),
1128
1321
  :reMatch => '!\d*XB',
1129
1322
  :reExtra => '!(\d*)XB',
1130
1323
  :mask => 0xFF,
@@ -1135,49 +1328,65 @@ module FormatText
1135
1328
  :data => [:hex],
1136
1329
  :code => ConvertNumeric,
1137
1330
  })
1331
+
1138
1332
  FTO.registerEffector({
1139
1333
  :name => 'Word: unsigned',
1334
+ :category => _('Numeric insertion'),
1335
+ :syntax => '![<i>w</i>]UW',
1336
+ :priority => 6110,
1140
1337
  :description => _('Insert the decimal ' +
1141
1338
  'representation of an unsigned ' +
1142
- '8-bit value, left space-filled ' +
1143
- 'to the field width'),
1339
+ '16-bit value, left space-filled ' +
1340
+ 'to the field width.'),
1144
1341
  :reMatch => '!\d*UW',
1145
1342
  :reExtra => '!(\d*)UW',
1146
1343
  :mask => 0xFFFF,
1147
- :code => ConvertNumeric,
1148
- })
1149
- FTO.registerEffector({
1150
- :name => 'Word: unsigned, zero-filled',
1151
- :description => _('Insert the decimal ' +
1152
- 'representation of an unsigned ' +
1153
- '8-bit value, left zero-filled ' +
1154
- 'to the field width'),
1155
- :reMatch => '!\d*ZW',
1156
- :reExtra => '!(\d*)ZW',
1157
- :mask => 0xFFFF,
1158
- :fill => '0',
1159
- :justify => :right,
1344
+ :dWidth => :asNeeded,
1160
1345
  :code => ConvertNumeric,
1161
1346
  })
1162
1347
  FTO.registerEffector({
1163
1348
  :name => 'Word: signed',
1349
+ :category => _('Numeric insertion'),
1350
+ :syntax => '![<i>w</i>]SW',
1351
+ :priority => 6120,
1164
1352
  :description => _('Insert the decimal ' +
1165
1353
  'representation of a signed ' +
1166
1354
  '16-bit value, left space-filled ' +
1167
- 'to the field width'),
1355
+ 'to the field width.'),
1168
1356
  :reMatch => '!\d*SW',
1169
1357
  :reExtra => '!(\d*)SW',
1170
1358
  :mask => 0xFFFF,
1171
1359
  :signbit => 0x8000,
1360
+ :dWidth => :asNeeded,
1361
+ :code => ConvertNumeric,
1362
+ })
1363
+ FTO.registerEffector({
1364
+ :name => 'Word: unsigned, zero-filled',
1365
+ :category => _('Numeric insertion'),
1366
+ :syntax => '![<i>w</i>]ZW',
1367
+ :priority => 6130,
1368
+ :description => _('Insert the decimal ' +
1369
+ 'representation of an unsigned ' +
1370
+ '16-bit value, left zero-filled ' +
1371
+ 'to the field width.'),
1372
+ :reMatch => '!\d*ZW',
1373
+ :reExtra => '!(\d*)ZW',
1374
+ :mask => 0xFFFF,
1375
+ :fill => '0',
1376
+ :justify => :right,
1377
+ :dWidth => :asNeeded,
1172
1378
  :code => ConvertNumeric,
1173
1379
  })
1174
1380
  FTO.registerEffector({
1175
1381
  :name => 'Word: octal',
1382
+ :category => _('Numeric insertion'),
1383
+ :syntax => '![<i>w</i>]OW',
1384
+ :priority => 6140,
1176
1385
  :description => _('Insert the octal ' +
1177
1386
  'representation of an unsigned ' +
1178
1387
  '16-bit value, left zero-filled ' +
1179
1388
  'to the field width (default ' +
1180
- '6)'),
1389
+ '6).'),
1181
1390
  :reMatch => '!\d*OW',
1182
1391
  :reExtra => '!(\d*)OW',
1183
1392
  :mask => 0xFFFF,
@@ -1190,11 +1399,14 @@ module FormatText
1190
1399
  })
1191
1400
  FTO.registerEffector({
1192
1401
  :name => 'Word: hex',
1402
+ :category => _('Numeric insertion'),
1403
+ :syntax => '![<i>w</i>]XW',
1404
+ :priority => 6150,
1193
1405
  :description => _('Insert the hexadecimal ' +
1194
1406
  'representation of an unsigned ' +
1195
1407
  '16-bit value, left zero-filled ' +
1196
1408
  'to the field width (default ' +
1197
- '4)'),
1409
+ '4).'),
1198
1410
  :reMatch => '!\d*XW',
1199
1411
  :reExtra => '!(\d*)XW',
1200
1412
  :mask => 0xFFFF,
@@ -1205,49 +1417,65 @@ module FormatText
1205
1417
  :data => [:hex],
1206
1418
  :code => ConvertNumeric,
1207
1419
  })
1420
+
1208
1421
  FTO.registerEffector({
1209
1422
  :name => 'Long: unsigned',
1423
+ :category => _('Numeric insertion'),
1424
+ :syntax => '![<i>w</i>]UL',
1425
+ :priority => 6210,
1210
1426
  :description => _('Insert the decimal ' +
1211
1427
  'representation of an unsigned ' +
1212
- '8-bit value, left space-filled ' +
1213
- 'to the field width'),
1428
+ '32-bit value, left space-filled ' +
1429
+ 'to the field width.'),
1214
1430
  :reMatch => '!\d*UL',
1215
1431
  :reExtra => '!(\d*)UL',
1216
1432
  :mask => 0xFFFFFFFF,
1217
- :code => ConvertNumeric,
1218
- })
1219
- FTO.registerEffector({
1220
- :name => 'Long: unsigned, zero-filled',
1221
- :description => _('Insert the decimal ' +
1222
- 'representation of an unsigned ' +
1223
- '8-bit value, left zero-filled ' +
1224
- 'to the field width'),
1225
- :reMatch => '!\d*ZL',
1226
- :reExtra => '!(\d*)ZL',
1227
- :mask => 0xFFFFFFFF,
1228
- :fill => '0',
1229
- :justify => :right,
1433
+ :dWidth => :asNeeded,
1230
1434
  :code => ConvertNumeric,
1231
1435
  })
1232
1436
  FTO.registerEffector({
1233
1437
  :name => 'Long: signed',
1438
+ :category => _('Numeric insertion'),
1439
+ :syntax => '![<i>w</i>]SL',
1440
+ :priority => 6220,
1234
1441
  :description => _('Insert the decimal ' +
1235
1442
  'representation of a signed ' +
1236
1443
  '32-bit value, left space-filled ' +
1237
- 'to the field width'),
1444
+ 'to the field width.'),
1238
1445
  :reMatch => '!\d*SL',
1239
1446
  :reExtra => '!(\d*)SL',
1240
1447
  :mask => 0xFFFFFFFF,
1241
1448
  :signbit => 0x80000000,
1449
+ :dWidth => :asNeeded,
1450
+ :code => ConvertNumeric,
1451
+ })
1452
+ FTO.registerEffector({
1453
+ :name => 'Long: unsigned, zero-filled',
1454
+ :category => _('Numeric insertion'),
1455
+ :syntax => '![<i>w</i>]ZL',
1456
+ :priority => 6230,
1457
+ :description => _('Insert the decimal ' +
1458
+ 'representation of an unsigned ' +
1459
+ '32-bit value, left zero-filled ' +
1460
+ 'to the field width.'),
1461
+ :reMatch => '!\d*ZL',
1462
+ :reExtra => '!(\d*)ZL',
1463
+ :mask => 0xFFFFFFFF,
1464
+ :fill => '0',
1465
+ :justify => :right,
1466
+ :dWidth => :asNeeded,
1242
1467
  :code => ConvertNumeric,
1243
1468
  })
1244
1469
  FTO.registerEffector({
1245
1470
  :name => 'Long: octal',
1471
+ :category => _('Numeric insertion'),
1472
+ :syntax => '![<i>w</i>]OL',
1473
+ :priority => 6240,
1246
1474
  :description => _('Insert the octal ' +
1247
1475
  'representation of an unsigned ' +
1248
1476
  '32-bit value, left zero-filled ' +
1249
1477
  'to the field width (default ' +
1250
- '11)'),
1478
+ '11).'),
1251
1479
  :reMatch => '!\d*OL',
1252
1480
  :reExtra => '!(\d*)OL',
1253
1481
  :mask => 0xFFFFFFFF,
@@ -1260,11 +1488,14 @@ module FormatText
1260
1488
  })
1261
1489
  FTO.registerEffector({
1262
1490
  :name => 'Long: hex',
1491
+ :category => _('Numeric insertion'),
1492
+ :syntax => '![<i>w</i>]XL',
1493
+ :priority => 6250,
1263
1494
  :description => _('Insert the hexadecimal ' +
1264
1495
  'representation of an unsigned ' +
1265
1496
  '32-bit value, left zero-filled ' +
1266
1497
  'to the field width (default ' +
1267
- '8)'),
1498
+ '8).'),
1268
1499
  :reMatch => '!\d*XL',
1269
1500
  :reExtra => '!(\d*)XL',
1270
1501
  :mask => 0xFFFFFFFF,
@@ -1275,49 +1506,65 @@ module FormatText
1275
1506
  :data => [:hex],
1276
1507
  :code => ConvertNumeric,
1277
1508
  })
1509
+
1278
1510
  FTO.registerEffector({
1279
1511
  :name => 'Quadword: unsigned',
1512
+ :category => _('Numeric insertion'),
1513
+ :syntax => '![<i>w</i>]UQ',
1514
+ :priority => 6310,
1280
1515
  :description => _('Insert the decimal ' +
1281
1516
  'representation of an unsigned ' +
1282
- '8-bit value, left space-filled ' +
1283
- 'to the field width'),
1517
+ '64-bit value, left space-filled ' +
1518
+ 'to the field width.'),
1284
1519
  :reMatch => '!\d*UQ',
1285
1520
  :reExtra => '!(\d*)UQ',
1286
1521
  :mask => 0xFFFFFFFFFFFFFFFF,
1287
- :code => ConvertNumeric,
1288
- })
1289
- FTO.registerEffector({
1290
- :name => 'Quadword: unsigned, zero-filled',
1291
- :description => _('Insert the decimal ' +
1292
- 'representation of an unsigned ' +
1293
- '8-bit value, left zero-filled ' +
1294
- 'to the field width'),
1295
- :reMatch => '!\d*ZQ',
1296
- :reExtra => '!(\d*)ZQ',
1297
- :mask => 0xFFFFFFFFFFFFFFFF,
1298
- :fill => '0',
1299
- :justify => :right,
1522
+ :dWidth => :asNeeded,
1300
1523
  :code => ConvertNumeric,
1301
1524
  })
1302
1525
  FTO.registerEffector({
1303
1526
  :name => 'Quadword: signed',
1527
+ :category => _('Numeric insertion'),
1528
+ :syntax => '![<i>w</i>]SQ',
1529
+ :priority => 6320,
1304
1530
  :description => _('Insert the decimal ' +
1305
1531
  'representation of a signed ' +
1306
1532
  '64-bit value, left space-filled ' +
1307
- 'to the field width'),
1533
+ 'to the field width.'),
1308
1534
  :reMatch => '!\d*SQ',
1309
1535
  :reExtra => '!(\d*)SQ',
1310
1536
  :mask => 0xFFFFFFFFFFFFFFFF,
1311
1537
  :signbit => 0x8000000000000000,
1538
+ :dWidth => :asNeeded,
1539
+ :code => ConvertNumeric,
1540
+ })
1541
+ FTO.registerEffector({
1542
+ :name => 'Quadword: unsigned, zero-filled',
1543
+ :category => _('Numeric insertion'),
1544
+ :syntax => '![<i>w</i>]ZQ',
1545
+ :priority => 6330,
1546
+ :description => _('Insert the decimal ' +
1547
+ 'representation of an unsigned ' +
1548
+ '64-bit value, left zero-filled ' +
1549
+ 'to the field width.'),
1550
+ :reMatch => '!\d*ZQ',
1551
+ :reExtra => '!(\d*)ZQ',
1552
+ :mask => 0xFFFFFFFFFFFFFFFF,
1553
+ :fill => '0',
1554
+ :justify => :right,
1555
+ :dWidth => :asNeeded,
1312
1556
  :code => ConvertNumeric,
1313
1557
  })
1314
1558
  FTO.registerEffector({
1315
1559
  :name => 'Quadword: octal',
1560
+ :category => _('Numeric insertion'),
1561
+ :syntax => '![<i>w</i>]OQ',
1562
+ :priority => 6340,
1316
1563
  :description => _('Insert the octal ' +
1317
1564
  'representation of an unsigned ' +
1318
1565
  '64-bit value, left zero-filled ' +
1319
1566
  'to the field width (default ' +
1320
- '22)'),
1567
+ '22).'),
1321
1568
  :reMatch => '!\d*OQ',
1322
1569
  :reExtra => '!(\d*)OQ',
1323
1570
  :mask => 0xFFFFFFFFFFFFFFFF,
@@ -1330,11 +1577,14 @@ module FormatText
1330
1577
  })
1331
1578
  FTO.registerEffector({
1332
1579
  :name => 'Quadword: hex',
1580
+ :category => _('Numeric insertion'),
1581
+ :syntax => '![<i>w</i>]XQ',
1582
+ :priority => 6350,
1333
1583
  :description => _('Insert the hexadecimal ' +
1334
1584
  'representation of an unsigned ' +
1335
1585
  '64-bit value, left zero-filled ' +
1336
1586
  'to the field width (default ' +
1337
- '16)'),
1587
+ '16).'),
1338
1588
  :reMatch => '!\d*XQ',
1339
1589
  :reExtra => '!(\d*)XQ',
1340
1590
  :mask => 0xFFFFFFFFFFFFFFFF,