Show helpful placeholder text when the raw editor is empty or invalid.
(self)
| 1859 | pass |
| 1860 | |
| 1861 | def _show_helpful_placeholder(self): |
| 1862 | """Show helpful placeholder text when the raw editor is empty or invalid.""" |
| 1863 | if not self.raw_text_view or not self.buffer: |
| 1864 | return |
| 1865 | |
| 1866 | current_text = self.buffer.get_text( |
| 1867 | self.buffer.get_start_iter(), self.buffer.get_end_iter(), False |
| 1868 | ).strip() |
| 1869 | |
| 1870 | if not current_text or not current_text.lower().startswith("host "): |
| 1871 | placeholder_text = """# SSH Host Configuration |
| 1872 | # Start with a Host declaration, for example: |
| 1873 | Host myserver |
| 1874 | HostName example.com |
| 1875 | User myuser |
| 1876 | Port 22 |
| 1877 | IdentityFile ~/.ssh/id_rsa |
| 1878 | |
| 1879 | # Add any other SSH options as needed""" |
| 1880 | |
| 1881 | if not current_text: |
| 1882 | self.buffer.set_text(placeholder_text) |
| 1883 | start = self.buffer.get_start_iter() |
| 1884 | end = self.buffer.get_end_iter() |
| 1885 | self.buffer.select_range(start, end) |
| 1886 | |
| 1887 | def _ensure_buffer_initialized(self): |
| 1888 | """Ensure the text buffer is initialized.""" |