Skip to content

Commit 4458568

Browse files
pxoralehander92
authored andcommitted
feat: Add different filesystem colors for added, deleted or changed diff files
1 parent 637d434 commit 4458568

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

src/frontend/styles/components/filesystem.styl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@
2525
.jstree-anchor
2626
color: TEXT_CONTENT_COLOR !important
2727

28-
.diff-file
28+
.diff-file-added
29+
color: green !important
30+
31+
.diff-file-changed
2932
color: orange !important
3033

34+
.diff-file-deleted
35+
color: red !important
36+
3137
.diff-files-list
3238
max-height: 20% !important
3339
height: auto

src/frontend/types.nim

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ type
287287
hasSaveHistoryTimeout*: bool
288288
switchTabHistoryLimit*: int
289289
cachedFiles*: JsAssoc[cstring, TabInfo]
290-
diffId*: seq[cstring]
290+
addedDiffId*: seq[cstring]
291+
changedDiffId*: seq[cstring]
292+
deletedDiffId*: seq[cstring]
291293
index*: int
292294
# commandData*: CommandData
293295

@@ -1534,7 +1536,7 @@ type
15341536
# sys*: SysConfig
15351537

15361538
when defined(ctRenderer):
1537-
import
1539+
import
15381540
std / jsconsole,
15391541
.. / common / ct_event
15401542

@@ -1590,7 +1592,9 @@ when defined(ctRenderer):
15901592
# lowLevel: LowLevel(),
15911593
expandedOpen: JsAssoc[cstring, TabInfo]{},
15921594
cachedFiles: JsAssoc[cstring, TabInfo]{},
1593-
diffId: @[],
1595+
addedDiffId: @[],
1596+
changedDiffId: @[],
1597+
deletedDiffId: @[],
15941598
index: 1),
15951599
calltrace: CalltraceService(
15961600
callstackCollapse: (name: cstring"", level: -1),
@@ -1630,7 +1634,7 @@ when defined(ctRenderer):
16301634
# TODO max for program, maybe min as well?
16311635

16321636
console.log "data.dapApi"
1633-
console.log data.dapApi
1637+
console.log data.dapApi
16341638

16351639
console.log "data.viewsApi"
16361640
console.log data.viewsApi
@@ -1678,7 +1682,7 @@ when defined(ctRenderer):
16781682

16791683
proc newLocalViewToMiddlewareTransport(middlewareToViewsTransport: Transport): LocalViewToMiddlewareTransport =
16801684
LocalViewToMiddlewareTransport(middlewareToViewsTransport: middlewareToViewsTransport)
1681-
1685+
16821686
# === end
16831687

16841688
proc setupLocalViewToMiddlewareApi*(name: cstring, middlewareToViewsApi: MediatorWithSubscribers): MediatorWithSubscribers =
@@ -1866,7 +1870,7 @@ method onOutputJumpFromShellUi*(self: Component, response: int) {.base, async.}
18661870

18671871
method onDapStopped*(self: Component, response: DapStoppedEvent) {.base, async.} =
18681872
discard
1869-
1873+
18701874
method increaseWhitespaceWidth*(self: EditorViewComponent) {.base.} =
18711875
if self.whitespace.width < MAX_WHITESPACE_WIDTH:
18721876
self.whitespace.width += 1

src/frontend/ui/filesystem.nim

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,30 @@ proc changeIcons*(file: CodetracerFile) =
119119

120120

121121
proc reapplyDiffClasses(self: FilesystemComponent) =
122-
for id in self.service.diffId:
123-
let sel = "#j" & id
124-
let el = jqFind(sel)
125-
if not el.isNil: el.addClass("diff-file")
122+
proc applyClass(diffIdList: seq[cstring], class: cstring) =
123+
for id in diffIdList:
124+
let sel = "#j" & id
125+
let el = jqFind(sel)
126+
if not el.isNil: el.addClass(class)
127+
128+
self.service.addedDiffId.applyClass("diff-file-added")
129+
self.service.changedDiffId.applyClass("diff-file-changed")
130+
self.service.deletedDiffId.applyClass("diff-file-deleted")
126131

127132
proc mapDiff(service: EditorService, node: CodetracerFile) =
128133
for child in node.children:
129134
service.index += 1
130135
for fileDiff in data.startOptions.diff.files:
131136
if child.original.path == fileDiff.currentPath:
132-
service.diffId.add(&"1_{service.index}_anchor")
137+
case fileDiff.change:
138+
of FileAdded:
139+
service.addedDiffId.add(&"1_{service.index}_anchor")
140+
of FileDeleted:
141+
service.deletedDiffId.add(&"1_{service.index}_anchor")
142+
of FileRenamed:
143+
discard
144+
of FileChanged:
145+
service.changedDiffId.add(&"1_{service.index}_anchor")
133146
mapDiff(service, child)
134147

135148
proc openTab(currentPath: cstring) =
@@ -165,8 +178,7 @@ method render*(self: FilesystemComponent): VNode =
165178
jqFind(".filesystem").toJs.on(
166179
"ready.jstree",
167180
proc(e: js, node: jsobject(node=CodetracerFile)) =
168-
for id in self.service.diffId:
169-
jqFind("#j" & id).addClass("diff-file")
181+
self.reapplyDiffClasses()
170182
)
171183

172184
jqFind(".filesystem").toJs.on(cstring"refresh.jstree",

0 commit comments

Comments
 (0)