kpartColorPrefs.patch

Donald Curtis, 06/28/2008 02:51 AM

Download (23.8 KB)

 
b/kpart_yzis/CMakeLists.txt Fri Jun 27 19:42:25 2008 -0500
16 16
	kteview.cpp
17 17
	kysession.cpp
18 18
	kyview.cpp
19
    kyconfig.cpp
20
    kyconfigpage.cpp
19 21
	kycommand.cpp
20 22
	kycursor.cpp
21 23
	kyeditor.cpp
b/kpart_yzis/kteeditor.cpp Fri Jun 27 19:42:25 2008 -0500
22 22
#include "kteeditor.h"
23 23
#include "ktedocument.h"
24 24
#include "kysession.h"
25
#include "kyconfig.h"
26
#include "kyconfigpage.h"
25 27

  
28
// QT
29
#include <QLabel>
30
#include <QVBoxLayout>
31

  
32
// KDE
33
#include <klocalizedstring.h>
34
#include <kglobal.h>
35
#include <kglobalsettings.h>
26 36

  
27 37
#include <debug.h>
28 38

  
......
34 44

  
35 45
KTEEditor::KTEEditor(QObject* parent)
36 46
        : KTextEditor::Editor(parent)
37
{}
47
{
48
	mConfig = new KYConfig();
49
}
38 50

  
39 51
KTEEditor::~KTEEditor()
40 52
{
......
67 79
    return 0;
68 80
}
69 81

  
70
void KTEEditor::readConfig (KConfig* /*config*/)
82
void KTEEditor::readConfig (KConfig* config)
71 83
{
72
    // TODO: implement
84
	if(!config)
85
	{
86
		config = KGlobal::config().data();
87
	}
88

  
89
	KYConfig::self()->readSettings(KConfigGroup(config, "KYzis Config"));
73 90
}
74 91

  
75
void KTEEditor::writeConfig( KConfig* /*config*/ )
92
void KTEEditor::writeConfig( KConfig* config )
76 93
{
77
    // TODO: implement
94
	if(!config)
95
	{
96
		config = KGlobal::config().data();
97
	}
98

  
99
	KConfigGroup cg(config, "KYzis Config");
100
	KYConfig::self()->writeSettings(cg);
101

  
102
	config->sync();
78 103
}
79 104

  
80 105
bool KTEEditor::configDialogSupported() const
81 106
{
82
    // TODO: implement
83 107
    return false;
84 108
}
85 109

  
......
88 112
    // TODO: implement
89 113
}
90 114

  
115

  
91 116
int KTEEditor::configPages() const
92 117
{
93
    // TODO: implement
118
    return 1;
119
}
120

  
121
KTextEditor::ConfigPage* KTEEditor::configPage( int number, QWidget* parent )
122
{
123
	switch(number)
124
	{
125
		case 0:
126
			// when an option changes we need to see it
127
			// also when an option is deleted
128
			KYColorConfigPage *ccp = new KYColorConfigPage(parent);
129
			foreach(KTextEditor::Document *doc, documents())
130
			{
131
				connect(ccp, SIGNAL(changed()), doc, SLOT(update()));
132
				connect(ccp, SIGNAL(deleted()), doc, SLOT(update()));
133
			}
134
			return ccp;
135
	}
136

  
94 137
    return 0;
95 138
}
96 139

  
97
KTextEditor::ConfigPage* KTEEditor::configPage( int /*number*/, QWidget* /*parent*/ )
140
QString KTEEditor::configPageName( int number ) const
98 141
{
99
    // TODO: implement
100
    return 0;
142
	switch(number)
143
	{
144
		case 0:
145
			return i18n("Colors");
146
	}
147
    return QString("");
101 148
}
102 149

  
103
QString KTEEditor::configPageName( int /*number*/ ) const
150
QString KTEEditor::configPageFullName( int number ) const
104 151
{
105
    // TODO: implement
106
    return QString();
107
}
108

  
109
QString KTEEditor::configPageFullName( int /*number*/ ) const
110
{
111
    // TODO: implement
112
    return QString();
152
	switch(number)
153
	{
154
		case 0:
155
			return i18n("Colors");
156
	}
157
    return QString("");
113 158
}
114 159

  
115 160
KIcon KTEEditor::configPageIcon( int /*number*/ ) const
b/kpart_yzis/kteeditor.h Fri Jun 27 19:42:25 2008 -0500
27 27
#include <ktexteditor/document.h>
28 28
#include <ktexteditor/configpage.h>
29 29

  
30
class KYConfig;
31

  
30 32
class KTEEditor : public KTextEditor::Editor
31 33
{
32 34
    Q_OBJECT
......
51 53

  
52 54
private:
53 55
    KTEEditor (QObject *parent);
56
    
57
    KYConfig *mConfig;
54 58

  
55 59
    static KTEEditor* me;
56 60
    QList<KTextEditor::Document*> m_documents;
b/kpart_yzis/kycursor.cpp Fri Jun 27 19:42:25 2008 -0500
27 27

  
28 28
#include <QPainter>
29 29

  
30
KYCursor::KYCursor( KYEditor* parent, shape type )
31
        : QWidget( parent )
30
#include "debug.h"
31

  
32
#define deepdbg() yzDeepDebug("KYCursor")
33
#define dbg() yzDebug("KYCursor")
34
#define err() yzError("KYCursor")
35

  
36
KYCursor::KYCursor( KYEditor* editor, YViewIface::CursorShape shape )
37
        : QWidget( editor )
32 38
{
39
	mEditor = editor;
33 40
    move( 0, 0 );
34
    setCursorType( type );
41
    setCursorShape( shape );
35 42
}
36 43

  
37 44
KYCursor::~KYCursor()
38 45
{}
39 46

  
40
KYCursor::shape KYCursor::type() const
47
YViewIface::CursorShape KYCursor::shape() const
41 48
{
42
    return mCursorType;
49
    return mCursorShape;
43 50
}
44
void KYCursor::setCursorType( shape type )
51
void KYCursor::setCursorShape( YViewIface::CursorShape shape )
45 52
{
46
    if ( type == mCursorType )
53
    if ( shape == mCursorShape )
47 54
        return ;
48
    mCursorType = type;
55
    mCursorShape = shape;
49 56
    int w = parentWidget()->fontMetrics().maxWidth();
50 57
    int h = parentWidget()->fontMetrics().lineSpacing();
51
    if ( mCursorType == VBAR )
58
    if ( mCursorShape == YViewIface::CursorVbar )
52 59
        w = 2;
53 60
    resize( w, h );
54 61
}
55 62

  
56 63
void KYCursor::paintEvent( QPaintEvent* )
57 64
{
65
    //const YDrawCell cell( mView->m_drawBuffer.at( mEdit->translateRealToPosition(pos()) ) );
66
	const YDrawCell cell( mEditor->view()->getCursorDrawCell() );
67
    QColor cbg, cfg;
68

  
69
    deepdbg().SPrintf( "paintEvent(): cell string='%s'", qp(cell.c) );
70

  
71
    if (cell.bg.isValid()) {
72
        deepdbg() << "paintEvent(): valid cell bg" << endl;
73
        cbg = QColor(cell.bg.rgb());
74
        //cbg = QColor( Qt::red );
75
    } else {
76
        deepdbg() << "paintEvent(): invalid cell bg" << endl;
77
        cbg = parentWidget()->palette().color(QPalette::Window);
78
        //cbg = QColor(Qt::magenta);
79
    }
80

  
81
    deepdbg() << "paintEvent(): cell background=" << cbg.name() << endl;
82

  
83
    if ( cell.fg.isValid() ) {
84
        deepdbg() << "paintEvent(): valid cell fg" << endl;
85
        cfg = QColor(cell.fg.rgb());
86
        //cfg = QColor(Qt::blue);
87
    } else {
88
        deepdbg() << "paintEvent(): invalid cell fg" << endl;
89
        cfg = parentWidget()->palette().color(QPalette::WindowText);
90
        //cfg = QColor(Qt::cyan);
91
    }
92
    deepdbg() << "paintEvent(): cell foreground=" << cfg.name() << endl;
93

  
94

  
58 95
    QPainter p( this );
96
    QRect r = rect();
97
	YViewIface::CursorShape s = shape();
98
    deepdbg() << "paintEvent(): shape=" << s << endl;
99
    switch ( s ) {
100
		case YViewIface::CursorFilledRect :
101
        p.setPen( cbg );
102
        p.setBackground( cfg );
103
        // erase with cell foreground
104
        p.eraseRect( rect() );
105
        // paint character with cell background
106
        p.drawText( rect(), cell.c );
107
        break;
59 108

  
60
#define GET_cell \
61
    KYView* yzview = static_cast<KYView*>( parentWidget()->parentWidget() ); \
62
    YDrawCell cell = yzview->getCursorDrawCell( )
63
#define SET_pen \
64
    p.setPen( cell.bg.isValid() ? QColor( cell.bg.rgb() ) : parentWidget()->palette().window().color() );
109
		case YViewIface::CursorFrameRect :
110
        p.setPen( cfg );
111
        p.setBackground( cbg );
112
        // erase with cell background
113
        p.eraseRect( r );
114
        // paint character with cell foreground
115
        p.drawText( r, cell.c );
65 116

  
66
    switch ( type() ) {
67
    case SQUARE : {
68
            GET_cell;
69
            SET_pen;
70
            p.setBackground( cell.fg.isValid() ? QBrush( cell.fg.rgb() ) : parentWidget()->palette().windowText() );
71
            p.eraseRect( rect() );
72
            p.drawText( rect(), cell.c );
73
        }
117
        // paint rect with cell foreground
118
        r.adjust(0, 0, -1, -1);
119
        p.drawRect( r );
74 120
        break;
75
    case RECT : {
76
            GET_cell;
77
            SET_pen;
78
            p.drawRect( rect() );
79
        }
121

  
122
		case YViewIface::CursorVbar :
123
        r.setWidth( 2 );
124
        p.fillRect( r, QBrush(cfg) );
80 125
        break;
81
    case VBAR :
82
        p.fillRect( rect(), parentWidget()->palette().text() );
126

  
127
		case YViewIface::CursorHbar:
128
        // erase with cell background
129
        p.eraseRect( r );
130
        // paint character with cell foreground
131
        p.drawText( r, cell.c );
132
        r.setTop( r.bottom() - 2 );
133
        p.fillRect( r, QBrush(cfg) );
83 134
        break;
84
    case HBAR :
85
        p.fillRect( rect(), parentWidget()->palette().text() );
86
        break;
135

  
136
		case YViewIface::CursorHidden:
137
        // erase with cell background
138
        p.eraseRect( r );
139
        // paint character with cell foreground
140
        p.drawText( r, cell.c );
141
        return ;
87 142
    }
88 143
}
89 144

  
b/kpart_yzis/kycursor.h Fri Jun 27 19:42:25 2008 -0500
21 21
#ifndef _KY_CURSOR_H_
22 22
#define _KY_CURSOR_H_
23 23

  
24
#include "viewiface.h"
25

  
24 26
#include <QPixmap>
25 27
#include <QWidget>
26 28

  
......
30 32
{
31 33
    Q_OBJECT
32 34
public :
33
    enum shape {
34
        SQUARE,
35
        VBAR,
36
        HBAR,
37
        RECT,
38
    };
39

  
40
    KYCursor( KYEditor* parent, shape type );
35
    KYCursor( KYEditor* editor, YViewIface::CursorShape shape );
41 36
    virtual ~KYCursor();
42 37

  
43
    void setCursorType( shape type );
44
    shape type() const;
38
    void setCursorShape( YViewIface::CursorShape shape );
39
    YViewIface::CursorShape shape() const;
45 40

  
46 41
protected :
47 42
    virtual void paintEvent( QPaintEvent* event );
48 43

  
49 44
private :
50
    shape mCursorType;
45
    YViewIface::CursorShape mCursorShape;
46
    KYEditor *mEditor;
51 47
};
52 48

  
53 49
#endif
b/kpart_yzis/kyeditor.cpp Fri Jun 27 19:42:25 2008 -0500
22 22
#include "kyeditor.h"
23 23
#include "kyview.h"
24 24
#include "kysession.h"
25
#include "kyconfig.h"
25 26

  
26 27
#include <QSignalMapper>
27 28
#include <QAction>
......
42 43
#include <libyzis/buffer.h>
43 44
#include <libyzis/action.h>
44 45

  
45
KYEditor::KYEditor(KYView* parent)
46
        : QWidget(parent)
46
KYEditor::KYEditor(KYView* view)
47
        : QWidget(view)
47 48
{
48
    mParent = parent;
49
    mView = view;
49 50
    setFocusPolicy( Qt::StrongFocus );
50 51
    mUseArea.setCoords( 0, 0, 0, 0 );
51 52

  
......
55 56
    /* show an edit cursor */
56 57
    QWidget::setCursor( Qt::IBeamCursor );
57 58

  
58
    // TODO: make this one configurable
59
    setFont( QFont( "Monospace" ) );
59
	/* load the pallette */
60
	setPalette( KYConfig::self()->foregroundColor(), KYConfig::self()->backgroundColor(), 0 );
61
    setFont( KYConfig::self()->font() );
60 62

  
61 63
    // for Input Method
62 64
    setAttribute( Qt::WA_InputMethodEnabled, true );
63 65

  
64
    mCursor = new KYCursor( this, KYCursor::SQUARE );
66
    mCursor = new KYCursor( this, YViewIface::CursorFilledRect );
65 67

  
66 68
    QTimer::singleShot(0, static_cast<KYSession*>(YSession::self()), SLOT(frontendGuiReady()) );
67 69
}
......
76 78
    p.setColor( QPalette::Window, bg );
77 79
    QWidget::setPalette( p );
78 80
    setWindowOpacity( opacity );
79
}
80

  
81
KYCursor::shape KYEditor::cursorShape()
82
{
83
    KYCursor::shape s;
84

  
85
    QString shape;
86
    YMode::ModeType m = mParent->modePool()->current()->modeType();
87
    switch ( m ) {
88
    case YMode::ModeInsert :
89
        shape = mParent->getLocalStringOption("cursorinsert");
90
        break;
91
    case YMode::ModeReplace :
92
        shape = mParent->getLocalStringOption("cursorreplace");
93
        break;
94
    case YMode::ModeCompletion :
95
        shape = "keep";
96
        break;
97
    default :
98
        shape = mParent->getLocalStringOption("cursor");
99
        break;
100
    }
101
    if ( shape == "hbar" ) {
102
        s = KYCursor::HBAR;
103
    } else if ( shape == "vbar" ) {
104
        s = KYCursor::VBAR;
105
    } else if ( shape == "keep" ) {
106
        s = mCursor->type();
107
    } else {
108
        if ( hasFocus() )
109
            s = KYCursor::SQUARE;
110
        else
111
            s = KYCursor::RECT;
112
    }
113
    return s;
114 81
}
115 82

  
116 83
QPoint KYEditor::translatePositionToReal( const YCursor& c ) const
......
136 103

  
137 104
YCursor KYEditor::translateRealToAbsolutePosition( const QPoint& p, bool ceil ) const
138 105
{
139
    return translateRealToPosition( p, ceil ) + mParent->getScreenPosition();
140
}
141

  
142
void KYEditor::updateCursor()
143
{
144
    mCursor->setCursorType( cursorShape() );
145
    mCursor->update();
106
    return translateRealToPosition( p, ceil ) + mView->getScreenPosition();
146 107
}
147 108

  
148 109

  
149 110
void KYEditor::updateArea( )
150 111
{
151
    updateCursor();
112
    mCursor->update();
152 113

  
153 114
    int lines = height() / fontMetrics().lineSpacing();
154 115
    int columns = width() / fontMetrics().maxWidth();
155 116
    mUseArea.setBottomRight( QPoint( columns * fontMetrics().maxWidth(), lines * fontMetrics().lineSpacing()) );
156
    mParent->setVisibleArea( columns, lines );
117
    mView->setVisibleArea( columns, lines );
157 118
}
158 119

  
159 120
/**
......
183 144
        modifiers |= YKey::Mod_Ctrl;
184 145

  
185 146
    YKey key( YKey::Key_Invalid, modifiers );
186
    if ( !mParent->containsKey( e->key() ) ) {
147
    if ( !mView->containsKey( e->key() ) ) {
187 148
        if ( e->key() >= Qt::Key_A && e->key() <= Qt::Key_Z && modifiers & YKey::Mod_Ctrl )
188 149
             key.setKey( QChar(e->key()).toLower() );
189 150
        else
190 151
             key.setKey( e->text()[0] );
191 152
    } else {
192
        key.setKey( mParent->getKey( e->key() ) );
153
        key.setKey( mView->getKey( e->key() ) );
193 154
    }
194 155

  
195
    KYSession::self()->sendKey(mParent, key );
156
    KYSession::self()->sendKey(mView, key );
196 157

  
197 158
    e->accept();
198 159
}
......
202 163
    /*
203 164
    FIXME: How to handle mouse events commented out now so kyzis will compile
204 165

  
205
    if ( mParent->myBuffer()->introShown() ) {
206
     mParent->myBuffer()->clearIntro();
207
     mParent->gotodxdy( 0, 0 );
166
    if ( mView->myBuffer()->introShown() ) {
167
     mView->myBuffer()->clearIntro();
168
     mView->gotodxdy( 0, 0 );
208 169
     return;
209 170
    }
210 171
    */
......
212 173
    // leave visual mode if the user clicks somewhere
213 174
    // TODO: this should only be done if the left button is used. Right button
214 175
    // should extend visual selection, like in vim.
215
    if ( mParent->modePool()->current()->isSelMode() )
216
        mParent->modePool()->pop();
176
    if ( mView->modePool()->current()->isSelMode() )
177
        mView->modePool()->pop();
217 178

  
218 179
    if (( e->button() == Qt::LeftButton ) || ( e->button() == Qt::RightButton )) {
219
        if (mParent->modePool()->currentType() != YMode::ModeEx) {
220
            mParent->gotodxdy( e->x() / ( fontMetrics().maxWidth() ) + mParent->getDrawCurrentLeft( ),
221
                                e->y() / fontMetrics().lineSpacing() + mParent->getDrawCurrentTop( ) );
222
            mParent->updateStickyCol();
180
        if (mView->modePool()->currentType() != YMode::ModeEx) {
181
            mView->gotodxdy( e->x() / ( fontMetrics().maxWidth() ) + mView->getDrawCurrentLeft( ),
182
                                e->y() / fontMetrics().lineSpacing() + mView->getDrawCurrentTop( ) );
183
            mView->updateStickyCol();
223 184
        }
224 185
    } else if ( e->button() == Qt::MidButton ) {
225 186
        QString text = KApplication::clipboard()->text( QClipboard::Selection );
......
227 188
        if ( text.isNull() )
228 189
            text = QApplication::clipboard()->text( QClipboard::Clipboard );
229 190
        if ( ! text.isNull() ) {
230
            if ( mParent->modePool()->current()->isEditMode() ) {
191
            if ( mView->modePool()->current()->isEditMode() ) {
231 192
                QChar reg = '\"';
232 193
                KYSession::self()->setRegister( reg, text.split( "\n" ) );
233
                mParent->myBuffer()->action()->pasteContent( mParent, reg, false );
234
                mParent->moveRight();
194
                mView->myBuffer()->action()->pasteContent( mView, reg, false );
195
                mView->moveRight();
235 196
            }
236 197
        }
237 198
    }
......
240 201
void KYEditor::mouseMoveEvent( QMouseEvent *e )
241 202
{
242 203
    if (e->button() == Qt::LeftButton) {
243
        if (mParent->modePool()->currentType() == YMode::ModeCommand) {
204
        if (mView->modePool()->currentType() == YMode::ModeCommand) {
244 205
            // start visual mode when user makes a selection with the left mouse button
245
            mParent->modePool()->push( YMode::ModeVisual );
246
        } else if (mParent->modePool()->current()->isSelMode() ) {
206
            mView->modePool()->push( YMode::ModeVisual );
207
        } else if (mView->modePool()->current()->isSelMode() ) {
247 208
            // already in visual mode - move cursor if the mouse pointer has moved over a new char
248 209
            int newX = e->x() / fontMetrics().maxWidth()
249
                       + mParent->getDrawCurrentLeft();
210
                       + mView->getDrawCurrentLeft();
250 211
            int newY = e->y() / fontMetrics().lineSpacing()
251
                       + mParent->getDrawCurrentTop();
212
                       + mView->getDrawCurrentTop();
252 213

  
253
            if (newX != mParent->getCursor().x() || newY != mParent->getCursor().y()) {
254
                mParent->gotodxdy( newX, newY );
214
            if (newX != mView->getCursor().x() || newY != mView->getCursor().y()) {
215
                mView->gotodxdy( newX, newY );
255 216
            }
256 217
        }
257 218
    }
......
259 220

  
260 221
void KYEditor::focusInEvent ( QFocusEvent * )
261 222
{
262
    KYSession::self()->setCurrentView( mParent );
263
    updateCursor();
223
    KYSession::self()->setCurrentView( mView );
224
    mCursor->update();
264 225
}
265 226
void KYEditor::focusOutEvent ( QFocusEvent * )
266 227
{
267
    updateCursor();
228
    mCursor->update();
268 229
}
269 230

  
270 231

  
......
276 237

  
277 238
void KYEditor::paintEvent( QPaintEvent* pe )
278 239
{
279
    updateCursor();
240
	/* load the pallette */
241
	setPalette( KYConfig::self()->foregroundColor(), KYConfig::self()->backgroundColor(), 0 );
242
    setFont( KYConfig::self()->font() );
243

  
244
    mCursor->update();
280 245

  
281 246
    // convert QPaintEvent rect to yzis coordinate
282 247
    QRect r = pe->rect();
......
285 250
    //dbg() << "QYisEdit::paintEvent : " << pe->rect().topLeft() << "," << pe->rect().bottomRight() <<
286 251
    //                              " => " << r.topLeft() << "," << r.bottomRight() << endl;
287 252
    // paint it
288
    mParent->guiPaintEvent( mParent->clipSelection( YSelection( r ) ) );
253
    mView->guiPaintEvent( mView->clipSelection( YSelection( r ) ) );
289 254
}
290 255

  
291 256
void KYEditor::setCursor( int c, int l )
292 257
{
293 258
    // yzDebug() << "setCursor" << endl;
294
    c = c - mParent->getDrawCurrentLeft();
295
    l -= mParent->getDrawCurrentTop();
259
    c = c - mView->getDrawCurrentLeft();
260
    l -= mView->getDrawCurrentTop();
296 261
    unsigned int x = c * fontMetrics().maxWidth();
297
    if ( mParent->getLocalBooleanOption( "rightleft" ) ) {
262
    if ( mView->getLocalBooleanOption( "rightleft" ) ) {
298 263
        x = width() - x - mCursor->width();
299 264
    }
300 265
    mCursor->move( x, l * fontMetrics().lineSpacing() );
......
303 268

  
304 269
    // need for InputMethod (OverTheSpot)
305 270
    // setMicroFocusHint( mCursor->x(), mCursor->y(), mCursor->width(), mCursor->height() );
271
}
272

  
273
void KYEditor::setCursorShape( YViewIface::CursorShape cs )
274
{
275
	mCursor->setCursorShape(cs);
306 276
}
307 277

  
308 278
QPoint KYEditor::cursorCoordinates( )
......
320 290
    cursorRect.moveTo( mCursor->pos() );
321 291
    update( cursorRect );
322 292
    QWidget::scroll( rx, ry, mUseArea );
293
}
294

  
295
KYView * KYEditor::view() const
296
{
297
	return mView;
323 298
}
324 299

  
325 300
void KYEditor::guiDrawCell( QPoint pos, const YDrawCell& cell, QPainter* p )
......
345 320
        r.setTopLeft( translatePositionToReal( YCursor(pos) ) );
346 321
        r.setRight( width() );
347 322
        r.setHeight( fontMetrics().lineSpacing() );
348
        int nb_char = mParent->getColumnsVisible() - pos.x();
323
        int nb_char = mView->getColumnsVisible() - pos.x();
349 324
        p->drawText( r, QString( nb_char, clearChar ) );
350 325
    }
351 326
}
......
370 345
/*
371 346
void KYEditor::imStartEvent( QIMEvent *e )
372 347
{
373
 if ( mParent->mParent->modePool()->current()->supportsInputMethod() ) {
374
  mParent->mParent->modePool()->current()->imBegin( mParent );
348
 if ( mView->mView->modePool()->current()->supportsInputMethod() ) {
349
  mView->mView->modePool()->current()->imBegin( mView );
375 350
 }
376 351
 e->accept();
377 352
}*/
......
380 355
/*
381 356
void KYEditor::imComposeEvent( QIMEvent *e ) {
382 357
 //yzDebug() << "KYEditor::imComposeEvent text=" << e->text() << " len=" << e->selectionLength() << " pos=" << e->cursorPos() << endl;
383
 if ( mParent->mParent->modePool()->current()->supportsInputMethod() ) {
384
  mParent->mParent->modePool()->current()->imCompose( mParent, e->text() );
358
 if ( mView->mView->modePool()->current()->supportsInputMethod() ) {
359
  mView->mView->modePool()->current()->imCompose( mView, e->text() );
385 360
  e->accept();
386 361
 } else {
387 362
  e->ignore();
......
392 367
/*
393 368
void KYEditor::imEndEvent( QIMEvent *e ) {
394 369
// yzDebug() << "KYEditor::imEndEvent text=" << e->text() << " len=" << e->selectionLength() << " pos=" << e->cursorPos() << endl;
395
 if ( mParent->mParent->modePool()->current()->supportsInputMethod() ) {
396
  mParent->mParent->modePool()->current()->imEnd( mParent, e->text() );
370
 if ( mView->mView->modePool()->current()->supportsInputMethod() ) {
371
  mView->mView->modePool()->current()->imEnd( mView, e->text() );
397 372
 } else {
398
  mParent->sendKey( e->text() );
373
  mView->sendKey( e->text() );
399 374
 }
400 375
 e->accept();
401 376
}*/
b/kpart_yzis/kyeditor.h Fri Jun 27 19:42:25 2008 -0500
43 43
    //append text
44 44
    void append ( const QString& );
45 45

  
46
    /**
47
     * move the cursor to the specificed column and line
48
     *
49
     * @param c column number
50
     * @param l line number
51
     */
46 52
    void setCursor(int c, int l);
53

  
54
    /**
55
     * set the cursor shape
56
     *
57
     * @param cs the new cursor shape
58
     */
59
    void setCursorShape( YViewIface::CursorShape cs );
60

  
47 61
    void scroll(int x, int y);
48 62

  
63
    /**
64
     * @return the view associated with this editor
65
     */
66
    KYView * view() const;
49 67

  
50
    KYCursor::shape cursorShape();
51
    void updateCursor();
52 68
    // update text area
53 69
    void updateArea( );
54 70

  
......
113 129
private :
114 130

  
115 131
    KYCursor* mCursor;
116
    KYView* mParent;
132
    KYView* mView;
117 133
    QRect mUseArea;
118 134
};
119 135

  
b/kpart_yzis/kyview.cpp Fri Jun 27 19:42:25 2008 -0500
45 45
{
46 46
    m_editor = new KYEditor( this );
47 47
    m_editor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
48
    // TODO: remove this, as soon as we can configure the edior component
49
    m_editor->setPalette( Qt::white, Qt::black, 0 );
50 48

  
51 49
    m_command = new KYCommand( this );
52 50

  
......
116 114
    m_editor->setCursor( viewCursor().screenX(), viewCursor().screenY() );
117 115
}
118 116

  
117
void KYView::guiCursorChanged( YViewIface::CursorShape cs )
118
{
119
	m_editor->setCursorShape( cs );
120
}
121

  
119 122
void KYView::guiUpdateMode()
120 123
{
121
    m_editor->updateCursor();
122 124
}
123 125

  
124 126
bool KYView::guiPopupFileSaveAs()
b/kpart_yzis/kyview.h Fri Jun 27 19:42:25 2008 -0500
54 54
    virtual YStatusBarIface* guiStatusBar();
55 55
    virtual void guiUpdateFileName();
56 56
    virtual void guiUpdateCursor();
57
    virtual void guiCursorChanged( YViewIface::CursorShape cs );
57 58
    virtual void guiUpdateMode();
58 59
    virtual void guiHighlightingChanged();
59 60
    virtual void guiNotifyContentChanged(const YSelection&);
b/qyzis/qyedit.cpp Fri Jun 27 19:42:25 2008 -0500
115 115
	mCursor->setCursorShape( cs );
116 116
}
117 117

  
118
void QYEdit::updateCursor()
118
void QYEdit::modeChanged()
119 119
{
120 120
    mCursor->update();
121
}
122

  
123
void QYEdit::modeChanged()
124
{
125
    updateCursor();
126 121
}
127 122

  
128 123
void QYEdit::updateArea( )
129 124
{
130 125
    dbg() << "updatearea()" << endl;
131
    updateCursor();
126
    mCursor->update();
132 127

  
133 128
    dbg() << "updateArea(): fixedPitch = " << fontInfo().fixedPitch() << endl;
134 129
    dbg() << "updateArea(): lineheight = " << fontMetrics().lineSpacing() << endl;
......
256 251
    dbg() << "focusInEvent() for " << mView->myBuffer()->fileNameShort() << endl;
257 252
	mView->setCursorShape( mPreviousCursorShape );
258 253
    YSession::self()->setCurrentView( mView );
259
    updateCursor();
254
    mCursor->update();
260 255
}
261 256
void QYEdit::focusOutEvent ( QFocusEvent * )
262 257
{
......
265 260
	if(mPreviousCursorShape != YViewIface::CursorHidden) {
266 261
		mView->setCursorShape( YViewIface::CursorFrameRect );
267 262
	}
268
    updateCursor();
263
    mCursor->update();
269 264
}
270 265

  
271 266
void QYEdit::resizeEvent(QResizeEvent* e)
......
276 271

  
277 272
void QYEdit::paintEvent( QPaintEvent* pe )
278 273
{
279
    updateCursor();
274
    mCursor->update();
280 275
    // convert QPaintEvent rect to yzis coordinate
281 276
    QRect r = pe->rect();
282 277
    r.setTopLeft( translateRealToAbsolutePosition( r.topLeft() ) );