Skip to content

Commit e5b4745

Browse files
committed
update EMPTY configuration and fixed empty file bug
1 parent 05904c7 commit e5b4745

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

config/config.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
empty = {
1+
# You can copy the EMPTY configuration to start your customizations
2+
3+
# A empty configuration
4+
EMPTY = {
25
'singleWords': '',
36
'multiWords': [],
47
'comment': '',
@@ -37,8 +40,10 @@
3740
}
3841
}
3942

43+
44+
# DEFAULT configuration
4045
DEFAULT = {
41-
'singleWords': '#%^&*()-+/{[]}\\|:;"\'/.,<>~=?',
46+
'singleWords': '#%^&*()-+/{[]}\\|:;"\'/.,<>~=?`$',
4247
'multiWords': [],
4348
'comment': '',
4449
'keyWord': [],
@@ -59,15 +64,17 @@
5964
}
6065
}
6166

67+
68+
# C++ configuration
6269
cpp = {
6370
'singleWords': '#%^&*()-+/{[]}\\|:;"\'/.,<>~=?',
64-
'multiWords': ['int', 'double', 'float', 'long', 'short', 'string', 'class', 'void', 'if', 'for', 'else', 'while', 'namespace', 'using', 'template', 'bool', 'return', 'auto', 'struct', 'friend', 'operator', 'cont', 'continue', 'break', 'true', 'false', 'new', 'delete', 'typename', 'protected', 'public', 'private', 'unsigned'],
71+
'multiWords': ['int', 'double', 'float', 'long', 'short', 'string', 'class', 'void', 'if', 'for', 'else', 'while', 'namespace', 'using', 'template', 'bool', 'return', 'auto', 'struct', 'friend', 'operator', 'cont', 'continue', 'break', 'true', 'false', 'new', 'delete', 'typename', 'protected', 'public', 'private', 'unsigned', 'typedef', 'static'],
6572
'comment': '//',
6673
'keyWord': ['define', 'ifdef', 'ifndef', 'endif', 'include'],
6774
'string': ['"', '\''],
6875
'before': ['('],
6976
'after': ['class'],
70-
'special': ['int', 'double', 'float', 'long', 'short', 'string', 'class', 'void', 'if', 'for', 'else', 'while', 'namespace', 'using', 'template', 'bool', 'return', 'auto', 'struct', 'friend', 'operator', 'const', 'continue', 'break', 'true', 'false', 'new', 'delete', 'typename', 'protected', 'public', 'private', 'unsigned'],
77+
'special': [], # configured below
7178
'color': {
7279
'symbol': ['red', []],
7380
'special': ['yellow', ['bold']],
@@ -80,8 +87,10 @@
8087
'clear': ['white', []],
8188
}
8289
}
90+
cpp['special'] = cpp['multiWords']
8391

8492

93+
# Python3 configuration
8594
python3 = {
8695
'singleWords': '#%^&*()-+/{[]}\\|:;"\'/.,<>~=?',
8796
'multiWords': ['int', 'float', 'str', 'class', 'if', 'for', 'else', 'elif', 'while', 'bool', 'return', 'cont', 'continue', 'break', 'True', 'False', 'del', 'async', 'import', 'as', 'def', 'try', 'except', 'not', 'in', 'with', 'from', 'None', 'lambda', 'raise'],
@@ -90,7 +99,7 @@
9099
'string': ['"', '\''],
91100
'before': ['('],
92101
'after': ['class'],
93-
'special': ['int', 'float', 'str', 'class', 'if', 'for', 'else', 'elif', 'while', 'bool', 'return', 'cont', 'continue', 'break', 'True', 'False', 'del', 'async', 'import', 'as', 'def', 'try', 'except', 'not', 'in', 'with', 'from', 'None', 'lambda', 'raise'],
102+
'special': [], # configured below
94103
'color': {
95104
'symbol': ['red', []],
96105
'special': ['yellow', ['bold']],
@@ -103,3 +112,4 @@
103112
'clear': ['white', []],
104113
}
105114
}
115+
python3['special'] = python3['multiWords']

lib/IO.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def fixLineNumber(lineNumber: int, expectLength: int) -> str:
1717
return lineNumber
1818

1919
def merge(lines: list) -> str:
20+
while lines[-1] == []:
21+
del lines[-1]
2022
expectLength = calcExpectLength(len(lines))
2123
for id, i in enumerate(lines):
2224
tmp = ''

lib/segment.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
config = {}
44

55
def comment(line: list) -> list:
6+
if len(config['comment']) == 0:
7+
return line
68
for index in range(len(line)):
79
tmp, tmpId = '', index
810
while len(tmp) != len(config['comment']) and tmpId < len(line):

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def main(fileName: str, language: str = ''):
4747
for id, i in enumerate(lines):
4848
lines[id] = lib.BAS.after(i)
4949
code = lib.IO.merge(lines)
50-
print(code)
50+
print(code, end = '\n\n')
5151

5252
def getFileExtension(filename: str) -> str:
5353
lastDotIndex = -1

0 commit comments

Comments
 (0)