proposal for extension of KTextEditor interface

F@lk Brettschneider falk.brettschneider at gmx.de
Sun Jan 12 21:46:03 UTC 2003


Joseph Wenninger wrote:

>Hi
>
>Am Son, 2003-01-12 um 00.03 schrieb F at lk Brettschneider:
>  
>
>>>signals:
>>>	void needTextHint(int line, int col, QString &text);
>>>		/*should only be emitted if line and col really changed (not inner
>>>cell moves) when a timeout has happened.
>>>
>>>      
>>>
>>Sound good.
>>
>>    
>>
>>>The slot
>>>
>>>      
>>>
>>Which slot? Do we miss a 4th interface method? How can we set the text 
>>for the tooltip?
>>    
>>
>
>eg:
>
>kdevelop_something::xyz()
>{
>...
>	connect(view,SIGNAL(needTextHint(int,int,
>QString&),SLOT(this,slotTextHint(int,int,QString&))); // the connnection
>should be 1:1 not 1:n
>...
>}
>
>void kdevelop_somthing::slotTextHint(int,int,QString& text) {
>...
>	if(compute_something) text="something" else text=QString();
>...
>}
>
Of course! I didn't see the & after QString. ;) So the signal also gets 
the string for the tooltip.

>
>
>
>  
>
>>>sets the text property and if it is not an emtpy string the
>>>text editor displays it next/above/below the textcell.
>>>
>>>      
>>>
>>What is with Roberto's 5th interface method:  (void setWordValidator( 
>>const QValidator* wordValidator ))? To reduce the number of emitted 
>>signals out of the texteditor. If the validator is something like:
>>
>>class CppExpressionsValidator: public QValidator{
>>...
>>    virtual State validate ( QString & input, int & pos ) const {
>>         Context* ctx = computeContextFromCursorPosition( cursorPosition );
>>         if( ctx->containsVariable( input ) ) 
>>            return Acceptable;
>>         ....
>>    }
>>}
>>
>>signals for tooltips in .cpp files were just emitted for things that make sense.
>>
>>    
>>
>
>I don't think  that this really saves time or CPU. I hope you keep in
>mind, that this validator MUST use ktexteditor interface methods ONLY
>anyways, to be usable with any ktexteditor.
>
>
>
>  
>
>>After reviewing the Microsoft Visual C++ debugger I saw that normal text tooltips show the variable values, but addionally, tooltips on selected text are able to show the value of the selected expression! 
>>Please, can you consider tooltips for selected text in the KTextEditor-Interface too!?!?
>>The editor just must check if the mouse is over selected or unselected text. In case of unselected text it must use the validator suggested by Roberto (see above), in case of selected text it must emit a signal with the selected text that KDevelop tries to resolve as an expression (e.g. '(d->x * d->y) / 45' ) and send the resolved result as tooltip for the editor.
>>
>>    
>>
>
>why not check in the above slotTextHint, if there is a selection ? I
>don't see the need of an additional signal
>
For instance code like this:
...... ( d->x / 100 ) ....
Note there are a lot of spaces in that text.

What text would the signal emit when the user hold the mouse over the 
'x'? 'x'? 'd->x'? '( d->x / 100 )'?

If you don't select text and hold the mouse over the 'x', I would expect 
the signal emits 'x' so that the slot can put the value of x for the 
tooltip in the signal string-parameter.
If you select 'd->x / 100' with the mouse, I would expect the signal 
emits 'd->x / 100' and not only 'x' so that the slot can put the result 
of the expression (maybe '0.4') for the tooltip in the signal 
string-parameter.

I think the KTextEditor cannot know which string the signal at least 
must emit, and would probably not emit the full string we needed.

Emitting the whole file content probably wouldn't be a good idea but I'm 
not sure what the delimiters of the interesting text are that is to be 
scanned by a validator or the slot itself.
Any idea? I suppose also the validator wouldn't help here, would it?

Ciao
F at lk







More information about the KDevelop-devel mailing list