| 361 | |
| 362 | |
| 363 | class WrappedLineHeightChangeDelegator(Delegator): |
| 364 | def __init__(self, callback): |
| 365 | """ |
| 366 | callback - Callable, will be called when an insert, delete or replace |
| 367 | action on the text widget may require updating the shell |
| 368 | sidebar. |
| 369 | """ |
| 370 | Delegator.__init__(self) |
| 371 | self.callback = callback |
| 372 | |
| 373 | def insert(self, index, chars, tags=None): |
| 374 | is_single_line = '\n' not in chars |
| 375 | if is_single_line: |
| 376 | before_displaylines = get_displaylines(self, index) |
| 377 | |
| 378 | self.delegate.insert(index, chars, tags) |
| 379 | |
| 380 | if is_single_line: |
| 381 | after_displaylines = get_displaylines(self, index) |
| 382 | if after_displaylines == before_displaylines: |
| 383 | return # no need to update the sidebar |
| 384 | |
| 385 | self.callback() |
| 386 | |
| 387 | def delete(self, index1, index2=None): |
| 388 | if index2 is None: |
| 389 | index2 = index1 + "+1c" |
| 390 | is_single_line = get_lineno(self, index1) == get_lineno(self, index2) |
| 391 | if is_single_line: |
| 392 | before_displaylines = get_displaylines(self, index1) |
| 393 | |
| 394 | self.delegate.delete(index1, index2) |
| 395 | |
| 396 | if is_single_line: |
| 397 | after_displaylines = get_displaylines(self, index1) |
| 398 | if after_displaylines == before_displaylines: |
| 399 | return # no need to update the sidebar |
| 400 | |
| 401 | self.callback() |
| 402 | |
| 403 | |
| 404 | class ShellSidebar(BaseSideBar): |
no outgoing calls
no test coverage detected
searching dependent graphs…