1 | <!doctype html>
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <title>/boot/home/haiku/haiku/src/apps/mail/Content.cpp</title>
|
---|
5 | <style type="text/css">
|
---|
6 | body { color:#000000; background-color:#ffffff }
|
---|
7 | body { font-family:Helvetica, sans-serif; font-size:10pt }
|
---|
8 | h1 { font-size:14pt }
|
---|
9 | .code { border-collapse:collapse; width:100%; }
|
---|
10 | .code { font-family: "Monospace", monospace; font-size:10pt }
|
---|
11 | .code { line-height: 1.2em }
|
---|
12 | .comment { color: green; font-style: oblique }
|
---|
13 | .keyword { color: blue }
|
---|
14 | .string_literal { color: red }
|
---|
15 | .directive { color: darkmagenta }
|
---|
16 | .expansion { display: none; }
|
---|
17 | .macro:hover .expansion { display: block; border: 2px solid #FF0000; padding: 2px; background-color:#FFF0F0; font-weight: normal; -webkit-border-radius:5px; -webkit-box-shadow:1px 1px 7px #000; position: absolute; top: -1em; left:10em; z-index: 1 }
|
---|
18 | .macro { color: darkmagenta; background-color:LemonChiffon; position: relative }
|
---|
19 | .num { width:2.5em; padding-right:2ex; background-color:#eeeeee }
|
---|
20 | .num { text-align:right; font-size:8pt }
|
---|
21 | .num { color:#444444 }
|
---|
22 | .line { padding-left: 1ex; border-left: 3px solid #ccc }
|
---|
23 | .line { white-space: pre }
|
---|
24 | .msg { -webkit-box-shadow:1px 1px 7px #000 }
|
---|
25 | .msg { -webkit-border-radius:5px }
|
---|
26 | .msg { font-family:Helvetica, sans-serif; font-size:8pt }
|
---|
27 | .msg { float:left }
|
---|
28 | .msg { padding:0.25em 1ex 0.25em 1ex }
|
---|
29 | .msg { margin-top:10px; margin-bottom:10px }
|
---|
30 | .msg { font-weight:bold }
|
---|
31 | .msg { max-width:60em; word-wrap: break-word; white-space: pre-wrap }
|
---|
32 | .msgT { padding:0x; spacing:0x }
|
---|
33 | .msgEvent { background-color:#fff8b4; color:#000000 }
|
---|
34 | .msgControl { background-color:#bbbbbb; color:#000000 }
|
---|
35 | .mrange { background-color:#dfddf3 }
|
---|
36 | .mrange { border-bottom:1px solid #6F9DBE }
|
---|
37 | .PathIndex { font-weight: bold; padding:0px 5px; margin-right:5px; }
|
---|
38 | .PathIndex { -webkit-border-radius:8px }
|
---|
39 | .PathIndexEvent { background-color:#bfba87 }
|
---|
40 | .PathIndexControl { background-color:#8c8c8c }
|
---|
41 | .PathNav a { text-decoration:none; font-size: larger }
|
---|
42 | .CodeInsertionHint { font-weight: bold; background-color: #10dd10 }
|
---|
43 | .CodeRemovalHint { background-color:#de1010 }
|
---|
44 | .CodeRemovalHint { border-bottom:1px solid #6F9DBE }
|
---|
45 | table.simpletable {
|
---|
46 | padding: 5px;
|
---|
47 | font-size:12pt;
|
---|
48 | margin:20px;
|
---|
49 | border-collapse: collapse; border-spacing: 0px;
|
---|
50 | }
|
---|
51 | td.rowname {
|
---|
52 | text-align:right; font-weight:bold; color:#444444;
|
---|
53 | padding-right:2ex; }
|
---|
54 | </style>
|
---|
55 | </head>
|
---|
56 | <body>
|
---|
57 | <!-- BUGDESC Potential leak of memory pointed to by 'target' -->
|
---|
58 |
|
---|
59 | <!-- BUGTYPE Memory leak -->
|
---|
60 |
|
---|
61 | <!-- BUGCATEGORY Memory Error -->
|
---|
62 |
|
---|
63 | <!-- BUGFILE /boot/home/haiku/haiku/src/apps/mail/Content.cpp -->
|
---|
64 |
|
---|
65 | <!-- BUGLINE 3154 -->
|
---|
66 |
|
---|
67 | <!-- BUGPATHLENGTH 13 -->
|
---|
68 |
|
---|
69 | <!-- BUGMETAEND -->
|
---|
70 | <!-- REPORTHEADER -->
|
---|
71 | <h3>Bug Summary</h3>
|
---|
72 | <table class="simpletable">
|
---|
73 | <tr><td class="rowname">File:</td><td>/boot/home/haiku/haiku/src/apps/mail/Content.cpp</td></tr>
|
---|
74 | <tr><td class="rowname">Location:</td><td><a href="#EndPath">line 3154, column 5</a></td></tr>
|
---|
75 | <tr><td class="rowname">Description:</td><td>Potential leak of memory pointed to by 'target'</td></tr>
|
---|
76 | </table>
|
---|
77 | <!-- REPORTSUMMARYEXTRA -->
|
---|
78 | <h3>Annotated Source Code</h3>
|
---|
79 | <table class="code">
|
---|
80 | <tr><td class="num" id="LN1">1</td><td class="line"><span class='comment'>/*</span></td></tr>
|
---|
81 | <tr><td class="num" id="LN2">2</td><td class="line"><span class='comment'>Open Tracker License</span></td></tr>
|
---|
82 | <tr><td class="num" id="LN3">3</td><td class="line"> </td></tr>
|
---|
83 | <tr><td class="num" id="LN4">4</td><td class="line"><span class='comment'>Terms and Conditions</span></td></tr>
|
---|
84 | <tr><td class="num" id="LN5">5</td><td class="line"> </td></tr>
|
---|
85 | <tr><td class="num" id="LN6">6</td><td class="line"><span class='comment'>Copyright (c) 1991-2001, Be Incorporated. All rights reserved.</span></td></tr>
|
---|
86 | <tr><td class="num" id="LN7">7</td><td class="line"> </td></tr>
|
---|
87 | <tr><td class="num" id="LN8">8</td><td class="line"><span class='comment'>Permission is hereby granted, free of charge, to any person obtaining a copy of</span></td></tr>
|
---|
88 | <tr><td class="num" id="LN9">9</td><td class="line"><span class='comment'>this software and associated documentation files (the "Software"), to deal in</span></td></tr>
|
---|
89 | <tr><td class="num" id="LN10">10</td><td class="line"><span class='comment'>the Software without restriction, including without limitation the rights to</span></td></tr>
|
---|
90 | <tr><td class="num" id="LN11">11</td><td class="line"><span class='comment'>use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies</span></td></tr>
|
---|
91 | <tr><td class="num" id="LN12">12</td><td class="line"><span class='comment'>of the Software, and to permit persons to whom the Software is furnished to do</span></td></tr>
|
---|
92 | <tr><td class="num" id="LN13">13</td><td class="line"><span class='comment'>so, subject to the following conditions:</span></td></tr>
|
---|
93 | <tr><td class="num" id="LN14">14</td><td class="line"> </td></tr>
|
---|
94 | <tr><td class="num" id="LN15">15</td><td class="line"><span class='comment'>The above copyright notice and this permission notice applies to all licensees</span></td></tr>
|
---|
95 | <tr><td class="num" id="LN16">16</td><td class="line"><span class='comment'>and shall be included in all copies or substantial portions of the Software.</span></td></tr>
|
---|
96 | <tr><td class="num" id="LN17">17</td><td class="line"> </td></tr>
|
---|
97 | <tr><td class="num" id="LN18">18</td><td class="line"><span class='comment'>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></td></tr>
|
---|
98 | <tr><td class="num" id="LN19">19</td><td class="line"><span class='comment'>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,</span></td></tr>
|
---|
99 | <tr><td class="num" id="LN20">20</td><td class="line"><span class='comment'>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span></td></tr>
|
---|
100 | <tr><td class="num" id="LN21">21</td><td class="line"><span class='comment'>BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN</span></td></tr>
|
---|
101 | <tr><td class="num" id="LN22">22</td><td class="line"><span class='comment'>AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN</span></td></tr>
|
---|
102 | <tr><td class="num" id="LN23">23</td><td class="line"><span class='comment'>CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</span></td></tr>
|
---|
103 | <tr><td class="num" id="LN24">24</td><td class="line"> </td></tr>
|
---|
104 | <tr><td class="num" id="LN25">25</td><td class="line"><span class='comment'>Except as contained in this notice, the name of Be Incorporated shall not be</span></td></tr>
|
---|
105 | <tr><td class="num" id="LN26">26</td><td class="line"><span class='comment'>used in advertising or otherwise to promote the sale, use or other dealings in</span></td></tr>
|
---|
106 | <tr><td class="num" id="LN27">27</td><td class="line"><span class='comment'>this Software without prior written authorization from Be Incorporated.</span></td></tr>
|
---|
107 | <tr><td class="num" id="LN28">28</td><td class="line"> </td></tr>
|
---|
108 | <tr><td class="num" id="LN29">29</td><td class="line"><span class='comment'>BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or</span></td></tr>
|
---|
109 | <tr><td class="num" id="LN30">30</td><td class="line"><span class='comment'>registered trademarks of Be Incorporated in the United States and other</span></td></tr>
|
---|
110 | <tr><td class="num" id="LN31">31</td><td class="line"><span class='comment'>countries. Other brand product names are registered trademarks or trademarks</span></td></tr>
|
---|
111 | <tr><td class="num" id="LN32">32</td><td class="line"><span class='comment'>of their respective holders. All rights reserved.</span></td></tr>
|
---|
112 | <tr><td class="num" id="LN33">33</td><td class="line"><span class='comment'>*/</span></td></tr>
|
---|
113 | <tr><td class="num" id="LN34">34</td><td class="line"> </td></tr>
|
---|
114 | <tr><td class="num" id="LN35">35</td><td class="line"> </td></tr>
|
---|
115 | <tr><td class="num" id="LN36">36</td><td class="line"><span class='directive'>#include <stdlib.h></span></td></tr>
|
---|
116 | <tr><td class="num" id="LN37">37</td><td class="line"><span class='directive'>#include <string.h></span></td></tr>
|
---|
117 | <tr><td class="num" id="LN38">38</td><td class="line"><span class='directive'>#include <stdio.h></span></td></tr>
|
---|
118 | <tr><td class="num" id="LN39">39</td><td class="line"><span class='directive'>#include <ctype.h></span></td></tr>
|
---|
119 | <tr><td class="num" id="LN40">40</td><td class="line"> </td></tr>
|
---|
120 | <tr><td class="num" id="LN41">41</td><td class="line"><span class='directive'>#include <Alert.h></span></td></tr>
|
---|
121 | <tr><td class="num" id="LN42">42</td><td class="line"><span class='directive'>#include <Beep.h></span></td></tr>
|
---|
122 | <tr><td class="num" id="LN43">43</td><td class="line"><span class='directive'>#include <Clipboard.h></span></td></tr>
|
---|
123 | <tr><td class="num" id="LN44">44</td><td class="line"><span class='directive'>#include <Debug.h></span></td></tr>
|
---|
124 | <tr><td class="num" id="LN45">45</td><td class="line"><span class='directive'>#include <E-mail.h></span></td></tr>
|
---|
125 | <tr><td class="num" id="LN46">46</td><td class="line"><span class='directive'>#include <Input.h></span></td></tr>
|
---|
126 | <tr><td class="num" id="LN47">47</td><td class="line"><span class='directive'>#include <Locale.h></span></td></tr>
|
---|
127 | <tr><td class="num" id="LN48">48</td><td class="line"><span class='directive'>#include <MenuItem.h></span></td></tr>
|
---|
128 | <tr><td class="num" id="LN49">49</td><td class="line"><span class='directive'>#include <Mime.h></span></td></tr>
|
---|
129 | <tr><td class="num" id="LN50">50</td><td class="line"><span class='directive'>#include <NodeInfo.h></span></td></tr>
|
---|
130 | <tr><td class="num" id="LN51">51</td><td class="line"><span class='directive'>#include <NodeMonitor.h></span></td></tr>
|
---|
131 | <tr><td class="num" id="LN52">52</td><td class="line"><span class='directive'>#include <Path.h></span></td></tr>
|
---|
132 | <tr><td class="num" id="LN53">53</td><td class="line"><span class='directive'>#include <PopUpMenu.h></span></td></tr>
|
---|
133 | <tr><td class="num" id="LN54">54</td><td class="line"><span class='directive'>#include <Region.h></span></td></tr>
|
---|
134 | <tr><td class="num" id="LN55">55</td><td class="line"><span class='directive'>#include <Roster.h></span></td></tr>
|
---|
135 | <tr><td class="num" id="LN56">56</td><td class="line"><span class='directive'>#include <ScrollView.h></span></td></tr>
|
---|
136 | <tr><td class="num" id="LN57">57</td><td class="line"><span class='directive'>#include <TextView.h></span></td></tr>
|
---|
137 | <tr><td class="num" id="LN58">58</td><td class="line"><span class='directive'>#include <UTF8.h></span></td></tr>
|
---|
138 | <tr><td class="num" id="LN59">59</td><td class="line"> </td></tr>
|
---|
139 | <tr><td class="num" id="LN60">60</td><td class="line"><span class='directive'>#include <MailMessage.h></span></td></tr>
|
---|
140 | <tr><td class="num" id="LN61">61</td><td class="line"><span class='directive'>#include <MailAttachment.h></span></td></tr>
|
---|
141 | <tr><td class="num" id="LN62">62</td><td class="line"><span class='directive'>#include <mail_util.h></span></td></tr>
|
---|
142 | <tr><td class="num" id="LN63">63</td><td class="line"> </td></tr>
|
---|
143 | <tr><td class="num" id="LN64">64</td><td class="line"><span class='directive'>#include "MailApp.h"</span></td></tr>
|
---|
144 | <tr><td class="num" id="LN65">65</td><td class="line"><span class='directive'>#include "MailSupport.h"</span></td></tr>
|
---|
145 | <tr><td class="num" id="LN66">66</td><td class="line"><span class='directive'>#include "MailWindow.h"</span></td></tr>
|
---|
146 | <tr><td class="num" id="LN67">67</td><td class="line"><span class='directive'>#include "Messages.h"</span></td></tr>
|
---|
147 | <tr><td class="num" id="LN68">68</td><td class="line"><span class='directive'>#include "Content.h"</span></td></tr>
|
---|
148 | <tr><td class="num" id="LN69">69</td><td class="line"><span class='directive'>#include "Utilities.h"</span></td></tr>
|
---|
149 | <tr><td class="num" id="LN70">70</td><td class="line"><span class='directive'>#include "FieldMsg.h"</span></td></tr>
|
---|
150 | <tr><td class="num" id="LN71">71</td><td class="line"><span class='directive'>#include "Words.h"</span></td></tr>
|
---|
151 | <tr><td class="num" id="LN72">72</td><td class="line"> </td></tr>
|
---|
152 | <tr><td class="num" id="LN73">73</td><td class="line"> </td></tr>
|
---|
153 | <tr><td class="num" id="LN74">74</td><td class="line"><span class='directive'>#define <span class='macro'>DEBUG_SPELLCHECK<span class='expansion'>0</span></span> 0</span></td></tr>
|
---|
154 | <tr><td class="num" id="LN75">75</td><td class="line"><span class='directive'>#if <span class='macro'>DEBUG_SPELLCHECK<span class='expansion'>0</span></span></span></td></tr>
|
---|
155 | <tr><td class="num" id="LN76">76</td><td class="line"><span class='directive'># define <span class='macro'>DSPELL(x)<span class='expansion'>;</span></span> x</span></td></tr>
|
---|
156 | <tr><td class="num" id="LN77">77</td><td class="line"><span class='directive'>#else</span></td></tr>
|
---|
157 | <tr><td class="num" id="LN78">78</td><td class="line"><span class='directive'># define <span class='macro'>DSPELL(x)<span class='expansion'>;</span></span> ;</span></td></tr>
|
---|
158 | <tr><td class="num" id="LN79">79</td><td class="line"><span class='directive'>#endif</span></td></tr>
|
---|
159 | <tr><td class="num" id="LN80">80</td><td class="line"> </td></tr>
|
---|
160 | <tr><td class="num" id="LN81">81</td><td class="line"> </td></tr>
|
---|
161 | <tr><td class="num" id="LN82">82</td><td class="line"><span class='directive'>#define <span class='macro'>B_TRANSLATION_CONTEXT<span class='expansion'>"Mail"</span></span> "Mail"</span></td></tr>
|
---|
162 | <tr><td class="num" id="LN83">83</td><td class="line"> </td></tr>
|
---|
163 | <tr><td class="num" id="LN84">84</td><td class="line"> </td></tr>
|
---|
164 | <tr><td class="num" id="LN85">85</td><td class="line"><span class='keyword'>const</span> rgb_color kNormalTextColor = {0, 0, 0, 255};</td></tr>
|
---|
165 | <tr><td class="num" id="LN86">86</td><td class="line"><span class='keyword'>const</span> rgb_color kSpellTextColor = {255, 0, 0, 255};</td></tr>
|
---|
166 | <tr><td class="num" id="LN87">87</td><td class="line"><span class='keyword'>const</span> rgb_color kHyperLinkColor = {0, 0, 255, 255};</td></tr>
|
---|
167 | <tr><td class="num" id="LN88">88</td><td class="line"><span class='keyword'>const</span> rgb_color kHeaderColor = {72, 72, 72, 255};</td></tr>
|
---|
168 | <tr><td class="num" id="LN89">89</td><td class="line"> </td></tr>
|
---|
169 | <tr><td class="num" id="LN90">90</td><td class="line"><span class='keyword'>const</span> rgb_color kQuoteColors[] = {</td></tr>
|
---|
170 | <tr><td class="num" id="LN91">91</td><td class="line"> {0, 0, 0x80, 0}, <span class='comment'>// 3rd, 6th, ... quote level color (blue)</span></td></tr>
|
---|
171 | <tr><td class="num" id="LN92">92</td><td class="line"> {0, 0x80, 0, 0}, <span class='comment'>// 1st, 4th, ... quote level color (green)</span></td></tr>
|
---|
172 | <tr><td class="num" id="LN93">93</td><td class="line"> {0x80, 0, 0, 0} <span class='comment'>// 2nd, ... (red)</span></td></tr>
|
---|
173 | <tr><td class="num" id="LN94">94</td><td class="line">};</td></tr>
|
---|
174 | <tr><td class="num" id="LN95">95</td><td class="line"><span class='keyword'>const</span> int32 kNumQuoteColors = 3;</td></tr>
|
---|
175 | <tr><td class="num" id="LN96">96</td><td class="line"> </td></tr>
|
---|
176 | <tr><td class="num" id="LN97">97</td><td class="line"><span class='keyword'>const</span> rgb_color kDiffColors[] = {</td></tr>
|
---|
177 | <tr><td class="num" id="LN98">98</td><td class="line"> {0xb0, 0, 0, 0}, <span class='comment'>// '-', red</span></td></tr>
|
---|
178 | <tr><td class="num" id="LN99">99</td><td class="line"> {0, 0x90, 0, 0}, <span class='comment'>// '+', green</span></td></tr>
|
---|
179 | <tr><td class="num" id="LN100">100</td><td class="line"> {0x6a, 0x6a, 0x6a, 0} <span class='comment'>// '@@', dark grey</span></td></tr>
|
---|
180 | <tr><td class="num" id="LN101">101</td><td class="line">};</td></tr>
|
---|
181 | <tr><td class="num" id="LN102">102</td><td class="line"> </td></tr>
|
---|
182 | <tr><td class="num" id="LN103">103</td><td class="line"><span class='keyword'>void</span> Unicode2UTF8(int32 c, <span class='keyword'>char</span> **out);</td></tr>
|
---|
183 | <tr><td class="num" id="LN104">104</td><td class="line"> </td></tr>
|
---|
184 | <tr><td class="num" id="LN105">105</td><td class="line"> </td></tr>
|
---|
185 | <tr><td class="num" id="LN106">106</td><td class="line"><span class='keyword'>inline</span> <span class='keyword'>bool</span></td></tr>
|
---|
186 | <tr><td class="num" id="LN107">107</td><td class="line">IsInitialUTF8Byte(uchar b)</td></tr>
|
---|
187 | <tr><td class="num" id="LN108">108</td><td class="line">{</td></tr>
|
---|
188 | <tr><td class="num" id="LN109">109</td><td class="line"> <span class='keyword'>return</span> ((b & 0xC0) != 0x80);</td></tr>
|
---|
189 | <tr><td class="num" id="LN110">110</td><td class="line">}</td></tr>
|
---|
190 | <tr><td class="num" id="LN111">111</td><td class="line"> </td></tr>
|
---|
191 | <tr><td class="num" id="LN112">112</td><td class="line"> </td></tr>
|
---|
192 | <tr><td class="num" id="LN113">113</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
193 | <tr><td class="num" id="LN114">114</td><td class="line">Unicode2UTF8(int32 c, <span class='keyword'>char</span> **out)</td></tr>
|
---|
194 | <tr><td class="num" id="LN115">115</td><td class="line">{</td></tr>
|
---|
195 | <tr><td class="num" id="LN116">116</td><td class="line"> <span class='keyword'>char</span> *s = *out;</td></tr>
|
---|
196 | <tr><td class="num" id="LN117">117</td><td class="line"> </td></tr>
|
---|
197 | <tr><td class="num" id="LN118">118</td><td class="line"> <span class='macro'>ASSERT(c < 0x200000)<span class='expansion'>(void)0</span></span>;</td></tr>
|
---|
198 | <tr><td class="num" id="LN119">119</td><td class="line"> </td></tr>
|
---|
199 | <tr><td class="num" id="LN120">120</td><td class="line"> <span class='keyword'>if</span> (c < 0x80)</td></tr>
|
---|
200 | <tr><td class="num" id="LN121">121</td><td class="line"> *(s++) = c;</td></tr>
|
---|
201 | <tr><td class="num" id="LN122">122</td><td class="line"> <span class='keyword'>else</span> <span class='keyword'>if</span> (c < 0x800) {</td></tr>
|
---|
202 | <tr><td class="num" id="LN123">123</td><td class="line"> *(s++) = 0xc0 | (c >> 6);</td></tr>
|
---|
203 | <tr><td class="num" id="LN124">124</td><td class="line"> *(s++) = 0x80 | (c & 0x3f);</td></tr>
|
---|
204 | <tr><td class="num" id="LN125">125</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (c < 0x10000) {</td></tr>
|
---|
205 | <tr><td class="num" id="LN126">126</td><td class="line"> *(s++) = 0xe0 | (c >> 12);</td></tr>
|
---|
206 | <tr><td class="num" id="LN127">127</td><td class="line"> *(s++) = 0x80 | ((c >> 6) & 0x3f);</td></tr>
|
---|
207 | <tr><td class="num" id="LN128">128</td><td class="line"> *(s++) = 0x80 | (c & 0x3f);</td></tr>
|
---|
208 | <tr><td class="num" id="LN129">129</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (c < 0x200000) {</td></tr>
|
---|
209 | <tr><td class="num" id="LN130">130</td><td class="line"> *(s++) = 0xf0 | (c >> 18);</td></tr>
|
---|
210 | <tr><td class="num" id="LN131">131</td><td class="line"> *(s++) = 0x80 | ((c >> 12) & 0x3f);</td></tr>
|
---|
211 | <tr><td class="num" id="LN132">132</td><td class="line"> *(s++) = 0x80 | ((c >> 6) & 0x3f);</td></tr>
|
---|
212 | <tr><td class="num" id="LN133">133</td><td class="line"> *(s++) = 0x80 | (c & 0x3f);</td></tr>
|
---|
213 | <tr><td class="num" id="LN134">134</td><td class="line"> }</td></tr>
|
---|
214 | <tr><td class="num" id="LN135">135</td><td class="line"> *out = s;</td></tr>
|
---|
215 | <tr><td class="num" id="LN136">136</td><td class="line">}</td></tr>
|
---|
216 | <tr><td class="num" id="LN137">137</td><td class="line"> </td></tr>
|
---|
217 | <tr><td class="num" id="LN138">138</td><td class="line"> </td></tr>
|
---|
218 | <tr><td class="num" id="LN139">139</td><td class="line"><span class='keyword'>static</span> <span class='keyword'>bool</span></td></tr>
|
---|
219 | <tr><td class="num" id="LN140">140</td><td class="line">FilterHTMLTag(int32 &first, <span class='keyword'>char</span> **t, <span class='keyword'>char</span> *end)</td></tr>
|
---|
220 | <tr><td class="num" id="LN141">141</td><td class="line">{</td></tr>
|
---|
221 | <tr><td class="num" id="LN142">142</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *newlineTags[] = {</td></tr>
|
---|
222 | <tr><td class="num" id="LN143">143</td><td class="line"> <span class='string_literal'>"br"</span>, <span class='string_literal'>"/p"</span>, <span class='string_literal'>"/div"</span>, <span class='string_literal'>"/table"</span>, <span class='string_literal'>"/tr"</span>,</td></tr>
|
---|
223 | <tr><td class="num" id="LN144">144</td><td class="line"> <span class='macro'>NULL<span class='expansion'>__null</span></span>};</td></tr>
|
---|
224 | <tr><td class="num" id="LN145">145</td><td class="line"> </td></tr>
|
---|
225 | <tr><td class="num" id="LN146">146</td><td class="line"> <span class='keyword'>char</span> *a = *t;</td></tr>
|
---|
226 | <tr><td class="num" id="LN147">147</td><td class="line"> </td></tr>
|
---|
227 | <tr><td class="num" id="LN148">148</td><td class="line"> <span class='comment'>// check for some common entities (in ISO-Latin-1)</span></td></tr>
|
---|
228 | <tr><td class="num" id="LN149">149</td><td class="line"> <span class='keyword'>if</span> (first == '&') {</td></tr>
|
---|
229 | <tr><td class="num" id="LN150">150</td><td class="line"> <span class='comment'>// filter out and convert decimal values</span></td></tr>
|
---|
230 | <tr><td class="num" id="LN151">151</td><td class="line"> <span class='keyword'>if</span> (a[1] == '#' && sscanf(a + 2, <span class='string_literal'>"%"</span> <span class='macro'>B_SCNd32<span class='expansion'>"l" "d"</span></span> <span class='string_literal'>";"</span>, &first) == 1) {</td></tr>
|
---|
231 | <tr><td class="num" id="LN152">152</td><td class="line"> t[0] += strchr(a, ';') - a;</td></tr>
|
---|
232 | <tr><td class="num" id="LN153">153</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
233 | <tr><td class="num" id="LN154">154</td><td class="line"> }</td></tr>
|
---|
234 | <tr><td class="num" id="LN155">155</td><td class="line"> </td></tr>
|
---|
235 | <tr><td class="num" id="LN156">156</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>struct</span> { <span class='keyword'>const</span> <span class='keyword'>char</span> *name; int32 code; } entities[] = {</td></tr>
|
---|
236 | <tr><td class="num" id="LN157">157</td><td class="line"> <span class='comment'>// this list is sorted alphabetically to be binary searchable</span></td></tr>
|
---|
237 | <tr><td class="num" id="LN158">158</td><td class="line"> <span class='comment'>// the current implementation doesn't do this, though</span></td></tr>
|
---|
238 | <tr><td class="num" id="LN159">159</td><td class="line"> </td></tr>
|
---|
239 | <tr><td class="num" id="LN160">160</td><td class="line"> <span class='comment'>// "name" is the entity name,</span></td></tr>
|
---|
240 | <tr><td class="num" id="LN161">161</td><td class="line"> <span class='comment'>// "code" is the corresponding unicode</span></td></tr>
|
---|
241 | <tr><td class="num" id="LN162">162</td><td class="line"> {<span class='string_literal'>"AElig;"</span>, 0x00c6},</td></tr>
|
---|
242 | <tr><td class="num" id="LN163">163</td><td class="line"> {<span class='string_literal'>"Aacute;"</span>, 0x00c1},</td></tr>
|
---|
243 | <tr><td class="num" id="LN164">164</td><td class="line"> {<span class='string_literal'>"Acirc;"</span>, 0x00c2},</td></tr>
|
---|
244 | <tr><td class="num" id="LN165">165</td><td class="line"> {<span class='string_literal'>"Agrave;"</span>, 0x00c0},</td></tr>
|
---|
245 | <tr><td class="num" id="LN166">166</td><td class="line"> {<span class='string_literal'>"Aring;"</span>, 0x00c5},</td></tr>
|
---|
246 | <tr><td class="num" id="LN167">167</td><td class="line"> {<span class='string_literal'>"Atilde;"</span>, 0x00c3},</td></tr>
|
---|
247 | <tr><td class="num" id="LN168">168</td><td class="line"> {<span class='string_literal'>"Auml;"</span>, 0x00c4},</td></tr>
|
---|
248 | <tr><td class="num" id="LN169">169</td><td class="line"> {<span class='string_literal'>"Ccedil;"</span>, 0x00c7},</td></tr>
|
---|
249 | <tr><td class="num" id="LN170">170</td><td class="line"> {<span class='string_literal'>"Eacute;"</span>, 0x00c9},</td></tr>
|
---|
250 | <tr><td class="num" id="LN171">171</td><td class="line"> {<span class='string_literal'>"Ecirc;"</span>, 0x00ca},</td></tr>
|
---|
251 | <tr><td class="num" id="LN172">172</td><td class="line"> {<span class='string_literal'>"Egrave;"</span>, 0x00c8},</td></tr>
|
---|
252 | <tr><td class="num" id="LN173">173</td><td class="line"> {<span class='string_literal'>"Euml;"</span>, 0x00cb},</td></tr>
|
---|
253 | <tr><td class="num" id="LN174">174</td><td class="line"> {<span class='string_literal'>"Iacute;"</span>, 0x00cd},</td></tr>
|
---|
254 | <tr><td class="num" id="LN175">175</td><td class="line"> {<span class='string_literal'>"Icirc;"</span>, 0x00ce},</td></tr>
|
---|
255 | <tr><td class="num" id="LN176">176</td><td class="line"> {<span class='string_literal'>"Igrave;"</span>, 0x00cc},</td></tr>
|
---|
256 | <tr><td class="num" id="LN177">177</td><td class="line"> {<span class='string_literal'>"Iuml;"</span>, 0x00cf},</td></tr>
|
---|
257 | <tr><td class="num" id="LN178">178</td><td class="line"> {<span class='string_literal'>"Ntilde;"</span>, 0x00d1},</td></tr>
|
---|
258 | <tr><td class="num" id="LN179">179</td><td class="line"> {<span class='string_literal'>"Oacute;"</span>, 0x00d3},</td></tr>
|
---|
259 | <tr><td class="num" id="LN180">180</td><td class="line"> {<span class='string_literal'>"Ocirc;"</span>, 0x00d4},</td></tr>
|
---|
260 | <tr><td class="num" id="LN181">181</td><td class="line"> {<span class='string_literal'>"Ograve;"</span>, 0x00d2},</td></tr>
|
---|
261 | <tr><td class="num" id="LN182">182</td><td class="line"> {<span class='string_literal'>"Ouml;"</span>, 0x00d6},</td></tr>
|
---|
262 | <tr><td class="num" id="LN183">183</td><td class="line"> {<span class='string_literal'>"Uacute;"</span>, 0x00da},</td></tr>
|
---|
263 | <tr><td class="num" id="LN184">184</td><td class="line"> {<span class='string_literal'>"Ucirc;"</span>, 0x00db},</td></tr>
|
---|
264 | <tr><td class="num" id="LN185">185</td><td class="line"> {<span class='string_literal'>"Ugrave;"</span>, 0x00d9},</td></tr>
|
---|
265 | <tr><td class="num" id="LN186">186</td><td class="line"> {<span class='string_literal'>"Uuml;"</span>, 0x00dc},</td></tr>
|
---|
266 | <tr><td class="num" id="LN187">187</td><td class="line"> {<span class='string_literal'>"aacute;"</span>, 0x00e1},</td></tr>
|
---|
267 | <tr><td class="num" id="LN188">188</td><td class="line"> {<span class='string_literal'>"acirc;"</span>, 0x00e2},</td></tr>
|
---|
268 | <tr><td class="num" id="LN189">189</td><td class="line"> {<span class='string_literal'>"aelig;"</span>, 0x00e6},</td></tr>
|
---|
269 | <tr><td class="num" id="LN190">190</td><td class="line"> {<span class='string_literal'>"agrave;"</span>, 0x00e0},</td></tr>
|
---|
270 | <tr><td class="num" id="LN191">191</td><td class="line"> {<span class='string_literal'>"amp;"</span>, '&'},</td></tr>
|
---|
271 | <tr><td class="num" id="LN192">192</td><td class="line"> {<span class='string_literal'>"aring;"</span>, 0x00e5},</td></tr>
|
---|
272 | <tr><td class="num" id="LN193">193</td><td class="line"> {<span class='string_literal'>"atilde;"</span>, 0x00e3},</td></tr>
|
---|
273 | <tr><td class="num" id="LN194">194</td><td class="line"> {<span class='string_literal'>"auml;"</span>, 0x00e4},</td></tr>
|
---|
274 | <tr><td class="num" id="LN195">195</td><td class="line"> {<span class='string_literal'>"ccedil;"</span>, 0x00e7},</td></tr>
|
---|
275 | <tr><td class="num" id="LN196">196</td><td class="line"> {<span class='string_literal'>"copy;"</span>, 0x00a9},</td></tr>
|
---|
276 | <tr><td class="num" id="LN197">197</td><td class="line"> {<span class='string_literal'>"eacute;"</span>, 0x00e9},</td></tr>
|
---|
277 | <tr><td class="num" id="LN198">198</td><td class="line"> {<span class='string_literal'>"ecirc;"</span>, 0x00ea},</td></tr>
|
---|
278 | <tr><td class="num" id="LN199">199</td><td class="line"> {<span class='string_literal'>"egrave;"</span>, 0x00e8},</td></tr>
|
---|
279 | <tr><td class="num" id="LN200">200</td><td class="line"> {<span class='string_literal'>"euml;"</span>, 0x00eb},</td></tr>
|
---|
280 | <tr><td class="num" id="LN201">201</td><td class="line"> {<span class='string_literal'>"gt;"</span>, '>'},</td></tr>
|
---|
281 | <tr><td class="num" id="LN202">202</td><td class="line"> {<span class='string_literal'>"iacute;"</span>, 0x00ed},</td></tr>
|
---|
282 | <tr><td class="num" id="LN203">203</td><td class="line"> {<span class='string_literal'>"icirc;"</span>, 0x00ee},</td></tr>
|
---|
283 | <tr><td class="num" id="LN204">204</td><td class="line"> {<span class='string_literal'>"igrave;"</span>, 0x00ec},</td></tr>
|
---|
284 | <tr><td class="num" id="LN205">205</td><td class="line"> {<span class='string_literal'>"iuml;"</span>, 0x00ef},</td></tr>
|
---|
285 | <tr><td class="num" id="LN206">206</td><td class="line"> {<span class='string_literal'>"lt;"</span>, '<'},</td></tr>
|
---|
286 | <tr><td class="num" id="LN207">207</td><td class="line"> {<span class='string_literal'>"nbsp;"</span>, ' '},</td></tr>
|
---|
287 | <tr><td class="num" id="LN208">208</td><td class="line"> {<span class='string_literal'>"ntilde;"</span>, 0x00f1},</td></tr>
|
---|
288 | <tr><td class="num" id="LN209">209</td><td class="line"> {<span class='string_literal'>"oacute;"</span>, 0x00f3},</td></tr>
|
---|
289 | <tr><td class="num" id="LN210">210</td><td class="line"> {<span class='string_literal'>"ocirc;"</span>, 0x00f4},</td></tr>
|
---|
290 | <tr><td class="num" id="LN211">211</td><td class="line"> {<span class='string_literal'>"ograve;"</span>, 0x00f2},</td></tr>
|
---|
291 | <tr><td class="num" id="LN212">212</td><td class="line"> {<span class='string_literal'>"ouml;"</span>, 0x00f6},</td></tr>
|
---|
292 | <tr><td class="num" id="LN213">213</td><td class="line"> {<span class='string_literal'>"quot;"</span>, '"'},</td></tr>
|
---|
293 | <tr><td class="num" id="LN214">214</td><td class="line"> {<span class='string_literal'>"szlig;"</span>, 0x00f6},</td></tr>
|
---|
294 | <tr><td class="num" id="LN215">215</td><td class="line"> {<span class='string_literal'>"uacute;"</span>, 0x00fa},</td></tr>
|
---|
295 | <tr><td class="num" id="LN216">216</td><td class="line"> {<span class='string_literal'>"ucirc;"</span>, 0x00fb},</td></tr>
|
---|
296 | <tr><td class="num" id="LN217">217</td><td class="line"> {<span class='string_literal'>"ugrave;"</span>, 0x00f9},</td></tr>
|
---|
297 | <tr><td class="num" id="LN218">218</td><td class="line"> {<span class='string_literal'>"uuml;"</span>, 0x00fc},</td></tr>
|
---|
298 | <tr><td class="num" id="LN219">219</td><td class="line"> {<span class='macro'>NULL<span class='expansion'>__null</span></span>, 0}</td></tr>
|
---|
299 | <tr><td class="num" id="LN220">220</td><td class="line"> };</td></tr>
|
---|
300 | <tr><td class="num" id="LN221">221</td><td class="line"> </td></tr>
|
---|
301 | <tr><td class="num" id="LN222">222</td><td class="line"> <span class='keyword'>for</span> (int32 i = 0; entities[i].name; i++) {</td></tr>
|
---|
302 | <tr><td class="num" id="LN223">223</td><td class="line"> <span class='comment'>// entities are case-sensitive</span></td></tr>
|
---|
303 | <tr><td class="num" id="LN224">224</td><td class="line"> int32 length = strlen(entities[i].name);</td></tr>
|
---|
304 | <tr><td class="num" id="LN225">225</td><td class="line"> <span class='keyword'>if</span> (!strncmp(a + 1, entities[i].name, length)) {</td></tr>
|
---|
305 | <tr><td class="num" id="LN226">226</td><td class="line"> t[0] += length; <span class='comment'>// note that the '&' is included here</span></td></tr>
|
---|
306 | <tr><td class="num" id="LN227">227</td><td class="line"> first = entities[i].code;</td></tr>
|
---|
307 | <tr><td class="num" id="LN228">228</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
308 | <tr><td class="num" id="LN229">229</td><td class="line"> }</td></tr>
|
---|
309 | <tr><td class="num" id="LN230">230</td><td class="line"> }</td></tr>
|
---|
310 | <tr><td class="num" id="LN231">231</td><td class="line"> }</td></tr>
|
---|
311 | <tr><td class="num" id="LN232">232</td><td class="line"> </td></tr>
|
---|
312 | <tr><td class="num" id="LN233">233</td><td class="line"> <span class='comment'>// no tag to filter</span></td></tr>
|
---|
313 | <tr><td class="num" id="LN234">234</td><td class="line"> <span class='keyword'>if</span> (first != '<')</td></tr>
|
---|
314 | <tr><td class="num" id="LN235">235</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
315 | <tr><td class="num" id="LN236">236</td><td class="line"> </td></tr>
|
---|
316 | <tr><td class="num" id="LN237">237</td><td class="line"> a++;</td></tr>
|
---|
317 | <tr><td class="num" id="LN238">238</td><td class="line"> </td></tr>
|
---|
318 | <tr><td class="num" id="LN239">239</td><td class="line"> <span class='comment'>// is the tag one of the newline tags?</span></td></tr>
|
---|
319 | <tr><td class="num" id="LN240">240</td><td class="line"> </td></tr>
|
---|
320 | <tr><td class="num" id="LN241">241</td><td class="line"> <span class='keyword'>bool</span> newline = <span class='keyword'>false</span>;</td></tr>
|
---|
321 | <tr><td class="num" id="LN242">242</td><td class="line"> <span class='keyword'>for</span> (<span class='keyword'>int</span> i = 0; newlineTags[i]; i++) {</td></tr>
|
---|
322 | <tr><td class="num" id="LN243">243</td><td class="line"> <span class='keyword'>int</span> length = strlen(newlineTags[i]);</td></tr>
|
---|
323 | <tr><td class="num" id="LN244">244</td><td class="line"> <span class='keyword'>if</span> (!strncasecmp(a, (<span class='keyword'>char</span> *)newlineTags[i], length) && !<span class='macro'>isalnum(a[length])<span class='expansion'>(__ctype_b[(int)((a[length]))] & (unsigned short int)_ISalnum<br>)</span></span>) {</td></tr>
|
---|
324 | <tr><td class="num" id="LN245">245</td><td class="line"> newline = <span class='keyword'>true</span>;</td></tr>
|
---|
325 | <tr><td class="num" id="LN246">246</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
326 | <tr><td class="num" id="LN247">247</td><td class="line"> }</td></tr>
|
---|
327 | <tr><td class="num" id="LN248">248</td><td class="line"> }</td></tr>
|
---|
328 | <tr><td class="num" id="LN249">249</td><td class="line"> </td></tr>
|
---|
329 | <tr><td class="num" id="LN250">250</td><td class="line"> <span class='comment'>// oh, it's not, so skip it!</span></td></tr>
|
---|
330 | <tr><td class="num" id="LN251">251</td><td class="line"> </td></tr>
|
---|
331 | <tr><td class="num" id="LN252">252</td><td class="line"> <span class='keyword'>if</span> (!strncasecmp(a, <span class='string_literal'>"head"</span>, 4)) { <span class='comment'>// skip "head" completely</span></td></tr>
|
---|
332 | <tr><td class="num" id="LN253">253</td><td class="line"> <span class='keyword'>for</span> (; a[0] && a < end; a++) {</td></tr>
|
---|
333 | <tr><td class="num" id="LN254">254</td><td class="line"> <span class='comment'>// Find the end of the HEAD section, or the start of the BODY,</span></td></tr>
|
---|
334 | <tr><td class="num" id="LN255">255</td><td class="line"> <span class='comment'>// which happens for some malformed spam.</span></td></tr>
|
---|
335 | <tr><td class="num" id="LN256">256</td><td class="line"> <span class='keyword'>if</span> (strncasecmp (a, <span class='string_literal'>"</head"</span>, 6) == 0 ||</td></tr>
|
---|
336 | <tr><td class="num" id="LN257">257</td><td class="line"> strncasecmp (a, <span class='string_literal'>"<body"</span>, 5) == 0)</td></tr>
|
---|
337 | <tr><td class="num" id="LN258">258</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
338 | <tr><td class="num" id="LN259">259</td><td class="line"> }</td></tr>
|
---|
339 | <tr><td class="num" id="LN260">260</td><td class="line"> }</td></tr>
|
---|
340 | <tr><td class="num" id="LN261">261</td><td class="line"> </td></tr>
|
---|
341 | <tr><td class="num" id="LN262">262</td><td class="line"> <span class='comment'>// skip until tag end</span></td></tr>
|
---|
342 | <tr><td class="num" id="LN263">263</td><td class="line"> <span class='keyword'>while</span> (a[0] && a[0] != '>' && a < end)</td></tr>
|
---|
343 | <tr><td class="num" id="LN264">264</td><td class="line"> a++;</td></tr>
|
---|
344 | <tr><td class="num" id="LN265">265</td><td class="line"> </td></tr>
|
---|
345 | <tr><td class="num" id="LN266">266</td><td class="line"> t[0] = a;</td></tr>
|
---|
346 | <tr><td class="num" id="LN267">267</td><td class="line"> </td></tr>
|
---|
347 | <tr><td class="num" id="LN268">268</td><td class="line"> <span class='keyword'>if</span> (newline) {</td></tr>
|
---|
348 | <tr><td class="num" id="LN269">269</td><td class="line"> first = '\n';</td></tr>
|
---|
349 | <tr><td class="num" id="LN270">270</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
350 | <tr><td class="num" id="LN271">271</td><td class="line"> }</td></tr>
|
---|
351 | <tr><td class="num" id="LN272">272</td><td class="line"> </td></tr>
|
---|
352 | <tr><td class="num" id="LN273">273</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>true</span>;</td></tr>
|
---|
353 | <tr><td class="num" id="LN274">274</td><td class="line">}</td></tr>
|
---|
354 | <tr><td class="num" id="LN275">275</td><td class="line"> </td></tr>
|
---|
355 | <tr><td class="num" id="LN276">276</td><td class="line"> </td></tr>
|
---|
356 | <tr><td class="num" id="LN277">277</td><td class="line"><span class='comment'>/** Returns the type and length of the URL in the string if it is one.</span></td></tr>
|
---|
357 | <tr><td class="num" id="LN278">278</td><td class="line"> <span class='comment'>* If the "url" string is specified, it will fill it with the complete</span></td></tr>
|
---|
358 | <tr><td class="num" id="LN279">279</td><td class="line"> <span class='comment'>* URL that might differ from the one in the text itself (i.e. because</span></td></tr>
|
---|
359 | <tr><td class="num" id="LN280">280</td><td class="line"> <span class='comment'>* of an prepended "http://").</span></td></tr>
|
---|
360 | <tr><td class="num" id="LN281">281</td><td class="line"> <span class='comment'>*/</span></td></tr>
|
---|
361 | <tr><td class="num" id="LN282">282</td><td class="line"> </td></tr>
|
---|
362 | <tr><td class="num" id="LN283">283</td><td class="line"><span class='keyword'>static</span> uint8</td></tr>
|
---|
363 | <tr><td class="num" id="LN284">284</td><td class="line">CheckForURL(<span class='keyword'>const</span> <span class='keyword'>char</span> *string, size_t &urlLength, BString *url = <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
364 | <tr><td class="num" id="LN285">285</td><td class="line">{</td></tr>
|
---|
365 | <tr><td class="num" id="LN286">286</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *urlPrefixes[] = {</td></tr>
|
---|
366 | <tr><td class="num" id="LN287">287</td><td class="line"> <span class='string_literal'>"http://"</span>,</td></tr>
|
---|
367 | <tr><td class="num" id="LN288">288</td><td class="line"> <span class='string_literal'>"ftp://"</span>,</td></tr>
|
---|
368 | <tr><td class="num" id="LN289">289</td><td class="line"> <span class='string_literal'>"shttp://"</span>,</td></tr>
|
---|
369 | <tr><td class="num" id="LN290">290</td><td class="line"> <span class='string_literal'>"https://"</span>,</td></tr>
|
---|
370 | <tr><td class="num" id="LN291">291</td><td class="line"> <span class='string_literal'>"finger://"</span>,</td></tr>
|
---|
371 | <tr><td class="num" id="LN292">292</td><td class="line"> <span class='string_literal'>"telnet://"</span>,</td></tr>
|
---|
372 | <tr><td class="num" id="LN293">293</td><td class="line"> <span class='string_literal'>"gopher://"</span>,</td></tr>
|
---|
373 | <tr><td class="num" id="LN294">294</td><td class="line"> <span class='string_literal'>"news://"</span>,</td></tr>
|
---|
374 | <tr><td class="num" id="LN295">295</td><td class="line"> <span class='string_literal'>"nntp://"</span>,</td></tr>
|
---|
375 | <tr><td class="num" id="LN296">296</td><td class="line"> <span class='string_literal'>"file://"</span>,</td></tr>
|
---|
376 | <tr><td class="num" id="LN297">297</td><td class="line"> <span class='macro'>NULL<span class='expansion'>__null</span></span></td></tr>
|
---|
377 | <tr><td class="num" id="LN298">298</td><td class="line"> };</td></tr>
|
---|
378 | <tr><td class="num" id="LN299">299</td><td class="line"> </td></tr>
|
---|
379 | <tr><td class="num" id="LN300">300</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
380 | <tr><td class="num" id="LN301">301</td><td class="line"> <span class='comment'>// Search for URL prefix</span></td></tr>
|
---|
381 | <tr><td class="num" id="LN302">302</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
382 | <tr><td class="num" id="LN303">303</td><td class="line"> uint8 type = 0;</td></tr>
|
---|
383 | <tr><td class="num" id="LN304">304</td><td class="line"> <span class='keyword'>for</span> (<span class='keyword'>const</span> <span class='keyword'>char</span> **prefix = urlPrefixes; *prefix != 0; prefix++) {</td></tr>
|
---|
384 | <tr><td class="num" id="LN305">305</td><td class="line"> <span class='keyword'>if</span> (!cistrncmp(string, *prefix, strlen(*prefix))) {</td></tr>
|
---|
385 | <tr><td class="num" id="LN306">306</td><td class="line"> type = TYPE_URL;</td></tr>
|
---|
386 | <tr><td class="num" id="LN307">307</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
387 | <tr><td class="num" id="LN308">308</td><td class="line"> }</td></tr>
|
---|
388 | <tr><td class="num" id="LN309">309</td><td class="line"> }</td></tr>
|
---|
389 | <tr><td class="num" id="LN310">310</td><td class="line"> </td></tr>
|
---|
390 | <tr><td class="num" id="LN311">311</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
391 | <tr><td class="num" id="LN312">312</td><td class="line"> <span class='comment'>// Not a URL? check for "mailto:" or "www."</span></td></tr>
|
---|
392 | <tr><td class="num" id="LN313">313</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
393 | <tr><td class="num" id="LN314">314</td><td class="line"> <span class='keyword'>if</span> (type == 0 && !cistrncmp(string, <span class='string_literal'>"mailto:"</span>, 7))</td></tr>
|
---|
394 | <tr><td class="num" id="LN315">315</td><td class="line"> type = TYPE_MAILTO;</td></tr>
|
---|
395 | <tr><td class="num" id="LN316">316</td><td class="line"> <span class='keyword'>if</span> (type == 0 && !strncmp(string, <span class='string_literal'>"www."</span>, 4)) {</td></tr>
|
---|
396 | <tr><td class="num" id="LN317">317</td><td class="line"> <span class='comment'>// this type will be special cased later (and a http:// is added</span></td></tr>
|
---|
397 | <tr><td class="num" id="LN318">318</td><td class="line"> <span class='comment'>// for the enclosure address)</span></td></tr>
|
---|
398 | <tr><td class="num" id="LN319">319</td><td class="line"> type = TYPE_URL;</td></tr>
|
---|
399 | <tr><td class="num" id="LN320">320</td><td class="line"> }</td></tr>
|
---|
400 | <tr><td class="num" id="LN321">321</td><td class="line"> <span class='keyword'>if</span> (type == 0) {</td></tr>
|
---|
401 | <tr><td class="num" id="LN322">322</td><td class="line"> <span class='comment'>// check for valid eMail addresses</span></td></tr>
|
---|
402 | <tr><td class="num" id="LN323">323</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *at = strchr(string, '@');</td></tr>
|
---|
403 | <tr><td class="num" id="LN324">324</td><td class="line"> <span class='keyword'>if</span> (at) {</td></tr>
|
---|
404 | <tr><td class="num" id="LN325">325</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *pos = string;</td></tr>
|
---|
405 | <tr><td class="num" id="LN326">326</td><td class="line"> <span class='keyword'>bool</span> readName = <span class='keyword'>false</span>;</td></tr>
|
---|
406 | <tr><td class="num" id="LN327">327</td><td class="line"> <span class='keyword'>for</span> (; pos < at; pos++) {</td></tr>
|
---|
407 | <tr><td class="num" id="LN328">328</td><td class="line"> <span class='comment'>// ToDo: are these all allowed characters?</span></td></tr>
|
---|
408 | <tr><td class="num" id="LN329">329</td><td class="line"> <span class='keyword'>if</span> (!<span class='macro'>isalnum(pos[0])<span class='expansion'>(__ctype_b[(int)((pos[0]))] & (unsigned short int)_ISalnum<br>)</span></span> && pos[0] != '_' && pos[0] != '.' && pos[0] != '-')</td></tr>
|
---|
409 | <tr><td class="num" id="LN330">330</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
410 | <tr><td class="num" id="LN331">331</td><td class="line"> </td></tr>
|
---|
411 | <tr><td class="num" id="LN332">332</td><td class="line"> readName = <span class='keyword'>true</span>;</td></tr>
|
---|
412 | <tr><td class="num" id="LN333">333</td><td class="line"> }</td></tr>
|
---|
413 | <tr><td class="num" id="LN334">334</td><td class="line"> <span class='keyword'>if</span> (pos == at && readName)</td></tr>
|
---|
414 | <tr><td class="num" id="LN335">335</td><td class="line"> type = TYPE_MAILTO;</td></tr>
|
---|
415 | <tr><td class="num" id="LN336">336</td><td class="line"> }</td></tr>
|
---|
416 | <tr><td class="num" id="LN337">337</td><td class="line"> }</td></tr>
|
---|
417 | <tr><td class="num" id="LN338">338</td><td class="line"> </td></tr>
|
---|
418 | <tr><td class="num" id="LN339">339</td><td class="line"> <span class='keyword'>if</span> (type == 0)</td></tr>
|
---|
419 | <tr><td class="num" id="LN340">340</td><td class="line"> <span class='keyword'>return</span> 0;</td></tr>
|
---|
420 | <tr><td class="num" id="LN341">341</td><td class="line"> </td></tr>
|
---|
421 | <tr><td class="num" id="LN342">342</td><td class="line"> int32 index = strcspn(string, <span class='string_literal'>" \t<>)\"\\,\r\n"</span>);</td></tr>
|
---|
422 | <tr><td class="num" id="LN343">343</td><td class="line"> </td></tr>
|
---|
423 | <tr><td class="num" id="LN344">344</td><td class="line"> <span class='comment'>// filter out some punctuation marks if they are the last character</span></td></tr>
|
---|
424 | <tr><td class="num" id="LN345">345</td><td class="line"> <span class='keyword'>char</span> suffix = string[index - 1];</td></tr>
|
---|
425 | <tr><td class="num" id="LN346">346</td><td class="line"> <span class='keyword'>if</span> (suffix == '.'</td></tr>
|
---|
426 | <tr><td class="num" id="LN347">347</td><td class="line"> || suffix == ','</td></tr>
|
---|
427 | <tr><td class="num" id="LN348">348</td><td class="line"> || suffix == '?'</td></tr>
|
---|
428 | <tr><td class="num" id="LN349">349</td><td class="line"> || suffix == '!'</td></tr>
|
---|
429 | <tr><td class="num" id="LN350">350</td><td class="line"> || suffix == ':'</td></tr>
|
---|
430 | <tr><td class="num" id="LN351">351</td><td class="line"> || suffix == ';')</td></tr>
|
---|
431 | <tr><td class="num" id="LN352">352</td><td class="line"> index--;</td></tr>
|
---|
432 | <tr><td class="num" id="LN353">353</td><td class="line"> </td></tr>
|
---|
433 | <tr><td class="num" id="LN354">354</td><td class="line"> <span class='keyword'>if</span> (type == TYPE_URL) {</td></tr>
|
---|
434 | <tr><td class="num" id="LN355">355</td><td class="line"> <span class='keyword'>char</span> *parenthesis = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
435 | <tr><td class="num" id="LN356">356</td><td class="line"> </td></tr>
|
---|
436 | <tr><td class="num" id="LN357">357</td><td class="line"> <span class='comment'>// filter out a trailing ')' if there is no left parenthesis before</span></td></tr>
|
---|
437 | <tr><td class="num" id="LN358">358</td><td class="line"> <span class='keyword'>if</span> (string[index - 1] == ')') {</td></tr>
|
---|
438 | <tr><td class="num" id="LN359">359</td><td class="line"> <span class='keyword'>char</span> *parenthesis = strchr(string, '(');</td></tr>
|
---|
439 | <tr><td class="num" id="LN360">360</td><td class="line"> <span class='keyword'>if</span> (parenthesis == <span class='macro'>NULL<span class='expansion'>__null</span></span> || parenthesis > string + index)</td></tr>
|
---|
440 | <tr><td class="num" id="LN361">361</td><td class="line"> index--;</td></tr>
|
---|
441 | <tr><td class="num" id="LN362">362</td><td class="line"> }</td></tr>
|
---|
442 | <tr><td class="num" id="LN363">363</td><td class="line"> </td></tr>
|
---|
443 | <tr><td class="num" id="LN364">364</td><td class="line"> <span class='comment'>// filter out a trailing ']' if there is no left bracket before</span></td></tr>
|
---|
444 | <tr><td class="num" id="LN365">365</td><td class="line"> <span class='keyword'>if</span> (parenthesis == <span class='macro'>NULL<span class='expansion'>__null</span></span> && string[index - 1] == ']') {</td></tr>
|
---|
445 | <tr><td class="num" id="LN366">366</td><td class="line"> <span class='keyword'>char</span> *parenthesis = strchr(string, '[');</td></tr>
|
---|
446 | <tr><td class="num" id="LN367">367</td><td class="line"> <span class='keyword'>if</span> (parenthesis == <span class='macro'>NULL<span class='expansion'>__null</span></span> || parenthesis > string + index)</td></tr>
|
---|
447 | <tr><td class="num" id="LN368">368</td><td class="line"> index--;</td></tr>
|
---|
448 | <tr><td class="num" id="LN369">369</td><td class="line"> }</td></tr>
|
---|
449 | <tr><td class="num" id="LN370">370</td><td class="line"> }</td></tr>
|
---|
450 | <tr><td class="num" id="LN371">371</td><td class="line"> </td></tr>
|
---|
451 | <tr><td class="num" id="LN372">372</td><td class="line"> <span class='keyword'>if</span> (url != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
452 | <tr><td class="num" id="LN373">373</td><td class="line"> <span class='comment'>// copy the address to the specified string</span></td></tr>
|
---|
453 | <tr><td class="num" id="LN374">374</td><td class="line"> <span class='keyword'>if</span> (type == TYPE_URL && string[0] == 'w') {</td></tr>
|
---|
454 | <tr><td class="num" id="LN375">375</td><td class="line"> <span class='comment'>// URL starts with "www.", so add the protocol to it</span></td></tr>
|
---|
455 | <tr><td class="num" id="LN376">376</td><td class="line"> url->SetTo(<span class='string_literal'>"http://"</span>);</td></tr>
|
---|
456 | <tr><td class="num" id="LN377">377</td><td class="line"> url->Append(string, index);</td></tr>
|
---|
457 | <tr><td class="num" id="LN378">378</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (type == TYPE_MAILTO && cistrncmp(string, <span class='string_literal'>"mailto:"</span>, 7)) {</td></tr>
|
---|
458 | <tr><td class="num" id="LN379">379</td><td class="line"> <span class='comment'>// eMail address had no "mailto:" prefix</span></td></tr>
|
---|
459 | <tr><td class="num" id="LN380">380</td><td class="line"> url->SetTo(<span class='string_literal'>"mailto:"</span>);</td></tr>
|
---|
460 | <tr><td class="num" id="LN381">381</td><td class="line"> url->Append(string, index);</td></tr>
|
---|
461 | <tr><td class="num" id="LN382">382</td><td class="line"> } <span class='keyword'>else</span></td></tr>
|
---|
462 | <tr><td class="num" id="LN383">383</td><td class="line"> url->SetTo(string, index);</td></tr>
|
---|
463 | <tr><td class="num" id="LN384">384</td><td class="line"> }</td></tr>
|
---|
464 | <tr><td class="num" id="LN385">385</td><td class="line"> urlLength = index;</td></tr>
|
---|
465 | <tr><td class="num" id="LN386">386</td><td class="line"> </td></tr>
|
---|
466 | <tr><td class="num" id="LN387">387</td><td class="line"> <span class='keyword'>return</span> type;</td></tr>
|
---|
467 | <tr><td class="num" id="LN388">388</td><td class="line">}</td></tr>
|
---|
468 | <tr><td class="num" id="LN389">389</td><td class="line"> </td></tr>
|
---|
469 | <tr><td class="num" id="LN390">390</td><td class="line"> </td></tr>
|
---|
470 | <tr><td class="num" id="LN391">391</td><td class="line"><span class='keyword'>static</span> <span class='keyword'>void</span></td></tr>
|
---|
471 | <tr><td class="num" id="LN392">392</td><td class="line">CopyQuotes(<span class='keyword'>const</span> <span class='keyword'>char</span> *text, size_t length, <span class='keyword'>char</span> *outText, size_t &outLength)</td></tr>
|
---|
472 | <tr><td class="num" id="LN393">393</td><td class="line">{</td></tr>
|
---|
473 | <tr><td class="num" id="LN394">394</td><td class="line"> <span class='comment'>// count qoute level (to be able to wrap quotes correctly)</span></td></tr>
|
---|
474 | <tr><td class="num" id="LN395">395</td><td class="line"> </td></tr>
|
---|
475 | <tr><td class="num" id="LN396">396</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *quote = <span class='macro'>QUOTE<span class='expansion'>"> "</span></span>;</td></tr>
|
---|
476 | <tr><td class="num" id="LN397">397</td><td class="line"> int32 level = 0;</td></tr>
|
---|
477 | <tr><td class="num" id="LN398">398</td><td class="line"> <span class='keyword'>for</span> (size_t i = 0; i < length; i++) {</td></tr>
|
---|
478 | <tr><td class="num" id="LN399">399</td><td class="line"> <span class='keyword'>if</span> (text[i] == quote[0])</td></tr>
|
---|
479 | <tr><td class="num" id="LN400">400</td><td class="line"> level++;</td></tr>
|
---|
480 | <tr><td class="num" id="LN401">401</td><td class="line"> <span class='keyword'>else</span> <span class='keyword'>if</span> (text[i] != ' ' && text[i] != '\t')</td></tr>
|
---|
481 | <tr><td class="num" id="LN402">402</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
482 | <tr><td class="num" id="LN403">403</td><td class="line"> }</td></tr>
|
---|
483 | <tr><td class="num" id="LN404">404</td><td class="line"> </td></tr>
|
---|
484 | <tr><td class="num" id="LN405">405</td><td class="line"> <span class='comment'>// if there are too much quotes, try to preserve the quote color level</span></td></tr>
|
---|
485 | <tr><td class="num" id="LN406">406</td><td class="line"> <span class='keyword'>if</span> (level > 10)</td></tr>
|
---|
486 | <tr><td class="num" id="LN407">407</td><td class="line"> level = kNumQuoteColors * 3 + (level % kNumQuoteColors);</td></tr>
|
---|
487 | <tr><td class="num" id="LN408">408</td><td class="line"> </td></tr>
|
---|
488 | <tr><td class="num" id="LN409">409</td><td class="line"> <span class='comment'>// copy the quotes to outText</span></td></tr>
|
---|
489 | <tr><td class="num" id="LN410">410</td><td class="line"> </td></tr>
|
---|
490 | <tr><td class="num" id="LN411">411</td><td class="line"> <span class='keyword'>const</span> int32 quoteLength = strlen(<span class='macro'>QUOTE<span class='expansion'>"> "</span></span>);</td></tr>
|
---|
491 | <tr><td class="num" id="LN412">412</td><td class="line"> outLength = 0;</td></tr>
|
---|
492 | <tr><td class="num" id="LN413">413</td><td class="line"> <span class='keyword'>while</span> (level-- > 0) {</td></tr>
|
---|
493 | <tr><td class="num" id="LN414">414</td><td class="line"> strcpy(outText + outLength, <span class='macro'>QUOTE<span class='expansion'>"> "</span></span>);</td></tr>
|
---|
494 | <tr><td class="num" id="LN415">415</td><td class="line"> outLength += quoteLength;</td></tr>
|
---|
495 | <tr><td class="num" id="LN416">416</td><td class="line"> }</td></tr>
|
---|
496 | <tr><td class="num" id="LN417">417</td><td class="line">}</td></tr>
|
---|
497 | <tr><td class="num" id="LN418">418</td><td class="line"> </td></tr>
|
---|
498 | <tr><td class="num" id="LN419">419</td><td class="line"> </td></tr>
|
---|
499 | <tr><td class="num" id="LN420">420</td><td class="line">int32</td></tr>
|
---|
500 | <tr><td class="num" id="LN421">421</td><td class="line">diff_mode(<span class='keyword'>char</span> c)</td></tr>
|
---|
501 | <tr><td class="num" id="LN422">422</td><td class="line">{</td></tr>
|
---|
502 | <tr><td class="num" id="LN423">423</td><td class="line"> <span class='keyword'>if</span> (c == '+')</td></tr>
|
---|
503 | <tr><td class="num" id="LN424">424</td><td class="line"> <span class='keyword'>return</span> 2;</td></tr>
|
---|
504 | <tr><td class="num" id="LN425">425</td><td class="line"> <span class='keyword'>if</span> (c == '-')</td></tr>
|
---|
505 | <tr><td class="num" id="LN426">426</td><td class="line"> <span class='keyword'>return</span> 1;</td></tr>
|
---|
506 | <tr><td class="num" id="LN427">427</td><td class="line"> <span class='keyword'>if</span> (c == '@')</td></tr>
|
---|
507 | <tr><td class="num" id="LN428">428</td><td class="line"> <span class='keyword'>return</span> 3;</td></tr>
|
---|
508 | <tr><td class="num" id="LN429">429</td><td class="line"> <span class='keyword'>if</span> (c == ' ')</td></tr>
|
---|
509 | <tr><td class="num" id="LN430">430</td><td class="line"> <span class='keyword'>return</span> 0;</td></tr>
|
---|
510 | <tr><td class="num" id="LN431">431</td><td class="line"> </td></tr>
|
---|
511 | <tr><td class="num" id="LN432">432</td><td class="line"> <span class='comment'>// everything else ends the diff mode</span></td></tr>
|
---|
512 | <tr><td class="num" id="LN433">433</td><td class="line"> <span class='keyword'>return</span> -1;</td></tr>
|
---|
513 | <tr><td class="num" id="LN434">434</td><td class="line">}</td></tr>
|
---|
514 | <tr><td class="num" id="LN435">435</td><td class="line"> </td></tr>
|
---|
515 | <tr><td class="num" id="LN436">436</td><td class="line"> </td></tr>
|
---|
516 | <tr><td class="num" id="LN437">437</td><td class="line"><span class='keyword'>bool</span></td></tr>
|
---|
517 | <tr><td class="num" id="LN438">438</td><td class="line">is_quote_char(<span class='keyword'>char</span> c)</td></tr>
|
---|
518 | <tr><td class="num" id="LN439">439</td><td class="line">{</td></tr>
|
---|
519 | <tr><td class="num" id="LN440">440</td><td class="line"> <span class='keyword'>return</span> c == '>' || c == '|';</td></tr>
|
---|
520 | <tr><td class="num" id="LN441">441</td><td class="line">}</td></tr>
|
---|
521 | <tr><td class="num" id="LN442">442</td><td class="line"> </td></tr>
|
---|
522 | <tr><td class="num" id="LN443">443</td><td class="line"> </td></tr>
|
---|
523 | <tr><td class="num" id="LN444">444</td><td class="line"><span class='comment'>/*! Fills the specified text_run_array with the correct values for the</span></td></tr>
|
---|
524 | <tr><td class="num" id="LN445">445</td><td class="line"> <span class='comment'>specified text.</span></td></tr>
|
---|
525 | <tr><td class="num" id="LN446">446</td><td class="line"> <span class='comment'>If "view" is NULL, it will assume that "line" lies on a line break,</span></td></tr>
|
---|
526 | <tr><td class="num" id="LN447">447</td><td class="line"> <span class='comment'>if not, it will correctly retrieve the number of quotes the current</span></td></tr>
|
---|
527 | <tr><td class="num" id="LN448">448</td><td class="line"> <span class='comment'>line already has.</span></td></tr>
|
---|
528 | <tr><td class="num" id="LN449">449</td><td class="line"><span class='comment'>*/</span></td></tr>
|
---|
529 | <tr><td class="num" id="LN450">450</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
530 | <tr><td class="num" id="LN451">451</td><td class="line">FillInQuoteTextRuns(BTextView* view, quote_context* context, <span class='keyword'>const</span> <span class='keyword'>char</span>* line,</td></tr>
|
---|
531 | <tr><td class="num" id="LN452">452</td><td class="line"> int32 length, <span class='keyword'>const</span> BFont& font, text_run_array* style, int32 maxStyles)</td></tr>
|
---|
532 | <tr><td class="num" id="LN453">453</td><td class="line">{</td></tr>
|
---|
533 | <tr><td class="num" id="LN454">454</td><td class="line"> text_run* runs = style->runs;</td></tr>
|
---|
534 | <tr><td class="num" id="LN455">455</td><td class="line"> int32 index = style->count;</td></tr>
|
---|
535 | <tr><td class="num" id="LN456">456</td><td class="line"> <span class='keyword'>bool</span> begin;</td></tr>
|
---|
536 | <tr><td class="num" id="LN457">457</td><td class="line"> int32 pos = 0;</td></tr>
|
---|
537 | <tr><td class="num" id="LN458">458</td><td class="line"> int32 diffMode = 0;</td></tr>
|
---|
538 | <tr><td class="num" id="LN459">459</td><td class="line"> <span class='keyword'>bool</span> inDiff = <span class='keyword'>false</span>;</td></tr>
|
---|
539 | <tr><td class="num" id="LN460">460</td><td class="line"> <span class='keyword'>bool</span> wasDiff = <span class='keyword'>false</span>;</td></tr>
|
---|
540 | <tr><td class="num" id="LN461">461</td><td class="line"> int32 level = 0;</td></tr>
|
---|
541 | <tr><td class="num" id="LN462">462</td><td class="line"> </td></tr>
|
---|
542 | <tr><td class="num" id="LN463">463</td><td class="line"> <span class='comment'>// get index to the beginning of the current line</span></td></tr>
|
---|
543 | <tr><td class="num" id="LN464">464</td><td class="line"> </td></tr>
|
---|
544 | <tr><td class="num" id="LN465">465</td><td class="line"> <span class='keyword'>if</span> (context != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
545 | <tr><td class="num" id="LN466">466</td><td class="line"> level = context->level;</td></tr>
|
---|
546 | <tr><td class="num" id="LN467">467</td><td class="line"> diffMode = context->diff_mode;</td></tr>
|
---|
547 | <tr><td class="num" id="LN468">468</td><td class="line"> begin = context->begin;</td></tr>
|
---|
548 | <tr><td class="num" id="LN469">469</td><td class="line"> inDiff = context->in_diff;</td></tr>
|
---|
549 | <tr><td class="num" id="LN470">470</td><td class="line"> wasDiff = context->was_diff;</td></tr>
|
---|
550 | <tr><td class="num" id="LN471">471</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (view != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
551 | <tr><td class="num" id="LN472">472</td><td class="line"> int32 start, end;</td></tr>
|
---|
552 | <tr><td class="num" id="LN473">473</td><td class="line"> view->GetSelection(&end, &end);</td></tr>
|
---|
553 | <tr><td class="num" id="LN474">474</td><td class="line"> </td></tr>
|
---|
554 | <tr><td class="num" id="LN475">475</td><td class="line"> begin = view->TextLength() == 0</td></tr>
|
---|
555 | <tr><td class="num" id="LN476">476</td><td class="line"> || view->ByteAt(view->TextLength() - 1) == '\n';</td></tr>
|
---|
556 | <tr><td class="num" id="LN477">477</td><td class="line"> </td></tr>
|
---|
557 | <tr><td class="num" id="LN478">478</td><td class="line"> <span class='comment'>// the following line works only reliable when text wrapping is set to</span></td></tr>
|
---|
558 | <tr><td class="num" id="LN479">479</td><td class="line"> <span class='comment'>// off; so the complicated version actually used here is necessary:</span></td></tr>
|
---|
559 | <tr><td class="num" id="LN480">480</td><td class="line"> <span class='comment'>// start = view->OffsetAt(view->CurrentLine());</span></td></tr>
|
---|
560 | <tr><td class="num" id="LN481">481</td><td class="line"> </td></tr>
|
---|
561 | <tr><td class="num" id="LN482">482</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = view->Text();</td></tr>
|
---|
562 | <tr><td class="num" id="LN483">483</td><td class="line"> </td></tr>
|
---|
563 | <tr><td class="num" id="LN484">484</td><td class="line"> <span class='keyword'>if</span> (!begin) {</td></tr>
|
---|
564 | <tr><td class="num" id="LN485">485</td><td class="line"> <span class='comment'>// if the text is not the start of a new line, go back</span></td></tr>
|
---|
565 | <tr><td class="num" id="LN486">486</td><td class="line"> <span class='comment'>// to the first character in the current line</span></td></tr>
|
---|
566 | <tr><td class="num" id="LN487">487</td><td class="line"> <span class='keyword'>for</span> (start = end; start > 0; start--) {</td></tr>
|
---|
567 | <tr><td class="num" id="LN488">488</td><td class="line"> <span class='keyword'>if</span> (text[start - 1] == '\n')</td></tr>
|
---|
568 | <tr><td class="num" id="LN489">489</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
569 | <tr><td class="num" id="LN490">490</td><td class="line"> }</td></tr>
|
---|
570 | <tr><td class="num" id="LN491">491</td><td class="line"> }</td></tr>
|
---|
571 | <tr><td class="num" id="LN492">492</td><td class="line"> </td></tr>
|
---|
572 | <tr><td class="num" id="LN493">493</td><td class="line"> <span class='comment'>// get number of nested qoutes for current line</span></td></tr>
|
---|
573 | <tr><td class="num" id="LN494">494</td><td class="line"> </td></tr>
|
---|
574 | <tr><td class="num" id="LN495">495</td><td class="line"> <span class='keyword'>if</span> (!begin && start < end) {</td></tr>
|
---|
575 | <tr><td class="num" id="LN496">496</td><td class="line"> begin = <span class='keyword'>true</span>;</td></tr>
|
---|
576 | <tr><td class="num" id="LN497">497</td><td class="line"> <span class='comment'>// if there was no text in this line, there may come</span></td></tr>
|
---|
577 | <tr><td class="num" id="LN498">498</td><td class="line"> <span class='comment'>// more nested quotes</span></td></tr>
|
---|
578 | <tr><td class="num" id="LN499">499</td><td class="line"> </td></tr>
|
---|
579 | <tr><td class="num" id="LN500">500</td><td class="line"> diffMode = diff_mode(text[start]);</td></tr>
|
---|
580 | <tr><td class="num" id="LN501">501</td><td class="line"> <span class='keyword'>if</span> (diffMode == 0) {</td></tr>
|
---|
581 | <tr><td class="num" id="LN502">502</td><td class="line"> <span class='keyword'>for</span> (int32 i = start; i < end; i++) {</td></tr>
|
---|
582 | <tr><td class="num" id="LN503">503</td><td class="line"> <span class='keyword'>if</span> (is_quote_char(text[i]))</td></tr>
|
---|
583 | <tr><td class="num" id="LN504">504</td><td class="line"> level++;</td></tr>
|
---|
584 | <tr><td class="num" id="LN505">505</td><td class="line"> <span class='keyword'>else</span> <span class='keyword'>if</span> (text[i] != ' ' && text[i] != '\t') {</td></tr>
|
---|
585 | <tr><td class="num" id="LN506">506</td><td class="line"> begin = <span class='keyword'>false</span>;</td></tr>
|
---|
586 | <tr><td class="num" id="LN507">507</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
587 | <tr><td class="num" id="LN508">508</td><td class="line"> }</td></tr>
|
---|
588 | <tr><td class="num" id="LN509">509</td><td class="line"> }</td></tr>
|
---|
589 | <tr><td class="num" id="LN510">510</td><td class="line"> } <span class='keyword'>else</span></td></tr>
|
---|
590 | <tr><td class="num" id="LN511">511</td><td class="line"> inDiff = <span class='keyword'>true</span>;</td></tr>
|
---|
591 | <tr><td class="num" id="LN512">512</td><td class="line"> </td></tr>
|
---|
592 | <tr><td class="num" id="LN513">513</td><td class="line"> <span class='keyword'>if</span> (begin) {</td></tr>
|
---|
593 | <tr><td class="num" id="LN514">514</td><td class="line"> <span class='comment'>// skip leading spaces (tabs & newlines aren't allowed here)</span></td></tr>
|
---|
594 | <tr><td class="num" id="LN515">515</td><td class="line"> <span class='keyword'>while</span> (line[pos] == ' ')</td></tr>
|
---|
595 | <tr><td class="num" id="LN516">516</td><td class="line"> pos++;</td></tr>
|
---|
596 | <tr><td class="num" id="LN517">517</td><td class="line"> }</td></tr>
|
---|
597 | <tr><td class="num" id="LN518">518</td><td class="line"> }</td></tr>
|
---|
598 | <tr><td class="num" id="LN519">519</td><td class="line"> } <span class='keyword'>else</span></td></tr>
|
---|
599 | <tr><td class="num" id="LN520">520</td><td class="line"> begin = <span class='keyword'>true</span>;</td></tr>
|
---|
600 | <tr><td class="num" id="LN521">521</td><td class="line"> </td></tr>
|
---|
601 | <tr><td class="num" id="LN522">522</td><td class="line"> <span class='comment'>// set styles for all qoute levels in the text to be inserted</span></td></tr>
|
---|
602 | <tr><td class="num" id="LN523">523</td><td class="line"> </td></tr>
|
---|
603 | <tr><td class="num" id="LN524">524</td><td class="line"> <span class='keyword'>for</span> (int32 pos = 0; pos < length;) {</td></tr>
|
---|
604 | <tr><td class="num" id="LN525">525</td><td class="line"> int32 next;</td></tr>
|
---|
605 | <tr><td class="num" id="LN526">526</td><td class="line"> <span class='keyword'>if</span> (begin && is_quote_char(line[pos])) {</td></tr>
|
---|
606 | <tr><td class="num" id="LN527">527</td><td class="line"> begin = <span class='keyword'>false</span>;</td></tr>
|
---|
607 | <tr><td class="num" id="LN528">528</td><td class="line"> </td></tr>
|
---|
608 | <tr><td class="num" id="LN529">529</td><td class="line"> <span class='keyword'>while</span> (pos < length && line[pos] != '\n') {</td></tr>
|
---|
609 | <tr><td class="num" id="LN530">530</td><td class="line"> <span class='comment'>// insert style for each quote level</span></td></tr>
|
---|
610 | <tr><td class="num" id="LN531">531</td><td class="line"> level++;</td></tr>
|
---|
611 | <tr><td class="num" id="LN532">532</td><td class="line"> </td></tr>
|
---|
612 | <tr><td class="num" id="LN533">533</td><td class="line"> <span class='keyword'>bool</span> search = <span class='keyword'>true</span>;</td></tr>
|
---|
613 | <tr><td class="num" id="LN534">534</td><td class="line"> <span class='keyword'>for</span> (next = pos + 1; next < length; next++) {</td></tr>
|
---|
614 | <tr><td class="num" id="LN535">535</td><td class="line"> <span class='keyword'>if</span> ((search && is_quote_char(line[next]))</td></tr>
|
---|
615 | <tr><td class="num" id="LN536">536</td><td class="line"> || line[next] == '\n')</td></tr>
|
---|
616 | <tr><td class="num" id="LN537">537</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
617 | <tr><td class="num" id="LN538">538</td><td class="line"> <span class='keyword'>else</span> <span class='keyword'>if</span> (search && line[next] != ' ' && line[next] != '\t')</td></tr>
|
---|
618 | <tr><td class="num" id="LN539">539</td><td class="line"> search = <span class='keyword'>false</span>;</td></tr>
|
---|
619 | <tr><td class="num" id="LN540">540</td><td class="line"> }</td></tr>
|
---|
620 | <tr><td class="num" id="LN541">541</td><td class="line"> </td></tr>
|
---|
621 | <tr><td class="num" id="LN542">542</td><td class="line"> runs[index].offset = pos;</td></tr>
|
---|
622 | <tr><td class="num" id="LN543">543</td><td class="line"> runs[index].font = font;</td></tr>
|
---|
623 | <tr><td class="num" id="LN544">544</td><td class="line"> runs[index].color = level > 0</td></tr>
|
---|
624 | <tr><td class="num" id="LN545">545</td><td class="line"> ? kQuoteColors[level % kNumQuoteColors] : kNormalTextColor;</td></tr>
|
---|
625 | <tr><td class="num" id="LN546">546</td><td class="line"> </td></tr>
|
---|
626 | <tr><td class="num" id="LN547">547</td><td class="line"> pos = next;</td></tr>
|
---|
627 | <tr><td class="num" id="LN548">548</td><td class="line"> <span class='keyword'>if</span> (++index >= maxStyles)</td></tr>
|
---|
628 | <tr><td class="num" id="LN549">549</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
629 | <tr><td class="num" id="LN550">550</td><td class="line"> }</td></tr>
|
---|
630 | <tr><td class="num" id="LN551">551</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
631 | <tr><td class="num" id="LN552">552</td><td class="line"> <span class='keyword'>if</span> (begin) {</td></tr>
|
---|
632 | <tr><td class="num" id="LN553">553</td><td class="line"> <span class='keyword'>if</span> (!inDiff) {</td></tr>
|
---|
633 | <tr><td class="num" id="LN554">554</td><td class="line"> inDiff = !strncmp(&line[pos], <span class='string_literal'>"--- "</span>, 4);</td></tr>
|
---|
634 | <tr><td class="num" id="LN555">555</td><td class="line"> wasDiff = <span class='keyword'>false</span>;</td></tr>
|
---|
635 | <tr><td class="num" id="LN556">556</td><td class="line"> }</td></tr>
|
---|
636 | <tr><td class="num" id="LN557">557</td><td class="line"> <span class='keyword'>if</span> (inDiff) {</td></tr>
|
---|
637 | <tr><td class="num" id="LN558">558</td><td class="line"> diffMode = diff_mode(line[pos]);</td></tr>
|
---|
638 | <tr><td class="num" id="LN559">559</td><td class="line"> <span class='keyword'>if</span> (diffMode < 0) {</td></tr>
|
---|
639 | <tr><td class="num" id="LN560">560</td><td class="line"> inDiff = <span class='keyword'>false</span>;</td></tr>
|
---|
640 | <tr><td class="num" id="LN561">561</td><td class="line"> wasDiff = <span class='keyword'>true</span>;</td></tr>
|
---|
641 | <tr><td class="num" id="LN562">562</td><td class="line"> }</td></tr>
|
---|
642 | <tr><td class="num" id="LN563">563</td><td class="line"> }</td></tr>
|
---|
643 | <tr><td class="num" id="LN564">564</td><td class="line"> }</td></tr>
|
---|
644 | <tr><td class="num" id="LN565">565</td><td class="line"> </td></tr>
|
---|
645 | <tr><td class="num" id="LN566">566</td><td class="line"> runs[index].offset = pos;</td></tr>
|
---|
646 | <tr><td class="num" id="LN567">567</td><td class="line"> runs[index].font = font;</td></tr>
|
---|
647 | <tr><td class="num" id="LN568">568</td><td class="line"> <span class='keyword'>if</span> (wasDiff)</td></tr>
|
---|
648 | <tr><td class="num" id="LN569">569</td><td class="line"> runs[index].color = kDiffColors[diff_mode('@') - 1];</td></tr>
|
---|
649 | <tr><td class="num" id="LN570">570</td><td class="line"> <span class='keyword'>else</span> <span class='keyword'>if</span> (diffMode <= 0) {</td></tr>
|
---|
650 | <tr><td class="num" id="LN571">571</td><td class="line"> runs[index].color = level > 0</td></tr>
|
---|
651 | <tr><td class="num" id="LN572">572</td><td class="line"> ? kQuoteColors[level % kNumQuoteColors] : kNormalTextColor;</td></tr>
|
---|
652 | <tr><td class="num" id="LN573">573</td><td class="line"> } <span class='keyword'>else</span></td></tr>
|
---|
653 | <tr><td class="num" id="LN574">574</td><td class="line"> runs[index].color = kDiffColors[diffMode - 1];</td></tr>
|
---|
654 | <tr><td class="num" id="LN575">575</td><td class="line"> </td></tr>
|
---|
655 | <tr><td class="num" id="LN576">576</td><td class="line"> begin = <span class='keyword'>false</span>;</td></tr>
|
---|
656 | <tr><td class="num" id="LN577">577</td><td class="line"> </td></tr>
|
---|
657 | <tr><td class="num" id="LN578">578</td><td class="line"> <span class='keyword'>for</span> (next = pos; next < length; next++) {</td></tr>
|
---|
658 | <tr><td class="num" id="LN579">579</td><td class="line"> <span class='keyword'>if</span> (line[next] == '\n') {</td></tr>
|
---|
659 | <tr><td class="num" id="LN580">580</td><td class="line"> begin = <span class='keyword'>true</span>;</td></tr>
|
---|
660 | <tr><td class="num" id="LN581">581</td><td class="line"> wasDiff = <span class='keyword'>false</span>;</td></tr>
|
---|
661 | <tr><td class="num" id="LN582">582</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
662 | <tr><td class="num" id="LN583">583</td><td class="line"> }</td></tr>
|
---|
663 | <tr><td class="num" id="LN584">584</td><td class="line"> }</td></tr>
|
---|
664 | <tr><td class="num" id="LN585">585</td><td class="line"> </td></tr>
|
---|
665 | <tr><td class="num" id="LN586">586</td><td class="line"> pos = next;</td></tr>
|
---|
666 | <tr><td class="num" id="LN587">587</td><td class="line"> index++;</td></tr>
|
---|
667 | <tr><td class="num" id="LN588">588</td><td class="line"> }</td></tr>
|
---|
668 | <tr><td class="num" id="LN589">589</td><td class="line"> </td></tr>
|
---|
669 | <tr><td class="num" id="LN590">590</td><td class="line"> <span class='keyword'>if</span> (pos < length)</td></tr>
|
---|
670 | <tr><td class="num" id="LN591">591</td><td class="line"> begin = line[pos] == '\n';</td></tr>
|
---|
671 | <tr><td class="num" id="LN592">592</td><td class="line"> </td></tr>
|
---|
672 | <tr><td class="num" id="LN593">593</td><td class="line"> <span class='keyword'>if</span> (begin) {</td></tr>
|
---|
673 | <tr><td class="num" id="LN594">594</td><td class="line"> pos++;</td></tr>
|
---|
674 | <tr><td class="num" id="LN595">595</td><td class="line"> level = 0;</td></tr>
|
---|
675 | <tr><td class="num" id="LN596">596</td><td class="line"> wasDiff = <span class='keyword'>false</span>;</td></tr>
|
---|
676 | <tr><td class="num" id="LN597">597</td><td class="line"> </td></tr>
|
---|
677 | <tr><td class="num" id="LN598">598</td><td class="line"> <span class='comment'>// skip one leading space (tabs & newlines aren't allowed here)</span></td></tr>
|
---|
678 | <tr><td class="num" id="LN599">599</td><td class="line"> <span class='keyword'>if</span> (!inDiff && pos < length && line[pos] == ' ')</td></tr>
|
---|
679 | <tr><td class="num" id="LN600">600</td><td class="line"> pos++;</td></tr>
|
---|
680 | <tr><td class="num" id="LN601">601</td><td class="line"> }</td></tr>
|
---|
681 | <tr><td class="num" id="LN602">602</td><td class="line"> </td></tr>
|
---|
682 | <tr><td class="num" id="LN603">603</td><td class="line"> <span class='keyword'>if</span> (index >= maxStyles)</td></tr>
|
---|
683 | <tr><td class="num" id="LN604">604</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
684 | <tr><td class="num" id="LN605">605</td><td class="line"> }</td></tr>
|
---|
685 | <tr><td class="num" id="LN606">606</td><td class="line"> style->count = index;</td></tr>
|
---|
686 | <tr><td class="num" id="LN607">607</td><td class="line"> </td></tr>
|
---|
687 | <tr><td class="num" id="LN608">608</td><td class="line"> <span class='keyword'>if</span> (context) {</td></tr>
|
---|
688 | <tr><td class="num" id="LN609">609</td><td class="line"> <span class='comment'>// update context for next run</span></td></tr>
|
---|
689 | <tr><td class="num" id="LN610">610</td><td class="line"> context->level = level;</td></tr>
|
---|
690 | <tr><td class="num" id="LN611">611</td><td class="line"> context->diff_mode = diffMode;</td></tr>
|
---|
691 | <tr><td class="num" id="LN612">612</td><td class="line"> context->begin = begin;</td></tr>
|
---|
692 | <tr><td class="num" id="LN613">613</td><td class="line"> context->in_diff = inDiff;</td></tr>
|
---|
693 | <tr><td class="num" id="LN614">614</td><td class="line"> context->was_diff = wasDiff;</td></tr>
|
---|
694 | <tr><td class="num" id="LN615">615</td><td class="line"> }</td></tr>
|
---|
695 | <tr><td class="num" id="LN616">616</td><td class="line">}</td></tr>
|
---|
696 | <tr><td class="num" id="LN617">617</td><td class="line"> </td></tr>
|
---|
697 | <tr><td class="num" id="LN618">618</td><td class="line"> </td></tr>
|
---|
698 | <tr><td class="num" id="LN619">619</td><td class="line"><span class='comment'>// #pragma mark -</span></td></tr>
|
---|
699 | <tr><td class="num" id="LN620">620</td><td class="line"> </td></tr>
|
---|
700 | <tr><td class="num" id="LN621">621</td><td class="line"> </td></tr>
|
---|
701 | <tr><td class="num" id="LN622">622</td><td class="line">TextRunArray::TextRunArray(size_t entries)</td></tr>
|
---|
702 | <tr><td class="num" id="LN623">623</td><td class="line"> :</td></tr>
|
---|
703 | <tr><td class="num" id="LN624">624</td><td class="line"> fNumEntries(entries)</td></tr>
|
---|
704 | <tr><td class="num" id="LN625">625</td><td class="line">{</td></tr>
|
---|
705 | <tr><td class="num" id="LN626">626</td><td class="line"> fArray = (text_run_array *)malloc(<span class='keyword'>sizeof</span>(int32) + <span class='keyword'>sizeof</span>(text_run) * entries);</td></tr>
|
---|
706 | <tr><td class="num" id="LN627">627</td><td class="line"> <span class='keyword'>if</span> (fArray != <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
707 | <tr><td class="num" id="LN628">628</td><td class="line"> fArray->count = 0;</td></tr>
|
---|
708 | <tr><td class="num" id="LN629">629</td><td class="line">}</td></tr>
|
---|
709 | <tr><td class="num" id="LN630">630</td><td class="line"> </td></tr>
|
---|
710 | <tr><td class="num" id="LN631">631</td><td class="line"> </td></tr>
|
---|
711 | <tr><td class="num" id="LN632">632</td><td class="line">TextRunArray::~TextRunArray()</td></tr>
|
---|
712 | <tr><td class="num" id="LN633">633</td><td class="line">{</td></tr>
|
---|
713 | <tr><td class="num" id="LN634">634</td><td class="line"> free(fArray);</td></tr>
|
---|
714 | <tr><td class="num" id="LN635">635</td><td class="line">}</td></tr>
|
---|
715 | <tr><td class="num" id="LN636">636</td><td class="line"> </td></tr>
|
---|
716 | <tr><td class="num" id="LN637">637</td><td class="line"> </td></tr>
|
---|
717 | <tr><td class="num" id="LN638">638</td><td class="line"><span class='comment'>//====================================================================</span></td></tr>
|
---|
718 | <tr><td class="num" id="LN639">639</td><td class="line"><span class='comment'>// #pragma mark -</span></td></tr>
|
---|
719 | <tr><td class="num" id="LN640">640</td><td class="line"> </td></tr>
|
---|
720 | <tr><td class="num" id="LN641">641</td><td class="line"> </td></tr>
|
---|
721 | <tr><td class="num" id="LN642">642</td><td class="line">TContentView::TContentView(BRect rect, <span class='keyword'>bool</span> incoming, BFont* font,</td></tr>
|
---|
722 | <tr><td class="num" id="LN643">643</td><td class="line"> <span class='keyword'>bool</span> showHeader, <span class='keyword'>bool</span> coloredQuotes)</td></tr>
|
---|
723 | <tr><td class="num" id="LN644">644</td><td class="line"> :</td></tr>
|
---|
724 | <tr><td class="num" id="LN645">645</td><td class="line"> BView(rect, <span class='string_literal'>"m_content"</span>, <span class='macro'>B_FOLLOW_ALL<span class='expansion'>_rule_(_VIEW_TOP_, _VIEW_LEFT_, _VIEW_BOTTOM_, _VIEW_RIGHT_)</span></span>,</td></tr>
|
---|
725 | <tr><td class="num" id="LN646">646</td><td class="line"> B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),</td></tr>
|
---|
726 | <tr><td class="num" id="LN647">647</td><td class="line"> </td></tr>
|
---|
727 | <tr><td class="num" id="LN648">648</td><td class="line"> fFocus(<span class='keyword'>false</span>),</td></tr>
|
---|
728 | <tr><td class="num" id="LN649">649</td><td class="line"> fIncoming(incoming)</td></tr>
|
---|
729 | <tr><td class="num" id="LN650">650</td><td class="line">{</td></tr>
|
---|
730 | <tr><td class="num" id="LN651">651</td><td class="line"> SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));</td></tr>
|
---|
731 | <tr><td class="num" id="LN652">652</td><td class="line"> fOffset = 12;</td></tr>
|
---|
732 | <tr><td class="num" id="LN653">653</td><td class="line"> </td></tr>
|
---|
733 | <tr><td class="num" id="LN654">654</td><td class="line"> BRect r(rect);</td></tr>
|
---|
734 | <tr><td class="num" id="LN655">655</td><td class="line"> r.OffsetTo(0, 0);</td></tr>
|
---|
735 | <tr><td class="num" id="LN656">656</td><td class="line"> r.right -= <span class='macro'>B_V_SCROLL_BAR_WIDTH<span class='expansion'>14.0f</span></span>;</td></tr>
|
---|
736 | <tr><td class="num" id="LN657">657</td><td class="line"> r.bottom -= <span class='macro'>B_H_SCROLL_BAR_HEIGHT<span class='expansion'>14.0f</span></span>;</td></tr>
|
---|
737 | <tr><td class="num" id="LN658">658</td><td class="line"> r.top += 4;</td></tr>
|
---|
738 | <tr><td class="num" id="LN659">659</td><td class="line"> BRect text(r);</td></tr>
|
---|
739 | <tr><td class="num" id="LN660">660</td><td class="line"> text.OffsetTo(0, 0);</td></tr>
|
---|
740 | <tr><td class="num" id="LN661">661</td><td class="line"> text.InsetBy(5, 5);</td></tr>
|
---|
741 | <tr><td class="num" id="LN662">662</td><td class="line"> </td></tr>
|
---|
742 | <tr><td class="num" id="LN663">663</td><td class="line"> fTextView = <span class='keyword'>new</span> TTextView(r, text, fIncoming, <span class='keyword'>this</span>, font, showHeader,</td></tr>
|
---|
743 | <tr><td class="num" id="LN664">664</td><td class="line"> coloredQuotes);</td></tr>
|
---|
744 | <tr><td class="num" id="LN665">665</td><td class="line"> BScrollView *scroll = <span class='keyword'>new</span> BScrollView(<span class='string_literal'>""</span>, fTextView, <span class='macro'>B_FOLLOW_ALL<span class='expansion'>_rule_(_VIEW_TOP_, _VIEW_LEFT_, _VIEW_BOTTOM_, _VIEW_RIGHT_)</span></span>, 0, <span class='keyword'>true</span>, <span class='keyword'>true</span>);</td></tr>
|
---|
745 | <tr><td class="num" id="LN666">666</td><td class="line"> AddChild(scroll);</td></tr>
|
---|
746 | <tr><td class="num" id="LN667">667</td><td class="line">}</td></tr>
|
---|
747 | <tr><td class="num" id="LN668">668</td><td class="line"> </td></tr>
|
---|
748 | <tr><td class="num" id="LN669">669</td><td class="line"> </td></tr>
|
---|
749 | <tr><td class="num" id="LN670">670</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
750 | <tr><td class="num" id="LN671">671</td><td class="line">TContentView::MessageReceived(BMessage *msg)</td></tr>
|
---|
751 | <tr><td class="num" id="LN672">672</td><td class="line">{</td></tr>
|
---|
752 | <tr><td class="num" id="LN673">673</td><td class="line"> <span class='keyword'>switch</span> (msg->what) {</td></tr>
|
---|
753 | <tr><td class="num" id="LN674">674</td><td class="line"> <span class='keyword'>case</span> CHANGE_FONT:</td></tr>
|
---|
754 | <tr><td class="num" id="LN675">675</td><td class="line"> {</td></tr>
|
---|
755 | <tr><td class="num" id="LN676">676</td><td class="line"> BFont *font;</td></tr>
|
---|
756 | <tr><td class="num" id="LN677">677</td><td class="line"> msg->FindPointer(<span class='string_literal'>"font"</span>, (<span class='keyword'>void</span> **)&font);</td></tr>
|
---|
757 | <tr><td class="num" id="LN678">678</td><td class="line"> fTextView->UpdateFont(font);</td></tr>
|
---|
758 | <tr><td class="num" id="LN679">679</td><td class="line"> fTextView->Invalidate(Bounds());</td></tr>
|
---|
759 | <tr><td class="num" id="LN680">680</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
760 | <tr><td class="num" id="LN681">681</td><td class="line"> }</td></tr>
|
---|
761 | <tr><td class="num" id="LN682">682</td><td class="line"> </td></tr>
|
---|
762 | <tr><td class="num" id="LN683">683</td><td class="line"> <span class='keyword'>case</span> M_QUOTE:</td></tr>
|
---|
763 | <tr><td class="num" id="LN684">684</td><td class="line"> {</td></tr>
|
---|
764 | <tr><td class="num" id="LN685">685</td><td class="line"> int32 start, finish;</td></tr>
|
---|
765 | <tr><td class="num" id="LN686">686</td><td class="line"> fTextView->GetSelection(&start, &finish);</td></tr>
|
---|
766 | <tr><td class="num" id="LN687">687</td><td class="line"> fTextView->AddQuote(start, finish);</td></tr>
|
---|
767 | <tr><td class="num" id="LN688">688</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
768 | <tr><td class="num" id="LN689">689</td><td class="line"> }</td></tr>
|
---|
769 | <tr><td class="num" id="LN690">690</td><td class="line"> <span class='keyword'>case</span> M_REMOVE_QUOTE:</td></tr>
|
---|
770 | <tr><td class="num" id="LN691">691</td><td class="line"> {</td></tr>
|
---|
771 | <tr><td class="num" id="LN692">692</td><td class="line"> int32 start, finish;</td></tr>
|
---|
772 | <tr><td class="num" id="LN693">693</td><td class="line"> fTextView->GetSelection(&start, &finish);</td></tr>
|
---|
773 | <tr><td class="num" id="LN694">694</td><td class="line"> fTextView->RemoveQuote(start, finish);</td></tr>
|
---|
774 | <tr><td class="num" id="LN695">695</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
775 | <tr><td class="num" id="LN696">696</td><td class="line"> }</td></tr>
|
---|
776 | <tr><td class="num" id="LN697">697</td><td class="line"> </td></tr>
|
---|
777 | <tr><td class="num" id="LN698">698</td><td class="line"> <span class='keyword'>case</span> M_SIGNATURE:</td></tr>
|
---|
778 | <tr><td class="num" id="LN699">699</td><td class="line"> {</td></tr>
|
---|
779 | <tr><td class="num" id="LN700">700</td><td class="line"> <span class='keyword'>if</span> (fTextView->IsReaderThreadRunning()) {</td></tr>
|
---|
780 | <tr><td class="num" id="LN701">701</td><td class="line"> <span class='comment'>// Do not add the signature until the reader thread</span></td></tr>
|
---|
781 | <tr><td class="num" id="LN702">702</td><td class="line"> <span class='comment'>// is finished. Resubmit the message for later processing</span></td></tr>
|
---|
782 | <tr><td class="num" id="LN703">703</td><td class="line"> Window()->PostMessage(msg);</td></tr>
|
---|
783 | <tr><td class="num" id="LN704">704</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
784 | <tr><td class="num" id="LN705">705</td><td class="line"> }</td></tr>
|
---|
785 | <tr><td class="num" id="LN706">706</td><td class="line"> </td></tr>
|
---|
786 | <tr><td class="num" id="LN707">707</td><td class="line"> entry_ref ref;</td></tr>
|
---|
787 | <tr><td class="num" id="LN708">708</td><td class="line"> msg->FindRef(<span class='string_literal'>"ref"</span>, &ref);</td></tr>
|
---|
788 | <tr><td class="num" id="LN709">709</td><td class="line"> </td></tr>
|
---|
789 | <tr><td class="num" id="LN710">710</td><td class="line"> BFile file(&ref, <span class='macro'>B_READ_ONLY<span class='expansion'>0x0000</span></span>);</td></tr>
|
---|
790 | <tr><td class="num" id="LN711">711</td><td class="line"> <span class='keyword'>if</span> (file.InitCheck() == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
791 | <tr><td class="num" id="LN712">712</td><td class="line"> int32 start, finish;</td></tr>
|
---|
792 | <tr><td class="num" id="LN713">713</td><td class="line"> fTextView->GetSelection(&start, &finish);</td></tr>
|
---|
793 | <tr><td class="num" id="LN714">714</td><td class="line"> </td></tr>
|
---|
794 | <tr><td class="num" id="LN715">715</td><td class="line"> off_t size;</td></tr>
|
---|
795 | <tr><td class="num" id="LN716">716</td><td class="line"> file.GetSize(&size);</td></tr>
|
---|
796 | <tr><td class="num" id="LN717">717</td><td class="line"> <span class='keyword'>if</span> (size > 32768) <span class='comment'>// safety against corrupt signatures</span></td></tr>
|
---|
797 | <tr><td class="num" id="LN718">718</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
798 | <tr><td class="num" id="LN719">719</td><td class="line"> </td></tr>
|
---|
799 | <tr><td class="num" id="LN720">720</td><td class="line"> <span class='keyword'>char</span> *signature = (<span class='keyword'>char</span> *)malloc(size);</td></tr>
|
---|
800 | <tr><td class="num" id="LN721">721</td><td class="line"> <span class='keyword'>if</span> (signature == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
801 | <tr><td class="num" id="LN722">722</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
802 | <tr><td class="num" id="LN723">723</td><td class="line"> ssize_t bytesRead = file.Read(signature, size);</td></tr>
|
---|
803 | <tr><td class="num" id="LN724">724</td><td class="line"> <span class='keyword'>if</span> (bytesRead < <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
804 | <tr><td class="num" id="LN725">725</td><td class="line"> free (signature);</td></tr>
|
---|
805 | <tr><td class="num" id="LN726">726</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
806 | <tr><td class="num" id="LN727">727</td><td class="line"> }</td></tr>
|
---|
807 | <tr><td class="num" id="LN728">728</td><td class="line"> </td></tr>
|
---|
808 | <tr><td class="num" id="LN729">729</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = fTextView->Text();</td></tr>
|
---|
809 | <tr><td class="num" id="LN730">730</td><td class="line"> int32 length = fTextView->TextLength();</td></tr>
|
---|
810 | <tr><td class="num" id="LN731">731</td><td class="line"> </td></tr>
|
---|
811 | <tr><td class="num" id="LN732">732</td><td class="line"> <span class='comment'>// reserve some empty lines before the signature</span></td></tr>
|
---|
812 | <tr><td class="num" id="LN733">733</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span>* newLines = <span class='string_literal'>"\n\n\n\n"</span>;</td></tr>
|
---|
813 | <tr><td class="num" id="LN734">734</td><td class="line"> <span class='keyword'>if</span> (length && text[length - 1] == '\n')</td></tr>
|
---|
814 | <tr><td class="num" id="LN735">735</td><td class="line"> newLines++;</td></tr>
|
---|
815 | <tr><td class="num" id="LN736">736</td><td class="line"> </td></tr>
|
---|
816 | <tr><td class="num" id="LN737">737</td><td class="line"> fTextView->Select(length, length);</td></tr>
|
---|
817 | <tr><td class="num" id="LN738">738</td><td class="line"> fTextView->Insert(newLines, strlen(newLines));</td></tr>
|
---|
818 | <tr><td class="num" id="LN739">739</td><td class="line"> length += strlen(newLines);</td></tr>
|
---|
819 | <tr><td class="num" id="LN740">740</td><td class="line"> </td></tr>
|
---|
820 | <tr><td class="num" id="LN741">741</td><td class="line"> <span class='comment'>// append the signature</span></td></tr>
|
---|
821 | <tr><td class="num" id="LN742">742</td><td class="line"> fTextView->Select(length, length);</td></tr>
|
---|
822 | <tr><td class="num" id="LN743">743</td><td class="line"> fTextView->Insert(signature, bytesRead);</td></tr>
|
---|
823 | <tr><td class="num" id="LN744">744</td><td class="line"> fTextView->Select(length, length + bytesRead);</td></tr>
|
---|
824 | <tr><td class="num" id="LN745">745</td><td class="line"> fTextView->ScrollToSelection();</td></tr>
|
---|
825 | <tr><td class="num" id="LN746">746</td><td class="line"> </td></tr>
|
---|
826 | <tr><td class="num" id="LN747">747</td><td class="line"> <span class='comment'>// set the editing cursor position</span></td></tr>
|
---|
827 | <tr><td class="num" id="LN748">748</td><td class="line"> fTextView->Select(length - 2 , length - 2);</td></tr>
|
---|
828 | <tr><td class="num" id="LN749">749</td><td class="line"> fTextView->ScrollToSelection();</td></tr>
|
---|
829 | <tr><td class="num" id="LN750">750</td><td class="line"> free (signature);</td></tr>
|
---|
830 | <tr><td class="num" id="LN751">751</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
831 | <tr><td class="num" id="LN752">752</td><td class="line"> beep();</td></tr>
|
---|
832 | <tr><td class="num" id="LN753">753</td><td class="line"> BAlert* alert = <span class='keyword'>new</span> BAlert(<span class='string_literal'>""</span>,</td></tr>
|
---|
833 | <tr><td class="num" id="LN754">754</td><td class="line"> <span class='macro'>B_TRANSLATE(<span class='string_literal'>"An error occurred trying to open this "<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("An error occurred trying to open this "<br> "signature."), "Mail")</span></span></span></td></tr>
|
---|
834 | <tr><td class="num" id="LN755">755</td><td class="line"> <span class='string_literal'><span class='macro'>"signature."</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("An error occurred trying to open this "<br> "signature."), "Mail")</span></span>, <span class='macro'>B_TRANSLATE(<span class='string_literal'>"Sorry"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Sorry"<br>), "Mail")</span></span>);</td></tr>
|
---|
835 | <tr><td class="num" id="LN756">756</td><td class="line"> alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);</td></tr>
|
---|
836 | <tr><td class="num" id="LN757">757</td><td class="line"> alert->Go();</td></tr>
|
---|
837 | <tr><td class="num" id="LN758">758</td><td class="line"> }</td></tr>
|
---|
838 | <tr><td class="num" id="LN759">759</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
839 | <tr><td class="num" id="LN760">760</td><td class="line"> }</td></tr>
|
---|
840 | <tr><td class="num" id="LN761">761</td><td class="line"> </td></tr>
|
---|
841 | <tr><td class="num" id="LN762">762</td><td class="line"> <span class='keyword'>case</span> M_FIND:</td></tr>
|
---|
842 | <tr><td class="num" id="LN763">763</td><td class="line"> FindString(msg->FindString(<span class='string_literal'>"findthis"</span>));</td></tr>
|
---|
843 | <tr><td class="num" id="LN764">764</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
844 | <tr><td class="num" id="LN765">765</td><td class="line"> </td></tr>
|
---|
845 | <tr><td class="num" id="LN766">766</td><td class="line"> <span class='keyword'>default</span>:</td></tr>
|
---|
846 | <tr><td class="num" id="LN767">767</td><td class="line"> BView::MessageReceived(msg);</td></tr>
|
---|
847 | <tr><td class="num" id="LN768">768</td><td class="line"> }</td></tr>
|
---|
848 | <tr><td class="num" id="LN769">769</td><td class="line">}</td></tr>
|
---|
849 | <tr><td class="num" id="LN770">770</td><td class="line"> </td></tr>
|
---|
850 | <tr><td class="num" id="LN771">771</td><td class="line"> </td></tr>
|
---|
851 | <tr><td class="num" id="LN772">772</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
852 | <tr><td class="num" id="LN773">773</td><td class="line">TContentView::FindString(<span class='keyword'>const</span> <span class='keyword'>char</span> *str)</td></tr>
|
---|
853 | <tr><td class="num" id="LN774">774</td><td class="line">{</td></tr>
|
---|
854 | <tr><td class="num" id="LN775">775</td><td class="line"> int32 finish;</td></tr>
|
---|
855 | <tr><td class="num" id="LN776">776</td><td class="line"> int32 pass = 0;</td></tr>
|
---|
856 | <tr><td class="num" id="LN777">777</td><td class="line"> int32 start = 0;</td></tr>
|
---|
857 | <tr><td class="num" id="LN778">778</td><td class="line"> </td></tr>
|
---|
858 | <tr><td class="num" id="LN779">779</td><td class="line"> <span class='keyword'>if</span> (str == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
859 | <tr><td class="num" id="LN780">780</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
860 | <tr><td class="num" id="LN781">781</td><td class="line"> </td></tr>
|
---|
861 | <tr><td class="num" id="LN782">782</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
862 | <tr><td class="num" id="LN783">783</td><td class="line"> <span class='comment'>// Start from current selection or from the beginning of the pool</span></td></tr>
|
---|
863 | <tr><td class="num" id="LN784">784</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
864 | <tr><td class="num" id="LN785">785</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = fTextView->Text();</td></tr>
|
---|
865 | <tr><td class="num" id="LN786">786</td><td class="line"> int32 count = fTextView->TextLength();</td></tr>
|
---|
866 | <tr><td class="num" id="LN787">787</td><td class="line"> fTextView->GetSelection(&start, &finish);</td></tr>
|
---|
867 | <tr><td class="num" id="LN788">788</td><td class="line"> <span class='keyword'>if</span> (start != finish)</td></tr>
|
---|
868 | <tr><td class="num" id="LN789">789</td><td class="line"> start = finish;</td></tr>
|
---|
869 | <tr><td class="num" id="LN790">790</td><td class="line"> <span class='keyword'>if</span> (!count || text == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
870 | <tr><td class="num" id="LN791">791</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
871 | <tr><td class="num" id="LN792">792</td><td class="line"> </td></tr>
|
---|
872 | <tr><td class="num" id="LN793">793</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
873 | <tr><td class="num" id="LN794">794</td><td class="line"> <span class='comment'>// Do the find</span></td></tr>
|
---|
874 | <tr><td class="num" id="LN795">795</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
875 | <tr><td class="num" id="LN796">796</td><td class="line"> <span class='keyword'>while</span> (pass < 2) {</td></tr>
|
---|
876 | <tr><td class="num" id="LN797">797</td><td class="line"> <span class='keyword'>long</span> found = -1;</td></tr>
|
---|
877 | <tr><td class="num" id="LN798">798</td><td class="line"> <span class='keyword'>char</span> lc = <span class='macro'>tolower(str[0])<span class='expansion'>((int)__ctype_tolower[(int)(str[0])])</span></span>;</td></tr>
|
---|
878 | <tr><td class="num" id="LN799">799</td><td class="line"> <span class='keyword'>char</span> uc = <span class='macro'>toupper(str[0])<span class='expansion'>((int)__ctype_toupper[(int)(str[0])])</span></span>;</td></tr>
|
---|
879 | <tr><td class="num" id="LN800">800</td><td class="line"> <span class='keyword'>for</span> (<span class='keyword'>long</span> i = start; i < count; i++) {</td></tr>
|
---|
880 | <tr><td class="num" id="LN801">801</td><td class="line"> <span class='keyword'>if</span> (text[i] == lc || text[i] == uc) {</td></tr>
|
---|
881 | <tr><td class="num" id="LN802">802</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *s = str;</td></tr>
|
---|
882 | <tr><td class="num" id="LN803">803</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *t = text + i;</td></tr>
|
---|
883 | <tr><td class="num" id="LN804">804</td><td class="line"> <span class='keyword'>while</span> (*s && (<span class='macro'>tolower(*s)<span class='expansion'>((int)__ctype_tolower[(int)(*s)])</span></span> == <span class='macro'>tolower(*t)<span class='expansion'>((int)__ctype_tolower[(int)(*t)])</span></span>)) {</td></tr>
|
---|
884 | <tr><td class="num" id="LN805">805</td><td class="line"> s++;</td></tr>
|
---|
885 | <tr><td class="num" id="LN806">806</td><td class="line"> t++;</td></tr>
|
---|
886 | <tr><td class="num" id="LN807">807</td><td class="line"> }</td></tr>
|
---|
887 | <tr><td class="num" id="LN808">808</td><td class="line"> <span class='keyword'>if</span> (*s == 0) {</td></tr>
|
---|
888 | <tr><td class="num" id="LN809">809</td><td class="line"> found = i;</td></tr>
|
---|
889 | <tr><td class="num" id="LN810">810</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
890 | <tr><td class="num" id="LN811">811</td><td class="line"> }</td></tr>
|
---|
891 | <tr><td class="num" id="LN812">812</td><td class="line"> }</td></tr>
|
---|
892 | <tr><td class="num" id="LN813">813</td><td class="line"> }</td></tr>
|
---|
893 | <tr><td class="num" id="LN814">814</td><td class="line"> </td></tr>
|
---|
894 | <tr><td class="num" id="LN815">815</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
895 | <tr><td class="num" id="LN816">816</td><td class="line"> <span class='comment'>// Select the text if it worked</span></td></tr>
|
---|
896 | <tr><td class="num" id="LN817">817</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
897 | <tr><td class="num" id="LN818">818</td><td class="line"> <span class='keyword'>if</span> (found != -1) {</td></tr>
|
---|
898 | <tr><td class="num" id="LN819">819</td><td class="line"> Window()->Activate();</td></tr>
|
---|
899 | <tr><td class="num" id="LN820">820</td><td class="line"> fTextView->Select(found, found + strlen(str));</td></tr>
|
---|
900 | <tr><td class="num" id="LN821">821</td><td class="line"> fTextView->ScrollToSelection();</td></tr>
|
---|
901 | <tr><td class="num" id="LN822">822</td><td class="line"> fTextView->MakeFocus(<span class='keyword'>true</span>);</td></tr>
|
---|
902 | <tr><td class="num" id="LN823">823</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
903 | <tr><td class="num" id="LN824">824</td><td class="line"> }</td></tr>
|
---|
904 | <tr><td class="num" id="LN825">825</td><td class="line"> <span class='keyword'>else</span> <span class='keyword'>if</span> (start) {</td></tr>
|
---|
905 | <tr><td class="num" id="LN826">826</td><td class="line"> start = 0;</td></tr>
|
---|
906 | <tr><td class="num" id="LN827">827</td><td class="line"> text = fTextView->Text();</td></tr>
|
---|
907 | <tr><td class="num" id="LN828">828</td><td class="line"> count = fTextView->TextLength();</td></tr>
|
---|
908 | <tr><td class="num" id="LN829">829</td><td class="line"> pass++;</td></tr>
|
---|
909 | <tr><td class="num" id="LN830">830</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
910 | <tr><td class="num" id="LN831">831</td><td class="line"> beep();</td></tr>
|
---|
911 | <tr><td class="num" id="LN832">832</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
912 | <tr><td class="num" id="LN833">833</td><td class="line"> }</td></tr>
|
---|
913 | <tr><td class="num" id="LN834">834</td><td class="line"> }</td></tr>
|
---|
914 | <tr><td class="num" id="LN835">835</td><td class="line">}</td></tr>
|
---|
915 | <tr><td class="num" id="LN836">836</td><td class="line"> </td></tr>
|
---|
916 | <tr><td class="num" id="LN837">837</td><td class="line"> </td></tr>
|
---|
917 | <tr><td class="num" id="LN838">838</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
918 | <tr><td class="num" id="LN839">839</td><td class="line">TContentView::Focus(<span class='keyword'>bool</span> focus)</td></tr>
|
---|
919 | <tr><td class="num" id="LN840">840</td><td class="line">{</td></tr>
|
---|
920 | <tr><td class="num" id="LN841">841</td><td class="line"> <span class='keyword'>if</span> (fFocus != focus) {</td></tr>
|
---|
921 | <tr><td class="num" id="LN842">842</td><td class="line"> fFocus = focus;</td></tr>
|
---|
922 | <tr><td class="num" id="LN843">843</td><td class="line"> Draw(Frame());</td></tr>
|
---|
923 | <tr><td class="num" id="LN844">844</td><td class="line"> }</td></tr>
|
---|
924 | <tr><td class="num" id="LN845">845</td><td class="line">}</td></tr>
|
---|
925 | <tr><td class="num" id="LN846">846</td><td class="line"> </td></tr>
|
---|
926 | <tr><td class="num" id="LN847">847</td><td class="line"> </td></tr>
|
---|
927 | <tr><td class="num" id="LN848">848</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
928 | <tr><td class="num" id="LN849">849</td><td class="line">TContentView::FrameResized(<span class='keyword'>float</span> <span class='comment'>/* width */</span>, <span class='keyword'>float</span> <span class='comment'>/* height */</span>)</td></tr>
|
---|
929 | <tr><td class="num" id="LN850">850</td><td class="line">{</td></tr>
|
---|
930 | <tr><td class="num" id="LN851">851</td><td class="line"> BRect r(fTextView->Bounds());</td></tr>
|
---|
931 | <tr><td class="num" id="LN852">852</td><td class="line"> r.OffsetTo(0, 0);</td></tr>
|
---|
932 | <tr><td class="num" id="LN853">853</td><td class="line"> r.InsetBy(5, 5);</td></tr>
|
---|
933 | <tr><td class="num" id="LN854">854</td><td class="line"> fTextView->SetTextRect(r);</td></tr>
|
---|
934 | <tr><td class="num" id="LN855">855</td><td class="line">}</td></tr>
|
---|
935 | <tr><td class="num" id="LN856">856</td><td class="line"> </td></tr>
|
---|
936 | <tr><td class="num" id="LN857">857</td><td class="line"> </td></tr>
|
---|
937 | <tr><td class="num" id="LN858">858</td><td class="line"><span class='comment'>//====================================================================</span></td></tr>
|
---|
938 | <tr><td class="num" id="LN859">859</td><td class="line"><span class='comment'>// #pragma mark -</span></td></tr>
|
---|
939 | <tr><td class="num" id="LN860">860</td><td class="line"> </td></tr>
|
---|
940 | <tr><td class="num" id="LN861">861</td><td class="line"> </td></tr>
|
---|
941 | <tr><td class="num" id="LN862">862</td><td class="line">TTextView::TTextView(BRect frame, BRect text, <span class='keyword'>bool</span> incoming, TContentView *view,</td></tr>
|
---|
942 | <tr><td class="num" id="LN863">863</td><td class="line"> BFont *font, <span class='keyword'>bool</span> showHeader, <span class='keyword'>bool</span> coloredQuotes)</td></tr>
|
---|
943 | <tr><td class="num" id="LN864">864</td><td class="line"> :</td></tr>
|
---|
944 | <tr><td class="num" id="LN865">865</td><td class="line"> BTextView(frame, <span class='string_literal'>""</span>, text, <span class='macro'>B_FOLLOW_ALL<span class='expansion'>_rule_(_VIEW_TOP_, _VIEW_LEFT_, _VIEW_BOTTOM_, _VIEW_RIGHT_)</span></span>, B_WILL_DRAW | B_NAVIGABLE),</td></tr>
|
---|
945 | <tr><td class="num" id="LN866">866</td><td class="line"> </td></tr>
|
---|
946 | <tr><td class="num" id="LN867">867</td><td class="line"> fHeader(showHeader),</td></tr>
|
---|
947 | <tr><td class="num" id="LN868">868</td><td class="line"> fColoredQuotes(coloredQuotes),</td></tr>
|
---|
948 | <tr><td class="num" id="LN869">869</td><td class="line"> fReady(<span class='keyword'>false</span>),</td></tr>
|
---|
949 | <tr><td class="num" id="LN870">870</td><td class="line"> fYankBuffer(<span class='macro'>NULL<span class='expansion'>__null</span></span>),</td></tr>
|
---|
950 | <tr><td class="num" id="LN871">871</td><td class="line"> fLastPosition(-1),</td></tr>
|
---|
951 | <tr><td class="num" id="LN872">872</td><td class="line"> fMail(<span class='macro'>NULL<span class='expansion'>__null</span></span>),</td></tr>
|
---|
952 | <tr><td class="num" id="LN873">873</td><td class="line"> fFont(font),</td></tr>
|
---|
953 | <tr><td class="num" id="LN874">874</td><td class="line"> fParent(view),</td></tr>
|
---|
954 | <tr><td class="num" id="LN875">875</td><td class="line"> fStopLoading(<span class='keyword'>false</span>),</td></tr>
|
---|
955 | <tr><td class="num" id="LN876">876</td><td class="line"> fThread(0),</td></tr>
|
---|
956 | <tr><td class="num" id="LN877">877</td><td class="line"> fPanel(<span class='macro'>NULL<span class='expansion'>__null</span></span>),</td></tr>
|
---|
957 | <tr><td class="num" id="LN878">878</td><td class="line"> fIncoming(incoming),</td></tr>
|
---|
958 | <tr><td class="num" id="LN879">879</td><td class="line"> fSpellCheck(<span class='keyword'>false</span>),</td></tr>
|
---|
959 | <tr><td class="num" id="LN880">880</td><td class="line"> fRaw(<span class='keyword'>false</span>),</td></tr>
|
---|
960 | <tr><td class="num" id="LN881">881</td><td class="line"> fCursor(<span class='keyword'>false</span>),</td></tr>
|
---|
961 | <tr><td class="num" id="LN882">882</td><td class="line"> fFirstSpellMark(<span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
962 | <tr><td class="num" id="LN883">883</td><td class="line">{</td></tr>
|
---|
963 | <tr><td class="num" id="LN884">884</td><td class="line"> fStopSem = create_sem(1, <span class='string_literal'>"reader_sem"</span>);</td></tr>
|
---|
964 | <tr><td class="num" id="LN885">885</td><td class="line"> SetStylable(<span class='keyword'>true</span>);</td></tr>
|
---|
965 | <tr><td class="num" id="LN886">886</td><td class="line"> </td></tr>
|
---|
966 | <tr><td class="num" id="LN887">887</td><td class="line"> fEnclosures = <span class='keyword'>new</span> BList();</td></tr>
|
---|
967 | <tr><td class="num" id="LN888">888</td><td class="line"> </td></tr>
|
---|
968 | <tr><td class="num" id="LN889">889</td><td class="line"> <span class='comment'>// Enclosure pop up menu</span></td></tr>
|
---|
969 | <tr><td class="num" id="LN890">890</td><td class="line"> fEnclosureMenu = <span class='keyword'>new</span> BPopUpMenu(<span class='string_literal'>"Enclosure"</span>, <span class='keyword'>false</span>, <span class='keyword'>false</span>);</td></tr>
|
---|
970 | <tr><td class="num" id="LN891">891</td><td class="line"> fEnclosureMenu->SetFont(be_plain_font);</td></tr>
|
---|
971 | <tr><td class="num" id="LN892">892</td><td class="line"> fEnclosureMenu->AddItem(<span class='keyword'>new</span> BMenuItem(</td></tr>
|
---|
972 | <tr><td class="num" id="LN893">893</td><td class="line"> <span class='macro'>B_TRANSLATE(<span class='string_literal'>"Save attachment"</span> B_UTF8_ELLIPSIS)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Save attachment"<br> "\xE2\x80\xA6"), "Mail")</span></span>, <span class='keyword'>new</span> BMessage(M_SAVE)));</td></tr>
|
---|
973 | <tr><td class="num" id="LN894">894</td><td class="line"> fEnclosureMenu->AddItem(<span class='keyword'>new</span> BMenuItem(<span class='macro'>B_TRANSLATE(<span class='string_literal'>"Open attachment"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Open attachment"<br>), "Mail")</span></span>,</td></tr>
|
---|
974 | <tr><td class="num" id="LN895">895</td><td class="line"> <span class='keyword'>new</span> BMessage(M_OPEN)));</td></tr>
|
---|
975 | <tr><td class="num" id="LN896">896</td><td class="line"> </td></tr>
|
---|
976 | <tr><td class="num" id="LN897">897</td><td class="line"> <span class='comment'>// Hyperlink pop up menu</span></td></tr>
|
---|
977 | <tr><td class="num" id="LN898">898</td><td class="line"> fLinkMenu = <span class='keyword'>new</span> BPopUpMenu(<span class='string_literal'>"Link"</span>, <span class='keyword'>false</span>, <span class='keyword'>false</span>);</td></tr>
|
---|
978 | <tr><td class="num" id="LN899">899</td><td class="line"> fLinkMenu->SetFont(be_plain_font);</td></tr>
|
---|
979 | <tr><td class="num" id="LN900">900</td><td class="line"> fLinkMenu->AddItem(<span class='keyword'>new</span> BMenuItem(<span class='macro'>B_TRANSLATE(<span class='string_literal'>"Open this link"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Open this link"<br>), "Mail")</span></span>,</td></tr>
|
---|
980 | <tr><td class="num" id="LN901">901</td><td class="line"> <span class='keyword'>new</span> BMessage(M_OPEN)));</td></tr>
|
---|
981 | <tr><td class="num" id="LN902">902</td><td class="line"> fLinkMenu->AddItem(<span class='keyword'>new</span> BMenuItem(<span class='macro'>B_TRANSLATE(<span class='string_literal'>"Copy link location"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Copy link location"<br>), "Mail")</span></span>,</td></tr>
|
---|
982 | <tr><td class="num" id="LN903">903</td><td class="line"> <span class='keyword'>new</span> BMessage(M_COPY)));</td></tr>
|
---|
983 | <tr><td class="num" id="LN904">904</td><td class="line"> </td></tr>
|
---|
984 | <tr><td class="num" id="LN905">905</td><td class="line"> SetDoesUndo(<span class='keyword'>true</span>);</td></tr>
|
---|
985 | <tr><td class="num" id="LN906">906</td><td class="line"> </td></tr>
|
---|
986 | <tr><td class="num" id="LN907">907</td><td class="line"> <span class='comment'>//Undo function</span></td></tr>
|
---|
987 | <tr><td class="num" id="LN908">908</td><td class="line"> fUndoBuffer.On();</td></tr>
|
---|
988 | <tr><td class="num" id="LN909">909</td><td class="line"> fInputMethodUndoBuffer.On();</td></tr>
|
---|
989 | <tr><td class="num" id="LN910">910</td><td class="line"> fUndoState.replaced = <span class='keyword'>false</span>;</td></tr>
|
---|
990 | <tr><td class="num" id="LN911">911</td><td class="line"> fUndoState.deleted = <span class='keyword'>false</span>;</td></tr>
|
---|
991 | <tr><td class="num" id="LN912">912</td><td class="line"> fInputMethodUndoState.active = <span class='keyword'>false</span>;</td></tr>
|
---|
992 | <tr><td class="num" id="LN913">913</td><td class="line"> fInputMethodUndoState.replace = <span class='keyword'>false</span>;</td></tr>
|
---|
993 | <tr><td class="num" id="LN914">914</td><td class="line">}</td></tr>
|
---|
994 | <tr><td class="num" id="LN915">915</td><td class="line"> </td></tr>
|
---|
995 | <tr><td class="num" id="LN916">916</td><td class="line"> </td></tr>
|
---|
996 | <tr><td class="num" id="LN917">917</td><td class="line">TTextView::~TTextView()</td></tr>
|
---|
997 | <tr><td class="num" id="LN918">918</td><td class="line">{</td></tr>
|
---|
998 | <tr><td class="num" id="LN919">919</td><td class="line"> ClearList();</td></tr>
|
---|
999 | <tr><td class="num" id="LN920">920</td><td class="line"> <span class='keyword'>delete</span> fPanel;</td></tr>
|
---|
1000 | <tr><td class="num" id="LN921">921</td><td class="line"> </td></tr>
|
---|
1001 | <tr><td class="num" id="LN922">922</td><td class="line"> <span class='keyword'>if</span> (fYankBuffer)</td></tr>
|
---|
1002 | <tr><td class="num" id="LN923">923</td><td class="line"> free(fYankBuffer);</td></tr>
|
---|
1003 | <tr><td class="num" id="LN924">924</td><td class="line"> </td></tr>
|
---|
1004 | <tr><td class="num" id="LN925">925</td><td class="line"> delete_sem(fStopSem);</td></tr>
|
---|
1005 | <tr><td class="num" id="LN926">926</td><td class="line">}</td></tr>
|
---|
1006 | <tr><td class="num" id="LN927">927</td><td class="line"> </td></tr>
|
---|
1007 | <tr><td class="num" id="LN928">928</td><td class="line"> </td></tr>
|
---|
1008 | <tr><td class="num" id="LN929">929</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1009 | <tr><td class="num" id="LN930">930</td><td class="line">TTextView::UpdateFont(<span class='keyword'>const</span> BFont* newFont)</td></tr>
|
---|
1010 | <tr><td class="num" id="LN931">931</td><td class="line">{</td></tr>
|
---|
1011 | <tr><td class="num" id="LN932">932</td><td class="line"> fFont = *newFont;</td></tr>
|
---|
1012 | <tr><td class="num" id="LN933">933</td><td class="line"> </td></tr>
|
---|
1013 | <tr><td class="num" id="LN934">934</td><td class="line"> <span class='comment'>// update the text run array safely with new font</span></td></tr>
|
---|
1014 | <tr><td class="num" id="LN935">935</td><td class="line"> text_run_array *runArray = RunArray(0, <span class='macro'>INT32_MAX<span class='expansion'>(2147483647)</span></span>);</td></tr>
|
---|
1015 | <tr><td class="num" id="LN936">936</td><td class="line"> <span class='keyword'>for</span> (<span class='keyword'>int</span> i = 0; i < runArray->count; i++)</td></tr>
|
---|
1016 | <tr><td class="num" id="LN937">937</td><td class="line"> runArray->runs[i].font = *newFont;</td></tr>
|
---|
1017 | <tr><td class="num" id="LN938">938</td><td class="line"> </td></tr>
|
---|
1018 | <tr><td class="num" id="LN939">939</td><td class="line"> SetRunArray(0, <span class='macro'>INT32_MAX<span class='expansion'>(2147483647)</span></span>, runArray);</td></tr>
|
---|
1019 | <tr><td class="num" id="LN940">940</td><td class="line"> FreeRunArray(runArray);</td></tr>
|
---|
1020 | <tr><td class="num" id="LN941">941</td><td class="line">}</td></tr>
|
---|
1021 | <tr><td class="num" id="LN942">942</td><td class="line"> </td></tr>
|
---|
1022 | <tr><td class="num" id="LN943">943</td><td class="line"> </td></tr>
|
---|
1023 | <tr><td class="num" id="LN944">944</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1024 | <tr><td class="num" id="LN945">945</td><td class="line">TTextView::AttachedToWindow()</td></tr>
|
---|
1025 | <tr><td class="num" id="LN946">946</td><td class="line">{</td></tr>
|
---|
1026 | <tr><td class="num" id="LN947">947</td><td class="line"> BTextView::AttachedToWindow();</td></tr>
|
---|
1027 | <tr><td class="num" id="LN948">948</td><td class="line"> fFont.SetSpacing(B_FIXED_SPACING);</td></tr>
|
---|
1028 | <tr><td class="num" id="LN949">949</td><td class="line"> SetFontAndColor(&fFont);</td></tr>
|
---|
1029 | <tr><td class="num" id="LN950">950</td><td class="line"> </td></tr>
|
---|
1030 | <tr><td class="num" id="LN951">951</td><td class="line"> <span class='keyword'>if</span> (fMail != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
1031 | <tr><td class="num" id="LN952">952</td><td class="line"> LoadMessage(fMail, <span class='keyword'>false</span>, <span class='macro'>NULL<span class='expansion'>__null</span></span>);</td></tr>
|
---|
1032 | <tr><td class="num" id="LN953">953</td><td class="line"> <span class='keyword'>if</span> (fIncoming)</td></tr>
|
---|
1033 | <tr><td class="num" id="LN954">954</td><td class="line"> MakeEditable(<span class='keyword'>false</span>);</td></tr>
|
---|
1034 | <tr><td class="num" id="LN955">955</td><td class="line"> }</td></tr>
|
---|
1035 | <tr><td class="num" id="LN956">956</td><td class="line">}</td></tr>
|
---|
1036 | <tr><td class="num" id="LN957">957</td><td class="line"> </td></tr>
|
---|
1037 | <tr><td class="num" id="LN958">958</td><td class="line"> </td></tr>
|
---|
1038 | <tr><td class="num" id="LN959">959</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1039 | <tr><td class="num" id="LN960">960</td><td class="line">TTextView::KeyDown(<span class='keyword'>const</span> <span class='keyword'>char</span> *key, int32 count)</td></tr>
|
---|
1040 | <tr><td class="num" id="LN961">961</td><td class="line">{</td></tr>
|
---|
1041 | <tr><td class="num" id="LN962">962</td><td class="line"> <span class='keyword'>char</span> raw;</td></tr>
|
---|
1042 | <tr><td class="num" id="LN963">963</td><td class="line"> int32 end;</td></tr>
|
---|
1043 | <tr><td class="num" id="LN964">964</td><td class="line"> int32 start;</td></tr>
|
---|
1044 | <tr><td class="num" id="LN965">965</td><td class="line"> uint32 mods;</td></tr>
|
---|
1045 | <tr><td class="num" id="LN966">966</td><td class="line"> BMessage *msg;</td></tr>
|
---|
1046 | <tr><td class="num" id="LN967">967</td><td class="line"> int32 textLen = TextLength();</td></tr>
|
---|
1047 | <tr><td class="num" id="LN968">968</td><td class="line"> </td></tr>
|
---|
1048 | <tr><td class="num" id="LN969">969</td><td class="line"> msg = Window()->CurrentMessage();</td></tr>
|
---|
1049 | <tr><td class="num" id="LN970">970</td><td class="line"> mods = msg->FindInt32(<span class='string_literal'>"modifiers"</span>);</td></tr>
|
---|
1050 | <tr><td class="num" id="LN971">971</td><td class="line"> </td></tr>
|
---|
1051 | <tr><td class="num" id="LN972">972</td><td class="line"> <span class='keyword'>switch</span> (key[0]) {</td></tr>
|
---|
1052 | <tr><td class="num" id="LN973">973</td><td class="line"> <span class='keyword'>case</span> B_HOME:</td></tr>
|
---|
1053 | <tr><td class="num" id="LN974">974</td><td class="line"> <span class='keyword'>if</span> (IsSelectable()) {</td></tr>
|
---|
1054 | <tr><td class="num" id="LN975">975</td><td class="line"> <span class='keyword'>if</span> (IsEditable())</td></tr>
|
---|
1055 | <tr><td class="num" id="LN976">976</td><td class="line"> BTextView::KeyDown(key, count);</td></tr>
|
---|
1056 | <tr><td class="num" id="LN977">977</td><td class="line"> <span class='keyword'>else</span> {</td></tr>
|
---|
1057 | <tr><td class="num" id="LN978">978</td><td class="line"> <span class='comment'>// scroll to the beginning</span></td></tr>
|
---|
1058 | <tr><td class="num" id="LN979">979</td><td class="line"> Select(0, 0);</td></tr>
|
---|
1059 | <tr><td class="num" id="LN980">980</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
1060 | <tr><td class="num" id="LN981">981</td><td class="line"> }</td></tr>
|
---|
1061 | <tr><td class="num" id="LN982">982</td><td class="line"> }</td></tr>
|
---|
1062 | <tr><td class="num" id="LN983">983</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1063 | <tr><td class="num" id="LN984">984</td><td class="line"> </td></tr>
|
---|
1064 | <tr><td class="num" id="LN985">985</td><td class="line"> <span class='keyword'>case</span> B_END:</td></tr>
|
---|
1065 | <tr><td class="num" id="LN986">986</td><td class="line"> <span class='keyword'>if</span> (IsSelectable()) {</td></tr>
|
---|
1066 | <tr><td class="num" id="LN987">987</td><td class="line"> <span class='keyword'>if</span> (IsEditable())</td></tr>
|
---|
1067 | <tr><td class="num" id="LN988">988</td><td class="line"> BTextView::KeyDown(key, count);</td></tr>
|
---|
1068 | <tr><td class="num" id="LN989">989</td><td class="line"> <span class='keyword'>else</span> {</td></tr>
|
---|
1069 | <tr><td class="num" id="LN990">990</td><td class="line"> <span class='comment'>// scroll to the end</span></td></tr>
|
---|
1070 | <tr><td class="num" id="LN991">991</td><td class="line"> int32 length = TextLength();</td></tr>
|
---|
1071 | <tr><td class="num" id="LN992">992</td><td class="line"> Select(length, length);</td></tr>
|
---|
1072 | <tr><td class="num" id="LN993">993</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
1073 | <tr><td class="num" id="LN994">994</td><td class="line"> }</td></tr>
|
---|
1074 | <tr><td class="num" id="LN995">995</td><td class="line"> }</td></tr>
|
---|
1075 | <tr><td class="num" id="LN996">996</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1076 | <tr><td class="num" id="LN997">997</td><td class="line"> </td></tr>
|
---|
1077 | <tr><td class="num" id="LN998">998</td><td class="line"> <span class='keyword'>case</span> 0x02: <span class='comment'>// ^b - back 1 char</span></td></tr>
|
---|
1078 | <tr><td class="num" id="LN999">999</td><td class="line"> <span class='keyword'>if</span> (IsSelectable()) {</td></tr>
|
---|
1079 | <tr><td class="num" id="LN1000">1000</td><td class="line"> GetSelection(&start, &end);</td></tr>
|
---|
1080 | <tr><td class="num" id="LN1001">1001</td><td class="line"> <span class='keyword'>while</span> (!IsInitialUTF8Byte(ByteAt(--start))) {</td></tr>
|
---|
1081 | <tr><td class="num" id="LN1002">1002</td><td class="line"> <span class='keyword'>if</span> (start < 0) {</td></tr>
|
---|
1082 | <tr><td class="num" id="LN1003">1003</td><td class="line"> start = 0;</td></tr>
|
---|
1083 | <tr><td class="num" id="LN1004">1004</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1084 | <tr><td class="num" id="LN1005">1005</td><td class="line"> }</td></tr>
|
---|
1085 | <tr><td class="num" id="LN1006">1006</td><td class="line"> }</td></tr>
|
---|
1086 | <tr><td class="num" id="LN1007">1007</td><td class="line"> <span class='keyword'>if</span> (start >= 0) {</td></tr>
|
---|
1087 | <tr><td class="num" id="LN1008">1008</td><td class="line"> Select(start, start);</td></tr>
|
---|
1088 | <tr><td class="num" id="LN1009">1009</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
1089 | <tr><td class="num" id="LN1010">1010</td><td class="line"> }</td></tr>
|
---|
1090 | <tr><td class="num" id="LN1011">1011</td><td class="line"> }</td></tr>
|
---|
1091 | <tr><td class="num" id="LN1012">1012</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1092 | <tr><td class="num" id="LN1013">1013</td><td class="line"> </td></tr>
|
---|
1093 | <tr><td class="num" id="LN1014">1014</td><td class="line"> <span class='keyword'>case</span> B_DELETE:</td></tr>
|
---|
1094 | <tr><td class="num" id="LN1015">1015</td><td class="line"> <span class='keyword'>if</span> (IsSelectable()) {</td></tr>
|
---|
1095 | <tr><td class="num" id="LN1016">1016</td><td class="line"> <span class='keyword'>if</span> ((key[0] == B_DELETE) || (mods & B_CONTROL_KEY)) {</td></tr>
|
---|
1096 | <tr><td class="num" id="LN1017">1017</td><td class="line"> <span class='comment'>// ^d</span></td></tr>
|
---|
1097 | <tr><td class="num" id="LN1018">1018</td><td class="line"> <span class='keyword'>if</span> (IsEditable()) {</td></tr>
|
---|
1098 | <tr><td class="num" id="LN1019">1019</td><td class="line"> GetSelection(&start, &end);</td></tr>
|
---|
1099 | <tr><td class="num" id="LN1020">1020</td><td class="line"> <span class='keyword'>if</span> (start != end)</td></tr>
|
---|
1100 | <tr><td class="num" id="LN1021">1021</td><td class="line"> Delete();</td></tr>
|
---|
1101 | <tr><td class="num" id="LN1022">1022</td><td class="line"> <span class='keyword'>else</span> {</td></tr>
|
---|
1102 | <tr><td class="num" id="LN1023">1023</td><td class="line"> <span class='keyword'>for</span> (end = start + 1; !IsInitialUTF8Byte(ByteAt(end)); end++) {</td></tr>
|
---|
1103 | <tr><td class="num" id="LN1024">1024</td><td class="line"> <span class='keyword'>if</span> (end > textLen) {</td></tr>
|
---|
1104 | <tr><td class="num" id="LN1025">1025</td><td class="line"> end = textLen;</td></tr>
|
---|
1105 | <tr><td class="num" id="LN1026">1026</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1106 | <tr><td class="num" id="LN1027">1027</td><td class="line"> }</td></tr>
|
---|
1107 | <tr><td class="num" id="LN1028">1028</td><td class="line"> }</td></tr>
|
---|
1108 | <tr><td class="num" id="LN1029">1029</td><td class="line"> Select(start, end);</td></tr>
|
---|
1109 | <tr><td class="num" id="LN1030">1030</td><td class="line"> Delete();</td></tr>
|
---|
1110 | <tr><td class="num" id="LN1031">1031</td><td class="line"> }</td></tr>
|
---|
1111 | <tr><td class="num" id="LN1032">1032</td><td class="line"> }</td></tr>
|
---|
1112 | <tr><td class="num" id="LN1033">1033</td><td class="line"> }</td></tr>
|
---|
1113 | <tr><td class="num" id="LN1034">1034</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
1114 | <tr><td class="num" id="LN1035">1035</td><td class="line"> Select(textLen, textLen);</td></tr>
|
---|
1115 | <tr><td class="num" id="LN1036">1036</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
1116 | <tr><td class="num" id="LN1037">1037</td><td class="line"> }</td></tr>
|
---|
1117 | <tr><td class="num" id="LN1038">1038</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1118 | <tr><td class="num" id="LN1039">1039</td><td class="line"> </td></tr>
|
---|
1119 | <tr><td class="num" id="LN1040">1040</td><td class="line"> <span class='keyword'>case</span> 0x05: <span class='comment'>// ^e - end of line</span></td></tr>
|
---|
1120 | <tr><td class="num" id="LN1041">1041</td><td class="line"> <span class='keyword'>if</span> (IsSelectable() && (mods & B_CONTROL_KEY)) {</td></tr>
|
---|
1121 | <tr><td class="num" id="LN1042">1042</td><td class="line"> <span class='keyword'>if</span> (CurrentLine() == CountLines() - 1)</td></tr>
|
---|
1122 | <tr><td class="num" id="LN1043">1043</td><td class="line"> Select(TextLength(), TextLength());</td></tr>
|
---|
1123 | <tr><td class="num" id="LN1044">1044</td><td class="line"> <span class='keyword'>else</span> {</td></tr>
|
---|
1124 | <tr><td class="num" id="LN1045">1045</td><td class="line"> GoToLine(CurrentLine() + 1);</td></tr>
|
---|
1125 | <tr><td class="num" id="LN1046">1046</td><td class="line"> GetSelection(&start, &end);</td></tr>
|
---|
1126 | <tr><td class="num" id="LN1047">1047</td><td class="line"> Select(start - 1, start - 1);</td></tr>
|
---|
1127 | <tr><td class="num" id="LN1048">1048</td><td class="line"> }</td></tr>
|
---|
1128 | <tr><td class="num" id="LN1049">1049</td><td class="line"> }</td></tr>
|
---|
1129 | <tr><td class="num" id="LN1050">1050</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1130 | <tr><td class="num" id="LN1051">1051</td><td class="line"> </td></tr>
|
---|
1131 | <tr><td class="num" id="LN1052">1052</td><td class="line"> <span class='keyword'>case</span> 0x06: <span class='comment'>// ^f - forward 1 char</span></td></tr>
|
---|
1132 | <tr><td class="num" id="LN1053">1053</td><td class="line"> <span class='keyword'>if</span> (IsSelectable()) {</td></tr>
|
---|
1133 | <tr><td class="num" id="LN1054">1054</td><td class="line"> GetSelection(&start, &end);</td></tr>
|
---|
1134 | <tr><td class="num" id="LN1055">1055</td><td class="line"> <span class='keyword'>if</span> (end > start)</td></tr>
|
---|
1135 | <tr><td class="num" id="LN1056">1056</td><td class="line"> start = end;</td></tr>
|
---|
1136 | <tr><td class="num" id="LN1057">1057</td><td class="line"> <span class='keyword'>else</span> {</td></tr>
|
---|
1137 | <tr><td class="num" id="LN1058">1058</td><td class="line"> <span class='keyword'>for</span> (end = start + 1; !IsInitialUTF8Byte(ByteAt(end));</td></tr>
|
---|
1138 | <tr><td class="num" id="LN1059">1059</td><td class="line"> end++) {</td></tr>
|
---|
1139 | <tr><td class="num" id="LN1060">1060</td><td class="line"> <span class='keyword'>if</span> (end > textLen) {</td></tr>
|
---|
1140 | <tr><td class="num" id="LN1061">1061</td><td class="line"> end = textLen;</td></tr>
|
---|
1141 | <tr><td class="num" id="LN1062">1062</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1142 | <tr><td class="num" id="LN1063">1063</td><td class="line"> }</td></tr>
|
---|
1143 | <tr><td class="num" id="LN1064">1064</td><td class="line"> }</td></tr>
|
---|
1144 | <tr><td class="num" id="LN1065">1065</td><td class="line"> start = end;</td></tr>
|
---|
1145 | <tr><td class="num" id="LN1066">1066</td><td class="line"> }</td></tr>
|
---|
1146 | <tr><td class="num" id="LN1067">1067</td><td class="line"> Select(start, start);</td></tr>
|
---|
1147 | <tr><td class="num" id="LN1068">1068</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
1148 | <tr><td class="num" id="LN1069">1069</td><td class="line"> }</td></tr>
|
---|
1149 | <tr><td class="num" id="LN1070">1070</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1150 | <tr><td class="num" id="LN1071">1071</td><td class="line"> </td></tr>
|
---|
1151 | <tr><td class="num" id="LN1072">1072</td><td class="line"> <span class='keyword'>case</span> 0x0e: <span class='comment'>// ^n - next line</span></td></tr>
|
---|
1152 | <tr><td class="num" id="LN1073">1073</td><td class="line"> <span class='keyword'>if</span> (IsSelectable()) {</td></tr>
|
---|
1153 | <tr><td class="num" id="LN1074">1074</td><td class="line"> raw = B_DOWN_ARROW;</td></tr>
|
---|
1154 | <tr><td class="num" id="LN1075">1075</td><td class="line"> BTextView::KeyDown(&raw, 1);</td></tr>
|
---|
1155 | <tr><td class="num" id="LN1076">1076</td><td class="line"> }</td></tr>
|
---|
1156 | <tr><td class="num" id="LN1077">1077</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1157 | <tr><td class="num" id="LN1078">1078</td><td class="line"> </td></tr>
|
---|
1158 | <tr><td class="num" id="LN1079">1079</td><td class="line"> <span class='keyword'>case</span> 0x0f: <span class='comment'>// ^o - open line</span></td></tr>
|
---|
1159 | <tr><td class="num" id="LN1080">1080</td><td class="line"> <span class='keyword'>if</span> (IsEditable()) {</td></tr>
|
---|
1160 | <tr><td class="num" id="LN1081">1081</td><td class="line"> GetSelection(&start, &end);</td></tr>
|
---|
1161 | <tr><td class="num" id="LN1082">1082</td><td class="line"> Delete();</td></tr>
|
---|
1162 | <tr><td class="num" id="LN1083">1083</td><td class="line"> </td></tr>
|
---|
1163 | <tr><td class="num" id="LN1084">1084</td><td class="line"> <span class='keyword'>char</span> newLine = '\n';</td></tr>
|
---|
1164 | <tr><td class="num" id="LN1085">1085</td><td class="line"> Insert(&newLine, 1);</td></tr>
|
---|
1165 | <tr><td class="num" id="LN1086">1086</td><td class="line"> Select(start, start);</td></tr>
|
---|
1166 | <tr><td class="num" id="LN1087">1087</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
1167 | <tr><td class="num" id="LN1088">1088</td><td class="line"> }</td></tr>
|
---|
1168 | <tr><td class="num" id="LN1089">1089</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1169 | <tr><td class="num" id="LN1090">1090</td><td class="line"> </td></tr>
|
---|
1170 | <tr><td class="num" id="LN1091">1091</td><td class="line"> <span class='keyword'>case</span> B_PAGE_UP:</td></tr>
|
---|
1171 | <tr><td class="num" id="LN1092">1092</td><td class="line"> <span class='keyword'>if</span> (mods & B_CONTROL_KEY) { <span class='comment'>// ^k kill text from cursor to e-o-line</span></td></tr>
|
---|
1172 | <tr><td class="num" id="LN1093">1093</td><td class="line"> <span class='keyword'>if</span> (IsEditable()) {</td></tr>
|
---|
1173 | <tr><td class="num" id="LN1094">1094</td><td class="line"> GetSelection(&start, &end);</td></tr>
|
---|
1174 | <tr><td class="num" id="LN1095">1095</td><td class="line"> <span class='keyword'>if</span> ((start != fLastPosition) && (fYankBuffer)) {</td></tr>
|
---|
1175 | <tr><td class="num" id="LN1096">1096</td><td class="line"> free(fYankBuffer);</td></tr>
|
---|
1176 | <tr><td class="num" id="LN1097">1097</td><td class="line"> fYankBuffer = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
1177 | <tr><td class="num" id="LN1098">1098</td><td class="line"> }</td></tr>
|
---|
1178 | <tr><td class="num" id="LN1099">1099</td><td class="line"> fLastPosition = start;</td></tr>
|
---|
1179 | <tr><td class="num" id="LN1100">1100</td><td class="line"> <span class='keyword'>if</span> (CurrentLine() < CountLines() - 1) {</td></tr>
|
---|
1180 | <tr><td class="num" id="LN1101">1101</td><td class="line"> GoToLine(CurrentLine() + 1);</td></tr>
|
---|
1181 | <tr><td class="num" id="LN1102">1102</td><td class="line"> GetSelection(&end, &end);</td></tr>
|
---|
1182 | <tr><td class="num" id="LN1103">1103</td><td class="line"> end--;</td></tr>
|
---|
1183 | <tr><td class="num" id="LN1104">1104</td><td class="line"> }</td></tr>
|
---|
1184 | <tr><td class="num" id="LN1105">1105</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
1185 | <tr><td class="num" id="LN1106">1106</td><td class="line"> end = TextLength();</td></tr>
|
---|
1186 | <tr><td class="num" id="LN1107">1107</td><td class="line"> <span class='keyword'>if</span> (end < start)</td></tr>
|
---|
1187 | <tr><td class="num" id="LN1108">1108</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1188 | <tr><td class="num" id="LN1109">1109</td><td class="line"> <span class='keyword'>if</span> (start == end)</td></tr>
|
---|
1189 | <tr><td class="num" id="LN1110">1110</td><td class="line"> end++;</td></tr>
|
---|
1190 | <tr><td class="num" id="LN1111">1111</td><td class="line"> Select(start, end);</td></tr>
|
---|
1191 | <tr><td class="num" id="LN1112">1112</td><td class="line"> <span class='keyword'>if</span> (fYankBuffer) {</td></tr>
|
---|
1192 | <tr><td class="num" id="LN1113">1113</td><td class="line"> fYankBuffer = (<span class='keyword'>char</span> *)realloc(fYankBuffer,</td></tr>
|
---|
1193 | <tr><td class="num" id="LN1114">1114</td><td class="line"> strlen(fYankBuffer) + (end - start) + 1);</td></tr>
|
---|
1194 | <tr><td class="num" id="LN1115">1115</td><td class="line"> GetText(start, end - start,</td></tr>
|
---|
1195 | <tr><td class="num" id="LN1116">1116</td><td class="line"> &fYankBuffer[strlen(fYankBuffer)]);</td></tr>
|
---|
1196 | <tr><td class="num" id="LN1117">1117</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
1197 | <tr><td class="num" id="LN1118">1118</td><td class="line"> fYankBuffer = (<span class='keyword'>char</span> *)malloc(end - start + 1);</td></tr>
|
---|
1198 | <tr><td class="num" id="LN1119">1119</td><td class="line"> GetText(start, end - start, fYankBuffer);</td></tr>
|
---|
1199 | <tr><td class="num" id="LN1120">1120</td><td class="line"> }</td></tr>
|
---|
1200 | <tr><td class="num" id="LN1121">1121</td><td class="line"> Delete();</td></tr>
|
---|
1201 | <tr><td class="num" id="LN1122">1122</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
1202 | <tr><td class="num" id="LN1123">1123</td><td class="line"> }</td></tr>
|
---|
1203 | <tr><td class="num" id="LN1124">1124</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1204 | <tr><td class="num" id="LN1125">1125</td><td class="line"> }</td></tr>
|
---|
1205 | <tr><td class="num" id="LN1126">1126</td><td class="line"> </td></tr>
|
---|
1206 | <tr><td class="num" id="LN1127">1127</td><td class="line"> BTextView::KeyDown(key, count);</td></tr>
|
---|
1207 | <tr><td class="num" id="LN1128">1128</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1208 | <tr><td class="num" id="LN1129">1129</td><td class="line"> </td></tr>
|
---|
1209 | <tr><td class="num" id="LN1130">1130</td><td class="line"> <span class='keyword'>case</span> 0x10: <span class='comment'>// ^p goto previous line</span></td></tr>
|
---|
1210 | <tr><td class="num" id="LN1131">1131</td><td class="line"> <span class='keyword'>if</span> (IsSelectable()) {</td></tr>
|
---|
1211 | <tr><td class="num" id="LN1132">1132</td><td class="line"> raw = B_UP_ARROW;</td></tr>
|
---|
1212 | <tr><td class="num" id="LN1133">1133</td><td class="line"> BTextView::KeyDown(&raw, 1);</td></tr>
|
---|
1213 | <tr><td class="num" id="LN1134">1134</td><td class="line"> }</td></tr>
|
---|
1214 | <tr><td class="num" id="LN1135">1135</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1215 | <tr><td class="num" id="LN1136">1136</td><td class="line"> </td></tr>
|
---|
1216 | <tr><td class="num" id="LN1137">1137</td><td class="line"> <span class='keyword'>case</span> 0x19: <span class='comment'>// ^y yank text</span></td></tr>
|
---|
1217 | <tr><td class="num" id="LN1138">1138</td><td class="line"> <span class='keyword'>if</span> (IsEditable() && fYankBuffer) {</td></tr>
|
---|
1218 | <tr><td class="num" id="LN1139">1139</td><td class="line"> Delete();</td></tr>
|
---|
1219 | <tr><td class="num" id="LN1140">1140</td><td class="line"> Insert(fYankBuffer);</td></tr>
|
---|
1220 | <tr><td class="num" id="LN1141">1141</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
1221 | <tr><td class="num" id="LN1142">1142</td><td class="line"> }</td></tr>
|
---|
1222 | <tr><td class="num" id="LN1143">1143</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1223 | <tr><td class="num" id="LN1144">1144</td><td class="line"> </td></tr>
|
---|
1224 | <tr><td class="num" id="LN1145">1145</td><td class="line"> <span class='keyword'>default</span>:</td></tr>
|
---|
1225 | <tr><td class="num" id="LN1146">1146</td><td class="line"> BTextView::KeyDown(key, count);</td></tr>
|
---|
1226 | <tr><td class="num" id="LN1147">1147</td><td class="line"> }</td></tr>
|
---|
1227 | <tr><td class="num" id="LN1148">1148</td><td class="line">}</td></tr>
|
---|
1228 | <tr><td class="num" id="LN1149">1149</td><td class="line"> </td></tr>
|
---|
1229 | <tr><td class="num" id="LN1150">1150</td><td class="line"> </td></tr>
|
---|
1230 | <tr><td class="num" id="LN1151">1151</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1231 | <tr><td class="num" id="LN1152">1152</td><td class="line">TTextView::MakeFocus(<span class='keyword'>bool</span> focus)</td></tr>
|
---|
1232 | <tr><td class="num" id="LN1153">1153</td><td class="line">{</td></tr>
|
---|
1233 | <tr><td class="num" id="LN1154">1154</td><td class="line"> <span class='keyword'>if</span> (!focus) {</td></tr>
|
---|
1234 | <tr><td class="num" id="LN1155">1155</td><td class="line"> <span class='comment'>// ToDo: can someone please translate this? Otherwise I will remove it - axeld.</span></td></tr>
|
---|
1235 | <tr><td class="num" id="LN1156">1156</td><td class="line"> <span class='comment'>// MakeFocus(false) は、IM も Inactive になり、そのまま確定される。</span></td></tr>
|
---|
1236 | <tr><td class="num" id="LN1157">1157</td><td class="line"> <span class='comment'>// しかしこの場合、input_server が B_INPUT_METHOD_EVENT(B_INPUT_METHOD_STOPPED)</span></td></tr>
|
---|
1237 | <tr><td class="num" id="LN1158">1158</td><td class="line"> <span class='comment'>// を送ってこないまま矛盾してしまうので、やむを得ずここでつじつまあわせ処理している。</span></td></tr>
|
---|
1238 | <tr><td class="num" id="LN1159">1159</td><td class="line"> fInputMethodUndoState.active = <span class='keyword'>false</span>;</td></tr>
|
---|
1239 | <tr><td class="num" id="LN1160">1160</td><td class="line"> <span class='comment'>// fInputMethodUndoBufferに溜まっている最後のデータがK_INSERTEDなら(確定)正規のバッファへ追加</span></td></tr>
|
---|
1240 | <tr><td class="num" id="LN1161">1161</td><td class="line"> <span class='keyword'>if</span> (fInputMethodUndoBuffer.CountItems() > 0) {</td></tr>
|
---|
1241 | <tr><td class="num" id="LN1162">1162</td><td class="line"> KUndoItem *item = fInputMethodUndoBuffer.ItemAt(fInputMethodUndoBuffer.CountItems() - 1);</td></tr>
|
---|
1242 | <tr><td class="num" id="LN1163">1163</td><td class="line"> <span class='keyword'>if</span> (item->History == K_INSERTED) {</td></tr>
|
---|
1243 | <tr><td class="num" id="LN1164">1164</td><td class="line"> fUndoBuffer.MakeNewUndoItem();</td></tr>
|
---|
1244 | <tr><td class="num" id="LN1165">1165</td><td class="line"> fUndoBuffer.AddUndo(item->RedoText, item->Length, item->Offset, item->History, item->CursorPos);</td></tr>
|
---|
1245 | <tr><td class="num" id="LN1166">1166</td><td class="line"> fUndoBuffer.MakeNewUndoItem();</td></tr>
|
---|
1246 | <tr><td class="num" id="LN1167">1167</td><td class="line"> }</td></tr>
|
---|
1247 | <tr><td class="num" id="LN1168">1168</td><td class="line"> fInputMethodUndoBuffer.MakeEmpty();</td></tr>
|
---|
1248 | <tr><td class="num" id="LN1169">1169</td><td class="line"> }</td></tr>
|
---|
1249 | <tr><td class="num" id="LN1170">1170</td><td class="line"> }</td></tr>
|
---|
1250 | <tr><td class="num" id="LN1171">1171</td><td class="line"> BTextView::MakeFocus(focus);</td></tr>
|
---|
1251 | <tr><td class="num" id="LN1172">1172</td><td class="line"> </td></tr>
|
---|
1252 | <tr><td class="num" id="LN1173">1173</td><td class="line"> fParent->Focus(focus);</td></tr>
|
---|
1253 | <tr><td class="num" id="LN1174">1174</td><td class="line">}</td></tr>
|
---|
1254 | <tr><td class="num" id="LN1175">1175</td><td class="line"> </td></tr>
|
---|
1255 | <tr><td class="num" id="LN1176">1176</td><td class="line"> </td></tr>
|
---|
1256 | <tr><td class="num" id="LN1177">1177</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1257 | <tr><td class="num" id="LN1178">1178</td><td class="line">TTextView::MessageReceived(BMessage *msg)</td></tr>
|
---|
1258 | <tr><td class="num" id="LN1179">1179</td><td class="line">{</td></tr>
|
---|
1259 | <tr><td class="num" id="LN1180">1180</td><td class="line"> <span class='keyword'>switch</span> (msg->what) {</td></tr>
|
---|
1260 | <tr><td class="num" id="LN1181">1181</td><td class="line"> <span class='keyword'>case</span> B_SIMPLE_DATA:</td></tr>
|
---|
1261 | <tr><td class="num" id="LN1182">1182</td><td class="line"> {</td></tr>
|
---|
1262 | <tr><td class="num" id="LN1183">1183</td><td class="line"> <span class='keyword'>if</span> (fIncoming)</td></tr>
|
---|
1263 | <tr><td class="num" id="LN1184">1184</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1264 | <tr><td class="num" id="LN1185">1185</td><td class="line"> </td></tr>
|
---|
1265 | <tr><td class="num" id="LN1186">1186</td><td class="line"> BMessage message(REFS_RECEIVED);</td></tr>
|
---|
1266 | <tr><td class="num" id="LN1187">1187</td><td class="line"> <span class='keyword'>bool</span> isEnclosure = <span class='keyword'>false</span>;</td></tr>
|
---|
1267 | <tr><td class="num" id="LN1188">1188</td><td class="line"> <span class='keyword'>bool</span> inserted = <span class='keyword'>false</span>;</td></tr>
|
---|
1268 | <tr><td class="num" id="LN1189">1189</td><td class="line"> </td></tr>
|
---|
1269 | <tr><td class="num" id="LN1190">1190</td><td class="line"> off_t len = 0;</td></tr>
|
---|
1270 | <tr><td class="num" id="LN1191">1191</td><td class="line"> int32 end;</td></tr>
|
---|
1271 | <tr><td class="num" id="LN1192">1192</td><td class="line"> int32 start;</td></tr>
|
---|
1272 | <tr><td class="num" id="LN1193">1193</td><td class="line"> </td></tr>
|
---|
1273 | <tr><td class="num" id="LN1194">1194</td><td class="line"> int32 index = 0;</td></tr>
|
---|
1274 | <tr><td class="num" id="LN1195">1195</td><td class="line"> entry_ref ref;</td></tr>
|
---|
1275 | <tr><td class="num" id="LN1196">1196</td><td class="line"> <span class='keyword'>while</span> (msg->FindRef(<span class='string_literal'>"refs"</span>, index++, &ref) == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1276 | <tr><td class="num" id="LN1197">1197</td><td class="line"> BFile file(&ref, <span class='macro'>B_READ_ONLY<span class='expansion'>0x0000</span></span>);</td></tr>
|
---|
1277 | <tr><td class="num" id="LN1198">1198</td><td class="line"> <span class='keyword'>if</span> (file.InitCheck() == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1278 | <tr><td class="num" id="LN1199">1199</td><td class="line"> BNodeInfo node(&file);</td></tr>
|
---|
1279 | <tr><td class="num" id="LN1200">1200</td><td class="line"> <span class='keyword'>char</span> type[<span class='macro'>B_FILE_NAME_LENGTH<span class='expansion'>(256)</span></span>];</td></tr>
|
---|
1280 | <tr><td class="num" id="LN1201">1201</td><td class="line"> node.GetType(type);</td></tr>
|
---|
1281 | <tr><td class="num" id="LN1202">1202</td><td class="line"> </td></tr>
|
---|
1282 | <tr><td class="num" id="LN1203">1203</td><td class="line"> off_t size = 0;</td></tr>
|
---|
1283 | <tr><td class="num" id="LN1204">1204</td><td class="line"> file.GetSize(&size);</td></tr>
|
---|
1284 | <tr><td class="num" id="LN1205">1205</td><td class="line"> </td></tr>
|
---|
1285 | <tr><td class="num" id="LN1206">1206</td><td class="line"> <span class='keyword'>if</span> (!strncasecmp(type, <span class='string_literal'>"text/"</span>, 5) && size > 0) {</td></tr>
|
---|
1286 | <tr><td class="num" id="LN1207">1207</td><td class="line"> len += size;</td></tr>
|
---|
1287 | <tr><td class="num" id="LN1208">1208</td><td class="line"> <span class='keyword'>char</span> *text = (<span class='keyword'>char</span> *)malloc(size);</td></tr>
|
---|
1288 | <tr><td class="num" id="LN1209">1209</td><td class="line"> <span class='keyword'>if</span> (text == <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
1289 | <tr><td class="num" id="LN1210">1210</td><td class="line"> puts(<span class='string_literal'>"no memory!"</span>);</td></tr>
|
---|
1290 | <tr><td class="num" id="LN1211">1211</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
1291 | <tr><td class="num" id="LN1212">1212</td><td class="line"> }</td></tr>
|
---|
1292 | <tr><td class="num" id="LN1213">1213</td><td class="line"> <span class='keyword'>if</span> (file.Read(text, size) < <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1293 | <tr><td class="num" id="LN1214">1214</td><td class="line"> puts(<span class='string_literal'>"could not read from file"</span>);</td></tr>
|
---|
1294 | <tr><td class="num" id="LN1215">1215</td><td class="line"> free(text);</td></tr>
|
---|
1295 | <tr><td class="num" id="LN1216">1216</td><td class="line"> <span class='keyword'>continue</span>;</td></tr>
|
---|
1296 | <tr><td class="num" id="LN1217">1217</td><td class="line"> }</td></tr>
|
---|
1297 | <tr><td class="num" id="LN1218">1218</td><td class="line"> <span class='keyword'>if</span> (!inserted) {</td></tr>
|
---|
1298 | <tr><td class="num" id="LN1219">1219</td><td class="line"> GetSelection(&start, &end);</td></tr>
|
---|
1299 | <tr><td class="num" id="LN1220">1220</td><td class="line"> Delete();</td></tr>
|
---|
1300 | <tr><td class="num" id="LN1221">1221</td><td class="line"> inserted = <span class='keyword'>true</span>;</td></tr>
|
---|
1301 | <tr><td class="num" id="LN1222">1222</td><td class="line"> }</td></tr>
|
---|
1302 | <tr><td class="num" id="LN1223">1223</td><td class="line"> </td></tr>
|
---|
1303 | <tr><td class="num" id="LN1224">1224</td><td class="line"> int32 offset = 0;</td></tr>
|
---|
1304 | <tr><td class="num" id="LN1225">1225</td><td class="line"> <span class='keyword'>for</span> (int32 loop = 0; loop < size; loop++) {</td></tr>
|
---|
1305 | <tr><td class="num" id="LN1226">1226</td><td class="line"> <span class='keyword'>if</span> (text[loop] == '\n') {</td></tr>
|
---|
1306 | <tr><td class="num" id="LN1227">1227</td><td class="line"> Insert(&text[offset], loop - offset + 1);</td></tr>
|
---|
1307 | <tr><td class="num" id="LN1228">1228</td><td class="line"> offset = loop + 1;</td></tr>
|
---|
1308 | <tr><td class="num" id="LN1229">1229</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (text[loop] == '\r') {</td></tr>
|
---|
1309 | <tr><td class="num" id="LN1230">1230</td><td class="line"> text[loop] = '\n';</td></tr>
|
---|
1310 | <tr><td class="num" id="LN1231">1231</td><td class="line"> Insert(&text[offset], loop - offset + 1);</td></tr>
|
---|
1311 | <tr><td class="num" id="LN1232">1232</td><td class="line"> <span class='keyword'>if</span> ((loop + 1 < size)</td></tr>
|
---|
1312 | <tr><td class="num" id="LN1233">1233</td><td class="line"> && (text[loop + 1] == '\n'))</td></tr>
|
---|
1313 | <tr><td class="num" id="LN1234">1234</td><td class="line"> loop++;</td></tr>
|
---|
1314 | <tr><td class="num" id="LN1235">1235</td><td class="line"> offset = loop + 1;</td></tr>
|
---|
1315 | <tr><td class="num" id="LN1236">1236</td><td class="line"> }</td></tr>
|
---|
1316 | <tr><td class="num" id="LN1237">1237</td><td class="line"> }</td></tr>
|
---|
1317 | <tr><td class="num" id="LN1238">1238</td><td class="line"> free(text);</td></tr>
|
---|
1318 | <tr><td class="num" id="LN1239">1239</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
1319 | <tr><td class="num" id="LN1240">1240</td><td class="line"> isEnclosure = <span class='keyword'>true</span>;</td></tr>
|
---|
1320 | <tr><td class="num" id="LN1241">1241</td><td class="line"> message.AddRef(<span class='string_literal'>"refs"</span>, &ref);</td></tr>
|
---|
1321 | <tr><td class="num" id="LN1242">1242</td><td class="line"> }</td></tr>
|
---|
1322 | <tr><td class="num" id="LN1243">1243</td><td class="line"> }</td></tr>
|
---|
1323 | <tr><td class="num" id="LN1244">1244</td><td class="line"> }</td></tr>
|
---|
1324 | <tr><td class="num" id="LN1245">1245</td><td class="line"> </td></tr>
|
---|
1325 | <tr><td class="num" id="LN1246">1246</td><td class="line"> <span class='keyword'>if</span> (index == 1) {</td></tr>
|
---|
1326 | <tr><td class="num" id="LN1247">1247</td><td class="line"> <span class='comment'>// message doesn't contain any refs - maybe the parent class likes it</span></td></tr>
|
---|
1327 | <tr><td class="num" id="LN1248">1248</td><td class="line"> BTextView::MessageReceived(msg);</td></tr>
|
---|
1328 | <tr><td class="num" id="LN1249">1249</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1329 | <tr><td class="num" id="LN1250">1250</td><td class="line"> }</td></tr>
|
---|
1330 | <tr><td class="num" id="LN1251">1251</td><td class="line"> </td></tr>
|
---|
1331 | <tr><td class="num" id="LN1252">1252</td><td class="line"> <span class='keyword'>if</span> (inserted)</td></tr>
|
---|
1332 | <tr><td class="num" id="LN1253">1253</td><td class="line"> Select(start, start + len);</td></tr>
|
---|
1333 | <tr><td class="num" id="LN1254">1254</td><td class="line"> <span class='keyword'>if</span> (isEnclosure)</td></tr>
|
---|
1334 | <tr><td class="num" id="LN1255">1255</td><td class="line"> Window()->PostMessage(&message, Window());</td></tr>
|
---|
1335 | <tr><td class="num" id="LN1256">1256</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1336 | <tr><td class="num" id="LN1257">1257</td><td class="line"> }</td></tr>
|
---|
1337 | <tr><td class="num" id="LN1258">1258</td><td class="line"> </td></tr>
|
---|
1338 | <tr><td class="num" id="LN1259">1259</td><td class="line"> <span class='keyword'>case</span> M_HEADER:</td></tr>
|
---|
1339 | <tr><td class="num" id="LN1260">1260</td><td class="line"> msg->FindBool(<span class='string_literal'>"header"</span>, &fHeader);</td></tr>
|
---|
1340 | <tr><td class="num" id="LN1261">1261</td><td class="line"> SetText(<span class='macro'>NULL<span class='expansion'>__null</span></span>);</td></tr>
|
---|
1341 | <tr><td class="num" id="LN1262">1262</td><td class="line"> LoadMessage(fMail, <span class='keyword'>false</span>, <span class='macro'>NULL<span class='expansion'>__null</span></span>);</td></tr>
|
---|
1342 | <tr><td class="num" id="LN1263">1263</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1343 | <tr><td class="num" id="LN1264">1264</td><td class="line"> </td></tr>
|
---|
1344 | <tr><td class="num" id="LN1265">1265</td><td class="line"> <span class='keyword'>case</span> M_RAW:</td></tr>
|
---|
1345 | <tr><td class="num" id="LN1266">1266</td><td class="line"> StopLoad();</td></tr>
|
---|
1346 | <tr><td class="num" id="LN1267">1267</td><td class="line"> </td></tr>
|
---|
1347 | <tr><td class="num" id="LN1268">1268</td><td class="line"> msg->FindBool(<span class='string_literal'>"raw"</span>, &fRaw);</td></tr>
|
---|
1348 | <tr><td class="num" id="LN1269">1269</td><td class="line"> SetText(<span class='macro'>NULL<span class='expansion'>__null</span></span>);</td></tr>
|
---|
1349 | <tr><td class="num" id="LN1270">1270</td><td class="line"> LoadMessage(fMail, <span class='keyword'>false</span>, <span class='macro'>NULL<span class='expansion'>__null</span></span>);</td></tr>
|
---|
1350 | <tr><td class="num" id="LN1271">1271</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1351 | <tr><td class="num" id="LN1272">1272</td><td class="line"> </td></tr>
|
---|
1352 | <tr><td class="num" id="LN1273">1273</td><td class="line"> <span class='keyword'>case</span> M_SELECT:</td></tr>
|
---|
1353 | <tr><td class="num" id="LN1274">1274</td><td class="line"> <span class='keyword'>if</span> (IsSelectable())</td></tr>
|
---|
1354 | <tr><td class="num" id="LN1275">1275</td><td class="line"> Select(0, TextLength());</td></tr>
|
---|
1355 | <tr><td class="num" id="LN1276">1276</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1356 | <tr><td class="num" id="LN1277">1277</td><td class="line"> </td></tr>
|
---|
1357 | <tr><td class="num" id="LN1278">1278</td><td class="line"> <span class='keyword'>case</span> M_SAVE:</td></tr>
|
---|
1358 | <tr><td class="num" id="LN1279">1279</td><td class="line"> Save(msg);</td></tr>
|
---|
1359 | <tr><td class="num" id="LN1280">1280</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1360 | <tr><td class="num" id="LN1281">1281</td><td class="line"> </td></tr>
|
---|
1361 | <tr><td class="num" id="LN1282">1282</td><td class="line"> <span class='keyword'>case</span> B_NODE_MONITOR:</td></tr>
|
---|
1362 | <tr><td class="num" id="LN1283">1283</td><td class="line"> {</td></tr>
|
---|
1363 | <tr><td class="num" id="LN1284">1284</td><td class="line"> int32 opcode;</td></tr>
|
---|
1364 | <tr><td class="num" id="LN1285">1285</td><td class="line"> <span class='keyword'>if</span> (msg->FindInt32(<span class='string_literal'>"opcode"</span>, &opcode) == <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1365 | <tr><td class="num" id="LN1286">1286</td><td class="line"> dev_t device;</td></tr>
|
---|
1366 | <tr><td class="num" id="LN1287">1287</td><td class="line"> <span class='keyword'>if</span> (msg->FindInt32(<span class='string_literal'>"device"</span>, &device) < <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
1367 | <tr><td class="num" id="LN1288">1288</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1368 | <tr><td class="num" id="LN1289">1289</td><td class="line"> ino_t inode;</td></tr>
|
---|
1369 | <tr><td class="num" id="LN1290">1290</td><td class="line"> <span class='keyword'>if</span> (msg->FindInt64(<span class='string_literal'>"node"</span>, &inode) < <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
1370 | <tr><td class="num" id="LN1291">1291</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1371 | <tr><td class="num" id="LN1292">1292</td><td class="line"> </td></tr>
|
---|
1372 | <tr><td class="num" id="LN1293">1293</td><td class="line"> hyper_text *enclosure;</td></tr>
|
---|
1373 | <tr><td class="num" id="LN1294">1294</td><td class="line"> <span class='keyword'>for</span> (int32 index = 0;</td></tr>
|
---|
1374 | <tr><td class="num" id="LN1295">1295</td><td class="line"> (enclosure = (hyper_text *)fEnclosures->ItemAt(index++)) != <span class='macro'>NULL<span class='expansion'>__null</span></span>;) {</td></tr>
|
---|
1375 | <tr><td class="num" id="LN1296">1296</td><td class="line"> <span class='keyword'>if</span> (device == enclosure->node.device</td></tr>
|
---|
1376 | <tr><td class="num" id="LN1297">1297</td><td class="line"> && inode == enclosure->node.node) {</td></tr>
|
---|
1377 | <tr><td class="num" id="LN1298">1298</td><td class="line"> <span class='keyword'>if</span> (opcode == <span class='macro'>B_ENTRY_REMOVED<span class='expansion'>2</span></span>) {</td></tr>
|
---|
1378 | <tr><td class="num" id="LN1299">1299</td><td class="line"> enclosure->saved = <span class='keyword'>false</span>;</td></tr>
|
---|
1379 | <tr><td class="num" id="LN1300">1300</td><td class="line"> enclosure->have_ref = <span class='keyword'>false</span>;</td></tr>
|
---|
1380 | <tr><td class="num" id="LN1301">1301</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (opcode == <span class='macro'>B_ENTRY_MOVED<span class='expansion'>3</span></span>) {</td></tr>
|
---|
1381 | <tr><td class="num" id="LN1302">1302</td><td class="line"> enclosure->ref.device = device;</td></tr>
|
---|
1382 | <tr><td class="num" id="LN1303">1303</td><td class="line"> msg->FindInt64(<span class='string_literal'>"to directory"</span>, &enclosure->ref.directory);</td></tr>
|
---|
1383 | <tr><td class="num" id="LN1304">1304</td><td class="line"> </td></tr>
|
---|
1384 | <tr><td class="num" id="LN1305">1305</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *name;</td></tr>
|
---|
1385 | <tr><td class="num" id="LN1306">1306</td><td class="line"> msg->FindString(<span class='string_literal'>"name"</span>, &name);</td></tr>
|
---|
1386 | <tr><td class="num" id="LN1307">1307</td><td class="line"> enclosure->ref.set_name(name);</td></tr>
|
---|
1387 | <tr><td class="num" id="LN1308">1308</td><td class="line"> }</td></tr>
|
---|
1388 | <tr><td class="num" id="LN1309">1309</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1389 | <tr><td class="num" id="LN1310">1310</td><td class="line"> }</td></tr>
|
---|
1390 | <tr><td class="num" id="LN1311">1311</td><td class="line"> }</td></tr>
|
---|
1391 | <tr><td class="num" id="LN1312">1312</td><td class="line"> }</td></tr>
|
---|
1392 | <tr><td class="num" id="LN1313">1313</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1393 | <tr><td class="num" id="LN1314">1314</td><td class="line"> }</td></tr>
|
---|
1394 | <tr><td class="num" id="LN1315">1315</td><td class="line"> </td></tr>
|
---|
1395 | <tr><td class="num" id="LN1316">1316</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1396 | <tr><td class="num" id="LN1317">1317</td><td class="line"> <span class='comment'>// Tracker has responded to a BMessage that was dragged out of</span></td></tr>
|
---|
1397 | <tr><td class="num" id="LN1318">1318</td><td class="line"> <span class='comment'>// this email message. It has created a file for us, we just have to</span></td></tr>
|
---|
1398 | <tr><td class="num" id="LN1319">1319</td><td class="line"> <span class='comment'>// put the stuff in it.</span></td></tr>
|
---|
1399 | <tr><td class="num" id="LN1320">1320</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1400 | <tr><td class="num" id="LN1321">1321</td><td class="line"> <span class='keyword'>case</span> B_COPY_TARGET:</td></tr>
|
---|
1401 | <tr><td class="num" id="LN1322">1322</td><td class="line"> {</td></tr>
|
---|
1402 | <tr><td class="num" id="LN1323">1323</td><td class="line"> BMessage data;</td></tr>
|
---|
1403 | <tr><td class="num" id="LN1324">1324</td><td class="line"> <span class='keyword'>if</span> (msg->FindMessage(<span class='string_literal'>"be:originator-data"</span>, &data) == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1404 | <tr><td class="num" id="LN1325">1325</td><td class="line"> entry_ref directory;</td></tr>
|
---|
1405 | <tr><td class="num" id="LN1326">1326</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *name;</td></tr>
|
---|
1406 | <tr><td class="num" id="LN1327">1327</td><td class="line"> hyper_text *enclosure;</td></tr>
|
---|
1407 | <tr><td class="num" id="LN1328">1328</td><td class="line"> </td></tr>
|
---|
1408 | <tr><td class="num" id="LN1329">1329</td><td class="line"> <span class='keyword'>if</span> (data.FindPointer(<span class='string_literal'>"enclosure"</span>, (<span class='keyword'>void</span> **)&enclosure) == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span></td></tr>
|
---|
1409 | <tr><td class="num" id="LN1330">1330</td><td class="line"> && msg->FindString(<span class='string_literal'>"name"</span>, &name) == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span></td></tr>
|
---|
1410 | <tr><td class="num" id="LN1331">1331</td><td class="line"> && msg->FindRef(<span class='string_literal'>"directory"</span>, &directory) == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1411 | <tr><td class="num" id="LN1332">1332</td><td class="line"> <span class='keyword'>switch</span> (enclosure->type) {</td></tr>
|
---|
1412 | <tr><td class="num" id="LN1333">1333</td><td class="line"> <span class='keyword'>case</span> TYPE_ENCLOSURE:</td></tr>
|
---|
1413 | <tr><td class="num" id="LN1334">1334</td><td class="line"> <span class='keyword'>case</span> TYPE_BE_ENCLOSURE:</td></tr>
|
---|
1414 | <tr><td class="num" id="LN1335">1335</td><td class="line"> {</td></tr>
|
---|
1415 | <tr><td class="num" id="LN1336">1336</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1416 | <tr><td class="num" id="LN1337">1337</td><td class="line"> <span class='comment'>// Enclosure. Decode the data and write it out.</span></td></tr>
|
---|
1417 | <tr><td class="num" id="LN1338">1338</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1418 | <tr><td class="num" id="LN1339">1339</td><td class="line"> BMessage saveMsg(M_SAVE);</td></tr>
|
---|
1419 | <tr><td class="num" id="LN1340">1340</td><td class="line"> saveMsg.AddString(<span class='string_literal'>"name"</span>, name);</td></tr>
|
---|
1420 | <tr><td class="num" id="LN1341">1341</td><td class="line"> saveMsg.AddRef(<span class='string_literal'>"directory"</span>, &directory);</td></tr>
|
---|
1421 | <tr><td class="num" id="LN1342">1342</td><td class="line"> saveMsg.AddPointer(<span class='string_literal'>"enclosure"</span>, enclosure);</td></tr>
|
---|
1422 | <tr><td class="num" id="LN1343">1343</td><td class="line"> Save(&saveMsg, <span class='keyword'>false</span>);</td></tr>
|
---|
1423 | <tr><td class="num" id="LN1344">1344</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1424 | <tr><td class="num" id="LN1345">1345</td><td class="line"> }</td></tr>
|
---|
1425 | <tr><td class="num" id="LN1346">1346</td><td class="line"> </td></tr>
|
---|
1426 | <tr><td class="num" id="LN1347">1347</td><td class="line"> <span class='keyword'>case</span> TYPE_URL:</td></tr>
|
---|
1427 | <tr><td class="num" id="LN1348">1348</td><td class="line"> {</td></tr>
|
---|
1428 | <tr><td class="num" id="LN1349">1349</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *replyType;</td></tr>
|
---|
1429 | <tr><td class="num" id="LN1350">1350</td><td class="line"> <span class='keyword'>if</span> (msg->FindString(<span class='string_literal'>"be:filetypes"</span>, &replyType) != <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
1430 | <tr><td class="num" id="LN1351">1351</td><td class="line"> <span class='comment'>// drag recipient didn't ask for any specific type,</span></td></tr>
|
---|
1431 | <tr><td class="num" id="LN1352">1352</td><td class="line"> <span class='comment'>// create a bookmark file as default</span></td></tr>
|
---|
1432 | <tr><td class="num" id="LN1353">1353</td><td class="line"> replyType = <span class='string_literal'>"application/x-vnd.Be-bookmark"</span>;</td></tr>
|
---|
1433 | <tr><td class="num" id="LN1354">1354</td><td class="line"> </td></tr>
|
---|
1434 | <tr><td class="num" id="LN1355">1355</td><td class="line"> BDirectory dir(&directory);</td></tr>
|
---|
1435 | <tr><td class="num" id="LN1356">1356</td><td class="line"> BFile file(&dir, name, <span class='macro'>B_READ_WRITE<span class='expansion'>0x0002</span></span>);</td></tr>
|
---|
1436 | <tr><td class="num" id="LN1357">1357</td><td class="line"> <span class='keyword'>if</span> (file.InitCheck() == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1437 | <tr><td class="num" id="LN1358">1358</td><td class="line"> <span class='keyword'>if</span> (strcmp(replyType, <span class='string_literal'>"application/x-vnd.Be-bookmark"</span>) == 0) {</td></tr>
|
---|
1438 | <tr><td class="num" id="LN1359">1359</td><td class="line"> <span class='comment'>// we got a request to create a bookmark, stuff</span></td></tr>
|
---|
1439 | <tr><td class="num" id="LN1360">1360</td><td class="line"> <span class='comment'>// it with the url attribute</span></td></tr>
|
---|
1440 | <tr><td class="num" id="LN1361">1361</td><td class="line"> file.WriteAttr(<span class='string_literal'>"META:url"</span>, B_STRING_TYPE, 0,</td></tr>
|
---|
1441 | <tr><td class="num" id="LN1362">1362</td><td class="line"> enclosure->name, strlen(enclosure->name) + 1);</td></tr>
|
---|
1442 | <tr><td class="num" id="LN1363">1363</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (strcasecmp(replyType, <span class='string_literal'>"text/plain"</span>) == 0) {</td></tr>
|
---|
1443 | <tr><td class="num" id="LN1364">1364</td><td class="line"> <span class='comment'>// create a plain text file, stuff it with</span></td></tr>
|
---|
1444 | <tr><td class="num" id="LN1365">1365</td><td class="line"> <span class='comment'>// the url as text</span></td></tr>
|
---|
1445 | <tr><td class="num" id="LN1366">1366</td><td class="line"> file.Write(enclosure->name, strlen(enclosure->name));</td></tr>
|
---|
1446 | <tr><td class="num" id="LN1367">1367</td><td class="line"> }</td></tr>
|
---|
1447 | <tr><td class="num" id="LN1368">1368</td><td class="line"> </td></tr>
|
---|
1448 | <tr><td class="num" id="LN1369">1369</td><td class="line"> BNodeInfo fileInfo(&file);</td></tr>
|
---|
1449 | <tr><td class="num" id="LN1370">1370</td><td class="line"> fileInfo.SetType(replyType);</td></tr>
|
---|
1450 | <tr><td class="num" id="LN1371">1371</td><td class="line"> }</td></tr>
|
---|
1451 | <tr><td class="num" id="LN1372">1372</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1452 | <tr><td class="num" id="LN1373">1373</td><td class="line"> }</td></tr>
|
---|
1453 | <tr><td class="num" id="LN1374">1374</td><td class="line"> </td></tr>
|
---|
1454 | <tr><td class="num" id="LN1375">1375</td><td class="line"> <span class='keyword'>case</span> TYPE_MAILTO:</td></tr>
|
---|
1455 | <tr><td class="num" id="LN1376">1376</td><td class="line"> {</td></tr>
|
---|
1456 | <tr><td class="num" id="LN1377">1377</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1457 | <tr><td class="num" id="LN1378">1378</td><td class="line"> <span class='comment'>// Add some attributes to the already created</span></td></tr>
|
---|
1458 | <tr><td class="num" id="LN1379">1379</td><td class="line"> <span class='comment'>// person file. Strip out the 'mailto:' if</span></td></tr>
|
---|
1459 | <tr><td class="num" id="LN1380">1380</td><td class="line"> <span class='comment'>// possible.</span></td></tr>
|
---|
1460 | <tr><td class="num" id="LN1381">1381</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1461 | <tr><td class="num" id="LN1382">1382</td><td class="line"> <span class='keyword'>char</span> *addrStart = enclosure->name;</td></tr>
|
---|
1462 | <tr><td class="num" id="LN1383">1383</td><td class="line"> <span class='keyword'>while</span> (<span class='keyword'>true</span>) {</td></tr>
|
---|
1463 | <tr><td class="num" id="LN1384">1384</td><td class="line"> <span class='keyword'>if</span> (*addrStart == ':') {</td></tr>
|
---|
1464 | <tr><td class="num" id="LN1385">1385</td><td class="line"> addrStart++;</td></tr>
|
---|
1465 | <tr><td class="num" id="LN1386">1386</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1466 | <tr><td class="num" id="LN1387">1387</td><td class="line"> }</td></tr>
|
---|
1467 | <tr><td class="num" id="LN1388">1388</td><td class="line"> </td></tr>
|
---|
1468 | <tr><td class="num" id="LN1389">1389</td><td class="line"> <span class='keyword'>if</span> (*addrStart == '\0') {</td></tr>
|
---|
1469 | <tr><td class="num" id="LN1390">1390</td><td class="line"> addrStart = enclosure->name;</td></tr>
|
---|
1470 | <tr><td class="num" id="LN1391">1391</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1471 | <tr><td class="num" id="LN1392">1392</td><td class="line"> }</td></tr>
|
---|
1472 | <tr><td class="num" id="LN1393">1393</td><td class="line"> </td></tr>
|
---|
1473 | <tr><td class="num" id="LN1394">1394</td><td class="line"> addrStart++;</td></tr>
|
---|
1474 | <tr><td class="num" id="LN1395">1395</td><td class="line"> }</td></tr>
|
---|
1475 | <tr><td class="num" id="LN1396">1396</td><td class="line"> </td></tr>
|
---|
1476 | <tr><td class="num" id="LN1397">1397</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *replyType;</td></tr>
|
---|
1477 | <tr><td class="num" id="LN1398">1398</td><td class="line"> <span class='keyword'>if</span> (msg->FindString(<span class='string_literal'>"be:filetypes"</span>, &replyType) != <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
1478 | <tr><td class="num" id="LN1399">1399</td><td class="line"> <span class='comment'>// drag recipient didn't ask for any specific type,</span></td></tr>
|
---|
1479 | <tr><td class="num" id="LN1400">1400</td><td class="line"> <span class='comment'>// create a bookmark file as default</span></td></tr>
|
---|
1480 | <tr><td class="num" id="LN1401">1401</td><td class="line"> replyType = <span class='string_literal'>"application/x-vnd.Be-bookmark"</span>;</td></tr>
|
---|
1481 | <tr><td class="num" id="LN1402">1402</td><td class="line"> </td></tr>
|
---|
1482 | <tr><td class="num" id="LN1403">1403</td><td class="line"> BDirectory dir(&directory);</td></tr>
|
---|
1483 | <tr><td class="num" id="LN1404">1404</td><td class="line"> BFile file(&dir, name, <span class='macro'>B_READ_WRITE<span class='expansion'>0x0002</span></span>);</td></tr>
|
---|
1484 | <tr><td class="num" id="LN1405">1405</td><td class="line"> <span class='keyword'>if</span> (file.InitCheck() == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1485 | <tr><td class="num" id="LN1406">1406</td><td class="line"> <span class='keyword'>if</span> (!strcmp(replyType, <span class='string_literal'>"application/x-person"</span>)) {</td></tr>
|
---|
1486 | <tr><td class="num" id="LN1407">1407</td><td class="line"> <span class='comment'>// we got a request to create a bookmark, stuff</span></td></tr>
|
---|
1487 | <tr><td class="num" id="LN1408">1408</td><td class="line"> <span class='comment'>// it with the address attribute</span></td></tr>
|
---|
1488 | <tr><td class="num" id="LN1409">1409</td><td class="line"> file.WriteAttr(<span class='string_literal'>"META:email"</span>, B_STRING_TYPE, 0,</td></tr>
|
---|
1489 | <tr><td class="num" id="LN1410">1410</td><td class="line"> addrStart, strlen(enclosure->name) + 1);</td></tr>
|
---|
1490 | <tr><td class="num" id="LN1411">1411</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (!strcasecmp(replyType, <span class='string_literal'>"text/plain"</span>)) {</td></tr>
|
---|
1491 | <tr><td class="num" id="LN1412">1412</td><td class="line"> <span class='comment'>// create a plain text file, stuff it with the</span></td></tr>
|
---|
1492 | <tr><td class="num" id="LN1413">1413</td><td class="line"> <span class='comment'>// email as text</span></td></tr>
|
---|
1493 | <tr><td class="num" id="LN1414">1414</td><td class="line"> file.Write(addrStart, strlen(addrStart));</td></tr>
|
---|
1494 | <tr><td class="num" id="LN1415">1415</td><td class="line"> }</td></tr>
|
---|
1495 | <tr><td class="num" id="LN1416">1416</td><td class="line"> </td></tr>
|
---|
1496 | <tr><td class="num" id="LN1417">1417</td><td class="line"> BNodeInfo fileInfo(&file);</td></tr>
|
---|
1497 | <tr><td class="num" id="LN1418">1418</td><td class="line"> fileInfo.SetType(replyType);</td></tr>
|
---|
1498 | <tr><td class="num" id="LN1419">1419</td><td class="line"> }</td></tr>
|
---|
1499 | <tr><td class="num" id="LN1420">1420</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1500 | <tr><td class="num" id="LN1421">1421</td><td class="line"> }</td></tr>
|
---|
1501 | <tr><td class="num" id="LN1422">1422</td><td class="line"> }</td></tr>
|
---|
1502 | <tr><td class="num" id="LN1423">1423</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
1503 | <tr><td class="num" id="LN1424">1424</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1504 | <tr><td class="num" id="LN1425">1425</td><td class="line"> <span class='comment'>// Assume this is handled by BTextView...</span></td></tr>
|
---|
1505 | <tr><td class="num" id="LN1426">1426</td><td class="line"> <span class='comment'>// (Probably drag clipping.)</span></td></tr>
|
---|
1506 | <tr><td class="num" id="LN1427">1427</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1507 | <tr><td class="num" id="LN1428">1428</td><td class="line"> BTextView::MessageReceived(msg);</td></tr>
|
---|
1508 | <tr><td class="num" id="LN1429">1429</td><td class="line"> }</td></tr>
|
---|
1509 | <tr><td class="num" id="LN1430">1430</td><td class="line"> }</td></tr>
|
---|
1510 | <tr><td class="num" id="LN1431">1431</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1511 | <tr><td class="num" id="LN1432">1432</td><td class="line"> }</td></tr>
|
---|
1512 | <tr><td class="num" id="LN1433">1433</td><td class="line"> </td></tr>
|
---|
1513 | <tr><td class="num" id="LN1434">1434</td><td class="line"> <span class='keyword'>case</span> B_INPUT_METHOD_EVENT:</td></tr>
|
---|
1514 | <tr><td class="num" id="LN1435">1435</td><td class="line"> {</td></tr>
|
---|
1515 | <tr><td class="num" id="LN1436">1436</td><td class="line"> int32 im_op;</td></tr>
|
---|
1516 | <tr><td class="num" id="LN1437">1437</td><td class="line"> <span class='keyword'>if</span> (msg->FindInt32(<span class='string_literal'>"be:opcode"</span>, &im_op) == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>){</td></tr>
|
---|
1517 | <tr><td class="num" id="LN1438">1438</td><td class="line"> <span class='keyword'>switch</span> (im_op) {</td></tr>
|
---|
1518 | <tr><td class="num" id="LN1439">1439</td><td class="line"> <span class='keyword'>case</span> B_INPUT_METHOD_STARTED:</td></tr>
|
---|
1519 | <tr><td class="num" id="LN1440">1440</td><td class="line"> fInputMethodUndoState.replace = <span class='keyword'>true</span>;</td></tr>
|
---|
1520 | <tr><td class="num" id="LN1441">1441</td><td class="line"> fInputMethodUndoState.active = <span class='keyword'>true</span>;</td></tr>
|
---|
1521 | <tr><td class="num" id="LN1442">1442</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1522 | <tr><td class="num" id="LN1443">1443</td><td class="line"> <span class='keyword'>case</span> B_INPUT_METHOD_STOPPED:</td></tr>
|
---|
1523 | <tr><td class="num" id="LN1444">1444</td><td class="line"> fInputMethodUndoState.active = <span class='keyword'>false</span>;</td></tr>
|
---|
1524 | <tr><td class="num" id="LN1445">1445</td><td class="line"> <span class='keyword'>if</span> (fInputMethodUndoBuffer.CountItems() > 0) {</td></tr>
|
---|
1525 | <tr><td class="num" id="LN1446">1446</td><td class="line"> KUndoItem *undo = fInputMethodUndoBuffer.ItemAt(</td></tr>
|
---|
1526 | <tr><td class="num" id="LN1447">1447</td><td class="line"> fInputMethodUndoBuffer.CountItems() - 1);</td></tr>
|
---|
1527 | <tr><td class="num" id="LN1448">1448</td><td class="line"> <span class='keyword'>if</span> (undo->History == K_INSERTED){</td></tr>
|
---|
1528 | <tr><td class="num" id="LN1449">1449</td><td class="line"> fUndoBuffer.MakeNewUndoItem();</td></tr>
|
---|
1529 | <tr><td class="num" id="LN1450">1450</td><td class="line"> fUndoBuffer.AddUndo(undo->RedoText, undo->Length,</td></tr>
|
---|
1530 | <tr><td class="num" id="LN1451">1451</td><td class="line"> undo->Offset, undo->History, undo->CursorPos);</td></tr>
|
---|
1531 | <tr><td class="num" id="LN1452">1452</td><td class="line"> fUndoBuffer.MakeNewUndoItem();</td></tr>
|
---|
1532 | <tr><td class="num" id="LN1453">1453</td><td class="line"> }</td></tr>
|
---|
1533 | <tr><td class="num" id="LN1454">1454</td><td class="line"> fInputMethodUndoBuffer.MakeEmpty();</td></tr>
|
---|
1534 | <tr><td class="num" id="LN1455">1455</td><td class="line"> }</td></tr>
|
---|
1535 | <tr><td class="num" id="LN1456">1456</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1536 | <tr><td class="num" id="LN1457">1457</td><td class="line"> <span class='keyword'>case</span> B_INPUT_METHOD_CHANGED:</td></tr>
|
---|
1537 | <tr><td class="num" id="LN1458">1458</td><td class="line"> fInputMethodUndoState.active = <span class='keyword'>true</span>;</td></tr>
|
---|
1538 | <tr><td class="num" id="LN1459">1459</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1539 | <tr><td class="num" id="LN1460">1460</td><td class="line"> <span class='keyword'>case</span> B_INPUT_METHOD_LOCATION_REQUEST:</td></tr>
|
---|
1540 | <tr><td class="num" id="LN1461">1461</td><td class="line"> fInputMethodUndoState.active = <span class='keyword'>true</span>;</td></tr>
|
---|
1541 | <tr><td class="num" id="LN1462">1462</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1542 | <tr><td class="num" id="LN1463">1463</td><td class="line"> }</td></tr>
|
---|
1543 | <tr><td class="num" id="LN1464">1464</td><td class="line"> }</td></tr>
|
---|
1544 | <tr><td class="num" id="LN1465">1465</td><td class="line"> BTextView::MessageReceived(msg);</td></tr>
|
---|
1545 | <tr><td class="num" id="LN1466">1466</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1546 | <tr><td class="num" id="LN1467">1467</td><td class="line"> }</td></tr>
|
---|
1547 | <tr><td class="num" id="LN1468">1468</td><td class="line"> </td></tr>
|
---|
1548 | <tr><td class="num" id="LN1469">1469</td><td class="line"> <span class='keyword'>case</span> M_REDO:</td></tr>
|
---|
1549 | <tr><td class="num" id="LN1470">1470</td><td class="line"> Redo();</td></tr>
|
---|
1550 | <tr><td class="num" id="LN1471">1471</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1551 | <tr><td class="num" id="LN1472">1472</td><td class="line"> </td></tr>
|
---|
1552 | <tr><td class="num" id="LN1473">1473</td><td class="line"> <span class='keyword'>default</span>:</td></tr>
|
---|
1553 | <tr><td class="num" id="LN1474">1474</td><td class="line"> BTextView::MessageReceived(msg);</td></tr>
|
---|
1554 | <tr><td class="num" id="LN1475">1475</td><td class="line"> }</td></tr>
|
---|
1555 | <tr><td class="num" id="LN1476">1476</td><td class="line">}</td></tr>
|
---|
1556 | <tr><td class="num" id="LN1477">1477</td><td class="line"> </td></tr>
|
---|
1557 | <tr><td class="num" id="LN1478">1478</td><td class="line"> </td></tr>
|
---|
1558 | <tr><td class="num" id="LN1479">1479</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1559 | <tr><td class="num" id="LN1480">1480</td><td class="line">TTextView::MouseDown(BPoint where)</td></tr>
|
---|
1560 | <tr><td class="num" id="LN1481">1481</td><td class="line">{</td></tr>
|
---|
1561 | <tr><td class="num" id="LN1482">1482</td><td class="line"> <span class='keyword'>if</span> (IsEditable()) {</td></tr>
|
---|
1562 | <tr><td class="num" id="LN1483">1483</td><td class="line"> BPoint point;</td></tr>
|
---|
1563 | <tr><td class="num" id="LN1484">1484</td><td class="line"> uint32 buttons;</td></tr>
|
---|
1564 | <tr><td class="num" id="LN1485">1485</td><td class="line"> GetMouse(&point, &buttons);</td></tr>
|
---|
1565 | <tr><td class="num" id="LN1486">1486</td><td class="line"> <span class='keyword'>if</span> (gDictCount && (buttons == B_SECONDARY_MOUSE_BUTTON)) {</td></tr>
|
---|
1566 | <tr><td class="num" id="LN1487">1487</td><td class="line"> int32 offset, start, end, length;</td></tr>
|
---|
1567 | <tr><td class="num" id="LN1488">1488</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = Text();</td></tr>
|
---|
1568 | <tr><td class="num" id="LN1489">1489</td><td class="line"> offset = OffsetAt(where);</td></tr>
|
---|
1569 | <tr><td class="num" id="LN1490">1490</td><td class="line"> <span class='keyword'>if</span> (<span class='macro'>isalpha(text[offset])<span class='expansion'>(__ctype_b[(int)((text[offset]))] & (unsigned short int)_ISalpha<br>)</span></span>) {</td></tr>
|
---|
1570 | <tr><td class="num" id="LN1491">1491</td><td class="line"> length = TextLength();</td></tr>
|
---|
1571 | <tr><td class="num" id="LN1492">1492</td><td class="line"> </td></tr>
|
---|
1572 | <tr><td class="num" id="LN1493">1493</td><td class="line"> <span class='comment'>//Find start and end of word</span></td></tr>
|
---|
1573 | <tr><td class="num" id="LN1494">1494</td><td class="line"> <span class='comment'>//FindSpellBoundry(length, offset, &start, &end);</span></td></tr>
|
---|
1574 | <tr><td class="num" id="LN1495">1495</td><td class="line"> </td></tr>
|
---|
1575 | <tr><td class="num" id="LN1496">1496</td><td class="line"> <span class='keyword'>char</span> c;</td></tr>
|
---|
1576 | <tr><td class="num" id="LN1497">1497</td><td class="line"> <span class='keyword'>bool</span> isAlpha, isApost, isCap;</td></tr>
|
---|
1577 | <tr><td class="num" id="LN1498">1498</td><td class="line"> int32 first;</td></tr>
|
---|
1578 | <tr><td class="num" id="LN1499">1499</td><td class="line"> </td></tr>
|
---|
1579 | <tr><td class="num" id="LN1500">1500</td><td class="line"> <span class='keyword'>for</span> (first = offset;</td></tr>
|
---|
1580 | <tr><td class="num" id="LN1501">1501</td><td class="line"> (first >= 0) && (((c = text[first]) == '\'') || <span class='macro'>isalpha(c)<span class='expansion'>(__ctype_b[(int)((c))] & (unsigned short int)_ISalpha)</span></span>);</td></tr>
|
---|
1581 | <tr><td class="num" id="LN1502">1502</td><td class="line"> first--) {}</td></tr>
|
---|
1582 | <tr><td class="num" id="LN1503">1503</td><td class="line"> isCap = <span class='macro'>isupper(text[++first])<span class='expansion'>(__ctype_b[(int)((text[++first]))] & (unsigned short int)<br>_ISupper)</span></span>;</td></tr>
|
---|
1583 | <tr><td class="num" id="LN1504">1504</td><td class="line"> </td></tr>
|
---|
1584 | <tr><td class="num" id="LN1505">1505</td><td class="line"> <span class='keyword'>for</span> (start = offset, c = text[start], isAlpha = <span class='macro'>isalpha(c)<span class='expansion'>(__ctype_b[(int)((c))] & (unsigned short int)_ISalpha)</span></span>, isApost = (c=='\'');</td></tr>
|
---|
1585 | <tr><td class="num" id="LN1506">1506</td><td class="line"> (start >= 0) && (isAlpha || (isApost</td></tr>
|
---|
1586 | <tr><td class="num" id="LN1507">1507</td><td class="line"> && (((c = text[start+1]) != 's') || !isCap) && <span class='macro'>isalpha(c)<span class='expansion'>(__ctype_b[(int)((c))] & (unsigned short int)_ISalpha)</span></span></td></tr>
|
---|
1587 | <tr><td class="num" id="LN1508">1508</td><td class="line"> && <span class='macro'>isalpha(text[start-1])<span class='expansion'>(__ctype_b[(int)((text[start-1]))] & (unsigned short int)<br>_ISalpha)</span></span>));</td></tr>
|
---|
1588 | <tr><td class="num" id="LN1509">1509</td><td class="line"> start--, c = text[start], isAlpha = <span class='macro'>isalpha(c)<span class='expansion'>(__ctype_b[(int)((c))] & (unsigned short int)_ISalpha)</span></span>, isApost = (c == '\'')) {}</td></tr>
|
---|
1589 | <tr><td class="num" id="LN1510">1510</td><td class="line"> start++;</td></tr>
|
---|
1590 | <tr><td class="num" id="LN1511">1511</td><td class="line"> </td></tr>
|
---|
1591 | <tr><td class="num" id="LN1512">1512</td><td class="line"> <span class='keyword'>for</span> (end = offset, c = text[end], isAlpha = <span class='macro'>isalpha(c)<span class='expansion'>(__ctype_b[(int)((c))] & (unsigned short int)_ISalpha)</span></span>, isApost = (c == '\'');</td></tr>
|
---|
1592 | <tr><td class="num" id="LN1513">1513</td><td class="line"> (end < length) && (isAlpha || (isApost</td></tr>
|
---|
1593 | <tr><td class="num" id="LN1514">1514</td><td class="line"> && (((c = text[end + 1]) != 's') || !isCap) && <span class='macro'>isalpha(c)<span class='expansion'>(__ctype_b[(int)((c))] & (unsigned short int)_ISalpha)</span></span>));</td></tr>
|
---|
1594 | <tr><td class="num" id="LN1515">1515</td><td class="line"> end++, c = text[end], isAlpha = <span class='macro'>isalpha(c)<span class='expansion'>(__ctype_b[(int)((c))] & (unsigned short int)_ISalpha)</span></span>, isApost = (c == '\'')) {}</td></tr>
|
---|
1595 | <tr><td class="num" id="LN1516">1516</td><td class="line"> </td></tr>
|
---|
1596 | <tr><td class="num" id="LN1517">1517</td><td class="line"> length = end - start;</td></tr>
|
---|
1597 | <tr><td class="num" id="LN1518">1518</td><td class="line"> BString srcWord;</td></tr>
|
---|
1598 | <tr><td class="num" id="LN1519">1519</td><td class="line"> srcWord.SetTo(text + start, length);</td></tr>
|
---|
1599 | <tr><td class="num" id="LN1520">1520</td><td class="line"> </td></tr>
|
---|
1600 | <tr><td class="num" id="LN1521">1521</td><td class="line"> <span class='keyword'>bool</span> foundWord = <span class='keyword'>false</span>;</td></tr>
|
---|
1601 | <tr><td class="num" id="LN1522">1522</td><td class="line"> BList matches;</td></tr>
|
---|
1602 | <tr><td class="num" id="LN1523">1523</td><td class="line"> BString *string;</td></tr>
|
---|
1603 | <tr><td class="num" id="LN1524">1524</td><td class="line"> </td></tr>
|
---|
1604 | <tr><td class="num" id="LN1525">1525</td><td class="line"> BMenuItem *menuItem;</td></tr>
|
---|
1605 | <tr><td class="num" id="LN1526">1526</td><td class="line"> BPopUpMenu menu(<span class='string_literal'>"Words"</span>, <span class='keyword'>false</span>, <span class='keyword'>false</span>);</td></tr>
|
---|
1606 | <tr><td class="num" id="LN1527">1527</td><td class="line"> </td></tr>
|
---|
1607 | <tr><td class="num" id="LN1528">1528</td><td class="line"> <span class='keyword'>for</span> (int32 i = 0; i < gDictCount; i++)</td></tr>
|
---|
1608 | <tr><td class="num" id="LN1529">1529</td><td class="line"> gWords[i]->FindBestMatches(&matches,</td></tr>
|
---|
1609 | <tr><td class="num" id="LN1530">1530</td><td class="line"> srcWord.String());</td></tr>
|
---|
1610 | <tr><td class="num" id="LN1531">1531</td><td class="line"> </td></tr>
|
---|
1611 | <tr><td class="num" id="LN1532">1532</td><td class="line"> <span class='keyword'>if</span> (matches.CountItems()) {</td></tr>
|
---|
1612 | <tr><td class="num" id="LN1533">1533</td><td class="line"> sort_word_list(&matches, srcWord.String());</td></tr>
|
---|
1613 | <tr><td class="num" id="LN1534">1534</td><td class="line"> <span class='keyword'>for</span> (int32 i = 0; (string = (BString *)matches.ItemAt(i)) != <span class='macro'>NULL<span class='expansion'>__null</span></span>; i++) {</td></tr>
|
---|
1614 | <tr><td class="num" id="LN1535">1535</td><td class="line"> menu.AddItem((menuItem = <span class='keyword'>new</span> BMenuItem(string->String(), <span class='macro'>NULL<span class='expansion'>__null</span></span>)));</td></tr>
|
---|
1615 | <tr><td class="num" id="LN1536">1536</td><td class="line"> <span class='keyword'>if</span> (!strcasecmp(string->String(), srcWord.String())) {</td></tr>
|
---|
1616 | <tr><td class="num" id="LN1537">1537</td><td class="line"> menuItem->SetEnabled(<span class='keyword'>false</span>);</td></tr>
|
---|
1617 | <tr><td class="num" id="LN1538">1538</td><td class="line"> foundWord = <span class='keyword'>true</span>;</td></tr>
|
---|
1618 | <tr><td class="num" id="LN1539">1539</td><td class="line"> }</td></tr>
|
---|
1619 | <tr><td class="num" id="LN1540">1540</td><td class="line"> <span class='keyword'>delete</span> string;</td></tr>
|
---|
1620 | <tr><td class="num" id="LN1541">1541</td><td class="line"> }</td></tr>
|
---|
1621 | <tr><td class="num" id="LN1542">1542</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
1622 | <tr><td class="num" id="LN1543">1543</td><td class="line"> menuItem = <span class='keyword'>new</span> BMenuItem(<span class='macro'>B_TRANSLATE(<span class='string_literal'>"No matches"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("No matches"<br>), "Mail")</span></span>, <span class='macro'>NULL<span class='expansion'>__null</span></span>);</td></tr>
|
---|
1623 | <tr><td class="num" id="LN1544">1544</td><td class="line"> menuItem->SetEnabled(<span class='keyword'>false</span>);</td></tr>
|
---|
1624 | <tr><td class="num" id="LN1545">1545</td><td class="line"> menu.AddItem(menuItem);</td></tr>
|
---|
1625 | <tr><td class="num" id="LN1546">1546</td><td class="line"> }</td></tr>
|
---|
1626 | <tr><td class="num" id="LN1547">1547</td><td class="line"> </td></tr>
|
---|
1627 | <tr><td class="num" id="LN1548">1548</td><td class="line"> BMenuItem *addItem = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
1628 | <tr><td class="num" id="LN1549">1549</td><td class="line"> <span class='keyword'>if</span> (!foundWord && gUserDict >= 0) {</td></tr>
|
---|
1629 | <tr><td class="num" id="LN1550">1550</td><td class="line"> menu.AddSeparatorItem();</td></tr>
|
---|
1630 | <tr><td class="num" id="LN1551">1551</td><td class="line"> addItem = <span class='keyword'>new</span> BMenuItem(<span class='macro'>B_TRANSLATE(<span class='string_literal'>"Add"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Add"<br>), "Mail")</span></span>, <span class='macro'>NULL<span class='expansion'>__null</span></span>);</td></tr>
|
---|
1631 | <tr><td class="num" id="LN1552">1552</td><td class="line"> menu.AddItem(addItem);</td></tr>
|
---|
1632 | <tr><td class="num" id="LN1553">1553</td><td class="line"> }</td></tr>
|
---|
1633 | <tr><td class="num" id="LN1554">1554</td><td class="line"> </td></tr>
|
---|
1634 | <tr><td class="num" id="LN1555">1555</td><td class="line"> point = ConvertToScreen(where);</td></tr>
|
---|
1635 | <tr><td class="num" id="LN1556">1556</td><td class="line"> <span class='keyword'>if</span> ((menuItem = menu.Go(point, <span class='keyword'>false</span>, <span class='keyword'>false</span>)) != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
1636 | <tr><td class="num" id="LN1557">1557</td><td class="line"> <span class='keyword'>if</span> (menuItem == addItem) {</td></tr>
|
---|
1637 | <tr><td class="num" id="LN1558">1558</td><td class="line"> BString newItem(srcWord.String());</td></tr>
|
---|
1638 | <tr><td class="num" id="LN1559">1559</td><td class="line"> newItem << <span class='string_literal'>"\n"</span>;</td></tr>
|
---|
1639 | <tr><td class="num" id="LN1560">1560</td><td class="line"> gWords[gUserDict]->InitIndex();</td></tr>
|
---|
1640 | <tr><td class="num" id="LN1561">1561</td><td class="line"> gExactWords[gUserDict]->InitIndex();</td></tr>
|
---|
1641 | <tr><td class="num" id="LN1562">1562</td><td class="line"> gUserDictFile->Write(newItem.String(), newItem.Length());</td></tr>
|
---|
1642 | <tr><td class="num" id="LN1563">1563</td><td class="line"> gWords[gUserDict]->BuildIndex();</td></tr>
|
---|
1643 | <tr><td class="num" id="LN1564">1564</td><td class="line"> gExactWords[gUserDict]->BuildIndex();</td></tr>
|
---|
1644 | <tr><td class="num" id="LN1565">1565</td><td class="line"> </td></tr>
|
---|
1645 | <tr><td class="num" id="LN1566">1566</td><td class="line"> <span class='keyword'>if</span> (fSpellCheck)</td></tr>
|
---|
1646 | <tr><td class="num" id="LN1567">1567</td><td class="line"> CheckSpelling(0, TextLength());</td></tr>
|
---|
1647 | <tr><td class="num" id="LN1568">1568</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
1648 | <tr><td class="num" id="LN1569">1569</td><td class="line"> int32 len = strlen(menuItem->Label());</td></tr>
|
---|
1649 | <tr><td class="num" id="LN1570">1570</td><td class="line"> Select(start, start);</td></tr>
|
---|
1650 | <tr><td class="num" id="LN1571">1571</td><td class="line"> Delete(start, end);</td></tr>
|
---|
1651 | <tr><td class="num" id="LN1572">1572</td><td class="line"> Insert(start, menuItem->Label(), len);</td></tr>
|
---|
1652 | <tr><td class="num" id="LN1573">1573</td><td class="line"> Select(start+len, start+len);</td></tr>
|
---|
1653 | <tr><td class="num" id="LN1574">1574</td><td class="line"> }</td></tr>
|
---|
1654 | <tr><td class="num" id="LN1575">1575</td><td class="line"> }</td></tr>
|
---|
1655 | <tr><td class="num" id="LN1576">1576</td><td class="line"> }</td></tr>
|
---|
1656 | <tr><td class="num" id="LN1577">1577</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
1657 | <tr><td class="num" id="LN1578">1578</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (fSpellCheck && IsEditable()) {</td></tr>
|
---|
1658 | <tr><td class="num" id="LN1579">1579</td><td class="line"> int32 start, end;</td></tr>
|
---|
1659 | <tr><td class="num" id="LN1580">1580</td><td class="line"> </td></tr>
|
---|
1660 | <tr><td class="num" id="LN1581">1581</td><td class="line"> GetSelection(&start, &end);</td></tr>
|
---|
1661 | <tr><td class="num" id="LN1582">1582</td><td class="line"> FindSpellBoundry(1, start, &start, &end);</td></tr>
|
---|
1662 | <tr><td class="num" id="LN1583">1583</td><td class="line"> CheckSpelling(start, end);</td></tr>
|
---|
1663 | <tr><td class="num" id="LN1584">1584</td><td class="line"> }</td></tr>
|
---|
1664 | <tr><td class="num" id="LN1585">1585</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
1665 | <tr><td class="num" id="LN1586">1586</td><td class="line"> <span class='comment'>// is not editable, look for enclosures/links</span></td></tr>
|
---|
1666 | <tr><td class="num" id="LN1587">1587</td><td class="line"> </td></tr>
|
---|
1667 | <tr><td class="num" id="LN1588">1588</td><td class="line"> int32 clickOffset = OffsetAt(where);</td></tr>
|
---|
1668 | <tr><td class="num" id="LN1589">1589</td><td class="line"> int32 items = fEnclosures->CountItems();</td></tr>
|
---|
1669 | <tr><td class="num" id="LN1590">1590</td><td class="line"> <span class='keyword'>for</span> (int32 loop = 0; loop < items; loop++) {</td></tr>
|
---|
1670 | <tr><td class="num" id="LN1591">1591</td><td class="line"> hyper_text *enclosure = (hyper_text*) fEnclosures->ItemAt(loop);</td></tr>
|
---|
1671 | <tr><td class="num" id="LN1592">1592</td><td class="line"> <span class='keyword'>if</span> (clickOffset < enclosure->text_start || clickOffset >= enclosure->text_end)</td></tr>
|
---|
1672 | <tr><td class="num" id="LN1593">1593</td><td class="line"> <span class='keyword'>continue</span>;</td></tr>
|
---|
1673 | <tr><td class="num" id="LN1594">1594</td><td class="line"> </td></tr>
|
---|
1674 | <tr><td class="num" id="LN1595">1595</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1675 | <tr><td class="num" id="LN1596">1596</td><td class="line"> <span class='comment'>// The user is clicking on this attachment</span></td></tr>
|
---|
1676 | <tr><td class="num" id="LN1597">1597</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1677 | <tr><td class="num" id="LN1598">1598</td><td class="line"> </td></tr>
|
---|
1678 | <tr><td class="num" id="LN1599">1599</td><td class="line"> int32 start;</td></tr>
|
---|
1679 | <tr><td class="num" id="LN1600">1600</td><td class="line"> int32 finish;</td></tr>
|
---|
1680 | <tr><td class="num" id="LN1601">1601</td><td class="line"> Select(enclosure->text_start, enclosure->text_end);</td></tr>
|
---|
1681 | <tr><td class="num" id="LN1602">1602</td><td class="line"> GetSelection(&start, &finish);</td></tr>
|
---|
1682 | <tr><td class="num" id="LN1603">1603</td><td class="line"> Window()->UpdateIfNeeded();</td></tr>
|
---|
1683 | <tr><td class="num" id="LN1604">1604</td><td class="line"> </td></tr>
|
---|
1684 | <tr><td class="num" id="LN1605">1605</td><td class="line"> <span class='keyword'>bool</span> drag = <span class='keyword'>false</span>;</td></tr>
|
---|
1685 | <tr><td class="num" id="LN1606">1606</td><td class="line"> <span class='keyword'>bool</span> held = <span class='keyword'>false</span>;</td></tr>
|
---|
1686 | <tr><td class="num" id="LN1607">1607</td><td class="line"> uint32 buttons = 0;</td></tr>
|
---|
1687 | <tr><td class="num" id="LN1608">1608</td><td class="line"> <span class='keyword'>if</span> (Window()->CurrentMessage()) {</td></tr>
|
---|
1688 | <tr><td class="num" id="LN1609">1609</td><td class="line"> Window()->CurrentMessage()->FindInt32(<span class='string_literal'>"buttons"</span>,</td></tr>
|
---|
1689 | <tr><td class="num" id="LN1610">1610</td><td class="line"> (int32 *) &buttons);</td></tr>
|
---|
1690 | <tr><td class="num" id="LN1611">1611</td><td class="line"> }</td></tr>
|
---|
1691 | <tr><td class="num" id="LN1612">1612</td><td class="line"> </td></tr>
|
---|
1692 | <tr><td class="num" id="LN1613">1613</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1693 | <tr><td class="num" id="LN1614">1614</td><td class="line"> <span class='comment'>// If this is the primary button, wait to see if the user is going</span></td></tr>
|
---|
1694 | <tr><td class="num" id="LN1615">1615</td><td class="line"> <span class='comment'>// to single click, hold, or drag.</span></td></tr>
|
---|
1695 | <tr><td class="num" id="LN1616">1616</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1696 | <tr><td class="num" id="LN1617">1617</td><td class="line"> <span class='keyword'>if</span> (buttons != B_SECONDARY_MOUSE_BUTTON) {</td></tr>
|
---|
1697 | <tr><td class="num" id="LN1618">1618</td><td class="line"> BPoint point = where;</td></tr>
|
---|
1698 | <tr><td class="num" id="LN1619">1619</td><td class="line"> bigtime_t popupDelay;</td></tr>
|
---|
1699 | <tr><td class="num" id="LN1620">1620</td><td class="line"> get_click_speed(&popupDelay);</td></tr>
|
---|
1700 | <tr><td class="num" id="LN1621">1621</td><td class="line"> popupDelay *= 2;</td></tr>
|
---|
1701 | <tr><td class="num" id="LN1622">1622</td><td class="line"> popupDelay += system_time();</td></tr>
|
---|
1702 | <tr><td class="num" id="LN1623">1623</td><td class="line"> <span class='keyword'>while</span> (buttons && abs((<span class='keyword'>int</span>)(point.x - where.x)) < 4</td></tr>
|
---|
1703 | <tr><td class="num" id="LN1624">1624</td><td class="line"> && abs((<span class='keyword'>int</span>)(point.y - where.y)) < 4</td></tr>
|
---|
1704 | <tr><td class="num" id="LN1625">1625</td><td class="line"> && system_time() < popupDelay) {</td></tr>
|
---|
1705 | <tr><td class="num" id="LN1626">1626</td><td class="line"> snooze(10000);</td></tr>
|
---|
1706 | <tr><td class="num" id="LN1627">1627</td><td class="line"> GetMouse(&point, &buttons);</td></tr>
|
---|
1707 | <tr><td class="num" id="LN1628">1628</td><td class="line"> }</td></tr>
|
---|
1708 | <tr><td class="num" id="LN1629">1629</td><td class="line"> </td></tr>
|
---|
1709 | <tr><td class="num" id="LN1630">1630</td><td class="line"> <span class='keyword'>if</span> (system_time() < popupDelay) {</td></tr>
|
---|
1710 | <tr><td class="num" id="LN1631">1631</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1711 | <tr><td class="num" id="LN1632">1632</td><td class="line"> <span class='comment'>// The user either dragged this or released the button.</span></td></tr>
|
---|
1712 | <tr><td class="num" id="LN1633">1633</td><td class="line"> <span class='comment'>// check if it was dragged.</span></td></tr>
|
---|
1713 | <tr><td class="num" id="LN1634">1634</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1714 | <tr><td class="num" id="LN1635">1635</td><td class="line"> <span class='keyword'>if</span> (!(abs((<span class='keyword'>int</span>)(point.x - where.x)) < 4</td></tr>
|
---|
1715 | <tr><td class="num" id="LN1636">1636</td><td class="line"> && abs((<span class='keyword'>int</span>)(point.y - where.y)) < 4) && buttons)</td></tr>
|
---|
1716 | <tr><td class="num" id="LN1637">1637</td><td class="line"> drag = <span class='keyword'>true</span>;</td></tr>
|
---|
1717 | <tr><td class="num" id="LN1638">1638</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
1718 | <tr><td class="num" id="LN1639">1639</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1719 | <tr><td class="num" id="LN1640">1640</td><td class="line"> <span class='comment'>// The user held the button down.</span></td></tr>
|
---|
1720 | <tr><td class="num" id="LN1641">1641</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1721 | <tr><td class="num" id="LN1642">1642</td><td class="line"> held = <span class='keyword'>true</span>;</td></tr>
|
---|
1722 | <tr><td class="num" id="LN1643">1643</td><td class="line"> }</td></tr>
|
---|
1723 | <tr><td class="num" id="LN1644">1644</td><td class="line"> }</td></tr>
|
---|
1724 | <tr><td class="num" id="LN1645">1645</td><td class="line"> </td></tr>
|
---|
1725 | <tr><td class="num" id="LN1646">1646</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1726 | <tr><td class="num" id="LN1647">1647</td><td class="line"> <span class='comment'>// If the user has right clicked on this menu,</span></td></tr>
|
---|
1727 | <tr><td class="num" id="LN1648">1648</td><td class="line"> <span class='comment'>// or held the button down on it for a while,</span></td></tr>
|
---|
1728 | <tr><td class="num" id="LN1649">1649</td><td class="line"> <span class='comment'>// pop up a context menu.</span></td></tr>
|
---|
1729 | <tr><td class="num" id="LN1650">1650</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1730 | <tr><td class="num" id="LN1651">1651</td><td class="line"> <span class='keyword'>if</span> (buttons == B_SECONDARY_MOUSE_BUTTON || held) {</td></tr>
|
---|
1731 | <tr><td class="num" id="LN1652">1652</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1732 | <tr><td class="num" id="LN1653">1653</td><td class="line"> <span class='comment'>// Right mouse click... Display a menu</span></td></tr>
|
---|
1733 | <tr><td class="num" id="LN1654">1654</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1734 | <tr><td class="num" id="LN1655">1655</td><td class="line"> BPoint point = where;</td></tr>
|
---|
1735 | <tr><td class="num" id="LN1656">1656</td><td class="line"> ConvertToScreen(&point);</td></tr>
|
---|
1736 | <tr><td class="num" id="LN1657">1657</td><td class="line"> </td></tr>
|
---|
1737 | <tr><td class="num" id="LN1658">1658</td><td class="line"> BMenuItem *item;</td></tr>
|
---|
1738 | <tr><td class="num" id="LN1659">1659</td><td class="line"> <span class='keyword'>if</span> ((enclosure->type != TYPE_ENCLOSURE)</td></tr>
|
---|
1739 | <tr><td class="num" id="LN1660">1660</td><td class="line"> && (enclosure->type != TYPE_BE_ENCLOSURE))</td></tr>
|
---|
1740 | <tr><td class="num" id="LN1661">1661</td><td class="line"> item = fLinkMenu->Go(point, <span class='keyword'>true</span>);</td></tr>
|
---|
1741 | <tr><td class="num" id="LN1662">1662</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
1742 | <tr><td class="num" id="LN1663">1663</td><td class="line"> item = fEnclosureMenu->Go(point, <span class='keyword'>true</span>);</td></tr>
|
---|
1743 | <tr><td class="num" id="LN1664">1664</td><td class="line"> </td></tr>
|
---|
1744 | <tr><td class="num" id="LN1665">1665</td><td class="line"> BMessage *msg;</td></tr>
|
---|
1745 | <tr><td class="num" id="LN1666">1666</td><td class="line"> <span class='keyword'>if</span> (item && (msg = item->Message()) != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
1746 | <tr><td class="num" id="LN1667">1667</td><td class="line"> <span class='keyword'>if</span> (msg->what == M_SAVE) {</td></tr>
|
---|
1747 | <tr><td class="num" id="LN1668">1668</td><td class="line"> <span class='keyword'>if</span> (fPanel)</td></tr>
|
---|
1748 | <tr><td class="num" id="LN1669">1669</td><td class="line"> fPanel->SetEnclosure(enclosure);</td></tr>
|
---|
1749 | <tr><td class="num" id="LN1670">1670</td><td class="line"> <span class='keyword'>else</span> {</td></tr>
|
---|
1750 | <tr><td class="num" id="LN1671">1671</td><td class="line"> fPanel = <span class='keyword'>new</span> TSavePanel(enclosure, <span class='keyword'>this</span>);</td></tr>
|
---|
1751 | <tr><td class="num" id="LN1672">1672</td><td class="line"> fPanel->Window()->Show();</td></tr>
|
---|
1752 | <tr><td class="num" id="LN1673">1673</td><td class="line"> }</td></tr>
|
---|
1753 | <tr><td class="num" id="LN1674">1674</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (msg->what == M_COPY) {</td></tr>
|
---|
1754 | <tr><td class="num" id="LN1675">1675</td><td class="line"> <span class='comment'>// copy link location to clipboard</span></td></tr>
|
---|
1755 | <tr><td class="num" id="LN1676">1676</td><td class="line"> </td></tr>
|
---|
1756 | <tr><td class="num" id="LN1677">1677</td><td class="line"> <span class='keyword'>if</span> (be_clipboard->Lock()) {</td></tr>
|
---|
1757 | <tr><td class="num" id="LN1678">1678</td><td class="line"> be_clipboard->Clear();</td></tr>
|
---|
1758 | <tr><td class="num" id="LN1679">1679</td><td class="line"> </td></tr>
|
---|
1759 | <tr><td class="num" id="LN1680">1680</td><td class="line"> BMessage *clip;</td></tr>
|
---|
1760 | <tr><td class="num" id="LN1681">1681</td><td class="line"> <span class='keyword'>if</span> ((clip = be_clipboard->Data()) != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
1761 | <tr><td class="num" id="LN1682">1682</td><td class="line"> clip->AddData(<span class='string_literal'>"text/plain"</span>, B_MIME_TYPE,</td></tr>
|
---|
1762 | <tr><td class="num" id="LN1683">1683</td><td class="line"> enclosure->name, strlen(enclosure->name));</td></tr>
|
---|
1763 | <tr><td class="num" id="LN1684">1684</td><td class="line"> be_clipboard->Commit();</td></tr>
|
---|
1764 | <tr><td class="num" id="LN1685">1685</td><td class="line"> }</td></tr>
|
---|
1765 | <tr><td class="num" id="LN1686">1686</td><td class="line"> be_clipboard->Unlock();</td></tr>
|
---|
1766 | <tr><td class="num" id="LN1687">1687</td><td class="line"> }</td></tr>
|
---|
1767 | <tr><td class="num" id="LN1688">1688</td><td class="line"> } <span class='keyword'>else</span></td></tr>
|
---|
1768 | <tr><td class="num" id="LN1689">1689</td><td class="line"> Open(enclosure);</td></tr>
|
---|
1769 | <tr><td class="num" id="LN1690">1690</td><td class="line"> }</td></tr>
|
---|
1770 | <tr><td class="num" id="LN1691">1691</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
1771 | <tr><td class="num" id="LN1692">1692</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1772 | <tr><td class="num" id="LN1693">1693</td><td class="line"> <span class='comment'>// Left button. If the user single clicks, open this link.</span></td></tr>
|
---|
1773 | <tr><td class="num" id="LN1694">1694</td><td class="line"> <span class='comment'>// Otherwise, initiate a drag.</span></td></tr>
|
---|
1774 | <tr><td class="num" id="LN1695">1695</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1775 | <tr><td class="num" id="LN1696">1696</td><td class="line"> <span class='keyword'>if</span> (drag) {</td></tr>
|
---|
1776 | <tr><td class="num" id="LN1697">1697</td><td class="line"> BMessage dragMessage(B_SIMPLE_DATA);</td></tr>
|
---|
1777 | <tr><td class="num" id="LN1698">1698</td><td class="line"> dragMessage.AddInt32(<span class='string_literal'>"be:actions"</span>, B_COPY_TARGET);</td></tr>
|
---|
1778 | <tr><td class="num" id="LN1699">1699</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:types"</span>, B_FILE_MIME_TYPE);</td></tr>
|
---|
1779 | <tr><td class="num" id="LN1700">1700</td><td class="line"> <span class='keyword'>switch</span> (enclosure->type) {</td></tr>
|
---|
1780 | <tr><td class="num" id="LN1701">1701</td><td class="line"> <span class='keyword'>case</span> TYPE_BE_ENCLOSURE:</td></tr>
|
---|
1781 | <tr><td class="num" id="LN1702">1702</td><td class="line"> <span class='keyword'>case</span> TYPE_ENCLOSURE:</td></tr>
|
---|
1782 | <tr><td class="num" id="LN1703">1703</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1783 | <tr><td class="num" id="LN1704">1704</td><td class="line"> <span class='comment'>// Attachment. The type is specified in the message.</span></td></tr>
|
---|
1784 | <tr><td class="num" id="LN1705">1705</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1785 | <tr><td class="num" id="LN1706">1706</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:types"</span>, B_FILE_MIME_TYPE);</td></tr>
|
---|
1786 | <tr><td class="num" id="LN1707">1707</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:filetypes"</span>,</td></tr>
|
---|
1787 | <tr><td class="num" id="LN1708">1708</td><td class="line"> enclosure->content_type ? enclosure->content_type : <span class='string_literal'>""</span>);</td></tr>
|
---|
1788 | <tr><td class="num" id="LN1709">1709</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:clip_name"</span>, enclosure->name);</td></tr>
|
---|
1789 | <tr><td class="num" id="LN1710">1710</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1790 | <tr><td class="num" id="LN1711">1711</td><td class="line"> </td></tr>
|
---|
1791 | <tr><td class="num" id="LN1712">1712</td><td class="line"> <span class='keyword'>case</span> TYPE_URL:</td></tr>
|
---|
1792 | <tr><td class="num" id="LN1713">1713</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1793 | <tr><td class="num" id="LN1714">1714</td><td class="line"> <span class='comment'>// URL. The user can drag it into the tracker to</span></td></tr>
|
---|
1794 | <tr><td class="num" id="LN1715">1715</td><td class="line"> <span class='comment'>// create a bookmark file.</span></td></tr>
|
---|
1795 | <tr><td class="num" id="LN1716">1716</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1796 | <tr><td class="num" id="LN1717">1717</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:types"</span>, B_FILE_MIME_TYPE);</td></tr>
|
---|
1797 | <tr><td class="num" id="LN1718">1718</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:filetypes"</span>,</td></tr>
|
---|
1798 | <tr><td class="num" id="LN1719">1719</td><td class="line"> <span class='string_literal'>"application/x-vnd.Be-bookmark"</span>);</td></tr>
|
---|
1799 | <tr><td class="num" id="LN1720">1720</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:filetypes"</span>, <span class='string_literal'>"text/plain"</span>);</td></tr>
|
---|
1800 | <tr><td class="num" id="LN1721">1721</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:clip_name"</span>, <span class='string_literal'>"Bookmark"</span>);</td></tr>
|
---|
1801 | <tr><td class="num" id="LN1722">1722</td><td class="line"> </td></tr>
|
---|
1802 | <tr><td class="num" id="LN1723">1723</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:url"</span>, enclosure->name);</td></tr>
|
---|
1803 | <tr><td class="num" id="LN1724">1724</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1804 | <tr><td class="num" id="LN1725">1725</td><td class="line"> </td></tr>
|
---|
1805 | <tr><td class="num" id="LN1726">1726</td><td class="line"> <span class='keyword'>case</span> TYPE_MAILTO:</td></tr>
|
---|
1806 | <tr><td class="num" id="LN1727">1727</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1807 | <tr><td class="num" id="LN1728">1728</td><td class="line"> <span class='comment'>// Mailto address. The user can drag it into the</span></td></tr>
|
---|
1808 | <tr><td class="num" id="LN1729">1729</td><td class="line"> <span class='comment'>// tracker to create a people file.</span></td></tr>
|
---|
1809 | <tr><td class="num" id="LN1730">1730</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1810 | <tr><td class="num" id="LN1731">1731</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:types"</span>, B_FILE_MIME_TYPE);</td></tr>
|
---|
1811 | <tr><td class="num" id="LN1732">1732</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:filetypes"</span>,</td></tr>
|
---|
1812 | <tr><td class="num" id="LN1733">1733</td><td class="line"> <span class='string_literal'>"application/x-person"</span>);</td></tr>
|
---|
1813 | <tr><td class="num" id="LN1734">1734</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:filetypes"</span>, <span class='string_literal'>"text/plain"</span>);</td></tr>
|
---|
1814 | <tr><td class="num" id="LN1735">1735</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:clip_name"</span>, <span class='string_literal'>"Person"</span>);</td></tr>
|
---|
1815 | <tr><td class="num" id="LN1736">1736</td><td class="line"> </td></tr>
|
---|
1816 | <tr><td class="num" id="LN1737">1737</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:email"</span>, enclosure->name);</td></tr>
|
---|
1817 | <tr><td class="num" id="LN1738">1738</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1818 | <tr><td class="num" id="LN1739">1739</td><td class="line"> </td></tr>
|
---|
1819 | <tr><td class="num" id="LN1740">1740</td><td class="line"> <span class='keyword'>default</span>:</td></tr>
|
---|
1820 | <tr><td class="num" id="LN1741">1741</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1821 | <tr><td class="num" id="LN1742">1742</td><td class="line"> <span class='comment'>// Otherwise it doesn't have a type that I know how</span></td></tr>
|
---|
1822 | <tr><td class="num" id="LN1743">1743</td><td class="line"> <span class='comment'>// to save. It won't have any types and if any</span></td></tr>
|
---|
1823 | <tr><td class="num" id="LN1744">1744</td><td class="line"> <span class='comment'>// program wants to accept it, more power to them.</span></td></tr>
|
---|
1824 | <tr><td class="num" id="LN1745">1745</td><td class="line"> <span class='comment'>// (tracker won't.)</span></td></tr>
|
---|
1825 | <tr><td class="num" id="LN1746">1746</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1826 | <tr><td class="num" id="LN1747">1747</td><td class="line"> dragMessage.AddString(<span class='string_literal'>"be:clip_name"</span>, <span class='string_literal'>"Hyperlink"</span>);</td></tr>
|
---|
1827 | <tr><td class="num" id="LN1748">1748</td><td class="line"> }</td></tr>
|
---|
1828 | <tr><td class="num" id="LN1749">1749</td><td class="line"> </td></tr>
|
---|
1829 | <tr><td class="num" id="LN1750">1750</td><td class="line"> BMessage data;</td></tr>
|
---|
1830 | <tr><td class="num" id="LN1751">1751</td><td class="line"> data.AddPointer(<span class='string_literal'>"enclosure"</span>, enclosure);</td></tr>
|
---|
1831 | <tr><td class="num" id="LN1752">1752</td><td class="line"> dragMessage.AddMessage(<span class='string_literal'>"be:originator-data"</span>, &data);</td></tr>
|
---|
1832 | <tr><td class="num" id="LN1753">1753</td><td class="line"> </td></tr>
|
---|
1833 | <tr><td class="num" id="LN1754">1754</td><td class="line"> BRegion selectRegion;</td></tr>
|
---|
1834 | <tr><td class="num" id="LN1755">1755</td><td class="line"> GetTextRegion(start, finish, &selectRegion);</td></tr>
|
---|
1835 | <tr><td class="num" id="LN1756">1756</td><td class="line"> DragMessage(&dragMessage, selectRegion.Frame(), <span class='keyword'>this</span>);</td></tr>
|
---|
1836 | <tr><td class="num" id="LN1757">1757</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
1837 | <tr><td class="num" id="LN1758">1758</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1838 | <tr><td class="num" id="LN1759">1759</td><td class="line"> <span class='comment'>// User Single clicked on the attachment. Open it.</span></td></tr>
|
---|
1839 | <tr><td class="num" id="LN1760">1760</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
1840 | <tr><td class="num" id="LN1761">1761</td><td class="line"> Open(enclosure);</td></tr>
|
---|
1841 | <tr><td class="num" id="LN1762">1762</td><td class="line"> }</td></tr>
|
---|
1842 | <tr><td class="num" id="LN1763">1763</td><td class="line"> }</td></tr>
|
---|
1843 | <tr><td class="num" id="LN1764">1764</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
1844 | <tr><td class="num" id="LN1765">1765</td><td class="line"> }</td></tr>
|
---|
1845 | <tr><td class="num" id="LN1766">1766</td><td class="line"> }</td></tr>
|
---|
1846 | <tr><td class="num" id="LN1767">1767</td><td class="line"> BTextView::MouseDown(where);</td></tr>
|
---|
1847 | <tr><td class="num" id="LN1768">1768</td><td class="line">}</td></tr>
|
---|
1848 | <tr><td class="num" id="LN1769">1769</td><td class="line"> </td></tr>
|
---|
1849 | <tr><td class="num" id="LN1770">1770</td><td class="line"> </td></tr>
|
---|
1850 | <tr><td class="num" id="LN1771">1771</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1851 | <tr><td class="num" id="LN1772">1772</td><td class="line">TTextView::MouseMoved(BPoint where, uint32 code, <span class='keyword'>const</span> BMessage *msg)</td></tr>
|
---|
1852 | <tr><td class="num" id="LN1773">1773</td><td class="line">{</td></tr>
|
---|
1853 | <tr><td class="num" id="LN1774">1774</td><td class="line"> int32 start = OffsetAt(where);</td></tr>
|
---|
1854 | <tr><td class="num" id="LN1775">1775</td><td class="line"> </td></tr>
|
---|
1855 | <tr><td class="num" id="LN1776">1776</td><td class="line"> <span class='keyword'>for</span> (int32 loop = fEnclosures->CountItems(); loop-- > 0;) {</td></tr>
|
---|
1856 | <tr><td class="num" id="LN1777">1777</td><td class="line"> hyper_text *enclosure = (hyper_text *)fEnclosures->ItemAt(loop);</td></tr>
|
---|
1857 | <tr><td class="num" id="LN1778">1778</td><td class="line"> <span class='keyword'>if</span> ((start >= enclosure->text_start) && (start < enclosure->text_end)) {</td></tr>
|
---|
1858 | <tr><td class="num" id="LN1779">1779</td><td class="line"> <span class='keyword'>if</span> (!fCursor)</td></tr>
|
---|
1859 | <tr><td class="num" id="LN1780">1780</td><td class="line"> SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);</td></tr>
|
---|
1860 | <tr><td class="num" id="LN1781">1781</td><td class="line"> fCursor = <span class='keyword'>true</span>;</td></tr>
|
---|
1861 | <tr><td class="num" id="LN1782">1782</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
1862 | <tr><td class="num" id="LN1783">1783</td><td class="line"> }</td></tr>
|
---|
1863 | <tr><td class="num" id="LN1784">1784</td><td class="line"> }</td></tr>
|
---|
1864 | <tr><td class="num" id="LN1785">1785</td><td class="line"> </td></tr>
|
---|
1865 | <tr><td class="num" id="LN1786">1786</td><td class="line"> <span class='keyword'>if</span> (fCursor) {</td></tr>
|
---|
1866 | <tr><td class="num" id="LN1787">1787</td><td class="line"> SetViewCursor(B_CURSOR_I_BEAM);</td></tr>
|
---|
1867 | <tr><td class="num" id="LN1788">1788</td><td class="line"> fCursor = <span class='keyword'>false</span>;</td></tr>
|
---|
1868 | <tr><td class="num" id="LN1789">1789</td><td class="line"> }</td></tr>
|
---|
1869 | <tr><td class="num" id="LN1790">1790</td><td class="line"> </td></tr>
|
---|
1870 | <tr><td class="num" id="LN1791">1791</td><td class="line"> BTextView::MouseMoved(where, code, msg);</td></tr>
|
---|
1871 | <tr><td class="num" id="LN1792">1792</td><td class="line">}</td></tr>
|
---|
1872 | <tr><td class="num" id="LN1793">1793</td><td class="line"> </td></tr>
|
---|
1873 | <tr><td class="num" id="LN1794">1794</td><td class="line"> </td></tr>
|
---|
1874 | <tr><td class="num" id="LN1795">1795</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1875 | <tr><td class="num" id="LN1796">1796</td><td class="line">TTextView::ClearList()</td></tr>
|
---|
1876 | <tr><td class="num" id="LN1797">1797</td><td class="line">{</td></tr>
|
---|
1877 | <tr><td class="num" id="LN1798">1798</td><td class="line"> hyper_text *enclosure;</td></tr>
|
---|
1878 | <tr><td class="num" id="LN1799">1799</td><td class="line"> <span class='keyword'>while</span> ((enclosure = (hyper_text *)fEnclosures->FirstItem()) != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
1879 | <tr><td class="num" id="LN1800">1800</td><td class="line"> fEnclosures->RemoveItem(enclosure);</td></tr>
|
---|
1880 | <tr><td class="num" id="LN1801">1801</td><td class="line"> </td></tr>
|
---|
1881 | <tr><td class="num" id="LN1802">1802</td><td class="line"> <span class='keyword'>if</span> (enclosure->name)</td></tr>
|
---|
1882 | <tr><td class="num" id="LN1803">1803</td><td class="line"> free(enclosure->name);</td></tr>
|
---|
1883 | <tr><td class="num" id="LN1804">1804</td><td class="line"> <span class='keyword'>if</span> (enclosure->content_type)</td></tr>
|
---|
1884 | <tr><td class="num" id="LN1805">1805</td><td class="line"> free(enclosure->content_type);</td></tr>
|
---|
1885 | <tr><td class="num" id="LN1806">1806</td><td class="line"> <span class='keyword'>if</span> (enclosure->encoding)</td></tr>
|
---|
1886 | <tr><td class="num" id="LN1807">1807</td><td class="line"> free(enclosure->encoding);</td></tr>
|
---|
1887 | <tr><td class="num" id="LN1808">1808</td><td class="line"> <span class='keyword'>if</span> (enclosure->have_ref && !enclosure->saved) {</td></tr>
|
---|
1888 | <tr><td class="num" id="LN1809">1809</td><td class="line"> BEntry entry(&enclosure->ref);</td></tr>
|
---|
1889 | <tr><td class="num" id="LN1810">1810</td><td class="line"> entry.Remove();</td></tr>
|
---|
1890 | <tr><td class="num" id="LN1811">1811</td><td class="line"> }</td></tr>
|
---|
1891 | <tr><td class="num" id="LN1812">1812</td><td class="line"> </td></tr>
|
---|
1892 | <tr><td class="num" id="LN1813">1813</td><td class="line"> watch_node(&enclosure->node, B_STOP_WATCHING, <span class='keyword'>this</span>);</td></tr>
|
---|
1893 | <tr><td class="num" id="LN1814">1814</td><td class="line"> free(enclosure);</td></tr>
|
---|
1894 | <tr><td class="num" id="LN1815">1815</td><td class="line"> }</td></tr>
|
---|
1895 | <tr><td class="num" id="LN1816">1816</td><td class="line">}</td></tr>
|
---|
1896 | <tr><td class="num" id="LN1817">1817</td><td class="line"> </td></tr>
|
---|
1897 | <tr><td class="num" id="LN1818">1818</td><td class="line"> </td></tr>
|
---|
1898 | <tr><td class="num" id="LN1819">1819</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1899 | <tr><td class="num" id="LN1820">1820</td><td class="line">TTextView::LoadMessage(BEmailMessage *mail, <span class='keyword'>bool</span> quoteIt, <span class='keyword'>const</span> <span class='keyword'>char</span> *text)</td></tr>
|
---|
1900 | <tr><td class="num" id="LN1821">1821</td><td class="line">{</td></tr>
|
---|
1901 | <tr><td class="num" id="LN1822">1822</td><td class="line"> StopLoad();</td></tr>
|
---|
1902 | <tr><td class="num" id="LN1823">1823</td><td class="line"> </td></tr>
|
---|
1903 | <tr><td class="num" id="LN1824">1824</td><td class="line"> fMail = mail;</td></tr>
|
---|
1904 | <tr><td class="num" id="LN1825">1825</td><td class="line"> </td></tr>
|
---|
1905 | <tr><td class="num" id="LN1826">1826</td><td class="line"> ClearList();</td></tr>
|
---|
1906 | <tr><td class="num" id="LN1827">1827</td><td class="line"> </td></tr>
|
---|
1907 | <tr><td class="num" id="LN1828">1828</td><td class="line"> MakeSelectable(<span class='keyword'>true</span>);</td></tr>
|
---|
1908 | <tr><td class="num" id="LN1829">1829</td><td class="line"> MakeEditable(<span class='keyword'>false</span>);</td></tr>
|
---|
1909 | <tr><td class="num" id="LN1830">1830</td><td class="line"> <span class='keyword'>if</span> (text)</td></tr>
|
---|
1910 | <tr><td class="num" id="LN1831">1831</td><td class="line"> Insert(text, strlen(text));</td></tr>
|
---|
1911 | <tr><td class="num" id="LN1832">1832</td><td class="line"> </td></tr>
|
---|
1912 | <tr><td class="num" id="LN1833">1833</td><td class="line"> <span class='comment'>//attr_info attrInfo;</span></td></tr>
|
---|
1913 | <tr><td class="num" id="LN1834">1834</td><td class="line"> TTextView::Reader *reader = <span class='keyword'>new</span> TTextView::Reader(fHeader, fRaw, quoteIt, fIncoming,</td></tr>
|
---|
1914 | <tr><td class="num" id="LN1835">1835</td><td class="line"> text != <span class='macro'>NULL<span class='expansion'>__null</span></span>, <span class='keyword'>true</span>,</td></tr>
|
---|
1915 | <tr><td class="num" id="LN1836">1836</td><td class="line"> <span class='comment'>// I removed the following, because I absolutely can't imagine why it's</span></td></tr>
|
---|
1916 | <tr><td class="num" id="LN1837">1837</td><td class="line"> <span class='comment'>// there (the mail kit should be able to deal with non-compliant mails)</span></td></tr>
|
---|
1917 | <tr><td class="num" id="LN1838">1838</td><td class="line"> <span class='comment'>// -- axeld.</span></td></tr>
|
---|
1918 | <tr><td class="num" id="LN1839">1839</td><td class="line"> <span class='comment'>// fFile->GetAttrInfo(B_MAIL_ATTR_MIME, &attrInfo) == B_OK,</span></td></tr>
|
---|
1919 | <tr><td class="num" id="LN1840">1840</td><td class="line"> <span class='keyword'>this</span>, mail, fEnclosures, fStopSem);</td></tr>
|
---|
1920 | <tr><td class="num" id="LN1841">1841</td><td class="line"> </td></tr>
|
---|
1921 | <tr><td class="num" id="LN1842">1842</td><td class="line"> resume_thread(fThread = spawn_thread(Reader::Run, <span class='string_literal'>"reader"</span>, <span class='macro'>B_NORMAL_PRIORITY<span class='expansion'>10</span></span>, reader));</td></tr>
|
---|
1922 | <tr><td class="num" id="LN1843">1843</td><td class="line">}</td></tr>
|
---|
1923 | <tr><td class="num" id="LN1844">1844</td><td class="line"> </td></tr>
|
---|
1924 | <tr><td class="num" id="LN1845">1845</td><td class="line"> </td></tr>
|
---|
1925 | <tr><td class="num" id="LN1846">1846</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
1926 | <tr><td class="num" id="LN1847">1847</td><td class="line">TTextView::Open(hyper_text *enclosure)</td></tr>
|
---|
1927 | <tr><td class="num" id="LN1848">1848</td><td class="line">{</td></tr>
|
---|
1928 | <tr><td class="num" id="LN1849">1849</td><td class="line"> <span class='keyword'>switch</span> (enclosure->type) {</td></tr>
|
---|
1929 | <tr><td class="num" id="LN1850">1850</td><td class="line"> <span class='keyword'>case</span> TYPE_URL:</td></tr>
|
---|
1930 | <tr><td class="num" id="LN1851">1851</td><td class="line"> {</td></tr>
|
---|
1931 | <tr><td class="num" id="LN1852">1852</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>struct</span> {<span class='keyword'>const</span> <span class='keyword'>char</span> *urlType, *handler; } handlerTable[] = {</td></tr>
|
---|
1932 | <tr><td class="num" id="LN1853">1853</td><td class="line"> {<span class='string_literal'>"http"</span>, B_URL_HTTP},</td></tr>
|
---|
1933 | <tr><td class="num" id="LN1854">1854</td><td class="line"> {<span class='string_literal'>"https"</span>, B_URL_HTTPS},</td></tr>
|
---|
1934 | <tr><td class="num" id="LN1855">1855</td><td class="line"> {<span class='string_literal'>"ftp"</span>, B_URL_FTP},</td></tr>
|
---|
1935 | <tr><td class="num" id="LN1856">1856</td><td class="line"> {<span class='string_literal'>"gopher"</span>, B_URL_GOPHER},</td></tr>
|
---|
1936 | <tr><td class="num" id="LN1857">1857</td><td class="line"> {<span class='string_literal'>"mailto"</span>, B_URL_MAILTO},</td></tr>
|
---|
1937 | <tr><td class="num" id="LN1858">1858</td><td class="line"> {<span class='string_literal'>"news"</span>, B_URL_NEWS},</td></tr>
|
---|
1938 | <tr><td class="num" id="LN1859">1859</td><td class="line"> {<span class='string_literal'>"nntp"</span>, B_URL_NNTP},</td></tr>
|
---|
1939 | <tr><td class="num" id="LN1860">1860</td><td class="line"> {<span class='string_literal'>"telnet"</span>, B_URL_TELNET},</td></tr>
|
---|
1940 | <tr><td class="num" id="LN1861">1861</td><td class="line"> {<span class='string_literal'>"rlogin"</span>, B_URL_RLOGIN},</td></tr>
|
---|
1941 | <tr><td class="num" id="LN1862">1862</td><td class="line"> {<span class='string_literal'>"tn3270"</span>, B_URL_TN3270},</td></tr>
|
---|
1942 | <tr><td class="num" id="LN1863">1863</td><td class="line"> {<span class='string_literal'>"wais"</span>, B_URL_WAIS},</td></tr>
|
---|
1943 | <tr><td class="num" id="LN1864">1864</td><td class="line"> {<span class='string_literal'>"file"</span>, B_URL_FILE},</td></tr>
|
---|
1944 | <tr><td class="num" id="LN1865">1865</td><td class="line"> {<span class='macro'>NULL<span class='expansion'>__null</span></span>, <span class='macro'>NULL<span class='expansion'>__null</span></span>}</td></tr>
|
---|
1945 | <tr><td class="num" id="LN1866">1866</td><td class="line"> };</td></tr>
|
---|
1946 | <tr><td class="num" id="LN1867">1867</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *handlerToLaunch = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
1947 | <tr><td class="num" id="LN1868">1868</td><td class="line"> </td></tr>
|
---|
1948 | <tr><td class="num" id="LN1869">1869</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *colonPos = strchr(enclosure->name, ':');</td></tr>
|
---|
1949 | <tr><td class="num" id="LN1870">1870</td><td class="line"> <span class='keyword'>if</span> (colonPos) {</td></tr>
|
---|
1950 | <tr><td class="num" id="LN1871">1871</td><td class="line"> <span class='keyword'>int</span> urlTypeLength = colonPos - enclosure->name;</td></tr>
|
---|
1951 | <tr><td class="num" id="LN1872">1872</td><td class="line"> </td></tr>
|
---|
1952 | <tr><td class="num" id="LN1873">1873</td><td class="line"> <span class='keyword'>for</span> (int32 index = 0; handlerTable[index].urlType; index++) {</td></tr>
|
---|
1953 | <tr><td class="num" id="LN1874">1874</td><td class="line"> <span class='keyword'>if</span> (!strncasecmp(enclosure->name,</td></tr>
|
---|
1954 | <tr><td class="num" id="LN1875">1875</td><td class="line"> handlerTable[index].urlType, urlTypeLength)) {</td></tr>
|
---|
1955 | <tr><td class="num" id="LN1876">1876</td><td class="line"> handlerToLaunch = handlerTable[index].handler;</td></tr>
|
---|
1956 | <tr><td class="num" id="LN1877">1877</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1957 | <tr><td class="num" id="LN1878">1878</td><td class="line"> }</td></tr>
|
---|
1958 | <tr><td class="num" id="LN1879">1879</td><td class="line"> }</td></tr>
|
---|
1959 | <tr><td class="num" id="LN1880">1880</td><td class="line"> }</td></tr>
|
---|
1960 | <tr><td class="num" id="LN1881">1881</td><td class="line"> <span class='keyword'>if</span> (handlerToLaunch) {</td></tr>
|
---|
1961 | <tr><td class="num" id="LN1882">1882</td><td class="line"> entry_ref appRef;</td></tr>
|
---|
1962 | <tr><td class="num" id="LN1883">1883</td><td class="line"> <span class='keyword'>if</span> (be_roster->FindApp(handlerToLaunch, &appRef) != <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
1963 | <tr><td class="num" id="LN1884">1884</td><td class="line"> handlerToLaunch = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
1964 | <tr><td class="num" id="LN1885">1885</td><td class="line"> }</td></tr>
|
---|
1965 | <tr><td class="num" id="LN1886">1886</td><td class="line"> <span class='keyword'>if</span> (!handlerToLaunch)</td></tr>
|
---|
1966 | <tr><td class="num" id="LN1887">1887</td><td class="line"> handlerToLaunch = <span class='string_literal'>"application/x-vnd.Be-Bookmark"</span>;</td></tr>
|
---|
1967 | <tr><td class="num" id="LN1888">1888</td><td class="line"> </td></tr>
|
---|
1968 | <tr><td class="num" id="LN1889">1889</td><td class="line"> status_t result = be_roster->Launch(handlerToLaunch, 1, &enclosure->name);</td></tr>
|
---|
1969 | <tr><td class="num" id="LN1890">1890</td><td class="line"> <span class='keyword'>if</span> (result != <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span> && result != <span class='macro'>B_ALREADY_RUNNING<span class='expansion'>(((-2147483647 - 1) + 0x2000) + 4)</span></span>) {</td></tr>
|
---|
1970 | <tr><td class="num" id="LN1891">1891</td><td class="line"> beep();</td></tr>
|
---|
1971 | <tr><td class="num" id="LN1892">1892</td><td class="line"> BAlert* alert = <span class='keyword'>new</span> BAlert(<span class='string_literal'>""</span>,</td></tr>
|
---|
1972 | <tr><td class="num" id="LN1893">1893</td><td class="line"> <span class='macro'>B_TRANSLATE(<span class='string_literal'>"There is no installed handler for "<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("There is no installed handler for "<br> "URL links."), "Mail")</span></span></span></td></tr>
|
---|
1973 | <tr><td class="num" id="LN1894">1894</td><td class="line"> <span class='string_literal'><span class='macro'>"URL links."</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("There is no installed handler for "<br> "URL links."), "Mail")</span></span>, <span class='macro'>B_TRANSLATE(<span class='string_literal'>"Sorry"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Sorry"<br>), "Mail")</span></span>);</td></tr>
|
---|
1974 | <tr><td class="num" id="LN1895">1895</td><td class="line"> alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);</td></tr>
|
---|
1975 | <tr><td class="num" id="LN1896">1896</td><td class="line"> alert->Go();</td></tr>
|
---|
1976 | <tr><td class="num" id="LN1897">1897</td><td class="line"> }</td></tr>
|
---|
1977 | <tr><td class="num" id="LN1898">1898</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1978 | <tr><td class="num" id="LN1899">1899</td><td class="line"> }</td></tr>
|
---|
1979 | <tr><td class="num" id="LN1900">1900</td><td class="line"> </td></tr>
|
---|
1980 | <tr><td class="num" id="LN1901">1901</td><td class="line"> <span class='keyword'>case</span> TYPE_MAILTO:</td></tr>
|
---|
1981 | <tr><td class="num" id="LN1902">1902</td><td class="line"> <span class='keyword'>if</span> (be_roster->Launch(<span class='macro'>B_MAIL_TYPE<span class='expansion'>"text/x-email"</span></span>, 1, &enclosure->name) < <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1982 | <tr><td class="num" id="LN1903">1903</td><td class="line"> <span class='keyword'>char</span> *argv[] = {(<span class='keyword'>char</span> *)<span class='string_literal'>"Mail"</span>, enclosure->name};</td></tr>
|
---|
1983 | <tr><td class="num" id="LN1904">1904</td><td class="line"> be_app->ArgvReceived(2, argv);</td></tr>
|
---|
1984 | <tr><td class="num" id="LN1905">1905</td><td class="line"> }</td></tr>
|
---|
1985 | <tr><td class="num" id="LN1906">1906</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
1986 | <tr><td class="num" id="LN1907">1907</td><td class="line"> </td></tr>
|
---|
1987 | <tr><td class="num" id="LN1908">1908</td><td class="line"> <span class='keyword'>case</span> TYPE_ENCLOSURE:</td></tr>
|
---|
1988 | <tr><td class="num" id="LN1909">1909</td><td class="line"> <span class='keyword'>case</span> TYPE_BE_ENCLOSURE:</td></tr>
|
---|
1989 | <tr><td class="num" id="LN1910">1910</td><td class="line"> <span class='keyword'>if</span> (!enclosure->have_ref) {</td></tr>
|
---|
1990 | <tr><td class="num" id="LN1911">1911</td><td class="line"> BPath path;</td></tr>
|
---|
1991 | <tr><td class="num" id="LN1912">1912</td><td class="line"> <span class='keyword'>if</span> (find_directory(B_COMMON_TEMP_DIRECTORY, &path) == <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1992 | <tr><td class="num" id="LN1913">1913</td><td class="line"> BDirectory dir(path.Path());</td></tr>
|
---|
1993 | <tr><td class="num" id="LN1914">1914</td><td class="line"> <span class='keyword'>if</span> (dir.InitCheck() == <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
1994 | <tr><td class="num" id="LN1915">1915</td><td class="line"> <span class='keyword'>char</span> name[<span class='macro'>B_FILE_NAME_LENGTH<span class='expansion'>(256)</span></span>];</td></tr>
|
---|
1995 | <tr><td class="num" id="LN1916">1916</td><td class="line"> <span class='keyword'>char</span> baseName[<span class='macro'>B_FILE_NAME_LENGTH<span class='expansion'>(256)</span></span>];</td></tr>
|
---|
1996 | <tr><td class="num" id="LN1917">1917</td><td class="line"> strcpy(baseName, enclosure->name ? enclosure->name : <span class='string_literal'>"enclosure"</span>);</td></tr>
|
---|
1997 | <tr><td class="num" id="LN1918">1918</td><td class="line"> strcpy(name, baseName);</td></tr>
|
---|
1998 | <tr><td class="num" id="LN1919">1919</td><td class="line"> <span class='keyword'>for</span> (int32 index = 0; dir.Contains(name); index++)</td></tr>
|
---|
1999 | <tr><td class="num" id="LN1920">1920</td><td class="line"> sprintf(name, <span class='string_literal'>"%s_%"</span> <span class='macro'>B_PRId32<span class='expansion'>"l" "d"</span></span>, baseName, index);</td></tr>
|
---|
2000 | <tr><td class="num" id="LN1921">1921</td><td class="line"> </td></tr>
|
---|
2001 | <tr><td class="num" id="LN1922">1922</td><td class="line"> BEntry entry(path.Path());</td></tr>
|
---|
2002 | <tr><td class="num" id="LN1923">1923</td><td class="line"> entry_ref ref;</td></tr>
|
---|
2003 | <tr><td class="num" id="LN1924">1924</td><td class="line"> entry.GetRef(&ref);</td></tr>
|
---|
2004 | <tr><td class="num" id="LN1925">1925</td><td class="line"> </td></tr>
|
---|
2005 | <tr><td class="num" id="LN1926">1926</td><td class="line"> BMessage save(M_SAVE);</td></tr>
|
---|
2006 | <tr><td class="num" id="LN1927">1927</td><td class="line"> save.AddRef(<span class='string_literal'>"directory"</span>, &ref);</td></tr>
|
---|
2007 | <tr><td class="num" id="LN1928">1928</td><td class="line"> save.AddString(<span class='string_literal'>"name"</span>, name);</td></tr>
|
---|
2008 | <tr><td class="num" id="LN1929">1929</td><td class="line"> save.AddPointer(<span class='string_literal'>"enclosure"</span>, enclosure);</td></tr>
|
---|
2009 | <tr><td class="num" id="LN1930">1930</td><td class="line"> <span class='keyword'>if</span> (Save(&save) != <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
2010 | <tr><td class="num" id="LN1931">1931</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
2011 | <tr><td class="num" id="LN1932">1932</td><td class="line"> enclosure->saved = <span class='keyword'>false</span>;</td></tr>
|
---|
2012 | <tr><td class="num" id="LN1933">1933</td><td class="line"> }</td></tr>
|
---|
2013 | <tr><td class="num" id="LN1934">1934</td><td class="line"> }</td></tr>
|
---|
2014 | <tr><td class="num" id="LN1935">1935</td><td class="line"> }</td></tr>
|
---|
2015 | <tr><td class="num" id="LN1936">1936</td><td class="line"> </td></tr>
|
---|
2016 | <tr><td class="num" id="LN1937">1937</td><td class="line"> BMessenger tracker(<span class='string_literal'>"application/x-vnd.Be-TRAK"</span>);</td></tr>
|
---|
2017 | <tr><td class="num" id="LN1938">1938</td><td class="line"> <span class='keyword'>if</span> (tracker.IsValid()) {</td></tr>
|
---|
2018 | <tr><td class="num" id="LN1939">1939</td><td class="line"> BMessage openMsg(B_REFS_RECEIVED);</td></tr>
|
---|
2019 | <tr><td class="num" id="LN1940">1940</td><td class="line"> openMsg.AddRef(<span class='string_literal'>"refs"</span>, &enclosure->ref);</td></tr>
|
---|
2020 | <tr><td class="num" id="LN1941">1941</td><td class="line"> tracker.SendMessage(&openMsg);</td></tr>
|
---|
2021 | <tr><td class="num" id="LN1942">1942</td><td class="line"> }</td></tr>
|
---|
2022 | <tr><td class="num" id="LN1943">1943</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
2023 | <tr><td class="num" id="LN1944">1944</td><td class="line"> }</td></tr>
|
---|
2024 | <tr><td class="num" id="LN1945">1945</td><td class="line">}</td></tr>
|
---|
2025 | <tr><td class="num" id="LN1946">1946</td><td class="line"> </td></tr>
|
---|
2026 | <tr><td class="num" id="LN1947">1947</td><td class="line"> </td></tr>
|
---|
2027 | <tr><td class="num" id="LN1948">1948</td><td class="line">status_t</td></tr>
|
---|
2028 | <tr><td class="num" id="LN1949">1949</td><td class="line">TTextView::Save(BMessage *msg, <span class='keyword'>bool</span> makeNewFile)</td></tr>
|
---|
2029 | <tr><td class="num" id="LN1950">1950</td><td class="line">{</td></tr>
|
---|
2030 | <tr><td class="num" id="LN1951">1951</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *name;</td></tr>
|
---|
2031 | <tr><td class="num" id="LN1952">1952</td><td class="line"> entry_ref ref;</td></tr>
|
---|
2032 | <tr><td class="num" id="LN1953">1953</td><td class="line"> BFile file;</td></tr>
|
---|
2033 | <tr><td class="num" id="LN1954">1954</td><td class="line"> BPath path;</td></tr>
|
---|
2034 | <tr><td class="num" id="LN1955">1955</td><td class="line"> hyper_text *enclosure;</td></tr>
|
---|
2035 | <tr><td class="num" id="LN1956">1956</td><td class="line"> status_t result = <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>;</td></tr>
|
---|
2036 | <tr><td class="num" id="LN1957">1957</td><td class="line"> <span class='keyword'>char</span> entry_name[<span class='macro'>B_FILE_NAME_LENGTH<span class='expansion'>(256)</span></span>];</td></tr>
|
---|
2037 | <tr><td class="num" id="LN1958">1958</td><td class="line"> </td></tr>
|
---|
2038 | <tr><td class="num" id="LN1959">1959</td><td class="line"> msg->FindString(<span class='string_literal'>"name"</span>, &name);</td></tr>
|
---|
2039 | <tr><td class="num" id="LN1960">1960</td><td class="line"> msg->FindRef(<span class='string_literal'>"directory"</span>, &ref);</td></tr>
|
---|
2040 | <tr><td class="num" id="LN1961">1961</td><td class="line"> msg->FindPointer(<span class='string_literal'>"enclosure"</span>, (<span class='keyword'>void</span> **)&enclosure);</td></tr>
|
---|
2041 | <tr><td class="num" id="LN1962">1962</td><td class="line"> </td></tr>
|
---|
2042 | <tr><td class="num" id="LN1963">1963</td><td class="line"> BDirectory dir;</td></tr>
|
---|
2043 | <tr><td class="num" id="LN1964">1964</td><td class="line"> dir.SetTo(&ref);</td></tr>
|
---|
2044 | <tr><td class="num" id="LN1965">1965</td><td class="line"> result = dir.InitCheck();</td></tr>
|
---|
2045 | <tr><td class="num" id="LN1966">1966</td><td class="line"> </td></tr>
|
---|
2046 | <tr><td class="num" id="LN1967">1967</td><td class="line"> <span class='keyword'>if</span> (result == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
2047 | <tr><td class="num" id="LN1968">1968</td><td class="line"> <span class='keyword'>if</span> (makeNewFile) {</td></tr>
|
---|
2048 | <tr><td class="num" id="LN1969">1969</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
2049 | <tr><td class="num" id="LN1970">1970</td><td class="line"> <span class='comment'>// Search for the file and delete it if it already exists.</span></td></tr>
|
---|
2050 | <tr><td class="num" id="LN1971">1971</td><td class="line"> <span class='comment'>// (It may not, that's ok.)</span></td></tr>
|
---|
2051 | <tr><td class="num" id="LN1972">1972</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
2052 | <tr><td class="num" id="LN1973">1973</td><td class="line"> BEntry entry;</td></tr>
|
---|
2053 | <tr><td class="num" id="LN1974">1974</td><td class="line"> <span class='keyword'>if</span> (dir.FindEntry(name, &entry) == <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
2054 | <tr><td class="num" id="LN1975">1975</td><td class="line"> entry.Remove();</td></tr>
|
---|
2055 | <tr><td class="num" id="LN1976">1976</td><td class="line"> </td></tr>
|
---|
2056 | <tr><td class="num" id="LN1977">1977</td><td class="line"> <span class='keyword'>if</span> ((enclosure->have_ref) && (!enclosure->saved)) {</td></tr>
|
---|
2057 | <tr><td class="num" id="LN1978">1978</td><td class="line"> entry.SetTo(&enclosure->ref);</td></tr>
|
---|
2058 | <tr><td class="num" id="LN1979">1979</td><td class="line"> </td></tr>
|
---|
2059 | <tr><td class="num" id="LN1980">1980</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
2060 | <tr><td class="num" id="LN1981">1981</td><td class="line"> <span class='comment'>// Added true arg and entry_name so MoveTo clobbers as</span></td></tr>
|
---|
2061 | <tr><td class="num" id="LN1982">1982</td><td class="line"> <span class='comment'>// before. This may not be the correct behaviour, but</span></td></tr>
|
---|
2062 | <tr><td class="num" id="LN1983">1983</td><td class="line"> <span class='comment'>// it's the preserved behaviour.</span></td></tr>
|
---|
2063 | <tr><td class="num" id="LN1984">1984</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
2064 | <tr><td class="num" id="LN1985">1985</td><td class="line"> entry.GetName(entry_name);</td></tr>
|
---|
2065 | <tr><td class="num" id="LN1986">1986</td><td class="line"> result = entry.MoveTo(&dir, entry_name, <span class='keyword'>true</span>);</td></tr>
|
---|
2066 | <tr><td class="num" id="LN1987">1987</td><td class="line"> <span class='keyword'>if</span> (result == <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
2067 | <tr><td class="num" id="LN1988">1988</td><td class="line"> entry.Rename(name);</td></tr>
|
---|
2068 | <tr><td class="num" id="LN1989">1989</td><td class="line"> entry.GetRef(&enclosure->ref);</td></tr>
|
---|
2069 | <tr><td class="num" id="LN1990">1990</td><td class="line"> entry.GetNodeRef(&enclosure->node);</td></tr>
|
---|
2070 | <tr><td class="num" id="LN1991">1991</td><td class="line"> enclosure->saved = <span class='keyword'>true</span>;</td></tr>
|
---|
2071 | <tr><td class="num" id="LN1992">1992</td><td class="line"> <span class='keyword'>return</span> result;</td></tr>
|
---|
2072 | <tr><td class="num" id="LN1993">1993</td><td class="line"> }</td></tr>
|
---|
2073 | <tr><td class="num" id="LN1994">1994</td><td class="line"> }</td></tr>
|
---|
2074 | <tr><td class="num" id="LN1995">1995</td><td class="line"> </td></tr>
|
---|
2075 | <tr><td class="num" id="LN1996">1996</td><td class="line"> <span class='keyword'>if</span> (result == <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
2076 | <tr><td class="num" id="LN1997">1997</td><td class="line"> result = dir.CreateFile(name, &file);</td></tr>
|
---|
2077 | <tr><td class="num" id="LN1998">1998</td><td class="line"> <span class='keyword'>if</span> (result == <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span> && enclosure->content_type) {</td></tr>
|
---|
2078 | <tr><td class="num" id="LN1999">1999</td><td class="line"> <span class='keyword'>char</span> type[<span class='macro'>B_MIME_TYPE_LENGTH<span class='expansion'>(((256)-1) - 15)</span></span>];</td></tr>
|
---|
2079 | <tr><td class="num" id="LN2000">2000</td><td class="line"> </td></tr>
|
---|
2080 | <tr><td class="num" id="LN2001">2001</td><td class="line"> <span class='keyword'>if</span> (!strcasecmp(enclosure->content_type, <span class='string_literal'>"message/rfc822"</span>))</td></tr>
|
---|
2081 | <tr><td class="num" id="LN2002">2002</td><td class="line"> strcpy(type, <span class='string_literal'>"text/x-email"</span>);</td></tr>
|
---|
2082 | <tr><td class="num" id="LN2003">2003</td><td class="line"> <span class='keyword'>else</span> <span class='keyword'>if</span> (!strcasecmp(enclosure->content_type, <span class='string_literal'>"message/delivery-status"</span>))</td></tr>
|
---|
2083 | <tr><td class="num" id="LN2004">2004</td><td class="line"> strcpy(type, <span class='string_literal'>"text/plain"</span>);</td></tr>
|
---|
2084 | <tr><td class="num" id="LN2005">2005</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
2085 | <tr><td class="num" id="LN2006">2006</td><td class="line"> strcpy(type, enclosure->content_type);</td></tr>
|
---|
2086 | <tr><td class="num" id="LN2007">2007</td><td class="line"> </td></tr>
|
---|
2087 | <tr><td class="num" id="LN2008">2008</td><td class="line"> BNodeInfo info(&file);</td></tr>
|
---|
2088 | <tr><td class="num" id="LN2009">2009</td><td class="line"> info.SetType(type);</td></tr>
|
---|
2089 | <tr><td class="num" id="LN2010">2010</td><td class="line"> }</td></tr>
|
---|
2090 | <tr><td class="num" id="LN2011">2011</td><td class="line"> }</td></tr>
|
---|
2091 | <tr><td class="num" id="LN2012">2012</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
2092 | <tr><td class="num" id="LN2013">2013</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
2093 | <tr><td class="num" id="LN2014">2014</td><td class="line"> <span class='comment'>// This file was dragged into the tracker or desktop. The file</span></td></tr>
|
---|
2094 | <tr><td class="num" id="LN2015">2015</td><td class="line"> <span class='comment'>// already exists.</span></td></tr>
|
---|
2095 | <tr><td class="num" id="LN2016">2016</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
2096 | <tr><td class="num" id="LN2017">2017</td><td class="line"> result = file.SetTo(&dir, name, <span class='macro'>B_WRITE_ONLY<span class='expansion'>0x0001</span></span>);</td></tr>
|
---|
2097 | <tr><td class="num" id="LN2018">2018</td><td class="line"> }</td></tr>
|
---|
2098 | <tr><td class="num" id="LN2019">2019</td><td class="line"> }</td></tr>
|
---|
2099 | <tr><td class="num" id="LN2020">2020</td><td class="line"> </td></tr>
|
---|
2100 | <tr><td class="num" id="LN2021">2021</td><td class="line"> <span class='keyword'>if</span> (enclosure->component == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2101 | <tr><td class="num" id="LN2022">2022</td><td class="line"> result = <span class='macro'>B_ERROR<span class='expansion'>(-1)</span></span>;</td></tr>
|
---|
2102 | <tr><td class="num" id="LN2023">2023</td><td class="line"> </td></tr>
|
---|
2103 | <tr><td class="num" id="LN2024">2024</td><td class="line"> <span class='keyword'>if</span> (result == <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
2104 | <tr><td class="num" id="LN2025">2025</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
2105 | <tr><td class="num" id="LN2026">2026</td><td class="line"> <span class='comment'>// Write the data</span></td></tr>
|
---|
2106 | <tr><td class="num" id="LN2027">2027</td><td class="line"> <span class='comment'>//</span></td></tr>
|
---|
2107 | <tr><td class="num" id="LN2028">2028</td><td class="line"> enclosure->component->GetDecodedData(&file);</td></tr>
|
---|
2108 | <tr><td class="num" id="LN2029">2029</td><td class="line"> </td></tr>
|
---|
2109 | <tr><td class="num" id="LN2030">2030</td><td class="line"> BEntry entry;</td></tr>
|
---|
2110 | <tr><td class="num" id="LN2031">2031</td><td class="line"> dir.FindEntry(name, &entry);</td></tr>
|
---|
2111 | <tr><td class="num" id="LN2032">2032</td><td class="line"> entry.GetRef(&enclosure->ref);</td></tr>
|
---|
2112 | <tr><td class="num" id="LN2033">2033</td><td class="line"> enclosure->have_ref = <span class='keyword'>true</span>;</td></tr>
|
---|
2113 | <tr><td class="num" id="LN2034">2034</td><td class="line"> enclosure->saved = <span class='keyword'>true</span>;</td></tr>
|
---|
2114 | <tr><td class="num" id="LN2035">2035</td><td class="line"> entry.GetPath(&path);</td></tr>
|
---|
2115 | <tr><td class="num" id="LN2036">2036</td><td class="line"> update_mime_info(path.Path(), <span class='keyword'>false</span>, <span class='keyword'>true</span>,</td></tr>
|
---|
2116 | <tr><td class="num" id="LN2037">2037</td><td class="line"> !cistrcmp(<span class='string_literal'>"application/octet-stream"</span>, enclosure->content_type ? enclosure->content_type : B_EMPTY_STRING));</td></tr>
|
---|
2117 | <tr><td class="num" id="LN2038">2038</td><td class="line"> entry.GetNodeRef(&enclosure->node);</td></tr>
|
---|
2118 | <tr><td class="num" id="LN2039">2039</td><td class="line"> watch_node(&enclosure->node, B_WATCH_NAME, <span class='keyword'>this</span>);</td></tr>
|
---|
2119 | <tr><td class="num" id="LN2040">2040</td><td class="line"> }</td></tr>
|
---|
2120 | <tr><td class="num" id="LN2041">2041</td><td class="line"> </td></tr>
|
---|
2121 | <tr><td class="num" id="LN2042">2042</td><td class="line"> <span class='keyword'>if</span> (result != <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
2122 | <tr><td class="num" id="LN2043">2043</td><td class="line"> beep();</td></tr>
|
---|
2123 | <tr><td class="num" id="LN2044">2044</td><td class="line"> BAlert* alert = <span class='keyword'>new</span> BAlert(<span class='string_literal'>""</span>, <span class='macro'>B_TRANSLATE(<span class='string_literal'>"An error occurred trying to save "<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("An error occurred trying to save "<br> "the attachment."), "Mail")</span></span></span></td></tr>
|
---|
2124 | <tr><td class="num" id="LN2045">2045</td><td class="line"> <span class='string_literal'><span class='macro'>"the attachment."</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("An error occurred trying to save "<br> "the attachment."), "Mail")</span></span>, <span class='macro'>B_TRANSLATE(<span class='string_literal'>"Sorry"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Sorry"<br>), "Mail")</span></span>);</td></tr>
|
---|
2125 | <tr><td class="num" id="LN2046">2046</td><td class="line"> alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);</td></tr>
|
---|
2126 | <tr><td class="num" id="LN2047">2047</td><td class="line"> alert->Go();</td></tr>
|
---|
2127 | <tr><td class="num" id="LN2048">2048</td><td class="line"> }</td></tr>
|
---|
2128 | <tr><td class="num" id="LN2049">2049</td><td class="line"> </td></tr>
|
---|
2129 | <tr><td class="num" id="LN2050">2050</td><td class="line"> <span class='keyword'>return</span> result;</td></tr>
|
---|
2130 | <tr><td class="num" id="LN2051">2051</td><td class="line">}</td></tr>
|
---|
2131 | <tr><td class="num" id="LN2052">2052</td><td class="line"> </td></tr>
|
---|
2132 | <tr><td class="num" id="LN2053">2053</td><td class="line"> </td></tr>
|
---|
2133 | <tr><td class="num" id="LN2054">2054</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
2134 | <tr><td class="num" id="LN2055">2055</td><td class="line">TTextView::StopLoad()</td></tr>
|
---|
2135 | <tr><td class="num" id="LN2056">2056</td><td class="line">{</td></tr>
|
---|
2136 | <tr><td class="num" id="LN2057">2057</td><td class="line"> Window()->Unlock();</td></tr>
|
---|
2137 | <tr><td class="num" id="LN2058">2058</td><td class="line"> </td></tr>
|
---|
2138 | <tr><td class="num" id="LN2059">2059</td><td class="line"> thread_info info;</td></tr>
|
---|
2139 | <tr><td class="num" id="LN2060">2060</td><td class="line"> <span class='keyword'>if</span> (fThread != 0 && <span class='macro'>get_thread_info(fThread, &info)<span class='expansion'>_get_thread_info((fThread), (&info), sizeof(*(&info))<br>)</span></span> == <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
2140 | <tr><td class="num" id="LN2061">2061</td><td class="line"> fStopLoading = <span class='keyword'>true</span>;</td></tr>
|
---|
2141 | <tr><td class="num" id="LN2062">2062</td><td class="line"> acquire_sem(fStopSem);</td></tr>
|
---|
2142 | <tr><td class="num" id="LN2063">2063</td><td class="line"> int32 result;</td></tr>
|
---|
2143 | <tr><td class="num" id="LN2064">2064</td><td class="line"> wait_for_thread(fThread, &result);</td></tr>
|
---|
2144 | <tr><td class="num" id="LN2065">2065</td><td class="line"> fThread = 0;</td></tr>
|
---|
2145 | <tr><td class="num" id="LN2066">2066</td><td class="line"> release_sem(fStopSem);</td></tr>
|
---|
2146 | <tr><td class="num" id="LN2067">2067</td><td class="line"> fStopLoading = <span class='keyword'>false</span>;</td></tr>
|
---|
2147 | <tr><td class="num" id="LN2068">2068</td><td class="line"> }</td></tr>
|
---|
2148 | <tr><td class="num" id="LN2069">2069</td><td class="line"> </td></tr>
|
---|
2149 | <tr><td class="num" id="LN2070">2070</td><td class="line"> Window()->Lock();</td></tr>
|
---|
2150 | <tr><td class="num" id="LN2071">2071</td><td class="line">}</td></tr>
|
---|
2151 | <tr><td class="num" id="LN2072">2072</td><td class="line"> </td></tr>
|
---|
2152 | <tr><td class="num" id="LN2073">2073</td><td class="line"> </td></tr>
|
---|
2153 | <tr><td class="num" id="LN2074">2074</td><td class="line"><span class='keyword'>bool</span></td></tr>
|
---|
2154 | <tr><td class="num" id="LN2075">2075</td><td class="line">TTextView::IsReaderThreadRunning()</td></tr>
|
---|
2155 | <tr><td class="num" id="LN2076">2076</td><td class="line">{</td></tr>
|
---|
2156 | <tr><td class="num" id="LN2077">2077</td><td class="line"> <span class='keyword'>if</span> (fThread == 0)</td></tr>
|
---|
2157 | <tr><td class="num" id="LN2078">2078</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2158 | <tr><td class="num" id="LN2079">2079</td><td class="line"> </td></tr>
|
---|
2159 | <tr><td class="num" id="LN2080">2080</td><td class="line"> thread_info info;</td></tr>
|
---|
2160 | <tr><td class="num" id="LN2081">2081</td><td class="line"> <span class='keyword'>for</span> (<span class='keyword'>int</span> i = 5; i > 0; i--, usleep(100000))</td></tr>
|
---|
2161 | <tr><td class="num" id="LN2082">2082</td><td class="line"> <span class='keyword'>if</span> (<span class='macro'>get_thread_info(fThread, &info)<span class='expansion'>_get_thread_info((fThread), (&info), sizeof(*(&info))<br>)</span></span> != <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
2162 | <tr><td class="num" id="LN2083">2083</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2163 | <tr><td class="num" id="LN2084">2084</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>true</span>;</td></tr>
|
---|
2164 | <tr><td class="num" id="LN2085">2085</td><td class="line">}</td></tr>
|
---|
2165 | <tr><td class="num" id="LN2086">2086</td><td class="line"> </td></tr>
|
---|
2166 | <tr><td class="num" id="LN2087">2087</td><td class="line"> </td></tr>
|
---|
2167 | <tr><td class="num" id="LN2088">2088</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
2168 | <tr><td class="num" id="LN2089">2089</td><td class="line">TTextView::AddAsContent(BEmailMessage *mail, <span class='keyword'>bool</span> wrap, uint32 charset, mail_encoding encoding)</td></tr>
|
---|
2169 | <tr><td class="num" id="LN2090">2090</td><td class="line">{</td></tr>
|
---|
2170 | <tr><td class="num" id="LN2091">2091</td><td class="line"> <span class='keyword'>if</span> (mail == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2171 | <tr><td class="num" id="LN2092">2092</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
2172 | <tr><td class="num" id="LN2093">2093</td><td class="line"> </td></tr>
|
---|
2173 | <tr><td class="num" id="LN2094">2094</td><td class="line"> int32 textLength = TextLength();</td></tr>
|
---|
2174 | <tr><td class="num" id="LN2095">2095</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = Text();</td></tr>
|
---|
2175 | <tr><td class="num" id="LN2096">2096</td><td class="line"> </td></tr>
|
---|
2176 | <tr><td class="num" id="LN2097">2097</td><td class="line"> BTextMailComponent *body = mail->Body();</td></tr>
|
---|
2177 | <tr><td class="num" id="LN2098">2098</td><td class="line"> <span class='keyword'>if</span> (body == <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
2178 | <tr><td class="num" id="LN2099">2099</td><td class="line"> <span class='keyword'>if</span> (mail->SetBody(body = <span class='keyword'>new</span> BTextMailComponent()) < <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
2179 | <tr><td class="num" id="LN2100">2100</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
2180 | <tr><td class="num" id="LN2101">2101</td><td class="line"> }</td></tr>
|
---|
2181 | <tr><td class="num" id="LN2102">2102</td><td class="line"> body->SetEncoding(encoding, charset);</td></tr>
|
---|
2182 | <tr><td class="num" id="LN2103">2103</td><td class="line"> </td></tr>
|
---|
2183 | <tr><td class="num" id="LN2104">2104</td><td class="line"> <span class='comment'>// Just add the text as a whole if we can, or ...</span></td></tr>
|
---|
2184 | <tr><td class="num" id="LN2105">2105</td><td class="line"> <span class='keyword'>if</span> (!wrap) {</td></tr>
|
---|
2185 | <tr><td class="num" id="LN2106">2106</td><td class="line"> body->AppendText(text);</td></tr>
|
---|
2186 | <tr><td class="num" id="LN2107">2107</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
2187 | <tr><td class="num" id="LN2108">2108</td><td class="line"> }</td></tr>
|
---|
2188 | <tr><td class="num" id="LN2109">2109</td><td class="line"> </td></tr>
|
---|
2189 | <tr><td class="num" id="LN2110">2110</td><td class="line"> <span class='comment'>// ... do word wrapping.</span></td></tr>
|
---|
2190 | <tr><td class="num" id="LN2111">2111</td><td class="line"> </td></tr>
|
---|
2191 | <tr><td class="num" id="LN2112">2112</td><td class="line"> BWindow *window = Window();</td></tr>
|
---|
2192 | <tr><td class="num" id="LN2113">2113</td><td class="line"> <span class='keyword'>char</span> *saveText = strdup(text);</td></tr>
|
---|
2193 | <tr><td class="num" id="LN2114">2114</td><td class="line"> BRect saveTextRect = TextRect();</td></tr>
|
---|
2194 | <tr><td class="num" id="LN2115">2115</td><td class="line"> </td></tr>
|
---|
2195 | <tr><td class="num" id="LN2116">2116</td><td class="line"> <span class='comment'>// do this before we start messing with the fonts</span></td></tr>
|
---|
2196 | <tr><td class="num" id="LN2117">2117</td><td class="line"> <span class='comment'>// the user will never know...</span></td></tr>
|
---|
2197 | <tr><td class="num" id="LN2118">2118</td><td class="line"> window->DisableUpdates();</td></tr>
|
---|
2198 | <tr><td class="num" id="LN2119">2119</td><td class="line"> Hide();</td></tr>
|
---|
2199 | <tr><td class="num" id="LN2120">2120</td><td class="line"> BScrollBar *vScroller = ScrollBar(B_VERTICAL);</td></tr>
|
---|
2200 | <tr><td class="num" id="LN2121">2121</td><td class="line"> BScrollBar *hScroller = ScrollBar(B_HORIZONTAL);</td></tr>
|
---|
2201 | <tr><td class="num" id="LN2122">2122</td><td class="line"> <span class='keyword'>if</span> (vScroller != <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2202 | <tr><td class="num" id="LN2123">2123</td><td class="line"> vScroller->SetTarget((BView *)<span class='macro'>NULL<span class='expansion'>__null</span></span>);</td></tr>
|
---|
2203 | <tr><td class="num" id="LN2124">2124</td><td class="line"> <span class='keyword'>if</span> (hScroller != <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2204 | <tr><td class="num" id="LN2125">2125</td><td class="line"> hScroller->SetTarget((BView *)<span class='macro'>NULL<span class='expansion'>__null</span></span>);</td></tr>
|
---|
2205 | <tr><td class="num" id="LN2126">2126</td><td class="line"> </td></tr>
|
---|
2206 | <tr><td class="num" id="LN2127">2127</td><td class="line"> <span class='comment'>// Temporarily set the font to a fixed width font for line wrapping</span></td></tr>
|
---|
2207 | <tr><td class="num" id="LN2128">2128</td><td class="line"> <span class='comment'>// calculations. If the font doesn't have as many of the symbols as</span></td></tr>
|
---|
2208 | <tr><td class="num" id="LN2129">2129</td><td class="line"> <span class='comment'>// the preferred font, go back to using the user's preferred font.</span></td></tr>
|
---|
2209 | <tr><td class="num" id="LN2130">2130</td><td class="line"> </td></tr>
|
---|
2210 | <tr><td class="num" id="LN2131">2131</td><td class="line"> <span class='keyword'>bool</span> *boolArray;</td></tr>
|
---|
2211 | <tr><td class="num" id="LN2132">2132</td><td class="line"> <span class='keyword'>int</span> missingCharactersFixedWidth = 0;</td></tr>
|
---|
2212 | <tr><td class="num" id="LN2133">2133</td><td class="line"> <span class='keyword'>int</span> missingCharactersPreferredFont = 0;</td></tr>
|
---|
2213 | <tr><td class="num" id="LN2134">2134</td><td class="line"> int32 numberOfCharacters;</td></tr>
|
---|
2214 | <tr><td class="num" id="LN2135">2135</td><td class="line"> </td></tr>
|
---|
2215 | <tr><td class="num" id="LN2136">2136</td><td class="line"> numberOfCharacters = BString(text).CountChars();</td></tr>
|
---|
2216 | <tr><td class="num" id="LN2137">2137</td><td class="line"> <span class='keyword'>if</span> (numberOfCharacters > 0</td></tr>
|
---|
2217 | <tr><td class="num" id="LN2138">2138</td><td class="line"> && (boolArray = (<span class='keyword'>bool</span> *)malloc(<span class='keyword'>sizeof</span>(<span class='keyword'>bool</span>) * numberOfCharacters)) != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
2218 | <tr><td class="num" id="LN2139">2139</td><td class="line"> memset(boolArray, 0, <span class='keyword'>sizeof</span> (<span class='keyword'>bool</span>) * numberOfCharacters);</td></tr>
|
---|
2219 | <tr><td class="num" id="LN2140">2140</td><td class="line"> be_fixed_font->GetHasGlyphs(text, numberOfCharacters, boolArray);</td></tr>
|
---|
2220 | <tr><td class="num" id="LN2141">2141</td><td class="line"> <span class='keyword'>for</span> (<span class='keyword'>int</span> i = 0; i < numberOfCharacters; i++) {</td></tr>
|
---|
2221 | <tr><td class="num" id="LN2142">2142</td><td class="line"> <span class='keyword'>if</span> (!boolArray[i])</td></tr>
|
---|
2222 | <tr><td class="num" id="LN2143">2143</td><td class="line"> missingCharactersFixedWidth += 1;</td></tr>
|
---|
2223 | <tr><td class="num" id="LN2144">2144</td><td class="line"> }</td></tr>
|
---|
2224 | <tr><td class="num" id="LN2145">2145</td><td class="line"> </td></tr>
|
---|
2225 | <tr><td class="num" id="LN2146">2146</td><td class="line"> memset(boolArray, 0, <span class='keyword'>sizeof</span> (<span class='keyword'>bool</span>) * numberOfCharacters);</td></tr>
|
---|
2226 | <tr><td class="num" id="LN2147">2147</td><td class="line"> fFont.GetHasGlyphs(text, numberOfCharacters, boolArray);</td></tr>
|
---|
2227 | <tr><td class="num" id="LN2148">2148</td><td class="line"> <span class='keyword'>for</span> (<span class='keyword'>int</span> i = 0; i < numberOfCharacters; i++) {</td></tr>
|
---|
2228 | <tr><td class="num" id="LN2149">2149</td><td class="line"> <span class='keyword'>if</span> (!boolArray[i])</td></tr>
|
---|
2229 | <tr><td class="num" id="LN2150">2150</td><td class="line"> missingCharactersPreferredFont += 1;</td></tr>
|
---|
2230 | <tr><td class="num" id="LN2151">2151</td><td class="line"> }</td></tr>
|
---|
2231 | <tr><td class="num" id="LN2152">2152</td><td class="line"> </td></tr>
|
---|
2232 | <tr><td class="num" id="LN2153">2153</td><td class="line"> free(boolArray);</td></tr>
|
---|
2233 | <tr><td class="num" id="LN2154">2154</td><td class="line"> }</td></tr>
|
---|
2234 | <tr><td class="num" id="LN2155">2155</td><td class="line"> </td></tr>
|
---|
2235 | <tr><td class="num" id="LN2156">2156</td><td class="line"> <span class='keyword'>if</span> (missingCharactersFixedWidth > missingCharactersPreferredFont)</td></tr>
|
---|
2236 | <tr><td class="num" id="LN2157">2157</td><td class="line"> SetFontAndColor(0, textLength, &fFont);</td></tr>
|
---|
2237 | <tr><td class="num" id="LN2158">2158</td><td class="line"> <span class='keyword'>else</span> <span class='comment'>// All things being equal, the fixed font is better for wrapping.</span></td></tr>
|
---|
2238 | <tr><td class="num" id="LN2159">2159</td><td class="line"> SetFontAndColor(0, textLength, be_fixed_font);</td></tr>
|
---|
2239 | <tr><td class="num" id="LN2160">2160</td><td class="line"> </td></tr>
|
---|
2240 | <tr><td class="num" id="LN2161">2161</td><td class="line"> <span class='comment'>// calculate a text rect that is 72 columns wide</span></td></tr>
|
---|
2241 | <tr><td class="num" id="LN2162">2162</td><td class="line"> BRect newTextRect = saveTextRect;</td></tr>
|
---|
2242 | <tr><td class="num" id="LN2163">2163</td><td class="line"> newTextRect.right = newTextRect.left + be_fixed_font->StringWidth(<span class='string_literal'>"m"</span>) * 72;</td></tr>
|
---|
2243 | <tr><td class="num" id="LN2164">2164</td><td class="line"> SetTextRect(newTextRect);</td></tr>
|
---|
2244 | <tr><td class="num" id="LN2165">2165</td><td class="line"> </td></tr>
|
---|
2245 | <tr><td class="num" id="LN2166">2166</td><td class="line"> <span class='comment'>// hard-wrap, based on TextView's soft-wrapping</span></td></tr>
|
---|
2246 | <tr><td class="num" id="LN2167">2167</td><td class="line"> int32 numLines = CountLines();</td></tr>
|
---|
2247 | <tr><td class="num" id="LN2168">2168</td><td class="line"> <span class='keyword'>bool</span> spaceMoved = <span class='keyword'>false</span>;</td></tr>
|
---|
2248 | <tr><td class="num" id="LN2169">2169</td><td class="line"> <span class='keyword'>char</span> *content = (<span class='keyword'>char</span> *)malloc(textLength + numLines * 72); <span class='comment'>// more we'll ever need</span></td></tr>
|
---|
2249 | <tr><td class="num" id="LN2170">2170</td><td class="line"> <span class='keyword'>if</span> (content != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
2250 | <tr><td class="num" id="LN2171">2171</td><td class="line"> int32 contentLength = 0;</td></tr>
|
---|
2251 | <tr><td class="num" id="LN2172">2172</td><td class="line"> </td></tr>
|
---|
2252 | <tr><td class="num" id="LN2173">2173</td><td class="line"> <span class='keyword'>for</span> (int32 i = 0; i < numLines; i++) {</td></tr>
|
---|
2253 | <tr><td class="num" id="LN2174">2174</td><td class="line"> int32 startOffset = OffsetAt(i);</td></tr>
|
---|
2254 | <tr><td class="num" id="LN2175">2175</td><td class="line"> <span class='keyword'>if</span> (spaceMoved) {</td></tr>
|
---|
2255 | <tr><td class="num" id="LN2176">2176</td><td class="line"> startOffset++;</td></tr>
|
---|
2256 | <tr><td class="num" id="LN2177">2177</td><td class="line"> spaceMoved = <span class='keyword'>false</span>;</td></tr>
|
---|
2257 | <tr><td class="num" id="LN2178">2178</td><td class="line"> }</td></tr>
|
---|
2258 | <tr><td class="num" id="LN2179">2179</td><td class="line"> int32 endOffset = OffsetAt(i + 1);</td></tr>
|
---|
2259 | <tr><td class="num" id="LN2180">2180</td><td class="line"> int32 lineLength = endOffset - startOffset;</td></tr>
|
---|
2260 | <tr><td class="num" id="LN2181">2181</td><td class="line"> </td></tr>
|
---|
2261 | <tr><td class="num" id="LN2182">2182</td><td class="line"> <span class='comment'>// quick hack to not break URLs into several parts</span></td></tr>
|
---|
2262 | <tr><td class="num" id="LN2183">2183</td><td class="line"> <span class='keyword'>for</span> (int32 pos = startOffset; pos < endOffset; pos++) {</td></tr>
|
---|
2263 | <tr><td class="num" id="LN2184">2184</td><td class="line"> size_t urlLength;</td></tr>
|
---|
2264 | <tr><td class="num" id="LN2185">2185</td><td class="line"> uint8 type = CheckForURL(text + pos, urlLength);</td></tr>
|
---|
2265 | <tr><td class="num" id="LN2186">2186</td><td class="line"> <span class='keyword'>if</span> (type != 0)</td></tr>
|
---|
2266 | <tr><td class="num" id="LN2187">2187</td><td class="line"> pos += urlLength;</td></tr>
|
---|
2267 | <tr><td class="num" id="LN2188">2188</td><td class="line"> </td></tr>
|
---|
2268 | <tr><td class="num" id="LN2189">2189</td><td class="line"> <span class='keyword'>if</span> (pos > endOffset) {</td></tr>
|
---|
2269 | <tr><td class="num" id="LN2190">2190</td><td class="line"> <span class='comment'>// find first break character after the URL</span></td></tr>
|
---|
2270 | <tr><td class="num" id="LN2191">2191</td><td class="line"> <span class='keyword'>for</span> (; text[pos]; pos++) {</td></tr>
|
---|
2271 | <tr><td class="num" id="LN2192">2192</td><td class="line"> <span class='keyword'>if</span> (<span class='macro'>isalnum(text[pos])<span class='expansion'>(__ctype_b[(int)((text[pos]))] & (unsigned short int)_ISalnum<br>)</span></span> || <span class='macro'>isspace(text[pos])<span class='expansion'>(__ctype_b[(int)((text[pos]))] & (unsigned short int)_ISspace<br>)</span></span>)</td></tr>
|
---|
2272 | <tr><td class="num" id="LN2193">2193</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
2273 | <tr><td class="num" id="LN2194">2194</td><td class="line"> }</td></tr>
|
---|
2274 | <tr><td class="num" id="LN2195">2195</td><td class="line"> <span class='keyword'>if</span> (text[pos] && <span class='macro'>isspace(text[pos])<span class='expansion'>(__ctype_b[(int)((text[pos]))] & (unsigned short int)_ISspace<br>)</span></span> && text[pos] != '\n')</td></tr>
|
---|
2275 | <tr><td class="num" id="LN2196">2196</td><td class="line"> pos++;</td></tr>
|
---|
2276 | <tr><td class="num" id="LN2197">2197</td><td class="line"> </td></tr>
|
---|
2277 | <tr><td class="num" id="LN2198">2198</td><td class="line"> endOffset += pos - endOffset;</td></tr>
|
---|
2278 | <tr><td class="num" id="LN2199">2199</td><td class="line"> lineLength = endOffset - startOffset;</td></tr>
|
---|
2279 | <tr><td class="num" id="LN2200">2200</td><td class="line"> </td></tr>
|
---|
2280 | <tr><td class="num" id="LN2201">2201</td><td class="line"> <span class='comment'>// insert a newline (and the same number of quotes) after the</span></td></tr>
|
---|
2281 | <tr><td class="num" id="LN2202">2202</td><td class="line"> <span class='comment'>// URL to make sure the rest of the text is properly wrapped</span></td></tr>
|
---|
2282 | <tr><td class="num" id="LN2203">2203</td><td class="line"> </td></tr>
|
---|
2283 | <tr><td class="num" id="LN2204">2204</td><td class="line"> <span class='keyword'>char</span> buffer[64];</td></tr>
|
---|
2284 | <tr><td class="num" id="LN2205">2205</td><td class="line"> <span class='keyword'>if</span> (text[pos] == '\n')</td></tr>
|
---|
2285 | <tr><td class="num" id="LN2206">2206</td><td class="line"> buffer[0] = '\0';</td></tr>
|
---|
2286 | <tr><td class="num" id="LN2207">2207</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
2287 | <tr><td class="num" id="LN2208">2208</td><td class="line"> strcpy(buffer, <span class='string_literal'>"\n"</span>);</td></tr>
|
---|
2288 | <tr><td class="num" id="LN2209">2209</td><td class="line"> </td></tr>
|
---|
2289 | <tr><td class="num" id="LN2210">2210</td><td class="line"> size_t quoteLength;</td></tr>
|
---|
2290 | <tr><td class="num" id="LN2211">2211</td><td class="line"> CopyQuotes(text + startOffset, lineLength, buffer + strlen(buffer), quoteLength);</td></tr>
|
---|
2291 | <tr><td class="num" id="LN2212">2212</td><td class="line"> </td></tr>
|
---|
2292 | <tr><td class="num" id="LN2213">2213</td><td class="line"> Insert(pos, buffer, strlen(buffer));</td></tr>
|
---|
2293 | <tr><td class="num" id="LN2214">2214</td><td class="line"> numLines = CountLines();</td></tr>
|
---|
2294 | <tr><td class="num" id="LN2215">2215</td><td class="line"> text = Text();</td></tr>
|
---|
2295 | <tr><td class="num" id="LN2216">2216</td><td class="line"> i++;</td></tr>
|
---|
2296 | <tr><td class="num" id="LN2217">2217</td><td class="line"> }</td></tr>
|
---|
2297 | <tr><td class="num" id="LN2218">2218</td><td class="line"> }</td></tr>
|
---|
2298 | <tr><td class="num" id="LN2219">2219</td><td class="line"> <span class='keyword'>if</span> (text[endOffset - 1] != ' '</td></tr>
|
---|
2299 | <tr><td class="num" id="LN2220">2220</td><td class="line"> && text[endOffset - 1] != '\n'</td></tr>
|
---|
2300 | <tr><td class="num" id="LN2221">2221</td><td class="line"> && text[endOffset] == ' ') {</td></tr>
|
---|
2301 | <tr><td class="num" id="LN2222">2222</td><td class="line"> <span class='comment'>// make sure spaces will be part of this line</span></td></tr>
|
---|
2302 | <tr><td class="num" id="LN2223">2223</td><td class="line"> endOffset++;</td></tr>
|
---|
2303 | <tr><td class="num" id="LN2224">2224</td><td class="line"> lineLength++;</td></tr>
|
---|
2304 | <tr><td class="num" id="LN2225">2225</td><td class="line"> spaceMoved = <span class='keyword'>true</span>;</td></tr>
|
---|
2305 | <tr><td class="num" id="LN2226">2226</td><td class="line"> }</td></tr>
|
---|
2306 | <tr><td class="num" id="LN2227">2227</td><td class="line"> </td></tr>
|
---|
2307 | <tr><td class="num" id="LN2228">2228</td><td class="line"> memcpy(content + contentLength, text + startOffset, lineLength);</td></tr>
|
---|
2308 | <tr><td class="num" id="LN2229">2229</td><td class="line"> contentLength += lineLength;</td></tr>
|
---|
2309 | <tr><td class="num" id="LN2230">2230</td><td class="line"> </td></tr>
|
---|
2310 | <tr><td class="num" id="LN2231">2231</td><td class="line"> <span class='comment'>// add a newline to every line except for the ones</span></td></tr>
|
---|
2311 | <tr><td class="num" id="LN2232">2232</td><td class="line"> <span class='comment'>// that already end in newlines, and the last line</span></td></tr>
|
---|
2312 | <tr><td class="num" id="LN2233">2233</td><td class="line"> <span class='keyword'>if</span> ((text[endOffset - 1] != '\n') && (i < numLines - 1)) {</td></tr>
|
---|
2313 | <tr><td class="num" id="LN2234">2234</td><td class="line"> content[contentLength++] = '\n';</td></tr>
|
---|
2314 | <tr><td class="num" id="LN2235">2235</td><td class="line"> </td></tr>
|
---|
2315 | <tr><td class="num" id="LN2236">2236</td><td class="line"> <span class='comment'>// copy quote level of the first line</span></td></tr>
|
---|
2316 | <tr><td class="num" id="LN2237">2237</td><td class="line"> size_t quoteLength;</td></tr>
|
---|
2317 | <tr><td class="num" id="LN2238">2238</td><td class="line"> CopyQuotes(text + startOffset, lineLength, content + contentLength, quoteLength);</td></tr>
|
---|
2318 | <tr><td class="num" id="LN2239">2239</td><td class="line"> contentLength += quoteLength;</td></tr>
|
---|
2319 | <tr><td class="num" id="LN2240">2240</td><td class="line"> }</td></tr>
|
---|
2320 | <tr><td class="num" id="LN2241">2241</td><td class="line"> }</td></tr>
|
---|
2321 | <tr><td class="num" id="LN2242">2242</td><td class="line"> content[contentLength] = '\0';</td></tr>
|
---|
2322 | <tr><td class="num" id="LN2243">2243</td><td class="line"> </td></tr>
|
---|
2323 | <tr><td class="num" id="LN2244">2244</td><td class="line"> body->AppendText(content);</td></tr>
|
---|
2324 | <tr><td class="num" id="LN2245">2245</td><td class="line"> free(content);</td></tr>
|
---|
2325 | <tr><td class="num" id="LN2246">2246</td><td class="line"> }</td></tr>
|
---|
2326 | <tr><td class="num" id="LN2247">2247</td><td class="line"> </td></tr>
|
---|
2327 | <tr><td class="num" id="LN2248">2248</td><td class="line"> <span class='comment'>// reset the text rect and font</span></td></tr>
|
---|
2328 | <tr><td class="num" id="LN2249">2249</td><td class="line"> SetTextRect(saveTextRect);</td></tr>
|
---|
2329 | <tr><td class="num" id="LN2250">2250</td><td class="line"> SetText(saveText);</td></tr>
|
---|
2330 | <tr><td class="num" id="LN2251">2251</td><td class="line"> free(saveText);</td></tr>
|
---|
2331 | <tr><td class="num" id="LN2252">2252</td><td class="line"> SetFontAndColor(0, textLength, &fFont);</td></tr>
|
---|
2332 | <tr><td class="num" id="LN2253">2253</td><td class="line"> </td></tr>
|
---|
2333 | <tr><td class="num" id="LN2254">2254</td><td class="line"> <span class='comment'>// should be OK to hook these back up now</span></td></tr>
|
---|
2334 | <tr><td class="num" id="LN2255">2255</td><td class="line"> <span class='keyword'>if</span> (vScroller != <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2335 | <tr><td class="num" id="LN2256">2256</td><td class="line"> vScroller->SetTarget(<span class='keyword'>this</span>);</td></tr>
|
---|
2336 | <tr><td class="num" id="LN2257">2257</td><td class="line"> <span class='keyword'>if</span> (hScroller != <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2337 | <tr><td class="num" id="LN2258">2258</td><td class="line"> hScroller->SetTarget(<span class='keyword'>this</span>);</td></tr>
|
---|
2338 | <tr><td class="num" id="LN2259">2259</td><td class="line"> </td></tr>
|
---|
2339 | <tr><td class="num" id="LN2260">2260</td><td class="line"> Show();</td></tr>
|
---|
2340 | <tr><td class="num" id="LN2261">2261</td><td class="line"> window->EnableUpdates();</td></tr>
|
---|
2341 | <tr><td class="num" id="LN2262">2262</td><td class="line">}</td></tr>
|
---|
2342 | <tr><td class="num" id="LN2263">2263</td><td class="line"> </td></tr>
|
---|
2343 | <tr><td class="num" id="LN2264">2264</td><td class="line"> </td></tr>
|
---|
2344 | <tr><td class="num" id="LN2265">2265</td><td class="line"><span class='comment'>// #pragma mark -</span></td></tr>
|
---|
2345 | <tr><td class="num" id="LN2266">2266</td><td class="line"> </td></tr>
|
---|
2346 | <tr><td class="num" id="LN2267">2267</td><td class="line"> </td></tr>
|
---|
2347 | <tr><td class="num" id="LN2268">2268</td><td class="line">TTextView::Reader::Reader(<span class='keyword'>bool</span> header, <span class='keyword'>bool</span> raw, <span class='keyword'>bool</span> quote, <span class='keyword'>bool</span> incoming,</td></tr>
|
---|
2348 | <tr><td class="num" id="LN2269">2269</td><td class="line"> <span class='keyword'>bool</span> stripHeader, <span class='keyword'>bool</span> mime, TTextView *view, BEmailMessage *mail,</td></tr>
|
---|
2349 | <tr><td class="num" id="LN2270">2270</td><td class="line"> BList *list, sem_id sem)</td></tr>
|
---|
2350 | <tr><td class="num" id="LN2271">2271</td><td class="line"> :</td></tr>
|
---|
2351 | <tr><td class="num" id="LN2272">2272</td><td class="line"> fHeader(header),</td></tr>
|
---|
2352 | <tr><td class="num" id="LN2273">2273</td><td class="line"> fRaw(raw),</td></tr>
|
---|
2353 | <tr><td class="num" id="LN2274">2274</td><td class="line"> fQuote(quote),</td></tr>
|
---|
2354 | <tr><td class="num" id="LN2275">2275</td><td class="line"> fIncoming(incoming),</td></tr>
|
---|
2355 | <tr><td class="num" id="LN2276">2276</td><td class="line"> fStripHeader(stripHeader),</td></tr>
|
---|
2356 | <tr><td class="num" id="LN2277">2277</td><td class="line"> fMime(mime),</td></tr>
|
---|
2357 | <tr><td class="num" id="LN2278">2278</td><td class="line"> fView(view),</td></tr>
|
---|
2358 | <tr><td class="num" id="LN2279">2279</td><td class="line"> fMail(mail),</td></tr>
|
---|
2359 | <tr><td class="num" id="LN2280">2280</td><td class="line"> fEnclosures(list),</td></tr>
|
---|
2360 | <tr><td class="num" id="LN2281">2281</td><td class="line"> fStopSem(sem)</td></tr>
|
---|
2361 | <tr><td class="num" id="LN2282">2282</td><td class="line">{</td></tr>
|
---|
2362 | <tr><td class="num" id="LN2283">2283</td><td class="line">}</td></tr>
|
---|
2363 | <tr><td class="num" id="LN2284">2284</td><td class="line"> </td></tr>
|
---|
2364 | <tr><td class="num" id="LN2285">2285</td><td class="line"> </td></tr>
|
---|
2365 | <tr><td class="num" id="LN2286">2286</td><td class="line"><span class='keyword'>bool</span></td></tr>
|
---|
2366 | <tr><td class="num" id="LN2287">2287</td><td class="line">TTextView::Reader::ParseMail(BMailContainer *container,</td></tr>
|
---|
2367 | <tr><td class="num" id="LN2288">2288</td><td class="line"> BTextMailComponent *ignore)</td></tr>
|
---|
2368 | <tr><td class="num" id="LN2289">2289</td><td class="line">{</td></tr>
|
---|
2369 | <tr><td class="num" id="LN2290">2290</td><td class="line"> int32 count = 0;</td></tr>
|
---|
2370 | <tr><td class="num" id="LN2291">2291</td><td class="line"> <span class='keyword'>for</span> (int32 i = 0; i < container->CountComponents(); i++) {</td></tr>
|
---|
2371 | <tr><td class="num" id="LN2292">2292</td><td class="line"> <span class='keyword'>if</span> (fView->fStopLoading)</td></tr>
|
---|
2372 | <tr><td class="num" id="LN2293">2293</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2373 | <tr><td class="num" id="LN2294">2294</td><td class="line"> </td></tr>
|
---|
2374 | <tr><td class="num" id="LN2295">2295</td><td class="line"> BMailComponent *component;</td></tr>
|
---|
2375 | <tr><td class="num" id="LN2296">2296</td><td class="line"> <span class='keyword'>if</span> ((component = container->GetComponent(i)) == <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
2376 | <tr><td class="num" id="LN2297">2297</td><td class="line"> <span class='keyword'>if</span> (fView->fStopLoading)</td></tr>
|
---|
2377 | <tr><td class="num" id="LN2298">2298</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2378 | <tr><td class="num" id="LN2299">2299</td><td class="line"> </td></tr>
|
---|
2379 | <tr><td class="num" id="LN2300">2300</td><td class="line"> hyper_text *enclosure = (hyper_text *)malloc(<span class='keyword'>sizeof</span>(hyper_text));</td></tr>
|
---|
2380 | <tr><td class="num" id="LN2301">2301</td><td class="line"> <span class='keyword'>if</span> (enclosure == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2381 | <tr><td class="num" id="LN2302">2302</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2382 | <tr><td class="num" id="LN2303">2303</td><td class="line"> </td></tr>
|
---|
2383 | <tr><td class="num" id="LN2304">2304</td><td class="line"> memset(enclosure, 0, <span class='keyword'>sizeof</span>(hyper_text));</td></tr>
|
---|
2384 | <tr><td class="num" id="LN2305">2305</td><td class="line"> </td></tr>
|
---|
2385 | <tr><td class="num" id="LN2306">2306</td><td class="line"> enclosure->type = TYPE_ENCLOSURE;</td></tr>
|
---|
2386 | <tr><td class="num" id="LN2307">2307</td><td class="line"> </td></tr>
|
---|
2387 | <tr><td class="num" id="LN2308">2308</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *name = <span class='string_literal'>"\n<Attachment: could not handle>\n"</span>;</td></tr>
|
---|
2388 | <tr><td class="num" id="LN2309">2309</td><td class="line"> </td></tr>
|
---|
2389 | <tr><td class="num" id="LN2310">2310</td><td class="line"> fView->GetSelection(&enclosure->text_start, &enclosure->text_end);</td></tr>
|
---|
2390 | <tr><td class="num" id="LN2311">2311</td><td class="line"> enclosure->text_start++;</td></tr>
|
---|
2391 | <tr><td class="num" id="LN2312">2312</td><td class="line"> enclosure->text_end += strlen(name) - 1;</td></tr>
|
---|
2392 | <tr><td class="num" id="LN2313">2313</td><td class="line"> </td></tr>
|
---|
2393 | <tr><td class="num" id="LN2314">2314</td><td class="line"> Insert(name, strlen(name), <span class='keyword'>true</span>);</td></tr>
|
---|
2394 | <tr><td class="num" id="LN2315">2315</td><td class="line"> fEnclosures->AddItem(enclosure);</td></tr>
|
---|
2395 | <tr><td class="num" id="LN2316">2316</td><td class="line"> <span class='keyword'>continue</span>;</td></tr>
|
---|
2396 | <tr><td class="num" id="LN2317">2317</td><td class="line"> }</td></tr>
|
---|
2397 | <tr><td class="num" id="LN2318">2318</td><td class="line"> </td></tr>
|
---|
2398 | <tr><td class="num" id="LN2319">2319</td><td class="line"> count++;</td></tr>
|
---|
2399 | <tr><td class="num" id="LN2320">2320</td><td class="line"> <span class='keyword'>if</span> (component == ignore)</td></tr>
|
---|
2400 | <tr><td class="num" id="LN2321">2321</td><td class="line"> <span class='keyword'>continue</span>;</td></tr>
|
---|
2401 | <tr><td class="num" id="LN2322">2322</td><td class="line"> </td></tr>
|
---|
2402 | <tr><td class="num" id="LN2323">2323</td><td class="line"> <span class='keyword'>if</span> (component->ComponentType() == B_MAIL_MULTIPART_CONTAINER) {</td></tr>
|
---|
2403 | <tr><td class="num" id="LN2324">2324</td><td class="line"> BMIMEMultipartMailContainer *c = <span class='keyword'>dynamic_cast</span><BMIMEMultipartMailContainer *>(container->GetComponent(i));</td></tr>
|
---|
2404 | <tr><td class="num" id="LN2325">2325</td><td class="line"> <span class='macro'>ASSERT(c != NULL)<span class='expansion'>(void)0</span></span>;</td></tr>
|
---|
2405 | <tr><td class="num" id="LN2326">2326</td><td class="line"> </td></tr>
|
---|
2406 | <tr><td class="num" id="LN2327">2327</td><td class="line"> <span class='keyword'>if</span> (!ParseMail(c, ignore))</td></tr>
|
---|
2407 | <tr><td class="num" id="LN2328">2328</td><td class="line"> count--;</td></tr>
|
---|
2408 | <tr><td class="num" id="LN2329">2329</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (fIncoming) {</td></tr>
|
---|
2409 | <tr><td class="num" id="LN2330">2330</td><td class="line"> hyper_text *enclosure = (hyper_text *)malloc(<span class='keyword'>sizeof</span>(hyper_text));</td></tr>
|
---|
2410 | <tr><td class="num" id="LN2331">2331</td><td class="line"> <span class='keyword'>if</span> (enclosure == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2411 | <tr><td class="num" id="LN2332">2332</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2412 | <tr><td class="num" id="LN2333">2333</td><td class="line"> </td></tr>
|
---|
2413 | <tr><td class="num" id="LN2334">2334</td><td class="line"> memset(enclosure, 0, <span class='keyword'>sizeof</span>(hyper_text));</td></tr>
|
---|
2414 | <tr><td class="num" id="LN2335">2335</td><td class="line"> </td></tr>
|
---|
2415 | <tr><td class="num" id="LN2336">2336</td><td class="line"> enclosure->type = TYPE_ENCLOSURE;</td></tr>
|
---|
2416 | <tr><td class="num" id="LN2337">2337</td><td class="line"> enclosure->component = component;</td></tr>
|
---|
2417 | <tr><td class="num" id="LN2338">2338</td><td class="line"> </td></tr>
|
---|
2418 | <tr><td class="num" id="LN2339">2339</td><td class="line"> BString name;</td></tr>
|
---|
2419 | <tr><td class="num" id="LN2340">2340</td><td class="line"> <span class='keyword'>char</span> fileName[<span class='macro'>B_FILE_NAME_LENGTH<span class='expansion'>(256)</span></span>];</td></tr>
|
---|
2420 | <tr><td class="num" id="LN2341">2341</td><td class="line"> strcpy(fileName, <span class='string_literal'>"untitled"</span>);</td></tr>
|
---|
2421 | <tr><td class="num" id="LN2342">2342</td><td class="line"> <span class='keyword'>if</span> (BMailAttachment *attachment = <span class='keyword'>dynamic_cast</span> <BMailAttachment *> (component))</td></tr>
|
---|
2422 | <tr><td class="num" id="LN2343">2343</td><td class="line"> attachment->FileName(fileName);</td></tr>
|
---|
2423 | <tr><td class="num" id="LN2344">2344</td><td class="line"> </td></tr>
|
---|
2424 | <tr><td class="num" id="LN2345">2345</td><td class="line"> BPath path(fileName);</td></tr>
|
---|
2425 | <tr><td class="num" id="LN2346">2346</td><td class="line"> enclosure->name = strdup(path.Leaf());</td></tr>
|
---|
2426 | <tr><td class="num" id="LN2347">2347</td><td class="line"> </td></tr>
|
---|
2427 | <tr><td class="num" id="LN2348">2348</td><td class="line"> BMimeType type;</td></tr>
|
---|
2428 | <tr><td class="num" id="LN2349">2349</td><td class="line"> component->MIMEType(&type);</td></tr>
|
---|
2429 | <tr><td class="num" id="LN2350">2350</td><td class="line"> enclosure->content_type = strdup(type.Type());</td></tr>
|
---|
2430 | <tr><td class="num" id="LN2351">2351</td><td class="line"> </td></tr>
|
---|
2431 | <tr><td class="num" id="LN2352">2352</td><td class="line"> <span class='keyword'>char</span> typeDescription[<span class='macro'>B_MIME_TYPE_LENGTH<span class='expansion'>(((256)-1) - 15)</span></span>];</td></tr>
|
---|
2432 | <tr><td class="num" id="LN2353">2353</td><td class="line"> <span class='keyword'>if</span> (type.GetShortDescription(typeDescription) != <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
2433 | <tr><td class="num" id="LN2354">2354</td><td class="line"> strcpy(typeDescription, type.Type() ? type.Type() : B_EMPTY_STRING);</td></tr>
|
---|
2434 | <tr><td class="num" id="LN2355">2355</td><td class="line"> </td></tr>
|
---|
2435 | <tr><td class="num" id="LN2356">2356</td><td class="line"> name = <span class='string_literal'>"\n<"</span>;</td></tr>
|
---|
2436 | <tr><td class="num" id="LN2357">2357</td><td class="line"> name.Append(<span class='macro'>B_TRANSLATE_COMMENT(<span class='string_literal'>"Enclosure: %name% (Type: %type%)"</span>,<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Enclosure: %name% (Type: %type%)"<br>), "Mail", ("Don't translate the variables %name% and %type%."<br>))</span></span></td></tr>
|
---|
2437 | <tr><td class="num" id="LN2358">2358</td><td class="line"> <span class='string_literal'><span class='macro'>"Don't translate the variables %name% and %type%."</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Enclosure: %name% (Type: %type%)"<br>), "Mail", ("Don't translate the variables %name% and %type%."<br>))</span></span>);</td></tr>
|
---|
2438 | <tr><td class="num" id="LN2359">2359</td><td class="line"> name.Append(<span class='string_literal'>">\n"</span>);</td></tr>
|
---|
2439 | <tr><td class="num" id="LN2360">2360</td><td class="line"> name.ReplaceFirst(<span class='string_literal'>"%name%"</span>, enclosure->name);</td></tr>
|
---|
2440 | <tr><td class="num" id="LN2361">2361</td><td class="line"> name.ReplaceFirst(<span class='string_literal'>"%type%"</span>, typeDescription);</td></tr>
|
---|
2441 | <tr><td class="num" id="LN2362">2362</td><td class="line"> </td></tr>
|
---|
2442 | <tr><td class="num" id="LN2363">2363</td><td class="line"> fView->GetSelection(&enclosure->text_start, &enclosure->text_end);</td></tr>
|
---|
2443 | <tr><td class="num" id="LN2364">2364</td><td class="line"> enclosure->text_start++;</td></tr>
|
---|
2444 | <tr><td class="num" id="LN2365">2365</td><td class="line"> enclosure->text_end += strlen(name.String()) - 1;</td></tr>
|
---|
2445 | <tr><td class="num" id="LN2366">2366</td><td class="line"> </td></tr>
|
---|
2446 | <tr><td class="num" id="LN2367">2367</td><td class="line"> Insert(name.String(), name.Length(), <span class='keyword'>true</span>);</td></tr>
|
---|
2447 | <tr><td class="num" id="LN2368">2368</td><td class="line"> fEnclosures->AddItem(enclosure);</td></tr>
|
---|
2448 | <tr><td class="num" id="LN2369">2369</td><td class="line"> }</td></tr>
|
---|
2449 | <tr><td class="num" id="LN2370">2370</td><td class="line"><span class='comment'>// default:</span></td></tr>
|
---|
2450 | <tr><td class="num" id="LN2371">2371</td><td class="line"><span class='comment'>// {</span></td></tr>
|
---|
2451 | <tr><td class="num" id="LN2372">2372</td><td class="line"><span class='comment'>// PlainTextBodyComponent *body = dynamic_cast<PlainTextBodyComponent *>(container->GetComponent(i));</span></td></tr>
|
---|
2452 | <tr><td class="num" id="LN2373">2373</td><td class="line"><span class='comment'>// const char *text;</span></td></tr>
|
---|
2453 | <tr><td class="num" id="LN2374">2374</td><td class="line"><span class='comment'>// if (body && (text = body->Text()) != NULL)</span></td></tr>
|
---|
2454 | <tr><td class="num" id="LN2375">2375</td><td class="line"><span class='comment'>// Insert(text, strlen(text), false);</span></td></tr>
|
---|
2455 | <tr><td class="num" id="LN2376">2376</td><td class="line"><span class='comment'>// }</span></td></tr>
|
---|
2456 | <tr><td class="num" id="LN2377">2377</td><td class="line"> }</td></tr>
|
---|
2457 | <tr><td class="num" id="LN2378">2378</td><td class="line"> <span class='keyword'>return</span> count > 0;</td></tr>
|
---|
2458 | <tr><td class="num" id="LN2379">2379</td><td class="line">}</td></tr>
|
---|
2459 | <tr><td class="num" id="LN2380">2380</td><td class="line"> </td></tr>
|
---|
2460 | <tr><td class="num" id="LN2381">2381</td><td class="line"> </td></tr>
|
---|
2461 | <tr><td class="num" id="LN2382">2382</td><td class="line"><span class='keyword'>bool</span></td></tr>
|
---|
2462 | <tr><td class="num" id="LN2383">2383</td><td class="line">TTextView::Reader::Process(<span class='keyword'>const</span> <span class='keyword'>char</span> *data, int32 data_len, <span class='keyword'>bool</span> isHeader)</td></tr>
|
---|
2463 | <tr><td class="num" id="LN2384">2384</td><td class="line">{</td></tr>
|
---|
2464 | <tr><td class="num" id="LN2385">2385</td><td class="line"> <span class='keyword'>char</span> line[522];</td></tr>
|
---|
2465 | <tr><td class="num" id="LN2386">2386</td><td class="line"> int32 count = 0;</td></tr>
|
---|
2466 | <tr><td class="num" id="LN2387">2387</td><td class="line"> </td></tr>
|
---|
2467 | <tr><td class="num" id="LN2388">2388</td><td class="line"> <span class='keyword'>for</span> (int32 loop = 0; loop < data_len; loop++) {</td></tr>
|
---|
2468 | <tr><td class="num" id="LN2389">2389</td><td class="line"> <span class='keyword'>if</span> (fView->fStopLoading)</td></tr>
|
---|
2469 | <tr><td class="num" id="LN2390">2390</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2470 | <tr><td class="num" id="LN2391">2391</td><td class="line"> </td></tr>
|
---|
2471 | <tr><td class="num" id="LN2392">2392</td><td class="line"> <span class='keyword'>if</span> (fQuote && (!loop || (loop && data[loop - 1] == '\n'))) {</td></tr>
|
---|
2472 | <tr><td class="num" id="LN2393">2393</td><td class="line"> strcpy(&line[count], <span class='macro'>QUOTE<span class='expansion'>"> "</span></span>);</td></tr>
|
---|
2473 | <tr><td class="num" id="LN2394">2394</td><td class="line"> count += strlen(<span class='macro'>QUOTE<span class='expansion'>"> "</span></span>);</td></tr>
|
---|
2474 | <tr><td class="num" id="LN2395">2395</td><td class="line"> }</td></tr>
|
---|
2475 | <tr><td class="num" id="LN2396">2396</td><td class="line"> <span class='keyword'>if</span> (!fRaw && fIncoming && (loop < data_len - 7)) {</td></tr>
|
---|
2476 | <tr><td class="num" id="LN2397">2397</td><td class="line"> size_t urlLength;</td></tr>
|
---|
2477 | <tr><td class="num" id="LN2398">2398</td><td class="line"> BString url;</td></tr>
|
---|
2478 | <tr><td class="num" id="LN2399">2399</td><td class="line"> uint8 type = CheckForURL(data + loop, urlLength, &url);</td></tr>
|
---|
2479 | <tr><td class="num" id="LN2400">2400</td><td class="line"> </td></tr>
|
---|
2480 | <tr><td class="num" id="LN2401">2401</td><td class="line"> <span class='keyword'>if</span> (type) {</td></tr>
|
---|
2481 | <tr><td class="num" id="LN2402">2402</td><td class="line"> <span class='keyword'>if</span> (!Insert(line, count, <span class='keyword'>false</span>, isHeader))</td></tr>
|
---|
2482 | <tr><td class="num" id="LN2403">2403</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2483 | <tr><td class="num" id="LN2404">2404</td><td class="line"> count = 0;</td></tr>
|
---|
2484 | <tr><td class="num" id="LN2405">2405</td><td class="line"> </td></tr>
|
---|
2485 | <tr><td class="num" id="LN2406">2406</td><td class="line"> hyper_text *enclosure = (hyper_text *)malloc(<span class='keyword'>sizeof</span>(hyper_text));</td></tr>
|
---|
2486 | <tr><td class="num" id="LN2407">2407</td><td class="line"> <span class='keyword'>if</span> (enclosure == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2487 | <tr><td class="num" id="LN2408">2408</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2488 | <tr><td class="num" id="LN2409">2409</td><td class="line"> </td></tr>
|
---|
2489 | <tr><td class="num" id="LN2410">2410</td><td class="line"> memset(enclosure, 0, <span class='keyword'>sizeof</span>(hyper_text));</td></tr>
|
---|
2490 | <tr><td class="num" id="LN2411">2411</td><td class="line"> fView->GetSelection(&enclosure->text_start,</td></tr>
|
---|
2491 | <tr><td class="num" id="LN2412">2412</td><td class="line"> &enclosure->text_end);</td></tr>
|
---|
2492 | <tr><td class="num" id="LN2413">2413</td><td class="line"> enclosure->type = type;</td></tr>
|
---|
2493 | <tr><td class="num" id="LN2414">2414</td><td class="line"> enclosure->name = strdup(url.String());</td></tr>
|
---|
2494 | <tr><td class="num" id="LN2415">2415</td><td class="line"> <span class='keyword'>if</span> (enclosure->name == <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
2495 | <tr><td class="num" id="LN2416">2416</td><td class="line"> free(enclosure);</td></tr>
|
---|
2496 | <tr><td class="num" id="LN2417">2417</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2497 | <tr><td class="num" id="LN2418">2418</td><td class="line"> }</td></tr>
|
---|
2498 | <tr><td class="num" id="LN2419">2419</td><td class="line"> </td></tr>
|
---|
2499 | <tr><td class="num" id="LN2420">2420</td><td class="line"> Insert(&data[loop], urlLength, <span class='keyword'>true</span>, isHeader);</td></tr>
|
---|
2500 | <tr><td class="num" id="LN2421">2421</td><td class="line"> enclosure->text_end += urlLength;</td></tr>
|
---|
2501 | <tr><td class="num" id="LN2422">2422</td><td class="line"> loop += urlLength - 1;</td></tr>
|
---|
2502 | <tr><td class="num" id="LN2423">2423</td><td class="line"> </td></tr>
|
---|
2503 | <tr><td class="num" id="LN2424">2424</td><td class="line"> fEnclosures->AddItem(enclosure);</td></tr>
|
---|
2504 | <tr><td class="num" id="LN2425">2425</td><td class="line"> <span class='keyword'>continue</span>;</td></tr>
|
---|
2505 | <tr><td class="num" id="LN2426">2426</td><td class="line"> }</td></tr>
|
---|
2506 | <tr><td class="num" id="LN2427">2427</td><td class="line"> }</td></tr>
|
---|
2507 | <tr><td class="num" id="LN2428">2428</td><td class="line"> <span class='keyword'>if</span> (!fRaw && fMime && data[loop] == '=') {</td></tr>
|
---|
2508 | <tr><td class="num" id="LN2429">2429</td><td class="line"> <span class='keyword'>if</span> ((loop) && (loop < data_len - 1) && (data[loop + 1] == '\r'))</td></tr>
|
---|
2509 | <tr><td class="num" id="LN2430">2430</td><td class="line"> loop += 2;</td></tr>
|
---|
2510 | <tr><td class="num" id="LN2431">2431</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
2511 | <tr><td class="num" id="LN2432">2432</td><td class="line"> line[count++] = data[loop];</td></tr>
|
---|
2512 | <tr><td class="num" id="LN2433">2433</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (data[loop] != '\r')</td></tr>
|
---|
2513 | <tr><td class="num" id="LN2434">2434</td><td class="line"> line[count++] = data[loop];</td></tr>
|
---|
2514 | <tr><td class="num" id="LN2435">2435</td><td class="line"> </td></tr>
|
---|
2515 | <tr><td class="num" id="LN2436">2436</td><td class="line"> <span class='keyword'>if</span> (count > 511 || (count && loop == data_len - 1)) {</td></tr>
|
---|
2516 | <tr><td class="num" id="LN2437">2437</td><td class="line"> <span class='keyword'>if</span> (!Insert(line, count, <span class='keyword'>false</span>, isHeader))</td></tr>
|
---|
2517 | <tr><td class="num" id="LN2438">2438</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2518 | <tr><td class="num" id="LN2439">2439</td><td class="line"> count = 0;</td></tr>
|
---|
2519 | <tr><td class="num" id="LN2440">2440</td><td class="line"> }</td></tr>
|
---|
2520 | <tr><td class="num" id="LN2441">2441</td><td class="line"> }</td></tr>
|
---|
2521 | <tr><td class="num" id="LN2442">2442</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>true</span>;</td></tr>
|
---|
2522 | <tr><td class="num" id="LN2443">2443</td><td class="line">}</td></tr>
|
---|
2523 | <tr><td class="num" id="LN2444">2444</td><td class="line"> </td></tr>
|
---|
2524 | <tr><td class="num" id="LN2445">2445</td><td class="line"> </td></tr>
|
---|
2525 | <tr><td class="num" id="LN2446">2446</td><td class="line"><span class='keyword'>bool</span></td></tr>
|
---|
2526 | <tr><td class="num" id="LN2447">2447</td><td class="line">TTextView::Reader::Insert(<span class='keyword'>const</span> <span class='keyword'>char</span> *line, int32 count, <span class='keyword'>bool</span> isHyperLink,</td></tr>
|
---|
2527 | <tr><td class="num" id="LN2448">2448</td><td class="line"> <span class='keyword'>bool</span> isHeader)</td></tr>
|
---|
2528 | <tr><td class="num" id="LN2449">2449</td><td class="line">{</td></tr>
|
---|
2529 | <tr><td class="num" id="LN2450">2450</td><td class="line"> <span class='keyword'>if</span> (!count)</td></tr>
|
---|
2530 | <tr><td class="num" id="LN2451">2451</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>true</span>;</td></tr>
|
---|
2531 | <tr><td class="num" id="LN2452">2452</td><td class="line"> </td></tr>
|
---|
2532 | <tr><td class="num" id="LN2453">2453</td><td class="line"> BFont font(fView->Font());</td></tr>
|
---|
2533 | <tr><td class="num" id="LN2454">2454</td><td class="line"> TextRunArray style(count / 8 + 8);</td></tr>
|
---|
2534 | <tr><td class="num" id="LN2455">2455</td><td class="line"> </td></tr>
|
---|
2535 | <tr><td class="num" id="LN2456">2456</td><td class="line"> <span class='keyword'>if</span> (fView->fColoredQuotes && !isHeader && !isHyperLink) {</td></tr>
|
---|
2536 | <tr><td class="num" id="LN2457">2457</td><td class="line"> FillInQuoteTextRuns(fView, &fQuoteContext, line, count, font,</td></tr>
|
---|
2537 | <tr><td class="num" id="LN2458">2458</td><td class="line"> &style.Array(), style.MaxEntries());</td></tr>
|
---|
2538 | <tr><td class="num" id="LN2459">2459</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
2539 | <tr><td class="num" id="LN2460">2460</td><td class="line"> text_run_array &array = style.Array();</td></tr>
|
---|
2540 | <tr><td class="num" id="LN2461">2461</td><td class="line"> array.count = 1;</td></tr>
|
---|
2541 | <tr><td class="num" id="LN2462">2462</td><td class="line"> array.runs[0].offset = 0;</td></tr>
|
---|
2542 | <tr><td class="num" id="LN2463">2463</td><td class="line"> <span class='keyword'>if</span> (isHeader) {</td></tr>
|
---|
2543 | <tr><td class="num" id="LN2464">2464</td><td class="line"> array.runs[0].color = isHyperLink ? kHyperLinkColor : kHeaderColor;</td></tr>
|
---|
2544 | <tr><td class="num" id="LN2465">2465</td><td class="line"> font.SetSize(font.Size() * 0.9);</td></tr>
|
---|
2545 | <tr><td class="num" id="LN2466">2466</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
2546 | <tr><td class="num" id="LN2467">2467</td><td class="line"> array.runs[0].color = isHyperLink</td></tr>
|
---|
2547 | <tr><td class="num" id="LN2468">2468</td><td class="line"> ? kHyperLinkColor : kNormalTextColor;</td></tr>
|
---|
2548 | <tr><td class="num" id="LN2469">2469</td><td class="line"> }</td></tr>
|
---|
2549 | <tr><td class="num" id="LN2470">2470</td><td class="line"> array.runs[0].font = font;</td></tr>
|
---|
2550 | <tr><td class="num" id="LN2471">2471</td><td class="line"> }</td></tr>
|
---|
2551 | <tr><td class="num" id="LN2472">2472</td><td class="line"> </td></tr>
|
---|
2552 | <tr><td class="num" id="LN2473">2473</td><td class="line"> <span class='keyword'>if</span> (!fView->Window()->Lock())</td></tr>
|
---|
2553 | <tr><td class="num" id="LN2474">2474</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2554 | <tr><td class="num" id="LN2475">2475</td><td class="line"> </td></tr>
|
---|
2555 | <tr><td class="num" id="LN2476">2476</td><td class="line"> fView->Insert(fView->TextLength(), line, count, &style.Array());</td></tr>
|
---|
2556 | <tr><td class="num" id="LN2477">2477</td><td class="line"> </td></tr>
|
---|
2557 | <tr><td class="num" id="LN2478">2478</td><td class="line"> fView->Window()->Unlock();</td></tr>
|
---|
2558 | <tr><td class="num" id="LN2479">2479</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>true</span>;</td></tr>
|
---|
2559 | <tr><td class="num" id="LN2480">2480</td><td class="line">}</td></tr>
|
---|
2560 | <tr><td class="num" id="LN2481">2481</td><td class="line"> </td></tr>
|
---|
2561 | <tr><td class="num" id="LN2482">2482</td><td class="line"> </td></tr>
|
---|
2562 | <tr><td class="num" id="LN2483">2483</td><td class="line">status_t</td></tr>
|
---|
2563 | <tr><td class="num" id="LN2484">2484</td><td class="line">TTextView::Reader::Run(<span class='keyword'>void</span> *_this)</td></tr>
|
---|
2564 | <tr><td class="num" id="LN2485">2485</td><td class="line">{</td></tr>
|
---|
2565 | <tr><td class="num" id="LN2486">2486</td><td class="line"> Reader *reader = (Reader *)_this;</td></tr>
|
---|
2566 | <tr><td class="num" id="LN2487">2487</td><td class="line"> TTextView *view = reader->fView;</td></tr>
|
---|
2567 | <tr><td class="num" id="LN2488">2488</td><td class="line"> <span class='keyword'>char</span> *msg = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
2568 | <tr><td class="num" id="LN2489">2489</td><td class="line"> off_t size = 0;</td></tr>
|
---|
2569 | <tr><td class="num" id="LN2490">2490</td><td class="line"> int32 len = 0;</td></tr>
|
---|
2570 | <tr><td class="num" id="LN2491">2491</td><td class="line"> </td></tr>
|
---|
2571 | <tr><td class="num" id="LN2492">2492</td><td class="line"> <span class='keyword'>if</span> (!reader->Lock())</td></tr>
|
---|
2572 | <tr><td class="num" id="LN2493">2493</td><td class="line"> <span class='keyword'>return</span> <span class='macro'>B_INTERRUPTED<span class='expansion'>((-2147483647 - 1) + 10)</span></span>;</td></tr>
|
---|
2573 | <tr><td class="num" id="LN2494">2494</td><td class="line"> </td></tr>
|
---|
2574 | <tr><td class="num" id="LN2495">2495</td><td class="line"> BFile *file = <span class='keyword'>dynamic_cast</span><BFile *>(reader->fMail->Data());</td></tr>
|
---|
2575 | <tr><td class="num" id="LN2496">2496</td><td class="line"> <span class='keyword'>if</span> (file != <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
2576 | <tr><td class="num" id="LN2497">2497</td><td class="line"> len = header_len(file);</td></tr>
|
---|
2577 | <tr><td class="num" id="LN2498">2498</td><td class="line"> </td></tr>
|
---|
2578 | <tr><td class="num" id="LN2499">2499</td><td class="line"> <span class='keyword'>if</span> (reader->fHeader)</td></tr>
|
---|
2579 | <tr><td class="num" id="LN2500">2500</td><td class="line"> size = len;</td></tr>
|
---|
2580 | <tr><td class="num" id="LN2501">2501</td><td class="line"> <span class='keyword'>if</span> (reader->fRaw || !reader->fMime)</td></tr>
|
---|
2581 | <tr><td class="num" id="LN2502">2502</td><td class="line"> file->GetSize(&size);</td></tr>
|
---|
2582 | <tr><td class="num" id="LN2503">2503</td><td class="line"> </td></tr>
|
---|
2583 | <tr><td class="num" id="LN2504">2504</td><td class="line"> <span class='keyword'>if</span> (size != 0 && (msg = (<span class='keyword'>char</span> *)malloc(size)) == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2584 | <tr><td class="num" id="LN2505">2505</td><td class="line"> <span class='keyword'>goto</span> done;</td></tr>
|
---|
2585 | <tr><td class="num" id="LN2506">2506</td><td class="line"> file->Seek(0, 0);</td></tr>
|
---|
2586 | <tr><td class="num" id="LN2507">2507</td><td class="line"> </td></tr>
|
---|
2587 | <tr><td class="num" id="LN2508">2508</td><td class="line"> <span class='keyword'>if</span> (msg)</td></tr>
|
---|
2588 | <tr><td class="num" id="LN2509">2509</td><td class="line"> size = file->Read(msg, size);</td></tr>
|
---|
2589 | <tr><td class="num" id="LN2510">2510</td><td class="line"> }</td></tr>
|
---|
2590 | <tr><td class="num" id="LN2511">2511</td><td class="line"> </td></tr>
|
---|
2591 | <tr><td class="num" id="LN2512">2512</td><td class="line"> <span class='comment'>// show the header?</span></td></tr>
|
---|
2592 | <tr><td class="num" id="LN2513">2513</td><td class="line"> <span class='keyword'>if</span> (reader->fHeader && len) {</td></tr>
|
---|
2593 | <tr><td class="num" id="LN2514">2514</td><td class="line"> <span class='comment'>// strip all headers except "From", "To", "Reply-To", "Subject", and "Date"</span></td></tr>
|
---|
2594 | <tr><td class="num" id="LN2515">2515</td><td class="line"> <span class='keyword'>if</span> (reader->fStripHeader) {</td></tr>
|
---|
2595 | <tr><td class="num" id="LN2516">2516</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *header = msg;</td></tr>
|
---|
2596 | <tr><td class="num" id="LN2517">2517</td><td class="line"> <span class='keyword'>char</span> *buffer = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
2597 | <tr><td class="num" id="LN2518">2518</td><td class="line"> </td></tr>
|
---|
2598 | <tr><td class="num" id="LN2519">2519</td><td class="line"> <span class='keyword'>while</span> (strncmp(header, <span class='string_literal'>"\r\n"</span>, 2)) {</td></tr>
|
---|
2599 | <tr><td class="num" id="LN2520">2520</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *eol = header;</td></tr>
|
---|
2600 | <tr><td class="num" id="LN2521">2521</td><td class="line"> <span class='keyword'>while</span> ((eol = strstr(eol, <span class='string_literal'>"\r\n"</span>)) != <span class='macro'>NULL<span class='expansion'>__null</span></span> && <span class='macro'>isspace(eol[2])<span class='expansion'>(__ctype_b[(int)((eol[2]))] & (unsigned short int)_ISspace<br>)</span></span>)</td></tr>
|
---|
2601 | <tr><td class="num" id="LN2522">2522</td><td class="line"> eol += 2;</td></tr>
|
---|
2602 | <tr><td class="num" id="LN2523">2523</td><td class="line"> <span class='keyword'>if</span> (eol == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2603 | <tr><td class="num" id="LN2524">2524</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
2604 | <tr><td class="num" id="LN2525">2525</td><td class="line"> </td></tr>
|
---|
2605 | <tr><td class="num" id="LN2526">2526</td><td class="line"> eol += 2; <span class='comment'>// CR+LF belong to the line</span></td></tr>
|
---|
2606 | <tr><td class="num" id="LN2527">2527</td><td class="line"> size_t length = eol - header;</td></tr>
|
---|
2607 | <tr><td class="num" id="LN2528">2528</td><td class="line"> </td></tr>
|
---|
2608 | <tr><td class="num" id="LN2529">2529</td><td class="line"> buffer = (<span class='keyword'>char</span> *)realloc(buffer, length + 1);</td></tr>
|
---|
2609 | <tr><td class="num" id="LN2530">2530</td><td class="line"> <span class='keyword'>if</span> (buffer == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2610 | <tr><td class="num" id="LN2531">2531</td><td class="line"> <span class='keyword'>goto</span> done;</td></tr>
|
---|
2611 | <tr><td class="num" id="LN2532">2532</td><td class="line"> </td></tr>
|
---|
2612 | <tr><td class="num" id="LN2533">2533</td><td class="line"> memcpy(buffer, header, length);</td></tr>
|
---|
2613 | <tr><td class="num" id="LN2534">2534</td><td class="line"> </td></tr>
|
---|
2614 | <tr><td class="num" id="LN2535">2535</td><td class="line"> length = rfc2047_to_utf8(&buffer, &length, length);</td></tr>
|
---|
2615 | <tr><td class="num" id="LN2536">2536</td><td class="line"> </td></tr>
|
---|
2616 | <tr><td class="num" id="LN2537">2537</td><td class="line"> <span class='keyword'>if</span> (!strncasecmp(header, <span class='string_literal'>"Reply-To: "</span>, 10)</td></tr>
|
---|
2617 | <tr><td class="num" id="LN2538">2538</td><td class="line"> || !strncasecmp(header, <span class='string_literal'>"To: "</span>, 4)</td></tr>
|
---|
2618 | <tr><td class="num" id="LN2539">2539</td><td class="line"> || !strncasecmp(header, <span class='string_literal'>"From: "</span>, 6)</td></tr>
|
---|
2619 | <tr><td class="num" id="LN2540">2540</td><td class="line"> || !strncasecmp(header, <span class='string_literal'>"Subject: "</span>, 8)</td></tr>
|
---|
2620 | <tr><td class="num" id="LN2541">2541</td><td class="line"> || !strncasecmp(header, <span class='string_literal'>"Date: "</span>, 6))</td></tr>
|
---|
2621 | <tr><td class="num" id="LN2542">2542</td><td class="line"> reader->Process(buffer, length, <span class='keyword'>true</span>);</td></tr>
|
---|
2622 | <tr><td class="num" id="LN2543">2543</td><td class="line"> </td></tr>
|
---|
2623 | <tr><td class="num" id="LN2544">2544</td><td class="line"> header = eol;</td></tr>
|
---|
2624 | <tr><td class="num" id="LN2545">2545</td><td class="line"> }</td></tr>
|
---|
2625 | <tr><td class="num" id="LN2546">2546</td><td class="line"> free(buffer);</td></tr>
|
---|
2626 | <tr><td class="num" id="LN2547">2547</td><td class="line"> reader->Process(<span class='string_literal'>"\r\n"</span>, 2, <span class='keyword'>true</span>);</td></tr>
|
---|
2627 | <tr><td class="num" id="LN2548">2548</td><td class="line"> }</td></tr>
|
---|
2628 | <tr><td class="num" id="LN2549">2549</td><td class="line"> <span class='keyword'>else</span> <span class='keyword'>if</span> (!reader->Process(msg, len, <span class='keyword'>true</span>))</td></tr>
|
---|
2629 | <tr><td class="num" id="LN2550">2550</td><td class="line"> <span class='keyword'>goto</span> done;</td></tr>
|
---|
2630 | <tr><td class="num" id="LN2551">2551</td><td class="line"> }</td></tr>
|
---|
2631 | <tr><td class="num" id="LN2552">2552</td><td class="line"> </td></tr>
|
---|
2632 | <tr><td class="num" id="LN2553">2553</td><td class="line"> <span class='keyword'>if</span> (reader->fRaw) {</td></tr>
|
---|
2633 | <tr><td class="num" id="LN2554">2554</td><td class="line"> <span class='keyword'>if</span> (!reader->Process((<span class='keyword'>const</span> <span class='keyword'>char</span> *)msg + len, size - len))</td></tr>
|
---|
2634 | <tr><td class="num" id="LN2555">2555</td><td class="line"> <span class='keyword'>goto</span> done;</td></tr>
|
---|
2635 | <tr><td class="num" id="LN2556">2556</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
2636 | <tr><td class="num" id="LN2557">2557</td><td class="line"> <span class='comment'>//reader->fFile->Seek(0, 0);</span></td></tr>
|
---|
2637 | <tr><td class="num" id="LN2558">2558</td><td class="line"> <span class='comment'>//BEmailMessage *mail = new BEmailMessage(reader->fFile);</span></td></tr>
|
---|
2638 | <tr><td class="num" id="LN2559">2559</td><td class="line"> BEmailMessage *mail = reader->fMail;</td></tr>
|
---|
2639 | <tr><td class="num" id="LN2560">2560</td><td class="line"> </td></tr>
|
---|
2640 | <tr><td class="num" id="LN2561">2561</td><td class="line"> <span class='comment'>// at first, insert the mail body</span></td></tr>
|
---|
2641 | <tr><td class="num" id="LN2562">2562</td><td class="line"> BTextMailComponent *body = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
2642 | <tr><td class="num" id="LN2563">2563</td><td class="line"> <span class='keyword'>if</span> (mail->BodyText() && !view->fStopLoading) {</td></tr>
|
---|
2643 | <tr><td class="num" id="LN2564">2564</td><td class="line"> <span class='keyword'>char</span> *bodyText = <span class='keyword'>const_cast</span><<span class='keyword'>char</span> *>(mail->BodyText());</td></tr>
|
---|
2644 | <tr><td class="num" id="LN2565">2565</td><td class="line"> int32 bodyLength = strlen(bodyText);</td></tr>
|
---|
2645 | <tr><td class="num" id="LN2566">2566</td><td class="line"> body = mail->Body();</td></tr>
|
---|
2646 | <tr><td class="num" id="LN2567">2567</td><td class="line"> <span class='keyword'>bool</span> isHTML = <span class='keyword'>false</span>;</td></tr>
|
---|
2647 | <tr><td class="num" id="LN2568">2568</td><td class="line"> </td></tr>
|
---|
2648 | <tr><td class="num" id="LN2569">2569</td><td class="line"> BMimeType type;</td></tr>
|
---|
2649 | <tr><td class="num" id="LN2570">2570</td><td class="line"> <span class='keyword'>if</span> (body->MIMEType(&type) == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span> && type == <span class='string_literal'>"text/html"</span>) {</td></tr>
|
---|
2650 | <tr><td class="num" id="LN2571">2571</td><td class="line"> <span class='comment'>// strip out HTML tags</span></td></tr>
|
---|
2651 | <tr><td class="num" id="LN2572">2572</td><td class="line"> <span class='keyword'>char</span> *t = bodyText, *a, *end = bodyText + bodyLength;</td></tr>
|
---|
2652 | <tr><td class="num" id="LN2573">2573</td><td class="line"> bodyText = (<span class='keyword'>char</span> *)malloc(bodyLength + 1);</td></tr>
|
---|
2653 | <tr><td class="num" id="LN2574">2574</td><td class="line"> isHTML = <span class='keyword'>true</span>;</td></tr>
|
---|
2654 | <tr><td class="num" id="LN2575">2575</td><td class="line"> </td></tr>
|
---|
2655 | <tr><td class="num" id="LN2576">2576</td><td class="line"> <span class='comment'>// TODO: is it correct to assume that the text is in Latin-1?</span></td></tr>
|
---|
2656 | <tr><td class="num" id="LN2577">2577</td><td class="line"> <span class='comment'>// because if it isn't, the code below won't work correctly...</span></td></tr>
|
---|
2657 | <tr><td class="num" id="LN2578">2578</td><td class="line"> </td></tr>
|
---|
2658 | <tr><td class="num" id="LN2579">2579</td><td class="line"> <span class='keyword'>for</span> (a = bodyText; t < end; t++) {</td></tr>
|
---|
2659 | <tr><td class="num" id="LN2580">2580</td><td class="line"> int32 c = *t;</td></tr>
|
---|
2660 | <tr><td class="num" id="LN2581">2581</td><td class="line"> </td></tr>
|
---|
2661 | <tr><td class="num" id="LN2582">2582</td><td class="line"> <span class='comment'>// compact spaces</span></td></tr>
|
---|
2662 | <tr><td class="num" id="LN2583">2583</td><td class="line"> <span class='keyword'>bool</span> space = <span class='keyword'>false</span>;</td></tr>
|
---|
2663 | <tr><td class="num" id="LN2584">2584</td><td class="line"> <span class='keyword'>while</span> (c && (c == ' ' || c == '\t')) {</td></tr>
|
---|
2664 | <tr><td class="num" id="LN2585">2585</td><td class="line"> c = *(++t);</td></tr>
|
---|
2665 | <tr><td class="num" id="LN2586">2586</td><td class="line"> space = <span class='keyword'>true</span>;</td></tr>
|
---|
2666 | <tr><td class="num" id="LN2587">2587</td><td class="line"> }</td></tr>
|
---|
2667 | <tr><td class="num" id="LN2588">2588</td><td class="line"> <span class='keyword'>if</span> (space) {</td></tr>
|
---|
2668 | <tr><td class="num" id="LN2589">2589</td><td class="line"> c = ' ';</td></tr>
|
---|
2669 | <tr><td class="num" id="LN2590">2590</td><td class="line"> t--;</td></tr>
|
---|
2670 | <tr><td class="num" id="LN2591">2591</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (FilterHTMLTag(c, &t, end)) <span class='comment'>// the tag filter</span></td></tr>
|
---|
2671 | <tr><td class="num" id="LN2592">2592</td><td class="line"> <span class='keyword'>continue</span>;</td></tr>
|
---|
2672 | <tr><td class="num" id="LN2593">2593</td><td class="line"> </td></tr>
|
---|
2673 | <tr><td class="num" id="LN2594">2594</td><td class="line"> Unicode2UTF8(c, &a);</td></tr>
|
---|
2674 | <tr><td class="num" id="LN2595">2595</td><td class="line"> }</td></tr>
|
---|
2675 | <tr><td class="num" id="LN2596">2596</td><td class="line"> </td></tr>
|
---|
2676 | <tr><td class="num" id="LN2597">2597</td><td class="line"> *a = 0;</td></tr>
|
---|
2677 | <tr><td class="num" id="LN2598">2598</td><td class="line"> bodyLength = strlen(bodyText);</td></tr>
|
---|
2678 | <tr><td class="num" id="LN2599">2599</td><td class="line"> body = <span class='macro'>NULL<span class='expansion'>__null</span></span>; <span class='comment'>// to add the HTML text as enclosure</span></td></tr>
|
---|
2679 | <tr><td class="num" id="LN2600">2600</td><td class="line"> }</td></tr>
|
---|
2680 | <tr><td class="num" id="LN2601">2601</td><td class="line"> <span class='keyword'>if</span> (!reader->Process(bodyText, bodyLength))</td></tr>
|
---|
2681 | <tr><td class="num" id="LN2602">2602</td><td class="line"> <span class='keyword'>goto</span> done;</td></tr>
|
---|
2682 | <tr><td class="num" id="LN2603">2603</td><td class="line"> </td></tr>
|
---|
2683 | <tr><td class="num" id="LN2604">2604</td><td class="line"> <span class='keyword'>if</span> (isHTML)</td></tr>
|
---|
2684 | <tr><td class="num" id="LN2605">2605</td><td class="line"> free(bodyText);</td></tr>
|
---|
2685 | <tr><td class="num" id="LN2606">2606</td><td class="line"> }</td></tr>
|
---|
2686 | <tr><td class="num" id="LN2607">2607</td><td class="line"> </td></tr>
|
---|
2687 | <tr><td class="num" id="LN2608">2608</td><td class="line"> <span class='keyword'>if</span> (!reader->ParseMail(mail, body))</td></tr>
|
---|
2688 | <tr><td class="num" id="LN2609">2609</td><td class="line"> <span class='keyword'>goto</span> done;</td></tr>
|
---|
2689 | <tr><td class="num" id="LN2610">2610</td><td class="line"> </td></tr>
|
---|
2690 | <tr><td class="num" id="LN2611">2611</td><td class="line"> <span class='comment'>//reader->fView->fMail = mail;</span></td></tr>
|
---|
2691 | <tr><td class="num" id="LN2612">2612</td><td class="line"> }</td></tr>
|
---|
2692 | <tr><td class="num" id="LN2613">2613</td><td class="line"> </td></tr>
|
---|
2693 | <tr><td class="num" id="LN2614">2614</td><td class="line"> <span class='keyword'>if</span> (!view->fStopLoading && view->Window()->Lock()) {</td></tr>
|
---|
2694 | <tr><td class="num" id="LN2615">2615</td><td class="line"> view->Select(0, 0);</td></tr>
|
---|
2695 | <tr><td class="num" id="LN2616">2616</td><td class="line"> view->MakeSelectable(<span class='keyword'>true</span>);</td></tr>
|
---|
2696 | <tr><td class="num" id="LN2617">2617</td><td class="line"> <span class='keyword'>if</span> (!reader->fIncoming)</td></tr>
|
---|
2697 | <tr><td class="num" id="LN2618">2618</td><td class="line"> view->MakeEditable(<span class='keyword'>true</span>);</td></tr>
|
---|
2698 | <tr><td class="num" id="LN2619">2619</td><td class="line"> </td></tr>
|
---|
2699 | <tr><td class="num" id="LN2620">2620</td><td class="line"> view->Window()->Unlock();</td></tr>
|
---|
2700 | <tr><td class="num" id="LN2621">2621</td><td class="line"> }</td></tr>
|
---|
2701 | <tr><td class="num" id="LN2622">2622</td><td class="line"> </td></tr>
|
---|
2702 | <tr><td class="num" id="LN2623">2623</td><td class="line">done:</td></tr>
|
---|
2703 | <tr><td class="num" id="LN2624">2624</td><td class="line"> <span class='comment'>// restore the reading position if available</span></td></tr>
|
---|
2704 | <tr><td class="num" id="LN2625">2625</td><td class="line"> view->Window()->PostMessage(M_READ_POS);</td></tr>
|
---|
2705 | <tr><td class="num" id="LN2626">2626</td><td class="line"> </td></tr>
|
---|
2706 | <tr><td class="num" id="LN2627">2627</td><td class="line"> reader->Unlock();</td></tr>
|
---|
2707 | <tr><td class="num" id="LN2628">2628</td><td class="line"> </td></tr>
|
---|
2708 | <tr><td class="num" id="LN2629">2629</td><td class="line"> <span class='keyword'>delete</span> reader;</td></tr>
|
---|
2709 | <tr><td class="num" id="LN2630">2630</td><td class="line"> free(msg);</td></tr>
|
---|
2710 | <tr><td class="num" id="LN2631">2631</td><td class="line"> </td></tr>
|
---|
2711 | <tr><td class="num" id="LN2632">2632</td><td class="line"> <span class='keyword'>return</span> <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>;</td></tr>
|
---|
2712 | <tr><td class="num" id="LN2633">2633</td><td class="line">}</td></tr>
|
---|
2713 | <tr><td class="num" id="LN2634">2634</td><td class="line"> </td></tr>
|
---|
2714 | <tr><td class="num" id="LN2635">2635</td><td class="line"> </td></tr>
|
---|
2715 | <tr><td class="num" id="LN2636">2636</td><td class="line">status_t</td></tr>
|
---|
2716 | <tr><td class="num" id="LN2637">2637</td><td class="line">TTextView::Reader::Unlock()</td></tr>
|
---|
2717 | <tr><td class="num" id="LN2638">2638</td><td class="line">{</td></tr>
|
---|
2718 | <tr><td class="num" id="LN2639">2639</td><td class="line"> <span class='keyword'>return</span> release_sem(fStopSem);</td></tr>
|
---|
2719 | <tr><td class="num" id="LN2640">2640</td><td class="line">}</td></tr>
|
---|
2720 | <tr><td class="num" id="LN2641">2641</td><td class="line"> </td></tr>
|
---|
2721 | <tr><td class="num" id="LN2642">2642</td><td class="line"> </td></tr>
|
---|
2722 | <tr><td class="num" id="LN2643">2643</td><td class="line"><span class='keyword'>bool</span></td></tr>
|
---|
2723 | <tr><td class="num" id="LN2644">2644</td><td class="line">TTextView::Reader::Lock()</td></tr>
|
---|
2724 | <tr><td class="num" id="LN2645">2645</td><td class="line">{</td></tr>
|
---|
2725 | <tr><td class="num" id="LN2646">2646</td><td class="line"> <span class='keyword'>if</span> (acquire_sem_etc(fStopSem, 1, B_TIMEOUT, 0) != <span class='macro'>B_NO_ERROR<span class='expansion'>((int)0)</span></span>)</td></tr>
|
---|
2726 | <tr><td class="num" id="LN2647">2647</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
2727 | <tr><td class="num" id="LN2648">2648</td><td class="line"> </td></tr>
|
---|
2728 | <tr><td class="num" id="LN2649">2649</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>true</span>;</td></tr>
|
---|
2729 | <tr><td class="num" id="LN2650">2650</td><td class="line">}</td></tr>
|
---|
2730 | <tr><td class="num" id="LN2651">2651</td><td class="line"> </td></tr>
|
---|
2731 | <tr><td class="num" id="LN2652">2652</td><td class="line"> </td></tr>
|
---|
2732 | <tr><td class="num" id="LN2653">2653</td><td class="line"><span class='comment'>//====================================================================</span></td></tr>
|
---|
2733 | <tr><td class="num" id="LN2654">2654</td><td class="line"><span class='comment'>// #pragma mark -</span></td></tr>
|
---|
2734 | <tr><td class="num" id="LN2655">2655</td><td class="line"> </td></tr>
|
---|
2735 | <tr><td class="num" id="LN2656">2656</td><td class="line"> </td></tr>
|
---|
2736 | <tr><td class="num" id="LN2657">2657</td><td class="line">TSavePanel::TSavePanel(hyper_text *enclosure, TTextView *view)</td></tr>
|
---|
2737 | <tr><td class="num" id="LN2658">2658</td><td class="line"> : BFilePanel(B_SAVE_PANEL)</td></tr>
|
---|
2738 | <tr><td class="num" id="LN2659">2659</td><td class="line">{</td></tr>
|
---|
2739 | <tr><td class="num" id="LN2660">2660</td><td class="line"> fEnclosure = enclosure;</td></tr>
|
---|
2740 | <tr><td class="num" id="LN2661">2661</td><td class="line"> fView = view;</td></tr>
|
---|
2741 | <tr><td class="num" id="LN2662">2662</td><td class="line"> <span class='keyword'>if</span> (enclosure->name)</td></tr>
|
---|
2742 | <tr><td class="num" id="LN2663">2663</td><td class="line"> SetSaveText(enclosure->name);</td></tr>
|
---|
2743 | <tr><td class="num" id="LN2664">2664</td><td class="line">}</td></tr>
|
---|
2744 | <tr><td class="num" id="LN2665">2665</td><td class="line"> </td></tr>
|
---|
2745 | <tr><td class="num" id="LN2666">2666</td><td class="line"> </td></tr>
|
---|
2746 | <tr><td class="num" id="LN2667">2667</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
2747 | <tr><td class="num" id="LN2668">2668</td><td class="line">TSavePanel::SendMessage(<span class='keyword'>const</span> BMessenger * <span class='comment'>/* messenger */</span>, BMessage *msg)</td></tr>
|
---|
2748 | <tr><td class="num" id="LN2669">2669</td><td class="line">{</td></tr>
|
---|
2749 | <tr><td class="num" id="LN2670">2670</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *name = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
2750 | <tr><td class="num" id="LN2671">2671</td><td class="line"> BMessage save(M_SAVE);</td></tr>
|
---|
2751 | <tr><td class="num" id="LN2672">2672</td><td class="line"> entry_ref ref;</td></tr>
|
---|
2752 | <tr><td class="num" id="LN2673">2673</td><td class="line"> </td></tr>
|
---|
2753 | <tr><td class="num" id="LN2674">2674</td><td class="line"> <span class='keyword'>if</span> ((!msg->FindRef(<span class='string_literal'>"directory"</span>, &ref)) && (!msg->FindString(<span class='string_literal'>"name"</span>, &name))) {</td></tr>
|
---|
2754 | <tr><td class="num" id="LN2675">2675</td><td class="line"> save.AddPointer(<span class='string_literal'>"enclosure"</span>, fEnclosure);</td></tr>
|
---|
2755 | <tr><td class="num" id="LN2676">2676</td><td class="line"> save.AddString(<span class='string_literal'>"name"</span>, name);</td></tr>
|
---|
2756 | <tr><td class="num" id="LN2677">2677</td><td class="line"> save.AddRef(<span class='string_literal'>"directory"</span>, &ref);</td></tr>
|
---|
2757 | <tr><td class="num" id="LN2678">2678</td><td class="line"> fView->Window()->PostMessage(&save, fView);</td></tr>
|
---|
2758 | <tr><td class="num" id="LN2679">2679</td><td class="line"> }</td></tr>
|
---|
2759 | <tr><td class="num" id="LN2680">2680</td><td class="line">}</td></tr>
|
---|
2760 | <tr><td class="num" id="LN2681">2681</td><td class="line"> </td></tr>
|
---|
2761 | <tr><td class="num" id="LN2682">2682</td><td class="line"> </td></tr>
|
---|
2762 | <tr><td class="num" id="LN2683">2683</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
2763 | <tr><td class="num" id="LN2684">2684</td><td class="line">TSavePanel::SetEnclosure(hyper_text *enclosure)</td></tr>
|
---|
2764 | <tr><td class="num" id="LN2685">2685</td><td class="line">{</td></tr>
|
---|
2765 | <tr><td class="num" id="LN2686">2686</td><td class="line"> fEnclosure = enclosure;</td></tr>
|
---|
2766 | <tr><td class="num" id="LN2687">2687</td><td class="line"> <span class='keyword'>if</span> (enclosure->name)</td></tr>
|
---|
2767 | <tr><td class="num" id="LN2688">2688</td><td class="line"> SetSaveText(enclosure->name);</td></tr>
|
---|
2768 | <tr><td class="num" id="LN2689">2689</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
2769 | <tr><td class="num" id="LN2690">2690</td><td class="line"> SetSaveText(<span class='string_literal'>""</span>);</td></tr>
|
---|
2770 | <tr><td class="num" id="LN2691">2691</td><td class="line"> </td></tr>
|
---|
2771 | <tr><td class="num" id="LN2692">2692</td><td class="line"> <span class='keyword'>if</span> (!IsShowing())</td></tr>
|
---|
2772 | <tr><td class="num" id="LN2693">2693</td><td class="line"> Show();</td></tr>
|
---|
2773 | <tr><td class="num" id="LN2694">2694</td><td class="line"> Window()->Activate();</td></tr>
|
---|
2774 | <tr><td class="num" id="LN2695">2695</td><td class="line">}</td></tr>
|
---|
2775 | <tr><td class="num" id="LN2696">2696</td><td class="line"> </td></tr>
|
---|
2776 | <tr><td class="num" id="LN2697">2697</td><td class="line"> </td></tr>
|
---|
2777 | <tr><td class="num" id="LN2698">2698</td><td class="line"><span class='comment'>//--------------------------------------------------------------------</span></td></tr>
|
---|
2778 | <tr><td class="num" id="LN2699">2699</td><td class="line"><span class='comment'>// #pragma mark -</span></td></tr>
|
---|
2779 | <tr><td class="num" id="LN2700">2700</td><td class="line"> </td></tr>
|
---|
2780 | <tr><td class="num" id="LN2701">2701</td><td class="line"> </td></tr>
|
---|
2781 | <tr><td class="num" id="LN2702">2702</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
2782 | <tr><td class="num" id="LN2703">2703</td><td class="line">TTextView::InsertText(<span class='keyword'>const</span> <span class='keyword'>char</span> *insertText, int32 length, int32 offset,</td></tr>
|
---|
2783 | <tr><td class="num" id="LN2704">2704</td><td class="line"> <span class='keyword'>const</span> text_run_array *runs)</td></tr>
|
---|
2784 | <tr><td class="num" id="LN2705">2705</td><td class="line">{</td></tr>
|
---|
2785 | <tr><td class="num" id="LN2706">2706</td><td class="line"> ContentChanged();</td></tr>
|
---|
2786 | <tr><td class="num" id="LN2707">2707</td><td class="line"> </td></tr>
|
---|
2787 | <tr><td class="num" id="LN2708">2708</td><td class="line"> <span class='comment'>// Undo function</span></td></tr>
|
---|
2788 | <tr><td class="num" id="LN2709">2709</td><td class="line"> </td></tr>
|
---|
2789 | <tr><td class="num" id="LN2710">2710</td><td class="line"> int32 cursorPos, dummy;</td></tr>
|
---|
2790 | <tr><td class="num" id="LN2711">2711</td><td class="line"> GetSelection(&cursorPos, &dummy);</td></tr>
|
---|
2791 | <tr><td class="num" id="LN2712">2712</td><td class="line"> </td></tr>
|
---|
2792 | <tr><td class="num" id="LN2713">2713</td><td class="line"> <span class='keyword'>if</span> (fInputMethodUndoState.active) {</td></tr>
|
---|
2793 | <tr><td class="num" id="LN2714">2714</td><td class="line"> <span class='comment'>// IMアクティブ時は、一旦別のバッファへ記憶</span></td></tr>
|
---|
2794 | <tr><td class="num" id="LN2715">2715</td><td class="line"> fInputMethodUndoBuffer.AddUndo(insertText, length, offset, K_INSERTED, cursorPos);</td></tr>
|
---|
2795 | <tr><td class="num" id="LN2716">2716</td><td class="line"> fInputMethodUndoState.replace = <span class='keyword'>false</span>;</td></tr>
|
---|
2796 | <tr><td class="num" id="LN2717">2717</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
2797 | <tr><td class="num" id="LN2718">2718</td><td class="line"> <span class='keyword'>if</span> (fUndoState.replaced) {</td></tr>
|
---|
2798 | <tr><td class="num" id="LN2719">2719</td><td class="line"> fUndoBuffer.AddUndo(insertText, length, offset, K_REPLACED, cursorPos);</td></tr>
|
---|
2799 | <tr><td class="num" id="LN2720">2720</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
2800 | <tr><td class="num" id="LN2721">2721</td><td class="line"> <span class='keyword'>if</span> (length == 1 && insertText[0] == 0x0a)</td></tr>
|
---|
2801 | <tr><td class="num" id="LN2722">2722</td><td class="line"> fUndoBuffer.MakeNewUndoItem();</td></tr>
|
---|
2802 | <tr><td class="num" id="LN2723">2723</td><td class="line"> </td></tr>
|
---|
2803 | <tr><td class="num" id="LN2724">2724</td><td class="line"> fUndoBuffer.AddUndo(insertText, length, offset, K_INSERTED, cursorPos);</td></tr>
|
---|
2804 | <tr><td class="num" id="LN2725">2725</td><td class="line"> </td></tr>
|
---|
2805 | <tr><td class="num" id="LN2726">2726</td><td class="line"> <span class='keyword'>if</span> (length == 1 && insertText[0] == 0x0a)</td></tr>
|
---|
2806 | <tr><td class="num" id="LN2727">2727</td><td class="line"> fUndoBuffer.MakeNewUndoItem();</td></tr>
|
---|
2807 | <tr><td class="num" id="LN2728">2728</td><td class="line"> }</td></tr>
|
---|
2808 | <tr><td class="num" id="LN2729">2729</td><td class="line"> }</td></tr>
|
---|
2809 | <tr><td class="num" id="LN2730">2730</td><td class="line"> </td></tr>
|
---|
2810 | <tr><td class="num" id="LN2731">2731</td><td class="line"> fUndoState.replaced = <span class='keyword'>false</span>;</td></tr>
|
---|
2811 | <tr><td class="num" id="LN2732">2732</td><td class="line"> fUndoState.deleted = <span class='keyword'>false</span>;</td></tr>
|
---|
2812 | <tr><td class="num" id="LN2733">2733</td><td class="line"> </td></tr>
|
---|
2813 | <tr><td class="num" id="LN2734">2734</td><td class="line"> <span class='keyword'>struct</span> text_runs : text_run_array { text_run _runs[1]; } style;</td></tr>
|
---|
2814 | <tr><td class="num" id="LN2735">2735</td><td class="line"> <span class='keyword'>if</span> (runs == <span class='macro'>NULL<span class='expansion'>__null</span></span> && IsEditable()) {</td></tr>
|
---|
2815 | <tr><td class="num" id="LN2736">2736</td><td class="line"> style.count = 1;</td></tr>
|
---|
2816 | <tr><td class="num" id="LN2737">2737</td><td class="line"> style.runs[0].offset = 0;</td></tr>
|
---|
2817 | <tr><td class="num" id="LN2738">2738</td><td class="line"> style.runs[0].font = fFont;</td></tr>
|
---|
2818 | <tr><td class="num" id="LN2739">2739</td><td class="line"> style.runs[0].color = kNormalTextColor;</td></tr>
|
---|
2819 | <tr><td class="num" id="LN2740">2740</td><td class="line"> runs = &style;</td></tr>
|
---|
2820 | <tr><td class="num" id="LN2741">2741</td><td class="line"> }</td></tr>
|
---|
2821 | <tr><td class="num" id="LN2742">2742</td><td class="line"> </td></tr>
|
---|
2822 | <tr><td class="num" id="LN2743">2743</td><td class="line"> BTextView::InsertText(insertText, length, offset, runs);</td></tr>
|
---|
2823 | <tr><td class="num" id="LN2744">2744</td><td class="line"> </td></tr>
|
---|
2824 | <tr><td class="num" id="LN2745">2745</td><td class="line"> <span class='keyword'>if</span> (fSpellCheck && IsEditable())</td></tr>
|
---|
2825 | <tr><td class="num" id="LN2746">2746</td><td class="line"> {</td></tr>
|
---|
2826 | <tr><td class="num" id="LN2747">2747</td><td class="line"> UpdateSpellMarks(offset, length);</td></tr>
|
---|
2827 | <tr><td class="num" id="LN2748">2748</td><td class="line"> </td></tr>
|
---|
2828 | <tr><td class="num" id="LN2749">2749</td><td class="line"> rgb_color color;</td></tr>
|
---|
2829 | <tr><td class="num" id="LN2750">2750</td><td class="line"> GetFontAndColor(offset - 1, <span class='macro'>NULL<span class='expansion'>__null</span></span>, &color);</td></tr>
|
---|
2830 | <tr><td class="num" id="LN2751">2751</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = Text();</td></tr>
|
---|
2831 | <tr><td class="num" id="LN2752">2752</td><td class="line"> </td></tr>
|
---|
2832 | <tr><td class="num" id="LN2753">2753</td><td class="line"> <span class='keyword'>if</span> (length > 1</td></tr>
|
---|
2833 | <tr><td class="num" id="LN2754">2754</td><td class="line"> || <span class='macro'>isalpha(text[offset + 1])<span class='expansion'>(__ctype_b[(int)((text[offset + 1]))] & (unsigned short int<br>)_ISalpha)</span></span></td></tr>
|
---|
2834 | <tr><td class="num" id="LN2755">2755</td><td class="line"> || (!<span class='macro'>isalpha(text[offset])<span class='expansion'>(__ctype_b[(int)((text[offset]))] & (unsigned short int)_ISalpha<br>)</span></span> && text[offset] != '\'')</td></tr>
|
---|
2835 | <tr><td class="num" id="LN2756">2756</td><td class="line"> || (color.red == kSpellTextColor.red</td></tr>
|
---|
2836 | <tr><td class="num" id="LN2757">2757</td><td class="line"> && color.green == kSpellTextColor.green</td></tr>
|
---|
2837 | <tr><td class="num" id="LN2758">2758</td><td class="line"> && color.blue == kSpellTextColor.blue))</td></tr>
|
---|
2838 | <tr><td class="num" id="LN2759">2759</td><td class="line"> {</td></tr>
|
---|
2839 | <tr><td class="num" id="LN2760">2760</td><td class="line"> int32 start, end;</td></tr>
|
---|
2840 | <tr><td class="num" id="LN2761">2761</td><td class="line"> FindSpellBoundry(length, offset, &start, &end);</td></tr>
|
---|
2841 | <tr><td class="num" id="LN2762">2762</td><td class="line"> </td></tr>
|
---|
2842 | <tr><td class="num" id="LN2763">2763</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"Offset %ld, start %ld, end %ld\n"</span>, offset, start, end))<span class='expansion'>;</span></span>;</td></tr>
|
---|
2843 | <tr><td class="num" id="LN2764">2764</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"\t\"%10.10s...\"\n"</span>, text + start))<span class='expansion'>;</span></span>;</td></tr>
|
---|
2844 | <tr><td class="num" id="LN2765">2765</td><td class="line"> </td></tr>
|
---|
2845 | <tr><td class="num" id="LN2766">2766</td><td class="line"> CheckSpelling(start, end);</td></tr>
|
---|
2846 | <tr><td class="num" id="LN2767">2767</td><td class="line"> }</td></tr>
|
---|
2847 | <tr><td class="num" id="LN2768">2768</td><td class="line"> }</td></tr>
|
---|
2848 | <tr><td class="num" id="LN2769">2769</td><td class="line">}</td></tr>
|
---|
2849 | <tr><td class="num" id="LN2770">2770</td><td class="line"> </td></tr>
|
---|
2850 | <tr><td class="num" id="LN2771">2771</td><td class="line"> </td></tr>
|
---|
2851 | <tr><td class="num" id="LN2772">2772</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
2852 | <tr><td class="num" id="LN2773">2773</td><td class="line">TTextView::DeleteText(int32 start, int32 finish)</td></tr>
|
---|
2853 | <tr><td class="num" id="LN2774">2774</td><td class="line">{</td></tr>
|
---|
2854 | <tr><td class="num" id="LN2775">2775</td><td class="line"> ContentChanged();</td></tr>
|
---|
2855 | <tr><td class="num" id="LN2776">2776</td><td class="line"> </td></tr>
|
---|
2856 | <tr><td class="num" id="LN2777">2777</td><td class="line"> <span class='comment'>// Undo function</span></td></tr>
|
---|
2857 | <tr><td class="num" id="LN2778">2778</td><td class="line"> int32 cursorPos, dummy;</td></tr>
|
---|
2858 | <tr><td class="num" id="LN2779">2779</td><td class="line"> GetSelection(&cursorPos, &dummy);</td></tr>
|
---|
2859 | <tr><td class="num" id="LN2780">2780</td><td class="line"> <span class='keyword'>if</span> (fInputMethodUndoState.active) {</td></tr>
|
---|
2860 | <tr><td class="num" id="LN2781">2781</td><td class="line"> <span class='keyword'>if</span> (fInputMethodUndoState.replace) {</td></tr>
|
---|
2861 | <tr><td class="num" id="LN2782">2782</td><td class="line"> fUndoBuffer.AddUndo(&Text()[start], finish - start, start, K_DELETED, cursorPos);</td></tr>
|
---|
2862 | <tr><td class="num" id="LN2783">2783</td><td class="line"> fInputMethodUndoState.replace = <span class='keyword'>false</span>;</td></tr>
|
---|
2863 | <tr><td class="num" id="LN2784">2784</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
2864 | <tr><td class="num" id="LN2785">2785</td><td class="line"> fInputMethodUndoBuffer.AddUndo(&Text()[start], finish - start, start,</td></tr>
|
---|
2865 | <tr><td class="num" id="LN2786">2786</td><td class="line"> K_DELETED, cursorPos);</td></tr>
|
---|
2866 | <tr><td class="num" id="LN2787">2787</td><td class="line"> }</td></tr>
|
---|
2867 | <tr><td class="num" id="LN2788">2788</td><td class="line"> } <span class='keyword'>else</span></td></tr>
|
---|
2868 | <tr><td class="num" id="LN2789">2789</td><td class="line"> fUndoBuffer.AddUndo(&Text()[start], finish - start, start, K_DELETED, cursorPos);</td></tr>
|
---|
2869 | <tr><td class="num" id="LN2790">2790</td><td class="line"> </td></tr>
|
---|
2870 | <tr><td class="num" id="LN2791">2791</td><td class="line"> fUndoState.deleted = <span class='keyword'>true</span>;</td></tr>
|
---|
2871 | <tr><td class="num" id="LN2792">2792</td><td class="line"> fUndoState.replaced = <span class='keyword'>true</span>;</td></tr>
|
---|
2872 | <tr><td class="num" id="LN2793">2793</td><td class="line"> </td></tr>
|
---|
2873 | <tr><td class="num" id="LN2794">2794</td><td class="line"> BTextView::DeleteText(start, finish);</td></tr>
|
---|
2874 | <tr><td class="num" id="LN2795">2795</td><td class="line"> <span class='keyword'>if</span> (fSpellCheck && IsEditable()) {</td></tr>
|
---|
2875 | <tr><td class="num" id="LN2796">2796</td><td class="line"> UpdateSpellMarks(start, start - finish);</td></tr>
|
---|
2876 | <tr><td class="num" id="LN2797">2797</td><td class="line"> </td></tr>
|
---|
2877 | <tr><td class="num" id="LN2798">2798</td><td class="line"> int32 s, e;</td></tr>
|
---|
2878 | <tr><td class="num" id="LN2799">2799</td><td class="line"> FindSpellBoundry(1, start, &s, &e);</td></tr>
|
---|
2879 | <tr><td class="num" id="LN2800">2800</td><td class="line"> CheckSpelling(s, e);</td></tr>
|
---|
2880 | <tr><td class="num" id="LN2801">2801</td><td class="line"> }</td></tr>
|
---|
2881 | <tr><td class="num" id="LN2802">2802</td><td class="line">}</td></tr>
|
---|
2882 | <tr><td class="num" id="LN2803">2803</td><td class="line"> </td></tr>
|
---|
2883 | <tr><td class="num" id="LN2804">2804</td><td class="line"> </td></tr>
|
---|
2884 | <tr><td class="num" id="LN2805">2805</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
2885 | <tr><td class="num" id="LN2806">2806</td><td class="line">TTextView::ContentChanged(<span class='keyword'>void</span>)</td></tr>
|
---|
2886 | <tr><td class="num" id="LN2807">2807</td><td class="line">{</td></tr>
|
---|
2887 | <tr><td class="num" id="LN2808">2808</td><td class="line"> BLooper *looper = Looper();</td></tr>
|
---|
2888 | <tr><td class="num" id="LN2809">2809</td><td class="line"> <span class='keyword'>if</span> (looper == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
2889 | <tr><td class="num" id="LN2810">2810</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
2890 | <tr><td class="num" id="LN2811">2811</td><td class="line"> </td></tr>
|
---|
2891 | <tr><td class="num" id="LN2812">2812</td><td class="line"> BMessage msg(FIELD_CHANGED);</td></tr>
|
---|
2892 | <tr><td class="num" id="LN2813">2813</td><td class="line"> msg.AddInt32(<span class='string_literal'>"bitmask"</span>, FIELD_BODY);</td></tr>
|
---|
2893 | <tr><td class="num" id="LN2814">2814</td><td class="line"> msg.AddPointer(<span class='string_literal'>"source"</span>, <span class='keyword'>this</span>);</td></tr>
|
---|
2894 | <tr><td class="num" id="LN2815">2815</td><td class="line"> looper->PostMessage(&msg);</td></tr>
|
---|
2895 | <tr><td class="num" id="LN2816">2816</td><td class="line">}</td></tr>
|
---|
2896 | <tr><td class="num" id="LN2817">2817</td><td class="line"> </td></tr>
|
---|
2897 | <tr><td class="num" id="LN2818">2818</td><td class="line"> </td></tr>
|
---|
2898 | <tr><td class="num" id="LN2819">2819</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
2899 | <tr><td class="num" id="LN2820">2820</td><td class="line">TTextView::CheckSpelling(int32 start, int32 end, int32 flags)</td></tr>
|
---|
2900 | <tr><td class="num" id="LN2821">2821</td><td class="line">{</td></tr>
|
---|
2901 | <tr><td class="num" id="LN2822">2822</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = Text();</td></tr>
|
---|
2902 | <tr><td class="num" id="LN2823">2823</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *next, *endPtr, *word = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
2903 | <tr><td class="num" id="LN2824">2824</td><td class="line"> int32 wordLength = 0, wordOffset;</td></tr>
|
---|
2904 | <tr><td class="num" id="LN2825">2825</td><td class="line"> int32 nextHighlight = start;</td></tr>
|
---|
2905 | <tr><td class="num" id="LN2826">2826</td><td class="line"> BString testWord;</td></tr>
|
---|
2906 | <tr><td class="num" id="LN2827">2827</td><td class="line"> <span class='keyword'>bool</span> isCap = <span class='keyword'>false</span>;</td></tr>
|
---|
2907 | <tr><td class="num" id="LN2828">2828</td><td class="line"> <span class='keyword'>bool</span> isAlpha;</td></tr>
|
---|
2908 | <tr><td class="num" id="LN2829">2829</td><td class="line"> <span class='keyword'>bool</span> isApost;</td></tr>
|
---|
2909 | <tr><td class="num" id="LN2830">2830</td><td class="line"> </td></tr>
|
---|
2910 | <tr><td class="num" id="LN2831">2831</td><td class="line"> <span class='keyword'>for</span> (next = text + start, endPtr = text + end; next <= endPtr; next++) {</td></tr>
|
---|
2911 | <tr><td class="num" id="LN2832">2832</td><td class="line"> <span class='comment'>//printf("next=%c\n", *next);</span></td></tr>
|
---|
2912 | <tr><td class="num" id="LN2833">2833</td><td class="line"> <span class='comment'>// ToDo: this has to be refined to other languages...</span></td></tr>
|
---|
2913 | <tr><td class="num" id="LN2834">2834</td><td class="line"> <span class='comment'>// Alpha signifies the start of a word</span></td></tr>
|
---|
2914 | <tr><td class="num" id="LN2835">2835</td><td class="line"> isAlpha = <span class='macro'>isalpha(*next)<span class='expansion'>(__ctype_b[(int)((*next))] & (unsigned short int)_ISalpha<br>)</span></span>;</td></tr>
|
---|
2915 | <tr><td class="num" id="LN2836">2836</td><td class="line"> isApost = (*next == '\'');</td></tr>
|
---|
2916 | <tr><td class="num" id="LN2837">2837</td><td class="line"> <span class='keyword'>if</span> (!word && isAlpha) {</td></tr>
|
---|
2917 | <tr><td class="num" id="LN2838">2838</td><td class="line"> <span class='comment'>//printf("Found word start\n");</span></td></tr>
|
---|
2918 | <tr><td class="num" id="LN2839">2839</td><td class="line"> word = next;</td></tr>
|
---|
2919 | <tr><td class="num" id="LN2840">2840</td><td class="line"> wordLength++;</td></tr>
|
---|
2920 | <tr><td class="num" id="LN2841">2841</td><td class="line"> isCap = <span class='macro'>isupper(*word)<span class='expansion'>(__ctype_b[(int)((*word))] & (unsigned short int)_ISupper<br>)</span></span>;</td></tr>
|
---|
2921 | <tr><td class="num" id="LN2842">2842</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (word && (isAlpha || isApost) && !(isApost && !<span class='macro'>isalpha(next[1])<span class='expansion'>(__ctype_b[(int)((next[1]))] & (unsigned short int)_ISalpha<br>)</span></span>)</td></tr>
|
---|
2922 | <tr><td class="num" id="LN2843">2843</td><td class="line"> && !(isCap && isApost && (next[1] == 's'))) {</td></tr>
|
---|
2923 | <tr><td class="num" id="LN2844">2844</td><td class="line"> <span class='comment'>// Word continues check</span></td></tr>
|
---|
2924 | <tr><td class="num" id="LN2845">2845</td><td class="line"> wordLength++;</td></tr>
|
---|
2925 | <tr><td class="num" id="LN2846">2846</td><td class="line"> <span class='comment'>//printf("Word continues...\n");</span></td></tr>
|
---|
2926 | <tr><td class="num" id="LN2847">2847</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (word) {</td></tr>
|
---|
2927 | <tr><td class="num" id="LN2848">2848</td><td class="line"> <span class='comment'>// End of word reached</span></td></tr>
|
---|
2928 | <tr><td class="num" id="LN2849">2849</td><td class="line"> </td></tr>
|
---|
2929 | <tr><td class="num" id="LN2850">2850</td><td class="line"> <span class='comment'>//printf("Word End\n");</span></td></tr>
|
---|
2930 | <tr><td class="num" id="LN2851">2851</td><td class="line"> <span class='comment'>// Don't check single characters</span></td></tr>
|
---|
2931 | <tr><td class="num" id="LN2852">2852</td><td class="line"> <span class='keyword'>if</span> (wordLength > 1) {</td></tr>
|
---|
2932 | <tr><td class="num" id="LN2853">2853</td><td class="line"> <span class='keyword'>bool</span> isUpper = <span class='keyword'>true</span>;</td></tr>
|
---|
2933 | <tr><td class="num" id="LN2854">2854</td><td class="line"> </td></tr>
|
---|
2934 | <tr><td class="num" id="LN2855">2855</td><td class="line"> <span class='comment'>// Look for all uppercase</span></td></tr>
|
---|
2935 | <tr><td class="num" id="LN2856">2856</td><td class="line"> <span class='keyword'>for</span> (int32 i = 0; i < wordLength; i++) {</td></tr>
|
---|
2936 | <tr><td class="num" id="LN2857">2857</td><td class="line"> <span class='keyword'>if</span> (word[i] == '\'')</td></tr>
|
---|
2937 | <tr><td class="num" id="LN2858">2858</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
2938 | <tr><td class="num" id="LN2859">2859</td><td class="line"> </td></tr>
|
---|
2939 | <tr><td class="num" id="LN2860">2860</td><td class="line"> <span class='keyword'>if</span> (<span class='macro'>islower(word[i])<span class='expansion'>(__ctype_b[(int)((word[i]))] & (unsigned short int)_ISlower<br>)</span></span>) {</td></tr>
|
---|
2940 | <tr><td class="num" id="LN2861">2861</td><td class="line"> isUpper = <span class='keyword'>false</span>;</td></tr>
|
---|
2941 | <tr><td class="num" id="LN2862">2862</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
2942 | <tr><td class="num" id="LN2863">2863</td><td class="line"> }</td></tr>
|
---|
2943 | <tr><td class="num" id="LN2864">2864</td><td class="line"> }</td></tr>
|
---|
2944 | <tr><td class="num" id="LN2865">2865</td><td class="line"> </td></tr>
|
---|
2945 | <tr><td class="num" id="LN2866">2866</td><td class="line"> <span class='comment'>// Don't check all uppercase words</span></td></tr>
|
---|
2946 | <tr><td class="num" id="LN2867">2867</td><td class="line"> <span class='keyword'>if</span> (!isUpper) {</td></tr>
|
---|
2947 | <tr><td class="num" id="LN2868">2868</td><td class="line"> <span class='keyword'>bool</span> foundMatch = <span class='keyword'>false</span>;</td></tr>
|
---|
2948 | <tr><td class="num" id="LN2869">2869</td><td class="line"> wordOffset = word - text;</td></tr>
|
---|
2949 | <tr><td class="num" id="LN2870">2870</td><td class="line"> testWord.SetTo(word, wordLength);</td></tr>
|
---|
2950 | <tr><td class="num" id="LN2871">2871</td><td class="line"> </td></tr>
|
---|
2951 | <tr><td class="num" id="LN2872">2872</td><td class="line"> testWord = testWord.ToLower();</td></tr>
|
---|
2952 | <tr><td class="num" id="LN2873">2873</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"Testing: \"%s\"\n"</span>, testWord.String()))<span class='expansion'>;</span></span>;</td></tr>
|
---|
2953 | <tr><td class="num" id="LN2874">2874</td><td class="line"> </td></tr>
|
---|
2954 | <tr><td class="num" id="LN2875">2875</td><td class="line"> int32 key = -1;</td></tr>
|
---|
2955 | <tr><td class="num" id="LN2876">2876</td><td class="line"> <span class='keyword'>if</span> (gDictCount)</td></tr>
|
---|
2956 | <tr><td class="num" id="LN2877">2877</td><td class="line"> key = gExactWords[0]->GetKey(testWord.String());</td></tr>
|
---|
2957 | <tr><td class="num" id="LN2878">2878</td><td class="line"> </td></tr>
|
---|
2958 | <tr><td class="num" id="LN2879">2879</td><td class="line"> <span class='comment'>// Search all dictionaries</span></td></tr>
|
---|
2959 | <tr><td class="num" id="LN2880">2880</td><td class="line"> <span class='keyword'>for</span> (int32 i = 0; i < gDictCount; i++) {</td></tr>
|
---|
2960 | <tr><td class="num" id="LN2881">2881</td><td class="line"> <span class='keyword'>if</span> (gExactWords[i]->Lookup(key) >= 0) {</td></tr>
|
---|
2961 | <tr><td class="num" id="LN2882">2882</td><td class="line"> foundMatch = <span class='keyword'>true</span>;</td></tr>
|
---|
2962 | <tr><td class="num" id="LN2883">2883</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
2963 | <tr><td class="num" id="LN2884">2884</td><td class="line"> }</td></tr>
|
---|
2964 | <tr><td class="num" id="LN2885">2885</td><td class="line"> }</td></tr>
|
---|
2965 | <tr><td class="num" id="LN2886">2886</td><td class="line"> </td></tr>
|
---|
2966 | <tr><td class="num" id="LN2887">2887</td><td class="line"> <span class='keyword'>if</span> (!foundMatch) {</td></tr>
|
---|
2967 | <tr><td class="num" id="LN2888">2888</td><td class="line"> <span class='keyword'>if</span> (flags & S_CLEAR_ERRORS)</td></tr>
|
---|
2968 | <tr><td class="num" id="LN2889">2889</td><td class="line"> RemoveSpellMark(nextHighlight, wordOffset);</td></tr>
|
---|
2969 | <tr><td class="num" id="LN2890">2890</td><td class="line"> </td></tr>
|
---|
2970 | <tr><td class="num" id="LN2891">2891</td><td class="line"> <span class='keyword'>if</span> (flags & S_SHOW_ERRORS)</td></tr>
|
---|
2971 | <tr><td class="num" id="LN2892">2892</td><td class="line"> AddSpellMark(wordOffset, wordOffset + wordLength);</td></tr>
|
---|
2972 | <tr><td class="num" id="LN2893">2893</td><td class="line"> } <span class='keyword'>else</span> <span class='keyword'>if</span> (flags & S_CLEAR_ERRORS)</td></tr>
|
---|
2973 | <tr><td class="num" id="LN2894">2894</td><td class="line"> RemoveSpellMark(nextHighlight, wordOffset + wordLength);</td></tr>
|
---|
2974 | <tr><td class="num" id="LN2895">2895</td><td class="line"> </td></tr>
|
---|
2975 | <tr><td class="num" id="LN2896">2896</td><td class="line"> nextHighlight = wordOffset + wordLength;</td></tr>
|
---|
2976 | <tr><td class="num" id="LN2897">2897</td><td class="line"> }</td></tr>
|
---|
2977 | <tr><td class="num" id="LN2898">2898</td><td class="line"> }</td></tr>
|
---|
2978 | <tr><td class="num" id="LN2899">2899</td><td class="line"> <span class='comment'>// Reset state to looking for word</span></td></tr>
|
---|
2979 | <tr><td class="num" id="LN2900">2900</td><td class="line"> word = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
2980 | <tr><td class="num" id="LN2901">2901</td><td class="line"> wordLength = 0;</td></tr>
|
---|
2981 | <tr><td class="num" id="LN2902">2902</td><td class="line"> }</td></tr>
|
---|
2982 | <tr><td class="num" id="LN2903">2903</td><td class="line"> }</td></tr>
|
---|
2983 | <tr><td class="num" id="LN2904">2904</td><td class="line"> </td></tr>
|
---|
2984 | <tr><td class="num" id="LN2905">2905</td><td class="line"> <span class='keyword'>if</span> (nextHighlight <= end</td></tr>
|
---|
2985 | <tr><td class="num" id="LN2906">2906</td><td class="line"> && (flags & S_CLEAR_ERRORS) != 0</td></tr>
|
---|
2986 | <tr><td class="num" id="LN2907">2907</td><td class="line"> && nextHighlight < TextLength())</td></tr>
|
---|
2987 | <tr><td class="num" id="LN2908">2908</td><td class="line"> SetFontAndColor(nextHighlight, end, <span class='macro'>NULL<span class='expansion'>__null</span></span>, B_FONT_ALL, &kNormalTextColor);</td></tr>
|
---|
2988 | <tr><td class="num" id="LN2909">2909</td><td class="line">}</td></tr>
|
---|
2989 | <tr><td class="num" id="LN2910">2910</td><td class="line"> </td></tr>
|
---|
2990 | <tr><td class="num" id="LN2911">2911</td><td class="line"> </td></tr>
|
---|
2991 | <tr><td class="num" id="LN2912">2912</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
2992 | <tr><td class="num" id="LN2913">2913</td><td class="line">TTextView::FindSpellBoundry(int32 length, int32 offset, int32 *_start, int32 *_end)</td></tr>
|
---|
2993 | <tr><td class="num" id="LN2914">2914</td><td class="line">{</td></tr>
|
---|
2994 | <tr><td class="num" id="LN2915">2915</td><td class="line"> int32 start, end, textLength;</td></tr>
|
---|
2995 | <tr><td class="num" id="LN2916">2916</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = Text();</td></tr>
|
---|
2996 | <tr><td class="num" id="LN2917">2917</td><td class="line"> textLength = TextLength();</td></tr>
|
---|
2997 | <tr><td class="num" id="LN2918">2918</td><td class="line"> </td></tr>
|
---|
2998 | <tr><td class="num" id="LN2919">2919</td><td class="line"> <span class='keyword'>for</span> (start = offset - 1; start >= 0</td></tr>
|
---|
2999 | <tr><td class="num" id="LN2920">2920</td><td class="line"> && (<span class='macro'>isalpha(text[start])<span class='expansion'>(__ctype_b[(int)((text[start]))] & (unsigned short int)_ISalpha<br>)</span></span> || text[start] == '\''); start--) {}</td></tr>
|
---|
3000 | <tr><td class="num" id="LN2921">2921</td><td class="line"> </td></tr>
|
---|
3001 | <tr><td class="num" id="LN2922">2922</td><td class="line"> start++;</td></tr>
|
---|
3002 | <tr><td class="num" id="LN2923">2923</td><td class="line"> </td></tr>
|
---|
3003 | <tr><td class="num" id="LN2924">2924</td><td class="line"> <span class='keyword'>for</span> (end = offset + length; end < textLength</td></tr>
|
---|
3004 | <tr><td class="num" id="LN2925">2925</td><td class="line"> && (<span class='macro'>isalpha(text[end])<span class='expansion'>(__ctype_b[(int)((text[end]))] & (unsigned short int)_ISalpha<br>)</span></span> || text[end] == '\''); end++) {}</td></tr>
|
---|
3005 | <tr><td class="num" id="LN2926">2926</td><td class="line"> </td></tr>
|
---|
3006 | <tr><td class="num" id="LN2927">2927</td><td class="line"> *_start = start;</td></tr>
|
---|
3007 | <tr><td class="num" id="LN2928">2928</td><td class="line"> *_end = end;</td></tr>
|
---|
3008 | <tr><td class="num" id="LN2929">2929</td><td class="line">}</td></tr>
|
---|
3009 | <tr><td class="num" id="LN2930">2930</td><td class="line"> </td></tr>
|
---|
3010 | <tr><td class="num" id="LN2931">2931</td><td class="line"> </td></tr>
|
---|
3011 | <tr><td class="num" id="LN2932">2932</td><td class="line">TTextView::spell_mark *</td></tr>
|
---|
3012 | <tr><td class="num" id="LN2933">2933</td><td class="line">TTextView::FindSpellMark(int32 start, int32 end, spell_mark **_previousMark)</td></tr>
|
---|
3013 | <tr><td class="num" id="LN2934">2934</td><td class="line">{</td></tr>
|
---|
3014 | <tr><td class="num" id="LN2935">2935</td><td class="line"> spell_mark *lastMark = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
3015 | <tr><td class="num" id="LN2936">2936</td><td class="line"> </td></tr>
|
---|
3016 | <tr><td class="num" id="LN2937">2937</td><td class="line"> <span class='keyword'>for</span> (spell_mark *spellMark = fFirstSpellMark; spellMark; spellMark = spellMark->next) {</td></tr>
|
---|
3017 | <tr><td class="num" id="LN2938">2938</td><td class="line"> <span class='keyword'>if</span> (spellMark->start < end && spellMark->end > start) {</td></tr>
|
---|
3018 | <tr><td class="num" id="LN2939">2939</td><td class="line"> <span class='keyword'>if</span> (_previousMark)</td></tr>
|
---|
3019 | <tr><td class="num" id="LN2940">2940</td><td class="line"> *_previousMark = lastMark;</td></tr>
|
---|
3020 | <tr><td class="num" id="LN2941">2941</td><td class="line"> <span class='keyword'>return</span> spellMark;</td></tr>
|
---|
3021 | <tr><td class="num" id="LN2942">2942</td><td class="line"> }</td></tr>
|
---|
3022 | <tr><td class="num" id="LN2943">2943</td><td class="line"> </td></tr>
|
---|
3023 | <tr><td class="num" id="LN2944">2944</td><td class="line"> lastMark = spellMark;</td></tr>
|
---|
3024 | <tr><td class="num" id="LN2945">2945</td><td class="line"> }</td></tr>
|
---|
3025 | <tr><td class="num" id="LN2946">2946</td><td class="line"> <span class='keyword'>return</span> <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
3026 | <tr><td class="num" id="LN2947">2947</td><td class="line">}</td></tr>
|
---|
3027 | <tr><td class="num" id="LN2948">2948</td><td class="line"> </td></tr>
|
---|
3028 | <tr><td class="num" id="LN2949">2949</td><td class="line"> </td></tr>
|
---|
3029 | <tr><td class="num" id="LN2950">2950</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
3030 | <tr><td class="num" id="LN2951">2951</td><td class="line">TTextView::UpdateSpellMarks(int32 offset, int32 length)</td></tr>
|
---|
3031 | <tr><td class="num" id="LN2952">2952</td><td class="line">{</td></tr>
|
---|
3032 | <tr><td class="num" id="LN2953">2953</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"UpdateSpellMarks: offset = %ld, length = %ld\n"</span>, offset, length))<span class='expansion'>;</span></span>;</td></tr>
|
---|
3033 | <tr><td class="num" id="LN2954">2954</td><td class="line"> </td></tr>
|
---|
3034 | <tr><td class="num" id="LN2955">2955</td><td class="line"> spell_mark *spellMark;</td></tr>
|
---|
3035 | <tr><td class="num" id="LN2956">2956</td><td class="line"> <span class='keyword'>for</span> (spellMark = fFirstSpellMark; spellMark; spellMark = spellMark->next) {</td></tr>
|
---|
3036 | <tr><td class="num" id="LN2957">2957</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"\tfound: %ld - %ld\n"</span>, spellMark->start, spellMark->end))<span class='expansion'>;</span></span>;</td></tr>
|
---|
3037 | <tr><td class="num" id="LN2958">2958</td><td class="line"> </td></tr>
|
---|
3038 | <tr><td class="num" id="LN2959">2959</td><td class="line"> <span class='keyword'>if</span> (spellMark->end < offset)</td></tr>
|
---|
3039 | <tr><td class="num" id="LN2960">2960</td><td class="line"> <span class='keyword'>continue</span>;</td></tr>
|
---|
3040 | <tr><td class="num" id="LN2961">2961</td><td class="line"> </td></tr>
|
---|
3041 | <tr><td class="num" id="LN2962">2962</td><td class="line"> <span class='keyword'>if</span> (spellMark->start > offset)</td></tr>
|
---|
3042 | <tr><td class="num" id="LN2963">2963</td><td class="line"> spellMark->start += length;</td></tr>
|
---|
3043 | <tr><td class="num" id="LN2964">2964</td><td class="line"> </td></tr>
|
---|
3044 | <tr><td class="num" id="LN2965">2965</td><td class="line"> spellMark->end += length;</td></tr>
|
---|
3045 | <tr><td class="num" id="LN2966">2966</td><td class="line"> </td></tr>
|
---|
3046 | <tr><td class="num" id="LN2967">2967</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"\t-> reset: %ld - %ld\n"</span>, spellMark->start, spellMark->end))<span class='expansion'>;</span></span>;</td></tr>
|
---|
3047 | <tr><td class="num" id="LN2968">2968</td><td class="line"> }</td></tr>
|
---|
3048 | <tr><td class="num" id="LN2969">2969</td><td class="line">}</td></tr>
|
---|
3049 | <tr><td class="num" id="LN2970">2970</td><td class="line"> </td></tr>
|
---|
3050 | <tr><td class="num" id="LN2971">2971</td><td class="line"> </td></tr>
|
---|
3051 | <tr><td class="num" id="LN2972">2972</td><td class="line">status_t</td></tr>
|
---|
3052 | <tr><td class="num" id="LN2973">2973</td><td class="line">TTextView::AddSpellMark(int32 start, int32 end)</td></tr>
|
---|
3053 | <tr><td class="num" id="LN2974">2974</td><td class="line">{</td></tr>
|
---|
3054 | <tr><td class="num" id="LN2975">2975</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"AddSpellMark: start = %ld, end = %ld\n"</span>, start, end))<span class='expansion'>;</span></span>;</td></tr>
|
---|
3055 | <tr><td class="num" id="LN2976">2976</td><td class="line"> </td></tr>
|
---|
3056 | <tr><td class="num" id="LN2977">2977</td><td class="line"> <span class='comment'>// check if there is already a mark for this passage</span></td></tr>
|
---|
3057 | <tr><td class="num" id="LN2978">2978</td><td class="line"> spell_mark *spellMark = FindSpellMark(start, end);</td></tr>
|
---|
3058 | <tr><td class="num" id="LN2979">2979</td><td class="line"> <span class='keyword'>if</span> (spellMark) {</td></tr>
|
---|
3059 | <tr><td class="num" id="LN2980">2980</td><td class="line"> <span class='keyword'>if</span> (spellMark->start == start && spellMark->end == end) {</td></tr>
|
---|
3060 | <tr><td class="num" id="LN2981">2981</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"\tfound one\n"</span>))<span class='expansion'>;</span></span>;</td></tr>
|
---|
3061 | <tr><td class="num" id="LN2982">2982</td><td class="line"> <span class='keyword'>return</span> <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>;</td></tr>
|
---|
3062 | <tr><td class="num" id="LN2983">2983</td><td class="line"> }</td></tr>
|
---|
3063 | <tr><td class="num" id="LN2984">2984</td><td class="line"> </td></tr>
|
---|
3064 | <tr><td class="num" id="LN2985">2985</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"\tremove old one\n"</span>))<span class='expansion'>;</span></span>;</td></tr>
|
---|
3065 | <tr><td class="num" id="LN2986">2986</td><td class="line"> RemoveSpellMark(start, end);</td></tr>
|
---|
3066 | <tr><td class="num" id="LN2987">2987</td><td class="line"> }</td></tr>
|
---|
3067 | <tr><td class="num" id="LN2988">2988</td><td class="line"> </td></tr>
|
---|
3068 | <tr><td class="num" id="LN2989">2989</td><td class="line"> spellMark = (spell_mark *)malloc(<span class='keyword'>sizeof</span>(spell_mark));</td></tr>
|
---|
3069 | <tr><td class="num" id="LN2990">2990</td><td class="line"> <span class='keyword'>if</span> (spellMark == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
3070 | <tr><td class="num" id="LN2991">2991</td><td class="line"> <span class='keyword'>return</span> <span class='macro'>B_NO_MEMORY<span class='expansion'>((-2147483647 - 1) + 0)</span></span>;</td></tr>
|
---|
3071 | <tr><td class="num" id="LN2992">2992</td><td class="line"> </td></tr>
|
---|
3072 | <tr><td class="num" id="LN2993">2993</td><td class="line"> spellMark->start = start;</td></tr>
|
---|
3073 | <tr><td class="num" id="LN2994">2994</td><td class="line"> spellMark->end = end;</td></tr>
|
---|
3074 | <tr><td class="num" id="LN2995">2995</td><td class="line"> spellMark->style = RunArray(start, end);</td></tr>
|
---|
3075 | <tr><td class="num" id="LN2996">2996</td><td class="line"> </td></tr>
|
---|
3076 | <tr><td class="num" id="LN2997">2997</td><td class="line"> <span class='comment'>// set the spell marks appearance</span></td></tr>
|
---|
3077 | <tr><td class="num" id="LN2998">2998</td><td class="line"> BFont font(fFont);</td></tr>
|
---|
3078 | <tr><td class="num" id="LN2999">2999</td><td class="line"> font.SetFace(B_BOLD_FACE | B_ITALIC_FACE);</td></tr>
|
---|
3079 | <tr><td class="num" id="LN3000">3000</td><td class="line"> SetFontAndColor(start, end, &font, B_FONT_ALL, &kSpellTextColor);</td></tr>
|
---|
3080 | <tr><td class="num" id="LN3001">3001</td><td class="line"> </td></tr>
|
---|
3081 | <tr><td class="num" id="LN3002">3002</td><td class="line"> <span class='comment'>// add it to the queue</span></td></tr>
|
---|
3082 | <tr><td class="num" id="LN3003">3003</td><td class="line"> spellMark->next = fFirstSpellMark;</td></tr>
|
---|
3083 | <tr><td class="num" id="LN3004">3004</td><td class="line"> fFirstSpellMark = spellMark;</td></tr>
|
---|
3084 | <tr><td class="num" id="LN3005">3005</td><td class="line"> </td></tr>
|
---|
3085 | <tr><td class="num" id="LN3006">3006</td><td class="line"> <span class='keyword'>return</span> <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>;</td></tr>
|
---|
3086 | <tr><td class="num" id="LN3007">3007</td><td class="line">}</td></tr>
|
---|
3087 | <tr><td class="num" id="LN3008">3008</td><td class="line"> </td></tr>
|
---|
3088 | <tr><td class="num" id="LN3009">3009</td><td class="line"> </td></tr>
|
---|
3089 | <tr><td class="num" id="LN3010">3010</td><td class="line"><span class='keyword'>bool</span></td></tr>
|
---|
3090 | <tr><td class="num" id="LN3011">3011</td><td class="line">TTextView::RemoveSpellMark(int32 start, int32 end)</td></tr>
|
---|
3091 | <tr><td class="num" id="LN3012">3012</td><td class="line">{</td></tr>
|
---|
3092 | <tr><td class="num" id="LN3013">3013</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"RemoveSpellMark: start = %ld, end = %ld\n"</span>, start, end))<span class='expansion'>;</span></span>;</td></tr>
|
---|
3093 | <tr><td class="num" id="LN3014">3014</td><td class="line"> </td></tr>
|
---|
3094 | <tr><td class="num" id="LN3015">3015</td><td class="line"> <span class='comment'>// find spell mark</span></td></tr>
|
---|
3095 | <tr><td class="num" id="LN3016">3016</td><td class="line"> spell_mark *lastMark = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
3096 | <tr><td class="num" id="LN3017">3017</td><td class="line"> spell_mark *spellMark = FindSpellMark(start, end, &lastMark);</td></tr>
|
---|
3097 | <tr><td class="num" id="LN3018">3018</td><td class="line"> <span class='keyword'>if</span> (spellMark == <span class='macro'>NULL<span class='expansion'>__null</span></span>) {</td></tr>
|
---|
3098 | <tr><td class="num" id="LN3019">3019</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"\tnot found!\n"</span>))<span class='expansion'>;</span></span>;</td></tr>
|
---|
3099 | <tr><td class="num" id="LN3020">3020</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>false</span>;</td></tr>
|
---|
3100 | <tr><td class="num" id="LN3021">3021</td><td class="line"> }</td></tr>
|
---|
3101 | <tr><td class="num" id="LN3022">3022</td><td class="line"> </td></tr>
|
---|
3102 | <tr><td class="num" id="LN3023">3023</td><td class="line"> <span class='macro'>DSPELL(printf(<span class='string_literal'>"\tfound: %ld - %ld\n"</span>, spellMark->start, spellMark->end))<span class='expansion'>;</span></span>;</td></tr>
|
---|
3103 | <tr><td class="num" id="LN3024">3024</td><td class="line"> </td></tr>
|
---|
3104 | <tr><td class="num" id="LN3025">3025</td><td class="line"> <span class='comment'>// dequeue the spell mark</span></td></tr>
|
---|
3105 | <tr><td class="num" id="LN3026">3026</td><td class="line"> <span class='keyword'>if</span> (lastMark)</td></tr>
|
---|
3106 | <tr><td class="num" id="LN3027">3027</td><td class="line"> lastMark->next = spellMark->next;</td></tr>
|
---|
3107 | <tr><td class="num" id="LN3028">3028</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
3108 | <tr><td class="num" id="LN3029">3029</td><td class="line"> fFirstSpellMark = spellMark->next;</td></tr>
|
---|
3109 | <tr><td class="num" id="LN3030">3030</td><td class="line"> </td></tr>
|
---|
3110 | <tr><td class="num" id="LN3031">3031</td><td class="line"> <span class='keyword'>if</span> (spellMark->start < start)</td></tr>
|
---|
3111 | <tr><td class="num" id="LN3032">3032</td><td class="line"> start = spellMark->start;</td></tr>
|
---|
3112 | <tr><td class="num" id="LN3033">3033</td><td class="line"> <span class='keyword'>if</span> (spellMark->end > end)</td></tr>
|
---|
3113 | <tr><td class="num" id="LN3034">3034</td><td class="line"> end = spellMark->end;</td></tr>
|
---|
3114 | <tr><td class="num" id="LN3035">3035</td><td class="line"> </td></tr>
|
---|
3115 | <tr><td class="num" id="LN3036">3036</td><td class="line"> <span class='comment'>// reset old text run array</span></td></tr>
|
---|
3116 | <tr><td class="num" id="LN3037">3037</td><td class="line"> SetRunArray(start, end, spellMark->style);</td></tr>
|
---|
3117 | <tr><td class="num" id="LN3038">3038</td><td class="line"> </td></tr>
|
---|
3118 | <tr><td class="num" id="LN3039">3039</td><td class="line"> free(spellMark->style);</td></tr>
|
---|
3119 | <tr><td class="num" id="LN3040">3040</td><td class="line"> free(spellMark);</td></tr>
|
---|
3120 | <tr><td class="num" id="LN3041">3041</td><td class="line"> </td></tr>
|
---|
3121 | <tr><td class="num" id="LN3042">3042</td><td class="line"> <span class='keyword'>return</span> <span class='keyword'>true</span>;</td></tr>
|
---|
3122 | <tr><td class="num" id="LN3043">3043</td><td class="line">}</td></tr>
|
---|
3123 | <tr><td class="num" id="LN3044">3044</td><td class="line"> </td></tr>
|
---|
3124 | <tr><td class="num" id="LN3045">3045</td><td class="line"> </td></tr>
|
---|
3125 | <tr><td class="num" id="LN3046">3046</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
3126 | <tr><td class="num" id="LN3047">3047</td><td class="line">TTextView::RemoveSpellMarks()</td></tr>
|
---|
3127 | <tr><td class="num" id="LN3048">3048</td><td class="line">{</td></tr>
|
---|
3128 | <tr><td class="num" id="LN3049">3049</td><td class="line"> spell_mark *spellMark, *nextMark;</td></tr>
|
---|
3129 | <tr><td class="num" id="LN3050">3050</td><td class="line"> </td></tr>
|
---|
3130 | <tr><td class="num" id="LN3051">3051</td><td class="line"> <span class='keyword'>for</span> (spellMark = fFirstSpellMark; spellMark; spellMark = nextMark) {</td></tr>
|
---|
3131 | <tr><td class="num" id="LN3052">3052</td><td class="line"> nextMark = spellMark->next;</td></tr>
|
---|
3132 | <tr><td class="num" id="LN3053">3053</td><td class="line"> </td></tr>
|
---|
3133 | <tr><td class="num" id="LN3054">3054</td><td class="line"> <span class='comment'>// reset old text run array</span></td></tr>
|
---|
3134 | <tr><td class="num" id="LN3055">3055</td><td class="line"> SetRunArray(spellMark->start, spellMark->end, spellMark->style);</td></tr>
|
---|
3135 | <tr><td class="num" id="LN3056">3056</td><td class="line"> </td></tr>
|
---|
3136 | <tr><td class="num" id="LN3057">3057</td><td class="line"> free(spellMark->style);</td></tr>
|
---|
3137 | <tr><td class="num" id="LN3058">3058</td><td class="line"> free(spellMark);</td></tr>
|
---|
3138 | <tr><td class="num" id="LN3059">3059</td><td class="line"> }</td></tr>
|
---|
3139 | <tr><td class="num" id="LN3060">3060</td><td class="line"> </td></tr>
|
---|
3140 | <tr><td class="num" id="LN3061">3061</td><td class="line"> fFirstSpellMark = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
3141 | <tr><td class="num" id="LN3062">3062</td><td class="line">}</td></tr>
|
---|
3142 | <tr><td class="num" id="LN3063">3063</td><td class="line"> </td></tr>
|
---|
3143 | <tr><td class="num" id="LN3064">3064</td><td class="line"> </td></tr>
|
---|
3144 | <tr><td class="num" id="LN3065">3065</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
3145 | <tr><td class="num" id="LN3066">3066</td><td class="line">TTextView::EnableSpellCheck(<span class='keyword'>bool</span> enable)</td></tr>
|
---|
3146 | <tr><td class="num" id="LN3067">3067</td><td class="line">{</td></tr>
|
---|
3147 | <tr><td class="num" id="LN3068">3068</td><td class="line"> <span class='keyword'>if</span> (fSpellCheck == enable)</td></tr>
|
---|
3148 | <tr><td class="num" id="LN3069">3069</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
3149 | <tr><td class="num" id="LN3070">3070</td><td class="line"> </td></tr>
|
---|
3150 | <tr><td class="num" id="LN3071">3071</td><td class="line"> fSpellCheck = enable;</td></tr>
|
---|
3151 | <tr><td class="num" id="LN3072">3072</td><td class="line"> int32 textLength = TextLength();</td></tr>
|
---|
3152 | <tr><td class="num" id="LN3073">3073</td><td class="line"> <span class='keyword'>if</span> (fSpellCheck) {</td></tr>
|
---|
3153 | <tr><td class="num" id="LN3074">3074</td><td class="line"> <span class='comment'>// work-around for a bug in the BTextView class</span></td></tr>
|
---|
3154 | <tr><td class="num" id="LN3075">3075</td><td class="line"> <span class='comment'>// which causes lots of flicker</span></td></tr>
|
---|
3155 | <tr><td class="num" id="LN3076">3076</td><td class="line"> int32 start, end;</td></tr>
|
---|
3156 | <tr><td class="num" id="LN3077">3077</td><td class="line"> GetSelection(&start, &end);</td></tr>
|
---|
3157 | <tr><td class="num" id="LN3078">3078</td><td class="line"> <span class='keyword'>if</span> (start != end)</td></tr>
|
---|
3158 | <tr><td class="num" id="LN3079">3079</td><td class="line"> Select(start, start);</td></tr>
|
---|
3159 | <tr><td class="num" id="LN3080">3080</td><td class="line"> </td></tr>
|
---|
3160 | <tr><td class="num" id="LN3081">3081</td><td class="line"> CheckSpelling(0, textLength);</td></tr>
|
---|
3161 | <tr><td class="num" id="LN3082">3082</td><td class="line"> </td></tr>
|
---|
3162 | <tr><td class="num" id="LN3083">3083</td><td class="line"> <span class='keyword'>if</span> (start != end)</td></tr>
|
---|
3163 | <tr><td class="num" id="LN3084">3084</td><td class="line"> Select(start, end);</td></tr>
|
---|
3164 | <tr><td class="num" id="LN3085">3085</td><td class="line"> }</td></tr>
|
---|
3165 | <tr><td class="num" id="LN3086">3086</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
3166 | <tr><td class="num" id="LN3087">3087</td><td class="line"> RemoveSpellMarks();</td></tr>
|
---|
3167 | <tr><td class="num" id="LN3088">3088</td><td class="line">}</td></tr>
|
---|
3168 | <tr><td class="num" id="LN3089">3089</td><td class="line"> </td></tr>
|
---|
3169 | <tr><td class="num" id="LN3090">3090</td><td class="line"> </td></tr>
|
---|
3170 | <tr><td class="num" id="LN3091">3091</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
3171 | <tr><td class="num" id="LN3092">3092</td><td class="line">TTextView::WindowActivated(<span class='keyword'>bool</span> flag)</td></tr>
|
---|
3172 | <tr><td class="num" id="LN3093">3093</td><td class="line">{</td></tr>
|
---|
3173 | <tr><td class="num" id="LN3094">3094</td><td class="line"> <span class='keyword'>if</span> (!flag) {</td></tr>
|
---|
3174 | <tr><td class="num" id="LN3095">3095</td><td class="line"> <span class='comment'>// WindowActivated(false) は、IM も Inactive になり、そのまま確定される。</span></td></tr>
|
---|
3175 | <tr><td class="num" id="LN3096">3096</td><td class="line"> <span class='comment'>// しかしこの場合、input_server が B_INPUT_METHOD_EVENT(B_INPUT_METHOD_STOPPED)</span></td></tr>
|
---|
3176 | <tr><td class="num" id="LN3097">3097</td><td class="line"> <span class='comment'>// を送ってこないまま矛盾してしまうので、やむを得ずここでつじつまあわせ処理している。</span></td></tr>
|
---|
3177 | <tr><td class="num" id="LN3098">3098</td><td class="line"> <span class='comment'>// OpenBeOSで修正されることを願って暫定処置としている。</span></td></tr>
|
---|
3178 | <tr><td class="num" id="LN3099">3099</td><td class="line"> fInputMethodUndoState.active = <span class='keyword'>false</span>;</td></tr>
|
---|
3179 | <tr><td class="num" id="LN3100">3100</td><td class="line"> <span class='comment'>// fInputMethodUndoBufferに溜まっている最後のデータがK_INSERTEDなら(確定)正規のバッファへ追加</span></td></tr>
|
---|
3180 | <tr><td class="num" id="LN3101">3101</td><td class="line"> <span class='keyword'>if</span> (fInputMethodUndoBuffer.CountItems() > 0) {</td></tr>
|
---|
3181 | <tr><td class="num" id="LN3102">3102</td><td class="line"> KUndoItem *item = fInputMethodUndoBuffer.ItemAt(fInputMethodUndoBuffer.CountItems() - 1);</td></tr>
|
---|
3182 | <tr><td class="num" id="LN3103">3103</td><td class="line"> <span class='keyword'>if</span> (item->History == K_INSERTED) {</td></tr>
|
---|
3183 | <tr><td class="num" id="LN3104">3104</td><td class="line"> fUndoBuffer.MakeNewUndoItem();</td></tr>
|
---|
3184 | <tr><td class="num" id="LN3105">3105</td><td class="line"> fUndoBuffer.AddUndo(item->RedoText, item->Length, item->Offset,</td></tr>
|
---|
3185 | <tr><td class="num" id="LN3106">3106</td><td class="line"> item->History, item->CursorPos);</td></tr>
|
---|
3186 | <tr><td class="num" id="LN3107">3107</td><td class="line"> fUndoBuffer.MakeNewUndoItem();</td></tr>
|
---|
3187 | <tr><td class="num" id="LN3108">3108</td><td class="line"> }</td></tr>
|
---|
3188 | <tr><td class="num" id="LN3109">3109</td><td class="line"> fInputMethodUndoBuffer.MakeEmpty();</td></tr>
|
---|
3189 | <tr><td class="num" id="LN3110">3110</td><td class="line"> }</td></tr>
|
---|
3190 | <tr><td class="num" id="LN3111">3111</td><td class="line"> }</td></tr>
|
---|
3191 | <tr><td class="num" id="LN3112">3112</td><td class="line"> BTextView::WindowActivated(flag);</td></tr>
|
---|
3192 | <tr><td class="num" id="LN3113">3113</td><td class="line">}</td></tr>
|
---|
3193 | <tr><td class="num" id="LN3114">3114</td><td class="line"> </td></tr>
|
---|
3194 | <tr><td class="num" id="LN3115">3115</td><td class="line"> </td></tr>
|
---|
3195 | <tr><td class="num" id="LN3116">3116</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
3196 | <tr><td class="num" id="LN3117">3117</td><td class="line">TTextView::AddQuote(int32 start, int32 finish)</td></tr>
|
---|
3197 | <tr><td class="num" id="LN3118">3118</td><td class="line">{</td></tr>
|
---|
3198 | <tr><td class="num" id="LN3119">3119</td><td class="line"> BRect rect = Bounds();</td></tr>
|
---|
3199 | <tr><td class="num" id="LN3120">3120</td><td class="line"> </td></tr>
|
---|
3200 | <tr><td class="num" id="LN3121">3121</td><td class="line"> int32 lineStart;</td></tr>
|
---|
3201 | <tr><td class="num" id="LN3122">3122</td><td class="line"> GoToLine(CurrentLine());</td></tr>
|
---|
3202 | <tr><td class="num" id="LN3123">3123</td><td class="line"> GetSelection(&lineStart, &lineStart);</td></tr>
|
---|
3203 | <tr><td class="num" id="LN3124">3124</td><td class="line"> </td></tr>
|
---|
3204 | <tr><td class="num" id="LN3125">3125</td><td class="line"> <span class='comment'>// make sure that we're changing the whole last line, too</span></td></tr>
|
---|
3205 | <tr><td class="num" id="LN3126">3126</td><td class="line"> int32 lineEnd = finish > lineStart ? finish - 1 : finish;</td></tr>
|
---|
3206 | <tr><td class="num"></td><td class="line"><div id="Path1" class="msg msgControl" style="margin-left:25ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexControl">1</div></td><td>'?' condition is false</td><td><div class="PathNav"><a href="#Path2" title="Next event (2)">→</a></div></td></tr></table></div></td></tr>
|
---|
3207 | <tr><td class="num" id="LN3127">3127</td><td class="line"> {</td></tr>
|
---|
3208 | <tr><td class="num" id="LN3128">3128</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = Text();</td></tr>
|
---|
3209 | <tr><td class="num" id="LN3129">3129</td><td class="line"> <span class='keyword'>while</span> (text[lineEnd] && text[lineEnd] != '\n')</td></tr>
|
---|
3210 | <tr><td class="num"></td><td class="line"><div id="Path2" class="msg msgControl" style="margin-left:17ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexControl">2</div></td><td><div class="PathNav"><a href="#Path1" title="Previous event (1)">←</a></div></td></td><td>Loop condition is false. Execution continues on line 3132</td><td><div class="PathNav"><a href="#Path3" title="Next event (3)">→</a></div></td></tr></table></div></td></tr>
|
---|
3211 | <tr><td class="num" id="LN3130">3130</td><td class="line"> lineEnd++;</td></tr>
|
---|
3212 | <tr><td class="num" id="LN3131">3131</td><td class="line"> }</td></tr>
|
---|
3213 | <tr><td class="num" id="LN3132">3132</td><td class="line"> Select(lineStart, lineEnd);</td></tr>
|
---|
3214 | <tr><td class="num" id="LN3133">3133</td><td class="line"> </td></tr>
|
---|
3215 | <tr><td class="num" id="LN3134">3134</td><td class="line"> int32 textLength = lineEnd - lineStart;</td></tr>
|
---|
3216 | <tr><td class="num" id="LN3135">3135</td><td class="line"> <span class='keyword'>char</span> *text = (<span class='keyword'>char</span> *)malloc(textLength + 1);</td></tr>
|
---|
3217 | <tr><td class="num" id="LN3136">3136</td><td class="line"> <span class='keyword'>if</span> (text == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
3218 | <tr><td class="num"></td><td class="line"><div id="Path3" class="msg msgControl" style="margin-left:9ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexControl">3</div></td><td><div class="PathNav"><a href="#Path2" title="Previous event (2)">←</a></div></td></td><td>Taking false branch</td><td><div class="PathNav"><a href="#Path4" title="Next event (4)">→</a></div></td></tr></table></div></td></tr>
|
---|
3219 | <tr><td class="num" id="LN3137">3137</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
3220 | <tr><td class="num" id="LN3138">3138</td><td class="line"> </td></tr>
|
---|
3221 | <tr><td class="num" id="LN3139">3139</td><td class="line"> GetText(lineStart, textLength, text);</td></tr>
|
---|
3222 | <tr><td class="num" id="LN3140">3140</td><td class="line"> </td></tr>
|
---|
3223 | <tr><td class="num" id="LN3141">3141</td><td class="line"> int32 quoteLength = strlen(<span class='macro'>QUOTE<span class='expansion'>"> "</span></span>);</td></tr>
|
---|
3224 | <tr><td class="num" id="LN3142">3142</td><td class="line"> int32 targetLength = 0;</td></tr>
|
---|
3225 | <tr><td class="num" id="LN3143">3143</td><td class="line"> <span class='keyword'>char</span> *target = <span class='macro'>NULL<span class='expansion'>__null</span></span>;</td></tr>
|
---|
3226 | <tr><td class="num" id="LN3144">3144</td><td class="line"> int32 lastLine = 0;</td></tr>
|
---|
3227 | <tr><td class="num" id="LN3145">3145</td><td class="line"> </td></tr>
|
---|
3228 | <tr><td class="num" id="LN3146">3146</td><td class="line"> <span class='keyword'>for</span> (int32 index = 0; <span class="mrange"><span class="mrange">index < textLength</span></span>; index++) {</td></tr>
|
---|
3229 | <tr><td class="num"></td><td class="line"><div id="Path4" class="msg msgEvent" style="margin-left:31ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexEvent">4</div></td><td><div class="PathNav"><a href="#Path3" title="Previous event (3)">←</a></div></td></td><td>Assuming 'index' is < 'textLength'</td><td><div class="PathNav"><a href="#Path5" title="Next event (5)">→</a></div></td></tr></table></div></td></tr>
|
---|
3230 | <tr><td class="num"></td><td class="line"><div id="Path5" class="msg msgControl" style="margin-left:9ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexControl">5</div></td><td><div class="PathNav"><a href="#Path4" title="Previous event (4)">←</a></div></td></td><td>Loop condition is true. Entering loop body</td><td><div class="PathNav"><a href="#Path6" title="Next event (6)">→</a></div></td></tr></table></div></td></tr>
|
---|
3231 | <tr><td class="num"></td><td class="line"><div id="Path8" class="msg msgEvent" style="margin-left:31ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexEvent">8</div></td><td><div class="PathNav"><a href="#Path7" title="Previous event (7)">←</a></div></td></td><td>Assuming 'index' is < 'textLength'</td><td><div class="PathNav"><a href="#Path9" title="Next event (9)">→</a></div></td></tr></table></div></td></tr>
|
---|
3232 | <tr><td class="num"></td><td class="line"><div id="Path9" class="msg msgControl" style="margin-left:9ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexControl">9</div></td><td><div class="PathNav"><a href="#Path8" title="Previous event (8)">←</a></div></td></td><td>Loop condition is true. Entering loop body</td><td><div class="PathNav"><a href="#Path10" title="Next event (10)">→</a></div></td></tr></table></div></td></tr>
|
---|
3233 | <tr><td class="num" id="LN3147">3147</td><td class="line"> <span class='keyword'>if</span> (text[index] == '\n' || index == textLength - 1) {</td></tr>
|
---|
3234 | <tr><td class="num" id="LN3148">3148</td><td class="line"> <span class='comment'>// add quote to this line</span></td></tr>
|
---|
3235 | <tr><td class="num" id="LN3149">3149</td><td class="line"> int32 lineLength = index - lastLine + 1;</td></tr>
|
---|
3236 | <tr><td class="num" id="LN3150">3150</td><td class="line"> </td></tr>
|
---|
3237 | <tr><td class="num" id="LN3151">3151</td><td class="line"> target = (<span class='keyword'>char</span> *)<span class="mrange"><span class="mrange">realloc(target, targetLength + lineLength + quoteLength)</span></span>;</td></tr>
|
---|
3238 | <tr><td class="num"></td><td class="line"><div id="Path6" class="msg msgEvent" style="margin-left:42ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexEvent">6</div></td><td><div class="PathNav"><a href="#Path5" title="Previous event (5)">←</a></div></td></td><td>Memory is allocated</td><td><div class="PathNav"><a href="#Path7" title="Next event (7)">→</a></div></td></tr></table></div></td></tr>
|
---|
3239 | <tr><td class="num"></td><td class="line"><div id="Path10" class="msg msgEvent" style="margin-left:42ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexEvent">10</div></td><td><div class="PathNav"><a href="#Path9" title="Previous event (9)">←</a></div></td></td><td>Attempt to reallocate memory</td><td><div class="PathNav"><a href="#Path11" title="Next event (11)">→</a></div></td></tr></table></div></td></tr>
|
---|
3240 | <tr><td class="num" id="LN3152">3152</td><td class="line"> <span class='keyword'>if</span> (<span class="mrange">target == <span class='macro'>NULL<span class='expansion'>__null</span></span></span>) {</td></tr>
|
---|
3241 | <tr><td class="num"></td><td class="line"><div id="Path7" class="msg msgControl" style="margin-left:25ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexControl">7</div></td><td><div class="PathNav"><a href="#Path6" title="Previous event (6)">←</a></div></td></td><td>Taking false branch</td><td><div class="PathNav"><a href="#Path8" title="Next event (8)">→</a></div></td></tr></table></div></td></tr>
|
---|
3242 | <tr><td class="num"></td><td class="line"><div id="Path11" class="msg msgEvent" style="margin-left:29ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexEvent">11</div></td><td><div class="PathNav"><a href="#Path10" title="Previous event (10)">←</a></div></td></td><td>Reallocation failed</td><td><div class="PathNav"><a href="#Path12" title="Next event (12)">→</a></div></td></tr></table></div></td></tr>
|
---|
3243 | <tr><td class="num"></td><td class="line"><div id="Path12" class="msg msgControl" style="margin-left:25ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexControl">12</div></td><td><div class="PathNav"><a href="#Path11" title="Previous event (11)">←</a></div></td></td><td>Taking true branch</td><td><div class="PathNav"><a href="#EndPath" title="Next event (13)">→</a></div></td></tr></table></div></td></tr>
|
---|
3244 | <tr><td class="num" id="LN3153">3153</td><td class="line"> <span class='comment'>// free the old buffer?</span></td></tr>
|
---|
3245 | <tr><td class="num" id="LN3154">3154</td><td class="line"> free(text);</td></tr>
|
---|
3246 | <tr><td class="num"></td><td class="line"><div id="EndPath" class="msg msgEvent" style="margin-left:33ex"><table class="msgT"><tr><td valign="top"><div class="PathIndex PathIndexEvent">13</div></td><td><div class="PathNav"><a href="#Path12" title="Previous event (12)">←</a></div></td></td><td>Potential leak of memory pointed to by 'target'</td></tr></table></div></td></tr>
|
---|
3247 | <tr><td class="num" id="LN3155">3155</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
3248 | <tr><td class="num" id="LN3156">3156</td><td class="line"> }</td></tr>
|
---|
3249 | <tr><td class="num" id="LN3157">3157</td><td class="line"> </td></tr>
|
---|
3250 | <tr><td class="num" id="LN3158">3158</td><td class="line"> <span class='comment'>// copy the quote sign</span></td></tr>
|
---|
3251 | <tr><td class="num" id="LN3159">3159</td><td class="line"> memcpy(&target[targetLength], <span class='macro'>QUOTE<span class='expansion'>"> "</span></span>, quoteLength);</td></tr>
|
---|
3252 | <tr><td class="num" id="LN3160">3160</td><td class="line"> targetLength += quoteLength;</td></tr>
|
---|
3253 | <tr><td class="num" id="LN3161">3161</td><td class="line"> </td></tr>
|
---|
3254 | <tr><td class="num" id="LN3162">3162</td><td class="line"> <span class='comment'>// copy the rest of the line</span></td></tr>
|
---|
3255 | <tr><td class="num" id="LN3163">3163</td><td class="line"> memcpy(&target[targetLength], &text[lastLine], lineLength);</td></tr>
|
---|
3256 | <tr><td class="num" id="LN3164">3164</td><td class="line"> targetLength += lineLength;</td></tr>
|
---|
3257 | <tr><td class="num" id="LN3165">3165</td><td class="line"> </td></tr>
|
---|
3258 | <tr><td class="num" id="LN3166">3166</td><td class="line"> lastLine = index + 1;</td></tr>
|
---|
3259 | <tr><td class="num" id="LN3167">3167</td><td class="line"> }</td></tr>
|
---|
3260 | <tr><td class="num" id="LN3168">3168</td><td class="line"> }</td></tr>
|
---|
3261 | <tr><td class="num" id="LN3169">3169</td><td class="line"> </td></tr>
|
---|
3262 | <tr><td class="num" id="LN3170">3170</td><td class="line"> <span class='comment'>// replace with quoted text</span></td></tr>
|
---|
3263 | <tr><td class="num" id="LN3171">3171</td><td class="line"> free(text);</td></tr>
|
---|
3264 | <tr><td class="num" id="LN3172">3172</td><td class="line"> Delete();</td></tr>
|
---|
3265 | <tr><td class="num" id="LN3173">3173</td><td class="line"> </td></tr>
|
---|
3266 | <tr><td class="num" id="LN3174">3174</td><td class="line"> <span class='keyword'>if</span> (fColoredQuotes) {</td></tr>
|
---|
3267 | <tr><td class="num" id="LN3175">3175</td><td class="line"> <span class='keyword'>const</span> BFont *font = Font();</td></tr>
|
---|
3268 | <tr><td class="num" id="LN3176">3176</td><td class="line"> TextRunArray style(targetLength / 8 + 8);</td></tr>
|
---|
3269 | <tr><td class="num" id="LN3177">3177</td><td class="line"> </td></tr>
|
---|
3270 | <tr><td class="num" id="LN3178">3178</td><td class="line"> FillInQuoteTextRuns(<span class='macro'>NULL<span class='expansion'>__null</span></span>, <span class='macro'>NULL<span class='expansion'>__null</span></span>, target, targetLength, font,</td></tr>
|
---|
3271 | <tr><td class="num" id="LN3179">3179</td><td class="line"> &style.Array(), style.MaxEntries());</td></tr>
|
---|
3272 | <tr><td class="num" id="LN3180">3180</td><td class="line"> Insert(target, targetLength, &style.Array());</td></tr>
|
---|
3273 | <tr><td class="num" id="LN3181">3181</td><td class="line"> } <span class='keyword'>else</span></td></tr>
|
---|
3274 | <tr><td class="num" id="LN3182">3182</td><td class="line"> Insert(target, targetLength);</td></tr>
|
---|
3275 | <tr><td class="num" id="LN3183">3183</td><td class="line"> </td></tr>
|
---|
3276 | <tr><td class="num" id="LN3184">3184</td><td class="line"> free(target);</td></tr>
|
---|
3277 | <tr><td class="num" id="LN3185">3185</td><td class="line"> </td></tr>
|
---|
3278 | <tr><td class="num" id="LN3186">3186</td><td class="line"> <span class='comment'>// redo the old selection (compute the new start if necessary)</span></td></tr>
|
---|
3279 | <tr><td class="num" id="LN3187">3187</td><td class="line"> Select(start + quoteLength, finish + (targetLength - textLength));</td></tr>
|
---|
3280 | <tr><td class="num" id="LN3188">3188</td><td class="line"> </td></tr>
|
---|
3281 | <tr><td class="num" id="LN3189">3189</td><td class="line"> ScrollTo(rect.LeftTop());</td></tr>
|
---|
3282 | <tr><td class="num" id="LN3190">3190</td><td class="line">}</td></tr>
|
---|
3283 | <tr><td class="num" id="LN3191">3191</td><td class="line"> </td></tr>
|
---|
3284 | <tr><td class="num" id="LN3192">3192</td><td class="line"> </td></tr>
|
---|
3285 | <tr><td class="num" id="LN3193">3193</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
3286 | <tr><td class="num" id="LN3194">3194</td><td class="line">TTextView::RemoveQuote(int32 start, int32 finish)</td></tr>
|
---|
3287 | <tr><td class="num" id="LN3195">3195</td><td class="line">{</td></tr>
|
---|
3288 | <tr><td class="num" id="LN3196">3196</td><td class="line"> BRect rect = Bounds();</td></tr>
|
---|
3289 | <tr><td class="num" id="LN3197">3197</td><td class="line"> </td></tr>
|
---|
3290 | <tr><td class="num" id="LN3198">3198</td><td class="line"> GoToLine(CurrentLine());</td></tr>
|
---|
3291 | <tr><td class="num" id="LN3199">3199</td><td class="line"> int32 lineStart;</td></tr>
|
---|
3292 | <tr><td class="num" id="LN3200">3200</td><td class="line"> GetSelection(&lineStart, &lineStart);</td></tr>
|
---|
3293 | <tr><td class="num" id="LN3201">3201</td><td class="line"> </td></tr>
|
---|
3294 | <tr><td class="num" id="LN3202">3202</td><td class="line"> <span class='comment'>// make sure that we're changing the whole last line, too</span></td></tr>
|
---|
3295 | <tr><td class="num" id="LN3203">3203</td><td class="line"> int32 lineEnd = finish > lineStart ? finish - 1 : finish;</td></tr>
|
---|
3296 | <tr><td class="num" id="LN3204">3204</td><td class="line"> <span class='keyword'>const</span> <span class='keyword'>char</span> *text = Text();</td></tr>
|
---|
3297 | <tr><td class="num" id="LN3205">3205</td><td class="line"> <span class='keyword'>while</span> (text[lineEnd] && text[lineEnd] != '\n')</td></tr>
|
---|
3298 | <tr><td class="num" id="LN3206">3206</td><td class="line"> lineEnd++;</td></tr>
|
---|
3299 | <tr><td class="num" id="LN3207">3207</td><td class="line"> </td></tr>
|
---|
3300 | <tr><td class="num" id="LN3208">3208</td><td class="line"> Select(lineStart, lineEnd);</td></tr>
|
---|
3301 | <tr><td class="num" id="LN3209">3209</td><td class="line"> </td></tr>
|
---|
3302 | <tr><td class="num" id="LN3210">3210</td><td class="line"> int32 length = lineEnd - lineStart;</td></tr>
|
---|
3303 | <tr><td class="num" id="LN3211">3211</td><td class="line"> <span class='keyword'>char</span> *target = (<span class='keyword'>char</span> *)malloc(length + 1);</td></tr>
|
---|
3304 | <tr><td class="num" id="LN3212">3212</td><td class="line"> <span class='keyword'>if</span> (target == <span class='macro'>NULL<span class='expansion'>__null</span></span>)</td></tr>
|
---|
3305 | <tr><td class="num" id="LN3213">3213</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
3306 | <tr><td class="num" id="LN3214">3214</td><td class="line"> </td></tr>
|
---|
3307 | <tr><td class="num" id="LN3215">3215</td><td class="line"> int32 quoteLength = strlen(<span class='macro'>QUOTE<span class='expansion'>"> "</span></span>);</td></tr>
|
---|
3308 | <tr><td class="num" id="LN3216">3216</td><td class="line"> int32 removed = 0;</td></tr>
|
---|
3309 | <tr><td class="num" id="LN3217">3217</td><td class="line"> text += lineStart;</td></tr>
|
---|
3310 | <tr><td class="num" id="LN3218">3218</td><td class="line"> </td></tr>
|
---|
3311 | <tr><td class="num" id="LN3219">3219</td><td class="line"> <span class='keyword'>for</span> (int32 index = 0; index < length;) {</td></tr>
|
---|
3312 | <tr><td class="num" id="LN3220">3220</td><td class="line"> <span class='comment'>// find out the length of the current line</span></td></tr>
|
---|
3313 | <tr><td class="num" id="LN3221">3221</td><td class="line"> int32 lineLength = 0;</td></tr>
|
---|
3314 | <tr><td class="num" id="LN3222">3222</td><td class="line"> <span class='keyword'>while</span> (index + lineLength < length && text[lineLength] != '\n')</td></tr>
|
---|
3315 | <tr><td class="num" id="LN3223">3223</td><td class="line"> lineLength++;</td></tr>
|
---|
3316 | <tr><td class="num" id="LN3224">3224</td><td class="line"> </td></tr>
|
---|
3317 | <tr><td class="num" id="LN3225">3225</td><td class="line"> <span class='comment'>// include the newline to be part of this line</span></td></tr>
|
---|
3318 | <tr><td class="num" id="LN3226">3226</td><td class="line"> <span class='keyword'>if</span> (text[lineLength] == '\n' && index + lineLength + 1 < length)</td></tr>
|
---|
3319 | <tr><td class="num" id="LN3227">3227</td><td class="line"> lineLength++;</td></tr>
|
---|
3320 | <tr><td class="num" id="LN3228">3228</td><td class="line"> </td></tr>
|
---|
3321 | <tr><td class="num" id="LN3229">3229</td><td class="line"> <span class='keyword'>if</span> (!strncmp(text, <span class='macro'>QUOTE<span class='expansion'>"> "</span></span>, quoteLength)) {</td></tr>
|
---|
3322 | <tr><td class="num" id="LN3230">3230</td><td class="line"> <span class='comment'>// remove quote</span></td></tr>
|
---|
3323 | <tr><td class="num" id="LN3231">3231</td><td class="line"> length -= quoteLength;</td></tr>
|
---|
3324 | <tr><td class="num" id="LN3232">3232</td><td class="line"> removed += quoteLength;</td></tr>
|
---|
3325 | <tr><td class="num" id="LN3233">3233</td><td class="line"> </td></tr>
|
---|
3326 | <tr><td class="num" id="LN3234">3234</td><td class="line"> lineLength -= quoteLength;</td></tr>
|
---|
3327 | <tr><td class="num" id="LN3235">3235</td><td class="line"> text += quoteLength;</td></tr>
|
---|
3328 | <tr><td class="num" id="LN3236">3236</td><td class="line"> }</td></tr>
|
---|
3329 | <tr><td class="num" id="LN3237">3237</td><td class="line"> </td></tr>
|
---|
3330 | <tr><td class="num" id="LN3238">3238</td><td class="line"> <span class='keyword'>if</span> (lineLength == 0) {</td></tr>
|
---|
3331 | <tr><td class="num" id="LN3239">3239</td><td class="line"> target[index] = '\0';</td></tr>
|
---|
3332 | <tr><td class="num" id="LN3240">3240</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
3333 | <tr><td class="num" id="LN3241">3241</td><td class="line"> }</td></tr>
|
---|
3334 | <tr><td class="num" id="LN3242">3242</td><td class="line"> </td></tr>
|
---|
3335 | <tr><td class="num" id="LN3243">3243</td><td class="line"> memcpy(&target[index], text, lineLength);</td></tr>
|
---|
3336 | <tr><td class="num" id="LN3244">3244</td><td class="line"> </td></tr>
|
---|
3337 | <tr><td class="num" id="LN3245">3245</td><td class="line"> text += lineLength;</td></tr>
|
---|
3338 | <tr><td class="num" id="LN3246">3246</td><td class="line"> index += lineLength;</td></tr>
|
---|
3339 | <tr><td class="num" id="LN3247">3247</td><td class="line"> }</td></tr>
|
---|
3340 | <tr><td class="num" id="LN3248">3248</td><td class="line"> </td></tr>
|
---|
3341 | <tr><td class="num" id="LN3249">3249</td><td class="line"> <span class='keyword'>if</span> (removed) {</td></tr>
|
---|
3342 | <tr><td class="num" id="LN3250">3250</td><td class="line"> Delete();</td></tr>
|
---|
3343 | <tr><td class="num" id="LN3251">3251</td><td class="line"> </td></tr>
|
---|
3344 | <tr><td class="num" id="LN3252">3252</td><td class="line"> <span class='keyword'>if</span> (fColoredQuotes) {</td></tr>
|
---|
3345 | <tr><td class="num" id="LN3253">3253</td><td class="line"> <span class='keyword'>const</span> BFont *font = Font();</td></tr>
|
---|
3346 | <tr><td class="num" id="LN3254">3254</td><td class="line"> TextRunArray style(length / 8 + 8);</td></tr>
|
---|
3347 | <tr><td class="num" id="LN3255">3255</td><td class="line"> </td></tr>
|
---|
3348 | <tr><td class="num" id="LN3256">3256</td><td class="line"> FillInQuoteTextRuns(<span class='macro'>NULL<span class='expansion'>__null</span></span>, <span class='macro'>NULL<span class='expansion'>__null</span></span>, target, length, font,</td></tr>
|
---|
3349 | <tr><td class="num" id="LN3257">3257</td><td class="line"> &style.Array(), style.MaxEntries());</td></tr>
|
---|
3350 | <tr><td class="num" id="LN3258">3258</td><td class="line"> Insert(target, length, &style.Array());</td></tr>
|
---|
3351 | <tr><td class="num" id="LN3259">3259</td><td class="line"> } <span class='keyword'>else</span></td></tr>
|
---|
3352 | <tr><td class="num" id="LN3260">3260</td><td class="line"> Insert(target, length);</td></tr>
|
---|
3353 | <tr><td class="num" id="LN3261">3261</td><td class="line"> </td></tr>
|
---|
3354 | <tr><td class="num" id="LN3262">3262</td><td class="line"> <span class='comment'>// redo old selection</span></td></tr>
|
---|
3355 | <tr><td class="num" id="LN3263">3263</td><td class="line"> <span class='keyword'>bool</span> noSelection = start == finish;</td></tr>
|
---|
3356 | <tr><td class="num" id="LN3264">3264</td><td class="line"> </td></tr>
|
---|
3357 | <tr><td class="num" id="LN3265">3265</td><td class="line"> <span class='keyword'>if</span> (start > lineStart + quoteLength)</td></tr>
|
---|
3358 | <tr><td class="num" id="LN3266">3266</td><td class="line"> start -= quoteLength;</td></tr>
|
---|
3359 | <tr><td class="num" id="LN3267">3267</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
3360 | <tr><td class="num" id="LN3268">3268</td><td class="line"> start = lineStart;</td></tr>
|
---|
3361 | <tr><td class="num" id="LN3269">3269</td><td class="line"> </td></tr>
|
---|
3362 | <tr><td class="num" id="LN3270">3270</td><td class="line"> <span class='keyword'>if</span> (noSelection)</td></tr>
|
---|
3363 | <tr><td class="num" id="LN3271">3271</td><td class="line"> finish = start;</td></tr>
|
---|
3364 | <tr><td class="num" id="LN3272">3272</td><td class="line"> <span class='keyword'>else</span></td></tr>
|
---|
3365 | <tr><td class="num" id="LN3273">3273</td><td class="line"> finish -= removed;</td></tr>
|
---|
3366 | <tr><td class="num" id="LN3274">3274</td><td class="line"> }</td></tr>
|
---|
3367 | <tr><td class="num" id="LN3275">3275</td><td class="line"> </td></tr>
|
---|
3368 | <tr><td class="num" id="LN3276">3276</td><td class="line"> free(target);</td></tr>
|
---|
3369 | <tr><td class="num" id="LN3277">3277</td><td class="line"> </td></tr>
|
---|
3370 | <tr><td class="num" id="LN3278">3278</td><td class="line"> Select(start, finish);</td></tr>
|
---|
3371 | <tr><td class="num" id="LN3279">3279</td><td class="line"> ScrollTo(rect.LeftTop());</td></tr>
|
---|
3372 | <tr><td class="num" id="LN3280">3280</td><td class="line">}</td></tr>
|
---|
3373 | <tr><td class="num" id="LN3281">3281</td><td class="line"> </td></tr>
|
---|
3374 | <tr><td class="num" id="LN3282">3282</td><td class="line"> </td></tr>
|
---|
3375 | <tr><td class="num" id="LN3283">3283</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
3376 | <tr><td class="num" id="LN3284">3284</td><td class="line">TTextView::Undo(BClipboard *<span class='comment'>/*clipboard*/</span>)</td></tr>
|
---|
3377 | <tr><td class="num" id="LN3285">3285</td><td class="line">{</td></tr>
|
---|
3378 | <tr><td class="num" id="LN3286">3286</td><td class="line"> <span class='keyword'>if</span> (fInputMethodUndoState.active)</td></tr>
|
---|
3379 | <tr><td class="num" id="LN3287">3287</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
3380 | <tr><td class="num" id="LN3288">3288</td><td class="line"> </td></tr>
|
---|
3381 | <tr><td class="num" id="LN3289">3289</td><td class="line"> int32 length, offset, cursorPos;</td></tr>
|
---|
3382 | <tr><td class="num" id="LN3290">3290</td><td class="line"> undo_type history;</td></tr>
|
---|
3383 | <tr><td class="num" id="LN3291">3291</td><td class="line"> <span class='keyword'>char</span> *text;</td></tr>
|
---|
3384 | <tr><td class="num" id="LN3292">3292</td><td class="line"> status_t status;</td></tr>
|
---|
3385 | <tr><td class="num" id="LN3293">3293</td><td class="line"> </td></tr>
|
---|
3386 | <tr><td class="num" id="LN3294">3294</td><td class="line"> status = fUndoBuffer.Undo(&text, &length, &offset, &history, &cursorPos);</td></tr>
|
---|
3387 | <tr><td class="num" id="LN3295">3295</td><td class="line"> <span class='keyword'>if</span> (status == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
3388 | <tr><td class="num" id="LN3296">3296</td><td class="line"> fUndoBuffer.Off();</td></tr>
|
---|
3389 | <tr><td class="num" id="LN3297">3297</td><td class="line"> </td></tr>
|
---|
3390 | <tr><td class="num" id="LN3298">3298</td><td class="line"> <span class='keyword'>switch</span> (history) {</td></tr>
|
---|
3391 | <tr><td class="num" id="LN3299">3299</td><td class="line"> <span class='keyword'>case</span> K_INSERTED:</td></tr>
|
---|
3392 | <tr><td class="num" id="LN3300">3300</td><td class="line"> BTextView::Delete(offset, offset + length);</td></tr>
|
---|
3393 | <tr><td class="num" id="LN3301">3301</td><td class="line"> Select(offset, offset);</td></tr>
|
---|
3394 | <tr><td class="num" id="LN3302">3302</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
3395 | <tr><td class="num" id="LN3303">3303</td><td class="line"> </td></tr>
|
---|
3396 | <tr><td class="num" id="LN3304">3304</td><td class="line"> <span class='keyword'>case</span> K_DELETED:</td></tr>
|
---|
3397 | <tr><td class="num" id="LN3305">3305</td><td class="line"> BTextView::Insert(offset, text, length);</td></tr>
|
---|
3398 | <tr><td class="num" id="LN3306">3306</td><td class="line"> Select(offset, offset + length);</td></tr>
|
---|
3399 | <tr><td class="num" id="LN3307">3307</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
3400 | <tr><td class="num" id="LN3308">3308</td><td class="line"> </td></tr>
|
---|
3401 | <tr><td class="num" id="LN3309">3309</td><td class="line"> <span class='keyword'>case</span> K_REPLACED:</td></tr>
|
---|
3402 | <tr><td class="num" id="LN3310">3310</td><td class="line"> BTextView::Delete(offset, offset + length);</td></tr>
|
---|
3403 | <tr><td class="num" id="LN3311">3311</td><td class="line"> status = fUndoBuffer.Undo(&text, &length, &offset, &history, &cursorPos);</td></tr>
|
---|
3404 | <tr><td class="num" id="LN3312">3312</td><td class="line"> <span class='keyword'>if</span> (status == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span> && history == K_DELETED) {</td></tr>
|
---|
3405 | <tr><td class="num" id="LN3313">3313</td><td class="line"> BTextView::Insert(offset, text, length);</td></tr>
|
---|
3406 | <tr><td class="num" id="LN3314">3314</td><td class="line"> Select(offset, offset + length);</td></tr>
|
---|
3407 | <tr><td class="num" id="LN3315">3315</td><td class="line"> } <span class='keyword'>else</span> {</td></tr>
|
---|
3408 | <tr><td class="num" id="LN3316">3316</td><td class="line"> ::beep();</td></tr>
|
---|
3409 | <tr><td class="num" id="LN3317">3317</td><td class="line"> BAlert* alert = <span class='keyword'>new</span> BAlert(<span class='string_literal'>""</span>,</td></tr>
|
---|
3410 | <tr><td class="num" id="LN3318">3318</td><td class="line"> <span class='macro'>B_TRANSLATE(<span class='string_literal'>"Inconsistency occurred in the undo/redo "<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Inconsistency occurred in the undo/redo "<br> "buffer."), "Mail")</span></span></span></td></tr>
|
---|
3411 | <tr><td class="num" id="LN3319">3319</td><td class="line"> <span class='string_literal'><span class='macro'>"buffer."</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Inconsistency occurred in the undo/redo "<br> "buffer."), "Mail")</span></span>, <span class='macro'>B_TRANSLATE(<span class='string_literal'>"OK"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("OK"<br>), "Mail")</span></span>);</td></tr>
|
---|
3412 | <tr><td class="num" id="LN3320">3320</td><td class="line"> alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);</td></tr>
|
---|
3413 | <tr><td class="num" id="LN3321">3321</td><td class="line"> alert->Go();</td></tr>
|
---|
3414 | <tr><td class="num" id="LN3322">3322</td><td class="line"> }</td></tr>
|
---|
3415 | <tr><td class="num" id="LN3323">3323</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
3416 | <tr><td class="num" id="LN3324">3324</td><td class="line"> }</td></tr>
|
---|
3417 | <tr><td class="num" id="LN3325">3325</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
3418 | <tr><td class="num" id="LN3326">3326</td><td class="line"> ContentChanged();</td></tr>
|
---|
3419 | <tr><td class="num" id="LN3327">3327</td><td class="line"> fUndoBuffer.On();</td></tr>
|
---|
3420 | <tr><td class="num" id="LN3328">3328</td><td class="line"> }</td></tr>
|
---|
3421 | <tr><td class="num" id="LN3329">3329</td><td class="line">}</td></tr>
|
---|
3422 | <tr><td class="num" id="LN3330">3330</td><td class="line"> </td></tr>
|
---|
3423 | <tr><td class="num" id="LN3331">3331</td><td class="line"> </td></tr>
|
---|
3424 | <tr><td class="num" id="LN3332">3332</td><td class="line"><span class='keyword'>void</span></td></tr>
|
---|
3425 | <tr><td class="num" id="LN3333">3333</td><td class="line">TTextView::Redo()</td></tr>
|
---|
3426 | <tr><td class="num" id="LN3334">3334</td><td class="line">{</td></tr>
|
---|
3427 | <tr><td class="num" id="LN3335">3335</td><td class="line"> <span class='keyword'>if</span> (fInputMethodUndoState.active)</td></tr>
|
---|
3428 | <tr><td class="num" id="LN3336">3336</td><td class="line"> <span class='keyword'>return</span>;</td></tr>
|
---|
3429 | <tr><td class="num" id="LN3337">3337</td><td class="line"> </td></tr>
|
---|
3430 | <tr><td class="num" id="LN3338">3338</td><td class="line"> int32 length, offset, cursorPos;</td></tr>
|
---|
3431 | <tr><td class="num" id="LN3339">3339</td><td class="line"> undo_type history;</td></tr>
|
---|
3432 | <tr><td class="num" id="LN3340">3340</td><td class="line"> <span class='keyword'>char</span> *text;</td></tr>
|
---|
3433 | <tr><td class="num" id="LN3341">3341</td><td class="line"> status_t status;</td></tr>
|
---|
3434 | <tr><td class="num" id="LN3342">3342</td><td class="line"> <span class='keyword'>bool</span> replaced;</td></tr>
|
---|
3435 | <tr><td class="num" id="LN3343">3343</td><td class="line"> </td></tr>
|
---|
3436 | <tr><td class="num" id="LN3344">3344</td><td class="line"> status = fUndoBuffer.Redo(&text, &length, &offset, &history, &cursorPos, &replaced);</td></tr>
|
---|
3437 | <tr><td class="num" id="LN3345">3345</td><td class="line"> <span class='keyword'>if</span> (status == <span class='macro'>B_OK<span class='expansion'>((int)0)</span></span>) {</td></tr>
|
---|
3438 | <tr><td class="num" id="LN3346">3346</td><td class="line"> fUndoBuffer.Off();</td></tr>
|
---|
3439 | <tr><td class="num" id="LN3347">3347</td><td class="line"> </td></tr>
|
---|
3440 | <tr><td class="num" id="LN3348">3348</td><td class="line"> <span class='keyword'>switch</span> (history) {</td></tr>
|
---|
3441 | <tr><td class="num" id="LN3349">3349</td><td class="line"> <span class='keyword'>case</span> K_INSERTED:</td></tr>
|
---|
3442 | <tr><td class="num" id="LN3350">3350</td><td class="line"> BTextView::Insert(offset, text, length);</td></tr>
|
---|
3443 | <tr><td class="num" id="LN3351">3351</td><td class="line"> Select(offset, offset + length);</td></tr>
|
---|
3444 | <tr><td class="num" id="LN3352">3352</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
3445 | <tr><td class="num" id="LN3353">3353</td><td class="line"> </td></tr>
|
---|
3446 | <tr><td class="num" id="LN3354">3354</td><td class="line"> <span class='keyword'>case</span> K_DELETED:</td></tr>
|
---|
3447 | <tr><td class="num" id="LN3355">3355</td><td class="line"> BTextView::Delete(offset, offset + length);</td></tr>
|
---|
3448 | <tr><td class="num" id="LN3356">3356</td><td class="line"> <span class='keyword'>if</span> (replaced) {</td></tr>
|
---|
3449 | <tr><td class="num" id="LN3357">3357</td><td class="line"> fUndoBuffer.Redo(&text, &length, &offset, &history, &cursorPos, &replaced);</td></tr>
|
---|
3450 | <tr><td class="num" id="LN3358">3358</td><td class="line"> BTextView::Insert(offset, text, length);</td></tr>
|
---|
3451 | <tr><td class="num" id="LN3359">3359</td><td class="line"> }</td></tr>
|
---|
3452 | <tr><td class="num" id="LN3360">3360</td><td class="line"> Select(offset, offset + length);</td></tr>
|
---|
3453 | <tr><td class="num" id="LN3361">3361</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
3454 | <tr><td class="num" id="LN3362">3362</td><td class="line"> </td></tr>
|
---|
3455 | <tr><td class="num" id="LN3363">3363</td><td class="line"> <span class='keyword'>case</span> K_REPLACED:</td></tr>
|
---|
3456 | <tr><td class="num" id="LN3364">3364</td><td class="line"> ::beep();</td></tr>
|
---|
3457 | <tr><td class="num" id="LN3365">3365</td><td class="line"> BAlert* alert = <span class='keyword'>new</span> BAlert(<span class='string_literal'>""</span>,</td></tr>
|
---|
3458 | <tr><td class="num" id="LN3366">3366</td><td class="line"> <span class='macro'>B_TRANSLATE(<span class='string_literal'>"Inconsistency occurred in the undo/redo "<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Inconsistency occurred in the undo/redo "<br> "buffer."), "Mail")</span></span></span></td></tr>
|
---|
3459 | <tr><td class="num" id="LN3367">3367</td><td class="line"> <span class='string_literal'><span class='macro'>"buffer."</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("Inconsistency occurred in the undo/redo "<br> "buffer."), "Mail")</span></span>, <span class='macro'>B_TRANSLATE(<span class='string_literal'>"OK"</span>)<span class='expansion'>BLocaleRoster::Default()->GetCatalog()->GetString(("OK"<br>), "Mail")</span></span>);</td></tr>
|
---|
3460 | <tr><td class="num" id="LN3368">3368</td><td class="line"> alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);</td></tr>
|
---|
3461 | <tr><td class="num" id="LN3369">3369</td><td class="line"> alert->Go();</td></tr>
|
---|
3462 | <tr><td class="num" id="LN3370">3370</td><td class="line"> <span class='keyword'>break</span>;</td></tr>
|
---|
3463 | <tr><td class="num" id="LN3371">3371</td><td class="line"> }</td></tr>
|
---|
3464 | <tr><td class="num" id="LN3372">3372</td><td class="line"> ScrollToSelection();</td></tr>
|
---|
3465 | <tr><td class="num" id="LN3373">3373</td><td class="line"> ContentChanged();</td></tr>
|
---|
3466 | <tr><td class="num" id="LN3374">3374</td><td class="line"> fUndoBuffer.On();</td></tr>
|
---|
3467 | <tr><td class="num" id="LN3375">3375</td><td class="line"> }</td></tr>
|
---|
3468 | <tr><td class="num" id="LN3376">3376</td><td class="line">}</td></tr>
|
---|
3469 | <tr><td class="num" id="LN3377">3377</td><td class="line"> </td></tr>
|
---|
3470 | </table></body></html>
|
---|