dataframe-textual 2.28.0__tar.gz → 2.29.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataframe-textual
3
- Version: 2.28.0
3
+ Version: 2.29.0
4
4
  Summary: Interactive terminal viewer/editor for tabular data
5
5
  Project-URL: Homepage, https://github.com/need47/dataframe-textual
6
6
  Project-URL: Repository, https://github.com/need47/dataframe-textual.git
@@ -154,7 +154,7 @@ dv data1.tsv < data2.tsv
154
154
 
155
155
  When multiple files are opened:
156
156
  - Each file appears as a separate tab. An Excel file may contain multiple tabs.
157
- - Switch between tabs using `>` (next) or `<` (previous), or use `b` for cycling through tabs
157
+ - Move the current tab with `>` (right, wrap to first) or `<` (left, wrap to last); use `b` to cycle tabs
158
158
  - Save current tab to file with `Ctrl+T`
159
159
  - Save all tabs to file with `Ctrl+A`
160
160
  - Duplicate the current tab with `Ctrl+D`
@@ -259,8 +259,8 @@ dv data-1.csv data-2.csv --all-in-one
259
259
 
260
260
  | Key | Action |
261
261
  | -------------- | ------------------------------------------------------------- |
262
- | `>` | Move to next tab |
263
- | `<` | Move to previous tab |
262
+ | `>` | Move current tab right (wrap to first) |
263
+ | `<` | Move current tab left (wrap to last) |
264
264
  | `b` | Cycle through tabs |
265
265
  | `B` | Toggle tab bar visibility |
266
266
  | `q` | Close current tab (prompts to save unsaved changes) |
@@ -115,7 +115,7 @@ dv data1.tsv < data2.tsv
115
115
 
116
116
  When multiple files are opened:
117
117
  - Each file appears as a separate tab. An Excel file may contain multiple tabs.
118
- - Switch between tabs using `>` (next) or `<` (previous), or use `b` for cycling through tabs
118
+ - Move the current tab with `>` (right, wrap to first) or `<` (left, wrap to last); use `b` to cycle tabs
119
119
  - Save current tab to file with `Ctrl+T`
120
120
  - Save all tabs to file with `Ctrl+A`
121
121
  - Duplicate the current tab with `Ctrl+D`
@@ -220,8 +220,8 @@ dv data-1.csv data-2.csv --all-in-one
220
220
 
221
221
  | Key | Action |
222
222
  | -------------- | ------------------------------------------------------------- |
223
- | `>` | Move to next tab |
224
- | `<` | Move to previous tab |
223
+ | `>` | Move current tab right (wrap to first) |
224
+ | `<` | Move current tab left (wrap to last) |
225
225
  | `b` | Cycle through tabs |
226
226
  | `B` | Toggle tab bar visibility |
227
227
  | `q` | Close current tab (prompts to save unsaved changes) |
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "dataframe-textual"
7
- version = "2.28.0"
7
+ version = "2.29.0"
8
8
  description = "Interactive terminal viewer/editor for tabular data"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -27,8 +27,8 @@ class DataFrameViewer(App):
27
27
  # 📊 DataFrame Viewer - App Controls
28
28
 
29
29
  ## ⚙️ File & Tab Management
30
- - **>** - ▶️ Next tab
31
- - **<** - ◀️ Previous tab
30
+ - **>** - ▶️ Move current tab right (wrap to first)
31
+ - **<** - ◀️ Move current tab left (wrap to last)
32
32
  - **b** - 🔄 Cycle through tabs
33
33
  - **B** - 👁️ Toggle tab bar visibility
34
34
  - **q** - ❌ Close current tab (prompts to save unsaved changes)
@@ -73,8 +73,9 @@ class DataFrameViewer(App):
73
73
  ("W", "save_all_tabs_overwrite", "Save All Tabs (overwrite)"),
74
74
  ("ctrl+d", "duplicate_tab", "Duplicate Tab"),
75
75
  ("k", "select_theme", "Select Theme"),
76
- ("greater_than_sign,b", "next_tab(1)", "Next Tab"), # '>' and 'b'
77
- ("less_than_sign", "next_tab(-1)", "Prev Tab"), # '<'
76
+ ("greater_than_sign", "move_tab(1)", "Move tab right"), # '>'
77
+ ("less_than_sign", "move_tab(-1)", "Move tab left"), # '<'
78
+ ("b", "next_tab(1)", "Next Tab"),
78
79
  ]
79
80
 
80
81
  CSS = """
@@ -357,6 +358,15 @@ class DataFrameViewer(App):
357
358
  """
358
359
  self.do_next_tab(offset)
359
360
 
361
+ def action_move_tab(self, offset: int = 1) -> None:
362
+ """Move the current tab left or right with wrap.
363
+
364
+ Args:
365
+ offset: Direction to move (+1 right, -1 left). Defaults to 1.
366
+ """
367
+
368
+ self.do_move_tab(offset)
369
+
360
370
  def do_next_tab(self, offset: int = 1) -> None:
361
371
  """Switch to the next tab or previous tab.
362
372
 
@@ -375,6 +385,49 @@ class DataFrameViewer(App):
375
385
  except (NoMatches, ValueError):
376
386
  pass
377
387
 
388
+ def do_move_tab(self, offset: int = 1) -> None:
389
+ """Move the active tab left or right with wrap.
390
+
391
+ Args:
392
+ offset: Direction to move (+1 right, -1 left). Defaults to 1.
393
+ """
394
+
395
+ if len(self.tabs) <= 1:
396
+ return
397
+
398
+ try:
399
+ tabs = list(self.tabs.keys())
400
+ active_pane = self.tabbed.active_pane
401
+ current_index = tabs.index(active_pane)
402
+
403
+ tabs.pop(current_index)
404
+ # len(tabs) is now len(self.tabs) - 1, but we want modulo len(self.tabs)
405
+ new_index = (current_index + offset) % (len(tabs) + 1)
406
+ tabs.insert(new_index, active_pane)
407
+
408
+ # Rebuild self.tabs to preserve new order
409
+ self.tabs = {pane: self.tabs[pane] for pane in tabs}
410
+
411
+ active_tab = self.tabbed.get_tab(active_pane.id)
412
+
413
+ if new_index == 0:
414
+ reference_pane = tabs[1]
415
+ reference_tab = self.tabbed.get_tab(reference_pane.id)
416
+ active_tab.parent.move_child(active_tab, before=reference_tab)
417
+ active_pane.parent.move_child(active_pane, before=reference_pane)
418
+ else:
419
+ reference_pane = tabs[new_index - 1]
420
+ reference_tab = self.tabbed.get_tab(reference_pane.id)
421
+ active_tab.parent.move_child(active_tab, after=reference_tab)
422
+ active_pane.parent.move_child(active_pane, after=reference_pane)
423
+
424
+ # Reset the active pane highlight visually
425
+ tabs_widget = self.query_one(ContentTabs)
426
+ self.call_after_refresh(lambda: tabs_widget._highlight_active())
427
+
428
+ except Exception as e:
429
+ self.log(f"Error moving tab: {e}")
430
+
378
431
  def action_toggle_tab_bar(self) -> None:
379
432
  """Toggle the tab bar visibility.
380
433
 
@@ -518,7 +518,7 @@ class FrequencyScreen(TableScreen):
518
518
  highlight_range=(0.0, percentage / 100 * 10),
519
519
  width=10,
520
520
  ),
521
- key=str(row_idx + 1),
521
+ label=str(row_idx + 1),
522
522
  )
523
523
 
524
524
  # Add a total row
@@ -538,7 +538,6 @@ class FrequencyScreen(TableScreen):
538
538
  highlight_range=(0.0, 10),
539
539
  width=10,
540
540
  ),
541
- key="total",
542
541
  )
543
542
 
544
543
  def sort_by_column(self, descending: bool) -> None:
@@ -9,8 +9,7 @@ from textual.widgets import OptionList
9
9
 
10
10
  class ThemeScreen(ModalScreen):
11
11
  BINDINGS = [
12
- ("q", "cancel", "Cancel"),
13
- ("escape", "cancel", "Cancel"),
12
+ ("q,escape", "cancel", "Cancel"),
14
13
  ]
15
14
 
16
15
  DEFAULT_CSS = """
@@ -21,9 +20,8 @@ class ThemeScreen(ModalScreen):
21
20
  #theme-container {
22
21
  width: 40;
23
22
  height: auto;
24
- padding: 0 1;
25
- border: solid $accent;
26
- border-title-color: $accent;
23
+ border: solid $primary;
24
+ border-title-color: $primary;
27
25
  }
28
26
 
29
27
  #theme-list {
@@ -34,7 +32,7 @@ class ThemeScreen(ModalScreen):
34
32
 
35
33
  def __init__(self) -> None:
36
34
  super().__init__()
37
- self.themes = list(BUILTIN_THEMES.keys())
35
+ self.themes = sorted(list(BUILTIN_THEMES.keys()))
38
36
  self.original_theme = self.app.theme
39
37
 
40
38
  def compose(self) -> ComposeResult:
@@ -36,8 +36,8 @@ class YMNScreen(ModalScreen):
36
36
  YMNScreen > Container {
37
37
  width: auto;
38
38
  height: auto;
39
- border: solid $accent;
40
- border-title-color: $accent;
39
+ border: solid $primary;
40
+ border-title-color: $primary;
41
41
  padding: 1 2;
42
42
  overflow: auto;
43
43
  }