#include "bcsignals.h"
#include "bctextbox.h"
#include "clip.h"
-#include "colors.h"
+#include "bccolors.h"
#include <ctype.h>
#include "cursors.h"
#include "filesystem.h"
#include "keys.h"
+#include "language.h"
#include <math.h>
#include "bctimer.h"
#include "vframe.h"
delete suggestions_popup;
suggestions->remove_all_objects();
delete suggestions;
+ delete menu;
delete [] wtext;
if( size > 0 )
delete [] text;
separators = 0;
xscroll = 0;
yscroll = 0;
+ menu = 0;
dirty = 1;
selection_active = 0;
return 0;
int BC_TextBox::tstrcmp(const char *cp)
{
- if( !tsize ) return strcmp(text, cp);
- return strncmp(text, cp, tsize);
+ const char *tp = get_text();
+ if( !tsize ) return strcmp(tp, cp);
+ return strncmp(tp, cp, tsize);
}
char *BC_TextBox::tstrcpy(const char *cp)
int BC_TextBox::initialize()
{
+
if (!skip_cursor)
skip_cursor = new Timer;
skip_cursor->update();
draw(0);
set_cursor(IBEAM_CURSOR, 0, 0);
show_window(0);
+
+ add_subwindow(menu = new BC_TextMenu(this));
+ menu->create_objects();
+
return 0;
}
// Show the highlighted text
if( suggestions->size() == 1 ) {
highlight_letter1 = wtext_update();
- text_update(wtext,wlen, text,tsize);
+ int len = text_update(wtext,wlen, text,tsize);
char *current_suggestion = suggestions->get(0);
- int col = highlight_letter1 - suggestion_column;
+ int col = len - suggestion_column;
if( col < 0 ) col = 0;
char *cur = current_suggestion + col;
tstrcat(cur);
const int debug = 0;
if(!enabled) return 0;
- if(get_buttonpress() != WHEEL_UP &&
- get_buttonpress() != WHEEL_DOWN &&
- get_buttonpress() != LEFT_BUTTON &&
- get_buttonpress() != MIDDLE_BUTTON) return 0;
-
-
+// if(get_buttonpress() != WHEEL_UP &&
+// get_buttonpress() != WHEEL_DOWN &&
+// get_buttonpress() != LEFT_BUTTON &&
+// get_buttonpress() != MIDDLE_BUTTON) return 0;
if(debug) printf("BC_TextBox::button_press_event %d\n", __LINE__);
update_scroll = 1;
}
else
+ if(get_buttonpress() == RIGHT_BUTTON)
+ {
+ menu->activate_menu();
+ }
+ else
{
cursor_letter = get_cursor_letter(top_level->cursor_x, top_level->cursor_y);
if( ctrl_down() ) {
switch( get_keypress() ) {
case 'c': case 'C': {
- if(highlight_letter1 != highlight_letter2) {
- copy_selection(SECONDARY_SELECTION);
- result = 1;
- }
+ result = copy(0);
break; }
case 'v': case 'V': {
- paste_selection(SECONDARY_SELECTION);
- find_ibeam(1);
- if(keypress_draw) draw(1);
+ result = paste(0);
dispatch_event = 1;
- result = 1;
break; }
case 'x': case 'X': {
- if(highlight_letter1 != highlight_letter2) {
- copy_selection(SECONDARY_SELECTION);
- delete_selection(highlight_letter1, highlight_letter2, wtext_len);
- highlight_letter2 = ibeam_letter = highlight_letter1;
- }
-
- find_ibeam(1);
- if(keypress_draw) draw(1);
+ result = cut(0);
dispatch_event = 1;
- result = 1;
break; }
case 'u': case 'U': {
if( shift_down() ) {
}
+int BC_TextBox::cut(int do_update)
+{
+ if( highlight_letter1 != highlight_letter2 ) {
+ int wtext_len = wtext_update();
+ copy_selection(SECONDARY_SELECTION);
+ delete_selection(highlight_letter1, highlight_letter2, wtext_len);
+ highlight_letter2 = ibeam_letter = highlight_letter1;
+ }
+
+ find_ibeam(1);
+ if( keypress_draw )
+ draw(1);
+
+ if( do_update ) {
+ skip_cursor->update();
+ handle_event();
+ }
+ return 1;
+}
+
+int BC_TextBox::copy(int do_update)
+{
+ int result = 0;
+ if( highlight_letter1 != highlight_letter2 ) {
+ copy_selection(SECONDARY_SELECTION);
+ result = 1;
+ if( do_update ) {
+ skip_cursor->update();
+ }
+ }
+ return result;
+}
+
+int BC_TextBox::paste(int do_update)
+{
+ paste_selection(SECONDARY_SELECTION);
+ find_ibeam(1);
+ if( keypress_draw )
+ draw(1);
+ if( do_update ) {
+ skip_cursor->update();
+ handle_event();
+ }
+ return 1;
+}
+
+
int BC_TextBox::uses_text()
{
return 1;
len = BC_Resources::encode(BC_Resources::encoding, BC_Resources::wide_encoding,
cstring,len, (char *)wstring,(len+1)*sizeof(wchar_t)) / sizeof(wchar_t);
insert_text(wstring, len);
+ last_keypress = 0;
}
}
tumbler->set_boundaries(min, max);
}
+
+
+BC_TextMenu::BC_TextMenu(BC_TextBox *textbox)
+ : BC_PopupMenu(0, 0, 0, "", 0)
+{
+ this->textbox = textbox;
+}
+
+BC_TextMenu::~BC_TextMenu()
+{
+}
+
+void BC_TextMenu::create_objects()
+{
+ add_item(new BC_TextMenuCut(this));
+ add_item(new BC_TextMenuCopy(this));
+ add_item(new BC_TextMenuPaste(this));
+}
+
+
+BC_TextMenuCut::BC_TextMenuCut(BC_TextMenu *menu)
+ : BC_MenuItem(_("Cut"))
+{
+ this->menu = menu;
+}
+
+int BC_TextMenuCut::handle_event()
+{
+ menu->textbox->cut(1);
+
+ return 0;
+}
+
+
+BC_TextMenuCopy::BC_TextMenuCopy(BC_TextMenu *menu)
+ : BC_MenuItem(_("Copy"))
+{
+ this->menu = menu;
+}
+
+int BC_TextMenuCopy::handle_event()
+{
+ menu->textbox->copy(1);
+ return 0;
+}
+
+
+BC_TextMenuPaste::BC_TextMenuPaste(BC_TextMenu *menu)
+ : BC_MenuItem(_("Paste"))
+{
+ this->menu = menu;
+}
+
+int BC_TextMenuPaste::handle_event()
+{
+ menu->textbox->paste(1);
+ return 0;
+}
+
+
void BC_TumbleTextBox::set_tooltip(const char *text)
{
textbox->set_tooltip(text);