changed: the way how the mouse selection works when you have clicked a button (sin/cos/..)
now if there is no selection and the last character is an operator: + - / * % ^ ( then the text is append at the end (instead of looking for beginning of the expression) this seems to be more comfortable git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@353 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
c4f316d7d3
commit
14f987012d
37
src/tabs.cpp
37
src/tabs.cpp
|
@ -145,27 +145,50 @@ int brackets;
|
|||
}
|
||||
|
||||
|
||||
bool IsWhite(int c)
|
||||
{
|
||||
return c==' ' || c=='\t';
|
||||
}
|
||||
|
||||
|
||||
bool IsOpeningOperand(int c)
|
||||
{
|
||||
return c=='-' || c=='+' || c=='*' ||c=='/' || c=='%' ||c=='^' || c=='(';
|
||||
}
|
||||
|
||||
|
||||
bool IsOpeningOperandBefore(const char * buf, int end)
|
||||
{
|
||||
while( end > 0 && IsWhite(buf[end-1]) )
|
||||
end -= 1;
|
||||
|
||||
if( end == 0 )
|
||||
return false;
|
||||
|
||||
return IsOpeningOperand(buf[end-1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CalcBracketsPos(HWND input, int & start, int & end)
|
||||
{
|
||||
DWORD sel_start, sel_end;
|
||||
|
||||
SendMessage(input, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||
|
||||
if( sel_start != sel_end )
|
||||
{
|
||||
start = sel_start;
|
||||
end = sel_end;
|
||||
|
||||
if( start != end )
|
||||
return;
|
||||
}
|
||||
|
||||
char * buf = GetPrgRes()->GetBufferTemp();
|
||||
start = 0;
|
||||
end = SendMessage(input, WM_GETTEXT, GetPrgRes()->GetBufferSize(), (LPARAM)buf);
|
||||
int len = SendMessage(input, WM_GETTEXT, GetPrgRes()->GetBufferSize(), (LPARAM)buf);
|
||||
|
||||
if( end > 0 )
|
||||
if( len > 0 && !IsOpeningOperandBefore(buf, end) )
|
||||
{
|
||||
start = CalcBracketsPrev(buf, sel_start);
|
||||
end = CalcBracketsNext(buf, end, sel_start);
|
||||
end = CalcBracketsNext(buf, len, sel_start);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue