Changeset a046a0c50b4c83eaa0a435fb80e302aaf11bacc2
- Timestamp:
- 01/06/07 23:44:58 (6 years ago)
- Author:
- Philipp Kern <phil@…>
- Parents:
- 0c7664e2841ae18fc47cb025ca4721a561ecdc99
- Children:
- f12139424c8680cd7a834d6fb2297156c9a582dd
- git-committer:
- Philipp Kern <phil@0x539.de> / 2007-01-06T22:44:58Z+0000
- Message:
-
[project @ Column returns the real column of the text not just the nth character]
Original author: Armin Burgmeier <armin@…>
Date: 2005-07-26 17:25:00+00:00
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rf764263
|
ra046a0c
|
|
| 145 | 145 | /** Obby signal handlers. |
| 146 | 146 | */ |
| 147 | | void on_obby_insert(const obby::insert_record& record); |
| 148 | | void on_obby_delete(const obby::delete_record& record); |
| | 147 | void on_obby_insert_before(const obby::insert_record& record); |
| | 148 | void on_obby_insert_after(const obby::insert_record& record); |
| | 149 | void on_obby_delete_before(const obby::delete_record& record); |
| | 150 | void on_obby_delete_after(const obby::delete_record& record); |
| 149 | 151 | |
| 150 | 152 | void on_obby_change_before(); |
-
|
rf764263
|
ra046a0c
|
|
| 169 | 169 | row = iter.get_line(); |
| 170 | 170 | col = iter.get_line_offset(); |
| | 171 | |
| | 172 | // Add tab characters to col |
| | 173 | if(m_doc.get_document() && is_subscribed() ) |
| | 174 | { |
| | 175 | const std::string& line = m_doc.get_document()->get_line(row); |
| | 176 | unsigned int tabs = m_preferences.editor.tab_width; |
| | 177 | |
| | 178 | // col chars |
| | 179 | std::string::size_type chars = col; col = 0; |
| | 180 | for(std::string::size_type i = 0; i < chars; ++ i) |
| | 181 | { |
| | 182 | unsigned int width = 1; |
| | 183 | if(line[i] == '\t') |
| | 184 | { |
| | 185 | width = (tabs - col % tabs) % tabs; |
| | 186 | if(width == 0) width = tabs; |
| | 187 | } |
| | 188 | col += width; |
| | 189 | } |
| | 190 | } |
| 171 | 191 | } |
| 172 | 192 | |
| … |
… |
|
| 206 | 226 | } |
| 207 | 227 | |
| | 228 | bool Gobby::Document::is_subscribed() const |
| | 229 | { |
| | 230 | return m_subscribed; |
| | 231 | } |
| | 232 | |
| 208 | 233 | bool Gobby::Document::get_modified() const |
| 209 | 234 | { |
| … |
… |
|
| 259 | 284 | } |
| 260 | 285 | |
| 261 | | void Gobby::Document::on_obby_insert(const obby::insert_record& record) |
| | 286 | void Gobby::Document::on_obby_insert_before(const obby::insert_record& record) |
| 262 | 287 | { |
| 263 | 288 | if(m_editing) return; |
| … |
… |
|
| 289 | 314 | } |
| 290 | 315 | |
| 291 | | void Gobby::Document::on_obby_delete(const obby::delete_record& record) |
| | 316 | void Gobby::Document::on_obby_insert_after(const obby::insert_record& record) |
| | 317 | { |
| | 318 | } |
| | 319 | |
| | 320 | void Gobby::Document::on_obby_delete_before(const obby::delete_record& record) |
| 292 | 321 | { |
| 293 | 322 | if(m_editing) return; |
| … |
… |
|
| 305 | 334 | buffer->get_iter_at_line_index(erow, ecol) |
| 306 | 335 | ); |
| | 336 | |
| 307 | 337 | m_editing = false; |
| 308 | 338 | } |
| 309 | 339 | |
| | 340 | void Gobby::Document::on_obby_delete_after(const obby::delete_record& record) |
| | 341 | { |
| | 342 | } |
| | 343 | |
| 310 | 344 | void Gobby::Document::on_obby_change_before() |
| 311 | 345 | { |
| … |
… |
|
| 314 | 348 | void Gobby::Document::on_obby_change_after() |
| 315 | 349 | { |
| 316 | | // Document changed |
| | 350 | if(m_editing) return; |
| | 351 | |
| | 352 | // Content may have changed / cursor have been moved |
| | 353 | m_signal_cursor_moved.emit(); |
| 317 | 354 | m_signal_content_changed.emit(); |
| 318 | | // Cursor may have moved |
| 319 | | m_signal_cursor_moved.emit(); |
| 320 | 355 | } |
| 321 | 356 | |
| … |
… |
|
| 345 | 380 | // Install signal handlers |
| 346 | 381 | doc.insert_event().before().connect( |
| 347 | | sigc::mem_fun(*this, &Document::on_obby_insert) ); |
| | 382 | sigc::mem_fun(*this, &Document::on_obby_insert_before) ); |
| | 383 | doc.insert_event().after().connect( |
| | 384 | sigc::mem_fun(*this, &Document::on_obby_insert_after) ); |
| 348 | 385 | doc.delete_event().before().connect( |
| 349 | | sigc::mem_fun(*this, &Document::on_obby_delete) ); |
| | 386 | sigc::mem_fun(*this, &Document::on_obby_delete_before) ); |
| | 387 | doc.delete_event().after().connect( |
| | 388 | sigc::mem_fun(*this, &Document::on_obby_delete_after) ); |
| 350 | 389 | doc.change_event().before().connect( |
| 351 | 390 | sigc::mem_fun(*this, &Document::on_obby_change_before) ); |
| … |
… |
|
| 691 | 730 | set_margin(m_preferences.view.margin_pos); |
| 692 | 731 | get_buffer()->set_check_brackets(m_preferences.view.bracket_highlight); |
| | 732 | |
| | 733 | // Cursor position may have changed because tab width may have changed |
| | 734 | m_signal_cursor_moved.emit(); |
| 693 | 735 | } |
| 694 | 736 | |