finalcut/src/flineedit.cpp

879 lines
18 KiB
C++
Raw Normal View History

// File: flineedit.cpp
// Provides: class FLineEdit
2015-05-23 13:35:12 +02:00
#include "fapp.h"
#include "flineedit.h"
#include "fstatusbar.h"
//----------------------------------------------------------------------
// class FLineEdit
//----------------------------------------------------------------------
// constructor and destructor
//----------------------------------------------------------------------
2015-09-22 04:18:20 +02:00
FLineEdit::FLineEdit(FWidget* parent)
: FWidget(parent)
, text("")
, label_text("")
, label(new FLabel("", parent))
, dragScroll(FLineEdit::noScroll)
, scrollTimer(false)
, scrollRepeat(100)
, insert_mode(true)
, cursor_pos(0)
, offset(0)
, label_orientation(FLineEdit::label_left)
2015-05-23 13:35:12 +02:00
{
2015-09-22 04:18:20 +02:00
init();
2015-05-23 13:35:12 +02:00
}
//----------------------------------------------------------------------
2015-09-22 04:18:20 +02:00
FLineEdit::FLineEdit (const FString& txt, FWidget* parent)
: FWidget(parent)
, text(txt)
, label_text("")
, label(new FLabel("", parent))
, dragScroll(FLineEdit::noScroll)
, scrollTimer(false)
, scrollRepeat(100)
, insert_mode(true)
, cursor_pos(0)
, offset(0)
, label_orientation(FLineEdit::label_left)
2015-05-23 13:35:12 +02:00
{
2015-09-22 04:18:20 +02:00
init();
2015-05-23 13:35:12 +02:00
setText(txt);
}
//----------------------------------------------------------------------
FLineEdit::~FLineEdit() // destructor
{
if ( ! insert_mode )
{
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
2015-05-23 13:35:12 +02:00
if ( isUrxvtTerminal() )
2015-10-23 23:57:00 +02:00
setXTermCursorColor("rgb:ffff/ffff/ffff");
2015-05-23 13:35:12 +02:00
}
2015-05-23 13:35:12 +02:00
if ( hasFocus() )
hideCursor();
}
// private methods of FLineEdit
//----------------------------------------------------------------------
void FLineEdit::init()
{
label->setAccelWidget(this);
setVisibleCursor();
if ( hasFocus() )
2016-01-24 14:53:09 +01:00
flags |= fc::focus;
2015-05-23 13:35:12 +02:00
if ( isEnabled() )
{
2016-01-24 14:53:09 +01:00
flags |= fc::active;
2015-05-23 13:35:12 +02:00
if ( hasFocus() )
{
foregroundColor = wc.inputfield_active_focus_fg;
backgroundColor = wc.inputfield_active_focus_bg;
}
else
{
foregroundColor = wc.inputfield_active_fg;
backgroundColor = wc.inputfield_active_bg;
}
}
else // inactive
{
foregroundColor = wc.inputfield_inactive_fg;
backgroundColor = wc.inputfield_inactive_bg;
}
}
//----------------------------------------------------------------------
bool FLineEdit::hasHotkey()
{
if ( label_text.isEmpty() )
return 0;
2015-05-23 13:35:12 +02:00
return label_text.includes('&');
}
//----------------------------------------------------------------------
void FLineEdit::draw()
{
bool isFocus;
drawInputField();
2016-01-24 14:53:09 +01:00
isFocus = ((flags & fc::focus) != 0);
2015-05-23 13:35:12 +02:00
if ( isFocus && statusBar() )
{
FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage();
2015-05-23 13:35:12 +02:00
if ( curMsg != msg )
{
statusBar()->setMessage(msg);
statusBar()->drawMessage();
}
}
}
//----------------------------------------------------------------------
void FLineEdit::drawInputField()
{
bool isActiveFocus, isActive, isShadow;
int x;
FString show_text;
2016-01-31 21:06:29 +01:00
int active_focus = fc::active + fc::focus;
isActiveFocus = ((flags & active_focus) == active_focus);
2016-01-24 14:53:09 +01:00
isActive = ((flags & fc::active) != 0);
isShadow = ((flags & fc::shadow) != 0 );
2015-05-23 13:35:12 +02:00
updateVTerm(false);
2015-05-23 13:35:12 +02:00
gotoxy (xpos+xmin-1, ypos+ymin-1);
2015-05-23 13:35:12 +02:00
if ( isMonochron() )
{
2015-10-11 21:56:16 +02:00
setReverse(true);
2015-05-23 13:35:12 +02:00
print (' ');
2015-10-11 21:56:16 +02:00
if ( isActiveFocus )
setReverse(false);
else
setUnderline(true);
2015-05-23 13:35:12 +02:00
}
else if ( isActiveFocus )
{
setColor (wc.inputfield_active_focus_bg, wc.dialog_bg);
2015-09-22 04:18:20 +02:00
if ( isCygwinTerminal() ) // IBM Codepage 850
2015-05-23 13:35:12 +02:00
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
2015-05-23 13:35:12 +02:00
else
print (fc::RightHalfBlock); // ▐
}
else if ( isActive )
{
setColor (wc.inputfield_active_bg, wc.dialog_bg);
2015-09-22 04:18:20 +02:00
if ( isCygwinTerminal() ) // IBM Codepage 850
2015-05-23 13:35:12 +02:00
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
2015-05-23 13:35:12 +02:00
else
print (fc::RightHalfBlock); // ▐
}
else // isInactive
{
setColor (wc.inputfield_inactive_bg, wc.dialog_bg);
2015-09-22 04:18:20 +02:00
if ( isCygwinTerminal() ) // IBM Codepage 850
2015-05-23 13:35:12 +02:00
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
2015-05-23 13:35:12 +02:00
else
print (fc::RightHalfBlock); // ▐
}
2015-10-23 23:57:00 +02:00
if ( isActiveFocus && getMaxColor() < 16 )
setBold();
2015-05-23 13:35:12 +02:00
setColor (foregroundColor, backgroundColor);
show_text = text.mid(uInt(1+offset), uInt(width-2));
if ( isUTF8_linux_terminal() )
{
setUTF8(true);
if ( show_text )
print (show_text);
2015-05-23 13:35:12 +02:00
setUTF8(false);
}
else if ( show_text )
2015-05-23 13:35:12 +02:00
print (show_text);
x = int(show_text.getLength());
2015-09-24 00:41:43 +02:00
while ( x < width-1 )
2015-05-23 13:35:12 +02:00
{
print (' ');
x++;
}
2015-10-23 23:57:00 +02:00
if ( isActiveFocus && getMaxColor() < 16 )
unsetBold();
2015-05-23 13:35:12 +02:00
if ( isMonochron() )
2015-10-11 21:56:16 +02:00
{
setReverse(false);
setUnderline(false);
2015-10-11 21:56:16 +02:00
}
2015-05-23 13:35:12 +02:00
if ( isShadow )
drawShadow ();
updateVTerm(true);
2015-05-23 13:35:12 +02:00
// set the cursor to the first pos.
setCursorPos (xpos+xmin+cursor_pos-offset, ypos+ymin-1);
if ( isCursorInside() && hasFocus() && isHiddenCursor() )
showCursor();
else if ( ! isHiddenCursor() )
hideCursor();
}
//----------------------------------------------------------------------
void FLineEdit::processActivate()
{
if ( ! hasFocus() )
{
setFocus();
redraw();
}
2015-05-23 13:35:12 +02:00
emitCallback("activate");
}
//----------------------------------------------------------------------
void FLineEdit::processChanged()
{
emitCallback("changed");
}
// protected methods of FListBox
//----------------------------------------------------------------------
void FLineEdit::adjustLabel()
{
int label_length = int(label_text.getLength());
if ( hasHotkey() )
label_length--;
assert ( label_orientation == label_above
|| label_orientation == label_left );
switch ( label_orientation )
{
case label_above:
label->setGeometry(xpos, ypos-1, label_length, 1);
break;
2015-09-20 05:44:50 +02:00
2015-05-23 13:35:12 +02:00
case label_left:
2015-05-24 19:15:03 +02:00
label->setGeometry(xpos-label_length, ypos, label_length, 1);
2015-05-23 13:35:12 +02:00
break;
}
}
//----------------------------------------------------------------------
void FLineEdit::adjustSize()
{
FWidget::adjustSize();
adjustLabel();
}
// public methods of FLineEdit
//----------------------------------------------------------------------
void FLineEdit::hide()
{
int s, size, lable_Length;
short fg, bg;
2015-05-23 13:35:12 +02:00
char* blank;
FWidget::hide();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
2015-05-23 13:35:12 +02:00
setColor (fg, bg);
s = hasShadow() ? 1 : 0;
size = width + s;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < height+s; y++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+y);
print (blank);
}
delete[] blank;
2015-05-23 13:35:12 +02:00
lable_Length = int(label_text.getLength());
if ( lable_Length > 0 )
{
assert ( label_orientation == label_above
|| label_orientation == label_left );
switch ( label_orientation )
{
case label_above:
gotoxy (xpos+xmin-1, ypos+ymin-2);
break;
2015-09-20 05:44:50 +02:00
2015-05-23 13:35:12 +02:00
case label_left:
gotoxy (xpos+xmin-int(lable_Length)-1, ypos+ymin-1);
break;
}
2015-05-23 13:35:12 +02:00
blank = new char[lable_Length+1];
memset(blank, ' ', uLong(size));
blank[lable_Length] = '\0';
print (blank);
delete[] blank;
}
}
//----------------------------------------------------------------------
bool FLineEdit::setEnable (bool on)
{
FWidget::setEnable(on);
if ( on )
{
2016-01-24 14:53:09 +01:00
flags |= fc::active;
2015-05-23 13:35:12 +02:00
if ( hasFocus() )
{
foregroundColor = wc.inputfield_active_focus_fg;
backgroundColor = wc.inputfield_active_focus_bg;
}
else
{
foregroundColor = wc.inputfield_active_fg;
backgroundColor = wc.inputfield_active_bg;
}
}
else
{
2016-01-24 14:53:09 +01:00
flags &= ~fc::active;
2015-05-23 13:35:12 +02:00
foregroundColor = wc.inputfield_inactive_fg;
backgroundColor = wc.inputfield_inactive_bg;
}
2015-05-23 13:35:12 +02:00
return on;
}
//----------------------------------------------------------------------
bool FLineEdit::setFocus (bool on)
{
FWidget::setFocus(on);
if ( on )
{
2016-01-24 14:53:09 +01:00
flags |= fc::focus;
2015-05-23 13:35:12 +02:00
if ( isEnabled() )
{
foregroundColor = wc.inputfield_active_focus_fg;
backgroundColor = wc.inputfield_active_focus_bg;
if ( statusBar() )
{
FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage();
2015-05-23 13:35:12 +02:00
if ( curMsg != msg )
statusBar()->setMessage(msg);
}
}
}
else
{
2016-01-24 14:53:09 +01:00
flags &= ~fc::focus;
2015-05-23 13:35:12 +02:00
if ( isEnabled() )
{
foregroundColor = wc.inputfield_active_fg;
backgroundColor = wc.inputfield_active_bg;
2015-05-23 13:35:12 +02:00
if ( statusBar() )
statusBar()->clearMessage();
}
}
2015-05-23 13:35:12 +02:00
return on;
}
//----------------------------------------------------------------------
bool FLineEdit::setShadow (bool on)
{
if ( on
&& (Encoding != fc::VT100 || isTeraTerm() )
&& Encoding != fc::ASCII )
2016-01-24 14:53:09 +01:00
flags |= fc::shadow;
2015-05-23 13:35:12 +02:00
else
2016-01-24 14:53:09 +01:00
flags &= ~fc::shadow;
2015-05-23 13:35:12 +02:00
return on;
}
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
void FLineEdit::onKeyPress (FKeyEvent* ev)
2015-05-23 13:35:12 +02:00
{
int len = int(text.getLength());
2015-09-20 05:44:50 +02:00
int key = ev->key();
2015-05-23 13:35:12 +02:00
switch ( key )
{
case fc::Fkey_left:
cursor_pos--;
2015-05-23 13:35:12 +02:00
if ( cursor_pos < 0 )
cursor_pos=0;
2015-05-23 13:35:12 +02:00
if ( cursor_pos < offset )
offset--;
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
break;
case fc::Fkey_right:
cursor_pos++;
2015-05-23 13:35:12 +02:00
if ( cursor_pos >= len )
cursor_pos=len;
2015-09-24 00:41:43 +02:00
if ( cursor_pos-offset >= width-2 && offset <= len-width+1 )
2015-05-23 13:35:12 +02:00
offset++;
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
break;
case fc::Fkey_home:
cursor_pos=0;
offset=0;
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
break;
case fc::Fkey_end:
cursor_pos=len;
2015-09-24 00:41:43 +02:00
if ( cursor_pos >= width-1 )
2015-05-23 13:35:12 +02:00
offset=len-width+2;
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
break;
case fc::Fkey_dc: // del key
if ( len > 0 && cursor_pos < len )
{
text.remove(uInt(cursor_pos), 1);
processChanged();
}
2015-05-23 13:35:12 +02:00
if ( cursor_pos >= len )
cursor_pos=len;
2015-05-23 13:35:12 +02:00
if ( cursor_pos < 0 )
cursor_pos=0;
2015-09-24 00:41:43 +02:00
if ( offset > 0 && len-offset < width-1 )
2015-05-23 13:35:12 +02:00
offset--;
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
break;
case fc::Fkey_erase:
case fc::Fkey_backspace:
if ( len > 0 && cursor_pos > 0 )
{
text.remove(uInt(cursor_pos-1), 1);
processChanged();
cursor_pos--;
2015-05-23 13:35:12 +02:00
if ( offset > 0 )
offset--;
}
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
break;
case fc::Fkey_ic: // insert key
insert_mode = not insert_mode;
2015-05-23 13:35:12 +02:00
if ( insert_mode )
{
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
2015-05-23 13:35:12 +02:00
if ( isUrxvtTerminal() )
2015-10-23 23:57:00 +02:00
setXTermCursorColor("rgb:ffff/ffff/ffff");
2015-05-23 13:35:12 +02:00
}
else
{
setXTermCursorStyle(fc::steady_block);
setKDECursor(fc::BlockCursor);
setConsoleCursor(fc::full_block_cursor);
2015-05-23 13:35:12 +02:00
if ( isUrxvtTerminal() )
2015-10-24 13:38:58 +02:00
setXTermCursorColor("rgb:eeee/0000/0000");
2015-05-23 13:35:12 +02:00
}
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
break;
case fc::Fkey_return:
case fc::Fkey_enter:
processActivate();
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
break;
case fc::Fkey_tab:
2015-09-20 05:44:50 +02:00
ev->ignore();
2015-05-23 13:35:12 +02:00
break;
default:
if ( key >= 0x20 && key <= 0x10fff )
{
if ( cursor_pos == len )
{
text += wchar_t(key);
processChanged();
}
else if ( len > 0 )
{
if ( insert_mode )
text.insert(wchar_t(key), uInt(cursor_pos));
else
text.overwrite(wchar_t(key), uInt(cursor_pos));
2015-05-23 13:35:12 +02:00
processChanged();
}
else
{
text = wchar_t(key);
processChanged();
}
cursor_pos++;
2015-09-24 00:41:43 +02:00
if ( cursor_pos >= width-1 )
2015-05-23 13:35:12 +02:00
offset++;
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
}
else
2015-09-20 05:44:50 +02:00
ev->ignore();
2015-05-23 13:35:12 +02:00
}
// end of switch
2015-09-20 05:44:50 +02:00
if ( ev->isAccepted()
2015-05-23 13:35:12 +02:00
&& key != fc::Fkey_return
&& key != fc::Fkey_enter )
{
drawInputField();
updateTerminal();
}
}
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
void FLineEdit::onMouseDown (FMouseEvent* ev)
2015-05-23 13:35:12 +02:00
{
int mouse_x, mouse_y;
2016-01-17 02:57:08 +01:00
if ( ev->getButton() != fc::LeftButton )
2015-05-23 13:35:12 +02:00
return;
if ( ! hasFocus() )
{
FWidget* focused_widget = getFocusWidget();
2016-01-17 02:57:08 +01:00
FFocusEvent out (fc::FocusOut_Event);
2015-05-23 13:35:12 +02:00
FApplication::queueEvent(focused_widget, &out);
2015-09-22 04:18:20 +02:00
setFocus();
2015-05-23 13:35:12 +02:00
if ( focused_widget )
focused_widget->redraw();
2015-09-22 04:18:20 +02:00
redraw();
2015-05-23 13:35:12 +02:00
if ( statusBar() )
statusBar()->drawMessage();
}
2015-09-20 05:44:50 +02:00
mouse_x = ev->getX();
mouse_y = ev->getY();
2015-05-23 13:35:12 +02:00
if ( mouse_x >= 2 && mouse_x <= width && mouse_y == 1 )
{
int len = int(text.getLength());
cursor_pos = offset + mouse_x - 2;
2015-05-23 13:35:12 +02:00
if ( cursor_pos >= len )
cursor_pos = len;
2015-05-23 13:35:12 +02:00
drawInputField();
updateTerminal();
}
}
//----------------------------------------------------------------------
void FLineEdit::onMouseUp (FMouseEvent*)
{
if ( dragScroll != FLineEdit::noScroll )
{
2015-12-19 20:49:01 +01:00
delOwnTimer();
2015-05-23 13:35:12 +02:00
dragScroll = FLineEdit::noScroll;
scrollTimer = false;
}
}
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
void FLineEdit::onMouseMove (FMouseEvent* ev)
2015-05-23 13:35:12 +02:00
{
int len, mouse_x, mouse_y;
2016-01-17 02:57:08 +01:00
if ( ev->getButton() != fc::LeftButton )
2015-05-23 13:35:12 +02:00
return;
len = int(text.getLength());
2015-09-20 05:44:50 +02:00
mouse_x = ev->getX();
mouse_y = ev->getY();
2015-05-23 13:35:12 +02:00
if ( mouse_x >= 2 && mouse_x <= width && mouse_y == 1 )
{
cursor_pos = offset + mouse_x - 2;
2015-05-23 13:35:12 +02:00
if ( cursor_pos >= len )
cursor_pos=len;
2015-05-23 13:35:12 +02:00
drawInputField();
updateTerminal();
}
// auto-scrolling when dragging mouse outside the widget
if ( mouse_x < 2 )
{
// drag left
if ( ! scrollTimer && offset > 0 )
{
scrollTimer = true;
addTimer(scrollRepeat);
dragScroll = FLineEdit::scrollLeft;
}
2015-05-23 13:35:12 +02:00
if ( offset == 0 )
{
2015-12-19 20:49:01 +01:00
delOwnTimer();
2015-05-23 13:35:12 +02:00
dragScroll = FLineEdit::noScroll;
}
}
else if ( mouse_x >= width )
{
// drag right
2015-09-24 00:41:43 +02:00
if ( ! scrollTimer && offset <= len-width+1 )
2015-05-23 13:35:12 +02:00
{
scrollTimer = true;
addTimer(scrollRepeat);
dragScroll = FLineEdit::scrollRight;
}
2015-05-23 13:35:12 +02:00
if ( offset == len-width+2 )
{
2015-12-19 20:49:01 +01:00
delOwnTimer();
2015-05-23 13:35:12 +02:00
dragScroll = FLineEdit::noScroll;
}
}
else
{
// no dragging
2015-12-19 20:49:01 +01:00
delOwnTimer();
2015-05-23 13:35:12 +02:00
scrollTimer = false;
dragScroll = FLineEdit::noScroll;
}
}
//----------------------------------------------------------------------
void FLineEdit::onTimer (FTimerEvent*)
{
int len = int(text.getLength());
switch ( dragScroll )
{
case FLineEdit::noScroll:
return;
case FLineEdit::scrollLeft:
if ( offset == 0)
{
dragScroll = FLineEdit::noScroll;
return;
}
2015-05-23 13:35:12 +02:00
offset--;
2015-05-23 13:35:12 +02:00
if ( offset < 0 )
offset = 0;
2015-05-23 13:35:12 +02:00
cursor_pos--;
2015-05-23 13:35:12 +02:00
if ( cursor_pos < 0 )
cursor_pos = 0;
2015-05-23 13:35:12 +02:00
break;
case FLineEdit::scrollRight:
if ( offset == len-width+2 )
{
dragScroll = FLineEdit::noScroll;
return;
}
2015-05-23 13:35:12 +02:00
offset++;
2015-05-23 13:35:12 +02:00
if ( offset > len-width+2 )
offset = len-width+2;
2015-05-23 13:35:12 +02:00
cursor_pos++;
2015-05-23 13:35:12 +02:00
if ( cursor_pos > len )
cursor_pos = len;
2015-09-20 05:44:50 +02:00
default:
break;
2015-05-23 13:35:12 +02:00
}
drawInputField();
updateTerminal();
}
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
void FLineEdit::onAccel (FAccelEvent* ev)
2015-05-23 13:35:12 +02:00
{
if ( isEnabled() )
{
if ( ! hasFocus() )
{
2015-09-20 05:44:50 +02:00
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
2016-01-17 02:57:08 +01:00
FFocusEvent out (fc::FocusOut_Event);
2015-05-23 13:35:12 +02:00
FApplication::queueEvent(focused_widget, &out);
2015-09-22 04:18:20 +02:00
setFocus();
2015-05-23 13:35:12 +02:00
if ( focused_widget )
focused_widget->redraw();
2015-09-22 04:18:20 +02:00
redraw();
2015-05-23 13:35:12 +02:00
if ( statusBar() )
{
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
}
2015-09-20 05:44:50 +02:00
ev->accept();
2015-05-23 13:35:12 +02:00
}
}
//----------------------------------------------------------------------
void FLineEdit::onHide (FHideEvent*)
{
if ( ! insert_mode )
{
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() )
2015-10-23 23:57:00 +02:00
setXTermCursorColor("rgb:ffff/ffff/ffff");
2015-05-23 13:35:12 +02:00
}
2015-05-23 13:35:12 +02:00
if ( hasFocus() )
hideCursor();
}
//----------------------------------------------------------------------
void FLineEdit::onFocusIn (FFocusEvent*)
{
if ( isCursorInside() )
showCursor();
if ( insert_mode )
{
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() )
2015-10-23 23:57:00 +02:00
setXTermCursorColor("rgb:ffff/ffff/ffff");
2015-05-23 13:35:12 +02:00
}
else
{
setXTermCursorStyle(fc::steady_block);
setKDECursor(fc::BlockCursor);
setConsoleCursor(fc::full_block_cursor);
if ( isUrxvtTerminal() )
2015-10-23 23:57:00 +02:00
setXTermCursorColor("rgb:0000/0000/0000");
2015-05-23 13:35:12 +02:00
}
2015-05-23 13:35:12 +02:00
if ( statusBar() )
{
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
}
//----------------------------------------------------------------------
void FLineEdit::onFocusOut (FFocusEvent*)
{
if ( statusBar() )
{
statusBar()->clearMessage();
statusBar()->drawMessage();
}
if ( ! insert_mode )
{
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
2015-05-23 13:35:12 +02:00
if ( isUrxvtTerminal() )
2015-10-23 23:57:00 +02:00
setXTermCursorColor("rgb:ffff/ffff/ffff");
2015-05-23 13:35:12 +02:00
}
hideCursor();
}
//----------------------------------------------------------------------
void FLineEdit::clearText()
{
offset = 0;
cursor_pos = 0;
text.clear();
}
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
void FLineEdit::setText (FString txt)
{
offset = 0;
cursor_pos = 0;
if ( txt )
text = txt;
else
text = "";
2015-05-23 13:35:12 +02:00
}
//----------------------------------------------------------------------
void FLineEdit::setLabelText (FString ltxt)
{
label_text = ltxt;
label->setText(label_text);
adjustLabel();
}
//----------------------------------------------------------------------
void FLineEdit::setLabelOrientation(label_o o)
{
label_orientation = o;
adjustLabel();
}