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

« back to all changes in this revision

Viewing changes to src/Data/Observers/ip_observer.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:
7
7
* An inverse path observer maintains the inverse path of the position
8
8
* of the corresponding tree with respect to the global meta-tree.
9
9
*******************************************************************************
10
 
* This software falls under the GNU general public license and comes WITHOUT
11
 
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
12
 
* If you don't have this file, write to the Free Software Foundation, Inc.,
13
 
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
10
* This software falls under the GNU general public license version 3 or later.
 
11
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
 
12
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
14
13
******************************************************************************/
15
14
 
16
 
#include "tree.hpp"
17
 
#include "path.hpp"
 
15
#include "modification.hpp"
18
16
 
19
17
#define DETACHED (-5)
 
18
extern tree the_et;
20
19
 
21
20
/******************************************************************************
22
21
* Definition of the ip_observer_rep class
26
25
  path ip;
27
26
public:
28
27
  ip_observer_rep (path ip2): ip (ip2) {}
 
28
  int get_type () { return OBSERVER_IP; }
29
29
  ostream& print (ostream& out) { return out << " " << ip; }
30
30
 
 
31
  void announce (tree& ref, modification mod);
 
32
  void done     (tree& ref, modification mod);
 
33
 
31
34
  void notify_assign      (tree& ref, tree t);
32
35
  void notify_insert      (tree& ref, int pos, int nr);
33
36
  void notify_remove      (tree& ref, int pos, int nr);
45
48
};
46
49
 
47
50
/******************************************************************************
 
51
* Call back routines for announcements
 
52
******************************************************************************/
 
53
 
 
54
bool
 
55
has_parent (path ip) {
 
56
  return !is_nil (ip) && last_item (ip) != DETACHED;
 
57
}
 
58
 
 
59
void
 
60
ip_observer_rep::announce (tree& ref, modification mod) {
 
61
  //cout << "Announce " << ip << ", " << p << "\n";
 
62
  if (!has_parent (ip)) return;
 
63
  tree& parent (subtree (the_et, reverse (ip->next)));
 
64
  parent->obs->announce (parent, ip->item * mod);
 
65
}
 
66
 
 
67
void
 
68
ip_observer_rep::done (tree& ref, modification mod) {
 
69
  //cout << "Done " << ip << ", " << p << "\n";
 
70
  if (!has_parent (ip)) return;
 
71
  tree& parent (subtree (the_et, reverse (ip->next)));
 
72
  parent->obs->done (parent, ip->item * mod);
 
73
}
 
74
 
 
75
/******************************************************************************
48
76
* Call back routines for modifications
49
77
******************************************************************************/
50
78
 
154
182
bool
155
183
ip_observer_rep::set_ip (path ip2) {
156
184
  if (is_nil (ip) || is_nil (ip2))
157
 
    fatal_error ("cannot alter global root", "ip_observer_rep::set_ip");
 
185
    FAILED ("cannot alter global root");
158
186
  ip->item= ip2->item;
159
187
  ip->next= ip2->next;
160
188
  return true;
193
221
  return ip;
194
222
}
195
223
 
 
224
bool
 
225
ip_attached (path ip) {
 
226
  return is_nil (ip) || last_item (ip) != DETACHED;
 
227
}
 
228
 
196
229
/******************************************************************************
197
230
* Setting and getting inverse paths
198
231
******************************************************************************/
199
232
 
200
233
observer
201
234
ip_observer (path ip) {
202
 
  return new ip_observer_rep (ip);
 
235
  return tm_new<ip_observer_rep> (ip);
203
236
}