Grammalecte  Check-in [d7ab6f010f]

Overview
Comment:[lo] text formatter editor: small ui update
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: d7ab6f010f75897b4f8cd6d179cf07612654a1a2c41e7faa271436fc061b401f
User & Date: olr on 2020-12-18 10:31:52
Other Links: manifest | tags
Context
2020-12-18
16:58
[fx] gc editor: don’t modify node content if no modification check-in: a3b0c51a85 user: olr tags: fx, trunk
10:31
[lo] text formatter editor: small ui update check-in: d7ab6f010f user: olr tags: lo, trunk
09:59
[lo] text formatter editor update check-in: 7d2246bb86 user: olr tags: lo, trunk
Changes

Modified gc_lang/fr/oxt/TextFormatter/TextFormatterEditor.py from [8b8fa9d3c8] to [b31844a66b].

135
136
137
138
139
140
141

142
143
144
145
146
147
148
...
234
235
236
237
238
239
240
241
242

243
244
245
246
247
248
249
250
251
252
253
254
...
308
309
310
311
312
313
314
315



316
317
318
319
320
321
322

        self.xNewName = self._addWidget('newname', 'Edit', nX, nY1+20, 60, 10, FontDescriptor = xFDMono)
        self.xNewPattern = self._addWidget('newreplace', 'Edit', nX+65, nY1+20, 130, 10, FontDescriptor = xFDMono)
        self.xNewRepl = self._addWidget('newby', 'Edit', nX+200, nY1+20, 100, 10, FontDescriptor = xFDMono)
        self.xNewRegex = self._addWidget('newregex', 'CheckBox', nX+305, nY1+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help"))
        self.xNewCaseSens = self._addWidget('newcasesens', 'CheckBox', nX+340, nY1+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), State=True)


        self._addWidget('add', 'Button', self.xDialog.Width-50, nY1+31, 40, 11, Label = ui.get('add'))

        lColumns = [
            {"Title": ui.get("name"),     "ColumnWidth": 80},
            {"Title": ui.get("pattern"),  "ColumnWidth": 160},
            {"Title": ui.get("repl"),     "ColumnWidth": 120},
            {"Title": ui.get("regex"),    "ColumnWidth": 60},
................................................................................

    # XGridSelectionListener
    def selectionChanged (self, xGridSelectionEvent):
        try:
            aRows = self.xGridControl.getSelectedRows()
            if aRows and len(aRows) == 1:
                self.iSelectedRow = aRows[0]
                self.sSelectedRuleName, sPattern, sRepl, sRegex, sCaseSens = self.xGridModel.GridDataModel.getRowData(self.iSelectedRow)
                # fill fields

                self.xEditName.Text = self.sSelectedRuleName
                self.xEditPattern.Text = sPattern
                self.xEditRepl.Text = sRepl
                self.xEditRegex.State = sRegex == "True"
                self.xEditCaseSens.State = sCaseSens == "True"
                # enable widgets
                self.xEditName.Enabled = True
                self.xEditPattern.Enabled = True
                self.xEditRepl.Enabled = True
                self.xEditRegex.Enabled = True
                self.xEditCaseSens.Enabled = True
                self.xDeleteButton.Enabled = True
................................................................................
        }
        xGridDataModel = self.xGridModel.GridDataModel
        xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName))
        xGridDataModel.sortByColumn(0, True)
        self._clearAddFields()

    def _getValuesForRow (self, sRuleName):
        return (sRuleName, self.dRules[sRuleName]["sPattern"], self.dRules[sRuleName]["sRepl"], str(self.dRules[sRuleName]["bRegex"]), str(self.dRules[sRuleName]["bCaseSens"]))




    def _checkRuleName (self, sRuleName):
        return re.search(r"^\w[\w_#.,;!?-]{,14}$", sRuleName)

    def modifyRule (self):
        if not self._checkRuleName(self.xEditName.Text):
            MessageBox(self.xDocument, ui.get("name_error"), ui.get("name_error_title"), ERRORBOX)







>







 







|

>

|
|
|
|







 







|
>
>
>







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
...
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327

        self.xNewName = self._addWidget('newname', 'Edit', nX, nY1+20, 60, 10, FontDescriptor = xFDMono)
        self.xNewPattern = self._addWidget('newreplace', 'Edit', nX+65, nY1+20, 130, 10, FontDescriptor = xFDMono)
        self.xNewRepl = self._addWidget('newby', 'Edit', nX+200, nY1+20, 100, 10, FontDescriptor = xFDMono)
        self.xNewRegex = self._addWidget('newregex', 'CheckBox', nX+305, nY1+22, 35, nHeight, Label = ui.get("regex"), HelpText=ui.get("regex_help"))
        self.xNewCaseSens = self._addWidget('newcasesens', 'CheckBox', nX+340, nY1+22, 40, nHeight, Label = ui.get("casesens"), HelpText=ui.get("casesens_help"), State=True)

        self._addWidget('order_info', 'FixedText', nX, nY1+32, 300, nHeight, Label = ui.get("order_info"))
        self._addWidget('add', 'Button', self.xDialog.Width-50, nY1+31, 40, 11, Label = ui.get('add'))

        lColumns = [
            {"Title": ui.get("name"),     "ColumnWidth": 80},
            {"Title": ui.get("pattern"),  "ColumnWidth": 160},
            {"Title": ui.get("repl"),     "ColumnWidth": 120},
            {"Title": ui.get("regex"),    "ColumnWidth": 60},
................................................................................

    # XGridSelectionListener
    def selectionChanged (self, xGridSelectionEvent):
        try:
            aRows = self.xGridControl.getSelectedRows()
            if aRows and len(aRows) == 1:
                self.iSelectedRow = aRows[0]
                self.sSelectedRuleName, *_ = self.xGridModel.GridDataModel.getRowData(self.iSelectedRow)
                # fill fields
                dRule = self.dRules[self.sSelectedRuleName]
                self.xEditName.Text = self.sSelectedRuleName
                self.xEditPattern.Text = dRule["sPattern"]
                self.xEditRepl.Text = dRule["sRepl"]
                self.xEditRegex.State = dRule["bRegex"]
                self.xEditCaseSens.State = dRule["bCaseSens"]
                # enable widgets
                self.xEditName.Enabled = True
                self.xEditPattern.Enabled = True
                self.xEditRepl.Enabled = True
                self.xEditRegex.Enabled = True
                self.xEditCaseSens.Enabled = True
                self.xDeleteButton.Enabled = True
................................................................................
        }
        xGridDataModel = self.xGridModel.GridDataModel
        xGridDataModel.addRow(xGridDataModel.RowCount + 1, self._getValuesForRow(sRuleName))
        xGridDataModel.sortByColumn(0, True)
        self._clearAddFields()

    def _getValuesForRow (self, sRuleName):
        return (sRuleName, self.dRules[sRuleName]["sPattern"],
                self.dRules[sRuleName]["sRepl"],
                "✓"  if self.dRules[sRuleName]["bRegex"]  else "",
                "✓"  if self.dRules[sRuleName]["bCaseSens"]  else "")

    def _checkRuleName (self, sRuleName):
        return re.search(r"^\w[\w_#.,;!?-]{,14}$", sRuleName)

    def modifyRule (self):
        if not self._checkRuleName(self.xEditName.Text):
            MessageBox(self.xDocument, ui.get("name_error"), ui.get("name_error_title"), ERRORBOX)

Modified gc_lang/fr/oxt/TextFormatter/tfe_strings.py from [10a90636db] to [15882e0f9b].

24
25
26
27
28
29
30

31
32
33
34
35
36
37
..
76
77
78
79
80
81
82

83
84
85
86
87
88
89
        "name": "Nom de la règle",
        "pattern": "Motif de recherche",
        "repl": "remplacer par",
        "regex": "Regex",
        "regex_help": "Une expression régulière est une forme de syntaxe décrivant un motif de recherche de caractères",
        "casesens": "Casse rigide",
        "casesens_help": "La casse des caractères sera respectée telle quelle.",


        "new_entry": "Nouvelle entrée",
        "edit_entry": "Entrée sélectionnée",

        "add": "Ajouter",
        "delete": "Supprimer",
        "modify": "Modifier",
................................................................................
        "name": "Rule name",
        "pattern": "Search pattern",
        "repl": "replace by",
        "regex": "Regex",
        "regex_help": "A regular expression is a kind of syntax describing a search pattern of characters",
        "casesens": "Case sensitivity",
        "casesens_help": "Characters case will be treated as written.",


        "new_entry": "New entry",
        "edit_entry": "Selected entry",

        "add": "Add",
        "delete": "Delete",
        "modify": "Modify",







>







 







>







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
..
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
        "name": "Nom de la règle",
        "pattern": "Motif de recherche",
        "repl": "remplacer par",
        "regex": "Regex",
        "regex_help": "Une expression régulière est une forme de syntaxe décrivant un motif de recherche de caractères",
        "casesens": "Casse rigide",
        "casesens_help": "La casse des caractères sera respectée telle quelle.",
        "order_info": "Les règles seront appliquées dans l’ordre alphabétique défini par leur nom.",

        "new_entry": "Nouvelle entrée",
        "edit_entry": "Entrée sélectionnée",

        "add": "Ajouter",
        "delete": "Supprimer",
        "modify": "Modifier",
................................................................................
        "name": "Rule name",
        "pattern": "Search pattern",
        "repl": "replace by",
        "regex": "Regex",
        "regex_help": "A regular expression is a kind of syntax describing a search pattern of characters",
        "casesens": "Case sensitivity",
        "casesens_help": "Characters case will be treated as written.",
        "order_info": "Rules will applied according to the alphabetical order defined by their name.",

        "new_entry": "New entry",
        "edit_entry": "Selected entry",

        "add": "Add",
        "delete": "Delete",
        "modify": "Modify",