Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

commit: add 'apply format' menu option

Changeset 5fa70da96be9

Parent fdda762c6b15

by Steve Borho

Changes to one file · Browse files at 5fa70da96be9 Showing diff from parent fdda762c6b15 Diff from another changeset...

 
20
21
22
23
24
25
26
 
179
180
181
 
182
 
183
184
185
186
187
188
189
190
191
192
 
218
219
220
 
221
222
223
224
225
 
 
 
 
 
 
 
 
 
226
227
228
 
233
234
235
 
236
237
238
 
20
21
22
 
23
24
25
 
178
179
180
181
182
183
184
185
186
 
187
188
 
189
190
191
 
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
 
242
243
244
245
246
247
248
@@ -20,7 +20,6 @@
 from tortoisehg.hgqt import qtlib, status, cmdui, branchop    # Technical Debt for CommitWidget -# auto-wrap  # qrefresh support  # refresh parent changeset descriptions after refresh  # threaded / wrapped commit (need a CmdRunner equivalent) @@ -179,14 +178,14 @@
  'User pressed Alt-Q'   if QApplication.focusWidget() != self.msgte:   return + self.reflowBlock(self.msgte.textCursor().block())   + def reflowBlock(self, block):   sumlen, maxlen = self.getLengths()   if not maxlen:   return -   # In QtTextDocument land, a block is a sequence of text ending   # in (and including) a carriage return. Aka, a line of text. - block = self.msgte.textCursor().block()   while block.length() and block.previous().length() > 1:   block = block.previous()   begin = block.position() @@ -218,11 +217,21 @@
    # Replace selection with new sentence   cursor.insertText(reflow) + return cursor.block()     def customContextMenuRequested(self, point):   cursor = self.msgte.cursorForPosition(point)   point = self.msgte.mapToGlobal(point)   + def apply(): + sumlen, maxlen = self.getLengths() + if not maxlen: + return + block = self.msgte.document().firstBlock() + while block != self.msgte.document().end(): + if block.length() > maxlen: + block = self.reflowBlock(block) + block = block.next()   def paste():   files = self.stwidget.getChecked()   cursor.insertText(', '.join(files)) @@ -233,6 +242,7 @@
    menu = self.msgte.createStandardContextMenu()   for name, func in [(_('Paste &Filenames'), paste), + (_('App&ly Format'), apply),   (_('C&onfigure Format'), settings)]:   action = menu.addAction(name)   action.wrapper = lambda f=func: f()