/src/wrappers/gtk/examples/gtk-eiffel-doc/eiffel_documentation_text_buffer.e

http://github.com/tybor/Liberty · Specman e · 659 lines · 495 code · 84 blank · 80 comment · 48 complexity · 18844d70f6225f0376e7ef991992db18 MD5 · raw file

  1. indexing
  2. description: "."
  3. copyright: "[
  4. Copyright (C) 2007 Paolo Redaelli
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2.0 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. class EIFFEL_DOCUMENTATION_TEXT_BUFFER
  19. -- TODO: Recognize class names stored into comments and add proper link to them
  20. inherit
  21. GTK_TEXT_BUFFER
  22. CLASS_NAME_VISITOR undefine is_equal, copy end
  23. CLASS_NAME_LIST_VISITOR undefine is_equal, copy end
  24. CLASS_TEXT_VISITOR undefine is_equal, copy end
  25. INDEX_LIST_VISITOR undefine is_equal, copy end
  26. INDEX_CLAUSE_VISITOR undefine is_equal, copy end
  27. COMMENT_VISITOR undefine is_equal, copy end
  28. FEATURE_CLAUSE_LIST_VISITOR undefine is_equal, copy end
  29. FEATURE_CLAUSE_VISITOR undefine is_equal, copy end
  30. PARENT_LISTS_VISITOR undefine is_equal, copy end
  31. PARENT_EDGE_VISITOR undefine is_equal, copy end
  32. CREATION_CLAUSE_LIST_VISITOR undefine is_equal, copy end
  33. CREATION_CLAUSE_VISITOR undefine is_equal, copy end
  34. CLIENT_LIST_VISITOR undefine is_equal, copy end
  35. FEATURE_NAME_LIST_VISITOR undefine is_equal, copy end
  36. FEATURE_NAME_VISITOR undefine is_equal, copy end
  37. ASSERTION_LIST_VISITOR undefine is_equal, copy end
  38. -- ASSERTION_LIST_VISITOR is an heir of CHECK_INVARIANT_VISITOR,
  39. -- CLASS_INVARIANT_VISITOR, E_ENSURE_VISITOR,
  40. -- LOOP_INVARIANT_VISITOR, REQUIRE_ITEM_VISITOR so there's no
  41. -- need to inherit them anew.
  42. insert
  43. PANGO_SCALES
  44. PANGO_STYLE
  45. PANGO_WEIGHT
  46. creation from_class_name
  47. feature {GTK_EIFFEL_DOC} -- Creation
  48. from_class_name (a_class_name: CLASS_NAME) is
  49. require
  50. class_name_not_void: a_class_name/=Void
  51. do
  52. class_name := a_class_name
  53. class_text := class_name.class_text
  54. debug
  55. io.put_string(once "{EIFFEL_DOCUMENTATION_TEXT_BUFFER}.from_class_name(")
  56. io.put_string(a_class_name.to_string)
  57. io.put_line(once ")")
  58. end
  59. make; add_tags; iter := start_iter
  60. if class_text = Void then insert_at(iter, once "No class text")
  61. else
  62. put_indexing
  63. -- remove the line above and put "if
  64. -- class_text.index_list/=Void then put_indexing end" when
  65. -- 2.4 is out.
  66. put_comment(class_text.heading_comment1)
  67. put_main_class_name
  68. put_comment(class_text.heading_comment2)
  69. if class_text.obsolete_mark/=Void then
  70. insert_with_tag(iter,once "obsolete ", class_tag)
  71. insert_with_tag(iter,class_text.obsolete_mark.to_string, string_tag)
  72. insert_at(iter,newline)
  73. end
  74. if class_text.parent_lists /= Void then put_parent_lists end
  75. if class_text.creation_clause_list /= Void then put_creation_clause_list end
  76. if class_text.feature_clause_list /= Void then put_feature_clause_list end
  77. if class_text.class_invariant/=Void then put_class_invariant(class_text.class_invariant) end
  78. put_comment(class_text.end_comment)
  79. end
  80. end
  81. feature
  82. iter: GTK_TEXT_ITER
  83. -- The insertion point used in all the features that add text
  84. -- to the buffer.
  85. put_indexing is
  86. -- Append the indexing clauses to Current buffer; TODO:
  87. -- currently only a small note is printed since the real
  88. -- implementation is commented out; in fact SmartEiffel 2.3
  89. -- does not export to visitors enought features to implement
  90. -- this. A couple of one-liner patches have already been
  91. -- applied to the SE repository.
  92. do
  93. insert_with_tag(iter,once "SmartEiffel 2.3 does not export to visitors enought features to implement this. A couple of one-liner patches have already been applied to the compiler SVN repository.%N",note_tag)
  94. -- require index_list_not_void: class_text.index_list /= Void
  95. -- local
  96. -- index_list: INDEX_LIST; string: STRING
  97. -- ici: ITERATOR[INDEX_CLAUSE]; index_clause: INDEX_CLAUSE;
  98. -- do
  99. -- index_list := class_name.class_text.index_list
  100. -- -- insert_at(iter, once "indexing")
  101. -- from ici:=index_list.list.get_new_iterator; ici.start; until ici.is_off
  102. -- loop
  103. -- index_clause := ici.item
  104. -- if index_clause /= Void then
  105. -- if index_clause.tag /= Void
  106. -- then insert_with_tag(iter,index_clause.tag.to_string+" ",keyword_tag)
  107. -- else insert_at(iter, once " (No tag?!?!) ")
  108. -- end
  109. -- if index_clause.list /= Void then
  110. -- string := merged_manifest_strings(index_clause.list)
  111. -- string.append_character('%N')
  112. -- insert_with_tag(iter,string,string_tag)
  113. -- end -- index_clause.list /= Void
  114. -- else
  115. -- debug io.put_line("Void index clause") end
  116. -- end -- index_claue /= Void
  117. -- ici.next
  118. -- end -- Loop over index list
  119. end
  120. put_comment (a_comment: COMMENT) is
  121. do
  122. if a_comment/=Void then
  123. insert_with_tag(iter,merged_strings(a_comment.list),comment_tag)
  124. end
  125. end
  126. put_main_class_name is
  127. -- Append to `iter' the name of the class text with full
  128. -- details as expected when you start reading an Eiffel
  129. -- class; i.e. "deferred class FOO [ITEM_->BAR]" or
  130. -- "expanded class MAMAN"
  131. local i: INTEGER; an_arg: FORMAL_GENERIC_ARG
  132. do
  133. if class_text.is_deferred
  134. then insert_with_tag(iter,once "deferred class ",class_tag)
  135. elseif class_text.is_expanded
  136. then insert_with_tag(iter,once "expanded class ",class_tag)
  137. else insert_with_tag(iter,once "class ",class_tag)
  138. end
  139. insert_with_tag(iter,class_name.to_string,class_tag)
  140. if class_text.formal_generic_list /= Void then
  141. insert_with_tag(iter,once " [",class_tag)
  142. from i := 1 until i > class_text.formal_generic_list.count - 1 loop
  143. an_arg := class_text.formal_generic_list.item(i)
  144. check arg_not_void: an_arg /= Void end
  145. put_formal_generic_arg(an_arg)
  146. insert_with_tag(iter,once ", ",class_tag)
  147. i := i + 1
  148. end
  149. put_formal_generic_arg(class_text.formal_generic_list.item(i))
  150. insert_with_tag(iter,once "]",class_tag)
  151. end
  152. put_newline
  153. end
  154. put_formal_generic_arg (an_arg: FORMAL_GENERIC_ARG) is
  155. do
  156. insert_with_tag(iter,an_arg.name.to_string,class_tag)
  157. if an_arg.constrained then
  158. insert_with_tag(iter,left_arrow,class_tag) -- "->"
  159. insert_with_tag(iter,an_arg.constraint.written_mark,class_tag)
  160. end
  161. end
  162. put_parent_lists is
  163. -- Put parent_lists if not Void
  164. require class_text.parent_lists /= Void
  165. local parents: PARENT_LISTS
  166. do
  167. parents := class_text.parent_lists
  168. if parents.inherit_count > 0 then
  169. if parents.inherit_count = 1
  170. then insert_with_tag(iter,once "Direct parent ",keyword_tag)
  171. else insert_with_tag(iter,once "Direct parents ",keyword_tag)
  172. end
  173. put_comment(parents.inherit_comment)
  174. if parents.inherit_list /= Void
  175. then put_parent_edges(parents.inherit_list)
  176. end
  177. end
  178. if parents.insert_count > 0 then
  179. insert_with_tag(iter,once "Directly inserting ",keyword_tag)
  180. put_comment(parents.insert_comment)
  181. if parents.default_insert_any_added_flag
  182. then insert_with_tag(iter,once "ANY has been automatically inserted%N",comment_tag)
  183. end
  184. if parents.insert_list /= Void
  185. then put_parent_edges(parents.insert_list)
  186. end
  187. end
  188. end
  189. put_parent_edges (some_parent_edges: COLLECTION[PARENT_EDGE]) is
  190. require some_parent_edges /= Void
  191. local i: INTEGER; edge: PARENT_EDGE
  192. do
  193. from i:=some_parent_edges.lower until i>some_parent_edges.upper-1
  194. loop
  195. edge := some_parent_edges.item(i)
  196. insert_with_tag(iter, edge.class_text_name+", ",feature_name_tag)
  197. i := i + 1
  198. end
  199. insert_with_tag(iter,some_parent_edges.item(i).class_text_name,
  200. feature_name_tag)
  201. insert_at(iter,newline)
  202. end
  203. put_creation_clause_list is
  204. require class_text.creation_clause_list /= Void
  205. local cci: ITERATOR[CREATION_CLAUSE]; cc: CREATION_CLAUSE; i, a_count: INTEGER
  206. do
  207. insert_with_tag(iter,once "creation features: ",feature_clause_tag)
  208. put_newline
  209. if class_text.creation_clause_list.list /= Void then
  210. from cci:=class_text.creation_clause_list.list.get_new_iterator
  211. until cci.is_off loop
  212. cc:=cci.item
  213. if cc/=Void then put_creation_clause(cc) end
  214. put_newline
  215. cci.next
  216. end -- loop over creation clauses
  217. end
  218. end
  219. put_creation_clause (a_creation_clause: CREATION_CLAUSE) is
  220. require non_void_clause: a_creation_clause/=Void
  221. do
  222. if a_creation_clause.clients/=Void then
  223. put_client_list(a_creation_clause.clients)
  224. end
  225. if a_creation_clause.comment/=Void then
  226. put_comment(a_creation_clause.comment)
  227. end
  228. if a_creation_clause.procedure_list/=Void then
  229. put_feature_name_list(a_creation_clause.procedure_list)
  230. else io.put_line(once "Void procedure list in creation clause list.")
  231. end
  232. end
  233. put_client_list (some_clients: CLIENT_LIST) is
  234. require clients_not_void: some_clients/=Void
  235. local i: INTEGER
  236. do
  237. if some_clients.class_name_list/=Void then
  238. from i:=1 until i>some_clients.class_name_list.count-1 loop
  239. insert_with_tag(iter,some_clients.class_name_list.item(i).to_string,feature_clause_tag)
  240. i := i + 1
  241. end
  242. end
  243. end
  244. put_feature_clause_list is
  245. require class_text.feature_clause_list /= Void
  246. local
  247. fci: ITERATOR[FEATURE_CLAUSE] -- Feature Clause Iterator
  248. fc: FEATURE_CLAUSE -- Feature Clause
  249. i: INTEGER
  250. do
  251. fci := class_text.feature_clause_list.list.get_new_iterator
  252. from fci.start until fci.is_off loop
  253. fc := fci.item
  254. -- clients: CLIENT_LIST The clients allowed to use these
  255. -- features.
  256. insert_with_tag(iter, "Feature clause "+fc.clients.eiffel_view,
  257. feature_name_tag)
  258. -- comment: COMMENT The heading comment comming with the
  259. -- clause.
  260. put_comment(fc.comment)
  261. -- list: FAST_ARRAY[FEATURE_TEXT] Only the features of the
  262. -- current clause.
  263. if fc.list/=Void then
  264. from i := fc.list.lower until i > fc.list.upper loop
  265. put_feature_text(fc.list.item(i))
  266. i := i + 1
  267. end
  268. else insert_with_tag(iter, once "no feature text into a feature clause%N", note_tag)
  269. end
  270. fci.next
  271. end -- Loop over Feature Clause
  272. end
  273. put_feature_name_list (a_list: FEATURE_NAME_LIST) is
  274. require list_not_void: a_list/=Void
  275. local i: INTEGER
  276. do
  277. from i:=1 until i> a_list.count-1 loop
  278. put_feature_name(a_list.item(i))
  279. insert_with_tag(iter,once ", ",feature_name_tag)
  280. i:=i+1
  281. end
  282. end
  283. put_feature_name (a_name: FEATURE_NAME) is
  284. require name_not_void: a_name /= Void
  285. do
  286. if a_name.is_frozen then
  287. insert_with_tag(iter,once "frozen ",feature_name_tag)
  288. end
  289. if a_name.is_infix_name then
  290. insert_with_tag(iter,once "infix ",feature_name_tag)
  291. end
  292. if a_name.is_prefix_name then
  293. insert_with_tag(iter,once "prefix ",feature_name_tag)
  294. end
  295. insert_with_tag(iter,a_name.to_string,feature_name_tag)
  296. end
  297. put_feature_text (a_text: FEATURE_TEXT) is
  298. require text_not_void: a_text/=Void
  299. local i, a_count: INTEGER
  300. do
  301. -- names: FEATURE_NAME_LIST All the names of the feature.
  302. if a_text.names/=Void then
  303. from i:=1; a_count:=a_text.names.count until i>a_count-1
  304. loop
  305. put_feature_name(a_text.names.item(i))
  306. insert_with_tag(iter, once ",",feature_name_tag)
  307. i:=i+1
  308. end
  309. put_feature_name(a_text.names.item(a_count))
  310. else io.put_line(once "Void feature names list!")
  311. end
  312. if a_text.arguments/=Void
  313. then put_formal_arg_list(a_text.arguments)
  314. end
  315. if a_text.result_type/=Void then
  316. -- result_type: TYPE_MARK Result type if any.
  317. insert_with_tag(iter,once ": ",argument_type_tag)
  318. insert_with_tag(iter,a_text.result_type.written_mark,argument_type_tag)
  319. end
  320. put_newline
  321. put_comment(a_text.header_comment) -- Header comment for a routine or following comment for an attribute.
  322. if a_text.obsolete_mark/=Void then
  323. -- obsolete_mark: MANIFEST_STRING The obsolete mark if any.
  324. insert_with_tag(iter,once "obsolete ", feature_clause_tag)
  325. insert_with_tag(iter,a_text.obsolete_mark.to_string, string_tag)
  326. put_newline
  327. end
  328. if a_text.clients/=Void then
  329. -- clients: CLIENT_LIST
  330. end
  331. if a_text.require_assertion/=Void then
  332. -- require_assertion: E_REQUIRE Not Void if any.
  333. end
  334. if a_text.ensure_assertion/=Void then
  335. -- ensure_assertion: E_ENSURE Not Void if any.
  336. put_ensure_assertion(a_text.ensure_assertion)
  337. end
  338. end
  339. put_class_invariant (an_invariant: CLASS_INVARIANT) is
  340. require class_text.class_invariant/=Void
  341. local assertion_iter: ITERATOR[ASSERTION]; an_assertion: ASSERTION
  342. do
  343. if an_invariant.list/=Void then
  344. assertion_iter:=an_invariant.list.get_new_iterator
  345. from assertion_iter.start until assertion_iter.is_off
  346. loop
  347. an_assertion := assertion_iter.item
  348. if an_assertion/=Void then put_assertion(an_assertion) end
  349. assertion_iter.next
  350. end
  351. else io.put_line(once "Empty assertion list in a class invariant.")
  352. end
  353. end
  354. put_assertion (an_assertion: ASSERTION) is
  355. require an_assertion/=Void
  356. do
  357. -- tag: TAG_NAME
  358. -- expression: EXPRESSION
  359. -- comment: COMMENT
  360. end
  361. put_formal_arg_list (some_arguments: FORMAL_ARG_LIST) is
  362. -- Put formal arguments
  363. require some_arguments/=Void
  364. local i, a_count: INTEGER; a_name: ARGUMENT_NAME1; a_type_mark: TYPE_MARK
  365. do
  366. insert_with_tag(iter, once " (",feature_clause_tag)
  367. from i:=1; a_count:=some_arguments.count
  368. until i > a_count-1 loop
  369. a_name := some_arguments.name(i)
  370. a_type_mark := some_arguments.type_mark(i)
  371. i := i + 1
  372. check
  373. name_not_void: a_name /= Void
  374. type_not_void: a_type_mark /= Void
  375. end
  376. -- if a_name=Void then io.put_line(once "Void argument name") end
  377. -- if a_type_mark=Void then io.put_line(once "Void argument type
  378. -- mark") end
  379. insert_with_tag(iter, a_name.to_string,argument_name_tag)
  380. insert_with_tag(iter, once ": ",argument_name_tag)
  381. insert_with_tag(iter, a_type_mark.written_mark,argument_type_tag)
  382. insert_with_tag(iter, once ", ",feature_clause_tag)
  383. end
  384. a_name := some_arguments.name(a_count)
  385. a_type_mark := some_arguments.type_mark(a_count)
  386. check
  387. name_not_void: a_name /= Void
  388. type_not_void: a_type_mark /= Void
  389. end
  390. insert_with_tag(iter,a_name.to_string,argument_name_tag)
  391. insert_with_tag(iter, once ": ",argument_name_tag)
  392. insert_with_tag(iter, a_type_mark.written_mark,argument_type_tag)
  393. insert_with_tag(iter, once ")",feature_clause_tag)
  394. end
  395. put_require_assertion (a_require_assertion: E_REQUIRE) is
  396. require a_require_assertion/=Void
  397. do
  398. end
  399. put_ensure_assertion (an_ensure_assertion: E_ENSURE) is
  400. require an_ensure_assertion /= Void
  401. do
  402. end
  403. feature -- Visitor features. Mostly empty
  404. visit_class_name (visited: CLASS_NAME) is do raise(dead_code) end
  405. visit_class_name_list (visited: CLASS_NAME_LIST) is do raise(dead_code) end
  406. visit_class_text (visited: CLASS_TEXT) is do raise(dead_code) end
  407. visit_index_list (visited: INDEX_LIST) is do raise(dead_code) end
  408. visit_index_clause (visited: INDEX_CLAUSE) is do raise(dead_code) end
  409. visit_comment (visited: COMMENT) is do raise(dead_code) end
  410. visit_feature_clause_list (some_features: FEATURE_CLAUSE_LIST) is do raise(dead_code) end
  411. visit_feature_clause (a_feature_clause: FEATURE_CLAUSE) is do raise(dead_code) end
  412. visit_parent_lists (visited: PARENT_LISTS) is do raise(dead_code) end
  413. visit_parent_edge (visited: PARENT_EDGE) is do raise(dead_code) end
  414. visit_creation_clause_list (visited: CREATION_CLAUSE_LIST) is do raise(dead_code) end
  415. visit_creation_clause (visited: CREATION_CLAUSE) is do raise(dead_code) end
  416. visit_client_list (visited: CLIENT_LIST) is do raise(dead_code) end
  417. visit_feature_name (visited: FEATURE_NAME) is do raise(dead_code) end
  418. visit_feature_name_list (visited: FEATURE_NAME_LIST) is do raise(dead_code) end
  419. -- ASSERTION_LIST_VISITOR features
  420. visit_loop_invariant (visited: LOOP_INVARIANT) is do raise(dead_code) end
  421. visit_require_item (visited: REQUIRE_ITEM) is do raise(dead_code) end
  422. visit_check_invariant (visited: CHECK_INVARIANT) is do raise(dead_code) end
  423. visit_e_ensure (an_ensure: E_ENSURE) is do raise(dead_code) end
  424. visit_e_require (a_require: E_REQUIRE) is do raise(dead_code) end
  425. visit_class_invariant (visited: CLASS_INVARIANT) is do raise(dead_code) end
  426. visit_assertion (visited: ASSERTION) is do raise(dead_code) end
  427. dead_code: STRING is "Visitor feature of an EIFFEL_DOCUMENTATION_TEXT_BUFFER invoked. They should never be invoked by design, since they're empty."
  428. feature -- Tags
  429. add_tags is
  430. -- Creates all the tags and add the them to the `tag_table'
  431. do
  432. create keyword_tag.with_name(once "keyword")
  433. -- keyword_tag.set_foreground(once "blue")
  434. keyword_tag.set_weight(pango_weight_semibold)
  435. tag_table.add(keyword_tag)
  436. create comment_tag.with_name(once "comment")
  437. -- comment_tag.set_foreground(once "green")
  438. comment_tag.set_style(pango_style_italic)
  439. comment_tag.set_left_margin(25)
  440. comment_tag.set_justification(gtk_justify_left) -- TODO: when supported gtk_justify_fill)
  441. tag_table.add(comment_tag)
  442. create string_tag.with_name(once "string")
  443. -- string_tag.set_foreground(once "gray")
  444. string_tag.set_style(pango_style_italic)
  445. string_tag.set_justification(gtk_justify_left) -- TODO: when supported gtk_justify_fill)
  446. tag_table.add(string_tag)
  447. create class_tag.with_name(once "class")
  448. class_tag.set_scale(pango_scale_xx_large*pango_scale_large)
  449. class_tag.set_weight(pango_weight_ultrabold)
  450. class_tag.set_pixels_above_lines(10)
  451. class_tag.set_pixels_below_lines(10)
  452. tag_table.add(class_tag)
  453. create feature_clause_tag.with_name(once "feature-clause")
  454. feature_clause_tag.set_weight(pango_weight_bold)
  455. feature_clause_tag.set_scale(pango_scale_x_large)
  456. feature_clause_tag.set_pixels_above_lines(5)
  457. feature_clause_tag.set_pixels_below_lines(5)
  458. tag_table.add(feature_clause_tag)
  459. create feature_name_tag.with_name(once "feature-name")
  460. feature_name_tag.set_weight(pango_weight_bold)
  461. feature_name_tag.set_scale(pango_scale_large)
  462. feature_clause_tag.set_pixels_above_lines(2)
  463. tag_table.add(feature_name_tag)
  464. create argument_name_tag.with_name(once "argument-name")
  465. argument_name_tag.set_scale(pango_scale_large)
  466. tag_table.add(argument_name_tag)
  467. create argument_type_tag.with_name(once "argument-type")
  468. argument_type_tag.set_weight(pango_weight_bold)
  469. argument_type_tag.set_scale(pango_scale_large)
  470. tag_table.add(argument_type_tag)
  471. -- TODO: instead of argument make argument-name and
  472. -- argument-type
  473. create cluster_tag.with_name(once "cluster")
  474. tag_table.add(cluster_tag)
  475. create note_tag.with_name(once "note")
  476. note_tag.set_scale(pango_scale_xx_small)
  477. note_tag.set_weight(pango_weight_ultralight)
  478. tag_table.add(note_tag)
  479. ensure
  480. keyword_tag /= Void
  481. comment_tag /= Void
  482. string_tag /= Void
  483. class_tag /= Void
  484. feature_clause_tag /= Void
  485. feature_name_tag /= Void
  486. argument_name_tag /= Void
  487. argument_type_tag /= Void
  488. cluster_tag /= Void
  489. note_tag /= Void
  490. end
  491. keyword_tag: GTK_TEXT_TAG
  492. comment_tag: GTK_TEXT_TAG
  493. string_tag: GTK_TEXT_TAG
  494. class_tag: GTK_TEXT_TAG
  495. feature_clause_tag: GTK_TEXT_TAG
  496. feature_name_tag: GTK_TEXT_TAG
  497. argument_name_tag: GTK_TEXT_TAG
  498. argument_type_tag: GTK_TEXT_TAG
  499. cluster_tag: GTK_TEXT_TAG
  500. note_tag: GTK_TEXT_TAG
  501. feature {} -- Implementation, syntactic sugar
  502. class_name: CLASS_NAME
  503. class_text: CLASS_TEXT
  504. not_homogeneous: BOOLEAN is False
  505. dont_expand: BOOLEAN is False
  506. expand: BOOLEAN is True
  507. dont_fill: BOOLEAN is False
  508. fill: BOOLEAN is True
  509. no_padding: INTEGER is 0
  510. newline: STRING is "%N"
  511. put_newline is
  512. do
  513. insert_at(iter,newline)
  514. end
  515. merged_strings (some_strings: COLLECTION[STRING]): STRING is
  516. -- A new string with all the strings in `some_strings'
  517. -- appended; all carriage return are replaced with a space. A
  518. -- newline is added at the end.
  519. require some_strings_not_void: some_strings /= Void
  520. local capacity: INTEGER;i: ITERATOR[STRING]
  521. do
  522. i := some_strings.get_new_iterator
  523. from i.start until i.is_off loop
  524. if i.item/=Void then capacity:=capacity+i.item.count end
  525. i.next
  526. end
  527. create Result.with_capacity(capacity+1)
  528. from i.start until i.is_off loop
  529. if i.item/=Void then Result.append(i.item) end
  530. i.next
  531. end
  532. Result.replace_all('%N',' ')
  533. Result.append_character('%N')
  534. ensure not_void: Result /= Void
  535. end
  536. merged_manifest_strings (some_strings: COLLECTION[MANIFEST_STRING]): STRING is
  537. -- A new string with all the strings in `some_strings'
  538. -- appended; all new lines are replaced with a space, except
  539. -- the ending one.
  540. require some_strings_not_void: some_strings /= Void
  541. local capacity: INTEGER;i: ITERATOR[MANIFEST_STRING]
  542. do
  543. -- Compute Result's length
  544. i := some_strings.get_new_iterator
  545. from i.start until i.is_off loop
  546. if i.item/=Void then capacity:=capacity+i.item.count end
  547. i.next
  548. end
  549. create Result.with_capacity(capacity)
  550. from i.start until i.is_off loop
  551. if i.item/=Void then Result.append(i.item.to_string) end
  552. i.next
  553. end
  554. Result.replace_all('%N',' ')
  555. if Result.last=' ' then Result.put('%N',Result.upper) end
  556. ensure not_void: Result /= Void
  557. end
  558. left_arrow: STRING is
  559. -- A right arrow in Unicode converted into UTF8
  560. do
  561. Result := (U"%/Ux2192/").to_string
  562. end
  563. midcolor (a,b: GDK_COLOR): GDK_COLOR is
  564. require
  565. a /= Void
  566. b /= Void
  567. do
  568. create Result.make
  569. Result.set_red((a.red+b.red)//2)
  570. Result.set_green((a.green+b.green)//2)
  571. Result.set_blue((a.blue+b.blue)//2)
  572. end
  573. invariant
  574. class_name/=Void
  575. end -- class EIFFEL_DOCUMENTATION_TEXT_BUFFER