]> git.lyx.org Git - features.git/blob - development/Win32/lyx-devel.patch
d2f76edfde1fc064dbfe2ed293cbeb1e4ab30e02
[features.git] / development / Win32 / lyx-devel.patch
1 Index: src/BufferView.C
2 ===================================================================
3 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
4 retrieving revision 1.256
5 diff -u -r1.256 BufferView.C
6 --- src/BufferView.C    30 Nov 2004 01:59:29 -0000      1.256
7 +++ src/BufferView.C    31 Jan 2005 11:19:24 -0000
8 @@ -290,10 +290,17 @@
9         screen().hideCursor();
10  }
11  
12 -
13 -LyXText * BufferView::getLyXText() const
14 +LyXText * BufferView::getLyXText()
15  {
16         LyXText * text = cursor().innerText();
17 +       BOOST_ASSERT(text);
18 +       return text;
19 +}
20 +
21 +
22 +LyXText const * BufferView::getLyXText() const
23 +{
24 +       LyXText const * text = cursor().innerText();
25         BOOST_ASSERT(text);
26         return text;
27  }
28 Index: src/BufferView.h
29 ===================================================================
30 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v
31 retrieving revision 1.183
32 diff -u -r1.183 BufferView.h
33 --- src/BufferView.h    19 Jan 2005 15:03:26 -0000      1.183
34 +++ src/BufferView.h    31 Jan 2005 11:15:54 -0000
35 @@ -102,7 +102,10 @@
36         Change const getCurrentChange();
37  
38         /// return the lyxtext we are using
39 -       LyXText * getLyXText() const;
40 +       LyXText * getLyXText();
41 +
42 +       /// return the lyxtext we are using
43 +       LyXText const * getLyXText() const;
44  
45         /// simple replacing. Use the font of the first selected character
46         void replaceSelectionWithString(std::string const & str);
47 Index: src/BufferView_pimpl.C
48 ===================================================================
49 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
50 retrieving revision 1.569
51 diff -u -r1.569 BufferView_pimpl.C
52 --- src/BufferView_pimpl.C      27 Jan 2005 21:05:30 -0000      1.569
53 +++ src/BufferView_pimpl.C      31 Jan 2005 12:25:38 -0000
54 @@ -445,7 +445,6 @@
55         t.redoParagraph(anchor_ref_);
56         int const h = t.getPar(anchor_ref_).height();
57         offset_ref_ = int((bar * t.paragraphs().size() - anchor_ref_) * h);
58 -       lyxerr << "scrolling: " << value << std::endl;
59         update();
60  
61         if (!lyxrc.cursor_follows_scrollbar)
62 @@ -612,6 +611,7 @@
63  
64                 CoordCache backup;
65                 std::swap(theCoords, backup);
66 +               theCoords.startUpdating();
67                 //
68                 ViewMetricsInfo vi = metrics();
69  
70 @@ -622,8 +622,11 @@
71                 if (forceupdate) {
72                         // second drawing step
73                         screen().redraw(*bv_, vi);
74 -               } else
75 +                       theCoords.doneUpdating();
76 +               } else {
77 +                       // Abort updating of the coord cache - just restore the old one
78                         std::swap(theCoords, backup);
79 +               }
80         } else
81                 screen().greyOut();
82  
83 @@ -743,7 +746,7 @@
84  
85  void BufferView::Pimpl::center()
86  {
87 -       CursorSlice const & bot = bv_->cursor().bottom();
88 +       CursorSlice & bot = bv_->cursor().bottom();
89         lyx::pit_type const pit = bot.pit();
90         bot.text()->redoParagraph(pit);
91         Paragraph const & par = bot.text()->paragraphs()[pit];
92 @@ -1247,7 +1250,7 @@
93         int y = y1;
94         for (lyx::pit_type pit = pit1; pit <= pit2; ++pit) {
95                 y += text->getPar(pit).ascent();
96 -               theCoords.pars_[text][pit] = Point(0, y);
97 +               theCoords.parPos()[text][pit] = Point(0, y);
98                 y += text->getPar(pit).descent();
99         }
100  
101 Index: src/DepTable.C
102 ===================================================================
103 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/DepTable.C,v
104 retrieving revision 1.41
105 diff -u -r1.41 DepTable.C
106 --- src/DepTable.C      13 Oct 2003 01:01:33 -0000      1.41
107 +++ src/DepTable.C      19 Jan 2005 10:35:54 -0000
108 @@ -26,7 +26,9 @@
109  #include <fstream>
110  
111  #ifndef CXX_GLOBAL_CSTD
112 +# ifndef _WIN32
113  using std::time;
114 +# endif
115  #endif
116  
117  using lyx::support::ltrim;
118 Index: src/RowList_fwd.h
119 ===================================================================
120 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/RowList_fwd.h,v
121 retrieving revision 1.5
122 diff -u -r1.5 RowList_fwd.h
123 --- src/RowList_fwd.h   16 Nov 2004 20:41:37 -0000      1.5
124 +++ src/RowList_fwd.h   27 Jan 2005 10:58:08 -0000
125 @@ -16,6 +16,11 @@
126  
127  #include <vector>
128  
129 +/**
130 + * Each paragraph is broken up into a number of rows on the screen.
131 + * This is a list of such on-screen rows, ordered from the top row
132 + * downwards.
133 + */
134  typedef std::vector<Row> RowList;
135  
136  #endif
137 Index: src/buffer.C
138 ===================================================================
139 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
140 retrieving revision 1.609
141 diff -u -r1.609 buffer.C
142 --- src/buffer.C        31 Jan 2005 10:42:17 -0000      1.609
143 +++ src/buffer.C        31 Jan 2005 11:08:10 -0000
144 @@ -77,7 +77,11 @@
145  #include <boost/bind.hpp>
146  #include <boost/filesystem/operations.hpp>
147  
148 -#include <utime.h>
149 +#ifdef _WIN32
150 +# include <windows.h>
151 +#else
152 +# include <utime.h>
153 +#endif
154  
155  #include <iomanip>
156  #include <stack>
157 Index: src/buffer.h
158 ===================================================================
159 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.h,v
160 retrieving revision 1.189
161 diff -u -r1.189 buffer.h
162 --- src/buffer.h        17 Dec 2004 16:27:07 -0000      1.189
163 +++ src/buffer.h        31 Jan 2005 09:58:01 -0000
164 @@ -49,10 +49,15 @@
165  
166  
167  /** The buffer object.
168 -  This is the buffer object. It contains all the informations about
169 -  a document loaded into LyX. I am not sure if the class is complete or
170 -  minimal, probably not.
171 -  \author Lars Gullik Bjønnes
172 + * This is the buffer object. It contains all the informations about
173 + * a document loaded into LyX.
174 + * The buffer object owns the LyXText (wrapped in an InsetText), which 
175 + * contains the individual paragraphs of the document.
176 + *
177 + * 
178 + * I am not sure if the class is complete or
179 + * minimal, probably not.
180 + * \author Lars Gullik Bjønnes
181    */
182  class Buffer {
183  public:
184 Index: src/bufferview_funcs.C
185 ===================================================================
186 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.C,v
187 retrieving revision 1.146
188 diff -u -r1.146 bufferview_funcs.C
189 --- src/bufferview_funcs.C      6 Jan 2005 16:39:21 -0000       1.146
190 +++ src/bufferview_funcs.C      31 Jan 2005 11:54:25 -0000
191 @@ -180,8 +180,8 @@
192  Point getPos(DocIterator const & dit)
193  {
194         CursorSlice const & bot = dit.bottom();
195 -       CoordCache::InnerParPosCache & cache = theCoords.pars_[bot.text()];
196 -       CoordCache::InnerParPosCache::iterator it = cache.find(bot.pit());
197 +       CoordCache::InnerParPosCache const & cache = theCoords.getParPos().find(bot.text())->second;
198 +       CoordCache::InnerParPosCache::const_iterator it = cache.find(bot.pit());
199         if (it == cache.end()) {
200                 //lyxerr << "cursor out of view" << std::endl;
201                 return Point(-1,-1);
202 @@ -195,7 +195,7 @@
203  // this could be used elsewhere as well?
204  CurStatus status(BufferView const * bv, DocIterator const & dit)
205  {
206 -       CoordCache::InnerParPosCache & cache = theCoords.pars_[dit.bottom().text()];
207 +       CoordCache::InnerParPosCache const & cache = theCoords.getParPos().find(dit.bottom().text())->second;
208  
209         if (cache.find(dit.bottom().pit()) != cache.end())
210                 return CUR_INSIDE;
211 Index: src/coordcache.C
212 ===================================================================
213 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/coordcache.C,v
214 retrieving revision 1.5
215 diff -u -r1.5 coordcache.C
216 --- src/coordcache.C    12 Jan 2005 10:30:44 -0000      1.5
217 +++ src/coordcache.C    31 Jan 2005 10:20:07 -0000
218 @@ -21,20 +21,24 @@
219  }
220  
221  
222 -void lyxaborter(int x, int y)
223 -{
224 -       lyxerr << "abort on x: " << x << " y: " << y << std::endl;
225 -       BOOST_ASSERT(false);
226 -}
227 -
228 -
229  void CoordCache::clear()
230  {
231 +       BOOST_ASSERT(updating);
232         arrays_.clear();
233         insets_.clear();
234         pars_.clear();
235  }
236  
237 +void CoordCache::startUpdating() {
238 +       BOOST_ASSERT(!updating);
239 +       updating = true;
240 +}
241 +
242 +
243 +void CoordCache::doneUpdating() {
244 +       BOOST_ASSERT(updating);
245 +       updating = false;
246 +}
247  
248  Point CoordCache::get(LyXText const * text, lyx::pit_type pit)
249  {
250 Index: src/coordcache.h
251 ===================================================================
252 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/coordcache.h,v
253 retrieving revision 1.6
254 diff -u -r1.6 coordcache.h
255 --- src/coordcache.h    19 Jan 2005 15:03:29 -0000      1.6
256 +++ src/coordcache.h    31 Jan 2005 12:23:49 -0000
257 @@ -12,13 +12,7 @@
258  
259  #include <map>
260  
261 -
262 -// All positions cached in this cache are only valid between subsequent
263 -// updated. (x,y) == (0,0) is the upper left screen corner, x increases
264 -// to the right, y increases downwords.
265 -
266  void lyxbreaker(void const * data, const char * hint, int size);
267 -void lyxaborter(int x, int y);
268  
269  class Point {
270  public:
271 @@ -92,21 +86,55 @@
272         cache_type data_;
273  };
274  
275 -
276 +/**
277 + * A global cache that allows us to come from a paragraph in a document
278 + * to a position point on the screen.
279 + * All points cached in this cache are only valid between subsequent
280 + * updated. (x,y) == (0,0) is the upper left screen corner, x increases
281 + * to the right, y increases downwords.
282 + * The cache is built in BufferView::Pimpl::metrics which is called
283 + * from BufferView::Pimpl::update. The individual points are added
284 + * while we paint them. See for instance paintPar in RowPainter.C.
285 + */
286  class CoordCache {
287  public:
288 +       CoordCache() : updating(false) { }
289 +       /// In order to find bugs, we record when we start updating the cache
290 +       void startUpdating();
291 +       /// When we are done, we record that to help find bugs
292 +       void doneUpdating();
293 +
294         void clear();
295         Point get(LyXText const *, lyx::pit_type);
296  
297 +       /// A map from paragraph index number to screen point
298 +       typedef std::map<lyx::pit_type, Point> InnerParPosCache;
299 +       /// A map from a LyXText to the map of paragraphs to screen points
300 +       typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
301 +
302 +       /// A map from MathArray to position on the screen
303 +       CoordCacheBase<MathArray> & arrays() { BOOST_ASSERT(updating); return arrays_; }
304 +       CoordCacheBase<MathArray> const & getArrays() const { return arrays_; }
305 +       /// A map from insets to positions on the screen
306 +       CoordCacheBase<InsetBase> & insets() { BOOST_ASSERT(updating); return insets_; }
307 +       CoordCacheBase<InsetBase> const & getInsets() const { return insets_; }
308 +       /// A map from (LyXText, paragraph) pair to screen positions
309 +       ParPosCache & parPos() { BOOST_ASSERT(updating); return pars_; }
310 +       ParPosCache const & getParPos() const { return pars_; }
311 +private:
312         CoordCacheBase<MathArray> arrays_;
313         
314         // all insets
315         CoordCacheBase<InsetBase> insets_;
316  
317         // paragraph grouped by owning text
318 -       typedef std::map<lyx::pit_type, Point> InnerParPosCache;
319 -       typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
320         ParPosCache pars_;
321 +
322 +       /**
323 +        * Debugging flag only: Set to true while the cache is being built.
324 +        * No changes to the structure are allowed unless we are updating.
325 +        */
326 +       bool updating;
327  };
328  
329  extern CoordCache theCoords;
330 Index: src/cursor.C
331 ===================================================================
332 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
333 retrieving revision 1.119
334 diff -u -r1.119 cursor.C
335 --- src/cursor.C        18 Jan 2005 14:15:55 -0000      1.119
336 +++ src/cursor.C        31 Jan 2005 11:08:09 -0000
337 @@ -58,7 +58,9 @@
338  using std::vector;
339  using std::endl;
340  #ifndef CXX_GLOBAL_CSTD
341 +# ifndef _WIN32
342  using std::isalpha;
343 +# endif
344  #endif
345  using std::min;
346  using std::swap;
347 @@ -1086,7 +1088,7 @@
348                 if (operator[](s).text())
349                         break;
350         CursorSlice const & sl = operator[](s);
351 -       LyXText & text = *sl.text();
352 +       LyXText const & text = *sl.text();
353         LyXFont font = text.getPar(sl.pit()).getFont(
354                 bv().buffer()->params(), sl.pos(), outerFont(sl.pit(), text.paragraphs()));
355         return font.language()->encoding();
356 @@ -1127,7 +1129,7 @@
357                 if (operator[](s).text())
358                         break;
359         CursorSlice const & sl = operator[](s);
360 -       LyXText & text = *sl.text();
361 +       LyXText const & text = *sl.text();
362         LyXFont font = text.getPar(sl.pit()).getFont(
363                 bv().buffer()->params(),
364                 sl.pos(),
365 Index: src/cursor_slice.C
366 ===================================================================
367 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor_slice.C,v
368 retrieving revision 1.26
369 diff -u -r1.26 cursor_slice.C
370 --- src/cursor_slice.C  24 Nov 2004 21:53:38 -0000      1.26
371 +++ src/cursor_slice.C  31 Jan 2005 11:01:13 -0000
372 @@ -104,7 +104,13 @@
373  }
374  
375  
376 -LyXText * CursorSlice::text() const
377 +LyXText * CursorSlice::text()
378 +{
379 +       BOOST_ASSERT(inset_);
380 +       return inset_->getText(idx_);
381 +}
382 +
383 +LyXText const * CursorSlice::text() const
384  {
385         BOOST_ASSERT(inset_);
386         return inset_->getText(idx_);
387 Index: src/cursor_slice.h
388 ===================================================================
389 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor_slice.h,v
390 retrieving revision 1.20
391 diff -u -r1.20 cursor_slice.h
392 --- src/cursor_slice.h  30 Nov 2004 01:59:33 -0000      1.20
393 +++ src/cursor_slice.h  31 Jan 2005 11:01:13 -0000
394 @@ -97,7 +97,9 @@
395         /// see comment for the member
396         bool & boundary() { return boundary_; }
397         ///
398 -       LyXText * text() const;
399 +       LyXText * text();
400 +       ///
401 +       LyXText const * text() const;
402         ///
403         UpdatableInset * asUpdatableInset() const;
404         ///
405 Index: src/dociterator.C
406 ===================================================================
407 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.C,v
408 retrieving revision 1.21
409 diff -u -r1.21 dociterator.C
410 --- src/dociterator.C   30 Nov 2004 01:59:33 -0000      1.21
411 +++ src/dociterator.C   31 Jan 2005 11:11:59 -0000
412 @@ -123,7 +123,13 @@
413  }
414  
415  
416 -LyXText * DocIterator::text() const
417 +LyXText * DocIterator::text()
418 +{
419 +       BOOST_ASSERT(!empty());
420 +       return top().text();
421 +}
422 +
423 +LyXText const * DocIterator::text() const
424  {
425         BOOST_ASSERT(!empty());
426         return top().text();
427 @@ -146,12 +152,14 @@
428  
429  Row & DocIterator::textRow()
430  {
431 +       BOOST_ASSERT(!paragraph().rows().empty());
432         return paragraph().getRow(pos());
433  }
434  
435  
436  Row const & DocIterator::textRow() const
437  {
438 +       BOOST_ASSERT(!paragraph().rows().empty());
439         return paragraph().getRow(pos());
440  }
441  
442 @@ -233,7 +241,18 @@
443  }
444  
445  
446 -LyXText * DocIterator::innerText() const
447 +LyXText * DocIterator::innerText()
448 +{
449 +       BOOST_ASSERT(!empty());
450 +       // go up until first non-0 text is hit
451 +       // (innermost text is 0 in mathed)
452 +       for (int i = size() - 1; i >= 0; --i)
453 +               if (operator[](i).text())
454 +                       return operator[](i).text();
455 +       return 0;
456 +}
457 +
458 +LyXText const * DocIterator::innerText() const
459  {
460         BOOST_ASSERT(!empty());
461         // go up until first non-0 text is hit
462 Index: src/dociterator.h
463 ===================================================================
464 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.h,v
465 retrieving revision 1.14
466 diff -u -r1.14 dociterator.h
467 --- src/dociterator.h   30 Nov 2004 01:59:33 -0000      1.14
468 +++ src/dociterator.h   31 Jan 2005 11:11:59 -0000
469 @@ -151,11 +151,15 @@
470         /// the row in the paragraph we're in
471         Row const & textRow() const;
472         ///
473 -       LyXText * text() const;
474 +       LyXText * text();
475 +       ///
476 +       LyXText const * text() const;
477         ///
478         InsetBase * innerInsetOfType(int code) const;
479         ///
480 -       LyXText * innerText() const;
481 +       LyXText * innerText();
482 +       ///
483 +       LyXText const * innerText() const;
484  
485         //
486         // elementary moving
487 Index: src/ispell.C
488 ===================================================================
489 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ispell.C,v
490 retrieving revision 1.25
491 diff -u -r1.25 ispell.C
492 --- src/ispell.C        20 Jan 2005 16:17:36 -0000      1.25
493 +++ src/ispell.C        23 Jan 2005 12:09:37 -0000
494 @@ -24,11 +24,17 @@
495  
496  #include "support/forkedcall.h"
497  
498 +#ifdef _WIN32
499 +# include "support/os_win32.h"
500 +#endif
501 +
502  // HP-UX 11.x doesn't have this header
503  #ifdef HAVE_SYS_SELECT_H
504  #include <sys/select.h>
505  #endif
506 -#include <sys/time.h>
507 +#ifndef _WIN32
508 +# include <sys/time.h>
509 +#endif
510  
511  using boost::shared_ptr;
512  
513 @@ -88,6 +94,7 @@
514         }
515  
516         // child process
517 +#ifndef _WIN32
518         dup2(pipein[0], STDIN_FILENO);
519         dup2(pipeout[1], STDOUT_FILENO);
520         dup2(pipeerr[1], STDERR_FILENO);
521 @@ -180,6 +187,7 @@
522  
523         lyxerr << "LyX: Failed to start ispell!" << endl;
524         _exit(0);
525 +#endif
526  }
527  
528  
529 @@ -191,6 +199,7 @@
530  {
531         lyxerr[Debug::GUI] << "Created ispell" << endl;
532  
533 +#ifndef _WIN32
534         // static due to the setvbuf. Ugly.
535         static char o_buf[BUFSIZ];
536  
537 @@ -275,6 +284,7 @@
538         close(pipeerr[1]);
539         child_->kill();
540         child_.reset(0);
541 +#endif
542  }
543  
544  
545 @@ -295,18 +305,23 @@
546                 fclose(out);
547         }
548  
549 +#ifndef _WIN32
550         close(pipein[0]);
551         close(pipein[1]);
552         close(pipeout[0]);
553         close(pipeout[1]);
554         close(pipeerr[0]);
555         close(pipeerr[1]);
556 +#endif
557         delete [] str;
558  }
559  
560  
561  bool ISpell::select(bool & err_read)
562  {
563 +#ifdef _WIN32
564 +       return false;
565 +#else
566         fd_set infds;
567         struct timeval tv;
568         int retval = 0;
569 @@ -316,11 +331,15 @@
570         tv.tv_sec = 2;
571         tv.tv_usec = 0;
572  
573 +#ifdef HAVE_SELECT
574         retval = ::select(SELECT_TYPE_ARG1 (max(pipeout[0], pipeerr[0]) + 1),
575                         SELECT_TYPE_ARG234 (&infds),
576                         0,
577                         0,
578                         SELECT_TYPE_ARG5 (&tv));
579 +#else
580 +       retval = -1;
581 +#endif
582  
583         // error
584         if (retval <= 0)
585 @@ -335,6 +354,7 @@
586         fgets(buf, BUFSIZ, in);
587         err_read = false;
588         return false;
589 +#endif
590  }
591  
592  
593 Index: src/lyx_cb.C
594 ===================================================================
595 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v
596 retrieving revision 1.247
597 diff -u -r1.247 lyx_cb.C
598 --- src/lyx_cb.C        31 Jan 2005 10:42:18 -0000      1.247
599 +++ src/lyx_cb.C        31 Jan 2005 10:57:53 -0000
600 @@ -44,6 +44,10 @@
601  #include "support/path.h"
602  #include "support/systemcall.h"
603  
604 +#ifdef _WIN32
605 +# include "support/os_win32.h" // fork()
606 +#endif
607 +
608  #include <boost/shared_ptr.hpp>
609  #include <boost/filesystem/operations.hpp>
610  
611 Index: src/lyxlex_pimpl.h
612 ===================================================================
613 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlex_pimpl.h,v
614 retrieving revision 1.22
615 diff -u -r1.22 lyxlex_pimpl.h
616 --- src/lyxlex_pimpl.h  21 Jan 2005 08:39:13 -0000      1.22
617 +++ src/lyxlex_pimpl.h  25 Jan 2005 12:40:01 -0000
618 @@ -23,6 +23,7 @@
619  #include <istream>
620  #include <stack>
621  #include <vector>
622 +#include <fstream> // for std::filebuf
623  
624  ///
625  class LyXLex::Pimpl : boost::noncopyable {
626 Index: src/lyxrow.h
627 ===================================================================
628 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrow.h,v
629 retrieving revision 1.42
630 diff -u -r1.42 lyxrow.h
631 --- src/lyxrow.h        30 Nov 2004 01:59:34 -0000      1.42
632 +++ src/lyxrow.h        27 Jan 2005 10:55:12 -0000
633 @@ -17,7 +17,11 @@
634  
635  #include "support/types.h"
636  
637 -///
638 +/**
639 + * An on-screen row of text. A paragraph is broken into a 
640 + * RowList for display. Each Row contains position pointers
641 + * into the first and last character positions of that row.
642 + */
643  class Row {
644  public:
645         ///
646 Index: src/lyxserver.C
647 ===================================================================
648 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxserver.C,v
649 retrieving revision 1.59
650 diff -u -r1.59 lyxserver.C
651 --- src/lyxserver.C     20 Jan 2005 15:07:36 -0000      1.59
652 +++ src/lyxserver.C     21 Jan 2005 09:47:31 -0000
653 @@ -54,6 +54,10 @@
654  #include <sys/stat.h>
655  #include <fcntl.h>
656  
657 +#ifdef _WIN32
658 +# include "support/os_win32.h" // F_SETFL, O_NONBLOCK, fcntl
659 +#endif
660 +
661  #ifdef __EMX__
662  #include <cstdlib>
663  #include <io.h>
664 @@ -182,6 +186,8 @@
665         // Imported handles can be used both with OS/2 APIs and emx
666         // library functions.
667         fd = _imphandle(os2fd);
668 +#elif defined(_WIN32)
669 +
670  #else
671         if (::access(filename.c_str(), F_OK) == 0) {
672                 lyxerr << "LyXComm: Pipe " << filename << " already exists.\n"
673 @@ -236,10 +242,12 @@
674         }
675  #endif
676  
677 +#ifndef _WIN32
678         if (::close(fd) < 0) {
679                 lyxerr << "LyXComm: Could not close pipe " << filename
680                        << '\n' << strerror(errno) << endl;
681         }
682 +#endif
683  
684  // OS/2 pipes are deleted automatically
685  #ifndef __EMX__
686 @@ -275,7 +283,13 @@
687         errno = 0;
688         int status;
689         // the single = is intended here.
690 -       while ((status = ::read(infd, charbuf, charbuf_size - 1))) {
691 +       while ((status = 
692 +#ifndef _WIN32
693 +               ::read(infd, charbuf, charbuf_size - 1)
694 +#else
695 +               -1
696 +#endif
697 +               )) {
698  
699                 if (status > 0) {
700                         charbuf[status] = '\0'; // turn it into a c string
701 @@ -332,6 +346,9 @@
702  
703         if (pipename.empty()) return;
704  
705 +#ifdef _WIN32
706 +       return;
707 +#else
708         if (!ready) {
709                 lyxerr << "LyXComm: Pipes are closed. Could not send "
710                        << msg << endl;
711 @@ -342,6 +359,7 @@
712                 closeConnection();
713                 openConnection();
714         }
715 +#endif
716  #ifdef __EMX__
717         APIRET rc;
718         int errnum;
719 Index: src/lyxsocket.C
720 ===================================================================
721 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxsocket.C,v
722 retrieving revision 1.6
723 diff -u -r1.6 lyxsocket.C
724 --- src/lyxsocket.C     23 Jul 2004 19:01:48 -0000      1.6
725 +++ src/lyxsocket.C     19 Jan 2005 11:18:01 -0000
726 @@ -68,7 +68,9 @@
727  LyXServerSocket::~LyXServerSocket()
728  {
729         lyx_gui::unregister_socket_callback(fd_);
730 +#ifndef _WIN32
731         ::close(fd_);
732 +#endif
733         lyx::support::unlink(address_);
734         lyxerr[Debug::LYXSERVER] << "lyx: Server socket quitting" << endl;
735  }
736 @@ -155,7 +157,11 @@
737  {
738         string const linen(line + '\n');
739         int const size = linen.size();
740 +#ifndef _WIN32
741         int const written = ::write(fd_, linen.c_str(), size);
742 +#else
743 +       int const written = -1;
744 +#endif
745         if (written < size) { // Allways mean end of connection.
746                 if ((written == -1) && (errno == EPIPE)) {
747                         // The program will also receive a SIGPIPE
748 @@ -194,7 +200,9 @@
749  
750  LyXDataSocket::~LyXDataSocket()
751  {
752 +#ifndef _WIN32
753         ::close(fd_);
754 +#endif
755  
756         lyx_gui::unregister_socket_callback(fd_);
757         lyxerr[Debug::LYXSERVER] << "lyx: Data socket " << fd_ << " quitting."
758 @@ -216,7 +224,13 @@
759         int count;
760  
761         // read and store characters in buffer
762 -       while ((count = ::read(fd_, charbuf, charbuf_size - 1)) > 0) {
763 +       while ((count = 
764 +#ifndef _WIN32
765 +               ::read(fd_, charbuf, charbuf_size - 1)
766 +#else
767 +               0
768 +#endif
769 +               ) > 0) {
770                 buffer_.append(charbuf, charbuf + count);
771         }
772  
773 @@ -250,7 +264,11 @@
774  {
775         string const linen(line + '\n');
776         int const size = linen.size();
777 +#ifndef _WIN32
778         int const written = ::write(fd_, linen.c_str(), size);
779 +#else
780 +       int const written = -1;
781 +#endif
782         if (written < size) { // Allways mean end of connection.
783                 if ((written == -1) && (errno == EPIPE)) {
784                         // The program will also receive a SIGPIPE
785 Index: src/lyxtext.h
786 ===================================================================
787 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v
788 retrieving revision 1.316
789 diff -u -r1.316 lyxtext.h
790 --- src/lyxtext.h       17 Dec 2004 16:27:07 -0000      1.316
791 +++ src/lyxtext.h       31 Jan 2005 09:58:00 -0000
792 @@ -70,7 +70,7 @@
793                 bool toggleall);
794  
795         /// what you expect when pressing <enter> at cursor position
796 -       void breakParagraph(LCursor & cur, char keep_layout = 0);
797 +       void breakParagraph(LCursor & cur, bool keep_layout = false);
798  
799         /// set layout over selection
800         pit_type setLayout(pit_type start, pit_type end,
801 @@ -124,7 +124,7 @@
802                 FuncStatus & status) const;
803  
804         /// access to out BufferView. This should go...
805 -       BufferView * bv();
806 +//     BufferView * bv();
807         /// access to out BufferView. This should go...
808         BufferView * bv() const;
809  
810 Index: src/paragraph.C
811 ===================================================================
812 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
813 retrieving revision 1.400
814 diff -u -r1.400 paragraph.C
815 --- src/paragraph.C     24 Jan 2005 17:12:18 -0000      1.400
816 +++ src/paragraph.C     27 Jan 2005 12:17:23 -0000
817 @@ -1795,6 +1795,8 @@
818  
819  Row & Paragraph::getRow(pos_type pos)
820  {
821 +       BOOST_ASSERT(!rows().empty());
822 +
823         RowList::iterator rit = rows_.end();
824         RowList::iterator const begin = rows_.begin();
825  
826 @@ -1807,6 +1809,8 @@
827  
828  Row const & Paragraph::getRow(pos_type pos) const
829  {
830 +       BOOST_ASSERT(!rows().empty());
831 +
832         RowList::const_iterator rit = rows_.end();
833         RowList::const_iterator const begin = rows_.begin();
834  
835 @@ -1819,6 +1823,8 @@
836  
837  size_t Paragraph::pos2row(pos_type pos) const
838  {
839 +       BOOST_ASSERT(!rows().empty());
840 +
841         RowList::const_iterator rit = rows_.end();
842         RowList::const_iterator const begin = rows_.begin();
843  
844 @@ -1873,11 +1879,3 @@
845         }
846  }
847  
848 -//void Paragraph::metrics(MetricsInfo & mi, Dimension & dim, LyXText & text)
849 -//{
850 -//}
851 -//
852 -//
853 -//void draw(PainterInfo & pi, int x, int y, LyXText & text) const
854 -//{
855 -//}
856 Index: src/paragraph.h
857 ===================================================================
858 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.h,v
859 retrieving revision 1.146
860 diff -u -r1.146 paragraph.h
861 --- src/paragraph.h     19 Jan 2005 15:03:29 -0000      1.146
862 +++ src/paragraph.h     27 Jan 2005 12:58:12 -0000
863 @@ -134,7 +134,7 @@
864                                   lyx::depth_type depth) const;
865  
866         /// Can we drop the standard paragraph wrapper?
867 -       bool Paragraph::emptyTag() const;
868 +       bool emptyTag() const;
869  
870         /// Get the id of the paragraph, usefull for docbook and linuxdoc
871         std::string getID(Buffer const & buf,
872 @@ -293,7 +293,7 @@
873                 BOOST_ASSERT(pos < int(text_.size()));
874                 return text_[pos];
875         }
876 -       ///
877 +       /// Get the char, but mirror all bracket characters if it is right-to-left
878         value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
879         /// The position must already exist.
880         void setChar(lyx::pos_type pos, value_type c);
881 @@ -326,6 +326,9 @@
882         InsetBase * getInset(lyx::pos_type pos);
883         ///
884         InsetBase const * getInset(lyx::pos_type pos) const;
885 +       ///
886 +       InsetList insetlist;
887 +
888  
889         ///
890         bool isHfill(lyx::pos_type pos) const;
891 @@ -344,7 +347,7 @@
892         /// returns -1 if inset not found
893         int getPositionOfInset(InsetBase const * inset) const;
894  
895 -       ///
896 +       /// Returns the number of line breaks and white-space stripped at the start
897         int stripLeadingSpaces();
898  
899         /// return true if we allow multiple spaces
900 @@ -352,7 +355,7 @@
901  
902         /// return true if we allow this par to stay empty
903         bool allowEmpty() const;
904 -       ////
905 +       /// 
906         unsigned char transformChar(unsigned char c, lyx::pos_type pos) const;
907         ///
908         ParagraphParameters & params();
909 @@ -366,37 +369,34 @@
910         ///
911         size_t pos2row(lyx::pos_type pos) const;
912  
913 -       ///
914 -       InsetList insetlist;
915 -
916         /// total height of paragraph
917         unsigned int height() const { return dim_.height(); }
918         /// total width of paragraph, may differ from workwidth
919         unsigned int width() const { return dim_.width(); }
920         unsigned int ascent() const { return dim_.ascent(); }
921         unsigned int descent() const { return dim_.descent(); }
922 -       ///
923 +       /// LyXText updates the rows using this access point
924         RowList & rows() { return rows_; }
925 -       ///
926 +       /// The painter and others use this
927         RowList const & rows() const { return rows_; }
928  
929 -       // compute paragraph metrics    
930 -       void metrics(MetricsInfo & mi, Dimension & dim, LyXText & text);
931 -       // draw paragraph
932 -       void draw(PainterInfo & pi, int x, int y, LyXText & text) const;
933 -       /// dump some information
934 -       void dump() const;
935 +       /// LyXText::redoParagraph updates this
936 +       Dimension & dim() { return dim_; }
937  
938 +       /// dump some information to lyxerr
939 +       void dump() const;
940 +private:
941         /// cached dimensions of paragraph
942         Dimension dim_;
943  
944 -private:
945         ///
946         mutable RowList rows_;
947         ///
948         LyXLayout_ptr layout_;
949 -       /// keeping this here instead of in the pimpl makes LyX >10% faster
950 -       // for average tasks as buffer loading/switching etc.
951 +       /**
952 +        * Keeping this here instead of in the pimpl makes LyX >10% faster
953 +        * for average tasks as buffer loading/switching etc.
954 +        */
955         TextContainer text_;
956         /// end of label
957         lyx::pos_type begin_of_body_;
958 @@ -406,7 +406,6 @@
959         friend class Paragraph::Pimpl;
960         ///
961         Pimpl * pimpl_;
962 -
963  };
964  
965  
966 Index: src/paragraph_funcs.h
967 ===================================================================
968 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_funcs.h,v
969 retrieving revision 1.46
970 diff -u -r1.46 paragraph_funcs.h
971 --- src/paragraph_funcs.h       30 Nov 2004 01:59:36 -0000      1.46
972 +++ src/paragraph_funcs.h       27 Jan 2005 13:19:36 -0000
973 @@ -21,8 +21,15 @@
974  class Paragraph;
975  class ParagraphList;
976  
977 -
978 -///
979 +/**
980 + * This breaks a paragraph at the specified position.
981 + * The new paragraph will:
982 + * get the default layout, when flag == 0
983 + * will inherit the existing one, except for depth, when flag == 1
984 + * will inherit the existing one, including depth, when flag == 2
985 + * Be aware that the old or new paragraph does not contain any rows
986 + * after this.
987 + */
988  void breakParagraph(BufferParams const & bparams,
989                     ParagraphList & paragraphs,
990                     lyx::pit_type par,
991 Index: src/rowpainter.C
992 ===================================================================
993 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v
994 retrieving revision 1.140
995 diff -u -r1.140 rowpainter.C
996 --- src/rowpainter.C    18 Jan 2005 14:15:55 -0000      1.140
997 +++ src/rowpainter.C    31 Jan 2005 11:59:07 -0000
998 @@ -58,7 +58,7 @@
999  public:
1000         /// initialise and run painter
1001         RowPainter(PainterInfo & pi, LyXText const & text,
1002 -               pit_type pit, Row & row, int x, int y);
1003 +               pit_type pit, Row const & row, int x, int y);
1004  
1005         // paint various parts
1006         void paintAppendix();
1007 @@ -101,7 +101,7 @@
1008         ParagraphList & pars_;
1009  
1010         /// The row to paint
1011 -       Row & row_;
1012 +       Row const & row_;
1013  
1014         /// Row's paragraph
1015         pit_type const pit_;
1016 @@ -119,7 +119,7 @@
1017  
1018  
1019  RowPainter::RowPainter(PainterInfo & pi,
1020 -       LyXText const & text, pit_type pit, Row & row, int x, int y)
1021 +       LyXText const & text, pit_type pit, Row const & row, int x, int y)
1022         : bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()),
1023           row_(row), pit_(pit), par_(text.paragraphs()[pit]),
1024           xo_(x), yo_(y), width_(text_.width())
1025 @@ -178,7 +178,7 @@
1026         PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
1027         pi.base.font = getFont(pos);
1028         pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
1029 -       theCoords.insets_.add(inset, int(x_), yo_);
1030 +       theCoords.insets().add(inset, int(x_), yo_);
1031         inset->drawSelection(pi, int(x_), yo_);
1032         inset->draw(pi, int(x_), yo_);
1033         x_ += inset->width();
1034 @@ -738,12 +738,12 @@
1035  
1036         Paragraph & par = text.paragraphs()[pit];
1037  
1038 -       RowList::iterator const rb = par.rows().begin();
1039 -       RowList::iterator const re = par.rows().end();
1040 -       theCoords.pars_[&text][pit] = Point(x, y);
1041 +       RowList::const_iterator const rb = par.rows().begin();
1042 +       RowList::const_iterator const re = par.rows().end();
1043 +       theCoords.parPos()[&text][pit] = Point(x, y);
1044  
1045         y -= rb->ascent();
1046 -       for (RowList::iterator rit = rb; rit != re; ++rit) {
1047 +       for (RowList::const_iterator rit = rb; rit != re; ++rit) {
1048                 y += rit->ascent();
1049                 bool const inside = (y + rit->descent() >= 0
1050                                        && y - rit->ascent() < ww);
1051 @@ -801,12 +801,12 @@
1052         }
1053  
1054         // and grey out above (should not happen later)
1055 -       lyxerr << "par ascent: " << text->getPar(vi.p1).ascent() << endl;
1056 +//     lyxerr << "par ascent: " << text->getPar(vi.p1).ascent() << endl;
1057         if (vi.y1 > 0)
1058                 pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
1059  
1060         // and possibly grey out below
1061 -       lyxerr << "par descent: " << text->getPar(vi.p1).ascent() << endl;
1062 +//     lyxerr << "par descent: " << text->getPar(vi.p1).ascent() << endl;
1063         if (vi.y2 < bv.workHeight())
1064                 pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
1065  }
1066 Index: src/text.C
1067 ===================================================================
1068 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
1069 retrieving revision 1.592
1070 diff -u -r1.592 text.C
1071 --- src/text.C  19 Jan 2005 08:42:32 -0000      1.592
1072 +++ src/text.C  31 Jan 2005 10:05:42 -0000
1073 @@ -376,12 +376,6 @@
1074  } // namespace anon
1075  
1076  
1077 -BufferView * LyXText::bv()
1078 -{
1079 -       BOOST_ASSERT(bv_owner != 0);
1080 -       return bv_owner;
1081 -}
1082 -
1083  
1084  BufferView * LyXText::bv() const
1085  {
1086 @@ -1017,7 +1011,7 @@
1087  
1088  }
1089  
1090 -void LyXText::breakParagraph(LCursor & cur, char keep_layout)
1091 +void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
1092  {
1093         BOOST_ASSERT(this == cur.text());
1094         // allow only if at start or end, or all previous is new text
1095 @@ -1045,25 +1039,30 @@
1096         if (cur.pos() != cur.lastpos() && cpar.isLineSeparator(cur.pos()))
1097                 cpar.erase(cur.pos());
1098  
1099 -       // break the paragraph
1100 +       // How should the layout for the new paragraph be?
1101 +       int preserve_layout = 0;
1102         if (keep_layout)
1103 -               keep_layout = 2;
1104 +               preserve_layout = 2;
1105         else
1106 -               keep_layout = layout->isEnvironment();
1107 +               preserve_layout = layout->isEnvironment();
1108 +
1109 +       // We need to remember this before we break the paragraph, because
1110 +       // that invalidates the layout variable
1111 +       bool sensitive = layout->labeltype == LABEL_SENSITIVE;
1112  
1113 -       // we need to set this before we insert the paragraph. IMO the
1114 -       // breakParagraph call should return a bool if it inserts the
1115 -       // paragraph before or behind and we should react on that one
1116 -       // but we can fix this in 1.3.0 (Jug 20020509)
1117 +       // we need to set this before we insert the paragraph.
1118         bool const isempty = cpar.allowEmpty() && cpar.empty();
1119 +
1120         ::breakParagraph(cur.buffer().params(), paragraphs(), cpit,
1121 -                        cur.pos(), keep_layout);
1122 +                        cur.pos(), preserve_layout);
1123 +
1124 +       // After this, neither paragraph contains any rows!
1125  
1126         cpit = cur.pit();
1127         pit_type next_par = cpit + 1;
1128  
1129         // well this is the caption hack since one caption is really enough
1130 -       if (layout->labeltype == LABEL_SENSITIVE) {
1131 +       if (sensitive) {
1132                 if (cur.pos() == 0)
1133                         // set to standard-layout
1134                         pars_[cpit].applyLayout(tclass.defaultLayout());
1135 @@ -1072,16 +1071,6 @@
1136                         pars_[next_par].applyLayout(tclass.defaultLayout());
1137         }
1138  
1139 -       // if the cursor is at the beginning of a row without prior newline,
1140 -       // move one row up!
1141 -       // This touches only the screen-update. Otherwise we would may have
1142 -       // an empty row on the screen
1143 -       if (cur.pos() != 0 && cur.textRow().pos() == cur.pos()
1144 -           && !pars_[cpit].isNewline(cur.pos() - 1))
1145 -       {
1146 -               cursorLeft(cur);
1147 -       }
1148 -
1149         while (!pars_[next_par].empty() && pars_[next_par].isNewline(0))
1150                 pars_[next_par].erase(0);
1151  
1152 @@ -1172,8 +1161,8 @@
1153                                 cur.message(_("You cannot insert a space at the "
1154                                         "beginning of a paragraph. Please read the Tutorial."));
1155                                 sent_space_message = true;
1156 -                               return;
1157                         }
1158 +                       return;
1159                 }
1160                 BOOST_ASSERT(cur.pos() > 0);
1161                 if (par.isLineSeparator(cur.pos() - 1)
1162 @@ -1686,7 +1675,7 @@
1163  
1164         dim.asc += par.rows()[0].ascent();
1165         dim.des -= par.rows()[0].ascent();
1166 -       par.dim_ = dim;
1167 +       par.dim() = dim;
1168         //lyxerr << "redoParagraph: " << par.rows().size() << " rows\n";
1169  }
1170  
1171 Index: src/text2.C
1172 ===================================================================
1173 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
1174 retrieving revision 1.594
1175 diff -u -r1.594 text2.C
1176 --- src/text2.C 6 Jan 2005 16:39:30 -0000       1.594
1177 +++ src/text2.C 31 Jan 2005 12:01:19 -0000
1178 @@ -119,7 +119,7 @@
1179                 InsetBase * inset = iit->inset;
1180  #if 1
1181                 lyxerr << "examining inset " << inset << endl;
1182 -               if (theCoords.insets_.has(inset))
1183 +               if (theCoords.getInsets().has(inset))
1184                         lyxerr
1185                                 << " xo: " << inset->xo() << "..."
1186                                 << inset->xo() + inset->width()
1187 @@ -1122,8 +1122,8 @@
1188  pit_type LyXText::getPitNearY(int y) const
1189  {
1190         BOOST_ASSERT(!paragraphs().empty());
1191 -       BOOST_ASSERT(theCoords.pars_.find(this) != theCoords.pars_.end());
1192 -       CoordCache::InnerParPosCache const & cc = theCoords.pars_[this];
1193 +       BOOST_ASSERT(theCoords.getParPos().find(this) != theCoords.getParPos().end());
1194 +       CoordCache::InnerParPosCache const & cc = theCoords.getParPos().find(this)->second;
1195         lyxerr << "LyXText::getPitNearY: y: " << y << " cache size: "
1196                 << cc.size() << endl;
1197  
1198 @@ -1282,8 +1282,6 @@
1199  
1200  void LyXText::cursorDown(LCursor & cur)
1201  {
1202 -
1203 -
1204         Paragraph const & par = cur.paragraph();
1205         int const row = par.pos2row(cur.pos());
1206         int const x = cur.targetX();
1207 Index: src/text3.C
1208 ===================================================================
1209 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
1210 retrieving revision 1.280
1211 diff -u -r1.280 text3.C
1212 --- src/text3.C 27 Jan 2005 21:05:34 -0000      1.280
1213 +++ src/text3.C 31 Jan 2005 12:11:17 -0000
1214 @@ -353,7 +353,7 @@
1215  void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
1216  {
1217         lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
1218 -       //lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl;
1219 +       lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl;
1220  
1221         BOOST_ASSERT(cur.text() == this);
1222         BufferView * bv = &cur.bv();
1223 Index: src/client/client.C
1224 ===================================================================
1225 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/client/client.C,v
1226 retrieving revision 1.7
1227 diff -u -r1.7 client.C
1228 --- src/client/client.C 20 Jan 2005 15:38:13 -0000      1.7
1229 +++ src/client/client.C 21 Jan 2005 09:43:09 -0000
1230 @@ -25,12 +25,14 @@
1231  # include <unistd.h>
1232  #endif
1233  
1234 +#ifndef _WIN32
1235  // select()
1236 -#include <sys/select.h>
1237 +# include <sys/select.h>
1238  
1239  // socket(), connect()
1240 -#include <sys/socket.h>
1241 -#include <sys/un.h>
1242 +# include <sys/socket.h>
1243 +# include <sys/un.h>
1244 +#endif
1245  
1246  // fcntl()
1247  #include <fcntl.h>
1248 Index: src/frontends/LyXView.C
1249 ===================================================================
1250 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.C,v
1251 retrieving revision 1.49
1252 diff -u -r1.49 LyXView.C
1253 --- src/frontends/LyXView.C     20 Jan 2005 15:38:14 -0000      1.49
1254 +++ src/frontends/LyXView.C     21 Jan 2005 09:43:10 -0000
1255 @@ -39,7 +39,9 @@
1256  
1257  #include <boost/bind.hpp>
1258  
1259 -#include <sys/time.h>
1260 +#ifndef _WIN32
1261 +# include <sys/time.h>
1262 +#endif
1263  #ifdef HAVE_UNISTD_H
1264  # include <unistd.h>
1265  #endif
1266 Index: src/frontends/qt2/QDialogView.h
1267 ===================================================================
1268 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QDialogView.h,v
1269 retrieving revision 1.10
1270 diff -u -r1.10 QDialogView.h
1271 --- src/frontends/qt2/QDialogView.h     19 May 2004 15:11:33 -0000      1.10
1272 +++ src/frontends/qt2/QDialogView.h     25 Jan 2005 12:45:06 -0000
1273 @@ -13,6 +13,7 @@
1274  #define QDIALOGVIEW_H
1275  
1276  #include "Dialog.h"
1277 +
1278  #include <boost/scoped_ptr.hpp>
1279  
1280  #include <qapplication.h>
1281 @@ -110,7 +111,11 @@
1282  template <class GUIDialog>
1283  QDialog * QView<GUIDialog>::form() const
1284  {
1285 -       return dialog_.get();
1286 +       /* Brain dead MSVC compiler wants to know the class hierarchy at the
1287 +          definition site of the template, rather than the instantation point
1288 +          to downcast correctly. So, rather than including all dialogs to 
1289 +          provide that, we just cast it with the ugly hammer. */
1290 +       return (QDialog *) dialog_.get();
1291  }
1292  
1293  
1294 Index: src/frontends/qt2/QLPainter.C
1295 ===================================================================
1296 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLPainter.C,v
1297 retrieving revision 1.34
1298 diff -u -r1.34 QLPainter.C
1299 --- src/frontends/qt2/QLPainter.C       20 May 2004 09:36:27 -0000      1.34
1300 +++ src/frontends/qt2/QLPainter.C       31 Jan 2005 12:29:53 -0000
1301 @@ -202,8 +202,9 @@
1302         int tmpx = x;
1303         size_t ls = s.length();
1304         for (size_t i = 0; i < ls; ++i) {
1305 -               QChar const c = s[i].upper();
1306 -               if (c != s[i]) {
1307 +               // Brain-dead MSVC wants at(i) rather than operator[]
1308 +               QChar const c = s.at(i).upper();
1309 +               if (c != s.at(i)) {
1310                         qp_->setFont(qsmallfont);
1311                         qp_->drawText(tmpx, y, c);
1312                         tmpx += qsmallfontm.width(c);
1313 @@ -229,7 +230,8 @@
1314  #if QT_VERSION >= 300
1315         str.setLength(ls);
1316         for (size_t i = 0; i < ls; ++i)
1317 -               str[i] = QChar(encoding->ucs(s[i]));
1318 +               // Brain-dead MSVC wants at(i) rather than operator[]
1319 +               str.at(i) = QChar(encoding->ucs(s[i]));
1320         // HACK: QT3 refuses to show single compose characters
1321         if (ls == 1 && str[0].unicode() >= 0x05b0 && str[0].unicode() <= 0x05c2)
1322                 str = ' ' + str;
1323 Index: src/frontends/qt2/lengthvalidator.h
1324 ===================================================================
1325 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lengthvalidator.h,v
1326 retrieving revision 1.4
1327 diff -u -r1.4 lengthvalidator.h
1328 --- src/frontends/qt2/lengthvalidator.h 22 Nov 2004 12:22:19 -0000      1.4
1329 +++ src/frontends/qt2/lengthvalidator.h 23 Jan 2005 09:47:57 -0000
1330 @@ -19,7 +19,7 @@
1331  class QWidget;
1332  
1333  
1334 -class Q_EXPORT LengthValidator : public QValidator
1335 +class LengthValidator : public QValidator
1336  {
1337         Q_OBJECT
1338  public:
1339 Index: src/insets/inset.C
1340 ===================================================================
1341 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.C,v
1342 retrieving revision 1.131
1343 diff -u -r1.131 inset.C
1344 --- src/insets/inset.C  5 Jan 2005 20:21:26 -0000       1.131
1345 +++ src/insets/inset.C  31 Jan 2005 09:31:42 -0000
1346 @@ -79,5 +79,5 @@
1347  void InsetOld::setPosCache(PainterInfo const &, int x, int y) const
1348  {
1349         //lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
1350 -       theCoords.insets_.add(this, x, y);
1351 +       theCoords.insets().add(this, x, y);
1352  }
1353 Index: src/insets/insetbase.C
1354 ===================================================================
1355 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.C,v
1356 retrieving revision 1.39
1357 diff -u -r1.39 insetbase.C
1358 --- src/insets/insetbase.C      19 Jan 2005 15:03:30 -0000      1.39
1359 +++ src/insets/insetbase.C      31 Jan 2005 12:01:20 -0000
1360 @@ -293,13 +293,13 @@
1361  
1362  int InsetBase::xo() const
1363  {
1364 -       return theCoords.insets_.x(this);
1365 +       return theCoords.getInsets().x(this);
1366  }
1367  
1368  
1369  int InsetBase::yo() const
1370  {
1371 -       return theCoords.insets_.y(this);
1372 +       return theCoords.getInsets().y(this);
1373  }
1374  
1375  
1376 @@ -310,7 +310,7 @@
1377         //      << " x1: " << xo() << " x2: " << xo() + width()
1378         //      << " y1: " << yo() - ascent() << " y2: " << yo() + descent()
1379         //      << std::endl;
1380 -       return theCoords.insets_.has(this)
1381 +       return theCoords.getInsets().has(this)
1382                         && x >= xo()
1383                         && x <= xo() + width()
1384                         && y >= yo() - ascent()
1385 Index: src/insets/insettabular.C
1386 ===================================================================
1387 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
1388 retrieving revision 1.452
1389 diff -u -r1.452 insettabular.C
1390 --- src/insets/insettabular.C   27 Jan 2005 21:05:42 -0000      1.452
1391 +++ src/insets/insettabular.C   31 Jan 2005 12:01:20 -0000
1392 @@ -1024,7 +1024,7 @@
1393  {
1394         int xx = 0;
1395         int yy = 0;
1396 -       Point o = theCoords.insets_.xy(&inset);
1397 +       Point o = theCoords.getInsets().xy(&inset);
1398         int const xo = o.x_;
1399         int const yo = o.y_;
1400  
1401 @@ -1055,7 +1055,7 @@
1402         idx_type idx_min = 0;
1403         int dist_min = std::numeric_limits<int>::max();
1404         for (idx_type i = 0; i < nargs(); ++i) {
1405 -               if (theCoords.insets_.has(tabular.getCellInset(i).get())) {
1406 +               if (theCoords.getInsets().has(tabular.getCellInset(i).get())) {
1407                         int d = dist(*tabular.getCellInset(i), x, y);
1408                         if (d < dist_min) {
1409                                 dist_min = d;
1410 Index: src/insets/updatableinset.C
1411 ===================================================================
1412 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/updatableinset.C,v
1413 retrieving revision 1.50
1414 diff -u -r1.50 updatableinset.C
1415 --- src/insets/updatableinset.C 27 Jan 2005 21:05:43 -0000      1.50
1416 +++ src/insets/updatableinset.C 31 Jan 2005 12:01:20 -0000
1417 @@ -43,7 +43,7 @@
1418         }
1419  
1420         int const workW = bv.workWidth();
1421 -       int xo_ = theCoords.insets_.x(this);
1422 +       int xo_ = theCoords.getInsets().x(this);
1423         int const tmp_xo_ = xo_ - scx;
1424  
1425         if (tmp_xo_ > 0 && tmp_xo_ + width() < workW)
1426 @@ -63,7 +63,7 @@
1427  
1428  void UpdatableInset::scroll(BufferView & bv, int offset) const
1429  {
1430 -       int const xo_ = theCoords.insets_.x(this);
1431 +       int const xo_ = theCoords.getInsets().x(this);
1432         if (offset > 0) {
1433                 if (!scx && xo_ >= 20)
1434                         return;
1435 Index: src/mathed/math_data.C
1436 ===================================================================
1437 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_data.C,v
1438 retrieving revision 1.59
1439 diff -u -r1.59 math_data.C
1440 --- src/mathed/math_data.C      5 Jan 2005 20:21:27 -0000       1.59
1441 +++ src/mathed/math_data.C      31 Jan 2005 12:01:19 -0000
1442 @@ -411,17 +411,17 @@
1443  void MathArray::setXY(int x, int y) const
1444  {
1445         //lyxerr << "setting position cache for MathArray " << this << std::endl;
1446 -       theCoords.arrays_.add(this, x, y);
1447 +       theCoords.arrays().add(this, x, y);
1448  }
1449  
1450  
1451  int MathArray::xo() const
1452  {
1453 -       return theCoords.arrays_.x(this);
1454 +       return theCoords.getArrays().x(this);
1455  }
1456  
1457  
1458  int MathArray::yo() const
1459  {
1460 -       return theCoords.arrays_.y(this);
1461 +       return theCoords.getArrays().y(this);
1462  }
1463 Index: src/mathed/math_diminset.C
1464 ===================================================================
1465 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_diminset.C,v
1466 retrieving revision 1.23
1467 diff -u -r1.23 math_diminset.C
1468 --- src/mathed/math_diminset.C  14 Aug 2004 14:03:42 -0000      1.23
1469 +++ src/mathed/math_diminset.C  31 Jan 2005 09:31:42 -0000
1470 @@ -40,5 +40,5 @@
1471  void MathDimInset::setPosCache(PainterInfo const &, int x, int y) const
1472  {
1473         //lyxerr << "MathDimInset: cache to " << x << " " << y << std::endl;
1474 -       theCoords.insets_.add(this, x, y);
1475 +       theCoords.insets().add(this, x, y);
1476  }
1477 Index: src/mathed/math_nestinset.C
1478 ===================================================================
1479 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_nestinset.C,v
1480 retrieving revision 1.143
1481 diff -u -r1.143 math_nestinset.C
1482 --- src/mathed/math_nestinset.C 6 Jan 2005 16:07:01 -0000       1.143
1483 +++ src/mathed/math_nestinset.C 31 Jan 2005 12:01:19 -0000
1484 @@ -110,23 +110,23 @@
1485  // absolute again when actually drawing the cursor. What a mess.
1486         BOOST_ASSERT(ptr_cmp(&sl.inset(), this));
1487         MathArray const & ar = sl.cell();
1488 -       if (!theCoords.arrays_.has(&ar)) {
1489 -               // this can (semi-)legally happen if we jsut created this cell
1490 +       if (!theCoords.getArrays().has(&ar)) {
1491 +               // this can (semi-)legally happen if we just created this cell
1492                 // and it never has been drawn before. So don't ASSERT.
1493                 //lyxerr << "no cached data for array " << &ar << endl;
1494                 x = 0;
1495                 y = 0;
1496                 return;
1497         }
1498 -       Point const pt = theCoords.arrays_.xy(&ar);
1499 -       if (!theCoords.insets_.has(this)) {
1500 +       Point const pt = theCoords.getArrays().xy(&ar);
1501 +       if (!theCoords.getInsets().has(this)) {
1502                 // same as above
1503                 //lyxerr << "no cached data for inset " << this << endl;
1504                 x = 0;
1505                 y = 0;
1506                 return;
1507         }
1508 -       Point const pt2 = theCoords.insets_.xy(this);
1509 +       Point const pt2 = theCoords.getInsets().xy(this);
1510         //lyxerr << "retrieving position cache for MathArray "
1511         //      << pt.x_ << ' ' << pt.y_ << std::endl;
1512         x = pt.x_ - pt2.x_ + ar.pos2x(sl.pos());
1513 Index: src/support/chdir.C
1514 ===================================================================
1515 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/chdir.C,v
1516 retrieving revision 1.10
1517 diff -u -r1.10 chdir.C
1518 --- src/support/chdir.C 20 Jan 2005 15:38:14 -0000      1.10
1519 +++ src/support/chdir.C 25 Jan 2005 12:47:15 -0000
1520 @@ -16,11 +16,17 @@
1521  # include <unistd.h>
1522  #endif
1523  
1524 +#ifdef _WIN32
1525 +# include <windows.h>
1526 +#endif
1527 +
1528  int lyx::support::chdir(std::string const & name)
1529  {
1530 -#ifndef __EMX__
1531 -       return ::chdir(name.c_str());
1532 -#else
1533 +#ifdef __EMX__
1534         return ::_chdir2(name.c_str());
1535 +#elif defined(_WIN32)
1536 +       return SetCurrentDirectory(name.c_str()) != 0 ? 0 : -1;
1537 +#else
1538 +       return ::chdir(name.c_str());
1539  #endif
1540  }
1541 Index: src/support/filetools.C
1542 ===================================================================
1543 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
1544 retrieving revision 1.204
1545 diff -u -r1.204 filetools.C
1546 --- src/support/filetools.C     31 Jan 2005 10:42:23 -0000      1.204
1547 +++ src/support/filetools.C     31 Jan 2005 11:08:10 -0000
1548 @@ -1153,6 +1153,11 @@
1549  
1550  cmd_ret const RunCommand(string const & cmd)
1551  {
1552 +#ifdef _WIN32
1553 +       // TODO: Implement this, or merge it into forkedcall.
1554 +       // Used for lyx2lyx in buffer.C, echo in math_extern and kpse in this file
1555 +       return make_pair(-1, string());
1556 +#else
1557         // FIXME: replace all calls to RunCommand with ForkedCall
1558         // (if the output is not needed) or the code in ispell.C
1559         // (if the output is needed).
1560 @@ -1193,6 +1198,7 @@
1561         sigprocmask(SIG_SETMASK, &oldMask, 0);
1562  
1563         return make_pair(pret, ret);
1564 +#endif
1565  }
1566  
1567  
1568 Index: src/support/forkedcall.C
1569 ===================================================================
1570 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcall.C,v
1571 retrieving revision 1.21
1572 diff -u -r1.21 forkedcall.C
1573 --- src/support/forkedcall.C    20 Jan 2005 15:38:14 -0000      1.21
1574 +++ src/support/forkedcall.C    25 Jan 2005 12:41:14 -0000
1575 @@ -30,6 +30,10 @@
1576  #include "support/lyxlib.h"
1577  #include "support/filetools.h"
1578  #include "support/os.h"
1579 +#ifdef _WIN32
1580 +#include "os_win32.h"
1581 +#include <process.h>
1582 +#endif
1583  
1584  #include "debug.h"
1585  
1586 @@ -41,7 +45,9 @@
1587  #include <csignal>
1588  #include <cstdlib>
1589  #include <sys/types.h>
1590 -#include <sys/wait.h>
1591 +#ifndef _WIN32
1592 +# include <sys/wait.h>
1593 +#endif
1594  #ifdef HAVE_UNISTD_H
1595  # include <unistd.h>
1596  #endif
1597 @@ -70,7 +76,9 @@
1598                 if (secs > 0) {
1599                         new Murder(secs, pid);
1600                 } else if (pid != 0) {
1601 +#ifdef SIGKILL
1602                         lyx::support::kill(pid, SIGKILL);
1603 +#endif
1604                 }
1605         }
1606  
1607 @@ -78,7 +86,9 @@
1608         void kill()
1609         {
1610                 if (pid_ != 0) {
1611 +#ifdef SIGKILL
1612                         lyx::support::kill(pid_, SIGKILL);
1613 +#endif
1614                 }
1615                 lyxerr << "Killed " << pid_ << std::endl;
1616                 delete this;
1617 @@ -152,14 +162,16 @@
1618         if (!pid())
1619                 return false;
1620  
1621 +#ifndef _WIN32
1622         // Un-UNIX like, but we don't have much use for
1623         // knowing if a zombie exists, so just reap it first.
1624         int waitstatus;
1625         waitpid(pid(), &waitstatus, WNOHANG);
1626  
1627         // Racy of course, but it will do.
1628 -       if (::kill(pid(), 0) && errno == ESRCH)
1629 +       if (lyx::kill(pid(), 0) && errno == ESRCH)
1630                 return false;
1631 +#endif
1632         return true;
1633  }
1634  
1635 @@ -178,6 +190,7 @@
1636                 Murder::killItDead(0, pid());
1637  
1638         } else {
1639 +#ifdef SIGHUP
1640                 int ret = lyx::support::kill(pid(), SIGHUP);
1641  
1642                 // The process is already dead if wait_for_death is false
1643 @@ -186,6 +199,7 @@
1644                 if (wait_for_death) {
1645                         Murder::killItDead(tolerance, pid());
1646                 }
1647 +#endif
1648         }
1649  }
1650  
1651 @@ -195,6 +209,7 @@
1652  {
1653         // We'll pretend that the child returns 1 on all error conditions.
1654         retval_ = 1;
1655 +#ifndef _WIN32
1656         int status;
1657         bool wait = true;
1658         while (wait) {
1659 @@ -223,6 +238,7 @@
1660                         wait = false;
1661                 }
1662         }
1663 +#endif
1664         return retval_;
1665  }
1666  
1667 @@ -299,7 +315,12 @@
1668                 std::cout << *ait << std::endl;
1669         argv.push_back(0);
1670  
1671 -#ifndef __EMX__
1672 +#ifdef __EMX
1673 +       pid_t const cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND,
1674 +                                  argv[0], &*argv.begin());
1675 +#elif defined(_WIN32)
1676 +       pid_t const cpid = spawnvp(_P_NOWAIT, argv[0], &*argv.begin());
1677 +#else
1678         pid_t const cpid = ::fork();
1679         if (cpid == 0) {
1680                 // Child
1681 @@ -310,9 +331,6 @@
1682                        << strerror(errno) << endl;
1683                 _exit(1);
1684         }
1685 -#else
1686 -       pid_t const cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND,
1687 -                                  argv[0], &*argv.begin());
1688  #endif
1689  
1690         if (cpid < 0) {
1691 Index: src/support/forkedcall.h
1692 ===================================================================
1693 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcall.h,v
1694 retrieving revision 1.19
1695 diff -u -r1.19 forkedcall.h
1696 --- src/support/forkedcall.h    26 Sep 2004 14:19:47 -0000      1.19
1697 +++ src/support/forkedcall.h    17 Jan 2005 12:17:09 -0000
1698 @@ -31,6 +31,10 @@
1699  
1700  #include <sys/types.h>
1701  
1702 +#ifdef _WIN32
1703 +typedef int pid_t;
1704 +#endif
1705 +
1706  namespace lyx {
1707  namespace support {
1708  
1709 Index: src/support/forkedcontr.C
1710 ===================================================================
1711 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcontr.C,v
1712 retrieving revision 1.27
1713 diff -u -r1.27 forkedcontr.C
1714 --- src/support/forkedcontr.C   20 Jan 2005 15:38:14 -0000      1.27
1715 +++ src/support/forkedcontr.C   21 Jan 2005 09:51:07 -0000
1716 @@ -19,14 +19,22 @@
1717  
1718  #include "debug.h"
1719  
1720 +#ifdef _WIN32
1721 +#include "os_win32.h"
1722 +#include <windows.h>
1723 +#endif
1724 +
1725  #include <boost/bind.hpp>
1726  
1727  #include <cerrno>
1728  #include <cstdlib>
1729 +
1730  #ifdef HAVE_UNISTD_H
1731  # include <unistd.h>
1732  #endif
1733 -#include <sys/wait.h>
1734 +#ifndef _WIN32
1735 +# include <sys/wait.h>
1736 +#endif
1737  
1738  using boost::bind;
1739  
1740 @@ -176,7 +184,9 @@
1741         ForkedcallsController::Data & store =
1742                 fcc.reaped_children[++fcc.current_child];
1743         // Clean up the child process.
1744 +#ifndef _WIN32
1745         store.pid = wait(&store.status);
1746 +#endif
1747  }
1748  
1749  } // namespace anon
1750 @@ -193,11 +203,12 @@
1751  ForkedcallsController::ForkedcallsController()
1752         : reaped_children(50), current_child(-1)
1753  {
1754 +#ifndef _WIN32
1755         signal(SIGCHLD, child_handler);
1756 -
1757         sigemptyset(&oldMask);
1758         sigemptyset(&newMask);
1759         sigaddset(&newMask, SIGCHLD);
1760 +#endif
1761  }
1762  
1763  
1764 @@ -206,7 +217,9 @@
1765  // I want to print or something.
1766  ForkedcallsController::~ForkedcallsController()
1767  {
1768 +#ifndef _WIN32
1769         signal(SIGCHLD, SIG_DFL);
1770 +#endif
1771  }
1772  
1773  
1774 @@ -215,6 +228,7 @@
1775         forkedCalls.push_back(newcall.clone());
1776  
1777         if (forkedCalls.size() > reaped_children.size()) {
1778 +#ifndef _WIN32
1779                 // Block the SIGCHLD signal.
1780                 sigprocmask(SIG_BLOCK, &newMask, &oldMask);
1781  
1782 @@ -222,6 +236,7 @@
1783  
1784                 // Unblock the SIGCHLD signal and restore the old mask.
1785                 sigprocmask(SIG_SETMASK, &oldMask, 0);
1786 +#endif
1787         }
1788  }
1789  
1790 @@ -255,8 +270,10 @@
1791         if (current_child == -1)
1792                 return;
1793  
1794 +#ifndef _WIN32
1795         // Block the SIGCHLD signal.
1796         sigprocmask(SIG_BLOCK, &newMask, &oldMask);
1797 +#endif
1798  
1799         for (int i = 0; i != 1 + current_child; ++i) {
1800                 Data & store = reaped_children[i];
1801 @@ -312,8 +329,10 @@
1802         // Reset the counter
1803         current_child = -1;
1804  
1805 +#ifndef _WIN32
1806         // Unblock the SIGCHLD signal and restore the old mask.
1807         sigprocmask(SIG_SETMASK, &oldMask, 0);
1808 +#endif
1809  }
1810  
1811  } // namespace support
1812 Index: src/support/forkedcontr.h
1813 ===================================================================
1814 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcontr.h,v
1815 retrieving revision 1.18
1816 diff -u -r1.18 forkedcontr.h
1817 --- src/support/forkedcontr.h   7 Nov 2004 13:22:51 -0000       1.18
1818 +++ src/support/forkedcontr.h   23 Jan 2005 12:25:33 -0000
1819 @@ -19,7 +19,10 @@
1820  #include <boost/shared_ptr.hpp>
1821  
1822  #include <csignal>
1823 -//#include <sys/types.h> // needed for pid_t
1824 +#ifdef _WIN32
1825 +typedef int pid_t;
1826 +#endif
1827 +#include <sys/types.h> // needed for pid_t
1828  #include <list>
1829  #include <vector>
1830  
1831 @@ -79,8 +82,10 @@
1832         /// The child processes
1833         ListType forkedCalls;
1834  
1835 +#ifndef _WIN32
1836         /// Used to block SIGCHLD signals.
1837         sigset_t newMask, oldMask;
1838 +#endif
1839  };
1840  
1841  } // namespace support
1842 Index: src/support/fs_extras.C
1843 ===================================================================
1844 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/fs_extras.C,v
1845 retrieving revision 1.1
1846 diff -u -r1.1 fs_extras.C
1847 --- src/support/fs_extras.C     31 Jan 2005 10:42:24 -0000      1.1
1848 +++ src/support/fs_extras.C     31 Jan 2005 11:31:39 -0000
1849 @@ -22,6 +22,10 @@
1850  #   endif
1851  # endif
1852  
1853 +#ifdef BOOST_WINDOWS
1854 +# include <windows.h>
1855 +#endif
1856 +
1857  namespace fs = boost::filesystem;
1858  
1859  namespace boost {
1860 @@ -32,6 +36,12 @@
1861  #ifdef BOOST_POSIX
1862         return ::access(ph.string().c_str(), R_OK) == 0;
1863  #endif
1864 +#ifdef BOOST_WINDOWS
1865 +       DWORD const attr = ::GetFileAttributes( ph.string().c_str() );
1866 +       return attr != INVALID_FILE_ATTRIBUTES && 
1867 +               ( attr & FILE_ATTRIBUTE_DIRECTORY ) != FILE_ATTRIBUTE_DIRECTORY;
1868 +
1869 +#endif
1870  }
1871  
1872  
1873 @@ -40,14 +50,21 @@
1874  #ifdef BOOST_POSIX
1875         return ::access(ph.string().c_str(), W_OK) == 0;
1876  #endif
1877 +#ifdef BOOST_WINDOWS
1878 +       DWORD const attr = ::GetFileAttributes( ph.string().c_str() );
1879 +       if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_READONLY) != 0) {
1880 +               // Read-only - no write access
1881 +               return false;
1882 +       }
1883 +       return attr != INVALID_FILE_ATTRIBUTES && 
1884 +               ( attr & FILE_ATTRIBUTE_DIRECTORY ) != FILE_ATTRIBUTE_DIRECTORY;
1885 +#endif
1886  }
1887  
1888  
1889  bool is_readonly(path const & ph)
1890  {
1891 -#ifdef BOOST_POSIX
1892         return is_readable(ph) && !is_writable(ph);
1893 -#endif
1894  }
1895  
1896  
1897 @@ -115,6 +132,16 @@
1898                                 "boost::filesystem::copy_file",
1899                                 source, target,
1900                                 fs::detail::system_error_code()));
1901 +#endif
1902 +
1903 +#ifdef BOOST_WINDOWS
1904 +       if (::CopyFile(source.string().c_str(), target.string().c_str(), FALSE) == 0) {
1905 +               boost::throw_exception(
1906 +                       filesystem_error(
1907 +                               "boost::filesystem::copy_file",
1908 +                               source, target,
1909 +                               fs::detail::system_error_code()));
1910 +       }
1911  #endif
1912  }
1913  
1914 Index: src/support/getcwd.C
1915 ===================================================================
1916 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/getcwd.C,v
1917 retrieving revision 1.12
1918 diff -u -r1.12 getcwd.C
1919 --- src/support/getcwd.C        20 Jan 2005 15:38:14 -0000      1.12
1920 +++ src/support/getcwd.C        21 Jan 2005 09:50:41 -0000
1921 @@ -19,6 +19,10 @@
1922  # include <unistd.h>
1923  #endif
1924  
1925 +#ifdef _WIN32
1926 +# include <windows.h>
1927 +#endif
1928 +
1929  using boost::scoped_array;
1930  
1931  using std::string;
1932 @@ -29,10 +33,13 @@
1933  inline
1934  char * l_getcwd(char * buffer, size_t size)
1935  {
1936 -#ifndef __EMX__
1937 -       return ::getcwd(buffer, size);
1938 -#else
1939 +#ifdef __EMX
1940         return ::_getcwd2(buffer, size);
1941 +#elif defined(_WIN32)
1942 +       GetCurrentDirectory(size, buffer);
1943 +       return buffer;
1944 +#else
1945 +       return ::getcwd(buffer, size);
1946  #endif
1947  }
1948  
1949 Index: src/support/kill.C
1950 ===================================================================
1951 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/kill.C,v
1952 retrieving revision 1.12
1953 diff -u -r1.12 kill.C
1954 --- src/support/kill.C  7 Nov 2004 13:22:51 -0000       1.12
1955 +++ src/support/kill.C  20 Jan 2005 11:46:47 -0000
1956 @@ -15,7 +15,38 @@
1957  #include <sys/types.h>
1958  #include <csignal>
1959  
1960 +#ifdef _WIN32
1961 +#include "debug.h"
1962 +#include "os.h"
1963 +
1964 +#include <windows.h>
1965 +#include <errno.h>
1966 +
1967 +using std::endl;
1968 +#endif //_WIN32
1969 +
1970  int lyx::support::kill(int pid, int sig)
1971  {
1972 +#ifdef _WIN32
1973 +       if (pid == (int)GetCurrentProcessId()) {
1974 +               return -(raise(sig));
1975 +       } else {
1976 +               HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
1977 +               if (!hProcess) {
1978 +                       lyxerr << "kill OpenProcess failed!" << endl;
1979 +                       return -1;
1980 +               } else {
1981 +                       if (!TerminateProcess(hProcess, sig)){
1982 +                               lyxerr << "kill process failed!" << endl;
1983 +                               CloseHandle(hProcess);
1984 +                               return -1;
1985 +                       }
1986 +               CloseHandle(hProcess);
1987 +               }
1988 +       }
1989 +       return 0;
1990 +
1991 +#else
1992         return ::kill(pid, sig);
1993 +#endif
1994  }
1995 Index: src/support/mkdir.C
1996 ===================================================================
1997 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/mkdir.C,v
1998 retrieving revision 1.16
1999 diff -u -r1.16 mkdir.C
2000 --- src/support/mkdir.C 20 Jan 2005 15:38:14 -0000      1.16
2001 +++ src/support/mkdir.C 25 Jan 2005 12:52:02 -0000
2002 @@ -18,6 +18,9 @@
2003  #ifdef HAVE_UNISTD_H
2004  # include <unistd.h>
2005  #endif
2006 +#ifdef _WIN32
2007 +# include <Windows.h>
2008 +#endif
2009  
2010  int lyx::support::mkdir(std::string const & pathname, unsigned long int mode)
2011  {
2012 @@ -30,12 +33,12 @@
2013         // POSIX
2014         return ::mkdir(pathname.c_str(), mode_t(mode));
2015  # endif
2016 -#else
2017 -# if HAVE__MKDIR
2018 +#elif defined(_WIN32)
2019         // plain Windows 32
2020 -       return ::_mkdir(pathname.c_str());
2021 -# else
2022 -#  error "Don't know how to create a directory on this system."
2023 -# endif
2024 +       return CreateDirectory(pathname.c_str(), 0) != 0 ? 0 : -1;
2025 +#elif HAVE__MKDIR
2026 +       return ::_mkdir(pathname.c_str());
2027 +#else
2028 +#   error "Don't know how to create a directory on this system."
2029  #endif
2030  }
2031 Index: src/support/os_win32.h
2032 ===================================================================
2033 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_win32.h,v
2034 retrieving revision 1.1
2035 diff -u -r1.1 os_win32.h
2036 --- src/support/os_win32.h      22 Jan 2005 15:36:53 -0000      1.1
2037 +++ src/support/os_win32.h      25 Jan 2005 12:40:09 -0000
2038 @@ -65,16 +65,6 @@
2039  #define O_NONBLOCK      0x4000
2040  inline int fcntl (int, int, ...) {return -1;}
2041  
2042 -//signal.h
2043 -#define SIGHUP 1
2044 -#define SIGKILL 9
2045 -
2046 -//sys/time.h
2047 -//struct timeval {
2048 -//  long tv_sec;
2049 -//  long tv_usec;
2050 -//};
2051 -
2052  //unistd.h
2053  inline int fork () {return -1;}
2054  #define pipe(a) _pipe(a,0,0)
2055 Index: src/support/rmdir.C
2056 ===================================================================
2057 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/rmdir.C,v
2058 retrieving revision 1.8
2059 diff -u -r1.8 rmdir.C
2060 --- src/support/rmdir.C 20 Jan 2005 15:38:14 -0000      1.8
2061 +++ src/support/rmdir.C 25 Jan 2005 12:13:39 -0000
2062 @@ -16,7 +16,15 @@
2063  # include <unistd.h>
2064  #endif
2065  
2066 +#ifdef _WIN32
2067 +# include <windows.h>
2068 +#endif
2069 +
2070  int lyx::support::rmdir(std::string const & dir)
2071  {
2072 -       return ::rmdir(dir.c_str());
2073 +#ifdef _WIN32
2074 +       return ::RemoveDirectory(dir.c_str()) != 0 ? 0 : -1;
2075 +#else
2076 +       return :rmdir(dir.c_str());
2077 +#endif
2078  }
2079 Index: src/support/socktools.C
2080 ===================================================================
2081 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/socktools.C,v
2082 retrieving revision 1.6
2083 diff -u -r1.6 socktools.C
2084 --- src/support/socktools.C     20 Jan 2005 15:38:14 -0000      1.6
2085 +++ src/support/socktools.C     21 Jan 2005 09:43:42 -0000
2086 @@ -15,8 +15,10 @@
2087  
2088  #include "debug.h"
2089  
2090 +#ifndef _WIN32
2091  #include <sys/socket.h>
2092  #include <sys/un.h>
2093 +#endif
2094  #include <fcntl.h>
2095  #ifdef HAVE_UNISTD_H
2096  # include <unistd.h>
2097 @@ -48,6 +50,7 @@
2098  // special file 'name' will be created in the filesystem.
2099  int listen(string const & name, int queue)
2100  {
2101 +#ifndef _WIN32
2102         int fd; // File descriptor for the socket
2103         sockaddr_un addr; // Structure that hold the socket address
2104  
2105 @@ -105,14 +108,17 @@
2106                 lyx::support::unlink(name);
2107                 return -1;
2108         }
2109 -
2110         return fd;
2111 +#else
2112 +       return -1;
2113 +#endif
2114  }
2115  
2116  // Returns a file descriptor for a new connection from the socket
2117  // descriptor 'sd' (or -1 in case of error)
2118  int accept(int sd)
2119  {
2120 +#ifndef _WIN32
2121         int fd;
2122  
2123         // Returns the new file descriptor or -1 in case of error
2124 @@ -132,6 +138,9 @@
2125                 return -1;
2126         }
2127         return fd;
2128 +#else
2129 +       return -1;
2130 +#endif
2131  }
2132  
2133  } // namespace socktools
2134 Index: src/support/tempname.C
2135 ===================================================================
2136 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/tempname.C,v
2137 retrieving revision 1.25
2138 diff -u -r1.25 tempname.C
2139 --- src/support/tempname.C      20 Jan 2005 15:38:14 -0000      1.25
2140 +++ src/support/tempname.C      24 Jan 2005 07:51:08 -0000
2141 @@ -30,6 +30,10 @@
2142  # include <sys/stat.h>
2143  #endif
2144  
2145 +#ifdef _WIN32
2146 +# include <io.h>
2147 +#endif
2148 +
2149  using boost::scoped_array;
2150  
2151  using std::string;
2152 @@ -42,6 +46,9 @@
2153  {
2154  #if defined(HAVE_MKSTEMP)
2155         return ::mkstemp(templ);
2156 +#elif defined(_WIN32)
2157 +       ::_mktemp(templ);
2158 +       return (int) ::fopen(templ, "w");
2159  #elif defined(HAVE_MKTEMP)
2160         // This probably just barely works...
2161         ::mktemp(templ);
2162 @@ -58,7 +65,9 @@
2163  {
2164         string const tmpdir(dir.empty() ? package().temp_dir() : dir);
2165         string tmpfl(AddName(tmpdir, mask));
2166 +#ifndef _WIN32
2167         tmpfl += convert<string>(getpid());
2168 +#endif
2169         tmpfl += "XXXXXX";
2170  
2171         // The supposedly safe mkstemp version
2172 @@ -69,7 +78,11 @@
2173         int const tmpf = make_tempfile(tmpl.get());
2174         if (tmpf != -1) {
2175                 string const t(tmpl.get());
2176 +#ifdef _WIN32
2177 +               ::fclose((FILE *) tmpf);
2178 +#else
2179                 ::close(tmpf);
2180 +#endif
2181                 lyxerr[Debug::FILES] << "Temporary file `" << t
2182                                      << "' created." << endl;
2183                 return t;
2184 Index: src/support/userinfo.C
2185 ===================================================================
2186 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/userinfo.C,v
2187 retrieving revision 1.9
2188 diff -u -r1.9 userinfo.C
2189 --- src/support/userinfo.C      20 Jan 2005 15:38:14 -0000      1.9
2190 +++ src/support/userinfo.C      21 Jan 2005 09:43:42 -0000
2191 @@ -15,7 +15,9 @@
2192  
2193  #include <boost/assert.hpp>
2194  
2195 -#include <pwd.h>
2196 +#ifndef _WIN32
2197 +# include <pwd.h>
2198 +#endif
2199  #ifdef HAVE_UNISTD_H
2200  # include <unistd.h>
2201  #endif
2202 @@ -28,6 +30,7 @@
2203  
2204  string const user_name()
2205  {
2206 +#ifndef _WIN32
2207         struct passwd * pw(getpwuid(geteuid()));
2208         BOOST_ASSERT(pw);
2209  
2210 @@ -35,6 +38,9 @@
2211         if (name.empty())
2212                 name = pw->pw_name;
2213         return name;
2214 +#else
2215 +       return "dummy";
2216 +#endif
2217  }
2218  
2219