added toggle reminder text action;

updated SymbolsInFont when creating 'insert symbol' menu

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@266 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-04-19 14:04:50 +00:00
parent 9f24da8d02
commit f530cd7244
6 changed files with 65 additions and 11 deletions
+31 -2
View File
@@ -144,8 +144,6 @@ TextValueAction* typing_action(const TextValueP& value, size_t start_i, size_t e
// no change
return nullptr;
} else {
// if (name == _("Backspace")) {
// // HACK: put start after end
if (reverse) {
return new TextValueAction(value, end, start, start+untag(replacement).size(), new_value, action_name);
} else {
@@ -154,6 +152,37 @@ TextValueAction* typing_action(const TextValueP& value, size_t start_i, size_t e
}
}
// ----------------------------------------------------------------------------- : Reminder text
TextToggleReminderAction::TextToggleReminderAction(const TextValueP& value, size_t pos_in)
: ValueAction(value)
{
pos = in_tag(value->value(), _("<kw-"), pos_in, pos_in);
if (pos == String::npos) {
throw InternalError(_("TextToggleReminderAction: not in <kw- tag"));
}
Char c = value->value().GetChar(pos + 4);
enable = !(c == _('1') || c == _('A')); // if it was not enabled, then enable it
old = enable ? _('1') : _('0');
}
String TextToggleReminderAction::getName(bool to_undo) const {
return enable ? _("Show reminder text") : _("Hide reminder text");
}
void TextToggleReminderAction::perform(bool to_undo) {
TextValue& value = static_cast<TextValue&>(*valueP);
String& val = value.value.mutate();
assert(pos + 4 < val.size());
size_t end = match_close_tag(val, pos);
Char& c = val[pos + 4];
swap(c, old);
if (end != String::npos && end + 5 < val.size()) {
val[end + 5] = c; // </kw-c>
}
value.last_update.update();
value.onAction(*this, to_undo); // notify value
}
// ----------------------------------------------------------------------------- : Event
+17 -1
View File
@@ -71,13 +71,29 @@ class TextValueAction : public ValueAction {
String name;
};
/// Action for toggleing some formating tag on or off in some range
/// Action for toggling some formating tag on or off in some range
TextValueAction* toggle_format_action(const TextValueP& value, const String& tag, size_t start_i, size_t end_i, size_t start, size_t end, const String& action_name);
/// Typing in a TextValue, replace the selection [start...end) with replacement
/** start and end are cursor positions, start_i and end_i are indices*/
TextValueAction* typing_action(const TextValueP& value, size_t start_i, size_t end_i, size_t start, size_t end, const String& replacement, const String& action_name);
// ----------------------------------------------------------------------------- : Reminder text
/// Toggle reminder text for a keyword on or off
class TextToggleReminderAction : public ValueAction {
public:
TextToggleReminderAction(const TextValueP& value, size_t pos);
virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo);
private:
size_t pos; ///< Position of "<kw-"
bool enable; ///< Should the reminder text be turned on or off?
Char old; ///< Old value of the <kw- tag
};
// ----------------------------------------------------------------------------- : Event
/// Notification that a script caused a value to change
+4
View File
@@ -323,6 +323,10 @@ RealSize SymbolFont::defaultSymbolSize(Context& ctx, double font_size) {
wxMenu* SymbolFont::insertSymbolMenu(Context& ctx) {
if (!processed_insert_symbol_menu && insert_symbol_menu) {
// update all symbol-in-fonts
FOR_EACH_CONST(sym, symbols) {
sym->update(ctx);
}
// Make menu
processed_insert_symbol_menu = insert_symbol_menu->makeMenu(ID_INSERT_SYMBOL_MENU_MIN, ctx, *this);
}