~ubuntu-branches/ubuntu/quantal/texmacs/quantal

« back to all changes in this revision

Viewing changes to src/Data/Tree/tree_cursor.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Atsuhito KOHDA, Kamaraju Kusumanchi, kohda
  • Date: 2009-04-26 19:35:14 UTC
  • mfrom: (1.1.10 upstream) (4.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090426193514-9yo3oggdslgdls4b
Tags: 1:1.0.7.2-1
[Kamaraju Kusumanchi <kamaraju@gmail.com>]
* New upstream release
* texmacs crashes if /usr/share/texmacs/TeXmacs/misc/pixmaps/unknown.ps
  is not present. Do not remove it. (Closes: #484073, #497021)
* update patches 03_mupad.dpatch, 04_axiom.dpatch, 11-desktop-file.dpatch
* fix the mime problem in gnome. Thanks to Andrea Gamba for the fix.
[kohda]
* Refined a fix for the mime problem in gnome a bit.
* Try to fix /bin/sh problem (debian/fixsh) but it is not complete fix yet.
* Try to fix hard coded settings for ipa fonts(patches/09_ipa.dpatch), 
  especially for Debian where no ipa fonts exist yet.
* Fixed obsolete Build-Depends: changed libltdl3-dev to 
  libltdl-dev | libltdl7-dev (the latter for Ubuntu?)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
* DESCRIPTION: abstract cursor handling
5
5
* COPYRIGHT  : (C) 1999  Joris van der Hoeven
6
6
*******************************************************************************
7
 
* This software falls under the GNU general public license and comes WITHOUT
8
 
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
9
 
* If you don't have this file, write to the Free Software Foundation, Inc.,
10
 
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
7
* This software falls under the GNU general public license version 3 or later.
 
8
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
 
9
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
11
10
******************************************************************************/
12
11
 
13
12
#include "tree_cursor.hpp"
121
120
    int i, k= p->item, n= N(t);
122
121
    if (p == 1) k= max (0, n-1);
123
122
    for (i=0; i<n; i++) {
124
 
      int j= (i&1 == 0? (k+(i>>1) % n): (k+n-((i+1)>>1) % n));
 
123
      int j= ((i&1) == 0? (k+(i>>1) % n): (k+n-((i+1)>>1) % n));
125
124
      if (the_drd->is_accessible_child (t, j)) {
126
125
        // FIXME: certain tags modify source accessability props
127
126
        // FIXME: cells with non-trivial span may lead to unaccessability
134
133
      return path ();
135
134
    }
136
135
  }
 
136
  return path ();
137
137
}
138
138
 
139
139
bool
162
162
valid_cursor (tree t, path p, bool start_flag) {
163
163
  if ((!is_nil (p)) && (!is_atom (p)) && ((p->item < 0) || (p->item >= arity (t)))) {
164
164
    cerr << "TeXmacs] testing valid cursor " << p << " in " << t << "\n";
165
 
    fatal_error ("bad path", "valid_cursor", "tree_cursor.cpp");
 
165
    FAILED ("bad path");
166
166
  }
167
167
 
168
168
  if (is_nil (p)) return false;
188
188
  // cout << "Precorrect " << p << " in " << t << "\n";
189
189
  if ((!is_nil (p)) && (!is_atom (p)) && ((p->item < 0) || (p->item >= arity (t)))) {
190
190
    cerr << "TeXmacs] precorrecting " << p << " in " << t << "\n";
191
 
    fatal_error ("bad path", "pre_correct", "tree_cursor.cpp");
 
191
    FAILED ("bad path");
192
192
  }
193
193
 
194
194
  if (is_nil (p)) return pre_correct (t, path(0));
228
228
 
229
229
static bool
230
230
left_most (tree t, path p) {
231
 
  if (is_nil (p))
232
 
    fatal_error ("invalid nil path", "left_most", "tree_cursor.cpp");
 
231
  if (is_nil (p)) FAILED ("invalid nil path");
233
232
  if ((!is_atom (p)) && ((p->item < 0) || (p->item >= arity (t)))) {
234
233
    cerr << "TeXmacs] left most " << p << " in " << t << "\n";
235
 
    fatal_error ("bad path", "left_most", "tree_cursor.cpp");
 
234
    FAILED ("bad path");
236
235
  }
237
236
 
238
237
  int i=p->item;
243
242
 
244
243
static path
245
244
left_correct (tree t, path p) {
246
 
  if (is_nil (p))
247
 
    fatal_error ("invalid nil path", "left_correct", "tree_cursor.cpp");
 
245
  if (is_nil (p)) FAILED ("invalid nil path");
248
246
  if ((!is_atom (p)) && ((p->item < 0) || (p->item >= arity (t)))) {
249
247
    cerr << "TeXmacs] left correcting " << p << " in " << t << "\n";
250
 
    fatal_error ("bad path", "left_correct", "tree_cursor.cpp");
 
248
    FAILED ("bad path");
251
249
  }
252
250
 
253
251
  int i=p->item;
260
258
 
261
259
static bool
262
260
right_most (tree t, path p) {
263
 
  if (is_nil (p))
264
 
    fatal_error ("invalid nil path", "right_most", "tree_cursor.cpp");
 
261
  if (is_nil (p)) FAILED ("invalid nil path");
265
262
  if ((!is_atom (p)) && ((p->item < 0) || (p->item >= arity (t)))) {
266
263
    cerr << "TeXmacs] right most " << p << " in " << t << "\n";
267
 
    fatal_error ("bad path", "right_most", "tree_cursor.cpp");
 
264
    FAILED ("bad path");
268
265
  }
269
266
 
270
267
  int i=p->item;
275
272
 
276
273
static path
277
274
right_correct (tree t, path p) {
278
 
  if (is_nil (p))
279
 
    fatal_error ("invalid nil path", "right_correct", "tree_cursor.cpp");
 
275
  if (is_nil (p)) FAILED ("invalid nil path");
280
276
  if ((!is_atom (p)) && ((p->item < 0) || (p->item >= arity (t)))) {
281
277
    cerr << "TeXmacs] right correcting " << p << " in " << t << "\n";
282
 
    fatal_error ("bad path", "right_correct", "tree_cursor.cpp");
 
278
    FAILED ("bad path");
283
279
  }
284
280
 
285
281
  int i=p->item;
331
327
  path q= path_up (p);
332
328
  path r= up_correct (t, q);
333
329
  if (q != r) {
334
 
    if (is_nil (r)) fatal_error ("Unexpected situation", "super_correct");
335
 
    else if (is_atomic (subtree (t, r))) p= path_up (r) * 0;
 
330
    ASSERT (!is_nil (r), "unexpected situation");
 
331
    if (is_atomic (subtree (t, r))) p= path_up (r) * 0;
336
332
    else p= r * 0;
337
333
  }
338
334
  return correct_cursor (t, p);