Commit 03477210 authored by twanvl's avatar twanvl

changed <line> semantics, usage is now <line>\n</line>

parent 10c1418b
...@@ -79,12 +79,16 @@ void TextValueEditor::onMotion(const RealPoint& pos, wxMouseEvent& ev) { ...@@ -79,12 +79,16 @@ void TextValueEditor::onMotion(const RealPoint& pos, wxMouseEvent& ev) {
size_t index = v.indexAt(style().getRotation().trInv(pos)); size_t index = v.indexAt(style().getRotation().trInv(pos));
if (select_words) { if (select_words) {
// on the left, swap start and end // on the left, swap start and end
bool left = index < max(selection_start_i, selection_end_i); bool left = selection_end_i < selection_start_i;
if (left != (selection_end_i < selection_start_i)) { size_t next = nextWordBoundry(index);
size_t prev = prevWordBoundry(index);
if (( left && next > max(selection_start_i, selection_end_i)) ||
(!left && prev < min(selection_start_i, selection_end_i))) {
left = !left;
swap(selection_start_i, selection_end_i); swap(selection_start_i, selection_end_i);
} }
// //if (left && selection_end_i < selection_start_i // TODO : still not quite right, requires a moveSelection function that moves start & end simultaniously
moveSelection(TYPE_INDEX, left ? prevWordBoundry(index) : nextWordBoundry(index), false, MOVE_MID); moveSelection(TYPE_INDEX, left ? prev : next, false, MOVE_MID);
} else { } else {
moveSelection(TYPE_INDEX, index, false, MOVE_MID); moveSelection(TYPE_INDEX, index, false, MOVE_MID);
} }
......
...@@ -1190,102 +1190,12 @@ ...@@ -1190,102 +1190,12 @@
<File <File
RelativePath=".\data\card.hpp"> RelativePath=".\data\card.hpp">
</File> </File>
<File
RelativePath=".\data\font.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Profile Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode fast build|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\data\font.hpp">
</File>
<File <File
RelativePath=".\data\game.cpp"> RelativePath=".\data\game.cpp">
</File> </File>
<File <File
RelativePath=".\data\game.hpp"> RelativePath=".\data\game.hpp">
</File> </File>
<File
RelativePath=".\data\keyword.cpp">
</File>
<File
RelativePath=".\data\keyword.hpp">
</File>
<File
RelativePath=".\data\locale.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Profile Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode fast build|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\data\locale.hpp">
</File>
<File <File
RelativePath=".\data\set.cpp"> RelativePath=".\data\set.cpp">
</File> </File>
...@@ -1298,12 +1208,6 @@ ...@@ -1298,12 +1208,6 @@
<File <File
RelativePath=".\data\settings.hpp"> RelativePath=".\data\settings.hpp">
</File> </File>
<File
RelativePath=".\data\statistics.cpp">
</File>
<File
RelativePath=".\data\statistics.hpp">
</File>
<File <File
RelativePath=".\data\stylesheet.cpp"> RelativePath=".\data\stylesheet.cpp">
</File> </File>
...@@ -1340,12 +1244,6 @@ ...@@ -1340,12 +1244,6 @@
<File <File
RelativePath=".\data\symbol.hpp"> RelativePath=".\data\symbol.hpp">
</File> </File>
<File
RelativePath=".\data\symbol_font.cpp">
</File>
<File
RelativePath=".\data\symbol_font.hpp">
</File>
<Filter <Filter
Name="action" Name="action"
Filter=""> Filter="">
...@@ -1619,6 +1517,112 @@ ...@@ -1619,6 +1517,112 @@
RelativePath=".\data\field\text.hpp"> RelativePath=".\data\field\text.hpp">
</File> </File>
</Filter> </Filter>
<Filter
Name="aux"
Filter="">
<File
RelativePath=".\data\font.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Profile Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode fast build|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\data\font.hpp">
</File>
<File
RelativePath=".\data\keyword.cpp">
</File>
<File
RelativePath=".\data\keyword.hpp">
</File>
<File
RelativePath=".\data\locale.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Profile Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode fast build|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\data\locale.hpp">
</File>
<File
RelativePath=".\data\statistics.cpp">
</File>
<File
RelativePath=".\data\statistics.hpp">
</File>
<File
RelativePath=".\data\symbol_font.cpp">
</File>
<File
RelativePath=".\data\symbol_font.hpp">
</File>
</Filter>
</Filter> </Filter>
<Filter <Filter
Name="util" Name="util"
......
...@@ -53,10 +53,10 @@ double TextElements::minScale() const { ...@@ -53,10 +53,10 @@ double TextElements::minScale() const {
struct TextElementsFromString { struct TextElementsFromString {
// What formatting is enabled? // What formatting is enabled?
int bold, italic, symbol; int bold, italic, symbol;
int soft, kwpph; int soft, kwpph, line;
TextElementsFromString() TextElementsFromString()
: bold(0), italic(0), symbol(0), soft(0), kwpph(0) {} : bold(0), italic(0), symbol(0), soft(0), kwpph(0), line(0) {}
// read TextElements from a string // read TextElements from a string
void fromString(TextElements& te, const String& text, size_t start, size_t end, const TextStyle& style, Context& ctx) { void fromString(TextElements& te, const String& text, size_t start, size_t end, const TextStyle& style, Context& ctx) {
...@@ -77,16 +77,9 @@ struct TextElementsFromString { ...@@ -77,16 +77,9 @@ struct TextElementsFromString {
else if (is_substr(text, tag_start, _("</sep-soft"))) soft -= 1; else if (is_substr(text, tag_start, _("</sep-soft"))) soft -= 1;
else if (is_substr(text, tag_start, _( "<atom-kwpph"))) kwpph += 1; else if (is_substr(text, tag_start, _( "<atom-kwpph"))) kwpph += 1;
else if (is_substr(text, tag_start, _("</atom-kwpph"))) kwpph -= 1; else if (is_substr(text, tag_start, _("</atom-kwpph"))) kwpph -= 1;
else if (is_substr(text, tag_start, _("<line"))) { else if (is_substr(text, tag_start, _( "<line"))) line += 1;
// horizontal line else if (is_substr(text, tag_start, _("</line"))) line -= 1;
te.elements.push_back(new_shared3<HorizontalLineTextElement>(text, tag_start, pos)); else if (is_substr(text, tag_start, _("<atom"))) {
/* } else if (is_substr(text, start, _("<error"))) {
// underline with wavy 'error' indicator
size_t end = match_close_tag(text, tag_start);
shared_ptr<ErrorTextElement> e(new ErrorTextElement(text, pos, end));
fromString(e->elements, text, pos, end, style, ctx);
pos = skip_tag(text, end);
*/ } else if (is_substr(text, tag_start, _("<atom"))) {
// 'atomic' indicator // 'atomic' indicator
size_t end = match_close_tag(text, tag_start); size_t end = match_close_tag(text, tag_start);
shared_ptr<AtomTextElement> e(new AtomTextElement(text, pos, end)); shared_ptr<AtomTextElement> e(new AtomTextElement(text, pos, end));
...@@ -107,7 +100,7 @@ struct TextElementsFromString { ...@@ -107,7 +100,7 @@ struct TextElementsFromString {
if (symbol > 0 && style.symbol_font.valid()) { if (symbol > 0 && style.symbol_font.valid()) {
te.elements.push_back(new_shared5<SymbolTextElement>(text, pos, pos + 1, style.symbol_font, &ctx)); te.elements.push_back(new_shared5<SymbolTextElement>(text, pos, pos + 1, style.symbol_font, &ctx));
} else { } else {
te.elements.push_back(new_shared4<FontTextElement> (text, pos, pos + 1, style.font.make(bold > 0, italic > 0))); te.elements.push_back(new_shared5<FontTextElement> (text, pos, pos + 1, style.font.make(bold > 0, italic > 0), line > 0 ? BREAK_LINE : BREAK_HARD));
} }
} }
pos += 1; pos += 1;
......
...@@ -126,17 +126,18 @@ class SimpleTextElement : public TextElement { ...@@ -126,17 +126,18 @@ class SimpleTextElement : public TextElement {
/// A text element that uses a normal font /// A text element that uses a normal font
class FontTextElement : public SimpleTextElement { class FontTextElement : public SimpleTextElement {
public: public:
FontTextElement(const String& text, size_t start ,size_t end, const FontP& font) FontTextElement(const String& text, size_t start ,size_t end, const FontP& font, LineBreak break_style)
: SimpleTextElement(text, start, end) : SimpleTextElement(text, start, end)
, font(font) , font(font), break_style(break_style)
{} {}
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const; virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const; virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const;
virtual double minScale() const; virtual double minScale() const;
private: private:
FontP font; FontP font;
DrawWhat draw_as; DrawWhat draw_as;
LineBreak break_style;
}; };
/// A text element that uses a symbol font /// A text element that uses a symbol font
...@@ -179,7 +180,7 @@ class AtomTextElement : public CompoundTextElement { ...@@ -179,7 +180,7 @@ class AtomTextElement : public CompoundTextElement {
// ----------------------------------------------------------------------------- : Other text elements // ----------------------------------------------------------------------------- : Other text elements
/*
/// A text element that displays a horizontal separator line /// A text element that displays a horizontal separator line
class HorizontalLineTextElement : public TextElement { class HorizontalLineTextElement : public TextElement {
public: public:
...@@ -189,21 +190,7 @@ class HorizontalLineTextElement : public TextElement { ...@@ -189,21 +190,7 @@ class HorizontalLineTextElement : public TextElement {
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const; virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const;
virtual double minScale() const; virtual double minScale() const;
}; };
/*
// ----------------------------------------------------------------------------- : CompoundTextElement
/// A TextElement consisting of sub elements
class CompoundTextElement : public TextElement {
public:
CompoundTextElement(const String& text, size_t start ,size_t end) : TextElement(text, start, end) {}
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
virtual RealSize charSize(RotatedDC& dc, double scale, size_t index) const;
private:
TextElements elements;
};
*/ */
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -44,7 +44,7 @@ void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& ...@@ -44,7 +44,7 @@ void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>&
Char c = text.GetChar(i); Char c = text.GetChar(i);
RealSize s = dc.GetTextExtent(text.substr(start, i - start + 1)); RealSize s = dc.GetTextExtent(text.substr(start, i - start + 1));
out.push_back(CharInfo(RealSize(s.width - prev_width, s.height), out.push_back(CharInfo(RealSize(s.width - prev_width, s.height),
c == _('\n') ? BREAK_HARD : c == _('\n') ? break_style :
c == _(' ') ? BREAK_SOFT : BREAK_NO c == _(' ') ? BREAK_SOFT : BREAK_NO
)); ));
prev_width = s.width; prev_width = s.width;
......
//+----------------------------------------------------------------------------+ /*//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards | //| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven | //| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) | //| License: GNU General Public License 2 or later (see file COPYING) |
...@@ -21,4 +21,4 @@ void HorizontalLineTextElement::getCharInfo(RotatedDC& dc, double scale, vector< ...@@ -21,4 +21,4 @@ void HorizontalLineTextElement::getCharInfo(RotatedDC& dc, double scale, vector<
double HorizontalLineTextElement::minScale() const { double HorizontalLineTextElement::minScale() const {
return 0; // we don't care about scaling return 0; // we don't care about scaling
} }
*/
...@@ -247,9 +247,9 @@ void TokenIterator::readStringToken() { ...@@ -247,9 +247,9 @@ void TokenIterator::readStringToken() {
// escape // escape
if (pos >= input.size()) throw ScriptParseError(_("Unexpected end of input in string constant")); if (pos >= input.size()) throw ScriptParseError(_("Unexpected end of input in string constant"));
c = input.GetChar(pos++); c = input.GetChar(pos++);
if (c == _('n')) str += _('\n'); if (c == _('n')) str += _('\n');
if (c == _('<')) str += _('\1'); // escape for < else if (c == _('<')) str += _('\1'); // escape for <
else str += c; // \ or { or " else str += c; // \ or { or "
} else if (c == _('{')) { } else if (c == _('{')) {
// smart string // smart string
// "a{e}b" --> "a" "{ e }" "b" // "a{e}b" --> "a" "{ e }" "b"
......
...@@ -175,13 +175,6 @@ size_t index_to_cursor(const String& str, size_t index, Movement dir) { ...@@ -175,13 +175,6 @@ size_t index_to_cursor(const String& str, size_t index, Movement dir) {
if (is_substr(str, i, _("<atom")) || is_substr(str, i, _("<sep"))) { if (is_substr(str, i, _("<atom")) || is_substr(str, i, _("<sep"))) {
// skip tag contents, tag counts as a single 'character' // skip tag contents, tag counts as a single 'character'
i = skip_tag(str, match_close_tag(str, i)); i = skip_tag(str, match_close_tag(str, i));
} else if (is_substr(str, i, _("<line"))) {
// no contents, but has width
i = skip_tag(str, i);
if (i > index) {
// HACK: Don't walk past <line>
dir = dir == MOVE_RIGHT ? MOVE_LEFT : MOVE_RIGHT;
}
} else { } else {
i = skip_tag(str, i); i = skip_tag(str, i);
end = i; end = i;
...@@ -216,9 +209,6 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size ...@@ -216,9 +209,6 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size
if (is_substr(str, i, _("<atom")) || is_substr(str, i, _("<sep"))) { if (is_substr(str, i, _("<atom")) || is_substr(str, i, _("<sep"))) {
// skip tag contents, tag counts as a single 'character' // skip tag contents, tag counts as a single 'character'
i = skip_tag(str, match_close_tag(str, i)); i = skip_tag(str, match_close_tag(str, i));
} else if (is_substr(str, i, _("<line"))) {
// no contents, but has width
i = skip_tag(str, i);
} else { } else {
i = skip_tag(str, i); i = skip_tag(str, i);
has_width = false; has_width = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment