Skip to content

Commit 42207d7

Browse files
committed
fix(project): rename tree node, refactor(config): for socket updates
1 parent 8c71628 commit 42207d7

File tree

4 files changed

+46
-31
lines changed

4 files changed

+46
-31
lines changed

socket.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ codesign_paths = ""
275275
; default value: "13.0.0"
276276
; minimum_supported_version = "13.0.0"
277277

278-
trafficLightPosition = "10x24"
278+
window_control_offsets = "10x24"
279279

280280
; The icon to use for identifying your app on MacOS.
281281
icon = "icons/icon.png"
@@ -322,8 +322,8 @@ height = 80%
322322
; The initial width of the first window in pixels or as a percentage of the screen.
323323
width = 80%
324324

325-
backgroundColorDark = "rgba(46, 46, 46, 1)"
326-
backgroundColorLight = "rgba(255, 255, 255, 1)"
325+
;background_color_dark = "rgba(46, 46, 46, 1)"
326+
;background_color_light = "rgba(255, 255, 255, 1)"
327327

328328
; Maximum height of the window in pixels or as a percentage of the screen.
329329
; default value: 100%
@@ -349,7 +349,7 @@ min_width = 700
349349
; default value: false
350350
; frameless = false
351351

352-
titleBarStyle = "hiddenInset"
352+
titlebar_style = "hiddenInset"
353353

354354
; If the window is utility window or not.
355355
; default value: false

src/components/editor.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ globalThis.MonacoEnvironment = {
4545
}
4646

4747
class EditorTabs extends Tonic {
48-
selectedTabId = null
4948
scrollLeft = 0
5049
index = 0
5150

5251
constructor () {
5352
super()
5453

5554
this.state = {
55+
selectedTabId: null,
56+
editingTabId: null,
5657
tabs: new Map(),
5758
...this.state
5859
}
@@ -606,10 +607,17 @@ class AppEditor extends Tonic {
606607
const coTabs = document.querySelector('editor-tabs')
607608
this.editor.updateOptions({ readOnly: false })
608609

609-
if (coTabs.tab?.label.endsWith('.patch') || coTabs.tab?.label.endsWith('.ini')) {
610+
if (coTabs.tab?.label.endsWith('.patch')) {
610611
this.editor.updateOptions({ readOnly: true })
611-
this.editor.getAction('editor.foldAll').run()
612612
}
613+
614+
if (coTabs.tab?.label.endsWith('.patch') || coTabs.tab?.label.endsWith('.ini')) {
615+
if (coTabs.state.editingTabId !== coTabs.tab.id) {
616+
this.editor.getAction('editor.foldAll').run()
617+
}
618+
}
619+
620+
coTabs.state.editingTabId = coTabs.tab.id
613621
})
614622

615623
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {

src/components/project.js

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ class AppProject extends Tonic {
108108
})
109109
}
110110

111+
resetMouse () {
112+
this.mouseMoveThreshold = 0
113+
this.removeAttribute('dragging')
114+
this.mouseIsDragging = false
115+
this.mouseIsDown = false
116+
}
117+
118+
async renameNode (node, value) {
119+
const dirname = path.dirname(node.id).replace(/%20/g, ' ')
120+
const newId = path.join(dirname, value)
121+
await fs.promises.rename(node.id, newId)
122+
123+
const coTabs = document.querySelector('editor-tabs')
124+
125+
if (coTabs && coTabs.tab?.id === node.id) {
126+
coTabs.rename({ oldId: coTabs.tab.id, newId, label: value })
127+
}
128+
129+
node.label = value
130+
node.id = newId
131+
132+
this.load()
133+
}
134+
111135
mousedown (e) {
112136
const el = Tonic.match(e.target, '[data-path]')
113137
if (!el) return
@@ -125,13 +149,6 @@ class AppProject extends Tonic {
125149
this.referenceNode = node
126150
}
127151

128-
resetMouse () {
129-
this.mouseMoveThreshold = 0
130-
this.removeAttribute('dragging')
131-
this.mouseIsDragging = false
132-
this.mouseIsDown = false
133-
}
134-
135152
async mouseup (e) {
136153
const mouseDragged = this.mouseIsDragging
137154
this.resetMouse()
@@ -270,20 +287,7 @@ class AppProject extends Tonic {
270287
if (e.key === 'Enter') {
271288
const value = e.target.value.trim()
272289
if (this.getNodeByProperty('id', value)) return
273-
274-
const dirname = path.dirname(node.id).replace(/%20/g, ' ')
275-
const newId = path.join(dirname, value)
276-
await fs.promises.rename(node.id, newId)
277-
278-
const coTabs = document.querySelector('editor-tabs')
279-
if (coTabs && coTabs.tab.id === node.id) {
280-
coTabs.rename({ oldId: coTabs.tab.id, newId, label: value })
281-
}
282-
283-
node.label = value
284-
node.id = newId
285-
286-
this.load()
290+
this.renameNode(node, value)
287291
}
288292
}
289293
}
@@ -313,6 +317,10 @@ class AppProject extends Tonic {
313317
input.addEventListener('blur', () => {
314318
container.innerHTML = ''
315319
container.textContent = node.label
320+
321+
const value = input.value.trim()
322+
if (this.getNodeByProperty('id', value)) return
323+
this.renameNode(node, value)
316324
})
317325

318326
container.innerHTML = ''
@@ -489,7 +497,6 @@ class AppProject extends Tonic {
489497
}
490498

491499
this.state.currentProjectId = projectNode.id
492-
this.props.parent.activatePreviewWindows()
493500

494501
if (node.type === 'project') {
495502
await coProjectSummary.reRender()

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ class AppView extends Tonic {
189189
title: preview.title,
190190
titleBarStyle: preview.titleBarStyle, // ie 'hiddenInset'
191191
trafficLightPosition: preview.trafficLightPosition, // ie '10x26'
192-
backgroundColorDark: 'rgba(46, 46, 46, 0.1)',
193-
backgroundColorLight: 'rgba(255, 255, 255, 0.1)',
192+
// backgroundColorDark: 'rgba(46, 46, 46, 0.1)',
193+
// backgroundColorLight: 'rgba(255, 255, 255, 0.1)',
194194
aspectRatio: preview.aspectRatio, // ie '9:19.5'
195195
width: Math.floor(width / scale),
196196
height: Math.floor(height / scale)

0 commit comments

Comments
 (0)