@akiojin/gwt 9.6.0 → 9.8.0

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.
@@ -0,0 +1,551 @@
1
+ // TODO: read all of this from terminfo
2
+
3
+ pub trait BufWrite {
4
+ fn write_buf(&self, buf: &mut Vec<u8>);
5
+ }
6
+
7
+ #[derive(Default, Debug)]
8
+ #[must_use = "this struct does nothing unless you call write_buf"]
9
+ pub struct ClearScreen;
10
+
11
+ impl BufWrite for ClearScreen {
12
+ fn write_buf(&self, buf: &mut Vec<u8>) {
13
+ buf.extend_from_slice(b"\x1b[H\x1b[J");
14
+ }
15
+ }
16
+
17
+ #[derive(Default, Debug)]
18
+ #[must_use = "this struct does nothing unless you call write_buf"]
19
+ pub struct ClearRowForward;
20
+
21
+ impl BufWrite for ClearRowForward {
22
+ fn write_buf(&self, buf: &mut Vec<u8>) {
23
+ buf.extend_from_slice(b"\x1b[K");
24
+ }
25
+ }
26
+
27
+ #[derive(Default, Debug)]
28
+ #[must_use = "this struct does nothing unless you call write_buf"]
29
+ pub struct Crlf;
30
+
31
+ impl BufWrite for Crlf {
32
+ fn write_buf(&self, buf: &mut Vec<u8>) {
33
+ buf.extend_from_slice(b"\r\n");
34
+ }
35
+ }
36
+
37
+ #[derive(Default, Debug)]
38
+ #[must_use = "this struct does nothing unless you call write_buf"]
39
+ pub struct Backspace;
40
+
41
+ impl BufWrite for Backspace {
42
+ fn write_buf(&self, buf: &mut Vec<u8>) {
43
+ buf.extend_from_slice(b"\x08");
44
+ }
45
+ }
46
+
47
+ #[derive(Default, Debug)]
48
+ #[must_use = "this struct does nothing unless you call write_buf"]
49
+ pub struct SaveCursor;
50
+
51
+ impl BufWrite for SaveCursor {
52
+ fn write_buf(&self, buf: &mut Vec<u8>) {
53
+ buf.extend_from_slice(b"\x1b7");
54
+ }
55
+ }
56
+
57
+ #[derive(Default, Debug)]
58
+ #[must_use = "this struct does nothing unless you call write_buf"]
59
+ pub struct RestoreCursor;
60
+
61
+ impl BufWrite for RestoreCursor {
62
+ fn write_buf(&self, buf: &mut Vec<u8>) {
63
+ buf.extend_from_slice(b"\x1b8");
64
+ }
65
+ }
66
+
67
+ #[derive(Default, Debug)]
68
+ #[must_use = "this struct does nothing unless you call write_buf"]
69
+ pub struct MoveTo {
70
+ row: u16,
71
+ col: u16,
72
+ }
73
+
74
+ impl MoveTo {
75
+ pub fn new(pos: crate::grid::Pos) -> Self {
76
+ Self {
77
+ row: pos.row,
78
+ col: pos.col,
79
+ }
80
+ }
81
+ }
82
+
83
+ impl BufWrite for MoveTo {
84
+ fn write_buf(&self, buf: &mut Vec<u8>) {
85
+ if self.row == 0 && self.col == 0 {
86
+ buf.extend_from_slice(b"\x1b[H");
87
+ } else {
88
+ buf.extend_from_slice(b"\x1b[");
89
+ extend_itoa(buf, self.row + 1);
90
+ buf.push(b';');
91
+ extend_itoa(buf, self.col + 1);
92
+ buf.push(b'H');
93
+ }
94
+ }
95
+ }
96
+
97
+ #[derive(Default, Debug)]
98
+ #[must_use = "this struct does nothing unless you call write_buf"]
99
+ pub struct ClearAttrs;
100
+
101
+ impl BufWrite for ClearAttrs {
102
+ fn write_buf(&self, buf: &mut Vec<u8>) {
103
+ buf.extend_from_slice(b"\x1b[m");
104
+ }
105
+ }
106
+
107
+ #[derive(Debug, Clone, Copy)]
108
+ pub enum Intensity {
109
+ Normal,
110
+ Bold,
111
+ Dim,
112
+ }
113
+
114
+ #[derive(Default, Debug)]
115
+ #[must_use = "this struct does nothing unless you call write_buf"]
116
+ pub struct Attrs {
117
+ fgcolor: Option<crate::Color>,
118
+ bgcolor: Option<crate::Color>,
119
+ intensity: Option<Intensity>,
120
+ italic: Option<bool>,
121
+ underline: Option<bool>,
122
+ inverse: Option<bool>,
123
+ }
124
+
125
+ impl Attrs {
126
+ pub fn fgcolor(mut self, fgcolor: crate::Color) -> Self {
127
+ self.fgcolor = Some(fgcolor);
128
+ self
129
+ }
130
+
131
+ pub fn bgcolor(mut self, bgcolor: crate::Color) -> Self {
132
+ self.bgcolor = Some(bgcolor);
133
+ self
134
+ }
135
+
136
+ pub fn intensity(mut self, intensity: Intensity) -> Self {
137
+ self.intensity = Some(intensity);
138
+ self
139
+ }
140
+
141
+ pub fn italic(mut self, italic: bool) -> Self {
142
+ self.italic = Some(italic);
143
+ self
144
+ }
145
+
146
+ pub fn underline(mut self, underline: bool) -> Self {
147
+ self.underline = Some(underline);
148
+ self
149
+ }
150
+
151
+ pub fn inverse(mut self, inverse: bool) -> Self {
152
+ self.inverse = Some(inverse);
153
+ self
154
+ }
155
+ }
156
+
157
+ impl BufWrite for Attrs {
158
+ #[allow(unused_assignments)]
159
+ #[allow(clippy::branches_sharing_code)]
160
+ fn write_buf(&self, buf: &mut Vec<u8>) {
161
+ if self.fgcolor.is_none()
162
+ && self.bgcolor.is_none()
163
+ && self.intensity.is_none()
164
+ && self.italic.is_none()
165
+ && self.underline.is_none()
166
+ && self.inverse.is_none()
167
+ {
168
+ return;
169
+ }
170
+
171
+ buf.extend_from_slice(b"\x1b[");
172
+ let mut first = true;
173
+
174
+ macro_rules! write_param {
175
+ ($i:expr) => {{
176
+ if first {
177
+ first = false;
178
+ } else {
179
+ buf.push(b';');
180
+ }
181
+ extend_itoa(buf, $i);
182
+ }};
183
+ }
184
+
185
+ if let Some(fgcolor) = self.fgcolor {
186
+ match fgcolor {
187
+ crate::Color::Default => {
188
+ write_param!(39);
189
+ }
190
+ crate::Color::Idx(i) => {
191
+ if i < 8 {
192
+ write_param!(i + 30);
193
+ } else if i < 16 {
194
+ write_param!(i + 82);
195
+ } else {
196
+ write_param!(38);
197
+ write_param!(5);
198
+ write_param!(i);
199
+ }
200
+ }
201
+ crate::Color::Rgb(r, g, b) => {
202
+ write_param!(38);
203
+ write_param!(2);
204
+ write_param!(r);
205
+ write_param!(g);
206
+ write_param!(b);
207
+ }
208
+ }
209
+ }
210
+
211
+ if let Some(bgcolor) = self.bgcolor {
212
+ match bgcolor {
213
+ crate::Color::Default => {
214
+ write_param!(49);
215
+ }
216
+ crate::Color::Idx(i) => {
217
+ if i < 8 {
218
+ write_param!(i + 40);
219
+ } else if i < 16 {
220
+ write_param!(i + 92);
221
+ } else {
222
+ write_param!(48);
223
+ write_param!(5);
224
+ write_param!(i);
225
+ }
226
+ }
227
+ crate::Color::Rgb(r, g, b) => {
228
+ write_param!(48);
229
+ write_param!(2);
230
+ write_param!(r);
231
+ write_param!(g);
232
+ write_param!(b);
233
+ }
234
+ }
235
+ }
236
+
237
+ if let Some(intensity) = self.intensity {
238
+ match intensity {
239
+ Intensity::Normal => write_param!(22),
240
+ Intensity::Bold => write_param!(1),
241
+ Intensity::Dim => write_param!(2),
242
+ }
243
+ }
244
+
245
+ if let Some(italic) = self.italic {
246
+ if italic {
247
+ write_param!(3);
248
+ } else {
249
+ write_param!(23);
250
+ }
251
+ }
252
+
253
+ if let Some(underline) = self.underline {
254
+ if underline {
255
+ write_param!(4);
256
+ } else {
257
+ write_param!(24);
258
+ }
259
+ }
260
+
261
+ if let Some(inverse) = self.inverse {
262
+ if inverse {
263
+ write_param!(7);
264
+ } else {
265
+ write_param!(27);
266
+ }
267
+ }
268
+
269
+ buf.push(b'm');
270
+ }
271
+ }
272
+
273
+ #[derive(Debug)]
274
+ #[must_use = "this struct does nothing unless you call write_buf"]
275
+ pub struct MoveRight {
276
+ count: u16,
277
+ }
278
+
279
+ impl MoveRight {
280
+ pub fn new(count: u16) -> Self {
281
+ Self { count }
282
+ }
283
+ }
284
+
285
+ impl Default for MoveRight {
286
+ fn default() -> Self {
287
+ Self { count: 1 }
288
+ }
289
+ }
290
+
291
+ impl BufWrite for MoveRight {
292
+ fn write_buf(&self, buf: &mut Vec<u8>) {
293
+ match self.count {
294
+ 0 => {}
295
+ 1 => buf.extend_from_slice(b"\x1b[C"),
296
+ n => {
297
+ buf.extend_from_slice(b"\x1b[");
298
+ extend_itoa(buf, n);
299
+ buf.push(b'C');
300
+ }
301
+ }
302
+ }
303
+ }
304
+
305
+ #[derive(Debug)]
306
+ #[must_use = "this struct does nothing unless you call write_buf"]
307
+ pub struct EraseChar {
308
+ count: u16,
309
+ }
310
+
311
+ impl EraseChar {
312
+ pub fn new(count: u16) -> Self {
313
+ Self { count }
314
+ }
315
+ }
316
+
317
+ impl Default for EraseChar {
318
+ fn default() -> Self {
319
+ Self { count: 1 }
320
+ }
321
+ }
322
+
323
+ impl BufWrite for EraseChar {
324
+ fn write_buf(&self, buf: &mut Vec<u8>) {
325
+ match self.count {
326
+ 0 => {}
327
+ 1 => buf.extend_from_slice(b"\x1b[X"),
328
+ n => {
329
+ buf.extend_from_slice(b"\x1b[");
330
+ extend_itoa(buf, n);
331
+ buf.push(b'X');
332
+ }
333
+ }
334
+ }
335
+ }
336
+
337
+ #[derive(Default, Debug)]
338
+ #[must_use = "this struct does nothing unless you call write_buf"]
339
+ pub struct HideCursor {
340
+ state: bool,
341
+ }
342
+
343
+ impl HideCursor {
344
+ pub fn new(state: bool) -> Self {
345
+ Self { state }
346
+ }
347
+ }
348
+
349
+ impl BufWrite for HideCursor {
350
+ fn write_buf(&self, buf: &mut Vec<u8>) {
351
+ if self.state {
352
+ buf.extend_from_slice(b"\x1b[?25l");
353
+ } else {
354
+ buf.extend_from_slice(b"\x1b[?25h");
355
+ }
356
+ }
357
+ }
358
+
359
+ #[derive(Debug)]
360
+ #[must_use = "this struct does nothing unless you call write_buf"]
361
+ pub struct MoveFromTo {
362
+ from: crate::grid::Pos,
363
+ to: crate::grid::Pos,
364
+ }
365
+
366
+ impl MoveFromTo {
367
+ pub fn new(from: crate::grid::Pos, to: crate::grid::Pos) -> Self {
368
+ Self { from, to }
369
+ }
370
+ }
371
+
372
+ impl BufWrite for MoveFromTo {
373
+ fn write_buf(&self, buf: &mut Vec<u8>) {
374
+ if self.to.row == self.from.row + 1 && self.to.col == 0 {
375
+ crate::term::Crlf.write_buf(buf);
376
+ } else if self.from.row == self.to.row && self.from.col < self.to.col
377
+ {
378
+ crate::term::MoveRight::new(self.to.col - self.from.col)
379
+ .write_buf(buf);
380
+ } else if self.to != self.from {
381
+ crate::term::MoveTo::new(self.to).write_buf(buf);
382
+ }
383
+ }
384
+ }
385
+
386
+ #[derive(Default, Debug)]
387
+ #[must_use = "this struct does nothing unless you call write_buf"]
388
+ pub struct ApplicationKeypad {
389
+ state: bool,
390
+ }
391
+
392
+ impl ApplicationKeypad {
393
+ pub fn new(state: bool) -> Self {
394
+ Self { state }
395
+ }
396
+ }
397
+
398
+ impl BufWrite for ApplicationKeypad {
399
+ fn write_buf(&self, buf: &mut Vec<u8>) {
400
+ if self.state {
401
+ buf.extend_from_slice(b"\x1b=");
402
+ } else {
403
+ buf.extend_from_slice(b"\x1b>");
404
+ }
405
+ }
406
+ }
407
+
408
+ #[derive(Default, Debug)]
409
+ #[must_use = "this struct does nothing unless you call write_buf"]
410
+ pub struct ApplicationCursor {
411
+ state: bool,
412
+ }
413
+
414
+ impl ApplicationCursor {
415
+ pub fn new(state: bool) -> Self {
416
+ Self { state }
417
+ }
418
+ }
419
+
420
+ impl BufWrite for ApplicationCursor {
421
+ fn write_buf(&self, buf: &mut Vec<u8>) {
422
+ if self.state {
423
+ buf.extend_from_slice(b"\x1b[?1h");
424
+ } else {
425
+ buf.extend_from_slice(b"\x1b[?1l");
426
+ }
427
+ }
428
+ }
429
+
430
+ #[derive(Default, Debug)]
431
+ #[must_use = "this struct does nothing unless you call write_buf"]
432
+ pub struct BracketedPaste {
433
+ state: bool,
434
+ }
435
+
436
+ impl BracketedPaste {
437
+ pub fn new(state: bool) -> Self {
438
+ Self { state }
439
+ }
440
+ }
441
+
442
+ impl BufWrite for BracketedPaste {
443
+ fn write_buf(&self, buf: &mut Vec<u8>) {
444
+ if self.state {
445
+ buf.extend_from_slice(b"\x1b[?2004h");
446
+ } else {
447
+ buf.extend_from_slice(b"\x1b[?2004l");
448
+ }
449
+ }
450
+ }
451
+
452
+ #[derive(Default, Debug)]
453
+ #[must_use = "this struct does nothing unless you call write_buf"]
454
+ pub struct MouseProtocolMode {
455
+ mode: crate::MouseProtocolMode,
456
+ prev: crate::MouseProtocolMode,
457
+ }
458
+
459
+ impl MouseProtocolMode {
460
+ pub fn new(
461
+ mode: crate::MouseProtocolMode,
462
+ prev: crate::MouseProtocolMode,
463
+ ) -> Self {
464
+ Self { mode, prev }
465
+ }
466
+ }
467
+
468
+ impl BufWrite for MouseProtocolMode {
469
+ fn write_buf(&self, buf: &mut Vec<u8>) {
470
+ if self.mode == self.prev {
471
+ return;
472
+ }
473
+
474
+ match self.mode {
475
+ crate::MouseProtocolMode::None => match self.prev {
476
+ crate::MouseProtocolMode::None => {}
477
+ crate::MouseProtocolMode::Press => {
478
+ buf.extend_from_slice(b"\x1b[?9l");
479
+ }
480
+ crate::MouseProtocolMode::PressRelease => {
481
+ buf.extend_from_slice(b"\x1b[?1000l");
482
+ }
483
+ crate::MouseProtocolMode::ButtonMotion => {
484
+ buf.extend_from_slice(b"\x1b[?1002l");
485
+ }
486
+ crate::MouseProtocolMode::AnyMotion => {
487
+ buf.extend_from_slice(b"\x1b[?1003l");
488
+ }
489
+ },
490
+ crate::MouseProtocolMode::Press => {
491
+ buf.extend_from_slice(b"\x1b[?9h");
492
+ }
493
+ crate::MouseProtocolMode::PressRelease => {
494
+ buf.extend_from_slice(b"\x1b[?1000h");
495
+ }
496
+ crate::MouseProtocolMode::ButtonMotion => {
497
+ buf.extend_from_slice(b"\x1b[?1002h");
498
+ }
499
+ crate::MouseProtocolMode::AnyMotion => {
500
+ buf.extend_from_slice(b"\x1b[?1003h");
501
+ }
502
+ }
503
+ }
504
+ }
505
+
506
+ #[derive(Default, Debug)]
507
+ #[must_use = "this struct does nothing unless you call write_buf"]
508
+ pub struct MouseProtocolEncoding {
509
+ encoding: crate::MouseProtocolEncoding,
510
+ prev: crate::MouseProtocolEncoding,
511
+ }
512
+
513
+ impl MouseProtocolEncoding {
514
+ pub fn new(
515
+ encoding: crate::MouseProtocolEncoding,
516
+ prev: crate::MouseProtocolEncoding,
517
+ ) -> Self {
518
+ Self { encoding, prev }
519
+ }
520
+ }
521
+
522
+ impl BufWrite for MouseProtocolEncoding {
523
+ fn write_buf(&self, buf: &mut Vec<u8>) {
524
+ if self.encoding == self.prev {
525
+ return;
526
+ }
527
+
528
+ match self.encoding {
529
+ crate::MouseProtocolEncoding::Default => match self.prev {
530
+ crate::MouseProtocolEncoding::Default => {}
531
+ crate::MouseProtocolEncoding::Utf8 => {
532
+ buf.extend_from_slice(b"\x1b[?1005l");
533
+ }
534
+ crate::MouseProtocolEncoding::Sgr => {
535
+ buf.extend_from_slice(b"\x1b[?1006l");
536
+ }
537
+ },
538
+ crate::MouseProtocolEncoding::Utf8 => {
539
+ buf.extend_from_slice(b"\x1b[?1005h");
540
+ }
541
+ crate::MouseProtocolEncoding::Sgr => {
542
+ buf.extend_from_slice(b"\x1b[?1006h");
543
+ }
544
+ }
545
+ }
546
+ }
547
+
548
+ fn extend_itoa<I: itoa::Integer>(buf: &mut Vec<u8>, i: I) {
549
+ let mut itoa_buf = itoa::Buffer::new();
550
+ buf.extend_from_slice(itoa_buf.format(i).as_bytes());
551
+ }
package/wix/main.wxs CHANGED
@@ -7,24 +7,62 @@
7
7
  Manufacturer="GWT Contributors"
8
8
  UpgradeCode="55555555-5555-5555-5555-555555555555"
9
9
  InstallerVersion="500"
10
- Scope="perMachine">
10
+ Scope="perUser">
11
11
  <SummaryInformation Description="Canvas-based floating terminal GUI for Git Worktree Manager" />
12
+ <Property Id="ARPPRODUCTICON" Value="GwtIcon.exe" />
13
+ <Property Id="GWT_ALLOW_LEGACY_MIGRATION" Secure="yes" />
14
+ <Property Id="GWT_LEGACY_PER_MACHINE_EXE">
15
+ <DirectorySearch Id="GwtLegacyProgramFilesSearch" Path="[ProgramFiles6432Folder]GWT" Depth="0">
16
+ <FileSearch Id="GwtLegacyProgramFilesExeSearch" Name="gwt.exe" />
17
+ </DirectorySearch>
18
+ </Property>
19
+ <Launch
20
+ Condition="NOT GWT_LEGACY_PER_MACHINE_EXE OR GWT_ALLOW_LEGACY_MIGRATION = &quot;1&quot;"
21
+ Message="A per-machine GWT installation was found in Program Files. Uninstall the existing GWT from Windows Settings, then run this installer again." />
12
22
  <MajorUpgrade DowngradeErrorMessage="A newer version of GWT is already installed." />
13
23
  <MediaTemplate EmbedCab="yes" />
14
24
 
15
- <StandardDirectory Id="ProgramFiles6432Folder">
16
- <Directory Id="INSTALLFOLDER" Name="GWT" />
25
+ <StandardDirectory Id="LocalAppDataFolder">
26
+ <Directory Id="GwtProgramsFolder" Name="Programs">
27
+ <Directory Id="INSTALLFOLDER" Name="GWT" />
28
+ </Directory>
29
+ </StandardDirectory>
30
+
31
+ <StandardDirectory Id="ProgramMenuFolder">
32
+ <Directory Id="ApplicationProgramsFolder" Name="GWT" />
17
33
  </StandardDirectory>
18
34
 
19
35
  <Feature Id="MainFeature" Title="GWT" Level="1">
20
36
  <ComponentGroupRef Id="ProductComponents" />
37
+ <ComponentGroupRef Id="ShortcutComponents" />
21
38
  </Feature>
39
+
40
+ <Icon Id="GwtIcon.exe" SourceFile="assets/icons/icon.ico" />
22
41
  </Package>
23
42
 
24
43
  <Fragment>
25
44
  <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
26
- <Component>
45
+ <Component Id="GwtExecutableComponent">
27
46
  <File Id="GwtExecutable" Source="!(bindpath.gwt)gwt.exe" KeyPath="yes" />
47
+ <Environment Id="GwtUserPath" Name="PATH" Value="[INSTALLFOLDER]" Action="set" Part="last" />
48
+ </Component>
49
+ <Component Id="GwtdExecutableComponent">
50
+ <File Id="GwtdExecutable" Source="!(bindpath.gwt)gwtd.exe" KeyPath="yes" />
51
+ </Component>
52
+ </ComponentGroup>
53
+
54
+ <ComponentGroup Id="ShortcutComponents" Directory="ApplicationProgramsFolder">
55
+ <Component Id="GwtStartMenuShortcutComponent">
56
+ <Shortcut
57
+ Id="GwtStartMenuShortcut"
58
+ Name="GWT"
59
+ Description="Open GWT"
60
+ Target="[#GwtExecutable]"
61
+ WorkingDirectory="INSTALLFOLDER"
62
+ Icon="GwtIcon.exe"
63
+ IconIndex="0" />
64
+ <RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
65
+ <RegistryValue Root="HKCU" Key="Software\GWT" Name="StartMenuShortcut" Type="integer" Value="1" KeyPath="yes" />
28
66
  </Component>
29
67
  </ComponentGroup>
30
68
  </Fragment>