feat: add underline to panels and export

This commit is contained in:
Brendan Hagan
2022-07-26 22:37:57 -04:00
parent 78227a30da
commit 132d8d9351
8 changed files with 47 additions and 19 deletions
+5 -2
View File
@@ -67,7 +67,8 @@ menu:
format: F&ormat
bold: &Bold Ctrl+B
italic: &Italic Ctrl+I
italic: &Italic Ctrl+I
underline: &Underline Ctrl+U
symbols: &Symbols Ctrl+M
reminder text: &Reminder Text Ctrl+R
insert symbol: I&nsert Symbol
@@ -187,7 +188,8 @@ help:
#format:
bold: Makes the selected text bold
italic: Makes the selected text italic
italic: Makes the selected text italic
underline: Makes the selected text underlined
symbols: Draws the selected text with symbols
reminder text: Show reminder text for the selected keyword
# spelling
@@ -390,6 +392,7 @@ tooltip:
bold: Bold
italic: Italic
underline: Underline
symbols: Symbols
reminder text: Reminder Text
Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

+1
View File
@@ -39,6 +39,7 @@ tool/find IMAGE "tool/find.png"
tool/bold IMAGE "tool/bold.png"
tool/italic IMAGE "tool/italic.png"
tool/underline IMAGE "tool/underline.png"
tool/symbol IMAGE "tool/symbol.png"
tool/reminder IMAGE "tool/reminder.png"
tool/no_auto IMAGE "tool/no_auto.png"
+8 -5
View File
@@ -88,7 +88,8 @@ CardsPanel::CardsPanel(Window* parent, int id)
menuFormat = new wxMenu();
add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, "bold", "bold", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, "underline", "underline", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, "symbol", "symbols", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, "reminder", "reminder_text", wxITEM_CHECK);
menuFormat->AppendSeparator();
@@ -184,7 +185,8 @@ wxMenu* CardsPanel::makeAddCardsSubmenu(bool add_single_card_option) {
void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar
add_tool_tr(tb, ID_FORMAT_BOLD, "bold", "bold", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_UNDERLINE, "underline", "underline", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_SYMBOL, "symbol", "symbols", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_REMINDER, "reminder", "reminder_text", false, wxITEM_CHECK);
tb->AddSeparator();
@@ -214,7 +216,8 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
void CardsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar
tb->DeleteTool(ID_FORMAT_BOLD);
tb->DeleteTool(ID_FORMAT_ITALIC);
tb->DeleteTool(ID_FORMAT_ITALIC);
tb->DeleteTool(ID_FORMAT_UNDERLINE);
tb->DeleteTool(ID_FORMAT_SYMBOL);
tb->DeleteTool(ID_FORMAT_REMINDER);
tb->DeleteTool(ID_CARD_ADD);
@@ -253,7 +256,7 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
break;
}
case ID_CARD_REMOVE: ev.Enable(card_list->canDelete()); break;
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_UNDERLINE: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
if (focused_control(this) == ID_EDITOR) {
ev.Enable(editor->canFormat(ev.GetId()));
ev.Check (editor->hasFormat(ev.GetId()));
@@ -327,7 +330,7 @@ void CardsPanel::onCommand(int id) {
case ID_SELECT_COLUMNS: {
card_list->selectColumns();
}
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_UNDERLINE: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
if (focused_control(this) == ID_EDITOR) {
editor->doFormat(id);
}
+8 -5
View File
@@ -35,14 +35,16 @@ void SetInfoPanel::onChangeSet() {
void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar
add_tool_tr(tb, ID_FORMAT_BOLD, "bold", "bold", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_UNDERLINE, "underline", "underline", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_SYMBOL, "symbol", "symbols", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_REMINDER, "reminder", "reminder_text", false, wxITEM_CHECK);
tb->Realize();
// Menus
auto menuFormat = new wxMenu();
add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, "bold", "bold", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, "underline", "underline", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, "symbol", "symbols", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, "reminder", "reminder_text", wxITEM_CHECK);
mb->Insert(2, menuFormat, _MENU_("format"));
@@ -53,7 +55,8 @@ void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
void SetInfoPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar
tb->DeleteTool(ID_FORMAT_BOLD);
tb->DeleteTool(ID_FORMAT_ITALIC);
tb->DeleteTool(ID_FORMAT_ITALIC);
tb->DeleteTool(ID_FORMAT_UNDERLINE);
tb->DeleteTool(ID_FORMAT_SYMBOL);
tb->DeleteTool(ID_FORMAT_REMINDER);
// Menus
@@ -62,7 +65,7 @@ void SetInfoPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
void SetInfoPanel::onUpdateUI(wxUpdateUIEvent& ev) {
switch (ev.GetId()) {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_UNDERLINE: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
ev.Enable(editor->canFormat(ev.GetId()));
ev.Check (editor->hasFormat(ev.GetId()));
break;
@@ -72,7 +75,7 @@ void SetInfoPanel::onUpdateUI(wxUpdateUIEvent& ev) {
void SetInfoPanel::onCommand(int id) {
switch (id) {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_UNDERLINE: case ID_FORMAT_SYMBOL: case ID_FORMAT_REMINDER: {
editor->doFormat(id);
break;
}
+8 -2
View File
@@ -805,7 +805,7 @@ bool TextValueEditor::doDelete() {
bool TextValueEditor::canFormat(int type) const {
switch (type) {
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC:
case ID_FORMAT_BOLD: case ID_FORMAT_ITALIC: case ID_FORMAT_UNDERLINE:
return !style().always_symbol && style().allow_formating;
case ID_FORMAT_SYMBOL:
return !style().always_symbol && style().allow_formating && style().symbol_font.valid();
@@ -822,7 +822,9 @@ bool TextValueEditor::hasFormat(int type) const {
case ID_FORMAT_BOLD:
return is_in_tag(value().value(), _("<b"), selection_start_i, selection_end_i);
case ID_FORMAT_ITALIC:
return is_in_tag(value().value(), _("<i"), selection_start_i, selection_end_i);
return is_in_tag(value().value(), _("<i"), selection_start_i, selection_end_i);
case ID_FORMAT_UNDERLINE:
return is_in_tag(value().value(), _("<u"), selection_start_i, selection_end_i);
case ID_FORMAT_SYMBOL:
return is_in_tag(value().value(), _("<sym"), selection_start_i, selection_end_i);
case ID_FORMAT_REMINDER: {
@@ -848,6 +850,10 @@ void TextValueEditor::doFormat(int type) {
case ID_FORMAT_ITALIC: {
addAction(toggle_format_action(valueP(), _("i"), selection_start_i, selection_end_i, selection_start, selection_end, _("Italic")));
break;
}
case ID_FORMAT_UNDERLINE: {
addAction(toggle_format_action(valueP(), _("u"), selection_start_i, selection_end_i, selection_start, selection_end, _("Underline")));
break;
}
case ID_FORMAT_SYMBOL: {
addAction(toggle_format_action(valueP(), _("sym"), selection_start_i, selection_end_i, selection_start, selection_end, _("Symbols")));
+15 -4
View File
@@ -209,7 +209,8 @@ String to_html(const String& str_in, const SymbolFontP& symbol_font, double symb
String str = remove_tag_contents(str_in,_("<sep-soft"));
String ret;
Tag bold (_("<b>"), _("</b>")),
italic(_("<i>"), _("</i>")),
italic(_("<i>"), _("</i>")),
underline(_("<u>"), _("</u>")),
symbol(_("<span class=\"symbol\">"), _("</span>"));
TagStack tags;
String symbols;
@@ -224,7 +225,11 @@ String to_html(const String& str_in, const SymbolFontP& symbol_font, double symb
} else if (is_substr(str, i, _("i"))) {
tags.open (ret, italic);
} else if (is_substr(str, i, _("/i"))) {
tags.close(ret, italic);
tags.close(ret, italic);
} else if (is_substr(str, i, _("u"))) {
tags.open(ret, underline);
} else if (is_substr(str, i, _("/u"))) {
tags.close(ret, underline);
} else if (is_substr(str, i, _("sym"))) {
tags.open (ret, symbol);
} else if (is_substr(str, i, _("/sym"))) {
@@ -300,7 +305,8 @@ String to_bbcode(const String& str_in) {
String str = remove_tag_contents(str_in,_("<sep-soft"));
String ret;
Tag bold (_("[b]"), _("[/b]")),
italic(_("[i]"), _("[/i]"));
italic(_("[i]"), _("[/i]")),
underline(_("[u]"), _("[/u]"));
TagStack tags;
String symbols;
for (size_t i = 0 ; i < str.size() ; ) {
@@ -315,7 +321,12 @@ String to_bbcode(const String& str_in) {
tags.open (ret, italic);
} else if (is_substr(str, i, _("/i"))) {
tags.close(ret, italic);
} /*else if (is_substr(str, i, _("sym"))) {
} else if (is_substr(str, i, _("u"))) {
tags.open(ret, underline);
} else if (is_substr(str, i, _("/u"))) {
tags.close(ret, underline);
}
/*else if (is_substr(str, i, _("sym"))) {
tags.open (ret, symbol);
} else if (is_substr(str, i, _("/sym"))) {
if (!symbols.empty()) {
+2 -1
View File
@@ -115,7 +115,8 @@ enum ChildMenuID {
// Format menu
ID_FORMAT_BOLD = 6201,
ID_FORMAT_ITALIC,
ID_FORMAT_ITALIC,
ID_FORMAT_UNDERLINE,
ID_FORMAT_SYMBOL,
ID_FORMAT_REMINDER,
ID_INSERT_SYMBOL,