patch from vadim to fix the issues in input-areas he introduced with his last
patch
This commit is contained in:
parent
5763339f4c
commit
4ddda95f20
2 changed files with 39 additions and 25 deletions
|
@ -1,6 +1,8 @@
|
|||
(Format: Year/Month/Day)
|
||||
Changes for 0.9.13
|
||||
*05/05/07:
|
||||
* Fix isses in patch from Vadim (thanx Vadim)
|
||||
FbTk/TextBox.cc
|
||||
* Remove default "gray" background (Simon)
|
||||
FbTk/FbWindow.cc
|
||||
* Fix titlebar transparency in some (tabbed) cases (Simon)
|
||||
|
@ -11,7 +13,7 @@ Changes for 0.9.13
|
|||
Styleresources:
|
||||
window.shade.pixmap, window.shade.unfocus.pixmap, window.shade.pressed.pixmap
|
||||
window.unshade.pixmap, window.unshade.unfocus.pixmap, window.unshade.pressed.pixmap
|
||||
etc.
|
||||
etc.
|
||||
- MenuIcon - click on it provides the windowmenu, if the app
|
||||
contains a pixmap (gvim, konqueror etc etc) the pixmap is displayed, a
|
||||
little menu otherwise.
|
||||
|
@ -26,7 +28,7 @@ Changes for 0.9.13
|
|||
Ewmh.hh/cc
|
||||
* Fix potential segfault menu bug, thanks chenfeng (Simon)
|
||||
Menu.cc
|
||||
* Added more KeyActions to TextBox (thanx to Vadim <suhanov_vadim@mail.ru>
|
||||
* Added more KeyActions to TextBox (thanx to Vadim <suhanov_vadim at mail dot ru>
|
||||
Control + LeftArrow -> Moves cursor to the left direction, up to next word.
|
||||
Control + RightArrow -> to the right direction.
|
||||
Control + BackSpace -> Removes everything from the cursor left side, up to next left word.
|
||||
|
|
|
@ -246,44 +246,54 @@ void TextBox::keyPressEvent(XKeyEvent &event) {
|
|||
m_cursor_pos = 0;
|
||||
m_end_pos = 0;
|
||||
break;
|
||||
case XK_Left:
|
||||
if (m_cursor_pos && m_text.size()){
|
||||
m_cursor_pos = findEmptySpaceLeft();
|
||||
case XK_Left: {
|
||||
int pos = findEmptySpaceLeft();
|
||||
if (pos < m_start_pos){
|
||||
m_start_pos = pos;
|
||||
m_cursor_pos = 0;
|
||||
} else if (m_start_pos > 0) {
|
||||
m_cursor_pos = pos - m_start_pos;
|
||||
} else {
|
||||
m_cursor_pos = pos;
|
||||
}
|
||||
adjustPos();
|
||||
}
|
||||
break;
|
||||
case XK_Right:
|
||||
if (m_text.size() && m_cursor_pos < m_text.size()){
|
||||
m_cursor_pos = findEmptySpaceRight();
|
||||
int pos = findEmptySpaceRight() - m_start_pos;
|
||||
if (m_start_pos + pos <= m_end_pos)
|
||||
m_cursor_pos = pos;
|
||||
else if (m_end_pos < text().size()) {
|
||||
m_cursor_pos = pos;
|
||||
m_end_pos = pos;
|
||||
}
|
||||
|
||||
adjustPos();
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case XK_BackSpace: {
|
||||
if (!m_cursor_pos || !m_text.size())
|
||||
break;
|
||||
|
||||
int pos = findEmptySpaceLeft();
|
||||
m_text.erase(pos, m_cursor_pos - pos + m_start_pos);
|
||||
|
||||
m_text.erase(pos, m_cursor_pos - pos);
|
||||
m_start_pos = 0;
|
||||
m_cursor_pos = pos;
|
||||
m_end_pos = m_text.size();
|
||||
if (pos < m_start_pos){
|
||||
m_start_pos = pos;
|
||||
m_cursor_pos = 0;
|
||||
} else if (m_start_pos > 0) {
|
||||
m_cursor_pos = pos - m_start_pos;
|
||||
} else {
|
||||
m_cursor_pos = pos;
|
||||
}
|
||||
adjustPos();
|
||||
}
|
||||
break;
|
||||
case XK_Delete: {
|
||||
|
||||
if (!m_text.size() || m_cursor_pos >= m_text.size())
|
||||
break;
|
||||
|
||||
int pos = findEmptySpaceRight();
|
||||
|
||||
m_text.erase(m_cursor_pos, pos - m_cursor_pos);
|
||||
m_start_pos = 0;
|
||||
m_cursor_pos = m_cursor_pos;
|
||||
m_end_pos = m_text.size();
|
||||
|
||||
m_text.erase(m_cursor_pos + m_start_pos, pos - (m_cursor_pos + m_start_pos));
|
||||
adjustPos();
|
||||
}
|
||||
break;
|
||||
|
@ -399,11 +409,12 @@ void TextBox::adjustStartPos() {
|
|||
int TextBox::findEmptySpaceLeft(){
|
||||
|
||||
// found the first left space symbol
|
||||
int pos = m_text.rfind(' ', m_cursor_pos - 1);
|
||||
int pos = m_text.rfind(' ', (m_start_pos + m_cursor_pos) > 0 ?
|
||||
m_start_pos + m_cursor_pos - 1 : 0);
|
||||
|
||||
// do we have one more space symbol near?
|
||||
int next_pos = -1;
|
||||
while ( pos > 0 && (next_pos = m_text.rfind(' ', pos - 1)) > -1 ){
|
||||
while (pos > 0 && (next_pos = m_text.rfind(' ', pos - 1)) > -1){
|
||||
if (next_pos + 1 < pos)
|
||||
break;
|
||||
pos = next_pos;
|
||||
|
@ -417,17 +428,18 @@ int TextBox::findEmptySpaceLeft(){
|
|||
int TextBox::findEmptySpaceRight(){
|
||||
|
||||
// found the first right space symbol
|
||||
int pos = m_text.find(' ', m_cursor_pos);
|
||||
int pos = m_text.find(' ', m_start_pos + m_cursor_pos);
|
||||
|
||||
// do we have one more space symbol near?
|
||||
int next_pos = -1;
|
||||
while (pos > -1 && pos < m_text.size() && (next_pos = m_text.find(' ', pos + 1)) > -1 ){
|
||||
|
||||
if (next_pos - 1 > pos)
|
||||
break;
|
||||
pos = next_pos;
|
||||
}
|
||||
if (pos < 0)
|
||||
pos = m_text.size();
|
||||
pos = m_text.size() - 1;
|
||||
|
||||
return pos + 1; // (+1) - sets cursor at the right.
|
||||
|
||||
|
|
Loading…
Reference in a new issue