reflexion 0.4.0 → 0.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8781c6a2e533488f1529b59cdb98ed7922909330e254bdbd80b7ce67f40a8252
4
- data.tar.gz: 449a81f9c5ba57c2daa68af18cc6e42d90319703beab674dee431e5bc2923d4b
3
+ metadata.gz: ee249febb85efea8890f5d4623feec5d9f191ad969e20d83af968cb243b2b116
4
+ data.tar.gz: 70b1950e21b7e6ddc89b967b72a1e4acdd42afda4952f59832aa84379b24e5fb
5
5
  SHA512:
6
- metadata.gz: c746ba6a4b32c05eca98a2bd3c7ab5e459e44222d80794323757a8516401a91404c76aa4e7dbb08b084126bf08d65bf310ab8f3095f06bd2df29577fa7989604
7
- data.tar.gz: 928aa64c73861dcb0848dc6c6ea6d770ccb3dff1e9e06ba6bb3cf470cb5104311af6ecfc543d4ca015f8efdc3a12d9bb6662b80014f9fc57a2bbc16c74bf5e43
6
+ metadata.gz: 816a5bfe8901e16a894ecb7f47cc5d542d50d33c856b0bed1b6b70189169e76f0abb917b2bf539ca71f4b25b3a3e47a05e5e3ff19f738b5125cdf338c1de894e
7
+ data.tar.gz: b53a2064c5b99b16195d69a51d02af0ff7437fafe3dab282528bb449c98c5fcd5de9b0b3dbf080a279a9ff2507e357f5b797fdb778d0a3787f2748955b63f1a8
data/ChangeLog.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # reflex ChangeLog
2
2
 
3
3
 
4
+ ## [v0.4.1] - 2026-05-20
5
+
6
+ - Track actual key repeat count on macOS
7
+ - Add key repeat on iOS
8
+
9
+
4
10
  ## [v0.4.0] - 2026-05-17
5
11
 
6
12
  - [BREAKING] Normalize wheel Y delta to top-left origin convention
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/reflex.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
 
28
28
  s.add_dependency 'xot', '~> 0.3.13'
29
29
  s.add_dependency 'rucy', '~> 0.3.13'
30
- s.add_dependency 'rays', '~> 0.3.13'
30
+ s.add_dependency 'rays', '~> 0.3.14'
31
31
 
32
32
  s.files = `git ls-files`.split $/
33
33
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
data/src/ios/event.h CHANGED
@@ -17,7 +17,7 @@ namespace Reflex
17
17
 
18
18
  public:
19
19
 
20
- NativeKeyEvent (UIPress* press, Action action)
20
+ NativeKeyEvent (UIPress* press, Action action, int repeat = 0)
21
21
  API_AVAILABLE(ios(13.4));
22
22
 
23
23
  };// NativeKeyEvent
data/src/ios/event.mm CHANGED
@@ -115,10 +115,10 @@ namespace Reflex
115
115
  return s.UTF8String;
116
116
  }
117
117
 
118
- NativeKeyEvent::NativeKeyEvent (UIPress* press, Action action)
118
+ NativeKeyEvent::NativeKeyEvent (UIPress* press, Action action, int repeat)
119
119
  : KeyEvent(
120
120
  action, get_chars(press.key), (int) press.key.keyCode,
121
- to_modifiers(press.key.modifierFlags), 0)
121
+ to_modifiers(press.key.modifierFlags), repeat)
122
122
  {
123
123
  }
124
124
 
@@ -65,6 +65,14 @@ show_reflex_view_controller (
65
65
  [top presentViewController: reflex_vc animated: YES completion: nil];
66
66
  }
67
67
 
68
+ static BOOL
69
+ is_modifier_key (long keyCode) API_AVAILABLE(ios(13.4))
70
+ {
71
+ return
72
+ keyCode >= UIKeyboardHIDUsageKeyboardLeftControl &&
73
+ keyCode <= UIKeyboardHIDUsageKeyboardRightGUI;
74
+ }
75
+
68
76
 
69
77
  namespace global
70
78
  {
@@ -129,6 +137,10 @@ ReflexViewController_get_show_fun ()
129
137
 
130
138
  @property(nonatomic, strong) UIHoverGestureRecognizer* hoverRecognizer;
131
139
 
140
+ @property(nonatomic, strong) UIPress* repeatingKeyPress;
141
+
142
+ @property(nonatomic, strong) NSTimer* repeatingKeyTimer;
143
+
132
144
  @end
133
145
 
134
146
 
@@ -138,6 +150,7 @@ ReflexViewController_get_show_fun ()
138
150
  Reflex::Window *pwindow, *ptr_for_rebind;
139
151
  int update_count;
140
152
  int touching_count;
153
+ int repeating_key_count;
141
154
  }
142
155
 
143
156
  - (id) init
@@ -145,10 +158,11 @@ ReflexViewController_get_show_fun ()
145
158
  self = [super init];
146
159
  if (!self) return nil;
147
160
 
148
- pwindow =
149
- ptr_for_rebind = NULL;
150
- update_count = 0;
151
- touching_count = 0;
161
+ pwindow =
162
+ ptr_for_rebind = NULL;
163
+ update_count = 0;
164
+ touching_count = 0;
165
+ repeating_key_count = 0;
152
166
 
153
167
  return self;
154
168
  }
@@ -301,6 +315,8 @@ ReflexViewController_get_show_fun ()
301
315
  ReflexView* view = self.reflexView;
302
316
  if (!view) return;
303
317
 
318
+ [self stopKeyRepeat];
319
+
304
320
  if (view.context && view.context == [EAGLContext currentContext])
305
321
  Rays::activate_offscreen_context();
306
322
 
@@ -333,6 +349,7 @@ ReflexViewController_get_show_fun ()
333
349
 
334
350
  - (void) viewDidDisappear: (BOOL) animated
335
351
  {
352
+ [self stopKeyRepeat];
336
353
  [self resignFirstResponder];
337
354
 
338
355
  [NSNotificationCenter.defaultCenter
@@ -357,6 +374,7 @@ ReflexViewController_get_show_fun ()
357
374
 
358
375
  - (void) willResignActive
359
376
  {
377
+ [self stopKeyRepeat];
360
378
  Window_call_deactivate_event(self.window);
361
379
  }
362
380
 
@@ -638,7 +656,56 @@ ReflexViewController_get_show_fun ()
638
656
  if (!press.key) continue;
639
657
  Reflex::NativeKeyEvent e(press, action);
640
658
  Window_call_key_event(win, &e);
659
+
660
+ if (action == Reflex::KeyEvent::DOWN)
661
+ {
662
+ if (!is_modifier_key(press.key.keyCode))
663
+ [self startKeyRepeat: press];
664
+ }
665
+ else if (
666
+ self.repeatingKeyPress &&
667
+ press.key.keyCode == self.repeatingKeyPress.key.keyCode)
668
+ {
669
+ [self stopKeyRepeat];
670
+ }
641
671
  }
642
672
  }
643
673
 
674
+ - (void) startKeyRepeat: (UIPress*) press
675
+ API_AVAILABLE(ios(13.4))
676
+ {
677
+ [self stopKeyRepeat];
678
+
679
+ repeating_key_count = 0;
680
+ self.repeatingKeyPress = press;
681
+ self.repeatingKeyTimer = [NSTimer scheduledTimerWithTimeInterval: 0.4
682
+ target: self selector: @selector(keyRepeatFired:) userInfo: nil repeats: NO];
683
+ }
684
+
685
+ - (void) keyRepeatFired: (NSTimer*) timer
686
+ API_AVAILABLE(ios(13.4))
687
+ {
688
+ Reflex::Window* win = self.window;
689
+ UIPress* press = self.repeatingKeyPress;
690
+ if (!win || !press || !press.key)
691
+ {
692
+ [self stopKeyRepeat];
693
+ return;
694
+ }
695
+
696
+ Reflex::NativeKeyEvent e(press, Reflex::KeyEvent::DOWN, ++repeating_key_count);
697
+ Window_call_key_event(win, &e);
698
+
699
+ self.repeatingKeyTimer = [NSTimer scheduledTimerWithTimeInterval: 0.1
700
+ target: self selector: @selector(keyRepeatFired:) userInfo: nil repeats: NO];
701
+ }
702
+
703
+ - (void) stopKeyRepeat
704
+ {
705
+ [self.repeatingKeyTimer invalidate];
706
+ self.repeatingKeyTimer = nil;
707
+ self.repeatingKeyPress = nil;
708
+ repeating_key_count = 0;
709
+ }
710
+
644
711
  @end// ReflexViewController
data/src/osx/event.h CHANGED
@@ -17,7 +17,7 @@ namespace Reflex
17
17
 
18
18
  public:
19
19
 
20
- NativeKeyEvent (NSEvent* event, Action action);
20
+ NativeKeyEvent (NSEvent* event, Action action, int repeat = 0);
21
21
 
22
22
  };// NativeKeyEvent
23
23
 
data/src/osx/event.mm CHANGED
@@ -52,10 +52,8 @@ namespace Reflex
52
52
  return [chars UTF8String];
53
53
  }
54
54
 
55
- NativeKeyEvent::NativeKeyEvent (NSEvent* e, Action action)
56
- : KeyEvent(
57
- action, get_chars(e), [e keyCode],
58
- get_modifiers(e), [e isARepeat] ? 1 : 0)
55
+ NativeKeyEvent::NativeKeyEvent (NSEvent* e, Action action, int repeat)
56
+ : KeyEvent(action, get_chars(e), [e keyCode], get_modifiers(e), repeat)
59
57
  {
60
58
  }
61
59
 
@@ -56,6 +56,8 @@ move_to_main_screen_origin (NativeWindow* window)
56
56
  OpenGLView* view;
57
57
  NSTimer* timer;
58
58
  int update_count;
59
+ int repeating_key_code;
60
+ int repeating_key_count;
59
61
  }
60
62
 
61
63
  - (id) init
@@ -67,11 +69,13 @@ move_to_main_screen_origin (NativeWindow* window)
67
69
  defer: NO];
68
70
  if (!self) return nil;
69
71
 
70
- pwindow =
71
- ptr_for_rebind = NULL;
72
- view = nil;
73
- timer = nil;
74
- update_count = 0;
72
+ pwindow =
73
+ ptr_for_rebind = NULL;
74
+ view = nil;
75
+ timer = nil;
76
+ update_count = 0;
77
+ repeating_key_code = -1;
78
+ repeating_key_count = 0;
75
79
 
76
80
  [self setDelegate: self];
77
81
  [self setupContentView];
@@ -365,7 +369,16 @@ move_to_main_screen_origin (NativeWindow* window)
365
369
  Reflex::Window* win = self.window;
366
370
  if (!win) return;
367
371
 
368
- Reflex::NativeKeyEvent e(event, Reflex::KeyEvent::DOWN);
372
+ int code = (int) event.keyCode;
373
+ if (event.isARepeat && code == repeating_key_code)
374
+ ++repeating_key_count;
375
+ else
376
+ {
377
+ repeating_key_code = code;
378
+ repeating_key_count = 0;
379
+ }
380
+
381
+ Reflex::NativeKeyEvent e(event, Reflex::KeyEvent::DOWN, repeating_key_count);
369
382
  Window_call_key_event(win, &e);
370
383
  }
371
384
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reflexion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-16 00:00:00.000000000 Z
11
+ date: 2026-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.3.13
47
+ version: 0.3.14
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.3.13
54
+ version: 0.3.14
55
55
  description: This library helps you to develop interactive graphical user interface.
56
56
  email: xordog@gmail.com
57
57
  executables: []