(self, s, tags, numoflines, squeezer)
| 93 | Squeezer instance when it is expanded (and therefore removed). |
| 94 | """ |
| 95 | def __init__(self, s, tags, numoflines, squeezer): |
| 96 | self.s = s |
| 97 | self.tags = tags |
| 98 | self.numoflines = numoflines |
| 99 | self.squeezer = squeezer |
| 100 | self.editwin = editwin = squeezer.editwin |
| 101 | self.text = text = editwin.text |
| 102 | # The base Text widget is needed to change text before iomark. |
| 103 | self.base_text = editwin.per.bottom |
| 104 | |
| 105 | line_plurality = "lines" if numoflines != 1 else "line" |
| 106 | button_text = f"Squeezed text ({numoflines} {line_plurality})." |
| 107 | tk.Button.__init__(self, text, text=button_text, |
| 108 | background="#FFFFC0", activebackground="#FFFFE0") |
| 109 | |
| 110 | button_tooltip_text = ( |
| 111 | "Double-click to expand, right-click for more options." |
| 112 | ) |
| 113 | Hovertip(self, button_tooltip_text, hover_delay=80) |
| 114 | |
| 115 | self.bind("<Double-Button-1>", self.expand) |
| 116 | if macosx.isAquaTk(): |
| 117 | # AquaTk defines <2> as the right button, not <3>. |
| 118 | self.bind("<Button-2>", self.context_menu_event) |
| 119 | else: |
| 120 | self.bind("<Button-3>", self.context_menu_event) |
| 121 | self.selection_handle( # X windows only. |
| 122 | lambda offset, length: s[int(offset):int(offset) + int(length)]) |
| 123 | |
| 124 | self.is_dangerous = None |
| 125 | self.after_idle(self.set_is_dangerous) |
| 126 | |
| 127 | def set_is_dangerous(self): |
| 128 | dangerous_line_len = 50 * self.text.winfo_width() |
nothing calls this directly
no test coverage detected