remove unused and a little documentation (all r=larsbj)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5462 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-10-21 16:21:56 +00:00
parent 5696dc3287
commit 774dabb323
18 changed files with 324 additions and 285 deletions

View File

@ -556,7 +556,7 @@ bool BufferView::gotoLabel(string const & label)
} }
void BufferView::menuUndo() void BufferView::undo()
{ {
if (!available()) if (!available())
return; return;
@ -573,7 +573,7 @@ void BufferView::menuUndo()
} }
void BufferView::menuRedo() void BufferView::redo()
{ {
if (!available()) if (!available())
return; return;

View File

@ -31,34 +31,48 @@ class Painter;
class UpdatableInset; class UpdatableInset;
class WordLangTuple; class WordLangTuple;
/// /**
* A buffer view encapsulates a view onto a particular
* buffer, and allows access to operate upon it. A view
* is a sliding window of the entire document rendering.
*
* Eventually we will allow several views onto a single
* buffer, but not yet.
*/
class BufferView : boost::noncopyable { class BufferView : boost::noncopyable {
public: public:
/// /**
* Codes to store necessary pending updates
* of the document rendering.
*/
enum UpdateCodes { enum UpdateCodes {
/// UPDATE = 0, //< FIXME
UPDATE = 0, SELECT = 1, //< selection change
/// FITCUR = 2, //< the cursor needs fitting into the view
SELECT = 1, CHANGE = 4 //< document data has changed
///
FITCUR = 2,
///
CHANGE = 4
}; };
/// /**
BufferView(LyXView * owner, int , int , int, int); * Create a view with the given owner main window,
/// * of the given dimensions.
*/
BufferView(LyXView * owner, int x, int y, int w, int h);
~BufferView(); ~BufferView();
///
Buffer * buffer() const; /// set the buffer we are viewing
///
Painter & painter() const;
///
LyXScreen & screen() const;
///
void buffer(Buffer * b); void buffer(Buffer * b);
/// /// return the buffer being viewed
Buffer * buffer() const;
/// return the painter object for drawing onto the view
Painter & painter() const;
/// return the screen object for handling re-drawing
LyXScreen & screen() const;
/// return the owning main view
LyXView * owner() const;
/// resize event has happened
void resize(); void resize();
/** /**
* Repaint the pixmap. Used for when we don't want * Repaint the pixmap. Used for when we don't want
@ -66,146 +80,164 @@ public:
* repaint of the whole screen. * repaint of the whole screen.
*/ */
void repaint(); void repaint();
///
/// fit the user cursor within the visible view
bool fitCursor(); bool fitCursor();
/// /// perform pending painting updates
void update(); void update();
// // update for a particular lyxtext
void update(LyXText *, UpdateCodes uc); void update(LyXText *, UpdateCodes uc);
/// /// update for a particular inset
void updateScrollbar();
///
void redoCurrentBuffer();
///
bool available() const;
///
LyXView * owner() const;
///
void beforeChange(LyXText *);
///
void savePosition(unsigned int i);
///
void restorePosition(unsigned int i);
///
bool isSavedPosition(unsigned int i);
/** This holds the mapping between buffer paragraphs and screen rows.
This should be private...but not yet. (Lgb)
*/
LyXText * text;
///
LyXText * getLyXText() const;
///
LyXText * getParentText(Inset * inset) const;
///
Language const * getParentLanguage(Inset * inset) const;
///
int workWidth() const;
///
UpdatableInset * theLockingInset() const;
///
void theLockingInset(UpdatableInset * inset);
///
void updateInset(Inset * inset, bool mark_dirty); void updateInset(Inset * inset, bool mark_dirty);
/// /// reset the scrollbar to reflect current view position
int slx; void updateScrollbar();
/// /// FIXME
int sly; void redoCurrentBuffer();
///
/// FIXME
bool available() const;
/// FIXME
void beforeChange(LyXText *);
/// Save the current position as bookmark i
void savePosition(unsigned int i);
/// Restore the position from bookmark i
void restorePosition(unsigned int i);
/// does the given bookmark have a saved position ?
bool isSavedPosition(unsigned int i);
/**
* This holds the mapping between buffer paragraphs and screen rows.
* This should be private...but not yet. (Lgb)
*/
LyXText * text;
/// return the lyxtext we are using
LyXText * getLyXText() const;
/// Return the current inset we are "locked" in
UpdatableInset * theLockingInset() const;
/// lock the given inset FIXME: return value ?
bool lockInset(UpdatableInset * inset);
/// unlock the given inset
int unlockInset(UpdatableInset * inset);
/// unlock the currently locked inset
void insetUnlock(); void insetUnlock();
///
void replaceWord(string const & replacestring); /// return the parent language of the given inset
/// Language const * getParentLanguage(Inset * inset) const;
void endOfSpellCheck();
/// /// Select the "current" word
void selectLastWord(); void selectLastWord();
/// replace the currently selected word
void replaceWord(string const & replacestring);
/// Update after spellcheck finishes
void endOfSpellCheck();
/// return the next word /// return the next word
WordLangTuple const nextWord(float & value); WordLangTuple const nextWord(float & value);
///
/// move cursor to the named label
bool gotoLabel(string const & label); bool gotoLabel(string const & label);
///
void pasteEnvironment(); /// copy the environment type from current paragraph
///
void copyEnvironment(); void copyEnvironment();
/// /// set the current paragraph's environment type
void menuUndo(); void pasteEnvironment();
///
void menuRedo(); /// undo last action
void undo();
/// redo last action
void redo();
/// removes all autodeletable insets /// removes all autodeletable insets
bool removeAutoInsets(); bool removeAutoInsets();
/// /// insert all errors found when running latex
void insertErrors(TeXErrors & terr); void insertErrors(TeXErrors & terr);
/// /// set the cursor based on the given TeX source row
void setCursorFromRow(int row); void setCursorFromRow(int row);
/** Insert an inset into the buffer.
Place it in a layout of lout, /**
if no_table make sure that it doesn't end up in a table. * Insert an inset into the buffer.
*/ * Place it in a layout of lout,
*/
bool insertInset(Inset * inset, string const & lout = string()); bool insertInset(Inset * inset, string const & lout = string());
/// Inserts a lyx file at cursor position. return #false# if it fails
/// Inserts a lyx file at cursor position. return false if it fails
bool insertLyXFile(string const & file); bool insertLyXFile(string const & file);
///
bool lockInset(UpdatableInset * inset); /// show the user cursor
///
void showLockedInsetCursor(int x, int y, int asc, int desc);
///
void hideLockedInsetCursor();
///
bool fitLockedInsetCursor(int x, int y, int asc, int desc);
///
int unlockInset(UpdatableInset * inset);
///
void lockedInsetStoreUndo(Undo::undo_kind kind);
///
void showCursor(); void showCursor();
/// /// hide the user cursor
void hideCursor(); void hideCursor();
/// /// FIXME
void showLockedInsetCursor(int x, int y, int asc, int desc);
/// FIXME
void hideLockedInsetCursor();
/// FIXME
bool fitLockedInsetCursor(int x, int y, int asc, int desc);
/// FIXME
void lockedInsetStoreUndo(Undo::undo_kind kind);
/// FIXME
void toggleSelection(bool = true); void toggleSelection(bool = true);
/// /// FIXME: my word !
void toggleToggle(); void toggleToggle();
///
/// center the document view around the cursor
void center(); void center();
/// scroll document by the given number of lines of default height /// scroll document by the given number of lines of default height
void scroll(int lines); void scroll(int lines);
/// Scroll the view by a number of pixels /// Scroll the view by a number of pixels
void scrollDocView(int); void scrollDocView(int);
///
void switchKeyMap();
///
bool ChangeInsets(Inset::Code code, string const & from,
string const & to);
///
bool ChangeRefsIfUnique(string const & from, string const & to);
///
bool ChangeCitationsIfUnique(string const & from, string const & to);
///
string const getClipboard() const;
///
void stuffClipboard(string const &) const;
///
bool dispatch(FuncRequest const & argument);
/// height of a normal line in pixels (zoom factor considered) /// height of a normal line in pixels (zoom factor considered)
int defaultHeight() const; int defaultHeight() const;
/// /// return the pixel width of the document view
void haveSelection(bool sel); int workWidth() const;
/// /// return the pixel height of the document view
int workHeight() const; int workHeight() const;
/// switch between primary and secondary keymaps for RTL entry
void switchKeyMap();
/// FIXME
bool ChangeRefsIfUnique(string const & from, string const & to);
/// FIXME
bool ChangeCitationsIfUnique(string const & from, string const & to);
/// get the contents of the window system clipboard
string const getClipboard() const;
/// fill the window system clipboard
void stuffClipboard(string const &) const;
/// tell the window system we have a selection
void haveSelection(bool sel);
/// execute the given function
bool dispatch(FuncRequest const & argument);
private: private:
/// /// Set the current locking inset
void theLockingInset(UpdatableInset * inset);
/// return the lyxtext containing this inset
LyXText * getParentText(Inset * inset) const;
/**
* Change all insets with the given code's contents to a new
* string. May only be used with InsetCommand-derived insets
* Returns true if a screen update is needed.
*/
bool ChangeInsets(Inset::Code code, string const & from,
string const & to);
struct Pimpl; struct Pimpl;
///
friend struct BufferView::Pimpl; friend struct BufferView::Pimpl;
///
Pimpl * pimpl_; Pimpl * pimpl_;
}; };
///
BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1, BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
BufferView::UpdateCodes uc2); BufferView::UpdateCodes uc2);
#endif #endif // BUFFERVIEW_H

View File

@ -1,3 +1,26 @@
2002-10-21 John Levon <levon@movementarian.org>
* BufferView.C: menuUndo ->undo, redo
* BufferView.h: document, remove dead, make some methods private
* paragraph_funcs.h:
* paragraph_funcs.C:
* CutAndPaste.C: s/pasteParagraph/mergeParagraph
* buffer.h:
* buffer.C:
* sgml.h:
* sgml.C: move sgml open/close tag into sgml.C
* bufferview_funcs.h: unused prototype
* lyxfunc.h:
* lyxfunc.C: remove unused
* lyxtext.h:
* text.C: remove unused
2002-10-21 John Levon <levon@movementarian.org> 2002-10-21 John Levon <levon@movementarian.org>
* BufferView.h: * BufferView.h:

View File

@ -149,7 +149,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
startpar->next()->stripLeadingSpaces(); startpar->next()->stripLeadingSpaces();
if (startpar->hasSameLayout(startpar->next()) || if (startpar->hasSameLayout(startpar->next()) ||
startpar->next()->empty()) { startpar->next()->empty()) {
pasteParagraph(current_view->buffer()->params, startpar); mergeParagraph(current_view->buffer()->params, startpar);
(*endpar) = startpar; // this because endpar gets deleted here! (*endpar) = startpar; // this because endpar gets deleted here!
} }
// this paragraph's are of noone's owner! // this paragraph's are of noone's owner!
@ -365,20 +365,20 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
if ((*par)->next() == lastbuffer) if ((*par)->next() == lastbuffer)
lastbuffer = *par; lastbuffer = *par;
pasteParagraph(current_view->buffer()->params, *par); mergeParagraph(current_view->buffer()->params, *par);
// store the new cursor position // store the new cursor position
*par = lastbuffer; *par = lastbuffer;
pos = lastbuffer->size(); pos = lastbuffer->size();
// maybe some pasting // maybe some pasting
if (lastbuffer->next() && paste_the_end) { if (lastbuffer->next() && paste_the_end) {
if (lastbuffer->next()->hasSameLayout(lastbuffer)) { if (lastbuffer->next()->hasSameLayout(lastbuffer)) {
pasteParagraph(current_view->buffer()->params, lastbuffer); mergeParagraph(current_view->buffer()->params, lastbuffer);
} else if (lastbuffer->next()->empty()) { } else if (lastbuffer->next()->empty()) {
lastbuffer->next()->makeSameLayout(lastbuffer); lastbuffer->next()->makeSameLayout(lastbuffer);
pasteParagraph(current_view->buffer()->params, lastbuffer); mergeParagraph(current_view->buffer()->params, lastbuffer);
} else if (lastbuffer->empty()) { } else if (lastbuffer->empty()) {
lastbuffer->makeSameLayout(lastbuffer->next()); lastbuffer->makeSameLayout(lastbuffer->next());
pasteParagraph(current_view->buffer()->params, lastbuffer); mergeParagraph(current_view->buffer()->params, lastbuffer);
} else } else
lastbuffer->next()->stripLeadingSpaces(); lastbuffer->next()->stripLeadingSpaces();
} }

View File

@ -199,7 +199,7 @@ string const Buffer::getLatexName(bool no_path) const
} }
pair<Buffer::LogType, string> const Buffer::getLogName(void) const pair<Buffer::LogType, string> const Buffer::getLogName() const
{ {
string const filename = getLatexName(false); string const filename = getLatexName(false);
@ -2201,38 +2201,6 @@ bool Buffer::isSGML() const
} }
int Buffer::sgmlOpenTag(ostream & os, Paragraph::depth_type depth, bool mixcont,
string const & latexname) const
{
if (!latexname.empty() && latexname != "!-- --") {
if (!mixcont)
os << string(" ",depth);
os << "<" << latexname << ">";
}
if (!mixcont)
os << endl;
return mixcont?0:1;
}
int Buffer::sgmlCloseTag(ostream & os, Paragraph::depth_type depth, bool mixcont,
string const & latexname) const
{
if (!latexname.empty() && latexname != "!-- --") {
if (!mixcont)
os << endl << string(" ",depth);
os << "</" << latexname << ">";
}
if (!mixcont)
os << endl;
return mixcont?0:1;
}
void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
{ {
ofstream ofs(fname.c_str()); ofstream ofs(fname.c_str());
@ -2269,12 +2237,12 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
ofs << ">\n\n"; ofs << ">\n\n";
if (params.options.empty()) if (params.options.empty())
sgmlOpenTag(ofs, 0, false, top_element); sgml::openTag(ofs, 0, false, top_element);
else { else {
string top = top_element; string top = top_element;
top += " "; top += " ";
top += params.options; top += params.options;
sgmlOpenTag(ofs, 0, false, top); sgml::openTag(ofs, 0, false, top);
} }
} }
@ -2295,7 +2263,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
Inset::Code lyx_code = inset->lyxCode(); Inset::Code lyx_code = inset->lyxCode();
if (lyx_code == Inset::TOC_CODE) { if (lyx_code == Inset::TOC_CODE) {
string const temp = "toc"; string const temp = "toc";
sgmlOpenTag(ofs, depth, false, temp); sgml::openTag(ofs, depth, false, temp);
par = par->next(); par = par->next();
continue; continue;
@ -2304,7 +2272,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
// environment tag closing // environment tag closing
for (; depth > par->params().depth(); --depth) { for (; depth > par->params().depth(); --depth) {
sgmlCloseTag(ofs, depth, false, environment_stack[depth]); sgml::closeTag(ofs, depth, false, environment_stack[depth]);
environment_stack[depth].erase(); environment_stack[depth].erase();
} }
@ -2313,14 +2281,14 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
case LATEX_PARAGRAPH: case LATEX_PARAGRAPH:
if (depth == par->params().depth() if (depth == par->params().depth()
&& !environment_stack[depth].empty()) { && !environment_stack[depth].empty()) {
sgmlCloseTag(ofs, depth, false, environment_stack[depth]); sgml::closeTag(ofs, depth, false, environment_stack[depth]);
environment_stack[depth].erase(); environment_stack[depth].erase();
if (depth) if (depth)
--depth; --depth;
else else
ofs << "</p>"; ofs << "</p>";
} }
sgmlOpenTag(ofs, depth, false, style->latexname()); sgml::openTag(ofs, depth, false, style->latexname());
break; break;
case LATEX_COMMAND: case LATEX_COMMAND:
@ -2330,12 +2298,12 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
" LatexType Command.\n")); " LatexType Command.\n"));
if (!environment_stack[depth].empty()) { if (!environment_stack[depth].empty()) {
sgmlCloseTag(ofs, depth, false, environment_stack[depth]); sgml::closeTag(ofs, depth, false, environment_stack[depth]);
ofs << "</p>"; ofs << "</p>";
} }
environment_stack[depth].erase(); environment_stack[depth].erase();
sgmlOpenTag(ofs, depth, false, style->latexname()); sgml::openTag(ofs, depth, false, style->latexname());
break; break;
case LATEX_ENVIRONMENT: case LATEX_ENVIRONMENT:
@ -2345,7 +2313,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
if (depth == par->params().depth() if (depth == par->params().depth()
&& environment_stack[depth] != latexname) { && environment_stack[depth] != latexname) {
sgmlCloseTag(ofs, depth, false, sgml::closeTag(ofs, depth, false,
environment_stack[depth]); environment_stack[depth]);
environment_stack[depth].erase(); environment_stack[depth].erase();
} }
@ -2355,9 +2323,9 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
} }
if (environment_stack[depth] != latexname) { if (environment_stack[depth] != latexname) {
if (depth == 0) { if (depth == 0) {
sgmlOpenTag(ofs, depth, false, "p"); sgml::openTag(ofs, depth, false, "p");
} }
sgmlOpenTag(ofs, depth, false, latexname); sgml::openTag(ofs, depth, false, latexname);
if (environment_stack.size() == depth + 1) if (environment_stack.size() == depth + 1)
environment_stack.push_back("!-- --"); environment_stack.push_back("!-- --");
@ -2374,12 +2342,12 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
else else
item_name = "item"; item_name = "item";
sgmlOpenTag(ofs, depth + 1, false, item_name); sgml::openTag(ofs, depth + 1, false, item_name);
} }
break; break;
default: default:
sgmlOpenTag(ofs, depth, false, style->latexname()); sgml::openTag(ofs, depth, false, style->latexname());
break; break;
} }
@ -2398,18 +2366,18 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
ofs << "]]>"; ofs << "]]>";
break; break;
default: default:
sgmlCloseTag(ofs, depth, false, style->latexname()); sgml::closeTag(ofs, depth, false, style->latexname());
break; break;
} }
} }
// Close open tags // Close open tags
for (int i = depth; i >= 0; --i) for (int i = depth; i >= 0; --i)
sgmlCloseTag(ofs, depth, false, environment_stack[i]); sgml::closeTag(ofs, depth, false, environment_stack[i]);
if (!body_only) { if (!body_only) {
ofs << "\n\n"; ofs << "\n\n";
sgmlCloseTag(ofs, 0, false, top_element); sgml::closeTag(ofs, 0, false, top_element);
} }
ofs.close(); ofs.close();
@ -2735,7 +2703,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
top += " "; top += " ";
top += params.options; top += params.options;
} }
sgmlOpenTag(ofs, 0, false, top); sgml::openTag(ofs, 0, false, top);
ofs << "<!-- DocBook file was created by " << lyx_docversion ofs << "<!-- DocBook file was created by " << lyx_docversion
<< "\n See http://www.lyx.org/ for more information -->\n"; << "\n See http://www.lyx.org/ for more information -->\n";
@ -2765,11 +2733,11 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
for (; depth > par->params().depth(); --depth) { for (; depth > par->params().depth(); --depth) {
if (environment_inner[depth] != "!-- --") { if (environment_inner[depth] != "!-- --") {
item_name = "listitem"; item_name = "listitem";
sgmlCloseTag(ofs, command_depth + depth, false, item_name); sgml::closeTag(ofs, command_depth + depth, false, item_name);
if (environment_inner[depth] == "varlistentry") if (environment_inner[depth] == "varlistentry")
sgmlCloseTag(ofs, depth+command_depth, false, environment_inner[depth]); sgml::closeTag(ofs, depth+command_depth, false, environment_inner[depth]);
} }
sgmlCloseTag(ofs, depth + command_depth, false, environment_stack[depth]); sgml::closeTag(ofs, depth + command_depth, false, environment_stack[depth]);
environment_stack[depth].erase(); environment_stack[depth].erase();
environment_inner[depth].erase(); environment_inner[depth].erase();
} }
@ -2779,12 +2747,12 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
&& !environment_stack[depth].empty()) { && !environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") { if (environment_inner[depth] != "!-- --") {
item_name= "listitem"; item_name= "listitem";
sgmlCloseTag(ofs, command_depth+depth, false, item_name); sgml::closeTag(ofs, command_depth+depth, false, item_name);
if (environment_inner[depth] == "varlistentry") if (environment_inner[depth] == "varlistentry")
sgmlCloseTag(ofs, depth + command_depth, false, environment_inner[depth]); sgml::closeTag(ofs, depth + command_depth, false, environment_inner[depth]);
} }
sgmlCloseTag(ofs, depth + command_depth, false, environment_stack[depth]); sgml::closeTag(ofs, depth + command_depth, false, environment_stack[depth]);
environment_stack[depth].erase(); environment_stack[depth].erase();
environment_inner[depth].erase(); environment_inner[depth].erase();
@ -2793,7 +2761,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
// Write opening SGML tags. // Write opening SGML tags.
switch (style->latextype) { switch (style->latextype) {
case LATEX_PARAGRAPH: case LATEX_PARAGRAPH:
sgmlOpenTag(ofs, depth + command_depth, sgml::openTag(ofs, depth + command_depth,
false, style->latexname()); false, style->latexname());
break; break;
@ -2814,14 +2782,14 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
if (cmd_depth < command_base) { if (cmd_depth < command_base) {
for (Paragraph::depth_type j = command_depth; for (Paragraph::depth_type j = command_depth;
j >= command_base; --j) { j >= command_base; --j) {
sgmlCloseTag(ofs, j, false, command_stack[j]); sgml::closeTag(ofs, j, false, command_stack[j]);
ofs << endl; ofs << endl;
} }
command_depth = command_base = cmd_depth; command_depth = command_base = cmd_depth;
} else if (cmd_depth <= command_depth) { } else if (cmd_depth <= command_depth) {
for (int j = command_depth; for (int j = command_depth;
j >= int(cmd_depth); --j) { j >= int(cmd_depth); --j) {
sgmlCloseTag(ofs, j, false, command_stack[j]); sgml::closeTag(ofs, j, false, command_stack[j]);
ofs << endl; ofs << endl;
} }
command_depth = cmd_depth; command_depth = cmd_depth;
@ -2850,10 +2818,10 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
} }
} }
sgmlOpenTag(ofs, depth + command_depth, false, command_name); sgml::openTag(ofs, depth + command_depth, false, command_name);
item_name = c_params.empty()?"title":c_params; item_name = c_params.empty()?"title":c_params;
sgmlOpenTag(ofs, depth + 1 + command_depth, false, item_name); sgml::openTag(ofs, depth + 1 + command_depth, false, item_name);
break; break;
case LATEX_ENVIRONMENT: case LATEX_ENVIRONMENT:
@ -2870,13 +2838,13 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
} }
environment_stack[depth] = style->latexname(); environment_stack[depth] = style->latexname();
environment_inner[depth] = "!-- --"; environment_inner[depth] = "!-- --";
sgmlOpenTag(ofs, depth + command_depth, false, environment_stack[depth]); sgml::openTag(ofs, depth + command_depth, false, environment_stack[depth]);
} else { } else {
if (environment_inner[depth] != "!-- --") { if (environment_inner[depth] != "!-- --") {
item_name= "listitem"; item_name= "listitem";
sgmlCloseTag(ofs, command_depth + depth, false, item_name); sgml::closeTag(ofs, command_depth + depth, false, item_name);
if (environment_inner[depth] == "varlistentry") if (environment_inner[depth] == "varlistentry")
sgmlCloseTag(ofs, depth + command_depth, false, environment_inner[depth]); sgml::closeTag(ofs, depth + command_depth, false, environment_inner[depth]);
} }
} }
@ -2885,7 +2853,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
if (style->latexparam() == "CDATA") if (style->latexparam() == "CDATA")
ofs << "<![CDATA["; ofs << "<![CDATA[";
else else
sgmlOpenTag(ofs, depth + command_depth, false, style->latexparam()); sgml::openTag(ofs, depth + command_depth, false, style->latexparam());
} }
break; break;
} }
@ -2893,15 +2861,15 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
desc_on = (style->labeltype == LABEL_MANUAL); desc_on = (style->labeltype == LABEL_MANUAL);
environment_inner[depth] = desc_on ? "varlistentry" : "listitem"; environment_inner[depth] = desc_on ? "varlistentry" : "listitem";
sgmlOpenTag(ofs, depth + 1 + command_depth, sgml::openTag(ofs, depth + 1 + command_depth,
false, environment_inner[depth]); false, environment_inner[depth]);
item_name = desc_on ? "term" : "para"; item_name = desc_on ? "term" : "para";
sgmlOpenTag(ofs, depth + 1 + command_depth, sgml::openTag(ofs, depth + 1 + command_depth,
false, item_name); false, item_name);
break; break;
default: default:
sgmlOpenTag(ofs, depth + command_depth, sgml::openTag(ofs, depth + command_depth,
false, style->latexname()); false, style->latexname());
break; break;
} }
@ -2915,7 +2883,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
switch (style->latextype) { switch (style->latextype) {
case LATEX_COMMAND: case LATEX_COMMAND:
end_tag = c_params.empty() ? "title" : c_params; end_tag = c_params.empty() ? "title" : c_params;
sgmlCloseTag(ofs, depth + command_depth, sgml::closeTag(ofs, depth + command_depth,
false, end_tag); false, end_tag);
break; break;
case LATEX_ENVIRONMENT: case LATEX_ENVIRONMENT:
@ -2923,19 +2891,19 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
if (style->latexparam() == "CDATA") if (style->latexparam() == "CDATA")
ofs << "]]>"; ofs << "]]>";
else else
sgmlCloseTag(ofs, depth + command_depth, false, style->latexparam()); sgml::closeTag(ofs, depth + command_depth, false, style->latexparam());
} }
break; break;
case LATEX_ITEM_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT:
if (desc_on == 1) break; if (desc_on == 1) break;
end_tag= "para"; end_tag= "para";
sgmlCloseTag(ofs, depth + 1 + command_depth, false, end_tag); sgml::closeTag(ofs, depth + 1 + command_depth, false, end_tag);
break; break;
case LATEX_PARAGRAPH: case LATEX_PARAGRAPH:
sgmlCloseTag(ofs, depth + command_depth, false, style->latexname()); sgml::closeTag(ofs, depth + command_depth, false, style->latexname());
break; break;
default: default:
sgmlCloseTag(ofs, depth + command_depth, false, style->latexname()); sgml::closeTag(ofs, depth + command_depth, false, style->latexname());
break; break;
} }
} }
@ -2945,23 +2913,23 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
if (!environment_stack[depth].empty()) { if (!environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") { if (environment_inner[depth] != "!-- --") {
item_name = "listitem"; item_name = "listitem";
sgmlCloseTag(ofs, command_depth + depth, false, item_name); sgml::closeTag(ofs, command_depth + depth, false, item_name);
if (environment_inner[depth] == "varlistentry") if (environment_inner[depth] == "varlistentry")
sgmlCloseTag(ofs, depth + command_depth, false, environment_inner[depth]); sgml::closeTag(ofs, depth + command_depth, false, environment_inner[depth]);
} }
sgmlCloseTag(ofs, depth + command_depth, false, environment_stack[depth]); sgml::closeTag(ofs, depth + command_depth, false, environment_stack[depth]);
} }
} }
for (int j = command_depth; j >= 0 ; --j) for (int j = command_depth; j >= 0 ; --j)
if (!command_stack[j].empty()) { if (!command_stack[j].empty()) {
sgmlCloseTag(ofs, j, false, command_stack[j]); sgml::closeTag(ofs, j, false, command_stack[j]);
ofs << endl; ofs << endl;
} }
ofs << "\n\n"; ofs << "\n\n";
sgmlCloseTag(ofs, 0, false, top_element); sgml::closeTag(ofs, 0, false, top_element);
ofs.close(); ofs.close();
// How to check for successful close // How to check for successful close

View File

@ -177,12 +177,6 @@ public:
/// ///
void makeDocBookFile(string const & filename, void makeDocBookFile(string const & filename,
bool nice, bool only_body = false); bool nice, bool only_body = false);
/// Open SGML/XML tag.
int sgmlOpenTag(std::ostream & os, Paragraph::depth_type depth, bool mixcont,
string const & latexname) const;
/// Closes SGML/XML tag.
int sgmlCloseTag(std::ostream & os, Paragraph::depth_type depth, bool mixcont,
string const & latexname) const;
/// ///
void sgmlError(Paragraph * par, int pos, string const & message) const; void sgmlError(Paragraph * par, int pos, string const & message) const;

View File

@ -29,8 +29,6 @@ extern void bold(BufferView *);
/// ///
extern void noun(BufferView *); extern void noun(BufferView *);
/// ///
extern void table();
///
extern void lang(BufferView *, string const &); extern void lang(BufferView *, string const &);
/// ///
extern void number(BufferView *); extern void number(BufferView *);

View File

@ -1,3 +1,9 @@
2002-10-21 John Levon <levon@movementarian.org>
* inset.h: remove unused DISPATCH_RESULT
* insettext.C: sgml open/close tag now in sgml namespace
2002-10-21 Angus Leeming <leeming@lyx.org> 2002-10-21 Angus Leeming <leeming@lyx.org>
* insetgraphics.C (draw): Fix the drawing of an inset with a relative * insetgraphics.C (draw): Fix the drawing of an inset with a relative

View File

@ -171,11 +171,6 @@ public:
FINISHED_DOWN FINISHED_DOWN
}; };
/// To convert old binary dispatch results
RESULT DISPATCH_RESULT(bool b) {
return b ? DISPATCHED : FINISHED;
}
/// ///
Inset(); Inset();
/// ///

View File

@ -38,6 +38,7 @@
#include "undo_funcs.h" #include "undo_funcs.h"
#include "WordLangTuple.h" #include "WordLangTuple.h"
#include "paragraph_funcs.h" #include "paragraph_funcs.h"
#include "sgml.h"
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
@ -1631,11 +1632,11 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
for (; depth > p->params().depth(); --depth) { for (; depth > p->params().depth(); --depth) {
if (environment_inner[depth] != "!-- --") { if (environment_inner[depth] != "!-- --") {
item_name = "listitem"; item_name = "listitem";
lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name); lines += sgml::closeTag(os, command_depth + depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry") if (environment_inner[depth] == "varlistentry")
lines += buf->sgmlCloseTag(os, depth+command_depth, mixcont, environment_inner[depth]); lines += sgml::closeTag(os, depth+command_depth, mixcont, environment_inner[depth]);
} }
lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]); lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_stack[depth]);
environment_stack[depth].erase(); environment_stack[depth].erase();
environment_inner[depth].erase(); environment_inner[depth].erase();
} }
@ -1645,12 +1646,12 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
&& !environment_stack[depth].empty()) { && !environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") { if (environment_inner[depth] != "!-- --") {
item_name= "listitem"; item_name= "listitem";
lines += buf->sgmlCloseTag(os, command_depth+depth, mixcont, item_name); lines += sgml::closeTag(os, command_depth+depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry") if (environment_inner[depth] == "varlistentry")
lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]); lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_inner[depth]);
} }
lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]); lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_stack[depth]);
environment_stack[depth].erase(); environment_stack[depth].erase();
environment_inner[depth].erase(); environment_inner[depth].erase();
@ -1659,7 +1660,7 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
// Write opening SGML tags. // Write opening SGML tags.
switch (style->latextype) { switch (style->latextype) {
case LATEX_PARAGRAPH: case LATEX_PARAGRAPH:
lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style->latexname()); lines += sgml::openTag(os, depth + command_depth, mixcont, style->latexname());
break; break;
case LATEX_COMMAND: case LATEX_COMMAND:
@ -1681,13 +1682,13 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
} }
environment_stack[depth] = style->latexname(); environment_stack[depth] = style->latexname();
environment_inner[depth] = "!-- --"; environment_inner[depth] = "!-- --";
lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, environment_stack[depth]); lines += sgml::openTag(os, depth + command_depth, mixcont, environment_stack[depth]);
} else { } else {
if (environment_inner[depth] != "!-- --") { if (environment_inner[depth] != "!-- --") {
item_name= "listitem"; item_name= "listitem";
lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name); lines += sgml::closeTag(os, command_depth + depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry") if (environment_inner[depth] == "varlistentry")
lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]); lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_inner[depth]);
} }
} }
@ -1696,7 +1697,7 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
if (style->latexparam() == "CDATA") if (style->latexparam() == "CDATA")
os << "<![CDATA["; os << "<![CDATA[";
else else
lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style->latexparam()); lines += sgml::openTag(os, depth + command_depth, mixcont, style->latexparam());
} }
break; break;
} }
@ -1704,14 +1705,14 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
desc_on = (style->labeltype == LABEL_MANUAL); desc_on = (style->labeltype == LABEL_MANUAL);
environment_inner[depth] = desc_on?"varlistentry":"listitem"; environment_inner[depth] = desc_on?"varlistentry":"listitem";
lines += buf->sgmlOpenTag(os, depth + 1 + command_depth, mixcont, environment_inner[depth]); lines += sgml::openTag(os, depth + 1 + command_depth, mixcont, environment_inner[depth]);
item_name = desc_on?"term":"para"; item_name = desc_on?"term":"para";
lines += buf->sgmlOpenTag(os, depth + 1 + command_depth, mixcont, item_name); lines += sgml::openTag(os, depth + 1 + command_depth, mixcont, item_name);
break; break;
default: default:
lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style->latexname()); lines += sgml::openTag(os, depth + command_depth, mixcont, style->latexname());
break; break;
} }
@ -1726,19 +1727,19 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
if (style->latexparam() == "CDATA") if (style->latexparam() == "CDATA")
os << "]]>"; os << "]]>";
else else
lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style->latexparam()); lines += sgml::closeTag(os, depth + command_depth, mixcont, style->latexparam());
} }
break; break;
case LATEX_ITEM_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT:
if (desc_on == 1) break; if (desc_on == 1) break;
end_tag= "para"; end_tag= "para";
lines += buf->sgmlCloseTag(os, depth + 1 + command_depth, mixcont, end_tag); lines += sgml::closeTag(os, depth + 1 + command_depth, mixcont, end_tag);
break; break;
case LATEX_PARAGRAPH: case LATEX_PARAGRAPH:
lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style->latexname()); lines += sgml::closeTag(os, depth + command_depth, mixcont, style->latexname());
break; break;
default: default:
lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style->latexname()); lines += sgml::closeTag(os, depth + command_depth, mixcont, style->latexname());
break; break;
} }
} }
@ -1748,12 +1749,12 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
if (!environment_stack[depth].empty()) { if (!environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") { if (environment_inner[depth] != "!-- --") {
item_name = "listitem"; item_name = "listitem";
lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name); lines += sgml::closeTag(os, command_depth + depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry") if (environment_inner[depth] == "varlistentry")
lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]); lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_inner[depth]);
} }
lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]); lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_stack[depth]);
} }
} }
@ -2763,7 +2764,7 @@ void InsetText::collapseParagraphs(BufferView * bv) const
llt->selection.end.pos() + paragraphs.begin()->size()); llt->selection.end.pos() + paragraphs.begin()->size());
} }
} }
pasteParagraph(bparams, &*paragraphs.begin()); mergeParagraph(bparams, &*paragraphs.begin());
} }
reinitLyXText(); reinitLyXText();
} }
@ -2805,7 +2806,7 @@ void InsetText::appendParagraphs(BufferParams const & bparams,
// paste it! // paste it!
lastbuffer->next(buf); lastbuffer->next(buf);
buf->previous(lastbuffer); buf->previous(lastbuffer);
pasteParagraph(bparams, lastbuffer); mergeParagraph(bparams, lastbuffer);
reinitLyXText(); reinitLyXText();
} }

View File

@ -100,11 +100,9 @@ extern void ShowLatexLog();
LyXFunc::LyXFunc(LyXView * o) LyXFunc::LyXFunc(LyXView * o)
: owner(o), : owner(o),
keyseq(toplevel_keymap.get(), toplevel_keymap.get()), keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()) cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
meta_fake_bit(key_modifier::none)
{ {
meta_fake_bit = key_modifier::none;
lyx_dead_action = LFUN_NOACTION;
lyx_calling_dead_action = LFUN_NOACTION;
} }
@ -742,10 +740,10 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
} }
// Undo/Redo is a bit tricky for insets. // Undo/Redo is a bit tricky for insets.
if (action == LFUN_UNDO) { if (action == LFUN_UNDO) {
view()->menuUndo(); view()->undo();
goto exit_with_message; goto exit_with_message;
} else if (action == LFUN_REDO) { } else if (action == LFUN_REDO) {
view()->menuRedo(); view()->redo();
goto exit_with_message; goto exit_with_message;
} else if (((result=inset-> } else if (((result=inset->
// Hand-over to inset's own dispatch: // Hand-over to inset's own dispatch:
@ -1031,11 +1029,11 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
break; break;
case LFUN_UNDO: case LFUN_UNDO:
view()->menuUndo(); view()->undo();
break; break;
case LFUN_REDO: case LFUN_REDO:
view()->menuRedo(); view()->redo();
break; break;
case LFUN_MENUSEARCH: case LFUN_MENUSEARCH:

View File

@ -78,8 +78,6 @@ private:
/// ///
LyXView * owner; LyXView * owner;
/// ///
static int psd_idx;
///
kb_sequence keyseq; kb_sequence keyseq;
/// ///
kb_sequence cancel_meta_seq; kb_sequence cancel_meta_seq;
@ -89,10 +87,6 @@ private:
void moveCursorUpdate(bool flag = true, bool selecting = false); void moveCursorUpdate(bool flag = true, bool selecting = false);
/// ///
void setupLocalKeymap(); void setupLocalKeymap();
///
kb_action lyx_dead_action;
///
kb_action lyx_calling_dead_action;
/// Error status, only Dispatch can change this flag /// Error status, only Dispatch can change this flag
mutable bool errorstat; mutable bool errorstat;

View File

@ -175,13 +175,7 @@ public:
/// ///
mutable int refresh_y; mutable int refresh_y;
/// ///
int refresh_width;
///
int refresh_x;
///
mutable Row * refresh_row; mutable Row * refresh_row;
///
lyx::pos_type refresh_pos;
/// give and set the LyXText status /// give and set the LyXText status
text_status status() const; text_status status() const;

View File

@ -125,13 +125,8 @@ void breakParagraphConservative(BufferParams const & bparams,
} }
// Be carefull, this does not make any check at all. void mergeParagraph(BufferParams const & bparams, Paragraph * par)
// This method has wrong name, it combined this par with the next par.
// In that sense it is the reverse of break paragraph. (Lgb)
void pasteParagraph(BufferParams const & bparams,
Paragraph * par)
{ {
// copy the next paragraph to this one
Paragraph * the_next = par->next(); Paragraph * the_next = par->next();
// first the DTP-stuff // first the DTP-stuff

View File

@ -28,11 +28,11 @@ void breakParagraphConservative(BufferParams const & bparams,
Paragraph *, Paragraph *,
lyx::pos_type pos); lyx::pos_type pos);
/** Paste this paragraph with the next one. /**
Be carefull, this doesent make any check at all. * Append the next paragraph onto the tail of this one.
*/ * Be careful, this doesent make any check at all.
void pasteParagraph(BufferParams const & bparams, */
Paragraph *); void mergeParagraph(BufferParams const & bparams, Paragraph *);
#if 0 #if 0

View File

@ -7,11 +7,17 @@
* \author John Levon <levon@movementarian.org> * \author John Levon <levon@movementarian.org>
*/ */
#include "sgml.h" #include <config.h>
#include "support/LOstream.h"
#include "paragraph.h" #include "paragraph.h"
#include "sgml.h"
using std::pair; using std::pair;
using std::make_pair; using std::make_pair;
using std::ostream;
using std::endl;
namespace sgml { namespace sgml {
@ -77,4 +83,36 @@ pair<bool, string> escapeChar(char c)
return make_pair(false, str); return make_pair(false, str);
} }
int openTag(ostream & os, Paragraph::depth_type depth,
bool mixcont, string const & latexname)
{
if (!latexname.empty() && latexname != "!-- --") {
if (!mixcont)
os << string(" ", depth);
os << "<" << latexname << ">";
}
if (!mixcont)
os << endl;
return !mixcont;
}
int closeTag(ostream & os, Paragraph::depth_type depth,
bool mixcont, string const & latexname)
{
if (!latexname.empty() && latexname != "!-- --") {
if (!mixcont)
os << endl << string(" ", depth);
os << "</" << latexname << ">";
}
if (!mixcont)
os << endl;
return !mixcont;
}
} // namespace sgml } // namespace sgml

View File

@ -10,21 +10,27 @@
#ifndef SGML_H #ifndef SGML_H
#define SGML_H #define SGML_H
#include <config.h>
#include "LString.h" #include "LString.h"
#include <algorithm> #include <algorithm>
#include <iosfwd>
namespace sgml { namespace sgml {
/** /**
* Escape the given character if necessary * Escape the given character if necessary
* to an SGML entity. The bool return is true * to an SGML entity. Returns true
* if it was a whitespace character. * if it was a whitespace character.
*/ */
std::pair<bool, string> escapeChar(char c); std::pair<bool, string> escapeChar(char c);
/// FIXME
int openTag(std::ostream & os, Paragraph::depth_type depth,
bool mixcont, string const & latexname);
/// FIXME
int closeTag(std::ostream & os, Paragraph::depth_type depth,
bool mixcont, string const & latexname);
} }
#endif // SGML_H #endif // SGML_H

View File

@ -2026,11 +2026,10 @@ void LyXText::insertChar(BufferView * bview, char c)
// we would not get a rebreak! // we would not get a rebreak!
row->fill(fill(bview, row, workWidth(bview))); row->fill(fill(bview, row, workWidth(bview)));
} }
if (c == Paragraph::META_INSET || row->fill() < 0) { if (c == Paragraph::META_INSET || row->fill() < 0) {
refresh_y = y; refresh_y = y;
refresh_row = row; refresh_row = row;
refresh_x = cursor.x();
refresh_pos = cursor.pos();
status(bview, LyXText::NEED_MORE_REFRESH); status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row); breakAgainOneRow(bview, row);
// will the cursor be in another row now? // will the cursor be in another row now?
@ -2055,9 +2054,7 @@ void LyXText::insertChar(BufferView * bview, char c)
need_break_row = 0; need_break_row = 0;
} else { } else {
refresh_y = y; refresh_y = y;
refresh_x = cursor.x();
refresh_row = row; refresh_row = row;
refresh_pos = cursor.pos();
int const tmpheight = row->height(); int const tmpheight = row->height();
setHeightOfRow(bview, row); setHeightOfRow(bview, row);
@ -2789,7 +2786,7 @@ void LyXText::backspace(BufferView * bview)
&& cursor.par()->getAlign() == tmppar->getAlign()) { && cursor.par()->getAlign() == tmppar->getAlign()) {
removeParagraph(tmprow); removeParagraph(tmprow);
removeRow(tmprow); removeRow(tmprow);
pasteParagraph(bview->buffer()->params, cursor.par()); mergeParagraph(bview->buffer()->params, cursor.par());
if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1)) if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1))
; //cursor.par()->insertChar(cursor.pos(), ' '); ; //cursor.par()->insertChar(cursor.pos(), ' ');