mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
some important changes to FIX_DOUBLE_SPCE still not completely correct (please help out.) Some external functions called from wrappers. use MODERN_STL_STREAMS in lyxsum.C
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@423 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
722d679779
commit
c36aa67f7b
23
ChangeLog
23
ChangeLog
@ -1,3 +1,26 @@
|
||||
2000-01-14 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/support/date.C: new file
|
||||
|
||||
* src/support/chdir.C: new file
|
||||
|
||||
* src/support/getUserName.C: new file
|
||||
|
||||
* src/support/getcwd.C: new file
|
||||
|
||||
* src/support/abort.C: new file
|
||||
|
||||
* src/support/kill.C: new file
|
||||
|
||||
* src/support/lyxlib.h: moved all the functions in this file
|
||||
insede struct lyx. Added also kill and abort to this struct. This
|
||||
is a way to avoid the "kill is not defined in <csignal>", we make
|
||||
C++ wrappers for functions that are not ANSI C or ANSI C++.
|
||||
|
||||
* src/support/lyxsum.C (sum): use #ifdef MODERN_STL_STREAMS
|
||||
instead of #if __GLIBCPP__. Since lyxsum is now put inside struct
|
||||
lyx it has been renamed to sum.
|
||||
|
||||
2000-01-14 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* src/text.C: add using directives for std::min and std::max.
|
||||
|
@ -35,7 +35,7 @@ void DepTable::insert(string const & fi,
|
||||
if (deplist.find(f) == deplist.end()) {
|
||||
if (upd) {
|
||||
one = two;
|
||||
two = lyxsum(f.c_str());
|
||||
two = lyx::sum(f.c_str());
|
||||
}
|
||||
deplist[f] = make_pair(one, two);
|
||||
}
|
||||
@ -48,7 +48,7 @@ void DepTable::update()
|
||||
itr != deplist.end();
|
||||
++itr) {
|
||||
unsigned long one = (*itr).second.second;
|
||||
unsigned long two = lyxsum((*itr).first.c_str());
|
||||
unsigned long two = lyx::sum((*itr).first.c_str());
|
||||
(*itr).second = make_pair(one, two);
|
||||
if (lyxerr.debugging()) {
|
||||
lyxerr << "update: " << (*itr).first << " "
|
||||
|
@ -1588,7 +1588,7 @@ void Buffer::makeLaTeXFile(string const & fname,
|
||||
// first paragraph of the document. (Asger)
|
||||
texrow.start(paragraph, 0);
|
||||
|
||||
string userName(getUserName());
|
||||
string userName(lyx::getUserName());
|
||||
string LFile;
|
||||
|
||||
if (!only_body && nice) {
|
||||
@ -2146,9 +2146,9 @@ void Buffer::makeLinuxDocFile(string const & fname, int column)
|
||||
<< params.preamble << " \n]>\n\n";
|
||||
}
|
||||
|
||||
string userName(getUserName());
|
||||
string userName(lyx::getUserName());
|
||||
ofs << "<!-- LinuxDoc file was created by LyX 1.0 (C) 1995-1999 "
|
||||
<< "by <" << userName << "> " << date() << " -->\n";
|
||||
<< "by <" << userName << "> " << lyx::date() << " -->\n";
|
||||
|
||||
if(params.options.empty())
|
||||
sgmlOpenTag(ofs, 0, top_element);
|
||||
|
@ -57,6 +57,7 @@ using std::ifstream;
|
||||
#include "gettext.h"
|
||||
#include "lyx_gui_misc.h" // CancelCloseBoxCB
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
extern BufferView * current_view;
|
||||
#if 0
|
||||
@ -260,7 +261,7 @@ extern "C" int GhostscriptMsg(FL_OBJECT *, Window, int, int,
|
||||
lyxerr << "Killing gs "
|
||||
<< p->gspid << endl;
|
||||
}
|
||||
kill(p->gspid, SIGHUP);
|
||||
lyx::kill(p->gspid, SIGHUP);
|
||||
|
||||
sprintf(tmp, "%s/~lyxgs%d.ps",
|
||||
system_tempdir.c_str(),
|
||||
@ -275,7 +276,7 @@ extern "C" int GhostscriptMsg(FL_OBJECT *, Window, int, int,
|
||||
lyxerr << "Killing gs "
|
||||
<< p->gspid << endl;
|
||||
}
|
||||
kill(p->gspid, SIGHUP);
|
||||
lyx::kill(p->gspid, SIGHUP);
|
||||
|
||||
sprintf(tmp, "%s/~lyxgs%d.ps",
|
||||
system_tempdir.c_str(),
|
||||
@ -472,7 +473,7 @@ static void freefigdata(figdata * tmpdata)
|
||||
chpixmap(tmpdata->bitmap, tmpdata->wid, tmpdata->hgh);
|
||||
// kill ghostscript and unlink it's files
|
||||
tmpdata->gspid = -1;
|
||||
kill(pid, SIGKILL);
|
||||
lyx::kill(pid, SIGKILL);
|
||||
sprintf(buf, "%s/~lyxgs%d.ps", system_tempdir.c_str(), pid);
|
||||
unlink(buf);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ extern "C" int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
|
||||
XGetErrorText(display, xeev->error_code, etxt, 512);
|
||||
lyxerr << etxt << endl;
|
||||
// By doing an abort we get a nice backtrace. (hopefully)
|
||||
abort();
|
||||
lyx::abort();
|
||||
return 0; // Solaris CC wants us to return something
|
||||
}
|
||||
|
||||
|
@ -615,6 +615,6 @@ void error_handler(int err_sig)
|
||||
|
||||
lyxerr << "Bye." << endl;
|
||||
if(err_sig!= SIGHUP && (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))
|
||||
abort();
|
||||
lyx::abort();
|
||||
exit(0);
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
#ifndef LASSERT_H
|
||||
#define LASSERT_H
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
//namespace LyX {
|
||||
|
||||
#ifdef ENABLE_ASSERTIONS
|
||||
@ -11,7 +13,7 @@ template<class A> inline void Assert(A assertion)
|
||||
{
|
||||
//if (!assertion) throw X();
|
||||
if (!assertion) {
|
||||
abort();
|
||||
lyx::abort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +26,7 @@ template<class A> inline void Assert(A * ptr)
|
||||
template<> inline void Assert(void const * ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
abort();
|
||||
lyx::abort();
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_PARTIAL_SPECIALIZATION */
|
||||
|
@ -23,9 +23,15 @@ libsupport_la_SOURCES = \
|
||||
LRegex.h \
|
||||
LSubstring.C \
|
||||
LSubstring.h \
|
||||
abort.C \
|
||||
block.h \
|
||||
chdir.C \
|
||||
date.C \
|
||||
filetools.C \
|
||||
filetools.h \
|
||||
getUserName.C \
|
||||
getcwd.C \
|
||||
kill.C \
|
||||
lstrings.C \
|
||||
lstrings.h \
|
||||
lyxlib.h \
|
||||
|
10
src/support/abort.C
Normal file
10
src/support/abort.C
Normal file
@ -0,0 +1,10 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
void lyx::abort()
|
||||
{
|
||||
::abort();
|
||||
}
|
14
src/support/chdir.C
Normal file
14
src/support/chdir.C
Normal file
@ -0,0 +1,14 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
int lyx::chdir(char const * name)
|
||||
{
|
||||
#ifndef __EMX__
|
||||
return ::chdir(name);
|
||||
#else
|
||||
return ::_chdir2(name);
|
||||
#endif
|
||||
}
|
14
src/support/date.C
Normal file
14
src/support/date.C
Normal file
@ -0,0 +1,14 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
char * lyx::date()
|
||||
{
|
||||
time_t tid;
|
||||
if ((tid = ::time(0)) == static_cast<time_t>(-1))
|
||||
return 0;
|
||||
else
|
||||
return ::ctime(&tid);
|
||||
}
|
15
src/support/getUserName.C
Normal file
15
src/support/getUserName.C
Normal file
@ -0,0 +1,15 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/filetools.h"
|
||||
#include "gettext.h"
|
||||
|
||||
string lyx::getUserName()
|
||||
{
|
||||
string userName(GetEnv("LOGNAME"));
|
||||
if (userName.empty())
|
||||
userName = GetEnv("USER");
|
||||
if (userName.empty())
|
||||
userName = _("unknown");
|
||||
return userName;
|
||||
}
|
14
src/support/getcwd.C
Normal file
14
src/support/getcwd.C
Normal file
@ -0,0 +1,14 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
char * lyx::getcwd(char * buffer, size_t size)
|
||||
{
|
||||
#ifndef __EMX__
|
||||
return ::getcwd(buffer, size);
|
||||
#else
|
||||
return ::_getcwd2(buffer, size);
|
||||
#endif
|
||||
}
|
11
src/support/kill.C
Normal file
11
src/support/kill.C
Normal file
@ -0,0 +1,11 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "lyxlib.h"
|
||||
|
||||
int lyx::kill(pid_t pid, int sig)
|
||||
{
|
||||
return ::kill(pid, sig);
|
||||
}
|
@ -10,36 +10,36 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "LAssert.h"
|
||||
//#include "LAssert.h"
|
||||
|
||||
//#warning verify this please. Lgb
|
||||
///
|
||||
template<class T>
|
||||
size_t lstrlen(T const * t)
|
||||
{
|
||||
Assert(t); // we don't want null pointers
|
||||
size_t count = 0;
|
||||
T const * r = t;
|
||||
while(*r != 0) ++r, ++count;
|
||||
return count;
|
||||
}
|
||||
//template<class T>
|
||||
//size_t lstrlen(T const * t)
|
||||
//{
|
||||
// Assert(t); // we don't want null pointers
|
||||
// size_t count = 0;
|
||||
// T const * r = t;
|
||||
// while(*r != 0) ++r, ++count;
|
||||
// return count;
|
||||
//}
|
||||
|
||||
|
||||
//#warning verify this please. Lgb
|
||||
//#Warning verify this please. Lgb
|
||||
///
|
||||
template<class T>
|
||||
T * lstrchr(T const * t, int c)
|
||||
{
|
||||
Assert(t); // we don't want null pointers
|
||||
T * r = const_cast<T*>(t);
|
||||
while(*r != 0) {
|
||||
if (*r == c)
|
||||
return r;
|
||||
else
|
||||
++r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//template<class T>
|
||||
//T * lstrchr(T const * t, int c)
|
||||
//{
|
||||
// Assert(t); // we don't want null pointers
|
||||
// T * r = const_cast<T*>(t);
|
||||
// while(*r != 0) {
|
||||
// if (*r == c)
|
||||
// return r;
|
||||
// else
|
||||
// ++r;
|
||||
// }
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
#include <cctype>
|
||||
#include "LString.h"
|
||||
|
@ -12,56 +12,27 @@
|
||||
#ifndef LYX_LIB_H
|
||||
#define LYX_LIB_H
|
||||
|
||||
#include <ctime>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "LString.h"
|
||||
#include "gettext.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
/// generates an checksum
|
||||
unsigned long lyxsum(char const * file);
|
||||
|
||||
/// returns a date string
|
||||
inline char * date()
|
||||
{
|
||||
time_t tid;
|
||||
if ((tid= time(0)) == static_cast<time_t>(-1))
|
||||
return 0;
|
||||
else
|
||||
return ctime(&tid);
|
||||
}
|
||||
|
||||
|
||||
// Where can I put this? I found the occurence of the same code
|
||||
// three/four times. Don't you think it better to use a macro definition
|
||||
// (an inlined member of some class)?
|
||||
///
|
||||
inline string getUserName()
|
||||
{
|
||||
string userName(GetEnv("LOGNAME"));
|
||||
if (userName.empty())
|
||||
userName = GetEnv("USER");
|
||||
if (userName.empty())
|
||||
userName = _("unknown");
|
||||
return userName;
|
||||
}
|
||||
|
||||
// This should have been a namespace
|
||||
struct lyx {
|
||||
static char * getcwd(char * buffer, size_t size) {
|
||||
#ifndef __EMX__
|
||||
return ::getcwd(buffer, size);
|
||||
#else
|
||||
return ::_getcwd2(buffer, size);
|
||||
#endif
|
||||
};
|
||||
static int chdir(char const * name) {
|
||||
#ifndef __EMX__
|
||||
return ::chdir(name);
|
||||
#else
|
||||
return ::_chdir2(name);
|
||||
#endif
|
||||
};
|
||||
///
|
||||
static char * getcwd(char * buffer, size_t size);
|
||||
///
|
||||
static int chdir(char const * name);
|
||||
/// generates an checksum
|
||||
static unsigned long sum(char const * file);
|
||||
/// returns a date string
|
||||
static char * date();
|
||||
///
|
||||
static string getUserName();
|
||||
///
|
||||
static int kill(int pid, int sig);
|
||||
///
|
||||
static void abort();
|
||||
};
|
||||
#endif
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* The function lyxsum is taken from GNU textutill-1.22
|
||||
* The function lyx::sum is taken from GNU textutill-1.22
|
||||
* and is there part of the program chsum. The chsum program
|
||||
* is written by Q. Frank Xia, qx@math.columbia.edu.
|
||||
*
|
||||
@ -14,12 +14,14 @@
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#ifdef __GLIBCPP__
|
||||
#ifdef MODERN_STL_STREAMS
|
||||
#include <fstream>
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
/* Number of bytes to read at once. */
|
||||
#define BUFLEN (1 << 16)
|
||||
|
||||
@ -84,12 +86,12 @@ static unsigned long const crctab[256] =
|
||||
Return crc if successful, 0 if an error occurs. */
|
||||
|
||||
unsigned long
|
||||
lyxsum (char const * file)
|
||||
lyx::sum (char const * file)
|
||||
{
|
||||
unsigned long crc = 0;
|
||||
long length = 0;
|
||||
long bytes_read;
|
||||
#if __GLIBCPP__
|
||||
#ifdef MODERN_STL_STREAMS
|
||||
char buf[BUFLEN];
|
||||
ifstream ifs(file);
|
||||
if (!ifs) {
|
||||
@ -98,7 +100,6 @@ lyxsum (char const * file)
|
||||
|
||||
while ((bytes_read = ifs.readsome(buf, BUFLEN)) > 0) {
|
||||
unsigned char * cp = reinterpret_cast<unsigned char*>(buf);
|
||||
|
||||
length += bytes_read;
|
||||
while (bytes_read--)
|
||||
crc = (crc << 8) ^ crctab[((crc >> 24) ^ *(cp++)) & 0xFF];
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "syscall.h"
|
||||
#include "syscontr.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
Systemcalls::Systemcalls() {
|
||||
pid = 0; // No child yet
|
||||
@ -33,7 +34,7 @@ Systemcalls::~Systemcalls() {
|
||||
#if 0
|
||||
// If the child is alive, we have to brutally kill it
|
||||
if (getpid() != 0) {
|
||||
::kill(getpid(), SIGKILL);
|
||||
lyx::kill(getpid(), SIGKILL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -77,7 +78,7 @@ void Systemcalls::kill(int /*tolerance*/) {
|
||||
lyxerr << "LyX: Can't kill non-existing process." << endl;
|
||||
return;
|
||||
}
|
||||
int ret = ::kill(getpid(), SIGHUP);
|
||||
int ret = lyx::kill(getpid(), SIGHUP);
|
||||
bool wait_for_death = true;
|
||||
if (ret != 0) {
|
||||
if (errno == ESRCH) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright (C) 1995 Matthias Ettrich
|
||||
* Copyright (C) 1995-1999 The LyX Team.
|
||||
* Copyright (C) 1995-2000 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-1998 The LyX Team
|
||||
* Copyright 1995-2000 The LyX Team
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
|
125
src/text2.C
125
src/text2.C
@ -1746,7 +1746,7 @@ void LyXText::InsertInset(Inset *inset)
|
||||
}
|
||||
|
||||
|
||||
/* this is for the simple cut and paste mechanism */
|
||||
// this is for the simple cut and paste mechanism
|
||||
static LyXParagraph * simple_cut_buffer = 0;
|
||||
static char simple_cut_buffer_textclass = 0;
|
||||
|
||||
@ -1832,7 +1832,7 @@ void LyXText::CutSelection(bool doclear)
|
||||
.par->ParFromPos(sel_start_cursor.pos)->previous,
|
||||
undoendpar);
|
||||
|
||||
// delete the simple_cut_buffer
|
||||
// clear the simple_cut_buffer
|
||||
DeleteSimpleCutBuffer();
|
||||
|
||||
// set the textclass
|
||||
@ -1867,7 +1867,18 @@ void LyXText::CutSelection(bool doclear)
|
||||
- cut across footnotes and paragraph
|
||||
My simplistic tests show that the idea are basically sound but
|
||||
there are some items to fix up...we only need to find them
|
||||
first. (Lgb)
|
||||
first.
|
||||
|
||||
As do redo Asger's example above (with | beeing the cursor in the
|
||||
result after cutting.):
|
||||
|
||||
Example: "This is our text."
|
||||
Using " our " as selection, cutting will give "This is|text.".
|
||||
Using "our" as selection, cutting will give "This is | text.".
|
||||
Using " our" as selection, cutting will give "This is| text.".
|
||||
Using "our " as selection, cutting will give "This is |text.".
|
||||
|
||||
(Lgb)
|
||||
*/
|
||||
|
||||
#ifndef FIX_DOUBLE_SPACE
|
||||
@ -1908,27 +1919,31 @@ void LyXText::CutSelection(bool doclear)
|
||||
}
|
||||
simple_cut_buffer->InsertFromMinibuffer(simple_cut_buffer->Last());
|
||||
}
|
||||
#ifdef FIX_DOUBLE_SPACES
|
||||
#ifndef FIX_DOUBLE_SPACE
|
||||
// check for double spaces
|
||||
if (sel_start_cursor.pos &&
|
||||
sel_start_cursor.par->Last() > sel_start_cursor.pos &&
|
||||
sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos - 1) &&
|
||||
sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos)) {
|
||||
sel_start_cursor.par->Last() > sel_start_cursor.pos
|
||||
&& sel_start_cursor.par
|
||||
->IsLineSeparator(sel_start_cursor.pos - 1)
|
||||
&& sel_start_cursor.par
|
||||
->IsLineSeparator(sel_start_cursor.pos)) {
|
||||
sel_start_cursor.par->Erase(sel_start_cursor.pos);
|
||||
}
|
||||
if (space_wrapped)
|
||||
simple_cut_buffer->InsertChar(i - sel_start_cursor.pos, ' ');
|
||||
simple_cut_buffer->InsertChar(i - sel_start_cursor.pos,
|
||||
' ');
|
||||
#endif
|
||||
endpar = sel_end_cursor.par->Next();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// cut more than one paragraph
|
||||
|
||||
sel_end_cursor.par->BreakParagraphConservative(sel_end_cursor.pos);
|
||||
sel_end_cursor.par
|
||||
->BreakParagraphConservative(sel_end_cursor.pos);
|
||||
#ifndef FIX_DOUBLE_SPACE
|
||||
// insert a space at the end if there was one
|
||||
if (space_wrapped)
|
||||
sel_end_cursor.par->InsertChar(sel_end_cursor.par->Last(), ' ');
|
||||
sel_end_cursor.par
|
||||
->InsertChar(sel_end_cursor.par->Last(), ' ');
|
||||
#endif
|
||||
sel_end_cursor.par = sel_end_cursor.par->Next();
|
||||
sel_end_cursor.pos = 0;
|
||||
@ -1938,14 +1953,18 @@ void LyXText::CutSelection(bool doclear)
|
||||
#ifndef FIX_DOUBLE_SPACE
|
||||
// please break behind a space, if there is one.
|
||||
// The space should be copied too
|
||||
if (sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos))
|
||||
if (sel_start_cursor.par
|
||||
->IsLineSeparator(sel_start_cursor.pos))
|
||||
sel_start_cursor.pos++;
|
||||
|
||||
#endif
|
||||
sel_start_cursor.par
|
||||
->BreakParagraphConservative(sel_start_cursor.pos);
|
||||
#ifndef FIX_DOUBLE_SPACE
|
||||
if (!sel_start_cursor.pos
|
||||
|| sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos - 1)
|
||||
|| sel_start_cursor.par->IsNewline(sel_start_cursor.pos - 1)) {
|
||||
|| sel_start_cursor.par
|
||||
->IsLineSeparator(sel_start_cursor.pos - 1)
|
||||
|| sel_start_cursor.par
|
||||
->IsNewline(sel_start_cursor.pos - 1)) {
|
||||
sel_start_cursor.par->Next()->InsertChar(0, ' ');
|
||||
}
|
||||
#endif
|
||||
@ -1988,11 +2007,13 @@ void LyXText::CutSelection(bool doclear)
|
||||
!sel_start_cursor.par->Next()->Last())
|
||||
sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->PasteParagraph();
|
||||
|
||||
#ifdef FIX_DOUBLE_SPACE
|
||||
#ifndef FIX_DOUBLE_SPACE
|
||||
// maybe a forgotten blank
|
||||
if (sel_start_cursor.pos
|
||||
&& sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos)
|
||||
&& sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos - 1)) {
|
||||
&& sel_start_cursor.par
|
||||
->IsLineSeparator(sel_start_cursor.pos)
|
||||
&& sel_start_cursor.par
|
||||
->IsLineSeparator(sel_start_cursor.pos - 1)) {
|
||||
sel_start_cursor.par->Erase(sel_start_cursor.pos);
|
||||
}
|
||||
#endif
|
||||
@ -2027,9 +2048,11 @@ void LyXText::CopySelection()
|
||||
|| sel_end_cursor.par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
|
||||
tmppar = sel_start_cursor.par;
|
||||
while (tmppar != sel_end_cursor.par) {
|
||||
if (tmppar->footnoteflag != sel_end_cursor.par->footnoteflag){
|
||||
if (tmppar->footnoteflag !=
|
||||
sel_end_cursor.par->footnoteflag) {
|
||||
WriteAlert(_("Impossible operation"),
|
||||
_("Don't know what to do with half floats."),
|
||||
_("Don't know what to do"
|
||||
" with half floats."),
|
||||
_("sorry."));
|
||||
return;
|
||||
}
|
||||
@ -2186,25 +2209,56 @@ void LyXText::PasteSelection()
|
||||
else
|
||||
table_too_small = true;
|
||||
} else {
|
||||
#ifdef FIX_DOUBLE_SPACE
|
||||
// This is an attempt to fix the
|
||||
// "never insert a space at the
|
||||
// beginning of a paragraph" problem.
|
||||
if (tmpcursor.pos == 0
|
||||
&& simple_cut_buffer->IsLineSeparator(0)) {
|
||||
simple_cut_buffer->Erase(0);
|
||||
} else {
|
||||
simple_cut_buffer->CutIntoMinibuffer(0);
|
||||
simple_cut_buffer->Erase(0);
|
||||
tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos);
|
||||
tmpcursor.pos++;
|
||||
}
|
||||
#else
|
||||
simple_cut_buffer->CutIntoMinibuffer(0);
|
||||
simple_cut_buffer->Erase(0);
|
||||
tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos);
|
||||
tmpcursor.pos++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* table stuff -- end */
|
||||
// Some provisions should be done here for checking if we
|
||||
// are inserting at the beginning of a paragraph. If there
|
||||
// are a space at the beginning of the text to insert and we are
|
||||
// inserting at the beginning of the paragraph the space should
|
||||
// Some provisions should be done here for checking
|
||||
// if we are inserting at the beginning of a
|
||||
// paragraph. If there are a space at the beginning
|
||||
// of the text to insert and we are inserting at
|
||||
// the beginning of the paragraph the space should
|
||||
// be removed.
|
||||
while (simple_cut_buffer->text.size()) {
|
||||
#ifdef FIX_DOUBLE_SPACE
|
||||
// This is an attempt to fix the
|
||||
// "never insert a space at the
|
||||
// beginning of a paragraph" problem.
|
||||
if (tmpcursor.pos == 0
|
||||
&& simple_cut_buffer->IsLineSeparator(0)) {
|
||||
simple_cut_buffer->Erase(0);
|
||||
} else {
|
||||
simple_cut_buffer->CutIntoMinibuffer(0);
|
||||
simple_cut_buffer->Erase(0);
|
||||
tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos);
|
||||
tmpcursor.pos++;
|
||||
}
|
||||
#else
|
||||
simple_cut_buffer->CutIntoMinibuffer(0);
|
||||
simple_cut_buffer->Erase(0);
|
||||
tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos);
|
||||
tmpcursor.pos++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
delete simple_cut_buffer;
|
||||
simple_cut_buffer = tmppar;
|
||||
@ -2246,10 +2300,16 @@ void LyXText::PasteSelection()
|
||||
lastbuffer = lastbuffer->Next();
|
||||
|
||||
// find the physical end of the buffer
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning Explain this please.
|
||||
#endif
|
||||
#if 0
|
||||
// Can someone explain to be why this is done a second time?
|
||||
// (Lgb)
|
||||
lastbuffer = simple_cut_buffer;
|
||||
while (lastbuffer->Next())
|
||||
lastbuffer = lastbuffer->Next();
|
||||
|
||||
#endif
|
||||
#ifndef FIX_DOUBLE_SPACE
|
||||
// Please break behind a space, if there is one. The space
|
||||
// should be copied too.
|
||||
@ -2279,11 +2339,14 @@ void LyXText::PasteSelection()
|
||||
endpar = cursor.par->ParFromPos(cursor.pos)->next->Next();
|
||||
|
||||
// paste it!
|
||||
lastbuffer->ParFromPos(lastbuffer->Last())->next = cursor.par->ParFromPos(cursor.pos)->next;
|
||||
cursor.par->ParFromPos(cursor.pos)->next->previous = lastbuffer->ParFromPos(lastbuffer->Last());
|
||||
lastbuffer->ParFromPos(lastbuffer->Last())->next =
|
||||
cursor.par->ParFromPos(cursor.pos)->next;
|
||||
cursor.par->ParFromPos(cursor.pos)->next->previous =
|
||||
lastbuffer->ParFromPos(lastbuffer->Last());
|
||||
|
||||
cursor.par->ParFromPos(cursor.pos)->next = simple_cut_buffer;
|
||||
simple_cut_buffer->previous = cursor.par->ParFromPos(cursor.pos);
|
||||
simple_cut_buffer->previous =
|
||||
cursor.par->ParFromPos(cursor.pos);
|
||||
|
||||
if (cursor.par->ParFromPos(cursor.pos)->Next() == lastbuffer)
|
||||
lastbuffer = cursor.par;
|
||||
@ -2334,8 +2397,8 @@ void LyXText::PasteSelection()
|
||||
#endif
|
||||
lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph();
|
||||
|
||||
}
|
||||
else lastbuffer->Next()->ClearParagraph();
|
||||
} else
|
||||
lastbuffer->Next()->ClearParagraph();
|
||||
}
|
||||
|
||||
// restore the simple cut buffer
|
||||
|
Loading…
Reference in New Issue
Block a user