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
13 -LyXText * BufferView::getLyXText() const
14 +LyXText * BufferView::getLyXText()
16 LyXText * text = cursor().innerText();
22 +LyXText const * BufferView::getLyXText() const
24 + LyXText const * text = cursor().innerText();
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
36 Change const getCurrentChange();
38 /// return the lyxtext we are using
39 - LyXText * getLyXText() const;
40 + LyXText * getLyXText();
42 + /// return the lyxtext we are using
43 + LyXText const * getLyXText() const;
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
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;
61 if (!lyxrc.cursor_follows_scrollbar)
65 std::swap(theCoords, backup);
66 + theCoords.startUpdating();
68 ViewMetricsInfo vi = metrics();
72 // second drawing step
73 screen().redraw(*bv_, vi);
75 + theCoords.doneUpdating();
77 + // Abort updating of the coord cache - just restore the old one
78 std::swap(theCoords, backup);
85 void BufferView::Pimpl::center()
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];
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();
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
111 #ifndef CXX_GLOBAL_CSTD
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
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
134 typedef std::vector<Row> RowList;
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
145 #include <boost/bind.hpp>
146 #include <boost/filesystem/operations.hpp>
150 +# include <windows.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
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.
178 + * I am not sure if the class is complete or
179 + * minimal, probably not.
180 + * \author Lars Gullik Bjønnes
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
192 Point getPos(DocIterator const & dit)
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;
203 // this could be used elsewhere as well?
204 CurStatus status(BufferView const * bv, DocIterator const & dit)
206 - CoordCache::InnerParPosCache & cache = theCoords.pars_[dit.bottom().text()];
207 + CoordCache::InnerParPosCache const & cache = theCoords.getParPos().find(dit.bottom().text())->second;
209 if (cache.find(dit.bottom().pit()) != cache.end())
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
222 -void lyxaborter(int x, int y)
224 - lyxerr << "abort on x: " << x << " y: " << y << std::endl;
225 - BOOST_ASSERT(false);
229 void CoordCache::clear()
231 + BOOST_ASSERT(updating);
237 +void CoordCache::startUpdating() {
238 + BOOST_ASSERT(!updating);
243 +void CoordCache::doneUpdating() {
244 + BOOST_ASSERT(updating);
248 Point CoordCache::get(LyXText const * text, lyx::pit_type pit)
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
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.
266 void lyxbreaker(void const * data, const char * hint, int size);
267 -void lyxaborter(int x, int y);
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.
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();
295 Point get(LyXText const *, lyx::pit_type);
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;
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_; }
312 CoordCacheBase<MathArray> arrays_;
315 CoordCacheBase<InsetBase> insets_;
317 // paragraph grouped by owning text
318 - typedef std::map<lyx::pit_type, Point> InnerParPosCache;
319 - typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
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.
329 extern CoordCache theCoords;
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
340 #ifndef CXX_GLOBAL_CSTD
347 @@ -1086,7 +1088,7 @@
348 if (operator[](s).text())
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())
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(),
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
376 -LyXText * CursorSlice::text() const
377 +LyXText * CursorSlice::text()
379 + BOOST_ASSERT(inset_);
380 + return inset_->getText(idx_);
383 +LyXText const * CursorSlice::text() const
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
395 /// see comment for the member
396 bool & boundary() { return boundary_; }
398 - LyXText * text() const;
401 + LyXText const * text() const;
403 UpdatableInset * asUpdatableInset() const;
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
416 -LyXText * DocIterator::text() const
417 +LyXText * DocIterator::text()
419 + BOOST_ASSERT(!empty());
420 + return top().text();
423 +LyXText const * DocIterator::text() const
425 BOOST_ASSERT(!empty());
427 @@ -146,12 +152,14 @@
429 Row & DocIterator::textRow()
431 + BOOST_ASSERT(!paragraph().rows().empty());
432 return paragraph().getRow(pos());
436 Row const & DocIterator::textRow() const
438 + BOOST_ASSERT(!paragraph().rows().empty());
439 return paragraph().getRow(pos());
446 -LyXText * DocIterator::innerText() const
447 +LyXText * DocIterator::innerText()
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();
458 +LyXText const * DocIterator::innerText() const
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;
473 - LyXText * text() const;
476 + LyXText const * text() const;
478 InsetBase * innerInsetOfType(int code) const;
480 - LyXText * innerText() const;
481 + LyXText * innerText();
483 + LyXText const * innerText() const;
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
496 #include "support/forkedcall.h"
499 +# include "support/os_win32.h"
502 // HP-UX 11.x doesn't have this header
503 #ifdef HAVE_SYS_SELECT_H
504 #include <sys/select.h>
506 -#include <sys/time.h>
508 +# include <sys/time.h>
511 using boost::shared_ptr;
518 dup2(pipein[0], STDIN_FILENO);
519 dup2(pipeout[1], STDOUT_FILENO);
520 dup2(pipeerr[1], STDERR_FILENO);
523 lyxerr << "LyX: Failed to start ispell!" << endl;
531 lyxerr[Debug::GUI] << "Created ispell" << endl;
534 // static due to the setvbuf. Ugly.
535 static char o_buf[BUFSIZ];
545 @@ -295,18 +305,23 @@
561 bool ISpell::select(bool & err_read)
569 @@ -316,11 +331,15 @@
574 retval = ::select(SELECT_TYPE_ARG1 (max(pipeout[0], pipeerr[0]) + 1),
575 SELECT_TYPE_ARG234 (&infds),
578 SELECT_TYPE_ARG5 (&tv));
586 fgets(buf, BUFSIZ, in);
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
601 #include "support/path.h"
602 #include "support/systemcall.h"
605 +# include "support/os_win32.h" // fork()
608 #include <boost/shared_ptr.hpp>
609 #include <boost/filesystem/operations.hpp>
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
622 +#include <fstream> // for std::filebuf
625 class LyXLex::Pimpl : boost::noncopyable {
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
635 #include "support/types.h"
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.
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
654 #include <sys/stat.h>
658 +# include "support/os_win32.h" // F_SETFL, O_NONBLOCK, fcntl
665 // Imported handles can be used both with OS/2 APIs and emx
666 // library functions.
667 fd = _imphandle(os2fd);
668 +#elif defined(_WIN32)
671 if (::access(filename.c_str(), F_OK) == 0) {
672 lyxerr << "LyXComm: Pipe " << filename << " already exists.\n"
673 @@ -236,10 +242,12 @@
678 if (::close(fd) < 0) {
679 lyxerr << "LyXComm: Could not close pipe " << filename
680 << '\n' << strerror(errno) << endl;
684 // OS/2 pipes are deleted automatically
689 // the single = is intended here.
690 - while ((status = ::read(infd, charbuf, charbuf_size - 1))) {
693 + ::read(infd, charbuf, charbuf_size - 1)
700 charbuf[status] = '\0'; // turn it into a c string
703 if (pipename.empty()) return;
709 lyxerr << "LyXComm: Pipes are closed. Could not send "
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
727 LyXServerSocket::~LyXServerSocket()
729 lyx_gui::unregister_socket_callback(fd_);
733 lyx::support::unlink(address_);
734 lyxerr[Debug::LYXSERVER] << "lyx: Server socket quitting" << endl;
738 string const linen(line + '\n');
739 int const size = linen.size();
741 int const written = ::write(fd_, linen.c_str(), size);
743 + int const written = -1;
745 if (written < size) { // Allways mean end of connection.
746 if ((written == -1) && (errno == EPIPE)) {
747 // The program will also receive a SIGPIPE
750 LyXDataSocket::~LyXDataSocket()
756 lyx_gui::unregister_socket_callback(fd_);
757 lyxerr[Debug::LYXSERVER] << "lyx: Data socket " << fd_ << " quitting."
761 // read and store characters in buffer
762 - while ((count = ::read(fd_, charbuf, charbuf_size - 1)) > 0) {
765 + ::read(fd_, charbuf, charbuf_size - 1)
770 buffer_.append(charbuf, charbuf + count);
775 string const linen(line + '\n');
776 int const size = linen.size();
778 int const written = ::write(fd_, linen.c_str(), size);
780 + int const written = -1;
782 if (written < size) { // Allways mean end of connection.
783 if ((written == -1) && (errno == EPIPE)) {
784 // The program will also receive a SIGPIPE
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
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);
799 /// set layout over selection
800 pit_type setLayout(pit_type start, pit_type end,
802 FuncStatus & status) const;
804 /// access to out BufferView. This should go...
806 +// BufferView * bv();
807 /// access to out BufferView. This should go...
808 BufferView * bv() const;
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 @@
819 Row & Paragraph::getRow(pos_type pos)
821 + BOOST_ASSERT(!rows().empty());
823 RowList::iterator rit = rows_.end();
824 RowList::iterator const begin = rows_.begin();
826 @@ -1807,6 +1809,8 @@
828 Row const & Paragraph::getRow(pos_type pos) const
830 + BOOST_ASSERT(!rows().empty());
832 RowList::const_iterator rit = rows_.end();
833 RowList::const_iterator const begin = rows_.begin();
835 @@ -1819,6 +1823,8 @@
837 size_t Paragraph::pos2row(pos_type pos) const
839 + BOOST_ASSERT(!rows().empty());
841 RowList::const_iterator rit = rows_.end();
842 RowList::const_iterator const begin = rows_.begin();
844 @@ -1873,11 +1879,3 @@
848 -//void Paragraph::metrics(MetricsInfo & mi, Dimension & dim, LyXText & text)
853 -//void draw(PainterInfo & pi, int x, int y, LyXText & text) const
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
864 lyx::depth_type depth) const;
866 /// Can we drop the standard paragraph wrapper?
867 - bool Paragraph::emptyTag() const;
868 + bool emptyTag() const;
870 /// Get the id of the paragraph, usefull for docbook and linuxdoc
871 std::string getID(Buffer const & buf,
873 BOOST_ASSERT(pos < int(text_.size()));
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);
882 InsetBase * getInset(lyx::pos_type pos);
884 InsetBase const * getInset(lyx::pos_type pos) const;
886 + InsetList insetlist;
890 bool isHfill(lyx::pos_type pos) const;
892 /// returns -1 if inset not found
893 int getPositionOfInset(InsetBase const * inset) const;
896 + /// Returns the number of line breaks and white-space stripped at the start
897 int stripLeadingSpaces();
899 /// return true if we allow multiple spaces
902 /// return true if we allow this par to stay empty
903 bool allowEmpty() const;
906 unsigned char transformChar(unsigned char c, lyx::pos_type pos) const;
908 ParagraphParameters & params();
909 @@ -366,37 +369,34 @@
911 size_t pos2row(lyx::pos_type pos) const;
914 - InsetList insetlist;
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(); }
923 + /// LyXText updates the rows using this access point
924 RowList & rows() { return rows_; }
926 + /// The painter and others use this
927 RowList const & rows() const { return rows_; }
929 - // compute paragraph metrics
930 - void metrics(MetricsInfo & mi, Dimension & dim, LyXText & text);
932 - void draw(PainterInfo & pi, int x, int y, LyXText & text) const;
933 - /// dump some information
935 + /// LyXText::redoParagraph updates this
936 + Dimension & dim() { return dim_; }
938 + /// dump some information to lyxerr
941 /// cached dimensions of paragraph
946 mutable RowList rows_;
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.
952 + * Keeping this here instead of in the pimpl makes LyX >10% faster
953 + * for average tasks as buffer loading/switching etc.
957 lyx::pos_type begin_of_body_;
959 friend class Paragraph::Pimpl;
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
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
988 void breakParagraph(BufferParams const & bparams,
989 ParagraphList & paragraphs,
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
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);
1005 // paint various parts
1006 void paintAppendix();
1008 ParagraphList & pars_;
1010 /// The row to paint
1015 pit_type const pit_;
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())
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 @@
1036 Paragraph & par = text.paragraphs()[pit];
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);
1046 - for (RowList::iterator rit = rb; rit != re; ++rit) {
1047 + for (RowList::const_iterator rit = rb; rit != re; ++rit) {
1049 bool const inside = (y + rit->descent() >= 0
1050 && y - rit->ascent() < ww);
1051 @@ -801,12 +801,12 @@
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;
1058 pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
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);
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 @@
1077 -BufferView * LyXText::bv()
1079 - BOOST_ASSERT(bv_owner != 0);
1084 BufferView * LyXText::bv() const
1086 @@ -1017,7 +1011,7 @@
1090 -void LyXText::breakParagraph(LCursor & cur, char keep_layout)
1091 +void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
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());
1099 - // break the paragraph
1100 + // How should the layout for the new paragraph be?
1101 + int preserve_layout = 0;
1104 + preserve_layout = 2;
1106 - keep_layout = layout->isEnvironment();
1107 + preserve_layout = layout->isEnvironment();
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;
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();
1120 ::breakParagraph(cur.buffer().params(), paragraphs(), cpit,
1121 - cur.pos(), keep_layout);
1122 + cur.pos(), preserve_layout);
1124 + // After this, neither paragraph contains any rows!
1127 pit_type next_par = cpit + 1;
1129 // well this is the caption hack since one caption is really enough
1130 - if (layout->labeltype == LABEL_SENSITIVE) {
1133 // set to standard-layout
1134 pars_[cpit].applyLayout(tclass.defaultLayout());
1135 @@ -1072,16 +1071,6 @@
1136 pars_[next_par].applyLayout(tclass.defaultLayout());
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))
1149 while (!pars_[next_par].empty() && pars_[next_par].isNewline(0))
1150 pars_[next_par].erase(0);
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;
1160 BOOST_ASSERT(cur.pos() > 0);
1161 if (par.isLineSeparator(cur.pos() - 1)
1162 @@ -1686,7 +1675,7 @@
1164 dim.asc += par.rows()[0].ascent();
1165 dim.des -= par.rows()[0].ascent();
1168 //lyxerr << "redoParagraph: " << par.rows().size() << " rows\n";
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
1179 InsetBase * inset = iit->inset;
1181 lyxerr << "examining inset " << inset << endl;
1182 - if (theCoords.insets_.has(inset))
1183 + if (theCoords.getInsets().has(inset))
1185 << " xo: " << inset->xo() << "..."
1186 << inset->xo() + inset->width()
1187 @@ -1122,8 +1122,8 @@
1188 pit_type LyXText::getPitNearY(int y) const
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;
1198 @@ -1282,8 +1282,6 @@
1200 void LyXText::cursorDown(LCursor & cur)
1204 Paragraph const & par = cur.paragraph();
1205 int const row = par.pos2row(cur.pos());
1206 int const x = cur.targetX();
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
1215 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
1217 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
1218 - //lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl;
1219 + lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl;
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
1231 # include <unistd.h>
1236 -#include <sys/select.h>
1237 +# include <sys/select.h>
1239 // socket(), connect()
1240 -#include <sys/socket.h>
1241 -#include <sys/un.h>
1242 +# include <sys/socket.h>
1243 +# include <sys/un.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
1257 #include <boost/bind.hpp>
1259 -#include <sys/time.h>
1261 +# include <sys/time.h>
1263 #ifdef HAVE_UNISTD_H
1264 # include <unistd.h>
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
1274 #define QDIALOGVIEW_H
1278 #include <boost/scoped_ptr.hpp>
1280 #include <qapplication.h>
1281 @@ -110,7 +111,11 @@
1282 template <class GUIDialog>
1283 QDialog * QView<GUIDialog>::form() const
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();
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
1303 size_t ls = s.length();
1304 for (size_t i = 0; i < ls; ++i) {
1305 - QChar const c = s[i].upper();
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);
1314 #if QT_VERSION >= 300
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)
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
1334 -class Q_EXPORT LengthValidator : public QValidator
1335 +class LengthValidator : public QValidator
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
1347 void InsetOld::setPosCache(PainterInfo const &, int x, int y) const
1349 //lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
1350 - theCoords.insets_.add(this, x, y);
1351 + theCoords.insets().add(this, x, y);
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 @@
1362 int InsetBase::xo() const
1364 - return theCoords.insets_.x(this);
1365 + return theCoords.getInsets().x(this);
1369 int InsetBase::yo() const
1371 - return theCoords.insets_.y(this);
1372 + return theCoords.getInsets().y(this);
1377 // << " x1: " << xo() << " x2: " << xo() + width()
1378 // << " y1: " << yo() - ascent() << " y2: " << yo() + descent()
1380 - return theCoords.insets_.has(this)
1381 + return theCoords.getInsets().has(this)
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 @@
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_;
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);
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
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;
1425 if (tmp_xo_ > 0 && tmp_xo_ + width() < workW)
1428 void UpdatableInset::scroll(BufferView & bv, int offset) const
1430 - int const xo_ = theCoords.insets_.x(this);
1431 + int const xo_ = theCoords.getInsets().x(this);
1433 if (!scx && xo_ >= 20)
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
1445 //lyxerr << "setting position cache for MathArray " << this << std::endl;
1446 - theCoords.arrays_.add(this, x, y);
1447 + theCoords.arrays().add(this, x, y);
1451 int MathArray::xo() const
1453 - return theCoords.arrays_.x(this);
1454 + return theCoords.getArrays().x(this);
1458 int MathArray::yo() const
1460 - return theCoords.arrays_.y(this);
1461 + return theCoords.getArrays().y(this);
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
1471 void MathDimInset::setPosCache(PainterInfo const &, int x, int y) const
1473 //lyxerr << "MathDimInset: cache to " << x << " " << y << std::endl;
1474 - theCoords.insets_.add(this, x, y);
1475 + theCoords.insets().add(this, x, y);
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;
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)) {
1503 //lyxerr << "no cached data for inset " << this << endl;
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
1521 # include <unistd.h>
1525 +# include <windows.h>
1528 int lyx::support::chdir(std::string const & name)
1531 - return ::chdir(name.c_str());
1534 return ::_chdir2(name.c_str());
1535 +#elif defined(_WIN32)
1536 + return SetCurrentDirectory(name.c_str()) != 0 ? 0 : -1;
1538 + return ::chdir(name.c_str());
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 @@
1550 cmd_ret const RunCommand(string const & cmd)
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());
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);
1563 return make_pair(pret, ret);
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
1576 #include "support/lyxlib.h"
1577 #include "support/filetools.h"
1578 #include "support/os.h"
1580 +#include "os_win32.h"
1581 +#include <process.h>
1589 #include <sys/types.h>
1590 -#include <sys/wait.h>
1592 +# include <sys/wait.h>
1594 #ifdef HAVE_UNISTD_H
1595 # include <unistd.h>
1599 new Murder(secs, pid);
1600 } else if (pid != 0) {
1602 lyx::support::kill(pid, SIGKILL);
1612 lyx::support::kill(pid_, SIGKILL);
1615 lyxerr << "Killed " << pid_ << std::endl;
1617 @@ -152,14 +162,16 @@
1622 // Un-UNIX like, but we don't have much use for
1623 // knowing if a zombie exists, so just reap it first.
1625 waitpid(pid(), &waitstatus, WNOHANG);
1627 // Racy of course, but it will do.
1628 - if (::kill(pid(), 0) && errno == ESRCH)
1629 + if (lyx::kill(pid(), 0) && errno == ESRCH)
1636 Murder::killItDead(0, pid());
1640 int ret = lyx::support::kill(pid(), SIGHUP);
1642 // The process is already dead if wait_for_death is false
1644 if (wait_for_death) {
1645 Murder::killItDead(tolerance, pid());
1653 // We'll pretend that the child returns 1 on all error conditions.
1667 @@ -299,7 +315,12 @@
1668 std::cout << *ait << std::endl;
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());
1678 pid_t const cpid = ::fork();
1682 << strerror(errno) << endl;
1686 - pid_t const cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND,
1687 - argv[0], &*argv.begin());
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
1700 #include <sys/types.h>
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
1721 +#include "os_win32.h"
1722 +#include <windows.h>
1725 #include <boost/bind.hpp>
1730 #ifdef HAVE_UNISTD_H
1731 # include <unistd.h>
1733 -#include <sys/wait.h>
1735 +# include <sys/wait.h>
1741 ForkedcallsController::Data & store =
1742 fcc.reaped_children[++fcc.current_child];
1743 // Clean up the child process.
1745 store.pid = wait(&store.status);
1750 @@ -193,11 +203,12 @@
1751 ForkedcallsController::ForkedcallsController()
1752 : reaped_children(50), current_child(-1)
1755 signal(SIGCHLD, child_handler);
1757 sigemptyset(&oldMask);
1758 sigemptyset(&newMask);
1759 sigaddset(&newMask, SIGCHLD);
1765 // I want to print or something.
1766 ForkedcallsController::~ForkedcallsController()
1769 signal(SIGCHLD, SIG_DFL);
1775 forkedCalls.push_back(newcall.clone());
1777 if (forkedCalls.size() > reaped_children.size()) {
1779 // Block the SIGCHLD signal.
1780 sigprocmask(SIG_BLOCK, &newMask, &oldMask);
1784 // Unblock the SIGCHLD signal and restore the old mask.
1785 sigprocmask(SIG_SETMASK, &oldMask, 0);
1790 @@ -255,8 +270,10 @@
1791 if (current_child == -1)
1795 // Block the SIGCHLD signal.
1796 sigprocmask(SIG_BLOCK, &newMask, &oldMask);
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
1806 // Unblock the SIGCHLD signal and restore the old mask.
1807 sigprocmask(SIG_SETMASK, &oldMask, 0);
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
1820 #include <boost/shared_ptr.hpp>
1823 -//#include <sys/types.h> // needed for pid_t
1827 +#include <sys/types.h> // needed for pid_t
1832 /// The child processes
1833 ListType forkedCalls;
1836 /// Used to block SIGCHLD signals.
1837 sigset_t newMask, oldMask;
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
1853 +#ifdef BOOST_WINDOWS
1854 +# include <windows.h>
1857 namespace fs = boost::filesystem;
1862 return ::access(ph.string().c_str(), R_OK) == 0;
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;
1875 return ::access(ph.string().c_str(), W_OK) == 0;
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
1883 + return attr != INVALID_FILE_ATTRIBUTES &&
1884 + ( attr & FILE_ATTRIBUTE_DIRECTORY ) != FILE_ATTRIBUTE_DIRECTORY;
1889 bool is_readonly(path const & ph)
1892 return is_readable(ph) && !is_writable(ph);
1897 @@ -115,6 +132,16 @@
1898 "boost::filesystem::copy_file",
1900 fs::detail::system_error_code()));
1903 +#ifdef BOOST_WINDOWS
1904 + if (::CopyFile(source.string().c_str(), target.string().c_str(), FALSE) == 0) {
1905 + boost::throw_exception(
1907 + "boost::filesystem::copy_file",
1909 + fs::detail::system_error_code()));
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
1922 # include <unistd.h>
1926 +# include <windows.h>
1929 using boost::scoped_array;
1934 char * l_getcwd(char * buffer, size_t size)
1937 - return ::getcwd(buffer, size);
1940 return ::_getcwd2(buffer, size);
1941 +#elif defined(_WIN32)
1942 + GetCurrentDirectory(size, buffer);
1945 + return ::getcwd(buffer, size);
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
1957 #include <sys/types.h>
1964 +#include <windows.h>
1970 int lyx::support::kill(int pid, int sig)
1973 + if (pid == (int)GetCurrentProcessId()) {
1974 + return -(raise(sig));
1976 + HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
1978 + lyxerr << "kill OpenProcess failed!" << endl;
1981 + if (!TerminateProcess(hProcess, sig)){
1982 + lyxerr << "kill process failed!" << endl;
1983 + CloseHandle(hProcess);
1986 + CloseHandle(hProcess);
1992 return ::kill(pid, sig);
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
2003 #ifdef HAVE_UNISTD_H
2004 # include <unistd.h>
2007 +# include <Windows.h>
2010 int lyx::support::mkdir(std::string const & pathname, unsigned long int mode)
2014 return ::mkdir(pathname.c_str(), mode_t(mode));
2018 +#elif defined(_WIN32)
2020 - return ::_mkdir(pathname.c_str());
2022 -# error "Don't know how to create a directory on this system."
2024 + return CreateDirectory(pathname.c_str(), 0) != 0 ? 0 : -1;
2026 + return ::_mkdir(pathname.c_str());
2028 +# error "Don't know how to create a directory on this system."
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
2039 #define O_NONBLOCK 0x4000
2040 inline int fcntl (int, int, ...) {return -1;}
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
2063 # include <unistd.h>
2067 +# include <windows.h>
2070 int lyx::support::rmdir(std::string const & dir)
2072 - return ::rmdir(dir.c_str());
2074 + return ::RemoveDirectory(dir.c_str()) != 0 ? 0 : -1;
2076 + return :rmdir(dir.c_str());
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
2091 #include <sys/socket.h>
2095 #ifdef HAVE_UNISTD_H
2096 # include <unistd.h>
2098 // special file 'name' will be created in the filesystem.
2099 int listen(string const & name, int queue)
2102 int fd; // File descriptor for the socket
2103 sockaddr_un addr; // Structure that hold the socket address
2105 @@ -105,14 +108,17 @@
2106 lyx::support::unlink(name);
2116 // Returns a file descriptor for a new connection from the socket
2117 // descriptor 'sd' (or -1 in case of error)
2123 // Returns the new file descriptor or -1 in case of error
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
2142 # include <sys/stat.h>
2149 using boost::scoped_array;
2154 #if defined(HAVE_MKSTEMP)
2155 return ::mkstemp(templ);
2156 +#elif defined(_WIN32)
2158 + return (int) ::fopen(templ, "w");
2159 #elif defined(HAVE_MKTEMP)
2160 // This probably just barely works...
2164 string const tmpdir(dir.empty() ? package().temp_dir() : dir);
2165 string tmpfl(AddName(tmpdir, mask));
2167 tmpfl += convert<string>(getpid());
2171 // The supposedly safe mkstemp version
2173 int const tmpf = make_tempfile(tmpl.get());
2175 string const t(tmpl.get());
2177 + ::fclose((FILE *) tmpf);
2181 lyxerr[Debug::FILES] << "Temporary file `" << t
2182 << "' created." << endl;
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
2193 #include <boost/assert.hpp>
2199 #ifdef HAVE_UNISTD_H
2200 # include <unistd.h>
2204 string const user_name()
2207 struct passwd * pw(getpwuid(geteuid()));