pygments-shell-console 0.0.1__tar.gz → 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/PKG-INFO +1 -1
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/git_lexer.py +31 -1
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/pyproject.toml +1 -1
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/shellconsole_lexer.py +28 -19
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/shellconsole_style.py +4 -0
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/test.exmpl +26 -2
- pygments_shell_console-0.0.2/test.sh +2 -0
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/.github/workflows/publish-to-pypi.yml +0 -0
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/.gitignore +0 -0
- {pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/README.md +0 -0
|
@@ -20,9 +20,12 @@ STANDARD_TYPES.update({
|
|
|
20
20
|
Token.Git.CommitMessage: 'git-cm',
|
|
21
21
|
Token.Git.CommitAuthor: 'git-ca',
|
|
22
22
|
Token.Git.Refs: 'git-r',
|
|
23
|
+
Token.Git.Untracked: 'git-untr',
|
|
24
|
+
Token.Git.Modified: 'git-mod',
|
|
25
|
+
Token.Git.Staged: 'git-stg',
|
|
23
26
|
})
|
|
24
27
|
|
|
25
|
-
class
|
|
28
|
+
class GitLogLexer(Lexer):
|
|
26
29
|
name = "Git"
|
|
27
30
|
aliases = ["git"]
|
|
28
31
|
filenames = ['*.git']
|
|
@@ -80,3 +83,30 @@ class GitLexer(Lexer):
|
|
|
80
83
|
|
|
81
84
|
else:
|
|
82
85
|
yield match.start(), Generic.Output, line
|
|
86
|
+
|
|
87
|
+
class GitStatusLexer(RegexLexer):
|
|
88
|
+
tokens = {
|
|
89
|
+
'root': [
|
|
90
|
+
(r'\s*Untracked files:\n', Text, 'untracked'),
|
|
91
|
+
(r'\s*Changes not staged for commit:\n', Text, 'modified'),
|
|
92
|
+
(r'\s*Changes to be committed:\n', Text, 'staged'),
|
|
93
|
+
],
|
|
94
|
+
'untracked': [
|
|
95
|
+
(r'^\s+\(.*\)\n', Text),
|
|
96
|
+
(r'^[^\n]+\n', Token.Git.Untracked),
|
|
97
|
+
(r'^\s+\n', Text, '#pop'),
|
|
98
|
+
],
|
|
99
|
+
'modified': [
|
|
100
|
+
(r'^\s+\(.*\)\n', Text),
|
|
101
|
+
(r'^[^\n]+\n', Token.Git.Modified),
|
|
102
|
+
(r'^\s+\n', Text, '#pop'),
|
|
103
|
+
],
|
|
104
|
+
'staged': [
|
|
105
|
+
(r'^\s+\(.*\)\n', Text),
|
|
106
|
+
(r'^[^\n]+\n', Token.Git.Staged),
|
|
107
|
+
(r'^\s+\n', Text, '#pop'),
|
|
108
|
+
],
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
@@ -8,7 +8,7 @@ from pygments.token import Token, Punctuation, Whitespace, \
|
|
|
8
8
|
from pygments.lexers.diff import DiffLexer
|
|
9
9
|
from pygments.lexers.shell import BashLexer
|
|
10
10
|
from pygments.lexers.diff import DiffLexer
|
|
11
|
-
from git_lexer import
|
|
11
|
+
from git_lexer import GitLogLexer, GitStatusLexer
|
|
12
12
|
from pygments.token import STANDARD_TYPES
|
|
13
13
|
|
|
14
14
|
import re
|
|
@@ -45,15 +45,17 @@ class ShellConsoleLexer(Lexer):
|
|
|
45
45
|
def get_tokens_unprocessed(self, text):
|
|
46
46
|
innerlexer = self._innerLexerCls(**self.options)
|
|
47
47
|
difflexer = DiffLexer()
|
|
48
|
-
|
|
48
|
+
gitloglexer = GitLogLexer()
|
|
49
|
+
gitstatuslexer = GitStatusLexer()
|
|
49
50
|
|
|
50
51
|
pos = 0
|
|
51
52
|
# Bash command
|
|
52
53
|
curcode = ''
|
|
53
54
|
insertions = []
|
|
54
55
|
backslash_continuation = False
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
|
|
57
|
+
custom_lexer = None
|
|
58
|
+
output = ""
|
|
57
59
|
|
|
58
60
|
for match in line_re.finditer(text):
|
|
59
61
|
line = match.group()
|
|
@@ -76,8 +78,16 @@ class ShellConsoleLexer(Lexer):
|
|
|
76
78
|
# To support output lexers (say diff output), the output
|
|
77
79
|
# needs to be broken by prompts whenever the output lexer
|
|
78
80
|
# changes.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
|
|
82
|
+
if output:
|
|
83
|
+
if custom_lexer:
|
|
84
|
+
for i, t, v in custom_lexer.get_tokens_unprocessed(output):
|
|
85
|
+
# print(f"\n2. yielding pos={pos+i}, t={t}, v={v}")
|
|
86
|
+
yield pos+i, t, v
|
|
87
|
+
else:
|
|
88
|
+
yield pos, Generic.Output, output
|
|
89
|
+
output = ''
|
|
90
|
+
custom_lexer = None
|
|
81
91
|
|
|
82
92
|
if not insertions:
|
|
83
93
|
pos = match.start()
|
|
@@ -127,19 +137,14 @@ class ShellConsoleLexer(Lexer):
|
|
|
127
137
|
# print(f"\n1. yielding pos={pos+i}, t={t}, v={v}")
|
|
128
138
|
yield pos+i, t, v
|
|
129
139
|
|
|
130
|
-
if
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
# print(f"\n2. yielding pos={match.start()+i}, t={t}, v={v}")
|
|
139
|
-
yield match.start()+i, t, v
|
|
140
|
-
else:
|
|
141
|
-
# print(f"\n3. yielding pos={match.start()}, t={Generic.Output}, v={line}")
|
|
142
|
-
yield match.start(), Generic.Output, line
|
|
140
|
+
if 'diff' in curcode:
|
|
141
|
+
custom_lexer = difflexer
|
|
142
|
+
elif curcode.startswith('git lg'):
|
|
143
|
+
custom_lexer = gitloglexer
|
|
144
|
+
elif curcode.startswith('git status'):
|
|
145
|
+
custom_lexer = gitstatuslexer
|
|
146
|
+
|
|
147
|
+
output += line
|
|
143
148
|
insertions = []
|
|
144
149
|
curcode = ''
|
|
145
150
|
|
|
@@ -148,3 +153,7 @@ class ShellConsoleLexer(Lexer):
|
|
|
148
153
|
innerlexer.get_tokens_unprocessed(curcode)):
|
|
149
154
|
# print(f"\n4. yielding pos={pos+i}, t={t}, v={v}")
|
|
150
155
|
yield pos+i, t, v
|
|
156
|
+
if output:
|
|
157
|
+
for i, t, v in custom_lexer.get_tokens_unprocessed(output):
|
|
158
|
+
# print(f"\n3. yielding pos={pos+i}, t={t}, v={v}")
|
|
159
|
+
yield pos+i, t, v
|
|
@@ -19,5 +19,9 @@ class ShellConsoleStyle(Style):
|
|
|
19
19
|
Token.Git.CommitMessage: "#FFFFFF",
|
|
20
20
|
Token.Git.CommitAuthor: "#aaaaaa",
|
|
21
21
|
Token.Git.Refs: "#00ffff",
|
|
22
|
+
|
|
23
|
+
Token.Git.Untracked: "#f00",
|
|
24
|
+
Token.Git.Modified: "#f00",
|
|
25
|
+
Token.Git.Staged: "#008000",
|
|
22
26
|
})
|
|
23
27
|
del styles[Token.Generic.Prompt]
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
joapuiib@FP:~/git_tutorial (main) $ echo "Hello world!"
|
|
1
|
+
joapuiib@FP:~/git_tutorial (main) $ echo "Hello world!" \
|
|
2
|
+
&& cd /tmp
|
|
3
|
+
|
|
2
4
|
(venv) joapuiib@FP:~/git_tutorial (main) $ git diff
|
|
3
5
|
diff --git a/README.md b/README.md
|
|
4
6
|
index 6d747b3..ff524e4 100644
|
|
@@ -10,6 +12,7 @@ index 6d747b3..ff524e4 100644
|
|
|
10
12
|
+
|
|
11
13
|
+Hem modificat un fitxer existent.
|
|
12
14
|
-Hem eliminat un fitxer.
|
|
15
|
+
|
|
13
16
|
joapuiib@FP:~/git_tutorial (main) $ git push
|
|
14
17
|
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
|
|
15
18
|
To /home/joapuiib/gitflow_example/remot
|
|
@@ -21,7 +24,28 @@ joapuiib@FP:~/git_tutorial (main) $ git lga
|
|
|
21
24
|
| * 9e34bb0 - (15 minutes ago) README: Afegida descripció del projecte - Anna (HEAD -> develop, origin/develop, feature/readme, origin/feature/readme)
|
|
22
25
|
|/
|
|
23
26
|
* 0fb88ef - (29 minutes ago) 1. Primer commit - Joan Puigcerver (origin/main, origin/HEAD, main)
|
|
27
|
+
|
|
24
28
|
[user@host ~ (main)] $ echo "Hello, world!"
|
|
29
|
+
|
|
25
30
|
(venv) [user@host ~] $ echo "Hello, world!"
|
|
26
|
-
(
|
|
31
|
+
(venv) [user@host ~] $ ls -l
|
|
32
|
+
|
|
33
|
+
joapuiib@fp:~/01_introduccio (main) $ git status
|
|
34
|
+
On branch main
|
|
35
|
+
|
|
36
|
+
No commits yet
|
|
37
|
+
|
|
38
|
+
Untracked files:
|
|
39
|
+
(use "git add <file>..." to include in what will be committed)
|
|
40
|
+
README.md
|
|
41
|
+
|
|
42
|
+
Changes not staged for commit:
|
|
43
|
+
(use "git add <file>..." to update what will be committed)
|
|
44
|
+
(use "git restore <file>..." to discard changes in working directory)
|
|
45
|
+
deleted: README.md
|
|
46
|
+
modified: mkdocs.yml
|
|
47
|
+
modified: requirements.txt
|
|
27
48
|
|
|
49
|
+
Changes to be committed:
|
|
50
|
+
(use "git rm --cached <file>..." to unstage)
|
|
51
|
+
new file: README.md
|
{pygments_shell_console-0.0.1 → pygments_shell_console-0.0.2}/.github/workflows/publish-to-pypi.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|