#include "Cursor.h"
#include "Dimension.h"
#include "FuncRequest.h"
+#include "FuncStatus.h"
#include "Length.h"
#include "Lexer.h"
#include "MetricsInfo.h"
case InsetSpaceParams::HFILL:
message = _("Horizontal Fill");
break;
+ case InsetSpaceParams::HFILL_PROTECTED:
+ message = _("Protected Horizontal Fill");
+ break;
case InsetSpaceParams::DOTFILL:
message = _("Horizontal Fill (Dots)");
break;
}
case LFUN_MOUSE_RELEASE:
- if (!cur.selection())
+ if (!cur.selection() && cmd.button() == mouse_button::button1)
InsetSpaceMailer(*this).showDialog(&cur.bv());
break;
}
+bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus & status) const
+{
+ switch (cmd.action) {
+ // we handle these
+ case LFUN_INSET_MODIFY:
+ if (cmd.getArg(0) == "space") {
+ InsetSpaceParams params;
+ InsetSpaceMailer::string2params(to_utf8(cmd.argument()), params);
+ status.setOnOff(params_.kind == params.kind);
+ } else
+ status.enabled(true);
+ return true;
+ default:
+ return Inset::getStatus(cur, cmd, status);
+ }
+}
+
+
+void InsetSpace::edit(Cursor & cur, bool, EntryDirection)
+{
+ InsetSpaceMailer(*this).showDialog(&cur.bv());
+}
+
+
void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
{
- if (params_.kind == InsetSpaceParams::HFILL ||
- params_.kind == InsetSpaceParams::DOTFILL ||
- params_.kind == InsetSpaceParams::HRULEFILL) {
+ if (isStretchableSpace()) {
// The metrics for this kinds are calculated externally in
// \c TextMetrics::computeRowMetrics. Those are dummy value:
dim = Dimension(10, 10, 10);
dim.wid = params_.length.inBP();
break;
case InsetSpaceParams::HFILL:
+ case InsetSpaceParams::HFILL_PROTECTED:
case InsetSpaceParams::DOTFILL:
case InsetSpaceParams::HRULEFILL:
// shut up compiler
{
Dimension const dim = dimension(*pi.base.bv);
- if (params_.kind == InsetSpaceParams::HFILL ||
- params_.kind == InsetSpaceParams::DOTFILL ||
- params_.kind == InsetSpaceParams::HRULEFILL) {
+ if (isStretchableSpace()) {
int const asc = theFontMetrics(pi.base.font).ascent('M');
int const desc = theFontMetrics(pi.base.font).descent('M');
int const x0 = x + 1;
pi.pain.line(x0, y2 , x1, y2, Color_added_space,
frontend::Painter::line_onoffdash);
pi.pain.line(x1, y1, x1, y0, Color_added_space);
+ } else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
+ pi.pain.line(x0, y1, x0, y0, Color_latex);
+ pi.pain.line(x0, y2 , x1, y2, Color_latex,
+ frontend::Painter::line_onoffdash);
+ pi.pain.line(x1, y1, x1, y0, Color_latex);
} else if (params_.kind == InsetSpaceParams::DOTFILL) {
pi.pain.line(x0, y1, x0, y0, Color_special);
pi.pain.line(x0, y, x1, y, Color_special,
case InsetSpaceParams::HFILL:
os << "\\hfill{}";
break;
+ case InsetSpaceParams::HFILL_PROTECTED:
+ os << "\\hspace*{\\fill}";
+ break;
case InsetSpaceParams::DOTFILL:
os << "\\dotfill{}";
break;
kind = InsetSpaceParams::NEGTHIN;
else if (command == "\\hfill{}")
kind = InsetSpaceParams::HFILL;
+ else if (command == "\\hspace*{\\fill}")
+ kind = InsetSpaceParams::HFILL_PROTECTED;
else if (command == "\\dotfill{}")
kind = InsetSpaceParams::DOTFILL;
else if (command == "\\hrulefill{}")
case InsetSpaceParams::HFILL:
os << (runparams.free_spacing ? " " : "\\hfill{}");
break;
+ case InsetSpaceParams::HFILL_PROTECTED:
+ os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
+ break;
case InsetSpaceParams::DOTFILL:
os << (runparams.free_spacing ? " " : "\\dotfill{}");
break;
{
switch (params_.kind) {
case InsetSpaceParams::HFILL:
+ case InsetSpaceParams::HFILL_PROTECTED:
os << " ";
return 5;
case InsetSpaceParams::DOTFILL:
os << " ";
break;
case InsetSpaceParams::HFILL:
+ case InsetSpaceParams::HFILL_PROTECTED:
os << '\n';
case InsetSpaceParams::DOTFILL:
// FIXME
bool InsetSpace::isStretchableSpace() const
{
return (params_.kind == InsetSpaceParams::HFILL ||
+ params_.kind == InsetSpaceParams::HFILL_PROTECTED ||
params_.kind == InsetSpaceParams::DOTFILL ||
params_.kind == InsetSpaceParams::HRULEFILL);
}
+docstring InsetSpace::contextMenu(BufferView const &, int, int) const
+{
+ return from_ascii("context-space");
+}
+
+
string const InsetSpaceMailer::name_ = "space";