{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: fix formatting.

This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-23 19:21:06 +02:00
parent 0843b7d330
commit bff70b409b
25 changed files with 6 additions and 58 deletions

View File

@ -231,7 +231,6 @@ class IrcMiRCARTBot(IrcClient):
elif serverMessage[1] == "PRIVMSG":
self._dispatchPrivmsg(serverMessage)
#
# __init__(self, serverHname, serverPort="6667", clientNick="pngbot", clientIdent="pngbot", clientGecos="pngbot", clientChannel="#MiRCART"): initialisation method
def __init__(self, serverHname, serverPort="6667", clientNick="pngbot", clientIdent="pngbot", clientGecos="pngbot", clientChannel="#MiRCART"):

View File

@ -12,7 +12,6 @@ class Canvas():
def _commitPatch(self, patch):
self.map[patch[1]][patch[0]] = patch[2:]
def dispatchPatch(self, isCursor, patch, commitUndo=True):
if (patch[0] >= self.size[0]) or (patch[1] >= self.size[1]):
return False
@ -92,7 +91,6 @@ class Canvas():
and (numCol < len(newCanvas[numRow])):
self._commitPatch([numCol, numRow, *newCanvas[numRow][numCol]])
#
# __init__(self, size): initialisation method
def __init__(self, size):

View File

@ -118,5 +118,4 @@ MiRCARTToAnsiColours = [
37, # Light Grey
];
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -35,7 +35,6 @@ class CanvasExportStore():
curPos[0] + fontSize[0], curPos[1] + (fontSize[1] - 2)), \
fill=fillColour)
def exportAnsiFile(self, canvasMap, canvasSize, outFile):
outBuffer = ""
for inCurRow in range(len(canvasMap)):
@ -210,5 +209,4 @@ class CanvasExportStore():
rc, outBuffer = self.exportTextBuffer(canvasMap, canvasSize)
return outFile.write(outBuffer) if rc else (rc, outBuffer)
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -15,11 +15,9 @@ class CanvasImportStore():
CS_ITALIC = 0x02
CS_UNDERLINE = 0x04
def _flipCellStateBit(self, bit, cellState):
return cellState & ~bit if cellState & bit else cellState | bit
def importAnsiBuffer(self, inBuffer, encoding="cp437", width=None):
curBg, curBgAnsi, curBoldAnsi, curFg, curFgAnsi = -1, 30, False, 15, 37
done, outMap, outMaxCols = False, [[]], 0
@ -136,7 +134,6 @@ class CanvasImportStore():
with open(pathName, "r", encoding="utf-8-sig") as inFile:
return self.importTextBuffer(inFile)
#
# __init__(self, inFile=None): initialisation method
def __init__(self, inFile=None):

View File

@ -53,11 +53,9 @@ class CanvasJournal():
self.patchesUndo[self.patchesUndoLevel][0].append(undoPatches)
self.patchesUndo[self.patchesUndoLevel][1].append(redoPatches)
def __del__(self):
self.resetCursor(); self.resetUndo();
#
# __init__(self): initialisation method
def __init__(self):

View File

@ -23,7 +23,6 @@ class GuiBufferedDC(wx.MemoryDC):
self.SelectObject(buffer); self.SetDeviceOrigin(*viewRect);
self.dc, self.viewRect, self.viewSize = dc, viewRect, viewSize
class GuiCanvasWxBackend():
arabicShapes = {
u'\u0621': (u'\uFE80'),
@ -71,7 +70,6 @@ class GuiCanvasWxBackend():
CS_ITALIC = 0x02
CS_UNDERLINE = 0x04
def _drawBrushPatch(self, eventDc, patch, point):
absPoint = self._xlatePoint(point)
brushBg, brushFg, pen = self._getBrushPatchColours(patch)
@ -174,7 +172,6 @@ class GuiCanvasWxBackend():
def _xlatePoint(self, point):
return [a * b for a, b in zip(point, self.cellSize)]
def drawCursorMaskWithJournal(self, canvas, canvasJournal, eventDc):
[self.drawPatch(canvas, eventDc, patch) for patch in canvasJournal.popCursor()]
@ -235,13 +232,11 @@ class GuiCanvasWxBackend():
mapX, mapY = int(rectX / self.cellSize[0] if rectX else 0), int(rectY / self.cellSize[1] if rectY else 0)
return [m + n for m, n in zip((mapX, mapY), viewRect)]
def __del__(self):
if self.canvasBitmap != None:
self.canvasBitmap.Destroy(); self.canvasBitmap = None;
self._finiBrushesAndPens()
#
# __init__(self, canvasSize, cellSize, fontName="Dejavu Sans Mono", fontPathName=os.path.join("assets", "fonts", "DejaVuSansMono.ttf")): initialisation method
def __init__(self, canvasSize, cellSize, fontName="Dejavu Sans Mono", fontPathName=os.path.join("assets", "fonts", "DejaVuSansMono.ttf")):

View File

@ -46,7 +46,6 @@ def GuiSubMenuDecorator(caption, label, icon, accel, initialState):
return targetObject
return GuiSubMenuDecoratorOuter
class GuiToolBarArtProvider(wx.lib.agw.aui.AuiDefaultToolBarArt):
def DrawBackground(self, dc, wnd, _rect, horizontal=True):
dc.SetBrush(wx.Brush(wx.Colour(240, 240, 240, 0), wx.BRUSHSTYLE_SOLID)); dc.SetPen(wx.Pen(wx.Colour(240, 240, 240, 0), 1));
@ -94,7 +93,6 @@ class GuiFrame(wx.Frame):
else:
menuItemWindow.Enable(menuItem.attrDict["initialState"])
def loadAccels(self, accelsIn, menus, toolBars):
def loadAccels_(accels):
nonlocal accelTableEntries
@ -193,7 +191,6 @@ class GuiFrame(wx.Frame):
def onMouseWheel(self, event):
event.Skip()
#
# __init__(self, iconPathName, size, parent=None, title=""): initialisation method
def __init__(self, iconPathName, size, parent=None, title=""):

View File

@ -16,7 +16,6 @@ class GuiWindow(wx.ScrolledWindow):
and ((self.size[0] <= clientSize[0]) or (self.size[1] <= clientSize[1])):
self.scrollFlag = False; super().SetVirtualSize((0, 0));
def onClose(self, event):
self.Destroy()
@ -48,7 +47,6 @@ class GuiWindow(wx.ScrolledWindow):
while curWindow != None:
curWindow.Layout(); curWindow = curWindow.GetParent();
#
# __init__(self, parent, pos, scrollStep, style=0): initialisation method
def __init__(self, parent, pos, scrollStep, style=0):

View File

@ -95,7 +95,6 @@ class RoarAssetsWindow(GuiMiniFrame):
and ((panelSize[0] <= clientSize[0]) or (panelSize[1] <= clientSize[1])):
self.scrollFlag = False; super(wx.ScrolledWindow, self.panelCanvas).SetVirtualSize((0, 0));
def drawCanvas(self, canvas):
panelSize = [a * b for a, b in zip(canvas.size, self.cellSize)]
self.panelCanvas.SetMinSize(panelSize); self.panelCanvas.SetSize(wx.DefaultCoord, wx.DefaultCoord, *panelSize);
@ -161,7 +160,6 @@ class RoarAssetsWindow(GuiMiniFrame):
self.backend.drawPatch(canvas, eventDc, [numCol, numRow, *canvas.map[numRow][numCol]])
eventDc.SetDeviceOrigin(*eventDcOrigin)
def onImportAnsi(self, event):
event.Skip()
@ -231,7 +229,6 @@ class RoarAssetsWindow(GuiMiniFrame):
if dialogChoice == wx.ID_CANCEL:
break
# {{{ onLoadList(self, event)
def onLoadList(self, event):
rc = True
with wx.FileDialog(self, "Load from list...", os.getcwd(), "", "List files (*.lst)|*.lst|Text files (*.txt)|*.txt|All Files (*.*)|*.*", wx.FD_OPEN) as dialog:
@ -278,7 +275,6 @@ class RoarAssetsWindow(GuiMiniFrame):
with wx.MessageDialog(self, "Error: {}".format(error), "", wx.OK | wx.OK_DEFAULT) as dialog:
dialogChoice = dialog.ShowModal()
#
# __init__(self, backend, cellSize, parent, pos=None, size=(400, 400), title="Assets"): initialisation method
def __init__(self, backend, cellSize, parent, pos=None, size=(400, 400), title="Assets"):

View File

@ -40,7 +40,6 @@ class RoarCanvasCommands(RoarCanvasCommandsFile, RoarCanvasCommandsEdit, RoarCan
_initColourBitmaps_(RoarCanvasCommandsEdit.canvasColour, RoarCanvasCommandsEdit.canvasColourAlpha, 1.0)
_initColourBitmaps_(RoarCanvasCommandsEdit.canvasColourBackground, RoarCanvasCommandsEdit.canvasColourAlphaBackground, 0.5)
def update(self, **kwargs):
self.lastPanelState.update(kwargs); textItems = [];
if "cellPos" in self.lastPanelState:
@ -109,7 +108,6 @@ class RoarCanvasCommands(RoarCanvasCommandsFile, RoarCanvasCommandsEdit, RoarCan
toolBar = self.parentFrame.toolBarItemsById[self.canvasRedo.attrDict["id"]][0]
toolBar.EnableTool(self.canvasRedo.attrDict["id"], False); toolBar.Refresh();
#
# __init__(self, parentCanvas, parentFrame):
def __init__(self, parentCanvas, parentFrame):

View File

@ -176,8 +176,6 @@ class RoarCanvasCommandsEdit():
eventDc = self.parentCanvas.backend.getDeviceContext(self.parentCanvas.GetClientSize(), self.parentCanvas, viewRect)
self.parentCanvas.applyTool(eventDc, True, None, None, None, self.parentCanvas.brushPos, False, False, False, self.currentTool, viewRect, force=True)
@GuiCommandDecorator("Copy", "&Copy", ["", wx.ART_COPY], None, False)
def canvasCopy(self, event):
pass
@ -204,7 +202,6 @@ class RoarCanvasCommandsEdit():
self.parentCanvas.dispatchDeltaPatches(self.parentCanvas.canvas.journal.popUndo())
self.update(size=self.parentCanvas.canvas.size, undoLevel=self.parentCanvas.canvas.journal.patchesUndoLevel)
#
# __init__(self)
def __init__(self):

View File

@ -91,13 +91,11 @@ class RoarCanvasCommandsFile():
for lastFile in [l["pathName"] for l in self.lastFiles]:
print(lastFile, file=outFile)
@GuiCommandDecorator("Exit", "E&xit", None, [wx.ACCEL_CTRL, ord("X")], None)
def canvasExit(self, event):
if self._promptSaveChanges():
self.parentFrame.Close(True)
@GuiCommandDecorator("Export as ANSI...", "Export as &ANSI...", None, None, None)
def canvasExportAsAnsi(self, event):
with wx.FileDialog(self.parentFrame, "Save As...", os.getcwd(), "", "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
@ -163,7 +161,6 @@ class RoarCanvasCommandsFile():
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
return True
@GuiCommandDecorator("Import ANSI...", "Import &ANSI...", None, None, None)
def canvasImportAnsi(self, event):
def canvasImportAnsi_(pathName):
@ -194,7 +191,6 @@ class RoarCanvasCommandsFile():
return (rc, error, self.parentCanvas.canvas.importStore.outMap, pathName, self.parentCanvas.canvas.importStore.inSize)
self._importFile(canvasImportSauce_, True, "SAUCE files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*")
@GuiCommandDecorator("New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None)
def canvasNew(self, event, newCanvasSize=None):
def canvasImportEmpty(pathName):
@ -251,7 +247,6 @@ class RoarCanvasCommandsFile():
if self.canvasSave(event, newDirty=True):
self._pushRecent(self.canvasPathName)
#
# __init__(self)
def __init__(self):

View File

@ -12,7 +12,6 @@ class RoarCanvasCommandsHelp():
def canvasAbout(self, event):
RoarWindowAbout(self.parentFrame)
#
# __init__(self)
def __init__(self):

View File

@ -27,7 +27,6 @@ class RoarCanvasCommandsOperators():
setattr(canvasOperator_, "attrDict", f.attrList[idx])
return canvasOperator_
#
# __init__(self)
def __init__(self):

View File

@ -45,7 +45,6 @@ class RoarCanvasCommandsTools():
setattr(canvasTool_, "isSelect", True)
return canvasTool_
#
# __init__(self)
def __init__(self):

View File

@ -39,7 +39,6 @@ class RoarCanvasWindowDropTarget(wx.TextDropTarget):
def __init__(self, parent):
super().__init__(); self.inProgress, self.parent = False, parent;
class RoarCanvasWindow(GuiWindow):
def _drawPatch(self, eventDc, isCursor, patch):
if not self.canvas.dirtyCursor:
@ -49,7 +48,6 @@ class RoarCanvasWindow(GuiWindow):
patchDeltaCell = self.canvas.map[patch[1]][patch[0]]; patchDelta = [*patch[0:2], *patchDeltaCell];
self.canvas.journal.pushCursor(patchDelta)
def applyOperator(self, currentTool, mapPoint, mouseLeftDown, mousePoint, operator, viewRect):
self.canvas.dirtyCursor = False
if (currentTool.__class__ == ToolObject) \
@ -191,7 +189,6 @@ class RoarCanvasWindow(GuiWindow):
self.backend.drawPatch(self.canvas, eventDc, [numCol, numRow, *self.canvas.map[numRow][numCol]])
eventDc.SetDeviceOrigin(*eventDcOrigin)
def onKeyboardInput(self, event):
keyCode, keyModifiers = event.GetKeyCode(), event.GetModifiers()
viewRect = self.GetViewStart(); eventDc = self.backend.getDeviceContext(self.GetClientSize(), self, viewRect);
@ -286,7 +283,6 @@ class RoarCanvasWindow(GuiWindow):
eventDc.SetDeviceOrigin(*eventDcOrigin)
self.backend.onPaint(self.GetClientSize(), self, self.GetViewStart())
#
# __init__(self, backend, canvas, cellSize, commands, parent, parentFrame, pos, scrollStep, size): initialisation method
def __init__(self, backend, canvas, cellSize, commands, parent, parentFrame, pos, scrollStep, size):

View File

@ -25,14 +25,12 @@ class RoarClient(GuiFrame):
for toolBarItem in [i for i in toolBar if i != NID_TOOLBAR_HSEP]:
toolBarItem.attrDict["icon"] = self.loadBitmap(basePathName, toolBarItem.attrDict["icon"])
def onChar(self, event):
self.canvasPanel.onKeyboardInput(event)
def onMouseWheel(self, event):
self.canvasPanel.GetEventHandler().ProcessEvent(event)
#
# __init__(self, parent, defaultCanvasPos=(0, 75), defaultCanvasSize=(100, 30), defaultCellSize=(7, 14), size=(840, 630), title=""): initialisation method
def __init__(self, parent, defaultCanvasPos=(0, 75), defaultCanvasSize=(100, 30), defaultCellSize=(7, 14), size=(840, 630), title=""):

View File

@ -11,7 +11,6 @@ class RoarWindowAbout(wx.Dialog):
def onButtonRoar(self, event):
self.Destroy()
#
# __init__(self, parent, minSize=(320, 300), title="About roar")
def __init__(self, parent, minSize=(320, 300), title="About roar"):

View File

@ -107,7 +107,6 @@ class IrcClient:
del self.clientQueue[0]
return True
#
# __init__(self, serverHname, serverPort, clientNick, clientIdent, clientGecos): initialisation method
def __init__(self, serverHname, serverPort, clientNick, clientIdent, clientGecos):

View File

@ -11,5 +11,4 @@ def getLocalConfPathName(*args):
vname = "LOCALAPPDATA" if platform.system() == "Windows" else "HOME"
return os.path.join(os.getenv(vname), "roar", *args)
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -11,5 +11,4 @@ class Tool(object):
def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown):
return False, False
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

View File

@ -46,7 +46,6 @@ class ToolLine(Tool):
def _pointSwap(self, a, b):
return [b, a]
#
# onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown)
def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown):

View File

@ -97,7 +97,6 @@ class ToolObject(Tool):
self.toolState = self.TS_SELECT
return dirty
def getRegion(self, canvas):
return self.objectMap
@ -169,7 +168,6 @@ class ToolObject(Tool):
self.srcRect = self.targetRect
self.objectMap, self.objectSize = objectMap, objectSize
# __init__(self, *args): initialisation method
def __init__(self, *args):
super().__init__(*args)

View File

@ -65,7 +65,6 @@ class ToolText(Tool):
rc, dirty = False, False
return rc, dirty
#
# onKeyboardEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyChar, keyCode, keyModifiers, mapPoint)
def onKeyboardEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyChar, keyCode, keyModifiers, mapPoint):