mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 13:48:59 +00:00
merge decDepth(), killing some non-parlist code
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6695 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c543071cb3
commit
d533ee3995
@ -72,6 +72,7 @@ using std::make_pair;
|
||||
using std::min;
|
||||
|
||||
using lyx::pos_type;
|
||||
using namespace bv_funcs;
|
||||
|
||||
extern BufferList bufferlist;
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
2003-04-03 John Levon <levon@movementarian.org>
|
||||
|
||||
* bufferview_funcs.h:
|
||||
* bufferview_funcs.C:
|
||||
* lyxfunc.C:
|
||||
* lyxtext.h:
|
||||
* text2.C: parlistize decDepth(), by merging it with incDepth()
|
||||
|
||||
2003-04-03 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* lyxrow.h: store a ParagraphList::iterator instead of a
|
||||
|
@ -38,10 +38,13 @@
|
||||
#include "support/BoostFormat.h"
|
||||
|
||||
namespace {
|
||||
|
||||
LyXFont freefont(LyXFont::ALL_IGNORE);
|
||||
bool toggleall(false);
|
||||
|
||||
}
|
||||
|
||||
namespace bv_funcs {
|
||||
|
||||
// Set data using font and toggle
|
||||
// If successful, returns true
|
||||
@ -214,20 +217,14 @@ void lang(BufferView * bv, string const & l)
|
||||
}
|
||||
|
||||
|
||||
// Change environment depth.
|
||||
// if decInc >= 0, increment depth
|
||||
// if decInc < 0, decrement depth
|
||||
void changeDepth(BufferView * bv, LyXText * text, int decInc)
|
||||
void changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type)
|
||||
{
|
||||
if (!bv->available() || !text)
|
||||
return;
|
||||
|
||||
bv->hideCursor();
|
||||
bv->update(BufferView::SELECT);
|
||||
if (decInc >= 0)
|
||||
text->incDepth();
|
||||
else
|
||||
text->decDepth();
|
||||
text->changeDepth(type);
|
||||
if (text->inset_owner)
|
||||
bv->updateInset((Inset *)text->inset_owner);
|
||||
bv->update(BufferView::SELECT);
|
||||
@ -401,3 +398,5 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
false, !cursor.boundary());
|
||||
}
|
||||
}
|
||||
|
||||
}; // namespace bv_funcs
|
||||
|
@ -20,6 +20,8 @@ class BufferView;
|
||||
class LyXFont;
|
||||
class LyXText;
|
||||
|
||||
namespace bv_funcs {
|
||||
|
||||
/** Set \param data using \param font and \param toggle.
|
||||
* If successful, returns true.
|
||||
*/
|
||||
@ -40,6 +42,14 @@ void update_and_apply_freefont(BufferView * bv, string const & data);
|
||||
*/
|
||||
void apply_freefont(BufferView * bv);
|
||||
|
||||
/// what type of depth change to make
|
||||
enum DEPTH_CHANGE {
|
||||
INC_DEPTH,
|
||||
DEC_DEPTH
|
||||
};
|
||||
|
||||
/// change the nesting depth of the selection
|
||||
extern void changeDepth(BufferView *, LyXText *, DEPTH_CHANGE);
|
||||
|
||||
///
|
||||
extern void emph(BufferView *);
|
||||
@ -54,8 +64,6 @@ extern void number(BufferView *);
|
||||
///
|
||||
extern void tex(BufferView *);
|
||||
///
|
||||
extern void changeDepth(BufferView *, LyXText *, int);
|
||||
///
|
||||
extern void code(BufferView *);
|
||||
///
|
||||
extern void sans(BufferView *);
|
||||
@ -72,4 +80,7 @@ extern string const currentState(BufferView *);
|
||||
///
|
||||
extern void toggleAndShow(BufferView *, LyXFont const &,
|
||||
bool toggleall = true);
|
||||
|
||||
}; // namespace bv_funcs
|
||||
|
||||
#endif
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "gettext.h"
|
||||
#include "language.h"
|
||||
|
||||
using namespace bv_funcs;
|
||||
|
||||
ControlCharacter::ControlCharacter(Dialog & parent)
|
||||
: Dialog::Controller(parent),
|
||||
|
@ -25,6 +25,7 @@ using std::vector;
|
||||
using std::back_inserter;
|
||||
using std::transform;
|
||||
using std::endl;
|
||||
using namespace bv_funcs;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <qstatusbar.h>
|
||||
|
||||
using std::endl;
|
||||
using namespace bv_funcs;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -85,6 +85,7 @@ using std::find_if;
|
||||
using std::vector;
|
||||
using std::transform;
|
||||
using std::back_inserter;
|
||||
using namespace bv_funcs;
|
||||
|
||||
extern BufferList bufferlist;
|
||||
extern LyXServer * lyxserver;
|
||||
@ -1109,11 +1110,11 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
|
||||
break;
|
||||
|
||||
case LFUN_DEPTH_MIN:
|
||||
changeDepth(view(), TEXT(false), -1);
|
||||
changeDepth(view(), TEXT(false), bv_funcs::DEC_DEPTH);
|
||||
break;
|
||||
|
||||
case LFUN_DEPTH_PLUS:
|
||||
changeDepth(view(), TEXT(false), 1);
|
||||
changeDepth(view(), TEXT(false), bv_funcs::INC_DEPTH);
|
||||
break;
|
||||
|
||||
case LFUN_FREEFONT_APPLY:
|
||||
|
@ -1,13 +1,15 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
/**
|
||||
* \file lyxtext.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
* \author unknown
|
||||
* \author Lars Gullik Bjønnes
|
||||
* \author John Levon
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
* Full author contact details are available in file CREDITS
|
||||
*/
|
||||
|
||||
#ifndef LYXTEXT_H
|
||||
#define LYXTEXT_H
|
||||
@ -18,6 +20,7 @@
|
||||
#include "LColor.h"
|
||||
#include "insets/inset.h"
|
||||
#include "RowList.h"
|
||||
#include "bufferview_funcs.h"
|
||||
|
||||
class Buffer;
|
||||
class BufferParams;
|
||||
@ -126,14 +129,8 @@ public:
|
||||
///
|
||||
void setLayout(string const & layout);
|
||||
|
||||
/** increment depth over selection and make a total rebreak of those
|
||||
paragraphs
|
||||
*/
|
||||
void incDepth();
|
||||
|
||||
/** decrement depth over selection and make a total rebreak of those
|
||||
paragraphs */
|
||||
void decDepth();
|
||||
/// increase or decrease the nesting depth of the selected paragraph(s)
|
||||
void changeDepth(bv_funcs::DEPTH_CHANGE type);
|
||||
|
||||
/// get the depth at current cursor position
|
||||
int getDepth() const;
|
||||
|
@ -252,7 +252,7 @@ void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end)
|
||||
|
||||
Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
|
||||
{
|
||||
#if 0
|
||||
#if 1
|
||||
// This is in the critical path for loading!
|
||||
pos_type const siz = size();
|
||||
|
||||
|
@ -48,6 +48,7 @@ using std::min;
|
||||
using std::endl;
|
||||
using std::pair;
|
||||
using lyx::pos_type;
|
||||
using namespace bv_funcs;
|
||||
|
||||
/// top, right, bottom pixel margin
|
||||
extern int const PAPER_MARGIN = 20;
|
||||
|
69
src/text2.C
69
src/text2.C
@ -457,7 +457,7 @@ void LyXText::setLayout(string const & layout)
|
||||
}
|
||||
|
||||
|
||||
void LyXText::incDepth()
|
||||
void LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type)
|
||||
{
|
||||
ParagraphList::iterator pit(cursor.par());
|
||||
ParagraphList::iterator end(cursor.par());
|
||||
@ -480,10 +480,14 @@ void LyXText::incDepth()
|
||||
|
||||
while (true) {
|
||||
int const depth = pit->params().depth();
|
||||
|
||||
if (depth < prev_after_depth
|
||||
&& pit->layout()->labeltype != LABEL_BIBLIO) {
|
||||
pit->params().depth(depth + 1);
|
||||
if (type == bv_funcs::INC_DEPTH) {
|
||||
if (depth < prev_after_depth
|
||||
&& pit->layout()->labeltype != LABEL_BIBLIO) {
|
||||
pit->params().depth(depth + 1);
|
||||
}
|
||||
} else {
|
||||
if (depth)
|
||||
pit->params().depth(depth - 1);
|
||||
}
|
||||
|
||||
prev_after_depth = pit->getMaxDepthAfter();
|
||||
@ -517,61 +521,6 @@ void LyXText::incDepth()
|
||||
}
|
||||
|
||||
|
||||
// decrement depth over selection and
|
||||
// make a total rebreak of those paragraphs
|
||||
void LyXText::decDepth()
|
||||
{
|
||||
// if there is no selection just set the layout
|
||||
// of the current paragraph
|
||||
if (!selection.set()) {
|
||||
selection.start = cursor; // dummy selection
|
||||
selection.end = cursor;
|
||||
}
|
||||
Paragraph * endpar = selection.end.par()->next();
|
||||
Paragraph * undoendpar = endpar;
|
||||
|
||||
if (endpar && endpar->getDepth()) {
|
||||
while (endpar && endpar->getDepth()) {
|
||||
endpar = endpar->next();
|
||||
undoendpar = endpar;
|
||||
}
|
||||
} else if (endpar) {
|
||||
endpar = endpar->next(); // because of parindents etc.
|
||||
}
|
||||
|
||||
setUndo(bv(), Undo::EDIT,
|
||||
selection.start.par(), undoendpar);
|
||||
|
||||
LyXCursor tmpcursor = cursor; // store the current cursor
|
||||
|
||||
// ok we have a selection. This is always between sel_start_cursor
|
||||
// and sel_end cursor
|
||||
cursor = selection.start;
|
||||
|
||||
while (true) {
|
||||
if (cursor.par()->params().depth()) {
|
||||
cursor.par()->params()
|
||||
.depth(cursor.par()->params().depth() - 1);
|
||||
}
|
||||
if (cursor.par() == selection.end.par()) {
|
||||
break;
|
||||
}
|
||||
cursor.par(cursor.par()->next());
|
||||
}
|
||||
|
||||
redoParagraphs(selection.start, endpar);
|
||||
|
||||
// we have to reset the visual selection because the
|
||||
// geometry could have changed
|
||||
setCursor(selection.start.par(), selection.start.pos());
|
||||
selection.cursor = cursor;
|
||||
setCursor(selection.end.par(), selection.end.pos());
|
||||
updateCounters();
|
||||
setSelection();
|
||||
setCursor(tmpcursor.par(), tmpcursor.pos());
|
||||
}
|
||||
|
||||
|
||||
// set font over selection and make a total rebreak of those paragraphs
|
||||
void LyXText::setFont(LyXFont const & font, bool toggleall)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user