Added some more classes for ScriptErrors;

Added split_text function, which is the 'opposite' of break_text;
Script code "f\n(stuff)" now parses as "f;stuff" instead of a function call, "f(stuff)";
Fixed bug in cursor movement, which caused the closing > of a tag at end of input to be overwritten.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1175 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-08-27 18:44:59 +00:00
parent 9abfdd171c
commit dc9405e441
9 changed files with 104 additions and 44 deletions
+22
View File
@@ -108,6 +108,28 @@ class ScriptError : public Error {
inline ScriptError(const String& str) : Error(str) {}
};
/// "Variable not set"
class ScriptErrorNoVariable : public ScriptError {
public:
inline ScriptErrorNoVariable(const String& var) : ScriptError(_("Variable not set: ") + var) {}
};
/// "Can't convert from A to B"
class ScriptErrorConversion : public ScriptError {
public:
inline ScriptErrorConversion(const String& a, const String& b)
: ScriptError(_ERROR_2_("can't convert", a, b)) {}
inline ScriptErrorConversion(const String& value, const String& a, const String& b)
: ScriptError(_ERROR_3_("can't convert value", value, a, b)) {}
};
/// "A has no member B"
class ScriptErrorNoMember : public ScriptError {
public:
inline ScriptErrorNoMember(const String& type, const String& member)
: ScriptError(_ERROR_2_("has no member", type, member)) {}
};
// ----------------------------------------------------------------------------- : Error handling
/// Should errors be written to stdout?
+6 -3
View File
@@ -307,9 +307,12 @@ void cursor_to_index_range(const String& str, size_t cursor, size_t& start, size
if (cur == cursor) start = i;
}
}
end = min(i, size);
if (cur < cursor) start = end = size;
if (end <= start) end = start + 1;
if (cur < cursor) {
start = end = size;
} else {
end = min(i, size);
}
end = max(end, start + 1); // always start < end, since there are always valid cursor positions
}
size_t cursor_to_index(const String& str, size_t cursor, Movement dir) {